]> git.cworth.org Git - apitrace/commitdiff
Merge remote-tracking branch 'github/master' into d2d
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 28 Sep 2012 07:40:24 +0000 (08:40 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Fri, 28 Sep 2012 07:40:24 +0000 (08:40 +0100)
Conflicts:
.gitignore
CMakeLists.txt
cmake/FindDirectX.cmake

459 files changed:
.gitignore
CMakeLists.txt [changed mode: 0755->0644]
DEVELOPMENT.markdown
INSTALL.markdown
LICENSE
NEWS.markdown
README.markdown
TODO.markdown
cgltrace.py [deleted file]
cli/CMakeLists.txt
cli/cli.hpp
cli/cli_diff.cpp
cli/cli_diff_images.cpp
cli/cli_diff_state.cpp
cli/cli_dump.cpp
cli/cli_dump_images.cpp [new file with mode: 0644]
cli/cli_main.cpp
cli/cli_pickle.cpp
cli/cli_repack.cpp
cli/cli_trace.cpp
cli/cli_trim.cpp
cmake/.gitignore [new file with mode: 0644]
cmake/FindDirectX.cmake
cmake/toolchain/android.toolchain.cmake [new file with mode: 0644]
codegen.py [deleted file]
common/formatter.hpp
common/image.hpp
common/image_png.cpp
common/image_pnm.cpp
common/json.hpp [deleted file]
common/os.hpp
common/os_binary.hpp [new file with mode: 0644]
common/os_posix.cpp
common/os_process.hpp
common/os_string.hpp
common/os_time.hpp
common/os_win32.cpp
common/pickle.hpp
common/trace_api.hpp
common/trace_dump.cpp
common/trace_file_zlib.cpp
common/trace_format.hpp
common/trace_model.cpp
common/trace_model.hpp
common/trace_parser.cpp
common/trace_parser.hpp
common/trace_parser_flags.cpp
common/trace_profiler.cpp [new file with mode: 0644]
common/trace_profiler.hpp [new file with mode: 0644]
common/trace_resource.cpp
common/trace_resource.hpp
common/trace_tools_trace.cpp
common/trace_writer.cpp
common/trace_writer.hpp
common/trace_writer_local.cpp
common/trace_writer_local.hpp
common/trace_writer_model.cpp
compat.h [deleted file]
d2d1trace.py [deleted file]
d2dimports.hpp [deleted file]
d3d10trace.py [deleted file]
d3d8trace.py [deleted file]
d3d9imports.hpp [deleted file]
d3d9trace.py [deleted file]
d3dshader.cpp [deleted file]
d3dshader.hpp [deleted file]
ddrawtrace.py [deleted file]
dispatch.py [deleted file]
dispatch/.gitignore [new file with mode: 0644]
dispatch/CMakeLists.txt [new file with mode: 0644]
dispatch/__init__.py [new file with mode: 0644]
dispatch/compat.h [new file with mode: 0644]
dispatch/d2dimports.hpp [new file with mode: 0644]
dispatch/d3d10_1imports.hpp [new file with mode: 0644]
dispatch/d3d10imports.hpp [new file with mode: 0644]
dispatch/d3d11imports.hpp [new file with mode: 0644]
dispatch/d3d9imports.hpp [new file with mode: 0644]
dispatch/d3derr.hpp [new file with mode: 0644]
dispatch/dispatch.py [new file with mode: 0644]
dispatch/eglimports.hpp [new file with mode: 0644]
dispatch/glimports.hpp [new file with mode: 0644]
dispatch/glproc.py [new file with mode: 0644]
dispatch/glproc_egl.cpp [new file with mode: 0644]
dispatch/glproc_gl.cpp [new file with mode: 0644]
dlltrace.py [deleted file]
dwritetrace.py [deleted file]
eglimports.hpp [deleted file]
egltrace.py [deleted file]
glcaps.cpp [deleted file]
glimports.hpp [deleted file]
glproc.py [deleted file]
glproc_egl.cpp [deleted file]
glproc_gl.cpp [deleted file]
glretrace.hpp [deleted file]
glretrace.py [deleted file]
glretrace_cgl.cpp [deleted file]
glretrace_egl.cpp [deleted file]
glretrace_glx.cpp [deleted file]
glretrace_main.cpp [deleted file]
glretrace_wgl.cpp [deleted file]
glsize.hpp [deleted file]
glstate.cpp [deleted file]
glstate.hpp [deleted file]
glstate.py [deleted file]
gltrace.hpp [deleted file]
gltrace.py [deleted file]
glws.cpp [deleted file]
glws.hpp [deleted file]
glws_cocoa.mm [deleted file]
glws_egl_xlib.cpp [deleted file]
glws_glx.cpp [deleted file]
glws_wgl.cpp [deleted file]
glxtrace.py [deleted file]
gui/CMakeLists.txt
gui/apicalldelegate.cpp
gui/apisurface.cpp
gui/apitrace.cpp
gui/apitrace.h
gui/apitracecall.cpp
gui/apitracecall.h
gui/apitracemodel.cpp
gui/apitracemodel.h
gui/calldurationgraph.h [new file with mode: 0644]
gui/graphing/frameaxiswidget.cpp [new file with mode: 0644]
gui/graphing/frameaxiswidget.h [new file with mode: 0644]
gui/graphing/graphaxiswidget.cpp [new file with mode: 0644]
gui/graphing/graphaxiswidget.h [new file with mode: 0644]
gui/graphing/graphing.h [new file with mode: 0644]
gui/graphing/graphlabelwidget.h [new file with mode: 0644]
gui/graphing/graphview.cpp [new file with mode: 0644]
gui/graphing/graphview.h [new file with mode: 0644]
gui/graphing/graphwidget.cpp [new file with mode: 0644]
gui/graphing/graphwidget.h [new file with mode: 0644]
gui/graphing/heatmapverticalaxiswidget.cpp [new file with mode: 0644]
gui/graphing/heatmapverticalaxiswidget.h [new file with mode: 0644]
gui/graphing/heatmapview.cpp [new file with mode: 0644]
gui/graphing/heatmapview.h [new file with mode: 0644]
gui/graphing/histogramview.cpp [new file with mode: 0644]
gui/graphing/histogramview.h [new file with mode: 0644]
gui/graphing/timeaxiswidget.cpp [new file with mode: 0644]
gui/graphing/timeaxiswidget.h [new file with mode: 0644]
gui/imageviewer.cpp
gui/imageviewer.h
gui/main.cpp
gui/mainwindow.cpp
gui/mainwindow.h
gui/profiledialog.cpp [new file with mode: 0644]
gui/profiledialog.h [new file with mode: 0644]
gui/profileheatmap.h [new file with mode: 0644]
gui/profiletablemodel.cpp [new file with mode: 0644]
gui/profiletablemodel.h [new file with mode: 0644]
gui/profiling.h [new file with mode: 0644]
gui/retracer.cpp
gui/retracer.h
gui/saverthread.cpp
gui/settingsdialog.cpp
gui/settingsdialog.h
gui/thumbnail.h [new file with mode: 0644]
gui/tracedialog.cpp
gui/tracedialog.h
gui/traceloader.cpp
gui/traceloader.h
gui/traceprocess.cpp
gui/traceprocess.h
gui/trimprocess.cpp [new file with mode: 0644]
gui/trimprocess.h [new file with mode: 0644]
gui/ui/imageviewer.ui
gui/ui/mainwindow.ui
gui/ui/profiledialog.ui [new file with mode: 0644]
gui/ui/profilereplaydialog.ui [new file with mode: 0644]
gui/ui/settings.ui
gui/ui/tracedialog.ui
helpers/d3dsize.hpp [new file with mode: 0644]
helpers/eglsize.cpp [new file with mode: 0644]
helpers/eglsize.hpp [new file with mode: 0644]
helpers/glsize.hpp [new file with mode: 0644]
retrace.cpp [deleted file]
retrace.hpp [deleted file]
retrace.py [deleted file]
retrace/.gitignore [new file with mode: 0644]
retrace/CMakeLists.txt [new file with mode: 0644]
retrace/d3dretrace.hpp [new file with mode: 0644]
retrace/d3dretrace.py [new file with mode: 0644]
retrace/d3dretrace_main.cpp [new file with mode: 0644]
retrace/d3dretrace_ws.cpp [new file with mode: 0644]
retrace/d3dstate.cpp [new file with mode: 0644]
retrace/d3dstate.hpp [new file with mode: 0644]
retrace/d3dstate_images.cpp [new file with mode: 0644]
retrace/dllretrace.py [new file with mode: 0644]
retrace/glretrace.hpp [new file with mode: 0644]
retrace/glretrace.py [new file with mode: 0644]
retrace/glretrace_cgl.cpp [new file with mode: 0644]
retrace/glretrace_egl.cpp [new file with mode: 0644]
retrace/glretrace_glx.cpp [new file with mode: 0644]
retrace/glretrace_main.cpp [new file with mode: 0755]
retrace/glretrace_wgl.cpp [new file with mode: 0644]
retrace/glretrace_ws.cpp [new file with mode: 0644]
retrace/glstate.cpp [new file with mode: 0644]
retrace/glstate.hpp [new file with mode: 0644]
retrace/glstate_images.cpp [new file with mode: 0644]
retrace/glstate_internal.hpp [new file with mode: 0644]
retrace/glstate_params.py [new file with mode: 0644]
retrace/glstate_shaders.cpp [new file with mode: 0644]
retrace/glws.cpp [new file with mode: 0644]
retrace/glws.hpp [new file with mode: 0644]
retrace/glws_cocoa.mm [new file with mode: 0644]
retrace/glws_egl_xlib.cpp [new file with mode: 0644]
retrace/glws_glx.cpp [new file with mode: 0644]
retrace/glws_wgl.cpp [new file with mode: 0644]
retrace/json.hpp [new file with mode: 0644]
retrace/retrace.cpp [new file with mode: 0644]
retrace/retrace.hpp [new file with mode: 0644]
retrace/retrace.py [new file with mode: 0644]
retrace/retrace_main.cpp [new file with mode: 0644]
retrace/retrace_stdc.cpp [new file with mode: 0644]
retrace/retrace_swizzle.cpp [new file with mode: 0644]
retrace/retrace_swizzle.hpp [new file with mode: 0644]
retrace_stdc.cpp [deleted file]
scripts/highlight.py
scripts/profileshader.py [new file with mode: 0755]
scripts/retracediff.py
scripts/snapdiff.py
scripts/tracediff.py [new file with mode: 0755]
scripts/tracediff.sh [deleted file]
scripts/tracediff2.py [new file with mode: 0755]
scripts/unpickle.py
specs/__init__.py
specs/cglapi.py
specs/d2d1.def [deleted file]
specs/d2d1.py
specs/d3d.py
specs/d3d10.def [deleted file]
specs/d3d10.py
specs/d3d10_1.def [deleted file]
specs/d3d10_1.py
specs/d3d10effect.py [new file with mode: 0644]
specs/d3d10misc.py
specs/d3d10sdklayers.py [new file with mode: 0644]
specs/d3d10shader.py [new file with mode: 0644]
specs/d3d11.py [new file with mode: 0644]
specs/d3d11_1.py [new file with mode: 0644]
specs/d3d11sdklayers.py [new file with mode: 0644]
specs/d3d11shader.py [new file with mode: 0644]
specs/d3d8.def [deleted file]
specs/d3d8.py
specs/d3d9.def [deleted file]
specs/d3d9.py
specs/d3d9caps.py
specs/d3d9types.py
specs/d3dcommon.py [new file with mode: 0644]
specs/ddraw.def [deleted file]
specs/ddraw.py
specs/dwrite.def [deleted file]
specs/dwrite.py
specs/dxgi.py
specs/dxgiformat.py
specs/dxgitype.py
specs/eglapi.py
specs/glapi.py
specs/glesapi.py
specs/glparams.py
specs/gltypes.py
specs/glxapi.py
specs/opengl32.def [deleted file]
specs/scripts/cdecl.py
specs/scripts/glspec.py
specs/stdapi.py
specs/wglapi.py
specs/winapi.py
thirdparty/glext/.gitignore [deleted file]
thirdparty/glext/GL/Makefile [deleted file]
thirdparty/glext/GL/glext.h [deleted file]
thirdparty/glext/GL/glext.sed [deleted file]
thirdparty/glext/GL/glxext.h [deleted file]
thirdparty/glext/GL/wglext.h [deleted file]
thirdparty/khr/EGL/egl.h [deleted file]
thirdparty/khr/EGL/eglext.h [deleted file]
thirdparty/khr/GLES/glext.h [deleted file]
thirdparty/khr/GLES2/gl2ext.h [deleted file]
thirdparty/khronos/.gitignore [new file with mode: 0644]
thirdparty/khronos/EGL/egl.h [new file with mode: 0644]
thirdparty/khronos/EGL/eglext.h [new file with mode: 0644]
thirdparty/khronos/EGL/eglplatform.h [new file with mode: 0644]
thirdparty/khronos/EGL/eglplatform.patch [new file with mode: 0644]
thirdparty/khronos/GL/gl.h [new file with mode: 0644]
thirdparty/khronos/GL/glext.h [new file with mode: 0644]
thirdparty/khronos/GL/glext.patch [new file with mode: 0644]
thirdparty/khronos/GL/glx.h [new file with mode: 0644]
thirdparty/khronos/GL/glxext.h [new file with mode: 0644]
thirdparty/khronos/GL/wglext.h [new file with mode: 0644]
thirdparty/khronos/GLES/gl.h [new file with mode: 0644]
thirdparty/khronos/GLES/glext.h [new file with mode: 0644]
thirdparty/khronos/GLES/glext.patch [new file with mode: 0644]
thirdparty/khronos/GLES/glplatform.h [new file with mode: 0644]
thirdparty/khronos/GLES2/gl2.h [new file with mode: 0644]
thirdparty/khronos/GLES2/gl2ext.h [new file with mode: 0644]
thirdparty/khronos/GLES2/gl2platform.h [new file with mode: 0644]
thirdparty/khronos/KHR/khrplatform.h [new file with mode: 0644]
thirdparty/khronos/Makefile [new file with mode: 0644]
thirdparty/khronos/README.markdown [new file with mode: 0644]
thirdparty/less.patch [new file with mode: 0644]
thirdparty/less/CMakeLists.txt [new file with mode: 0644]
thirdparty/less/COPYING [new file with mode: 0644]
thirdparty/less/INSTALL [new file with mode: 0644]
thirdparty/less/LICENSE [new file with mode: 0644]
thirdparty/less/NEWS [new file with mode: 0644]
thirdparty/less/README [new file with mode: 0644]
thirdparty/less/brac.c [new file with mode: 0644]
thirdparty/less/ch.c [new file with mode: 0644]
thirdparty/less/charset.c [new file with mode: 0644]
thirdparty/less/charset.h [new file with mode: 0644]
thirdparty/less/cmd.h [new file with mode: 0644]
thirdparty/less/cmdbuf.c [new file with mode: 0644]
thirdparty/less/command.c [new file with mode: 0644]
thirdparty/less/cvt.c [new file with mode: 0644]
thirdparty/less/decode.c [new file with mode: 0644]
thirdparty/less/defines.h.in [new file with mode: 0644]
thirdparty/less/defines.wn [new file with mode: 0644]
thirdparty/less/edit.c [new file with mode: 0644]
thirdparty/less/filename.c [new file with mode: 0644]
thirdparty/less/forwback.c [new file with mode: 0644]
thirdparty/less/funcs.h [new file with mode: 0644]
thirdparty/less/help.c [new file with mode: 0644]
thirdparty/less/ifile.c [new file with mode: 0644]
thirdparty/less/input.c [new file with mode: 0644]
thirdparty/less/jump.c [new file with mode: 0644]
thirdparty/less/less.h [new file with mode: 0644]
thirdparty/less/less.hlp [new file with mode: 0644]
thirdparty/less/lessecho.c [new file with mode: 0644]
thirdparty/less/lesskey.c [new file with mode: 0644]
thirdparty/less/lesskey.h [new file with mode: 0644]
thirdparty/less/lglob.h [new file with mode: 0644]
thirdparty/less/line.c [new file with mode: 0644]
thirdparty/less/linenum.c [new file with mode: 0644]
thirdparty/less/lsystem.c [new file with mode: 0644]
thirdparty/less/main.c [new file with mode: 0644]
thirdparty/less/mark.c [new file with mode: 0644]
thirdparty/less/mkhelp.c [new file with mode: 0644]
thirdparty/less/optfunc.c [new file with mode: 0644]
thirdparty/less/option.c [new file with mode: 0644]
thirdparty/less/option.h [new file with mode: 0644]
thirdparty/less/opttbl.c [new file with mode: 0644]
thirdparty/less/os.c [new file with mode: 0644]
thirdparty/less/output.c [new file with mode: 0644]
thirdparty/less/pattern.c [new file with mode: 0644]
thirdparty/less/pattern.h [new file with mode: 0644]
thirdparty/less/pckeys.h [new file with mode: 0644]
thirdparty/less/position.c [new file with mode: 0644]
thirdparty/less/position.h [new file with mode: 0644]
thirdparty/less/prompt.c [new file with mode: 0644]
thirdparty/less/regexp.c [new file with mode: 0644]
thirdparty/less/regexp.h [new file with mode: 0644]
thirdparty/less/screen.c [new file with mode: 0644]
thirdparty/less/scrsize.c [new file with mode: 0644]
thirdparty/less/search.c [new file with mode: 0644]
thirdparty/less/signal.c [new file with mode: 0644]
thirdparty/less/tags.c [new file with mode: 0644]
thirdparty/less/ttyin.c [new file with mode: 0644]
thirdparty/less/version.c [new file with mode: 0644]
thirdparty/libpng/ANNOUNCE
thirdparty/libpng/CHANGES
thirdparty/libpng/LICENSE
thirdparty/libpng/README
thirdparty/libpng/libpng.txt [deleted file]
thirdparty/libpng/png.c
thirdparty/libpng/png.h
thirdparty/libpng/pngconf.h
thirdparty/libpng/pngerror.c
thirdparty/libpng/pngget.c
thirdparty/libpng/pnginfo.h
thirdparty/libpng/pnglibconf.h
thirdparty/libpng/pngmem.c
thirdparty/libpng/pngpread.c
thirdparty/libpng/pngpriv.h
thirdparty/libpng/pngread.c
thirdparty/libpng/pngrtran.c
thirdparty/libpng/pngrutil.c
thirdparty/libpng/pngset.c
thirdparty/libpng/pngstruct.h
thirdparty/libpng/pngtrans.c
thirdparty/libpng/pngwrite.c
thirdparty/libpng/pngwtran.c
thirdparty/libpng/pngwutil.c
thirdparty/msvc/.gitignore [new file with mode: 0644]
thirdparty/msvc/Makefile [new file with mode: 0644]
thirdparty/snappy/ChangeLog
thirdparty/snappy/NEWS
thirdparty/snappy/README
thirdparty/snappy/format_description.txt
thirdparty/snappy/framing_format.txt [new file with mode: 0644]
thirdparty/snappy/snappy-sinksource.cc
thirdparty/snappy/snappy-sinksource.h
thirdparty/snappy/snappy-stubs-internal.h
thirdparty/snappy/snappy-stubs-public.h
thirdparty/snappy/snappy-test.cc
thirdparty/snappy/snappy-test.h
thirdparty/snappy/snappy.cc
thirdparty/snappy/snappy.h
thirdparty/snappy/snappy_unittest.cc
thirdparty/zlib/CMakeLists.txt
thirdparty/zlib/ChangeLog
thirdparty/zlib/README
thirdparty/zlib/adler32.c
thirdparty/zlib/crc32.c
thirdparty/zlib/crc32.h
thirdparty/zlib/deflate.c
thirdparty/zlib/deflate.h
thirdparty/zlib/example.c [deleted file]
thirdparty/zlib/gzguts.h
thirdparty/zlib/gzlib.c
thirdparty/zlib/gzread.c
thirdparty/zlib/gzwrite.c
thirdparty/zlib/infback.c
thirdparty/zlib/inffixed.h
thirdparty/zlib/inflate.c
thirdparty/zlib/inftrees.c
thirdparty/zlib/minigzip.c [deleted file]
thirdparty/zlib/trees.c
thirdparty/zlib/zconf.h
thirdparty/zlib/zlib.h
thirdparty/zlib/zutil.c
thirdparty/zlib/zutil.h
trace.py [deleted file]
wgltrace.py [deleted file]
wrappers/.gitignore [new file with mode: 0644]
wrappers/CMakeLists.txt [new file with mode: 0644]
wrappers/cgltrace.py [new file with mode: 0644]
wrappers/d2d1.def [new file with mode: 0644]
wrappers/d2d1trace.py [new file with mode: 0644]
wrappers/d3d10.def [new file with mode: 0644]
wrappers/d3d10_1.def [new file with mode: 0644]
wrappers/d3d10_1trace.py [new file with mode: 0644]
wrappers/d3d10shader.cpp [new file with mode: 0644]
wrappers/d3d10shader.hpp [new file with mode: 0644]
wrappers/d3d10trace.py [new file with mode: 0644]
wrappers/d3d11.def [new file with mode: 0644]
wrappers/d3d11trace.py [new file with mode: 0644]
wrappers/d3d8.def [new file with mode: 0644]
wrappers/d3d8trace.py [new file with mode: 0644]
wrappers/d3d9.def [new file with mode: 0644]
wrappers/d3d9shader.cpp [new file with mode: 0644]
wrappers/d3d9shader.hpp [new file with mode: 0644]
wrappers/d3d9trace.py [new file with mode: 0644]
wrappers/ddraw.def [new file with mode: 0644]
wrappers/ddrawtrace.py [new file with mode: 0644]
wrappers/dlltrace.py [new file with mode: 0644]
wrappers/dwrite.def [new file with mode: 0644]
wrappers/dwritetrace.py [new file with mode: 0644]
wrappers/egltrace.py [new file with mode: 0644]
wrappers/glcaps.cpp [new file with mode: 0644]
wrappers/gltrace.hpp [new file with mode: 0644]
wrappers/gltrace.py [new file with mode: 0644]
wrappers/gltrace_state.cpp [new file with mode: 0644]
wrappers/glxtrace.py [new file with mode: 0644]
wrappers/opengl32.def [new file with mode: 0644]
wrappers/trace.cpp [new file with mode: 0644]
wrappers/trace.hpp [new file with mode: 0644]
wrappers/trace.py [new file with mode: 0644]
wrappers/wgltrace.py [new file with mode: 0644]

index 89057b768b83236cf841158e9a38bd57888c211e..1e6d570ac1d9f2a8edcc6a7fbe4f91fb33325217 100644 (file)
@@ -30,22 +30,9 @@ CMakeFiles
 Makefile
 apitrace
 build
-cgltrace.cpp
-d2d1trace.cpp
-d3d10trace.cpp
-d3d8trace.cpp
-d3d9trace.cpp
-ddrawtrace.cpp
-dwritetrace.cpp
 dxsdk
-egltrace.cpp
 eglretrace
-glproc.hpp
 glretrace
-glretrace_gl.cpp
-glstate_params.cpp
-glxtrace.cpp
 install_manifest.txt
 qapitrace
 traces
-wgltrace.cpp
old mode 100755 (executable)
new mode 100644 (file)
index c87ef70..9fe2002
@@ -17,20 +17,28 @@ endif ()
 # prescribed in http://www.gentoo.org/proj/en/qa/automagic.xml
 set (ENABLE_GUI "AUTO" CACHE STRING "Enable Qt GUI.")
 
-set (ENABLE_EGL "AUTO" CACHE STRING "Enable EGL support.")
+set (ENABLE_CLI true CACHE BOOL "Enable command Line interface.")
+
+set (ENABLE_EGL true CACHE BOOL "Enable EGL support.")
 
 
 ##############################################################################
 # Find dependencies
 
-include (FindPkgConfig)
-
 set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 
 set (CMAKE_USE_PYTHON_VERSION 2.7 2.6)
 
-find_package (PythonInterp REQUIRED)
-find_package (OpenGL REQUIRED)
+if (ANDROID)
+    set (ENABLE_GUI false)
+else ()
+    macro (find_host_package)
+        find_package (${ARGN})
+    endmacro()
+endif ()
+
+find_host_package (PythonInterp REQUIRED)
+find_package (Threads)
 
 if (ENABLE_GUI)
     if (NOT (ENABLE_GUI STREQUAL "AUTO"))
@@ -40,11 +48,11 @@ if (ENABLE_GUI)
     find_package (QJSON ${REQUIRE_GUI})
 endif ()
 
-include_directories (${OPENGL_INCLUDE_DIR})
-
 if (WIN32)
     find_package (DirectX)
+    set (ENABLE_EGL false)
 elseif (APPLE)
+    set (ENABLE_EGL false)
 else ()
     find_package (X11)
 
@@ -52,19 +60,6 @@ else ()
         include_directories (${X11_INCLUDE_DIR})
         add_definitions (-DHAVE_X11)
     endif ()
-
-    if (ENABLE_EGL)
-        if (NOT ENABLE_EGL STREQUAL "AUTO")
-            set (REQUIRE_EGL REQUIRED)
-        endif ()
-        pkg_check_modules (EGL egl glesv1_cm glesv2 ${REQUIRE_EGL})
-        if (EGL_FOUND)
-            include_directories (${EGL_INCLUDE_DIR})
-            add_definitions (-DHAVE_EGL)
-        endif ()
-    else ()
-        set (EGL_FOUND 0)
-    endif ()
 endif ()
 
 
@@ -74,17 +69,14 @@ endif ()
 include (CheckCXXCompilerFlag)
 
 if (WIN32)
-    # MSVC & MinGW only define & use APIENTRY
-    add_definitions (-DGLAPIENTRY=__stdcall)
-
     # http://msdn.microsoft.com/en-us/library/aa383745.aspx
-    add_definitions (-D_WIN32_WINNT=0x0500 -DWINVER=0x0500)
+    add_definitions (-D_WIN32_WINNT=0x0601 -DWINVER=0x0601)
 else (WIN32)
     CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" CXX_COMPILER_FLAG_VISIBILITY)
     if (CXX_COMPILER_FLAG_VISIBILITY)
         add_definitions ("-fvisibility=hidden")
-    endif (CXX_COMPILER_FLAG_VISIBILITY)
-endif (WIN32)
+    endif ()
+endif ()
 
 if (MSVC)
     # C99 includes for msvc
@@ -100,13 +92,15 @@ if (MSVC)
     add_definitions (-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
     add_definitions (-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
     add_definitions (-W4)
+    # XXX: it's safer to use ssize_t everywhere instead of disabling warning
+    add_definitions (-wd4018) # signed/unsigned mismatch
     add_definitions (-wd4063) # not a valid value for switch of enum
+    add_definitions (-wd4100) # unreferenced formal parameter
     add_definitions (-wd4127) # conditional expression is constant
     add_definitions (-wd4244) # conversion from 'type1' to 'type2', possible loss of data
     add_definitions (-wd4505) # unreferenced local function has been removed
+    add_definitions (-wd4512) # assignment operator could not be generated
     add_definitions (-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
-    # XXX: it's safer to use ssize_t everywhere instead of disabling warning
-    add_definitions (-wd4018) # signed/unsigned mismatch
     
     # Use static runtime
     # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
@@ -116,13 +110,23 @@ if (MSVC)
     )
         if (${flag_var} MATCHES "/MD")
             string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
-        endif (${flag_var} MATCHES "/MD")
+        endif ()
     endforeach (flag_var)
 else ()
     # Adjust warnings
     add_definitions (-Wall)
     # XXX: it's safer to use ssize_t everywhere instead of disabling warning
     add_definitions (-Wno-sign-compare) # comparison between signed and unsigned integer expressions
+
+    # Use GDB extensions if available
+    if (CMAKE_COMPILER_IS_GNUC)
+        set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -O0")
+        set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb")
+    endif ()
+    if (CMAKE_COMPILER_IS_GNUCXX)
+        set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb -O0")
+        set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ggdb")
+    endif ()
 endif ()
 
 if (MINGW)
@@ -160,14 +164,12 @@ set (ZLIB_LIBRARIES z_bundled)
 add_subdirectory (thirdparty/zlib EXCLUDE_FROM_ALL)
 
 include_directories (${ZLIB_INCLUDE_DIRS})
-link_libraries (${ZLIB_LIBRARIES})
 
 set (SNAPPY_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/snappy)
 set (SNAPPY_LIBRARIES snappy_bundled)
 add_subdirectory (thirdparty/snappy EXCLUDE_FROM_ALL)
 
 include_directories (${SNAPPY_INCLUDE_DIRS})
-link_libraries (${SNAPPY_LIBRARIES})
 
 set (PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libpng)
 set (PNG_DEFINITIONS "")
@@ -176,7 +178,6 @@ set (PNG_LIBRARIES png_bundled)
 add_subdirectory (thirdparty/libpng EXCLUDE_FROM_ALL)
 include_directories (${PNG_INCLUDE_DIR})
 add_definitions (${PNG_DEFINITIONS})
-link_libraries (${PNG_LIBRARIES})
 
 if (MSVC)
     add_subdirectory (thirdparty/getopt EXCLUDE_FROM_ALL)
@@ -184,6 +185,10 @@ if (MSVC)
     set (GETOPT_LIBRARIES getopt_bundled)
 endif ()
 
+if (WIN32)
+    add_subdirectory (thirdparty/less)
+endif ()
+
 # The Qt website provides binaries for Windows and MacOSX, and they are
 # automatically found by cmake without any manual intervention.  The situation
 # for QJSON is substantially different: there are no binaries for QJSON
@@ -201,36 +206,43 @@ if (QT4_FOUND AND NOT QJSON_FOUND AND (ENABLE_GUI STREQUAL "AUTO"))
     set (QJSON_FOUND TRUE)
 endif ()
 
-# For glext headers.  Needs to be before system includes as often system's GL
-# headers bundle and include glext.h and glxext.h
-include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glext)
+# We use bundled headers for all Khronos APIs, to guarantee support for both
+# OpenGL and OpenGL ES at build time, because the OpenGL and OpenGL ES 1 APIs
+# are so intertwined that conditional compilation extremely difficult. This
+# also avoids missing/inconsistent declarations in system headers.
+include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/khronos)
 
-# For EGL headers
-include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/khr)
 
 ##############################################################################
 # Installation directories
 
+if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+    # Debian multiarch support
+    execute_process(COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
+        OUTPUT_VARIABLE ARCH_SUBDIR
+        ERROR_QUIET
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+endif()
+
 if (WIN32 OR APPLE)
     # On Windows/MacOSX, applications are usually installed on a directory of
     # their own
     set (DOC_INSTALL_DIR doc)
+    set (LIB_INSTALL_DIR lib)
+    set (LIB_ARCH_INSTALL_DIR lib)
 else ()
     set (DOC_INSTALL_DIR share/doc/${CMAKE_PROJECT_NAME})
+    set (LIB_INSTALL_DIR lib/${CMAKE_PROJECT_NAME})
+    if (ARCH_SUBDIR)
+        set (LIB_ARCH_INSTALL_DIR lib/${ARCH_SUBDIR}/${CMAKE_PROJECT_NAME})
+    else ()
+        set (LIB_ARCH_INSTALL_DIR lib/${CMAKE_PROJECT_NAME})
+    endif ()
 endif ()
 
-set (LIB_INSTALL_DIR lib/apitrace)
-
-if (APPLE)
-    # MacOSX uses fat binaries, so no need to have per-architecture wrapper
-    # directories
-    set (LIB_ARCH_INSTALL_DIR ${LIB_INSTALL_DIR})
-else ()
-    set (LIB_ARCH_INSTALL_DIR ${LIB_INSTALL_DIR}/${CMAKE_SYSTEM_PROCESSOR})
-endif ()
-
-set(SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
-set(WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
+set (SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
+set (WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
 
 # Expose the binary/install directories to source
 #
@@ -240,7 +252,8 @@ set(WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
 add_definitions(
     -DAPITRACE_BINARY_DIR="${CMAKE_BINARY_DIR}"
     -DAPITRACE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
-    -DAPITRACE_WRAPPER_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
+    -DAPITRACE_SCRIPTS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTS_INSTALL_DIR}"
+    -DAPITRACE_WRAPPERS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
 )
 
 
@@ -253,17 +266,6 @@ include_directories (
     ${CMAKE_CURRENT_SOURCE_DIR}/common
 )
 
-add_custom_command (
-    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
-    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
-    DEPENDS glproc.py dispatch.py specs/wglapi.py specs/glxapi.py specs/cglapi.py specs/eglapi.py specs/glesapi.py specs/glapi.py specs/gltypes.py specs/stdapi.py
-)
-
-# Wrap glproc.hpp as a target to prevent the command from being executed
-# multiple times simulatenously, when the targets that depend on it are built
-# in parallel.
-add_custom_target (glproc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
-
 if (WIN32)
     set (os os_win32.cpp)
     set (glws_os glws_wgl.cpp)
@@ -293,6 +295,7 @@ add_library (common STATIC
     common/trace_loader.cpp
     common/trace_resource.cpp
     common/trace_tools_trace.cpp
+    common/trace_profiler.cpp
     common/image.cpp
     common/image_bmp.cpp
     common/image_pnm.cpp
@@ -306,362 +309,32 @@ set_target_properties (common PROPERTIES
     COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
 )
 
-link_libraries (common)
-
-
-##############################################################################
-# API tracers
-
-if (WIN32)
-    if (MINGW)
-        # Silence warnings about @nn suffix mismatch
-        set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--enable-stdcall-fixup")
-    endif (MINGW)
-
-    # ddraw.dll
-    if (DirectX_D3D_INCLUDE_DIR)
-        include_directories (SYSTEM ${DirectX_D3D_INCLUDE_DIR})
-        add_custom_command (
-            OUTPUT ddrawtrace.cpp
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp
-            DEPENDS ddrawtrace.py trace.py specs/d3d.py specs/d3dtypes.py specs/d3dcaps.py specs/ddraw.py specs/winapi.py specs/stdapi.py
-        )
-        add_library (ddraw MODULE specs/ddraw.def ddrawtrace.cpp)
-        set_target_properties (ddraw
-            PROPERTIES PREFIX ""
-            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-            LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        )
-        install (TARGETS ddraw LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-    endif (DirectX_D3D_INCLUDE_DIR)
-
-    # d3d8.dll
-    if (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3DX9_INCLUDE_DIR)
-        include_directories (SYSTEM ${DirectX_D3D8_INCLUDE_DIR} ${DirectX_D3DX9_INCLUDE_DIR})
-        add_custom_command (
-            OUTPUT d3d8trace.cpp
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp
-            DEPENDS d3d8trace.py trace.py specs/d3d8.py specs/d3d8types.py specs/d3d8caps.py specs/winapi.py specs/stdapi.py
-        )
-        add_library (d3d8 MODULE specs/d3d8.def d3d8trace.cpp d3dshader.cpp)
-        set_target_properties (d3d8
-            PROPERTIES PREFIX ""
-            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-            LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        )
-        install (TARGETS d3d8 LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-    endif (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3DX9_INCLUDE_DIR)
-
-    # d3d9.dll
-    if (DirectX_D3DX9_INCLUDE_DIR)
-        include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR})
-        add_custom_command (
-            OUTPUT d3d9trace.cpp
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp
-            DEPENDS d3d9trace.py trace.py specs/d3d9.py specs/d3d9types.py specs/d3d9caps.py specs/winapi.py specs/stdapi.py
-        )
-        add_library (d3d9 MODULE specs/d3d9.def d3d9trace.cpp d3dshader.cpp)
-        set_target_properties (d3d9
-            PROPERTIES PREFIX ""
-            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-            LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        )
-        install (TARGETS d3d9 LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-    endif (DirectX_D3DX9_INCLUDE_DIR)
-
-    # d3d10.dll
-    if (DirectX_D3D10_INCLUDE_DIR)
-        include_directories (SYSTEM ${DirectX_D3D10_INCLUDE_DIR})
-        add_custom_command (
-            OUTPUT d3d10trace.cpp
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10trace.cpp
-            DEPENDS d3d10trace.py trace.py specs/d3d10misc.py specs/d3d10.py specs/dxgi.py specs/dxgitype.py specs/dxgiformat.py specs/winapi.py specs/stdapi.py
-        )
-        add_library (d3d10 MODULE specs/d3d10.def d3d10trace.cpp)
-        set_target_properties (d3d10
-            PROPERTIES PREFIX ""
-            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-            LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        )
-        install (TARGETS d3d10 LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-    endif (DirectX_D3D10_INCLUDE_DIR)
-
-    # d2d1.dll, dwrite.dll
-    if (DirectX_D2D1_INCLUDE_DIR)
-        include_directories (SYSTEM ${DirectX_D2D1_INCLUDE_DIR})
-
-        add_custom_command (
-            OUTPUT d2d1trace.cpp
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp
-            DEPENDS d2d1trace.py trace.py specs/d2d1.py specs/d2d1.py specs/d2dbasetypes.py specs/d2derr.py specs/dwrite.py specs/dcommon.py specs/dxgi.py specs/dxgitype.py specs/dxgiformat.py specs/winapi.py specs/stdapi.py
-        )
-        add_library (d2d1 MODULE specs/d2d1.def d2d1trace.cpp)
-        set_target_properties (d2d1
-            PROPERTIES PREFIX ""
-            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-            LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        )
-        install (TARGETS d2d1 LIBRARY DESTINATION wrappers)
-
-        add_custom_command (
-            OUTPUT dwritetrace.cpp
-            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dwritetrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dwritetrace.cpp
-            DEPENDS dwritetrace.py trace.py specs/d2d1.py specs/d2d1.py specs/d2dbasetypes.py specs/d2derr.py specs/dwrite.py specs/dcommon.py specs/dxgi.py specs/dxgitype.py specs/dxgiformat.py specs/winapi.py specs/stdapi.py
-        )
-        add_library (dwrite MODULE specs/dwrite.def dwritetrace.cpp)
-        set_target_properties (dwrite
-            PROPERTIES PREFIX ""
-            RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-            LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        )
-        install (TARGETS dwrite LIBRARY DESTINATION wrappers)
-    endif (DirectX_D2D1_INCLUDE_DIR)
-
-    # opengl32.dll
-    add_custom_command (
-        OUTPUT wgltrace.cpp
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
-        DEPENDS wgltrace.py gltrace.py trace.py specs/wglapi.py specs/wglenum.py specs/glapi.py specs/glparams.py specs/gltypes.py specs/winapi.py specs/stdapi.py
-    )
-    add_library (wgltrace MODULE specs/opengl32.def
-        wgltrace.cpp
-        glcaps.cpp
-        glproc_gl.cpp
-    )
-    add_dependencies (wgltrace glproc)
-    set_target_properties (wgltrace PROPERTIES
-        PREFIX ""
-        OUTPUT_NAME opengl32
-        RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-    )
-    install (TARGETS wgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-
-elseif (APPLE)
-    # OpenGL framework
-    add_custom_command (
-        OUTPUT cgltrace.cpp
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp
-        DEPENDS cgltrace.py gltrace.py trace.py specs/cglapi.py specs/glapi.py specs/glparams.py specs/gltypes.py specs/stdapi.py
-    )
-
-    add_library (cgltrace SHARED
-        cgltrace.cpp
-        glcaps.cpp
-        glproc_gl.cpp
-    )
-
-    add_dependencies (cgltrace glproc)
-
-    set_target_properties (cgltrace PROPERTIES
-        # OpenGL framework name
-        PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
-        # Specificy the version and reexport GLU symbols
-        LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
-        RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-    )
-
-    target_link_libraries (cgltrace
-        pthread
-        dl
-    )
-
-    install (TARGETS cgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-elseif (X11_FOUND)
-    # libGL.so
-    add_custom_command (
-        OUTPUT glxtrace.cpp
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
-        DEPENDS glxtrace.py gltrace.py trace.py specs/glxapi.py specs/glapi.py specs/glparams.py specs/gltypes.py specs/stdapi.py
-    )
-
-    add_library (glxtrace SHARED
-        glxtrace.cpp
-        glcaps.cpp
-        glproc_gl.cpp
-    )
-
-    add_dependencies (glxtrace glproc)
-
-    set_target_properties (glxtrace PROPERTIES
-        # avoid the default "lib" prefix
-        PREFIX ""
-        # Prevent symbol relocations internal to our wrapper library to be
-        # overwritten by the application.
-        LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
-        RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-    )
-
-    target_link_libraries (glxtrace
-        ${X11_X11_LIB}
-        pthread
-        dl
-    )
-
-    install (TARGETS glxtrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+if (ANDROID)
+    target_link_libraries (common log)
 endif ()
 
 
-if (EGL_FOUND)
-    # libEGL.so/libGL.so
-    add_custom_command (
-        OUTPUT egltrace.cpp
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp
-        DEPENDS egltrace.py gltrace.py trace.py specs/eglapi.py specs/glesapi.py specs/glapi.py specs/glparams.py specs/gltypes.py specs/stdapi.py
-    )
-
-    add_library (egltrace SHARED
-        egltrace.cpp
-        glcaps.cpp
-        glproc_egl.cpp
-    )
-
-    add_dependencies (egltrace glproc)
-
-    set_property (
-        TARGET egltrace
-        APPEND
-        PROPERTY COMPILE_DEFINITIONS "TRACE_EGL"
-    )
-
-    set_target_properties (egltrace PROPERTIES
-        # avoid the default "lib" prefix
-        PREFIX ""
-        LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
-        # Prevent symbol relocations internal to our wrapper library to be
-        # overwritten by the application.
-        RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-        LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/wrappers
-    )
-
-    target_link_libraries (egltrace
-        pthread
-        dl
-    )
-
-    install (TARGETS egltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
-endif ()
-
 ##############################################################################
-# API retracers
-
-add_custom_command (
-    OUTPUT glretrace_gl.cpp
-    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
-    DEPENDS glretrace.py retrace.py specs/glapi.py specs/gltypes.py specs/stdapi.py
-)
+# Sub-directories
 
-add_custom_command (
-    OUTPUT glstate_params.cpp
-    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp
-    DEPENDS glstate.py specs/glparams.py specs/gltypes.py specs/stdapi.py
-)
-
-set (retrace_sources
-    glretrace_gl.cpp
-    glretrace_cgl.cpp
-    glretrace_glx.cpp
-    glretrace_wgl.cpp
-    glretrace_egl.cpp
-    glretrace_main.cpp
-    glstate.cpp
-    glstate_params.cpp
-    retrace.cpp
-    retrace_stdc.cpp
-    glws.cpp
-)
+add_subdirectory (dispatch)
+add_subdirectory (wrappers)
+add_subdirectory (retrace)
 
-if (WIN32 OR APPLE OR X11_FOUND)
-    add_executable (glretrace
-        ${retrace_sources}
-        ${glws_os}
-        glproc_gl.cpp
-    )
-
-    add_dependencies (glretrace glproc)
-
-    set_property (
-        TARGET glretrace
-        APPEND
-        PROPERTY COMPILE_DEFINITIONS "RETRACE"
-    )
-
-    target_link_libraries (glretrace
-        common
-    )
-
-    if (WIN32)
-    else ()
-        if (APPLE)
-            target_link_libraries (glretrace
-                "-framework Cocoa"
-                "-framework ApplicationServices" # CGS*
-                ${OPENGL_gl_LIBRARY} # CGL*
-            )
-        else ()
-            target_link_libraries (glretrace ${X11_X11_LIB})
-        endif ()
-
-        target_link_libraries (glretrace
-            # gdb doesn't like when pthreads is loaded through dlopen (which happens
-            # when dlopen'ing libGL), so link pthreads to avoid this issue.  See also
-            # http://stackoverflow.com/questions/2702628/gdb-cannot-find-new-threads-generic-error
-            pthread
-            dl
-        )
-
-        if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-            target_link_libraries (glretrace rt)
-        endif ()
-
-    endif ()
-
-    install (TARGETS glretrace RUNTIME DESTINATION bin) 
-endif ()
-
-if (EGL_FOUND AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
-    add_executable (eglretrace
-        ${retrace_sources}
-        glws_egl_xlib.cpp
-        glproc_egl.cpp
-    )
-
-    add_dependencies (eglretrace glproc)
-
-    set_property (
-        TARGET eglretrace
-        APPEND
-        PROPERTY COMPILE_DEFINITIONS "RETRACE"
-        PROPERTY COMPILE_DEFINITIONS "TRACE_EGL"
-    )
-
-    target_link_libraries (eglretrace
-        common
-        ${X11_X11_LIB}
-        pthread
-        dl
-    )
-
-    if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-        target_link_libraries (eglretrace rt)
-    endif ()
-
-    install (TARGETS eglretrace RUNTIME DESTINATION bin) 
-endif ()
 
 ##############################################################################
 # CLI
 
-add_subdirectory(cli)
+if (ENABLE_CLI)
+    add_subdirectory(cli)
+endif ()
 
 ##############################################################################
 # Scripts (to support the CLI)
 
 install (
     PROGRAMS
-        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/tracediff.sh
+        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/tracediff.py
         ${CMAKE_CURRENT_SOURCE_DIR}/scripts/jsondiff.py
         ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snapdiff.py
     DESTINATION ${SCRIPTS_INSTALL_DIR}
@@ -684,11 +357,10 @@ install (
         LICENSE
         NEWS.markdown
         README.markdown
-        TODO.markdown
     DESTINATION ${DOC_INSTALL_DIR}
 )
 
-set (CPACK_PACKAGE_VERSION_MAJOR "2")
+set (CPACK_PACKAGE_VERSION_MAJOR "3")
 set (CPACK_PACKAGE_VERSION_MINOR "0")
 
 # Use current date in YYYYMMDD format as patch number 
@@ -697,6 +369,13 @@ execute_process (
     OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH
 )
 
+# cpack mistakenly detects Mingw-w64 as win32
+if (MINGW)
+    if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+        set (CPACK_SYSTEM_NAME win64)
+    endif ()
+endif ()
+
 # See http://www.vtk.org/Wiki/CMake:CPackPackageGenerators
 if (WIN32)
     set (CPACK_GENERATOR "ZIP")
index 5d2c052bff63fb6d5aca2ed9cda175ebf49091eb..5af6ed697e3962328fa280d68572fdb392141475 100644 (file)
@@ -1,8 +1,8 @@
 Coding Style
 ============
 
-XXX: These are mostly guidelines for new code, as some of existing hasn't been
-updated to these conventions yet.
+These are guidelines for new code.  Some of existing hasn't been updated to
+these conventions yet.
 
 Whitespace (all languages):
 
@@ -24,6 +24,9 @@ Naming convention:
 
  * `UPPER_CASE` for #defines
 
+ * single underscore prefix for variables/functions in automatically generated
+   code
+
 C++:
 
  * enclose single statement `if` clauses in { }, specially for automatically
@@ -35,7 +38,7 @@ C++:
 
 CMake:
 
- * `lower_case`
+ * `lower_case` commands
 
  * space between ( and precedent name
 
index e6cfb6116af5b0c2817ebbf491c56f372a371cfd..94e2d631cc0a8450e37cd1a04fd65209afe2e427 100644 (file)
@@ -20,8 +20,8 @@ The GUI also dependends on:
 
 * QJSON version 0.5 or higher (tested with version 0.7.1, which is bundled)
 
-Qt and QJSON will be required if `-DENABLE_GUI=TRUE` is passed to `cmake`, and
-never used if `-DENABLED_GUI=FALSE` is passed instead.  The implicit default is
+Qt and QJSON will be required if `-DENABLE_GUI=TRUE` is passed to CMake, and
+never used if `-DENABLE_GUI=FALSE` is passed instead.  The implicit default is
 `-DENABLE_GUI=AUTO`, which will build the GUI if Qt is available, using the
 bundled QJSON if it is not found on the system.
 
@@ -43,29 +43,54 @@ Build as:
 You can also build the 32bit GL wrapper on 64bit distro with a multilib gcc by
 doing:
 
-    cmake -H. -Bbuild32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_EXE_LINKER_FLAGS=-m32 -DENABLE_GUI=FALSE
+    cmake \
+        -DCMAKE_C_FLAGS=-m32 \
+        -DCMAKE_CXX_FLAGS=-m32 \
+        -DCMAKE_EXE_LINKER_FLAGS=-m32 \
+        -DCMAKE_SYSTEM_LIBRARY_PATH=/usr/lib32 \
+        -DENABLE_GUI=FALSE \
+        -H. -Bbuild32
     make -C build32 glxtrace
 
+Android
+-------
+
+Additional requirements:
+
+* [Android NDK](http://developer.android.com/sdk/ndk/index.html)
+
+Build as:
+
+    export ANDROID_NDK=/path/to/your/ndk
+    cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/android.toolchain.cmake -DANDROID_API_LEVEL=9 -H. -Bbuild
+    make -C build
 
 Windows
 -------
 
 Additional requirements:
 
-* Microsoft Visual Studio (tested with 2008 version) or MinGW (tested with gcc version 4.4)
+* For Direct3D 11.1 support:
+
+  * [Microsoft Visual Studio 11 Ultimate Beta](http://www.microsoft.com/download/en/details.aspx?id=27543)
+
+* Other:
+
+  * Microsoft Visual Studio (tested with 2010 version) or MinGW (tested with
+    mingw-w64's gcc version 4.6.2)
 
-* Microsoft DirectX SDK:
+  * [Microsoft DirectX SDK](http://msdn.microsoft.com/en-us/directx/aa937781):
 
-  * for D3D10 support the [latest](http://msdn.microsoft.com/en-us/directx/default.aspx) is
-    recommended.
+    * for D3D 10, 10.1, and 11 support the [June 2010 release](http://www.microsoft.com/en-us/download/details.aspx?id=6812) is
+      recommended.
 
-  * for DDRAW, D3D7, D3D8 support the [August 2007 release](http://www.microsoft.com/downloads/details.aspx?familyid=529F03BE-1339-48C4-BD5A-8506E5ACF571)
-    or earlier is required, as later releases do not include the necessary
-    headers.
+    * for D3D7, D3D8 support the [August 2007 release](http://www.microsoft.com/downloads/details.aspx?familyid=529F03BE-1339-48C4-BD5A-8506E5ACF571)
+      or earlier is required, as later releases do not include the necessary
+      headers.
 
 To build with Visual Studio first invoke CMake GUI as:
 
-    cmake-gui -H. -B%cd%\build
+    cmake-gui -H%cd% -B%cd%\build
 
 and press the _Configure_ button.
 
@@ -74,14 +99,14 @@ not found automatically, you can manually specify the location of the
 dependencies from the CMake GUI.
 
 After you've successfully configured, you can start the build by opening the
-generated `build\apitrace.sln` solution file, or invoking `cmake` as:
+generated `build\apitrace.sln` solution file, or invoking CMake as:
 
     cmake --build build --config MinSizeRel
 
-The steps to build 64bit version are similar, but choosing _Visual Studio 9
-2008 Win64_ instead of _Visual Studio 9 2008_.
+The steps to build 64bit version are similar, but choosing _Visual Studio 10
+Win64_ instead of _Visual Studio 10_.
 
-It's also possible to instruct `cmake` build Windows binaries on Linux with
+It's also possible to instruct CMake build Windows binaries on Linux with
 [MinGW cross compilers](http://www.cmake.org/Wiki/CmakeMingw).
 
 
diff --git a/LICENSE b/LICENSE
index 29598650db97a8aed201c678a1675643f0b19ab9..d0cf6d2cc800068817a5e5fb011281881cff9ae3 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,9 @@
-Copyright 2011 Jose Fonseca, Zack Rusin
-Copyright 2008-2010 VMware, Inc.
+Copyright 2007-2012 VMware, Inc.
+Copyright 2011 Intel Corporation
+Copyright 2011 LunarG, Inc.
+Copyright 2011 Zack Rusin
+Copyright 2011-2012 Jose Fonseca
+
 All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -20,4 +24,3 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
-
index 29ca6198c5b962b3d9c6984961831f9710876b39..53a3f0f3d64208af0bb73bcad49ce7368451cd8d 100644 (file)
@@ -1,13 +1,31 @@
-This file lists the major user visible improvments.  For a full list of changes
+This file lists the major user visible improvements.  For a full list of changes
 and their authors see the git history.
 
 
 Development
 ===========
 
+* Support to trace in Android.
+
+* Show frame thumbnails in the GUI.
+
+* Basic D3D 10.1, 11, and 11.1 trace support.
+
+
+Version 3.0
+===========
+
 * Top-level `apitrace` command.
 
-* Trace and retrace support for EGL, GLES1, and GLES2 APIs.
+* Trace and retrace support for EGL, GLES1, and GLES2 APIs on Linux.
+
+* Ability to trim traces.
+
+* Basic CPU profiling when retracing.
+
+* Basic D3D10 trace support.
+
+* Many bugfixes.
 
 
 Version 2.0
index 38dfa5e21c357ae47a9187ded3d786b895a9dee4..b59ee3bef506501b69d0ce4dc6e976345f3c8a43 100644 (file)
@@ -3,7 +3,7 @@ About **apitrace**
 
 **apitrace** consists of a set of tools to:
 
-* trace OpenGL, OpenGL ES, D3D9, D3D8, D3D7, and DDRAW APIs calls to a file;
+* trace OpenGL, OpenGL ES, Direct3D, and DirectDraw APIs calls to a file;
 
 * retrace OpenGL and OpenGL ES calls from a file;
 
@@ -12,24 +12,38 @@ About **apitrace**
 * visualize and edit trace files.
 
 
-Basic usage
-===========
+Obtaining **apitrace**
+======================
 
+To obtain apitrace either [download the latest
+binaries](https://github.com/apitrace/apitrace/downloads) for your platform if
+available, or follow the instructions in INSTALL.markdown to build it yourself.
+On 64bits Linux and Windows platforms you'll need apitrace binaries that match
+the architecture (32bits or 64bits) of the application being traced.
 
-Linux and Mac OS X
-------------------
+
+Basic usage
+===========
 
 Run the application you want to trace as
 
-    apitrace trace /path/to/application [args...]
+    apitrace trace --api API /path/to/application [args...]
 
 and it will generate a trace named `application.trace` in the current
-directory.  You can specify the written trace filename by setting the
-`TRACE_FILE` environment variable before running.
+directory.  You can specify the written trace filename by passing the
+`--output` command line option.
+
+Problems while tracing (e.g, if the application uses calls/parameters
+unsupported by apitrace) will be reported via stderr output on Unices.  On
+Windows you'll need to run
+[DebugView](http://technet.microsoft.com/en-us/sysinternals/bb896647) to view
+these messages.
+
+Follow the "Tracing manually" instructions below if you cannot obtain a trace.
 
 View the trace with
 
-    apitrace dump --color application.trace
+    apitrace dump application.trace
 
 Replay an OpenGL trace with
 
@@ -38,26 +52,17 @@ Replay an OpenGL trace with
 Pass the `-sb` option to use a single buffered visual.  Pass `--help` to
 glretrace for more options.
 
-Start the GUI as
-
-    qapitrace application.trace
-
-
-Windows
--------
 
-* Copy `opengl32.dll`, `d3d8.dll`, or `d3d9.dll` from build/wrappers directory
-  to the directory with the application you want to trace.
+Basic GUI usage
+===============
 
-* Run the application.
-
-* View the trace with
+Start the GUI as
 
-        \path\to\apitrace dump application.trace
+    qapitrace application.trace
 
-* Replay the trace with
+You can also tell the GUI to go directly to a specific call
 
-        \path\to\glretrace application.trace
+    qapitrace application.trace 12345
 
 
 Advanced command line usage
@@ -97,6 +102,14 @@ Tracing manually
 
 ### Linux ###
 
+On 64 bits systems, you'll need to determine ether the application is 64 bits
+or 32 bits.  This can be done by doing
+
+    file /path/to/application
+
+But beware of wrapper shell scripts -- what matters is the architecture of the
+main process.
+
 Run the application you want to trace as
 
      LD_PRELOAD=/path/to/apitrace/wrappers/glxtrace.so /path/to/application
@@ -128,6 +141,63 @@ To trace the application inside gdb, invoke gdb as:
 
     gdb --ex 'set exec-wrapper env LD_PRELOAD=/path/to/glxtrace.so' --args /path/to/application
 
+### Android ###
+
+The following instructions should work at least for Android Ice Scream
+Sandwitch:
+
+For standalone applications the instructions above for Linux should
+work. To trace applications started from within the Android VM process
+(`app_process` aka zygote) you'll have to wrap this process and enable
+tracing dynamically for the application to be traced.
+
+- Wrapping the android main VM process:
+
+  In the Android root /init.rc add the `LD_PRELOAD` setting to zygote's
+  environment in the 'service zygote' section:
+
+        service zygote ...
+           setenv LD_PRELOAD /data/egltrace.so
+           ...
+
+  Note that ICS will overwrite the /init.rc during each boot with the
+  version in the recovery image. So you'll have to change the file in
+  your ICS source tree, rebuild and reflash the device.
+  Rebuilding/reflashing only the recovery image should be sufficient.
+
+- Copy egltrace.so to /data
+
+  On the host:
+
+        adb push /path/to/apitrace/build/wrappers/egltrace.so /data
+
+- Adjust file permissions to store the trace file:
+
+  By default egltrace.so will store the trace in
+  `/data/app_process.trace`. For this to work for applications running
+  with a uid other than 0, you have to allow writes to the `/data`
+  directory on the device:
+
+        chmod 0777 /data
+
+- Enable tracing for a specific process name:
+
+  To trace for example the Settings application:
+
+        setprop debug.apitrace.procname com.android.settings
+
+  In general this name will match what `ps` reports.
+
+- Start the application:
+
+  If the application was already running, for example due to ICS's way
+  of pre-starting the apps, you might have to kill the application
+  first:
+
+        kill <pid of app>
+
+  Launch the application for example from the application menu.
+
 ### Mac OS X ###
 
 Run the application you want to trace as
@@ -139,11 +209,35 @@ Note that although Mac OS X has an `LD_PRELOAD` equivalent,
 `DYLD_FORCE_FLAT_NAMESPACE=1` which breaks most applications.  See the `dyld` man
 page for more details about these environment flags.
 
+### Windows ###
+
+When tracing third-party applications, you can identify the target
+application's main executable, either by:
+
+* right clicking on the application's icon in the _Start Menu_, choose
+  _Properties_, and see the _Target_ field;
+
+* or by starting the application, run Windows Task Manager (taskmgr.exe), right
+  click on the application name in the _Applications_ tab, choose _Go To Process_,
+  note the highlighted _Image Name_, and search it on `C:\Program Files` or
+  `C:\Program Files (x86)`.
+
+On 64 bits Windows, you'll need to determine ether the application is a 64 bits
+or 32 bits. 32 bits applications will have a `*32` suffix in the _Image Name_
+column of the _Processes_ tab of _Windows Task Manager_ window.
+
+Copy the appropriate `opengl32.dll`, `d3d8.dll`, or `d3d9.dll` from the
+wrappers directory to the directory with the application you want to trace.
+Then run the application as usual.
+
+You can specify the written trace filename by setting the `TRACE_FILE`
+environment variable before running.
 
-Emitting annotations to the trace from GL applications
-------------------------------------------------------
 
-You can emit string and frame annotations through the
+Emitting annotations to the trace
+---------------------------------
+
+From OpenGL applications you can embed annotations in the trace file through the
 [`GL_GREMEDY_string_marker`](http://www.opengl.org/registry/specs/GREMEDY/string_marker.txt)
 and
 [`GL_GREMEDY_frame_terminator`](http://www.opengl.org/registry/specs/GREMEDY/frame_terminator.txt)
@@ -173,6 +267,15 @@ detect and use GL extensions, you could easily accomplish this by doing:
 This has the added advantage of working equally well with gDEBugger.
 
 
+From OpenGL ES applications you can embed annotations in the trace file through the
+[`GL_EXT_debug_marker`](http://www.khronos.org/registry/gles/extensions/EXT/EXT_debug_marker.txt)
+extension.
+
+
+For Direct3D applications you can follow the same procedure used for 
+[instrumenting an application for PIX](http://technet.microsoft.com/en-us/query/ee417250)
+
+
 Dump GL state at a particular call
 ----------------------------------
 
@@ -205,6 +308,39 @@ You can make a video of the output by doing
     | ffmpeg -r 30 -f image2pipe -vcodec ppm -i pipe: -vcodec mpeg4 -y output.mp4
 
 
+Trimming a trace
+----------------
+
+You can make a smaller trace by doing:
+
+    apitrace trim --callset 100-1000 -o trimed.trace applicated.trace
+
+If you need precise control over which calls to trim you can specify the
+individual call numbers a plaintext file, as described in the 'Call sets'
+section above.
+
+
+Profiling a trace
+-----------------
+
+You can perform gpu and cpu profiling with the command line options:
+
+ * `-pgpu` record gpu times for frames and draw calls.
+
+ * `-pcpu` record cpu times for frames and draw calls.
+
+ * `-ppd` record pixels drawn for each draw call.
+
+The results from this can then be read by hand or analysed with a script.
+
+`scripts/profileshader.py` will read the profile results and format them into a
+table which displays profiling results per shader.
+
+For example, to record all profiling data and utilise the per shader script:
+
+    ./glretrace -pgpu -pcpu -ppd foo.trace | ./scripts/profileshader.py
+
+
 Advanced usage for OpenGL implementors
 ======================================
 
@@ -218,13 +354,11 @@ These are the steps to create a regression test-suite around **apitrace**:
 
 * obtain a trace
 
-* obtain reference snapshots, by doing:
+* obtain reference snapshots, by doing on a reference system:
 
-        mkdir /path/to/snapshots/
+        mkdir /path/to/reference/snapshots/
         glretrace -s /path/to/reference/snapshots/ application.trace
 
-  on reference system.
-
 * prune the snapshots which are not interesting
 
 * to do a regression test, do:
@@ -233,8 +367,8 @@ These are the steps to create a regression test-suite around **apitrace**:
 
   Alternatively, for a HTML summary, use `apitrace diff-images`:
 
-        glretrace -s /path/to/current/snapshots/ application.trace
-        apitrace diff-images --output summary.html /path/to/reference/snapshots/ /path/to/current/snapshots/
+        glretrace -s /path/to/test/snapshots/ application.trace
+        apitrace diff-images --output summary.html /path/to/reference/snapshots/ /path/to/test/snapshots/
 
 
 Automated git-bisection
@@ -302,16 +436,20 @@ reference software renderer.
 
 This can be achieved with retracediff.py script, which invokes glretrace with
 different environments, allowing to choose the desired GL driver by
-manipulating variables such as `LD_LIBRARY_PATH` or `LIBGL_DRIVERS_DIR`.
+manipulating variables such as `LD_LIBRARY_PATH`, `LIBGL_DRIVERS_DIR`, or
+`TRACE_LIBGL`.
 
-For example:
+For example, on Linux:
 
     ./scripts/retracediff.py \
         --ref-env LD_LIBRARY_PATH=/path/to/reference/GL/implementation \
-        -r ./glretrace \
+        --retrace /path/to/glretrace \
         --diff-prefix=/path/to/output/diffs \
         application.trace
 
+Or on Windows:
+
+    python scripts\retracediff.py --retrace \path\to\glretrace.exe --ref-env TRACE_LIBGL=\path\to\reference\opengl32.dll application.trace
 
 
 Links
@@ -343,8 +481,12 @@ Closed-source:
 
   * [D3DSpy](http://doc.51windows.net/Directx9_SDK/?url=/directx9_sdk/graphics/programmingguide/TutorialsAndSamplesAndToolsAndTips/Tools/D3DSpy.htm): the predecessor of PIX
 
+* [NVIDIA PerfKit](http://developer.nvidia.com/nvidia-perfkit)
+
 * [AMD GPU PerfStudio](http://developer.amd.com/gpu/PerfStudio/pages/APITraceWindow.aspx)
 
+* [Intel Graphics Performance Analyzers](http://www.intel.com/software/gpa/)
+
 
 OpenGL
 ------
@@ -357,9 +499,11 @@ Open-source:
 
 * [tracy](https://gitorious.org/tracy): OpenGL ES and OpenVG trace, retrace, and state inspection
 
+* [WebGL-Inspector](http://benvanik.github.com/WebGL-Inspector/)
+
 Closed-source:
 
-* [gDEBugger](http://www.gremedy.com/products.php)
+* [gDEBugger](http://www.gremedy.com/products.php) and [AMD gDEBugger](http://developer.amd.com/tools/gDEBugger/Pages/default.aspx)
 
 * [glslDevil](http://cumbia.informatik.uni-stuttgart.de/glsldevil/index.html)
 
index 2fd23831aa55beec34ef9d7db5a30f5058a39650..d8375aee0062ea151dcd35dda3ecc113f00fd5c6 100644 (file)
@@ -1,128 +1 @@
-Things To Do
-============
-
-(in no particular order)
-
-
-Tracing
--------
-
-* Allow clamping to a GL version or a number of extensions.
-
-* Put (de)compression in a separate thread.
-
-* Trace TSCs
-
-* Trace window sizes somehow
-
-* Allow to distinguish between the calls really done by the program, vs the
-  fakes one necessary to retrace correctly.
-
-* Start tracing on demand (e.g., key-press, or by frame no), emitting calls
-  that recreate all current state.
-
-* Add option to include call stack frames in the trace.
-
-* Trace the internal GL calls done by GLU on Mac OS X & Windows.
-
-
-Retracing
----------
-
-* Use visuals that best match those used in the trace; specially auto
-  detect single/double buffer visuals.
-
-* Respect multiple context sharing of the traces.
-
-* Support multiple threads
-
-* Leverage `ARB_debug_output` where available.
-
-* D3D support.
-
-
-GUI
----
-
-* Timeline view.
-
-* Visualize meshes in draw commands.
-
-* Breakpointing and step-by-step debugging.
-
-
-CLI
----
-
-* Add retrace     Replay all the calls in a trace
-* Add trim        Trim a trace by including only the specified calls/frames
-* Add dump-state  Output the OpenGL state in JSON format
-* Add dump-images Create image files for each frame/drawing operation of a trace
-
-* Add some common command-line options:
-
-  Most commands acting on a trace accept the following common options:
-
-   --calls=[RANGE]       Operate only on calls with index numbers within
-                        the specified range.
-
-   --frames=[RANGE]      Operate only on frames with index numbers within
-                        the specified range.
-
-   --functions=[REGEXP]  Operate only on function calls which have a
-                        name that matches the given regular expression.
-
-   A [RANGE] can be any of the following:
-
-     Example    Description        
-     -------    -----------        
-     4          A single number specifying a single call or frame.
-
-     10-20      Two numbers separated by '-' (FIRST-LAST) specifying a
-               range of consecutive calls/frames from FIRST to LAST. If
-               either of FIRST or LAST is omitted, the first or last
-               call/frame index in the trace will be used.
-
-     1-100/5    Either of the above range specifications followed by '/'
-               and a number (INTERVAL). This specifies the inclusion of
-               only each INTERVAL call/frame within the range. For
-               example, 1-100/5 species frame 1, frame 5, frame 10,
-               ... up to frame 100.
-
-     4,10-20/2  A comma separated list of any of the above range
-               specifications, specifying the union of the ranges.
-
-* Add some retrace-specific options (-b, -db, -sb, -v)
-
-* Add some trime-specific options (--every={draw,framebuffer,frame})
-
-* Accept a filename for --calls or --functions (to use the same calls
-  or functions as present in a trace dump).
-
-* Add an "apitrace bisect" for trimming down a trace based on user
-  input at each stage.
-
-* Add an "apitrace git-bisect-helper" for calling from git-bisect.
-
-
-Other
------
-
-* Side-by-side trace diffing; either as a separate tool on or the GUI.
-
-* Ability to extract just a single frame from a trace, and all previous calls
-  that contributed to it:
-
-  * via a state tracker (i.e., knowledge of how calls affect the state);
-
-  * or by leveragine retrace, dumping the calls to emit all state at beginning
-    of the frame.
-
-
-See also:
-
-* open issues on [github](https://github.com/apitrace/apitrace/issues)
-
-* _Known issues_ section in BUGS.markdown
-
-* FIXME, TODO, and XXX comments on the source code.
+Content moved to the [wiki](https://github.com/apitrace/apitrace/wiki/ToDo).
diff --git a/cgltrace.py b/cgltrace.py
deleted file mode 100644 (file)
index 0e40663..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-##########################################################################
-#
-# Copyright 2011 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""Cgl tracing generator."""
-
-
-from specs.stdapi import API
-from specs.glapi import glapi
-from specs.cglapi import cglapi
-from gltrace import GlTracer
-
-
-class CglTracer(GlTracer):
-
-    def isFunctionPublic(self, function):
-        # The symbols visible in libGL.dylib can vary, so expose them all
-        return True
-
-
-if __name__ == '__main__':
-    print
-    print '#include <stdlib.h>'
-    print '#include <string.h>'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print
-    print '// To validate our prototypes'
-    print '#define GL_GLEXT_PROTOTYPES'
-    print
-    print '#include "glproc.hpp"'
-    print '#include "glsize.hpp"'
-    print
-
-    api = API()
-    api.addApi(cglapi)
-    api.addApi(glapi)
-    tracer = CglTracer()
-    tracer.trace_api(api)
-
-    print r'''
-
-PUBLIC
-void * gll_noop = 0;
-
-'''
index af99f57aaa06c3ad17caca0822a7be31dd31304d..a6fc3a6d3abe6ca3088180cf3566bdf5c7ae0b5d 100644 (file)
@@ -4,6 +4,7 @@ add_executable (apitrace
     cli_diff_state.cpp
     cli_diff_images.cpp
     cli_dump.cpp
+    cli_dump_images.cpp
     cli_pager.cpp
     cli_pickle.cpp
     cli_repack.cpp
@@ -12,6 +13,10 @@ add_executable (apitrace
 )
 
 target_link_libraries (apitrace
+    common
+    ${PNG_LIBRARIES}
+    ${ZLIB_LIBRARIES}
+    ${SNAPPY_LIBRARIES}
     ${GETOPT_LIBRARIES}
 )
 
index 6c080e86de65683883d520661ecc728ac8a1ae2a..4f3e2b9b36d2f2ad179dac478a9e1d152175f9dc 100644 (file)
@@ -44,6 +44,7 @@ extern const Command diff_command;
 extern const Command diff_state_command;
 extern const Command diff_images_command;
 extern const Command dump_command;
+extern const Command dump_images_command;
 extern const Command pickle_command;
 extern const Command repack_command;
 extern const Command trace_command;
index 9f6efefa00eac2ac29e2b086161dd16b0c2a354c..ffc0e303878ba9cc165d019df768b17433d2b806 100644 (file)
 
 static const char *synopsis = "Identify differences between two traces.";
 
+static os::String
+find_command(void)
+{
+    return trace::findScript("tracediff.py");
+}
+
 static void
 usage(void)
 {
-    std::cout
-        << "usage: apitrace diff <trace-1> <trace-2>\n"
-        << synopsis << "\n"
-        "\n"
-        "    Both input files should be the result of running 'apitrace trace'.\n";
+    os::String command = find_command();
+    if (!command.length()) {
+        exit(1);
+    }
+
+    char *args[4];
+    args[0] = (char *) "python";
+    args[1] = (char *) command.str();
+    args[2] = (char *) "--help";
+    args[3] = NULL;
+
+    os::execute(args);
 }
 
 static int
@@ -50,55 +63,24 @@ command(int argc, char *argv[])
 {
     int i;
 
-    for (i = 1; i < argc; ++i) {
-        const char *arg = argv[i];
-
-        if (arg[0] != '-') {
-            break;
-        }
-
-        if (!strcmp(arg, "--")) {
-            i++;
-            break;
-        } else if (!strcmp(arg, "--help")) {
-            usage();
-            return 0;
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
-            usage();
-            return 1;
-        }
-    }
-
-    if (argc - i != 2) {
-        std::cerr << "Error: diff requires exactly two trace files as arguments.\n";
-        usage();
+    os::String command = find_command();
+    if (!command.length()) {
         return 1;
     }
 
-    char *file1, *file2;
-
-    file1 = argv[i];
-    file2 = argv[i+1];
-
-    os::String command = trace::findScript("tracediff.sh");
+    os::String apitracePath = os::getProcessName();
 
-    char* args[4];
-
-    args[0] = (char *) command.str();
-    args[1] = file1;
-    args[2] = file2;
-    args[3] = NULL;
-
-#ifdef _WIN32
-    std::cerr << "The 'apitrace diff' command is not yet supported on this O/S.\n";
-    return 1;
-#else
-    os::String apitrace = os::getProcessName();
-    setenv("APITRACE", apitrace.str(), 1);
+    std::vector<const char *> args;
+    args.push_back("python");
+    args.push_back(command.str());
+    args.push_back("--apitrace");
+    args.push_back(apitracePath.str());
+    for (i = 1; i < argc; i++) {
+        args.push_back(argv[i]);
+    }
+    args.push_back(NULL);
 
-    return os::execute(args);
-#endif
+    return os::execute((char * const *)&args[0]);
 }
 
 const Command diff_command = {
index 626a34fc7790f4a56fb5070d81f2246c9deb72db..3932fa24c51e8afcacb492ed2b0c704bf15196b5 100644 (file)
@@ -49,10 +49,11 @@ usage(void)
         exit(1);
     }
 
-    char *args[3];
-    args[0] = (char *) command.str();
-    args[1] = (char *) "--help";
-    args[2] = NULL;
+    char *args[4];
+    args[0] = (char *) "python";
+    args[1] = (char *) command.str();
+    args[2] = (char *) "--help";
+    args[3] = NULL;
 
     os::execute(args);
 }
@@ -61,25 +62,21 @@ static int
 command(int argc, char *argv[])
 {
     int i;
-    int ret;
 
     os::String command = find_command();
     if (!command.length()) {
         return 1;
     }
 
-    char **args = new char* [argc + 1];
-    args[0] = (char *) command.str();
+    std::vector<const char *> args;
+    args.push_back("python");
+    args.push_back(command.str());
     for (i = 1; i < argc; i++) {
-        args[i] = argv[i];
+        args.push_back(argv[i]);
     }
-    args[argc] = NULL;
+    args.push_back(NULL);
 
-    ret = os::execute(args);
-
-    delete [] args;
-
-    return ret;
+    return os::execute((char * const *)&args[0]);
 }
 
 const Command diff_images_command = {
index 8536e3235c16b170388ce899ce9c651d29ae5f7c..7f75484289fae30e70edbfe593611c0e8cca59ab 100644 (file)
@@ -26,6 +26,8 @@
  *********************************************************************/
 
 #include <string.h>
+#include <getopt.h>
+
 #include <iostream>
 
 #include "cli.hpp"
@@ -45,32 +47,32 @@ usage(void)
         "    Both input files should be the result of running 'glretrace -D XYZ <trace>'.\n";
 }
 
+const static char *
+shortOptions = "h";
+
+const static struct option
+longOptions[] = {
+    {"help", no_argument, 0, 'h'},
+    {0, 0, 0, 0}
+};
+
 static int
 command(int argc, char *argv[])
 {
-    int i;
-
-    for (i = 1; i < argc; ++i) {
-        const char *arg = argv[i];
-
-        if (arg[0] != '-') {
-            break;
-        }
-
-        if (!strcmp(arg, "--")) {
-            i++;
-            break;
-        } else if (!strcmp(arg, "--help")) {
+    int opt;
+    while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
+        switch (opt) {
+        case 'h':
             usage();
             return 0;
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
+        default:
+            std::cerr << "error: unexpected option `" << opt << "`\n";
             usage();
             return 1;
         }
     }
 
-    if (argc - i != 2) {
+    if (argc != optind + 2) {
         std::cerr << "Error: diff-state requires exactly two state-dump files as arguments.\n";
         usage();
         return 1;
@@ -78,8 +80,8 @@ command(int argc, char *argv[])
 
     char *file1, *file2;
 
-    file1 = argv[i];
-    file2 = argv[i+1];
+    file1 = argv[optind];
+    file2 = argv[optind + 1];
 
     os::String command = trace::findScript("jsondiff.py");
 
index d6f50141a3ebda2495dc0eacfddd0415bcdfac55..f52b83c3e0dcbde9cd3b5bb6347fb9a064a8a0a7 100644 (file)
@@ -28,6 +28,9 @@
 #include <string.h>
 #include <limits.h> // for CHAR_MAX
 #include <getopt.h>
+#ifndef _WIN32
+#include <unistd.h> // for isatty()
+#endif
 
 #include "cli.hpp"
 #include "cli_pager.hpp"
@@ -64,8 +67,9 @@ usage(void)
         "    --color[=WHEN]\n"
         "    --colour[=WHEN]      colored syntax highlighting\n"
         "                         WHEN is 'auto', 'always', or 'never'\n"
-        "    --arg-names[=BOOL]   dump argument names [default: yes]\n"
         "    --thread-ids=[=BOOL] dump thread ids [default: no]\n"
+        "    --call-nos[=BOOL]    dump call numbers[default: yes]\n"
+        "    --arg-names[=BOOL]   dump argument names [default: yes]\n"
         "\n"
     ;
 }
@@ -73,8 +77,9 @@ usage(void)
 enum {
        CALLS_OPT = CHAR_MAX + 1,
        COLOR_OPT,
-    ARG_NAMES_OPT,
     THREAD_IDS_OPT,
+    CALL_NOS_OPT,
+    ARG_NAMES_OPT,
 };
 
 const static char *
@@ -87,8 +92,9 @@ longOptions[] = {
     {"calls", required_argument, 0, CALLS_OPT},
     {"colour", optional_argument, 0, COLOR_OPT},
     {"color", optional_argument, 0, COLOR_OPT},
-    {"arg-names", optional_argument, 0, ARG_NAMES_OPT},
     {"thread-ids", optional_argument, 0, THREAD_IDS_OPT},
+    {"call-nos", optional_argument, 0, CALL_NOS_OPT},
+    {"arg-names", optional_argument, 0, ARG_NAMES_OPT},
     {0, 0, 0, 0}
 };
 
@@ -142,6 +148,16 @@ command(int argc, char *argv[])
                 return 1;
             }
             break;
+        case THREAD_IDS_OPT:
+            dumpThreadIds = boolOption(optarg);
+            break;
+        case CALL_NOS_OPT:
+            if (boolOption(optarg)) {
+                dumpFlags &= ~trace::DUMP_FLAG_NO_CALL_NO;
+            } else {
+                dumpFlags |= trace::DUMP_FLAG_NO_CALL_NO;
+            }
+            break;
         case ARG_NAMES_OPT:
             if (boolOption(optarg)) {
                 dumpFlags &= ~trace::DUMP_FLAG_NO_ARG_NAMES;
@@ -149,9 +165,6 @@ command(int argc, char *argv[])
                 dumpFlags |= trace::DUMP_FLAG_NO_ARG_NAMES;
             }
             break;
-        case THREAD_IDS_OPT:
-            dumpThreadIds = boolOption(optarg);
-            break;
         default:
             std::cerr << "error: unexpected option `" << opt << "`\n";
             usage();
diff --git a/cli/cli_dump_images.cpp b/cli/cli_dump_images.cpp
new file mode 100644 (file)
index 0000000..d42b3f7
--- /dev/null
@@ -0,0 +1,145 @@
+/*********************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * Copyright 2012 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+#include <string.h>
+#include <limits.h> // for CHAR_MAX
+#include <getopt.h>
+#include <iostream>
+
+#include "cli.hpp"
+
+#include "os_string.hpp"
+#include "os_process.hpp"
+
+static const char *synopsis = "Dump frame images obtained from a trace.";
+
+static void
+usage(void)
+{
+    std::cout << "usage apitrace dump-images [OPTIONS] TRACE_FILE\n"
+              << synopsis << "\n"
+        "\n"
+        "    -h, --help           show this help message and exit\n"
+        "        --calls=CALLSET  dump images only for specified calls\n"
+        "                         (default value is \"*/frame\" which\n"
+        "                          which dumps an image for each frame)\n"
+        "    -o, --output=PREFIX  prefix to use in naming output files\n"
+        "                         (default is trace filename without extension)\n"
+        "\n";
+}
+
+enum {
+    CALLS_OPT = CHAR_MAX + 1,
+};
+
+const static char *
+shortOptions = "ho:";
+
+const static struct option
+longOptions[] = {
+    {"help", no_argument, 0, 'h'},
+    {"calls", required_argument, 0, CALLS_OPT},
+    {"output", required_argument, 0, 'o'},
+    {0, 0, 0, 0}
+};
+
+static int
+command(int argc, char *argv[])
+{
+    os::String prefix;
+    const char *calls, *filename, *output = NULL;
+
+    int opt;
+    while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
+        switch (opt) {
+        case 'h':
+            usage();
+            return 0;
+        case CALLS_OPT:
+            calls = optarg;
+            break;
+        case 'o':
+            output = optarg;
+            break;
+        default:
+            std::cerr << "error: unexpected option `" << opt << "`\n";
+            usage();
+            return 1;
+        }
+    }
+
+    if (optind >= argc) {
+        std::cerr << "error: apitrace dump-images requires a trace file as an argument.\n";
+        usage();
+        return 1;
+    }
+
+    if (optind < argc - 1) { 
+        std::cerr << "error: apitrace dump-images can accept only a single trace file argument.\n";
+        usage();
+        return 1;
+    }
+
+    filename = argv[optind];
+
+    if (output == NULL) {
+        prefix = filename;
+        prefix.trimDirectory();
+        prefix.trimExtension();
+        output = prefix.str();
+    }
+
+    /* FIXME: It would be cleaner to pull the replaying of the trace
+     * in-process here and generate the images directly. But that
+     * pulls in a non-trivial amount of the existing 'retrace' code,
+     * along with dependencies on GL, etc.
+     *
+     * It will definitely make sense to do that once all that code has
+     * already been pulled in for the "apitrace retrace" (or "apitrace
+     * replay") command. */
+    std::vector<const char *> command;
+    command.push_back("glretrace");
+    command.push_back("-s");
+    command.push_back(output);
+    command.push_back("-S");
+    if (calls)
+        command.push_back(calls);
+    else
+        command.push_back("*/frame");
+    command.push_back(filename);
+    command.push_back(NULL);
+
+    return os::execute((char * const *)&command[0]);
+}
+
+const Command dump_images_command = {
+    "dump-images",
+    synopsis,
+    usage,
+    command
+};
index cff6a05de111955323219d8575ba7400d955f174..8c619ba73a6ea7a865d7a14ffabea0b759c21fd8 100644 (file)
@@ -70,6 +70,7 @@ static const Command * commands[] = {
     &diff_state_command,
     &diff_images_command,
     &dump_command,
+    &dump_images_command,
     &pickle_command,
     &repack_command,
     &trace_command,
index 6af879fa3da6960d7aca1a02b2c06cf8e27e2b4a..ffea40b7596b38acc536ad0d3520e05b56e869a9 100644 (file)
 
 
 #include <string.h>
-
-#ifdef _WIN32
-#include <fcntl.h>
-#include <io.h>
-#endif
+#include <limits.h> // for CHAR_MAX
+#include <getopt.h>
 
 #include "pickle.hpp"
 
+#include "os_binary.hpp"
+
 #include "cli.hpp"
 #include "cli_pager.hpp"
 
@@ -48,10 +47,12 @@ class PickleVisitor : public trace::Visitor
 {
 protected:
     PickleWriter &writer;
+    bool symbolic;
 
 public:
-    PickleVisitor(PickleWriter &_writer) :
-        writer(_writer) {
+    PickleVisitor(PickleWriter &_writer, bool _symbolic) :
+        writer(_writer),
+        symbolic(_symbolic) {
     }
 
     void visit(Null *node) {
@@ -83,23 +84,56 @@ public:
     }
 
     void visit(Enum *node) {
-        // TODO: keep symbolic name
+        if (symbolic) {
+            const EnumValue *it = node->lookup();
+            if (it) {
+                writer.writeString(it->name);
+                return;
+            }
+        }
         writer.writeInt(node->value);
     }
 
     void visit(Bitmask *node) {
-        // TODO: keep symbolic name
-        writer.writeInt(node->value);
+        if (symbolic) {
+            unsigned long long value = node->value;
+            const BitmaskSig *sig = node->sig;
+            writer.beginList();
+            for (const BitmaskFlag *it = sig->flags; it != sig->flags + sig->num_flags; ++it) {
+                if ((it->value && (value & it->value) == it->value) ||
+                    (!it->value && value == 0)) {
+                    writer.writeString(it->name);
+                    value &= ~it->value;
+                }
+                if (value == 0) {
+                    break;
+                }
+            }
+            if (value) {
+                writer.writeInt(value);
+            }
+            writer.endList();
+        } else {
+            writer.writeInt(node->value);
+        }
     }
 
     void visit(Struct *node) {
-        writer.beginDict();
-        for (unsigned i = 0; i < node->sig->num_members; ++i) {
-            writer.beginItem(node->sig->member_names[i]);
-            _visit(node->members[i]);
-            writer.endItem();
+        if (false) {
+            writer.beginDict();
+            for (unsigned i = 0; i < node->sig->num_members; ++i) {
+                writer.beginItem(node->sig->member_names[i]);
+                _visit(node->members[i]);
+                writer.endItem();
+            }
+            writer.endDict();
+        } else {
+            writer.beginTuple();
+            for (unsigned i = 0; i < node->sig->num_members; ++i) {
+                _visit(node->members[i]);
+            }
+            writer.endTuple();
         }
-        writer.endDict();
     }
 
     void visit(Array *node) {
@@ -111,13 +145,21 @@ public:
     }
 
     void visit(Blob *node) {
-        writer.writeString((const char *)node->buf, node->size);
+        writer.writeByteArray(node->buf, node->size);
     }
 
     void visit(Pointer *node) {
         writer.writeInt(node->value);
     }
 
+    void visit(Repr *r) {
+        if (symbolic) {
+            _visit(r->humanValue);
+        } else {
+            _visit(r->machineValue);
+        }
+    }
+
     void visit(Call *call) {
         writer.beginTuple();
 
@@ -154,51 +196,62 @@ static void
 usage(void)
 {
     std::cout
-        << "usage: apitrace pickle [OPTIONS] <trace-file>...\n"
+        << "usage: apitrace pickle [OPTIONS] TRACE_FILE...\n"
         << synopsis << "\n"
         "\n"
-        "    --calls <CALLSET>   Only pickle specified calls\n"
+        "    -h, --help           show this help message and exit\n"
+        "    -s, --symbolic       dump symbolic names\n"
+        "    --calls=CALLSET      only dump specified calls\n"
     ;
 }
 
-static int
-command(int argc, char *argv[])
-{
-    int i;
+enum {
+       CALLS_OPT = CHAR_MAX + 1,
+};
 
-    for (i = 1; i < argc;) {
-        const char *arg = argv[i];
+const static char *
+shortOptions = "hs";
 
-        if (arg[0] != '-') {
-            break;
-        }
+const static struct option
+longOptions[] = {
+    {"help", no_argument, 0, 'h'},
+    {"symbolic", no_argument, 0, 's'},
+    {"calls", required_argument, 0, CALLS_OPT},
+    {0, 0, 0, 0}
+};
 
-        ++i;
+static int
+command(int argc, char *argv[])
+{
+    bool symbolic;
 
-        if (!strcmp(arg, "--")) {
-            break;
-        } else if (!strcmp(arg, "--help")) {
+    int opt;
+    while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
+        switch (opt) {
+        case 'h':
             usage();
             return 0;
-        } else if (!strcmp(arg, "--calls")) {
-            calls = trace::CallSet(argv[i++]);
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
+        case 's':
+            symbolic = true;
+            break;
+        case CALLS_OPT:
+            calls = trace::CallSet(optarg);
+            break;
+        default:
+            std::cerr << "error: unexpected option `" << opt << "`\n";
             usage();
             return 1;
         }
     }
 
-#ifdef _WIN32
-    // Set stdout in binary mode
-    fflush(stdout);
-    int mode = _setmode(_fileno(stdout), _O_BINARY);
-    if (mode == -1) {
-        std::cerr << "warning: failed to set stdout in binary mode\n";
-    }
-#endif
+    os::setBinaryMode(stdout);
+    
+    std::cout.sync_with_stdio(false);
+
+    PickleWriter writer(std::cout);
+    PickleVisitor visitor(writer, symbolic);
 
-    for (; i < argc; ++i) {
+    for (int i = optind; i < argc; ++i) {
         trace::Parser parser;
 
         if (!parser.open(argv[i])) {
@@ -209,23 +262,14 @@ command(int argc, char *argv[])
         trace::Call *call;
         while ((call = parser.parse_call())) {
             if (calls.contains(*call)) {
-                PickleWriter writer(std::cout);
-                PickleVisitor visitor(writer);
-                
+                writer.begin();
                 visitor.visit(call);
+                writer.end();
             }
             delete call;
         }
     }
 
-#ifdef _WIN32
-    std::cout.flush();
-    fflush(stdout);
-    if (mode != -1) {
-        _setmode(_fileno(stdout), mode);
-    }
-#endif
-
     return 0;
 }
 
index a92723d60ddaa59af5c43c0adf2bd0db77ac2f85..6f08896e1eb99e102b42e857fe516a0f15490edf 100644 (file)
@@ -25,6 +25,8 @@
 
 
 #include <string.h>
+#include <getopt.h>
+
 #include <iostream>
 
 #include "cli.hpp"
@@ -46,6 +48,15 @@ usage(void)
         << "\n";
 }
 
+const static char *
+shortOptions = "h";
+
+const static struct option
+longOptions[] = {
+    {"help", no_argument, 0, 'h'},
+    {0, 0, 0, 0}
+};
+
 static int
 repack(const char *inFileName, const char *outFileName)
 {
@@ -78,34 +89,26 @@ repack(const char *inFileName, const char *outFileName)
 static int
 command(int argc, char *argv[])
 {
-    int i;
-
-    for (i = 1; i < argc; ++i) {
-        const char *arg = argv[i];
-
-        if (arg[0] != '-') {
-            break;
-        }
-
-        if (!strcmp(arg, "--")) {
-            break;
-        } else if (strcmp(arg, "--help") == 0) {
+    int opt;
+    while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
+        switch (opt) {
+        case 'h':
             usage();
             return 0;
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
+        default:
+            std::cerr << "error: unexpected option `" << opt << "`\n";
             usage();
             return 1;
         }
     }
 
-    if (argc != i + 2) {
+    if (argc != optind + 2) {
         std::cerr << "error: insufficient number of arguments\n";
         usage();
         return 1;
     }
 
-    return repack(argv[i], argv[i + 1]);
+    return repack(argv[optind], argv[optind + 1]);
 }
 
 const Command repack_command = {
index 68526cb4b01c69a5ce559f93a2227434d20cfe90..80775090c7b1be79cbce6dc9a8e9e6f6b8c521d2 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <getopt.h>
 
 #include <iostream>
 
@@ -41,7 +42,7 @@ static const char *synopsis = "Generate a new trace by executing the given progr
 static void
 usage(void)
 {
-    std::cout << "usage: apitrace trace PROGRAM [ARGS ...]\n"
+    std::cout << "usage: apitrace trace [OPTIONS] PROGRAM [ARGS ...]\n"
         << synopsis << "\n"
         "\n"
         "    The given program will be executed with the given arguments.\n"
@@ -50,67 +51,87 @@ usage(void)
         "    with other apitrace utilities for replay or analysis.\n"
         "\n"
         "    -v, --verbose       verbose output\n"
-        "    -a, --api API       specify API to trace (gl or egl);\n"
+        "    -a, --api=API       specify API to trace ("
+#ifdef _WIN32
+                                                      "gl, d3d7, d3d8, d3d9, or d3d10"
+#else
+                                                      "gl or egl"
+#endif
+                                                      ");\n"
         "                        default is `gl`\n"
-        "    -o, --output TRACE  specify output trace file;\n"
+        "    -o, --output=TRACE  specify output trace file;\n"
         "                        default is `PROGRAM.trace`\n";
 }
 
+const static char *
+shortOptions = "+hva:o:";
+
+const static struct option
+longOptions[] = {
+    {"help", no_argument, 0, 'h'},
+    {"verbose", no_argument, 0, 'v'},
+    {"api", required_argument, 0, 'a'},
+    {"output", required_argument, 0, 'o'},
+    {0, 0, 0, 0}
+};
+
 static int
 command(int argc, char *argv[])
 {
     bool verbose = false;
     trace::API api = trace::API_GL;
     const char *output = NULL;
-    int i;
-
-    for (i = 1; i < argc; ) {
-        const char *arg = argv[i];
-
-        if (arg[0] != '-') {
-            break;
-        }
-
-        ++i;
 
-        if (strcmp(arg, "--") == 0) {
-            break;
-        } else if (strcmp(arg, "--help") == 0) {
+    int opt;
+    while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
+        switch (opt) {
+        case 'h':
             usage();
             return 0;
-        } else if (strcmp(arg, "-v") == 0 ||
-                   strcmp(arg, "--verbose") == 0) {
+        case 'v':
             verbose = true;
-        } else if (strcmp(arg, "-a") == 0 ||
-                   strcmp(arg, "--api") == 0) {
-            arg = argv[i++];
-            if (strcmp(arg, "gl") == 0) {
+            break;
+        case 'a':
+            if (strcmp(optarg, "gl") == 0) {
                 api = trace::API_GL;
-            } else if (strcmp(arg, "egl") == 0) {
+            } else if (strcmp(optarg, "egl") == 0) {
                 api = trace::API_EGL;
+            } else if (strcmp(optarg, "d3d7") == 0) {
+                api = trace::API_D3D7;
+            } else if (strcmp(optarg, "d3d8") == 0) {
+                api = trace::API_D3D8;
+            } else if (strcmp(optarg, "d3d9") == 0) {
+                api = trace::API_D3D9;
+            } else if (strcmp(optarg, "d3d10") == 0) {
+                api = trace::API_D3D10;
+            } else if (strcmp(optarg, "d3d10_1") == 0) {
+                api = trace::API_D3D10_1;
+            } else if (strcmp(optarg, "d3d11") == 0) {
+                api = trace::API_D3D11;
             } else {
-                std::cerr << "error: unknown API `" << arg << "`\n";
+                std::cerr << "error: unknown API `" << optarg << "`\n";
                 usage();
                 return 1;
             }
-        } else if (strcmp(arg, "-o") == 0 ||
-                   strcmp(arg, "--output") == 0) {
-            output = argv[i++];
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
+            break;
+        case 'o':
+            output = optarg;
+            break;
+        default:
+            std::cerr << "error: unexpected option `" << opt << "`\n";
             usage();
             return 1;
         }
     }
 
-    if (i == argc) {
+    if (optind == argc) {
         std::cerr << "error: no command specified\n";
         usage();
         return 1;
     }
 
     assert(argv[argc] == 0);
-    return trace::traceProgram(api, argv + i, output, verbose);
+    return trace::traceProgram(api, argv + optind, output, verbose);
 }
 
 const Command trace_command = {
index 515b4b61b8a9068ca50241900fd90facbe7a1020..d9446822748e07913e13416aac8629a30eb97e90 100644 (file)
  *
  **************************************************************************/
 
+
 #include <string.h>
+#include <limits.h> // for CHAR_MAX
+#include <getopt.h>
 
 #include "cli.hpp"
 
@@ -40,55 +43,71 @@ static void
 usage(void)
 {
     std::cout
-        << "usage: apitrace trim [OPTIONS] <trace-file>...\n"
+        << "usage: apitrace trim [OPTIONS] TRACE_FILE...\n"
         << synopsis << "\n"
         "\n"
-        "       --calls <CALLSET>     Only trim specified calls\n"
-        "    -o --output <TRACEFILE>  Output trace file\n"
+        "    -h, --help               show this help message and exit\n"
+        "        --calls=CALLSET      only retain specified calls\n"
+        "        --thread=THREAD_ID   only retain calls from specified thread\n"
+        "    -o, --output=TRACE_FILE  output trace file\n"
         "\n"
     ;
 }
 
+enum {
+    CALLS_OPT = CHAR_MAX + 1,
+    THREAD_OPT,
+};
+
+const static char *
+shortOptions = "ho:";
+
+const static struct option
+longOptions[] = {
+    {"help", no_argument, 0, 'h'},
+    {"calls", required_argument, 0, CALLS_OPT},
+    {"thread", required_argument, 0, THREAD_OPT},
+    {"output", required_argument, 0, 'o'},
+    {0, 0, 0, 0}
+};
+
 static int
 command(int argc, char *argv[])
 {
     std::string output;
     trace::CallSet calls(trace::FREQUENCY_ALL);
+    int thread = -1;
     int i;
 
-    for (i = 1; i < argc;) {
-        const char *arg = argv[i];
-
-        if (arg[0] != '-') {
-            break;
-        }
-
-        ++i;
-
-        if (!strcmp(arg, "--")) {
-            break;
-        } else if (!strcmp(arg, "--help")) {
+    int opt;
+    while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
+        switch (opt) {
+        case 'h':
             usage();
             return 0;
-        } else if (!strcmp(arg, "--calls")) {
-            calls = trace::CallSet(argv[i++]);
-        } else if (!strcmp(arg, "-o") ||
-                   !strcmp(arg, "--output")) {
-            output = argv[i++];
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
+        case CALLS_OPT:
+            calls = trace::CallSet(optarg);
+            break;
+        case THREAD_OPT:
+            thread = atoi(optarg);
+            break;
+        case 'o':
+            output = optarg;
+            break;
+        default:
+            std::cerr << "error: unexpected option `" << opt << "`\n";
             usage();
             return 1;
         }
     }
 
-    if (i >= argc) {
-        std::cerr << "Error: apitrace trim requires a trace file as an argument.\n";
+    if (optind >= argc) {
+        std::cerr << "error: apitrace trim requires a trace file as an argument.\n";
         usage();
         return 1;
     }
 
-    for ( ; i < argc; ++i) {
+    for (i = optind; i < argc; ++i) {
         trace::Parser p;
         if (!p.open(argv[i])) {
             std::cerr << "error: failed to open " << argv[i] << "\n";
@@ -110,7 +129,8 @@ command(int argc, char *argv[])
 
         trace::Call *call;
         while ((call = p.parse_call())) {
-            if (calls.contains(*call)) {
+            if (calls.contains(*call) &&
+                (thread == -1 || call->thread_id == thread)) {
                 writer.writeCall(call);
             }
             delete call;
diff --git a/cmake/.gitignore b/cmake/.gitignore
new file mode 100644 (file)
index 0000000..4d7a231
--- /dev/null
@@ -0,0 +1 @@
+!*.cmake
index faeee60f150a99745fb1163a8a185301363dd997..43472fad19306fcea027928943717dd9ef0be8e1 100644 (file)
 # - try to find DirectX include dirs and libraries
 
+
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+
+
+       if (CMAKE_CL_64)
+               set (DirectX_ARCHITECTURE x64)
+       else ()
+               set (DirectX_ARCHITECTURE x86)
+       endif ()
+
+
+       # DirectX SDK
        find_path (DirectX_ROOT_DIR
                Include/d3d9.h
                PATHS
                        "$ENV{DXSDK_DIR}"
                        "$ENV{ProgramFiles}/Microsoft DirectX SDK (June 2010)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (February 2010)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (March 2009)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (August 2008)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (June 2008)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (March 2008)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (November 2007)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (August 2007)"
-                       "$ENV{ProgramFiles}/Microsoft DirectX SDK"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (June 2010)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (February 2010)"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (February 2010)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (March 2009)"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (March 2009)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (August 2008)"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (August 2008)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (June 2008)"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (June 2008)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (March 2008)"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (March 2008)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (November 2007)"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (November 2007)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK (August 2007)"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (August 2007)"
+                       "$ENV{ProgramFiles}/Microsoft DirectX SDK"
                        "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK"
-               DOC "DirectX SDK root directory")
+               DOC "DirectX SDK root directory"
+       )
+       if (DirectX_ROOT_DIR)
+               set (DirectX_INC_SEARCH_PATH "${DirectX_ROOT_DIR}/Include")
+               set (DirectX_LIB_SEARCH_PATH "${DirectX_ROOT_DIR}/Lib/${DirectX_ARCHITECTURE}")
+               set (DirectX_BIN_SEARCH_PATH "${DirectX_ROOT_DIR}/Utilities/bin/x86")
+       endif ()
+
+
+       # With VS 2011 and Windows 8 SDK, the DirectX SDK is included as part of
+       # the Windows SDK.
+       #
+       # See also:
+       # - http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx
+       # TODO: Allow using DirectX SDK with VS 2011
+       if (DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
+               find_path (WIN8_SDK_ROOT_DIR
+                       Include/um/windows.h
+                       PATHS
+                               "$ENV{ProgramFiles}/Windows Kits/8.0"
+                               "$ENV{ProgramFiles(x86)}/Windows Kits/8.0"
+                               DOC "Windows 8 SDK root directory"
+               )
+
+               if (WIN8_SDK_ROOT_DIR)
+                       set (DirectX_INC_SEARCH_PATH "${WIN8_SDK_ROOT_DIR}/Include/um" "${WIN8_SDK_ROOT_DIR}/Include/shared")
+                       set (DirectX_LIB_SEARCH_PATH "${WIN8_SDK_ROOT_DIR}/Lib/Win8/um/${DirectX_ARCHITECTURE}")
+                       set (DirectX_BIN_SEARCH_PATH "${WIN8_SDK_ROOT_DIR}/bin/x86")
+               endif ()
+       endif ()
 
 
        find_path (DirectX_D3D_INCLUDE_DIR d3d.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3d.h resides")
 
        find_path (DirectX_D3DX_INCLUDE_DIR d3dx.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3dx.h resides")
 
        find_library (DirectX_DDRAW_LIBRARY ddraw
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where ddraw resides")
 
        find_library (DirectX_D3DX_LIBRARY d3dx
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where d3dx resides")
 
        if (DirectX_D3D_INCLUDE_DIR AND DirectX_DDRAW_LIBRARY)
                set (DirectX_D3D_FOUND 1)
                if (DirectX_D3DX_INCLUDE_DIR AND DirectX_D3DX_LIBRARY)
                        set (DirectX_D3DX_FOUND 1)
-               endif (DirectX_D3DX_INCLUDE_DIR AND DirectX_D3DX_LIBRARY)
-       endif (DirectX_D3D_INCLUDE_DIR AND DirectX_DDRAW_LIBRARY)
+               endif ()
+       endif ()
 
 
        find_path (DirectX_D3D8_INCLUDE_DIR d3d8.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3d8.h resides")
 
        find_path (DirectX_D3DX8_INCLUDE_DIR d3dx8.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3dx8.h resides")
 
        find_library (DirectX_D3D8_LIBRARY d3d8
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where d3d8 resides")
 
        find_library (DirectX_D3DX8_LIBRARY d3dx8
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where d3dx8 resides")
 
        if (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3D8_LIBRARY)
                set (DirectX_D3D8_FOUND 1)
                if (DirectX_D3DX8_INCLUDE_DIR AND DirectX_D3DX8_LIBRARY)
                        set (DirectX_D3DX8_FOUND 1)
-               endif (DirectX_D3DX8_INCLUDE_DIR AND DirectX_D3DX8_LIBRARY)
-       endif (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3D8_LIBRARY)
+               endif ()
+       endif ()
 
 
        find_path (DirectX_D3D9_INCLUDE_DIR d3d9.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3d9.h resides")
 
        find_path (DirectX_D3DX9_INCLUDE_DIR d3dx9.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3dx9.h resides")
 
        find_library (DirectX_D3D9_LIBRARY d3d9
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where d3d9 resides")
 
        find_library (DirectX_D3DX9_LIBRARY d3dx9
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where d3dx9 resides")
 
        if (DirectX_D3D9_INCLUDE_DIR AND DirectX_D3D9_LIBRARY)
                set (DirectX_D3D9_FOUND 1)
                if (DirectX_D3DX9_INCLUDE_DIR AND DirectX_D3DX9_LIBRARY)
                        set (DirectX_D3DX9_FOUND 1)
-               endif (DirectX_D3DX9_INCLUDE_DIR AND DirectX_D3DX9_LIBRARY)
-       endif (DirectX_D3D9_INCLUDE_DIR AND DirectX_D3D9_LIBRARY)
+               endif ()
+       endif ()
 
 
        find_path (DirectX_D3D10_INCLUDE_DIR d3d10.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3d10.h resides")
 
        find_path (DirectX_D3DX10_INCLUDE_DIR d3dx10.h
-               PATHS
-                       "${DirectX_ROOT_DIR}/Include"
+               PATHS ${DirectX_INC_SEARCH_PATH}
                DOC "The directory where d3dx10.h resides")
 
        find_library (DirectX_D3D10_LIBRARY d3d10
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where d3d10 resides")
 
        find_library (DirectX_D3DX10_LIBRARY d3dx10
-               PATHS
-                       "${DirectX_ROOT_DIR}/Lib/x86"
+               PATHS ${DirectX_LIB_SEARCH_PATH}
                DOC "The directory where d3dx10 resides")
 
        if (DirectX_D3D10_INCLUDE_DIR AND DirectX_D3D10_LIBRARY)
                set (DirectX_D3D10_FOUND 1)
                if (DirectX_D3DX10_INCLUDE_DIR AND DirectX_D3DX10_LIBRARY)
                        set (DirectX_D3DX10_FOUND 1)
-               endif (DirectX_D3DX10_INCLUDE_DIR AND DirectX_D3DX10_LIBRARY)
-       endif (DirectX_D3D10_INCLUDE_DIR AND DirectX_D3D10_LIBRARY)
+               endif ()
+       endif ()
+
+
+       find_path (DirectX_D3D10_1_INCLUDE_DIR d3d10_1.h
+               PATHS ${DirectX_INC_SEARCH_PATH}
+               DOC "The directory where d3d10_1.h resides")
+
+       find_library (DirectX_D3D10_1_LIBRARY d3d10_1
+               PATHS ${DirectX_LIB_SEARCH_PATH}
+               DOC "The directory where d3d10_1 resides")
+
+       if (DirectX_D3D10_1_INCLUDE_DIR AND DirectX_D3D10_1_LIBRARY)
+               set (DirectX_D3D10_1_FOUND 1)
+       endif ()
+
+
+       find_path (DirectX_D3D11_INCLUDE_DIR d3d11.h
+               PATHS ${DirectX_INC_SEARCH_PATH}
+               DOC "The directory where d3d11.h resides")
+
+       find_path (DirectX_D3DX11_INCLUDE_DIR d3dx11.h
+               PATHS ${DirectX_INC_SEARCH_PATH}
+               DOC "The directory where d3dx11.h resides")
+
+       find_library (DirectX_D3D11_LIBRARY d3d11
+               PATHS ${DirectX_LIB_SEARCH_PATH}
+               DOC "The directory where d3d11 resides")
+
+       find_library (DirectX_D3DX11_LIBRARY d3dx11
+               PATHS ${DirectX_LIB_SEARCH_PATH}
+               DOC "The directory where d3dx11 resides")
+
+       if (DirectX_D3D11_INCLUDE_DIR AND DirectX_D3D11_LIBRARY)
+               set (DirectX_D3D11_FOUND 1)
+               if (DirectX_D3DX11_INCLUDE_DIR AND DirectX_D3DX11_LIBRARY)
+                       set (DirectX_D3DX11_FOUND 1)
+               endif ()
+       endif ()
+
+
+       find_path (DirectX_D3D11_1_INCLUDE_DIR d3d11_1.h
+               PATHS ${DirectX_INC_SEARCH_PATH}
+               DOC "The directory where d3d11_1.h resides")
+
+       if (DirectX_D3D11_1_INCLUDE_DIR AND DirectX_D3D11_LIBRARY)
+               set (DirectX_D3D11_1_FOUND 1)
+       endif ()
+
+
+       find_program (DirectX_FXC_EXECUTABLE fxc
+               PATHS ${DirectX_BIN_SEARCH_PATH}
+               DOC "Path to fxc.exe executable.")
 
 
        find_path (DirectX_D2D1_INCLUDE_DIR d2d1.h
@@ -153,7 +228,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
        endif (DirectX_D2D1_INCLUDE_DIR AND DirectX_D2D1_LIBRARY)
 
 
-       mark_as_advanced(
+       mark_as_advanced (
                DirectX_D3D_INCLUDE_DIR
                DirectX_D3D_INCLUDE_DIR
                DirectX_DDRAW_LIBRARY
@@ -178,11 +253,20 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
                DirectX_D3D10_LIBRARY
                DirectX_D3DX10_INCLUDE_DIR
                DirectX_D3DX10_LIBRARY
+               DirectX_D3D10_1_INCLUDE_DIR
+               DirectX_D3D10_1_LIBRARY
+               DirectX_D3D11_INCLUDE_DIR
+               DirectX_D3D11_LIBRARY
+               DirectX_D3DX11_INCLUDE_DIR
+               DirectX_D3DX11_LIBRARY
+               DirectX_D3D11_1_INCLUDE_DIR
                DirectX_D2D1_INCLUDE_DIR
                DirectX_D2D1_LIBRARY
        )
 
-endif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+
+endif ()
+
 
 mark_as_advanced (
        DirectX_D3D_FOUND
@@ -193,5 +277,12 @@ mark_as_advanced (
        DirectX_D3DX9_FOUND
        DirectX_D3D10_FOUND
        DirectX_D3DX10_FOUND
+       DirectX_D3D10_1_FOUND
+       DirectX_D3D11_FOUND
+       DirectX_D3DX11_FOUND
+       DirectX_D3D11_1_FOUND
        DirectX_D2D1_FOUND
 )
+
+
+# vim:set sw=4 ts=4 noet:
diff --git a/cmake/toolchain/android.toolchain.cmake b/cmake/toolchain/android.toolchain.cmake
new file mode 100644 (file)
index 0000000..37c9ad1
--- /dev/null
@@ -0,0 +1,1125 @@
+# ------------------------------------------------------------------------------
+#  Android CMake toolchain file, for use with the Android NDK r5-r8
+#  Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended).
+#  See home page: http://code.google.com/p/android-cmake/
+#
+#  The file is mantained by the OpenCV project. And also can be found at
+#  http://code.opencv.org/projects/opencv/repository/revisions/master/changes/android/android.toolchain.cmake
+#
+#  Usage Linux:
+#   $ export ANDROID_NDK=/absolute/path/to/the/android-ndk
+#   $ mkdir build && cd build
+#   $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake ..
+#   $ make -j8
+#
+#  Usage Linux (using standalone toolchain):
+#   $ export ANDROID_STANDALONE_TOOLCHAIN=/absolute/path/to/android-toolchain
+#   $ mkdir build && cd build
+#   $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake ..
+#   $ make -j8
+#
+#  Usage Windows:
+#     You need native port of make to build your project.
+#     Android NDK r7 (or newer) already has make.exe on board.
+#     For older NDK you have to install it separately.
+#     For example, this one: http://gnuwin32.sourceforge.net/packages/make.htm
+#
+#   $ SET ANDROID_NDK=C:\absolute\path\to\the\android-ndk
+#   $ mkdir build && cd build
+#   $ cmake.exe -G"MinGW Makefiles"
+#       -DCMAKE_TOOLCHAIN_FILE=path\to\the\android.toolchain.cmake
+#       -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%\prebuilt\windows\bin\make.exe" ..
+#   $ "%ANDROID_NDK%\prebuilt\windows\bin\make.exe"
+#
+#
+#  Options (can be set as cmake parameters: -D<option_name>=<value>):
+#    ANDROID_NDK=/opt/android-ndk - path to the NDK root.
+#      Can be set as environment variable. Can be set only at first cmake run.
+#
+#    ANDROID_STANDALONE_TOOLCHAIN=/opt/android-toolchain - path to the
+#      standalone toolchain. This option is not used if full NDK is found
+#      (ignored if ANDROID_NDK is set).
+#      Can be set as environment variable. Can be set only at first cmake run.
+#
+#    ANDROID_ABI=armeabi-v7a -  specifies the target Application Binary
+#      Interface (ABI). This option nearly matches to the APP_ABI variable
+#      used by ndk-build tool from Android NDK.
+#
+#      Possible targets are:
+#        "armeabi" - matches to the NDK ABI with the same name.
+#           See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
+#        "armeabi-v7a" - matches to the NDK ABI with the same name.
+#           See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
+#        "armeabi-v7a with NEON" - same as armeabi-v7a, but
+#            sets NEON as floating-point unit
+#        "armeabi-v7a with VFPV3" - same as armeabi-v7a, but
+#            sets VFPV3 as floating-point unit (has 32 registers instead of 16).
+#        "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP.
+#        "x86" - matches to the NDK ABI with the same name.
+#            See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
+#        "mips" - matches to the NDK ABI with the same name
+#            (not testes on real devices)
+#
+#    ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
+#      Option is read-only when standalone toolchain used.
+#
+#    ANDROID_FORCE_ARM_BUILD=OFF - set true to generate 32-bit ARM instructions
+#      instead of Thumb-1. Is not available for "x86" (inapplicable) and
+#      "armeabi-v6 with VFP" (forced) ABIs.
+#
+#    ANDROID_NO_UNDEFINED=ON - set true to show all undefined symbols as linker
+#      errors even if they are not used.
+#
+#    ANDROID_SO_UNDEFINED=OFF - set true to allow undefined symbols in shared
+#      libraries. Automatically turned on for NDK r5x and r6x due to GLESv2
+#      problems.
+#
+#    LIBRARY_OUTPUT_PATH_ROOT=${CMAKE_SOURCE_DIR} - where to output binary
+#      files. See additional details below.
+#
+#    ANDROID_SET_OBSOLETE_VARIABLES=ON - it set, then toolchain defines some
+#      obsolete variables which were set by previous versions of this file for
+#      backward compatibility.
+#
+#
+#  What?:
+#    android-cmake toolchain searches for NDK/toolchain in the following order:
+#      ANDROID_NDK - cmake parameter
+#      ANDROID_NDK - environment variable
+#      ANDROID_STANDALONE_TOOLCHAIN - cmake parameter
+#      ANDROID_STANDALONE_TOOLCHAIN - environment variable
+#      ANDROID_NDK - default locations
+#      ANDROID_STANDALONE_TOOLCHAIN - default locations
+#
+#    Make sure to do the following in your scripts:
+#      SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}" )
+#      SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}" )
+#      The flags will be prepopulated with critical flags, so don't loose them.
+#      Also be aware that toolchain also sets configuration-specific compiler
+#      flags and linker flags.
+#
+#    ANDROID and BUILD_ANDROID will be set to true, you may test any of these
+#    variables to make necessary Android-specific configuration changes.
+#
+#    Also ARMEABI or ARMEABI_V7A or X86 will be set true, mutually exclusive.
+#    NEON option will be set true if VFP is set to NEON.
+#
+#    LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where Android
+#    libraries will be installed.
+#    Default is ${CMAKE_SOURCE_DIR}, and the android libs will always be
+#    under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
+#    (depending on the target ABI). This is convenient for Android packaging.
+#
+#  Authors:
+#    Ethan Rublee ethan.ruble@gmail.com
+#    Andrey Kamaev andrey.kamaev@itseez.com
+#
+#  Change Log:
+#   - initial version December 2010
+#   - modified April 2011
+#     [+] added possibility to build with NDK (without standalone toolchain)
+#     [+] support cross-compilation on Windows (native, no cygwin support)
+#     [+] added compiler option to force "char" type to be signed
+#     [+] added toolchain option to compile to 32-bit ARM instructions
+#     [+] added toolchain option to disable SWIG search
+#     [+] added platform "armeabi-v7a with VFPV3"
+#     [~] ARM_TARGETS renamed to ARM_TARGET
+#     [+] EXECUTABLE_OUTPUT_PATH is set by toolchain (required on Windows)
+#     [~] Fixed bug with ANDROID_API_LEVEL variable
+#     [~] turn off SWIG search if it is not found first time
+#   - modified May 2011
+#     [~] ANDROID_LEVEL is renamed to ANDROID_API_LEVEL
+#     [+] ANDROID_API_LEVEL is detected by toolchain if not specified
+#     [~] added guard to prevent changing of output directories on the first
+#         cmake pass
+#     [~] toolchain exits with error if ARM_TARGET is not recognized
+#   - modified June 2011
+#     [~] default NDK path is updated for version r5c
+#     [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET
+#     [~] toolchain install directory is added to linker paths
+#     [-] removed SWIG-related stuff from toolchain
+#     [+] added macro find_host_package, find_host_program to search
+#         packages/programs on the host system
+#     [~] fixed path to STL library
+#   - modified July 2011
+#     [~] fixed options caching
+#     [~] search for all supported NDK versions
+#     [~] allowed spaces in NDK path
+#   - modified September 2011
+#     [~] updated for NDK r6b
+#   - modified November 2011
+#     [*] rewritten for NDK r7
+#     [+] x86 toolchain support (experimental)
+#     [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors.
+#     [~] improved compiler and linker flags management
+#     [+] support different build flags for Release and Debug configurations
+#     [~] by default compiler flags the same as used by ndk-build (but only
+#         where reasonable)
+#     [~] ANDROID_NDK_TOOLCHAIN_ROOT is splitted to ANDROID_STANDALONE_TOOLCHAIN
+#         and ANDROID_TOOLCHAIN_ROOT
+#     [~] ARM_TARGET is renamed to ANDROID_ABI
+#     [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME
+#     [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL
+#   - modified January 2012
+#     [+] added stlport_static support (experimental)
+#     [+] added special check for cygwin
+#     [+] filtered out hidden files (starting with .) while globbing inside NDK
+#     [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6
+#     [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags
+#   - modified February 2012
+#     [+] updated for NDK r7b
+#     [~] fixed cmake try_compile() command
+#     [~] Fix for missing install_name_tool on OS X
+#   - modified March 2012
+#     [~] fixed incorrect C compiler flags
+#     [~] fixed CMAKE_SYSTEM_PROCESSOR change on ANDROID_ABI change
+#     [+] improved toolchain loading speed
+#     [+] added assembler language support (.S)
+#     [+] allowed preset search paths and extra search suffixes
+#   - modified April 2012
+#     [+] updated for NDK r7c
+#     [~] fixed most of problems with compiler/linker flags and caching
+#     [+] added option ANDROID_FUNCTION_LEVEL_LINKING
+#   - modified May 2012
+#     [+] updated for NDK r8
+#     [+] added mips architecture support
+#   - modified August 2012
+#     [+] updated for NDK r8b
+#     [~] all intermediate files generated by toolchain are moved into CMakeFiles
+#     [~] libstdc++ and libsupc are removed from explicit link libraries
+# ------------------------------------------------------------------------------
+
+cmake_minimum_required( VERSION 2.6.3 )
+
+if( DEFINED CMAKE_CROSSCOMPILING )
+ # subsequent toolchain loading is not really needed
+ return()
+endif()
+
+get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
+if( _CMAKE_IN_TRY_COMPILE )
+ include( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL )
+endif()
+
+# this one is important
+set( CMAKE_SYSTEM_NAME Linux )
+# this one not so much
+set( CMAKE_SYSTEM_VERSION 1 )
+
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
+if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
+ if( CMAKE_HOST_WIN32 )
+  file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
+  set( ANDROID_NDK_SEARCH_PATHS "${ANDROID_NDK_SEARCH_PATHS}/android-ndk" "$ENV{SystemDrive}/NVPACK/android-ndk" )
+ else()
+  file( TO_CMAKE_PATH "$ENV{HOME}" ANDROID_NDK_SEARCH_PATHS )
+  set( ANDROID_NDK_SEARCH_PATHS /opt/android-ndk "${ANDROID_NDK_SEARCH_PATHS}/NVPACK/android-ndk" )
+ endif()
+endif()
+if(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH)
+ set( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain )
+endif()
+
+set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" )
+set( ANDROID_SUPPORTED_ABIS_x86 "x86" )
+set( ANDROID_SUPPORTED_ABIS_mipsel "mips" )
+
+set( ANDROID_DEFAULT_NDK_API_LEVEL 8 )
+set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 )
+set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 )
+
+
+macro( __LIST_FILTER listvar regex )
+ if( ${listvar} )
+  foreach( __val ${${listvar}} )
+   if( __val MATCHES "${regex}" )
+    list( REMOVE_ITEM ${listvar} "${__val}" )
+   endif()
+  endforeach()
+ endif()
+endmacro()
+
+macro( __INIT_VARIABLE var_name )
+ set( __test_path 0 )
+ foreach( __var ${ARGN} )
+  if( __var STREQUAL "PATH" )
+   set( __test_path 1 )
+   break()
+  endif()
+ endforeach()
+ if( __test_path AND NOT EXISTS "${${var_name}}" )
+  unset( ${var_name} CACHE )
+ endif()
+ if( "${${var_name}}" STREQUAL "" )
+  set( __values 0 )
+  foreach( __var ${ARGN} )
+   if( __var STREQUAL "VALUES" )
+    set( __values 1 )
+   elseif( NOT __var STREQUAL "PATH" )
+    set( __obsolete 0 )
+    if( __var MATCHES "^OBSOLETE_.*$" )
+     string( REPLACE "OBSOLETE_" "" __var "${__var}" )
+     set( __obsolete 1 )
+    endif()
+    if( __var MATCHES "^ENV_.*$" )
+     string( REPLACE "ENV_" "" __var "${__var}" )
+     set( __value "$ENV{${__var}}" )
+    elseif( DEFINED ${__var} )
+     set( __value "${${__var}}" )
+    else()
+     if( __values )
+      set( __value "${__var}" )
+     else()
+      set( __value "" )
+     endif()
+    endif()
+    if( NOT "${__value}" STREQUAL "" )
+     if( __test_path )
+      if( EXISTS "${__value}" )
+       set( ${var_name} "${__value}" )
+       if( __obsolete )
+        message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." )
+       endif()
+       break()
+      endif()
+     else()
+      set( ${var_name} "${__value}" )
+       if( __obsolete )
+        message( WARNING "Using value of obsolete variable ${__var} as initial value for ${var_name}. Please note, that ${__var} can be completely removed in future versions of the toolchain." )
+       endif()
+      break()
+     endif()
+    endif()
+   endif()
+  endforeach()
+  unset( __value )
+  unset( __values )
+  unset( __obsolete )
+ endif()
+ unset( __test_path )
+endmacro()
+
+macro( __DETECT_NATIVE_API_LEVEL _var _path )
+ SET( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*$" )
+ FILE( STRINGS ${_path} __apiFileContent REGEX "${__ndkApiLevelRegex}" )
+ if( NOT __apiFileContent )
+  message( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." )
+ endif()
+ string( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${_var} "${__apiFileContent}" )
+ unset( __apiFileContent )
+ unset( __ndkApiLevelRegex )
+endmacro()
+
+macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root )
+ file( GLOB __gccExePath "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
+ __LIST_FILTER( __gccExePath "bin/[.].*-gcc${TOOL_OS_SUFFIX}$" )
+ list( LENGTH __gccExePath __gccExePathsCount )
+ if( NOT __gccExePathsCount EQUAL 1 )
+  message( WARNING "Could not uniquely determine machine name for compiler from ${_root}." )
+  set( ${_var} "" )
+ else()
+  get_filename_component( __gccExeName "${__gccExePath}" NAME_WE )
+  string( REPLACE "-gcc" "" ${_var} "${__gccExeName}" )
+ endif()
+ unset( __gccExePath )
+ unset( __gccExePathsCount )
+ unset( __gccExeName )
+endmacro()
+
+macro( __COPY_IF_DIFFERENT _source _destination )
+ execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_source}" "${_destination}" RESULT_VARIABLE __fileCopyProcess )
+ if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${_destination}")
+  message( SEND_ERROR "Failed copying of ${_source} to the ${_destination}" )
+ endif()
+ unset( __fileCopyProcess )
+endmacro()
+
+
+# stl version: by default gnustl_static will be used
+set( ANDROID_USE_STLPORT FALSE CACHE BOOL "Experimental: use stlport_static instead of gnustl_static")
+mark_as_advanced( ANDROID_USE_STLPORT )
+
+# fight against cygwin
+set( ANDROID_FORBID_SYGWIN TRUE CACHE BOOL "Prevent cmake from working under cygwin and using cygwin tools")
+mark_as_advanced( ANDROID_FORBID_SYGWIN )
+if( ANDROID_FORBID_SYGWIN )
+ if( CYGWIN )
+  message( FATAL_ERROR "Android NDK and android-cmake toolchain are not welcome Cygwin. It is unlikely that this cmake toolchain will work under cygwin. But if you want to try then you can set cmake variable ANDROID_FORBID_SYGWIN to FALSE and rerun cmake." )
+ endif()
+
+ if( CMAKE_HOST_WIN32 )
+  # remove cygwin from PATH
+  set( __new_path "$ENV{PATH}")
+  __LIST_FILTER( __new_path "cygwin" )
+  set(ENV{PATH} "${__new_path}")
+  unset(__new_path)
+ endif()
+endif()
+
+# detect current host platform
+set( TOOL_OS_SUFFIX "" )
+if( CMAKE_HOST_APPLE )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME "darwin-x86" )
+elseif( CMAKE_HOST_WIN32 )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME "windows" )
+ set( TOOL_OS_SUFFIX ".exe" )
+elseif( CMAKE_HOST_UNIX )
+ set( ANDROID_NDK_HOST_SYSTEM_NAME "linux-x86" )
+else()
+ message( FATAL_ERROR "Cross-compilation on your platform is not supported by this cmake toolchain" )
+endif()
+
+# see if we have path to Android NDK
+__INIT_VARIABLE( ANDROID_NDK PATH ENV_ANDROID_NDK )
+if( NOT ANDROID_NDK )
+ # see if we have path to Android standalone toolchain
+ __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ENV_ANDROID_STANDALONE_TOOLCHAIN OBSOLETE_ANDROID_NDK_TOOLCHAIN_ROOT OBSOLETE_ENV_ANDROID_NDK_TOOLCHAIN_ROOT )
+
+ if( NOT ANDROID_STANDALONE_TOOLCHAIN )
+  #try to find Android NDK in one of the the default locations
+  set( __ndkSearchPaths )
+  foreach( __ndkSearchPath ${ANDROID_NDK_SEARCH_PATHS} )
+   foreach( suffix ${ANDROID_SUPPORTED_NDK_VERSIONS} )
+    list( APPEND __ndkSearchPaths "${__ndkSearchPath}${suffix}" )
+   endforeach()
+  endforeach()
+  __INIT_VARIABLE( ANDROID_NDK PATH VALUES ${__ndkSearchPaths} )
+  unset( __ndkSearchPaths )
+
+  if( ANDROID_NDK )
+   message( STATUS "Using default path for Android NDK: ${ANDROID_NDK}" )
+   message( STATUS "  If you prefer to use a different location, please define a cmake or environment variable: ANDROID_NDK" )
+  else()
+   #try to find Android standalone toolchain in one of the the default locations
+   __INIT_VARIABLE( ANDROID_STANDALONE_TOOLCHAIN PATH ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH )
+
+   if( ANDROID_STANDALONE_TOOLCHAIN )
+    message( STATUS "Using default path for standalone toolchain ${ANDROID_STANDALONE_TOOLCHAIN}" )
+    message( STATUS "  If you prefer to use a different location, please define the variable: ANDROID_STANDALONE_TOOLCHAIN" )
+   endif( ANDROID_STANDALONE_TOOLCHAIN )
+  endif( ANDROID_NDK )
+ endif( NOT ANDROID_STANDALONE_TOOLCHAIN )
+endif( NOT ANDROID_NDK )
+
+# remember found paths
+if( ANDROID_NDK )
+ get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE )
+ # try to detect change
+ if( CMAKE_AR )
+  string( LENGTH "${ANDROID_NDK}" __length )
+  string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath )
+  if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK )
+   message( FATAL_ERROR "It is not possible to change path to the NDK on subsequent run." )
+  endif()
+  unset( __androidNdkPreviousPath )
+  unset( __length )
+ endif()
+ set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" )
+ set( BUILD_WITH_ANDROID_NDK True )
+elseif( ANDROID_STANDALONE_TOOLCHAIN )
+ get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
+ # try to detect change
+ if( CMAKE_AR )
+  string( LENGTH "${ANDROID_STANDALONE_TOOLCHAIN}" __length )
+  string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidStandaloneToolchainPreviousPath )
+  if( NOT __androidStandaloneToolchainPreviousPath STREQUAL ANDROID_STANDALONE_TOOLCHAIN )
+   message( FATAL_ERROR "It is not possible to change path to the Android standalone toolchain on subsequent run." )
+  endif()
+  unset( __androidStandaloneToolchainPreviousPath )
+  unset( __length )
+ endif()
+ set( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" CACHE INTERNAL "Path of the Android standalone toolchain" )
+ set( BUILD_WITH_STANDALONE_TOOLCHAIN True )
+else()
+ list(GET ANDROID_NDK_SEARCH_PATHS 0 ANDROID_NDK_SEARCH_PATH)
+ message( FATAL_ERROR "Could not find neither Android NDK nor Android standalone toolcahin.
+    You should either set an environment variable:
+      export ANDROID_NDK=~/my-android-ndk
+    or
+      export ANDROID_STANDALONE_TOOLCHAIN=~/my-android-toolchain
+    or put the toolchain or NDK in the default path:
+      sudo ln -s ~/my-android-ndk ${ANDROID_NDK_SEARCH_PATH}
+      sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" )
+endif()
+
+# get all the details about standalone toolchain
+if( BUILD_WITH_STANDALONE_TOOLCHAIN )
+ __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" )
+ set( ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
+ set( __availableToolchains "standalone" )
+ __DETECT_TOOLCHAIN_MACHINE_NAME( __availableToolchainMachines "${ANDROID_STANDALONE_TOOLCHAIN}" )
+ if( NOT __availableToolchainMachines )
+  message( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." )
+ endif()
+ if( __availableToolchainMachines MATCHES i686 )
+  set( __availableToolchainArchs "x86" )
+ elseif( __availableToolchainMachines MATCHES arm )
+  set( __availableToolchainArchs "arm" )
+ elseif( __availableToolchainMachines MATCHES mipsel )
+  set( __availableToolchainArchs "mipsel" )
+ endif()
+ if( ANDROID_COMPILER_VERSION )
+  # do not run gcc every time because it is relatevely expencive
+  set( __availableToolchainCompilerVersions "${ANDROID_COMPILER_VERSION}" )
+ else()
+  execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" --version
+   OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE )
+  string( REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" )
+ endif()
+endif()
+
+# get all the details about NDK
+if( BUILD_WITH_ANDROID_NDK )
+ file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" )
+ string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
+ file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
+ __LIST_FILTER( __availableToolchains "^[.]" )
+ set( __availableToolchainMachines "" )
+ set( __availableToolchainArchs "" )
+ set( __availableToolchainCompilerVersions "" )
+ foreach( __toolchain ${__availableToolchains} )
+  __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+  if( __machine )
+   string( REGEX MATCH "[0-9]+[.][0-9]+[.]*[0-9]*$" __version "${__toolchain}" )
+   string( REGEX MATCH "^[^-]+" __arch "${__toolchain}" )
+   list( APPEND __availableToolchainMachines "${__machine}" )
+   list( APPEND __availableToolchainArchs "${__arch}" )
+   list( APPEND __availableToolchainCompilerVersions "${__version}" )
+  else()
+   list( REMOVE_ITEM __availableToolchains "${__toolchain}" )
+  endif()
+ endforeach()
+ if( NOT __availableToolchains )
+  message( FATAL_ERROR "Could not any working toolchain in the NDK. Probably your Android NDK is broken." )
+ endif()
+endif()
+
+# build list of available ABIs
+if( NOT ANDROID_SUPPORTED_ABIS )
+ set( ANDROID_SUPPORTED_ABIS "" )
+ set( __uniqToolchainArchNames ${__availableToolchainArchs} )
+ list( REMOVE_DUPLICATES __uniqToolchainArchNames )
+ list( SORT __uniqToolchainArchNames )
+ foreach( __arch ${__uniqToolchainArchNames} )
+  list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
+ endforeach()
+ unset( __uniqToolchainArchNames )
+ if( NOT ANDROID_SUPPORTED_ABIS )
+  message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
+ endif()
+endif()
+
+# choose target ABI
+__INIT_VARIABLE( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${ANDROID_SUPPORTED_ABIS} )
+# verify that target ABI is supported
+list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx )
+if( __androidAbiIdx EQUAL -1 )
+ string( REPLACE ";" "\", \"", PRINTABLE_ANDROID_SUPPORTED_ABIS  "${ANDROID_SUPPORTED_ABIS}" )
+ message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain.
+   Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\"
+   " )
+endif()
+unset( __androidAbiIdx )
+
+# remember target ABI
+set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
+
+# set target ABI options
+if( ANDROID_ABI STREQUAL "x86" )
+ set( X86 true )
+ set( ANDROID_NDK_ABI_NAME "x86" )
+ set( ANDROID_ARCH_NAME "x86" )
+ set( ANDROID_ARCH_FULLNAME "x86" )
+ set( CMAKE_SYSTEM_PROCESSOR "i686" )
+elseif( ANDROID_ABI STREQUAL "mips" )
+ set( MIPS true )
+ set( ANDROID_NDK_ABI_NAME "mips" )
+ set( ANDROID_ARCH_NAME "mips" )
+ set( ANDROID_ARCH_FULLNAME "mipsel" )
+ set( CMAKE_SYSTEM_PROCESSOR "mips" )
+elseif( ANDROID_ABI STREQUAL "armeabi" )
+ set( ARMEABI true )
+ set( ANDROID_NDK_ABI_NAME "armeabi" )
+ set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
+ set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
+elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
+ set( ARMEABI_V6 true )
+ set( ANDROID_NDK_ABI_NAME "armeabi" )
+ set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
+ set( CMAKE_SYSTEM_PROCESSOR "armv6" )
+ # need always fallback to older platform
+ set( ARMEABI true )
+elseif( ANDROID_ABI STREQUAL "armeabi-v7a")
+ set( ARMEABI_V7A true )
+ set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
+ set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
+ set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
+elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" )
+ set( ARMEABI_V7A true )
+ set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
+ set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
+ set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
+ set( VFPV3 true )
+elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
+ set( ARMEABI_V7A true )
+ set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
+ set( ANDROID_ARCH_NAME "arm" )
+ set( ANDROID_ARCH_FULLNAME "arm" )
+ set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
+ set( VFPV3 true )
+ set( NEON true )
+else()
+ message( SEND_ERROR "Unknown ANDROID_ABI=\"${ANDROID_ABI}\" is specified." )
+endif()
+
+if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" )
+ # really dirty hack
+ # it is not possible to change CMAKE_SYSTEM_PROCESSOR after the first run...
+ file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" )
+endif()
+
+set( ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} CACHE INTERNAL "ANDROID_ABI can be changed only to one of these ABIs. Changing to any other ABI requires to reset cmake cache." )
+if( CMAKE_VERSION VERSION_GREATER "2.8" )
+ list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
+ set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
+endif()
+
+if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 )
+ __INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD OBSOLETE_FORCE_ARM VALUES OFF )
+ set( ANDROID_FORCE_ARM_BUILD ${ANDROID_FORCE_ARM_BUILD} CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE )
+ mark_as_advanced( ANDROID_FORCE_ARM_BUILD )
+else()
+ unset( ANDROID_FORCE_ARM_BUILD CACHE )
+endif()
+
+# choose toolchain
+if( ANDROID_TOOLCHAIN_NAME )
+ list( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx )
+ if( __toolchainIdx EQUAL -1 )
+  message( FATAL_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing. You need to remove CMakeCache.txt and rerun cmake manually to change the toolchain" )
+ endif()
+ list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch )
+ if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
+  message( SEND_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
+ endif()
+else()
+ set( __toolchainIdx -1 )
+ set( __applicableToolchains "" )
+ set( __toolchainMaxVersion "0.0.0" )
+ list( LENGTH __availableToolchains __availableToolchainsCount )
+ math( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" )
+ foreach( __idx RANGE ${__availableToolchainsCount} )
+  list( GET __availableToolchainArchs ${__idx} __toolchainArch )
+  if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
+   list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion )
+   if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
+    set( __toolchainMaxVersion "${__toolchainVersion}" )
+    set( __toolchainIdx ${__idx} )
+   endif()
+  endif()
+ endforeach()
+ unset( __availableToolchainsCount )
+ unset( __toolchainMaxVersion )
+ unset( __toolchainVersion )
+endif()
+unset( __toolchainArch )
+if( __toolchainIdx EQUAL -1 )
+ message( FATAL_ERROR "No one of available compiler toolchains is able to compile for ${ANDROID_ARCH_NAME} platform." )
+endif()
+list( GET __availableToolchains ${__toolchainIdx} ANDROID_TOOLCHAIN_NAME )
+list( GET __availableToolchainMachines ${__toolchainIdx} ANDROID_TOOLCHAIN_MACHINE_NAME )
+list( GET __availableToolchainCompilerVersions ${__toolchainIdx} ANDROID_COMPILER_VERSION )
+set( ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" CACHE INTERNAL "Name of toolchain used" )
+set( ANDROID_COMPILER_VERSION "${ANDROID_COMPILER_VERSION}" CACHE INTERNAL "compiler version from selected toolchain" )
+unset( __toolchainIdx )
+unset( __availableToolchains )
+unset( __availableToolchainMachines )
+unset( __availableToolchainArchs )
+unset( __availableToolchainCompilerVersions )
+
+# choose native API level
+__INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL )
+string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
+# validate
+list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
+if( __levelIdx EQUAL -1 )
+ message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
+endif()
+unset( __levelIdx )
+if( BUILD_WITH_ANDROID_NDK )
+ __DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
+ if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
+  message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
+ endif()
+ unset( __realApiLevel )
+endif()
+set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
+if( CMAKE_VERSION VERSION_GREATER "2.8" )
+ list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
+ set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
+endif()
+
+# setup paths
+if( BUILD_WITH_STANDALONE_TOOLCHAIN )
+ set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
+ set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
+ set( __stlLibPath "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
+endif()
+if( BUILD_WITH_ANDROID_NDK )
+ set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
+ set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
+ if( ANDROID_USE_STLPORT )
+  set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/stlport/stlport" )
+  set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/stlport/libs/${ANDROID_NDK_ABI_NAME}" )
+ else()
+  if( EXISTS "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}" )
+   set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/include" )
+   set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}" )
+  else()
+   set( __stlIncludePath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/include" )
+   set( __stlLibPath "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}" )
+  endif()
+ endif()
+endif()
+
+# specify the cross compiler
+set( CMAKE_C_COMPILER   "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"     CACHE PATH "gcc" )
+set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}"     CACHE PATH "g++" )
+set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}"     CACHE PATH "Assembler" )
+if( CMAKE_VERSION VERSION_LESS 2.8.5 )
+ set( CMAKE_ASM_COMPILER_ARG1 "-c" )
+endif()
+# there may be a way to make cmake deduce these TODO deduce the rest of the tools
+set( CMAKE_STRIP        "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}"   CACHE PATH "strip" )
+set( CMAKE_AR           "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}"      CACHE PATH "archive" )
+set( CMAKE_LINKER       "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}"      CACHE PATH "linker" )
+set( CMAKE_NM           "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}"      CACHE PATH "nm" )
+set( CMAKE_OBJCOPY      "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" )
+set( CMAKE_OBJDUMP      "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objdump${TOOL_OS_SUFFIX}" CACHE PATH "objdump" )
+set( CMAKE_RANLIB       "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ranlib${TOOL_OS_SUFFIX}"  CACHE PATH "ranlib" )
+set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" )
+if( APPLE )
+ find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool )
+ if( NOT CMAKE_INSTALL_NAME_TOOL )
+  message( FATAL_ERROR "Could not find install_name_tool, please check your installation." )
+ endif()
+ mark_as_advanced( CMAKE_INSTALL_NAME_TOOL )
+endif()
+
+# export directories
+set( ANDROID_SYSTEM_INCLUDE_DIRS "" )
+set( ANDROID_SYSTEM_LIB_DIRS "" )
+
+# setup output directories
+set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
+set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
+
+if(NOT _CMAKE_IN_TRY_COMPILE)
+ if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
+  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
+ else()
+  set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
+ endif()
+ set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
+endif()
+
+# includes
+list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_SYSROOT}/usr/include" )
+if( __stlIncludePath AND EXISTS "${__stlIncludePath}" )
+ list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlIncludePath}" )
+endif()
+
+# c++ bits includes
+if( __stlLibPath AND EXISTS "${__stlLibPath}/include" )
+ list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${__stlLibPath}/include" )
+endif()
+if( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb/bits" )
+ list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
+elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
+ list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
+elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
+ list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
+elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/bits" )
+ list( APPEND ANDROID_SYSTEM_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
+endif()
+
+# flags and definitions
+if(ANDROID_SYSROOT MATCHES "[ ;\"]")
+ set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
+ # quotes will break try_compile and compiler identification
+ message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.")
+else()
+ set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
+endif()
+
+remove_definitions( -DANDROID )
+add_definitions( -DANDROID )
+
+# Force set compilers because standard identification works badly for us
+include( CMakeForceCompiler )
+CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
+set( CMAKE_C_PLATFORM_ID Linux )
+set( CMAKE_C_SIZEOF_DATA_PTR 4 )
+set( CMAKE_C_HAS_ISYSROOT 1 )
+set( CMAKE_C_COMPILER_ABI ELF )
+CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
+set( CMAKE_CXX_PLATFORM_ID Linux )
+set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
+set( CMAKE_CXX_HAS_ISYSROOT 1 )
+set( CMAKE_CXX_COMPILER_ABI ELF )
+# force ASM compiler (required for CMake < 2.8.5)
+set( CMAKE_ASM_COMPILER_ID_RUN TRUE )
+set( CMAKE_ASM_COMPILER_ID GNU )
+set( CMAKE_ASM_COMPILER_WORKS TRUE )
+set( CMAKE_ASM_COMPILER_FORCED TRUE )
+set( CMAKE_COMPILER_IS_GNUASM 1)
+
+# NDK flags
+if( ARMEABI OR ARMEABI_V7A )
+ # NDK also defines -ffunction-sections -funwind-tables but they result in worse OpenCV performance
+ set( _CMAKE_CXX_FLAGS "-fPIC -Wno-psabi" )
+ set( _CMAKE_C_FLAGS "-fPIC -Wno-psabi" )
+ remove_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
+ add_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
+ # extra arm-specific flags
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
+elseif( X86 )
+ set( _CMAKE_CXX_FLAGS "-funwind-tables" )
+ set( _CMAKE_C_FLAGS "-funwind-tables" )
+elseif( MIPS )
+ set( _CMAKE_CXX_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
+ set( _CMAKE_CXX_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
+else()
+ set( _CMAKE_CXX_FLAGS "" )
+ set( _CMAKE_C_FLAGS "" )
+endif()
+
+if( ANDROID_USE_STLPORT )
+ set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions" )
+ set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fno-exceptions" )
+else()
+ set( _CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS} -frtti -fexceptions" )
+ set( _CMAKE_C_FLAGS "${_CMAKE_C_FLAGS} -fexceptions" )
+endif()
+
+# release and debug flags
+if( ARMEABI OR ARMEABI_V7A )
+ if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
+  # It is recommended to use the -mthumb compiler flag to force the generation
+  # of 16-bit Thumb-1 instructions (the default being 32-bit ARM ones).
+  # O3 instead of O2/Os in release mode - like cmake sets for desktop gcc
+  set( _CMAKE_CXX_FLAGS_RELEASE "-mthumb -O3" )
+  set( _CMAKE_C_FLAGS_RELEASE   "-mthumb -O3" )
+  set( _CMAKE_CXX_FLAGS_DEBUG "-marm -Os -finline-limit=64" )
+  set( _CMAKE_C_FLAGS_DEBUG   "-marm -Os -finline-limit=64" )
+ else()
+  # always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI
+  # O3 instead of O2/Os in release mode - like cmake sets for desktop gcc
+  set( _CMAKE_CXX_FLAGS_RELEASE "-marm -O3 -fstrict-aliasing" )
+  set( _CMAKE_C_FLAGS_RELEASE   "-marm -O3 -fstrict-aliasing" )
+  set( _CMAKE_CXX_FLAGS_DEBUG "-marm -O0 -finline-limit=300" )
+  set( _CMAKE_C_FLAGS_DEBUG   "-marm -O0 -finline-limit=300" )
+ endif()
+elseif( X86 )
+ set( _CMAKE_CXX_FLAGS_RELEASE "-O3 -fstrict-aliasing" )
+ set( _CMAKE_C_FLAGS_RELEASE   "-O3 -fstrict-aliasing" )
+ set( _CMAKE_CXX_FLAGS_DEBUG "-O0 -finline-limit=300" )
+ set( _CMAKE_C_FLAGS_DEBUG   "-O0 -finline-limit=300" )
+elseif( MIPS )
+ set( _CMAKE_CXX_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
+ set( _CMAKE_C_FLAGS_RELEASE   "-O3 -funswitch-loops -finline-limit=300" )
+ set( _CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
+ set( _CMAKE_C_FLAGS_DEBUG   "-O0 -g" )
+endif()
+set( _CMAKE_CXX_FLAGS_RELEASE "${_CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
+set( _CMAKE_C_FLAGS_RELEASE   "${_CMAKE_C_FLAGS_RELEASE}   -fomit-frame-pointer -DNDEBUG" )
+set( _CMAKE_CXX_FLAGS_DEBUG "${_CMAKE_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
+set( _CMAKE_C_FLAGS_DEBUG   "${_CMAKE_C_FLAGS_DEBUG}   -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
+
+# ABI-specific flags
+if( ARMEABI_V7A )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp" )
+ if( NEON )
+  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=neon" )
+ elseif( VFPV3 )
+  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" )
+ else()
+  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfp" )
+ endif()
+elseif( ARMEABI_V6 )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" )
+elseif( ARMEABI )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
+elseif( X86 )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" )#sse?
+endif()
+
+# linker flags
+if( NOT DEFINED __ndklibspath )
+ set( __ndklibspath "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ndklibs/${ANDROID_NDK_ABI_NAME}" )
+endif()
+list( APPEND ANDROID_SYSTEM_LIB_DIRS "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
+set( ANDROID_LINKER_FLAGS "" )
+
+# STL
+if( ANDROID_USE_STLPORT )
+ if( EXISTS "${__stlLibPath}/libstlport_static.a" )
+  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \"${__stlLibPath}/libstlport_static.a\"")
+  set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> \"${__stlLibPath}/libstlport_static.a\"")
+ endif()
+else( ANDROID_USE_STLPORT )
+ if( EXISTS "${__stlLibPath}/libgnustl_static.a" )
+  __COPY_IF_DIFFERENT( "${__stlLibPath}/libgnustl_static.a" "${__ndklibspath}/libstdc++.a" )
+ elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
+  __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
+ elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" )
+  __COPY_IF_DIFFERENT( "${__stlLibPath}/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
+ elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${__stlLibPath}/thumb/libstdc++.a" )
+  __COPY_IF_DIFFERENT( "${__stlLibPath}/thumb/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
+ elseif( EXISTS "${__stlLibPath}/libstdc++.a" )
+  __COPY_IF_DIFFERENT( "${__stlLibPath}/libstdc++.a" "${__ndklibspath}/libstdc++.a" )
+ endif()
+ if( EXISTS "${__stlLibPath}/libsupc++.a" )
+  __COPY_IF_DIFFERENT( "${__stlLibPath}/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
+ elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" )
+  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
+ elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" )
+  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
+ elseif( ANDROID_ARCH_NAME STREQUAL "arm" AND EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" )
+  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
+ elseif( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" )
+  __COPY_IF_DIFFERENT( "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libsupc++.a" "${__ndklibspath}/libsupc++.a" )
+ endif()
+ list( APPEND ANDROID_SYSTEM_LIB_DIRS "${__ndklibspath}" )
+endif( ANDROID_USE_STLPORT )
+
+# cleanup for STL search
+unset( __stlIncludePath )
+unset( __stlLibPath )
+
+# other linker flags
+__INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
+set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" FORCE )
+mark_as_advanced( ANDROID_NO_UNDEFINED )
+if( ANDROID_NO_UNDEFINED )
+ set( ANDROID_LINKER_FLAGS "-Wl,--no-undefined ${ANDROID_LINKER_FLAGS}" )
+endif()
+
+if (ANDROID_NDK MATCHES "-r[56].?$")
+ # libGLESv2.so in NDK's prior to r7 refers to exteranal symbols. So this flag option is required for all projects using OpenGL from native.
+ __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON )
+else()
+ __INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF )
+endif()
+
+set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
+mark_as_advanced( ANDROID_SO_UNDEFINED )
+if( ANDROID_SO_UNDEFINED )
+ set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" )
+endif()
+
+__INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON )
+set( ANDROID_FUNCTION_LEVEL_LINKING ON CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
+mark_as_advanced( ANDROID_FUNCTION_LEVEL_LINKING )
+if( ANDROID_FUNCTION_LEVEL_LINKING )
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
+ set( ANDROID_LINKER_FLAGS "-Wl,--gc-sections ${ANDROID_LINKER_FLAGS}" )
+endif()
+
+if( ARMEABI_V7A )
+ # this is *required* to use the following linker flags that routes around
+ # a CPU bug in some Cortex-A8 implementations:
+ set( ANDROID_LINKER_FLAGS "-Wl,--fix-cortex-a8 ${ANDROID_LINKER_FLAGS}" )
+endif()
+
+# cache flags
+set( CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
+set( CMAKE_C_FLAGS "${_CMAKE_C_FLAGS}" CACHE STRING "c flags" )
+set( CMAKE_CXX_FLAGS_RELEASE "${_CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c++ Release flags" )
+set( CMAKE_C_FLAGS_RELEASE "${_CMAKE_C_FLAGS_RELEASE}" CACHE STRING "c Release flags" )
+set( CMAKE_CXX_FLAGS_DEBUG "${_CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c++ Debug flags" )
+set( CMAKE_C_FLAGS_DEBUG "${_CMAKE_C_FLAGS_DEBUG}" CACHE STRING "c Debug flags" )
+set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "linker flags" )
+set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" )
+set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "linker flags" )
+
+include_directories( SYSTEM ${ANDROID_SYSTEM_INCLUDE_DIRS} )
+link_directories( ${ANDROID_SYSTEM_LIB_DIRS} )
+
+# finish flags
+set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS}"    CACHE INTERNAL "Extra Android compiler flags")
+set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Extra Android linker flags")
+set( CMAKE_CXX_FLAGS           "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
+set( CMAKE_C_FLAGS             "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
+if( MIPS AND BUILD_WITH_ANDROID_NDK )
+ set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
+ set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
+ set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
+else()
+ set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
+ set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
+ set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
+endif()
+
+# set these global flags for cmake client scripts to change behavior
+set( ANDROID True )
+set( BUILD_ANDROID True )
+
+# where is the target environment
+set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_ROOT}/bin" "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" "${ANDROID_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" )
+
+# only search for libraries and includes in the ndk toolchain
+set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
+set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
+set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
+
+
+# macro to find packages on the host OS
+macro( find_host_package )
+ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
+ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
+ set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
+ if( CMAKE_HOST_WIN32 )
+  SET( WIN32 1 )
+  SET( UNIX )
+ elseif( CMAKE_HOST_APPLE )
+  SET( APPLE 1 )
+  SET( UNIX )
+ endif()
+ find_package( ${ARGN} )
+ SET( WIN32 )
+ SET( APPLE )
+ SET( UNIX 1 )
+ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
+ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
+ set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
+endmacro()
+
+
+# macro to find programs on the host OS
+macro( find_host_program )
+ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
+ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
+ set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
+ if( CMAKE_HOST_WIN32 )
+  SET( WIN32 1 )
+  SET( UNIX )
+ elseif( CMAKE_HOST_APPLE )
+  SET( APPLE 1 )
+  SET( UNIX )
+ endif()
+ find_program( ${ARGN} )
+ SET( WIN32 )
+ SET( APPLE )
+ SET( UNIX 1 )
+ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
+ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
+ set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
+endmacro()
+
+
+macro( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR )
+ if( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI" )
+  set( ${VAR} "armeabi" )
+ elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" )
+    set( ${VAR} "armeabi-v7a" )
+ elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86" )
+    set( ${VAR} "x86" )
+ else()
+    set( ${VAR} "unknown" )
+ endif()
+endmacro()
+
+
+# export toolchain settings for the try_compile() command
+if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
+ set( __toolchain_config "")
+ foreach( __var ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_USE_STLPORT ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN ANDROID_FUNCTION_LEVEL_LINKING __ndklibspath )
+  if( DEFINED ${__var} )
+   if( "${__var}" MATCHES " ")
+    set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" )
+   else()
+    set( __toolchain_config "${__toolchain_config}set( ${__var} ${${__var}} CACHE INTERNAL \"\" )\n" )
+   endif()
+  endif()
+ endforeach()
+ file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/android.toolchain.config.cmake" "${__toolchain_config}" )
+ unset( __toolchain_config )
+ unset( __ndklibspath )
+endif()
+
+
+# set some obsolete variables for backward compatibility
+set( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" )
+mark_as_advanced( ANDROID_SET_OBSOLETE_VARIABLES )
+if( ANDROID_SET_OBSOLETE_VARIABLES )
+ set( ANDROID_API_LEVEL ${ANDROID_NATIVE_API_LEVEL} )
+ set( ARM_TARGET "${ANDROID_ABI}" )
+ set( ARMEABI_NDK_NAME "${ANDROID_NDK_ABI_NAME}" )
+endif()
+
+
+# Variables controlling behavior or set by cmake toolchain:
+#   ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
+#   ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version)
+#   ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
+#   ANDROID_USE_STLPORT : OFF/ON - EXPERIMENTAL!!!
+#   ANDROID_FORBID_SYGWIN : ON/OFF
+#   ANDROID_NO_UNDEFINED : ON/OFF
+#   ANDROID_SO_UNDEFINED : OFF/ON  (default depends on NDK version)
+#   ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF
+# Variables that takes effect only at first run:
+#   ANDROID_FORCE_ARM_BUILD : ON/OFF
+#   LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
+# Can be set only at the first run:
+#   ANDROID_NDK
+#   ANDROID_STANDALONE_TOOLCHAIN
+#   ANDROID_TOOLCHAIN_NAME : "arm-linux-androideabi-4.4.3" or "arm-linux-androideabi-4.6" or "mipsel-linux-android-4.4.3" or "mipsel-linux-android-4.6" or "x86-4.4.3" or "x86-4.6"
+# Obsolete:
+#   ANDROID_API_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL
+#   ARM_TARGET : superseded by ANDROID_ABI
+#   ARM_TARGETS : superseded by ANDROID_ABI (can be set only)
+#   ANDROID_NDK_TOOLCHAIN_ROOT : superseded by ANDROID_STANDALONE_TOOLCHAIN (can be set only)
+#   ANDROID_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL (completely removed)
+#
+# Primary read-only variables:
+#   ANDROID : always TRUE
+#   ARMEABI : TRUE for arm v6 and older devices
+#   ARMEABI_V6 : TRUE for arm v6
+#   ARMEABI_V7A : TRUE for arm v7a
+#   NEON : TRUE if NEON unit is enabled
+#   VFPV3 : TRUE if VFP version 3 is enabled
+#   X86 : TRUE if configured for x86
+#   BUILD_ANDROID : always TRUE
+#   BUILD_WITH_ANDROID_NDK : TRUE if NDK is used
+#   BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used
+#   ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform
+#   ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a" or "x86" depending on ANDROID_ABI
+#   ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
+#   TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
+#   ANDROID_SYSROOT : path to the compiler sysroot
+#   ANDROID_SYSTEM_INCLUDE_DIRS
+#   ANDROID_SYSTEM_LIB_DIRS
+# Obsolete:
+#   ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME
+#
+# Secondary (less stable) read-only variables:
+#   ANDROID_COMPILER_VERSION : GCC version used
+#   ANDROID_CXX_FLAGS : C/C++ compiler flags required by Android platform
+#   ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI
+#   ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux"
+#   ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK)
+#   ANDROID_SUPPORTED_NATIVE_API_LEVELS : list of native API levels found inside NDK
+#
+# Defaults:
+#   ANDROID_DEFAULT_NDK_API_LEVEL
+#   ANDROID_DEFAULT_NDK_API_LEVEL_${ARCH}
+#   ANDROID_NDK_SEARCH_PATHS
+#   ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH
+#   ANDROID_SUPPORTED_ABIS_${ARCH}
+#   ANDROID_SUPPORTED_NDK_VERSIONS
diff --git a/codegen.py b/codegen.py
deleted file mode 100644 (file)
index 4a6405d..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-##########################################################################
-#
-# Copyright 2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""C code generation helpers."""
-
-
-def _string_switch(var, prefix, suffixes, case, default):
-    index = len(prefix)
-    indent = '    '*(index + 1)
-
-    if len(suffixes) == 1:
-        suffix = suffixes[0]
-        chars = list(suffix) + ["\\0"]
-        predicates = ['%s[%u] == \'%s\'' % (var, index + i, chars[i]) for i in range(len(chars))]
-        print indent + 'if (%s) {' % (' && '.join(predicates),)
-        value = prefix + suffix
-        print indent + '    // %s' % value
-        case(value)
-        print indent + '}'
-        if default is not None:
-            print indent + 'else {'
-            default()
-            print indent + '}'
-        return
-
-    print indent + 'switch (%s[%u]) {' % (var, index)
-    if "" in suffixes:
-        print indent + 'case \'\\0\':'
-        print indent + '    // %s' % prefix
-        case(prefix)
-        print indent + '    break;'
-
-    chars = [suffix[0] for suffix in suffixes if suffix]
-    chars = list(set(chars))
-    chars.sort()
-
-    for char in chars:
-        print indent + 'case \'%c\':' % (char)
-        new_prefix = prefix + char
-        new_suffixes = [suffix[1:] for suffix in suffixes if suffix.startswith(char)]
-        _string_switch(var, new_prefix, new_suffixes, case, default)
-        print indent + '    break;'
-    if default is not None:
-        print indent + 'default:'
-        default()
-        print indent + '    break;'
-    print indent + '}'
-
-
-def _noop(*args, **kwargs):
-    pass
-
-
-def string_switch(var, values, case=_noop, default=None):
-    """Product a switch of strings, using a tree character switches."""
-    values = list(values)
-    values.sort()
-    _string_switch(var, '', values, case, default)
index 59f0feac22220f53dc00474edc9f5355694fe330..75a407f7469ee421f3cde1c9bc8b7e4a68a4772d 100644 (file)
 
 #include <iostream>
 
+#ifdef _WIN32
+#include <windows.h>
+
+#ifndef COMMON_LVB_LEADING_BYTE
+#define COMMON_LVB_LEADING_BYTE    0x0100
+#endif
+
+#ifndef COMMON_LVB_TRAILING_BYTE
+#define COMMON_LVB_TRAILING_BYTE   0x0200
+#endif
+
+#ifndef COMMON_LVB_GRID_HORIZONTAL
+#define COMMON_LVB_GRID_HORIZONTAL 0x0400
+#endif
+
+#ifndef COMMON_LVB_GRID_LVERTICAL
+#define COMMON_LVB_GRID_LVERTICAL  0x0800
+#endif
+
+#ifndef COMMON_LVB_GRID_RVERTICAL
+#define COMMON_LVB_GRID_RVERTICAL  0x1000
+#endif
+
+#ifndef COMMON_LVB_REVERSE_VIDEO
+#define COMMON_LVB_REVERSE_VIDEO   0x4000
+#endif
+
+#ifndef COMMON_LVB_UNDERSCORE
+#define COMMON_LVB_UNDERSCORE      0x8000
+#endif
+
+#endif /* _WIN32 */
+
 
 namespace formatter {
 
@@ -88,7 +121,10 @@ protected:
 public:
     virtual Attribute *normal(void) const { return new AnsiAttribute("0m"); }
     virtual Attribute *bold(void) const { return new AnsiAttribute("1m"); }
+    /* Italic is not widely supported, or worse, implemented with a reverse */
+#if 0
     virtual Attribute *italic(void) const { return new AnsiAttribute("3m"); }
+#endif
     virtual Attribute *strike(void) const { return new AnsiAttribute("9m"); }
     virtual Attribute *color(Color c) const { 
         static const char *color_escapes[] = {
@@ -110,38 +146,6 @@ inline std::ostream& operator<<(std::ostream& os, const Attribute *attr) {
 #ifdef _WIN32
 
 
-#include <windows.h>
-
-
-#ifndef COMMON_LVB_LEADING_BYTE
-#define COMMON_LVB_LEADING_BYTE    0x0100
-#endif
-
-#ifndef COMMON_LVB_TRAILING_BYTE
-#define COMMON_LVB_TRAILING_BYTE   0x0200
-#endif
-
-#ifndef COMMON_LVB_GRID_HORIZONTAL
-#define COMMON_LVB_GRID_HORIZONTAL 0x0400
-#endif
-
-#ifndef COMMON_LVB_GRID_LVERTICAL
-#define COMMON_LVB_GRID_LVERTICAL  0x0800
-#endif
-
-#ifndef COMMON_LVB_GRID_RVERTICAL
-#define COMMON_LVB_GRID_RVERTICAL  0x1000
-#endif
-
-#ifndef COMMON_LVB_REVERSE_VIDEO
-#define COMMON_LVB_REVERSE_VIDEO   0x4000
-#endif
-
-#ifndef COMMON_LVB_UNDERSCORE
-#define COMMON_LVB_UNDERSCORE      0x8000
-#endif
-
-
 class WindowsAttribute : public Attribute {
 protected:
     WORD wAttributes;
@@ -186,12 +190,25 @@ public:
     }
 };
 
-#endif
+
+#endif /* _WIN32 */
 
 
 inline Formatter *defaultFormatter(bool color = true) {
     if (color) {
 #ifdef _WIN32
+        // http://wiki.winehq.org/DeveloperFaq#detect-wine
+        static HMODULE hNtDll = NULL;
+        static bool bWine = false;
+        if (!hNtDll) {
+            hNtDll = LoadLibraryA("ntdll");
+            if (hNtDll) {
+                bWine = GetProcAddress(hNtDll, "wine_get_version") != NULL;
+            }
+        }
+        if (bWine) {
+            return new AnsiFormatter;
+        }
         return new WindowsFormatter;
 #else
         return new AnsiFormatter;
index 6316791bba210763dd79d10ed52afd6a20bfef9c..e930512f86473c89352a8990443cd9bbff40d622 100644 (file)
@@ -78,7 +78,7 @@ public:
     }
 
     inline signed stride(void) const {
-        return flipped ? -width*channels : width*channels;
+        return flipped ? -(signed)(width*channels) : width*channels;
     }
 
     bool writeBMP(const char *filename) const;
@@ -108,6 +108,8 @@ bool writePixelsToBuffer(unsigned char *pixels,
 Image *
 readPNG(const char *filename);
 
+const char *
+readPNMHeader(const char *buffer, size_t size, unsigned *channels, unsigned *width, unsigned *height);
 
 } /* namespace image */
 
index a65577af364de48adf9002ce0dd382c8d2fca653..cc6d3f2cc4d7ff6e476db9df609a5148e27a6546 100644 (file)
@@ -40,6 +40,9 @@
 namespace image {
 
 
+static const int png_compression_level = Z_BEST_SPEED;
+
+
 bool
 Image::writePNG(const char *filename) const {
     FILE *fp;
@@ -89,7 +92,7 @@ Image::writePNG(const char *filename) const {
     png_set_IHDR(png_ptr, info_ptr, width, height, 8, color_type,
         PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
 
-    png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION);
+    png_set_compression_level(png_ptr, png_compression_level);
 
     png_write_info(png_ptr, info_ptr);
 
@@ -275,7 +278,7 @@ bool writePixelsToBuffer(unsigned char *pixels,
                  type, PNG_INTERLACE_NONE,
                  PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
 
-    png_set_compression_level(png_ptr, Z_DEFAULT_COMPRESSION);
+    png_set_compression_level(png_ptr, png_compression_level);
 
     png_write_info(png_ptr, info_ptr);
 
index c95f640fcc1ee6ff69af318f3bc52ba0d4edf1a8..f9cd05d1fbc7593dafcb6e5bf77d48beb7505a1d 100644 (file)
@@ -28,6 +28,7 @@
 #include <assert.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdio.h>
 
 #include "image.hpp"
 
@@ -108,5 +109,55 @@ Image::writePNM(std::ostream &os, const char *comment) const {
     }
 }
 
+const char *
+readPNMHeader(const char *buffer, size_t bufferSize, unsigned *channels, unsigned *width, unsigned *height)
+{
+    *channels = 0;
+    *width = 0;
+    *height = 0;
+
+    const char *currentBuffer = buffer;
+    const char *nextBuffer;
+
+    // parse number of channels
+    int scannedChannels = sscanf(currentBuffer, "P%d\n", channels);
+    if (scannedChannels != 1) { // validate scanning of channels
+        // invalid channel line
+        return buffer;
+    }
+    // convert channel token to number of channels
+    *channels = (*channels == 5) ? 1 : 3;
+
+    // advance past channel line
+    nextBuffer = (const char *) memchr((const void *) currentBuffer, '\n', bufferSize) + 1;
+    bufferSize -= nextBuffer - currentBuffer;
+    currentBuffer = nextBuffer;
+
+    // skip over optional comment
+    if (*currentBuffer == '#') {
+        // advance past comment line
+        nextBuffer = (const char *) memchr((const void *) currentBuffer, '\n', bufferSize) + 1;
+        bufferSize -= nextBuffer - currentBuffer;
+        currentBuffer = nextBuffer;
+    }
+
+    // parse dimensions of image
+    int scannedDimensions = sscanf(currentBuffer, "%d %d\n", width, height);
+    if (scannedDimensions != 2) { // validate scanning of dimensions
+        // invalid dimension line
+        return buffer;
+    }
+
+    // advance past dimension line
+    nextBuffer = (const char *) memchr((const void *) currentBuffer, '\n', bufferSize) + 1;
+    bufferSize -= nextBuffer - currentBuffer;
+    currentBuffer = nextBuffer;
+
+    // skip over "255\n" at end of header
+    nextBuffer = (const char *) memchr((const void *) currentBuffer, '\n', bufferSize) + 1;
+
+    // return start of image data
+    return nextBuffer;
+}
 
 } /* namespace image */
diff --git a/common/json.hpp b/common/json.hpp
deleted file mode 100644 (file)
index 621610a..0000000
+++ /dev/null
@@ -1,342 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Trace writing functions.
- */
-
-#ifndef _JSON_HPP_
-#define _JSON_HPP_
-
-#include <assert.h>
-#include <stddef.h>
-#include <wchar.h>
-
-#include <iomanip>
-#include <ostream>
-#include <string>
-
-
-class JSONWriter
-{
-private:
-    std::ostream &os;
-
-    int level;
-    bool value;
-    char space;
-
-    void newline(void) {
-        os << "\n";
-        for (int i = 0; i < level; ++i) 
-            os << "  ";
-    }
-
-    void separator(void) {
-        if (value) {
-            os << ",";
-            switch (space) {
-            case '\0':
-                break;
-            case '\n':
-                newline();
-                break;
-            default:
-                os << space;
-                break;
-            }
-        } else {
-            if (space == '\n') {
-                newline();
-            }
-        }
-    }
-
-    void escapeAsciiString(const char *str) {
-        os << "\"";
-
-        const unsigned char *src = (const unsigned char *)str;
-        unsigned char c;
-        while ((c = *src++)) {
-            if ((c == '\"') ||
-                (c == '\\')) {
-                // escape character
-                os << '\\' << (unsigned char)c;
-            } else if ((c >= 0x20 && c <= 0x7e) ||
-                        c == '\t' ||
-                        c == '\r' ||
-                        c == '\n') {
-                // pass-through character
-                os << (unsigned char)c;
-            } else {
-                assert(0);
-                os << "?";
-            }
-        }
-
-        os << "\"";
-    }
-
-    void escapeUnicodeString(const char *str) {
-        os << "\"";
-
-        const char *locale = setlocale(LC_CTYPE, "");
-        const char *src = str;
-        mbstate_t state;
-
-        memset(&state, 0, sizeof state);
-
-        do {
-            // Convert characters one at a time in order to recover from
-            // conversion errors
-            wchar_t c;
-            size_t written = mbsrtowcs(&c, &src, 1, &state);
-            if (written == 0) {
-                // completed
-                break;
-            } if (written == (size_t)-1) {
-                // conversion error -- skip 
-                os << "?";
-                do {
-                    ++src;
-                } while (*src & 0x80);
-            } else if ((c == '\"') ||
-                       (c == '\\')) {
-                // escape character
-                os << '\\' << (unsigned char)c;
-            } else if ((c >= 0x20 && c <= 0x7e) ||
-                        c == '\t' ||
-                        c == '\r' ||
-                        c == '\n') {
-                // pass-through character
-                os << (unsigned char)c;
-            } else {
-                // unicode
-                os << "\\u" << std::setfill('0') << std::hex << std::setw(4) << (unsigned)c;
-                os << std::dec;
-            }
-        } while (src);
-
-        setlocale(LC_CTYPE, locale);
-
-        os << "\"";
-    }
-
-    void encodeBase64String(const unsigned char *bytes, size_t size) {
-        const char *table64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-        unsigned char c0, c1, c2, c3;
-        char buf[4];
-        unsigned written;
-
-        os << "\"";
-
-        written = 0;
-        while (size >= 3) {
-            c0 = bytes[0] >> 2;
-            c1 = ((bytes[0] & 0x03) << 4) | ((bytes[1] & 0xf0) >> 4);
-            c2 = ((bytes[1] & 0x0f) << 2) | ((bytes[2] & 0xc0) >> 6);
-            c3 = bytes[2] & 0x3f;
-
-            buf[0] = table64[c0];
-            buf[1] = table64[c1];
-            buf[2] = table64[c2];
-            buf[3] = table64[c3];
-
-            os.write(buf, 4);
-
-            bytes += 3;
-            size -= 3;
-            ++written;
-
-            if (written >= 76/4 && size) {
-                os << "\n";
-                written = 0;
-            }
-        }
-
-        if (size > 0) {
-            c0 = bytes[0] >> 2;
-            c1 = ((bytes[0] & 0x03) << 4);
-            buf[2] = '=';
-            buf[3] = '=';
-            
-            if (size > 1) {
-                c1 |= ((bytes[1] & 0xf0) >> 4);
-                c2 = ((bytes[1] & 0x0f) << 2);
-                if (size > 2) {
-                    c2 |= ((bytes[2] & 0xc0) >> 6);
-                    c3 = bytes[2] & 0x3f;
-                    buf[3] = table64[c3];
-                }
-                buf[2] = table64[c2];
-            }
-            buf[1] = table64[c1];
-            buf[0] = table64[c0];
-
-            os.write(buf, 4);
-        }
-
-        os << "\"";
-    }
-
-public:
-    JSONWriter(std::ostream &_os) : 
-        os(_os), 
-        level(0),
-        value(false),
-        space(0)
-    {
-        beginObject();
-    }
-
-    ~JSONWriter() {
-        endObject();
-        newline();
-    }
-
-    inline void beginObject() {
-        separator();
-        os << "{";
-        ++level;
-        value = false;
-    }
-
-    inline void endObject() {
-        --level;
-        if (value)
-            newline();
-        os << "}";
-        value = true;
-        space = '\n';
-    }
-
-    inline void beginMember(const char * name) {
-        space = 0;
-        separator();
-        newline();
-        escapeAsciiString(name);
-        os << ": ";
-        value = false;
-    }
-
-    inline void beginMember(const std::string &name) {
-        beginMember(name.c_str());
-    }
-
-    inline void endMember(void) {
-        assert(value);
-        value = true;
-        space = 0;
-    }
-
-    inline void beginArray() {
-        separator();
-        os << "[";
-        ++level;
-        value = false;
-        space = 0;
-    }
-
-    inline void endArray(void) {
-        --level;
-        if (space == '\n') {
-            newline();
-        }
-        os << "]";
-        value = true;
-        space = '\n';
-    }
-
-    inline void writeString(const char *s) {
-        if (!s) {
-            writeNull();
-            return;
-        }
-
-        separator();
-        escapeUnicodeString(s);
-        value = true;
-        space = ' ';
-    }
-
-    inline void writeString(const std::string &s) {
-        writeString(s.c_str());
-    }
-
-    inline void writeBase64(const void *bytes, size_t size) {
-        separator();
-        encodeBase64String((const unsigned char *)bytes, size);
-        value = true;
-        space = ' ';
-    }
-
-    inline void writeNull(void) {
-        separator();
-        os << "null";
-        value = true;
-        space = ' ';
-    }
-
-    inline void writeBool(bool b) {
-        separator();
-        os << (b ? "true" : "false");
-        value = true;
-        space = ' ';
-    }
-
-    template<class T>
-    inline void writeNumber(T n) {
-        if (n != n) {
-            // NaN
-            writeNull();
-        } else {
-            separator();
-            os << std::dec << std::setprecision(9) << n;
-            value = true;
-            space = ' ';
-        }
-    }
-    
-    inline void writeStringMember(const char *name, const char *s) {
-        beginMember(name);
-        writeString(s);
-        endMember();
-    }
-
-    inline void writeBoolMember(const char *name, bool b) {
-        beginMember(name);
-        writeBool(b);
-        endMember();
-    }
-
-    template<class T>
-    inline void writeNumberMember(const char *name, T n) {
-        beginMember(name);
-        writeNumber(n);
-        endMember();
-    }
-};
-
-#endif /* _JSON_HPP_ */
index caf9dc3d2cc66e4243d819571beaf1082c7bd723..cc72a0ea5b288184ffeb1759894344d2f5f5de3a 100644 (file)
@@ -70,11 +70,6 @@ void log(const char *format, ...)
   #endif
 #endif
 
-/**
- * Get the current time in microseconds from an unknown base.
- */
-long long getTime(void);
-
 void abort(void);
 
 void setExceptionCallback(void (*callback)(void));
diff --git a/common/os_binary.hpp b/common/os_binary.hpp
new file mode 100644 (file)
index 0000000..a231c70
--- /dev/null
@@ -0,0 +1,61 @@
+/**************************************************************************
+ *
+ * Copyright 2011 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Force binary mode standard files on Windows.
+ */
+
+#ifndef _OS_BINARY_HPP_
+#define _OS_BINARY_HPP_
+
+
+#include <stdio.h>
+
+#ifdef _WIN32
+#include <assert.h>
+
+#include <fcntl.h>
+#include <io.h>
+#endif
+
+
+namespace os {
+
+
+void setBinaryMode(FILE *fp) {
+#ifdef _WIN32
+    fflush(fp);
+    int mode = _setmode(_fileno(fp), _O_BINARY);
+    assert(mode != -1);
+    (void)mode;
+#else
+    (void)fp;
+#endif
+}
+
+
+} /* namespace os */
+
+#endif /* _OS_BINARY_HPP_ */
index 261fe88c929409d796b8cbd82ed6ea574dfc9990..7d39d8ada5e0ffafc0f730bcdd3e913744f734d2 100644 (file)
 #include <mach-o/dyld.h>
 #endif
 
+#ifdef ANDROID
+#include <android/log.h>
+#endif
+
 #ifndef PATH_MAX
 #warning PATH_MAX undefined
 #define PATH_MAX 4096
@@ -139,8 +143,17 @@ int execute(char * const * args)
             return -1;
         }
         int status = -1;
+        int ret;
         waitpid(pid, &status, 0);
-        return status;
+        if (WIFEXITED(status)) {
+            ret = WEXITSTATUS(status);
+        } else if (WIFSIGNALED(status)) {
+            // match shell return code
+            ret = WTERMSIG(status) + 128;
+        } else {
+            ret = 128;
+        }
+        return ret;
     }
 }
 
@@ -153,11 +166,19 @@ log(const char *format, ...)
     va_list ap;
     va_start(ap, format);
     fflush(stdout);
+#ifdef ANDROID
+    __android_log_vprint(ANDROID_LOG_DEBUG, "apitrace", format, ap);
+#else
     vfprintf(stderr, format, ap);
+#endif
     va_end(ap);
     logging = false;
 }
 
+#if defined(__APPLE__)
+long long timeFrequency = 0LL;
+#endif
+
 void
 abort(void)
 {
index f1dd5172b6cf777b40c5363c4270f71ae11fddd5..ba53408ccb8faa662df5d6f3ed021ce5e7d890f9 100644 (file)
 #define _OS_PROCESS_HPP_
 
 
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
 #include "os.hpp"
 
 
 namespace os {
 
 
+inline void
+setEnvironment(const char *name, const char *value) {
+#ifdef _WIN32
+    SetEnvironmentVariableA(name, value);
+#else
+    setenv(name, value, 1);
+#endif
+}
+
+
+inline void
+unsetEnvironment(const char *name) {
+#ifdef _WIN32
+    SetEnvironmentVariableA(name, NULL);
+#else
+    unsetenv(name);
+#endif
+}
+
+
 int execute(char * const * args);
 
 
index c92e6a88a7ede3fb58b4f39e08e1bae1f7b377ea..78d02f2cacc5a4bbefcf430249a74361b068377a 100644 (file)
@@ -93,12 +93,19 @@ protected:
 
     Buffer::iterator rfind(char c) {
         Buffer::iterator it = buffer.end();
+
+        // Skip trailing '\0'
+        assert(it != buffer.begin());
+        --it;
+        assert(*it == '\0');
+
         while (it != buffer.begin()) {
             --it;
             if (*it == c) {
                 return it;
             }
         }
+
         return buffer.end();
     }
 
@@ -110,6 +117,52 @@ protected:
         return &buffer[0];
     }
 
+    inline bool
+    isSep(char c) {
+        if (c == '/') {
+            return true;
+        }
+#ifdef _WIN32
+        if (c == '\\') {
+            return true;
+        }
+#endif
+        return false;
+    }
+
+    Buffer::iterator rfindSep(void) {
+        Buffer::iterator it = buffer.end();
+
+        // Skip trailing '\0'
+        assert(it != buffer.begin());
+        --it;
+        assert(*it == '\0');
+
+        // Skip trailing separators
+        while (it != buffer.begin()) {
+            --it;
+            if (isSep(*it)) {
+                // Halt if find the root
+                if (it == buffer.begin()) {
+                    return it;
+                }
+            } else {
+                break;
+            }
+        }
+
+        // Advance to the last separator
+        while (it != buffer.begin()) {
+            --it;
+            if (isSep(*it)) {
+                return it;
+            }
+        }
+
+        return buffer.end();
+    }
+
+
 public:
 
     /*
@@ -153,7 +206,7 @@ public:
         va_list args_copy;
         va_copy(args_copy, args);
 #ifdef _WIN32
-        /* We need to use _vcsprintf to calculate the length as vsnprintf returns -1
+        /* We need to use _vscprintf to calculate the length as vsnprintf returns -1
          * if the number of characters to write is greater than count.
          */
         length = _vscprintf(format, args_copy);
@@ -280,14 +333,16 @@ public:
 
 
     /*
-     * String manipulation
+     * Path manipulation
      */
 
     bool
     exists(void) const;
 
+    /* Trim directory (leaving base filename).
+     */
     void trimDirectory(void) {
-        iterator sep = rfind(OS_DIR_SEP);
+        iterator sep = rfindSep();
         if (sep != buffer.end()) {
             buffer.erase(buffer.begin(), sep + 1);
         }
@@ -295,27 +350,28 @@ public:
 
     /* Trim filename component (leaving containing directory).
      *
-     * This function removes everything after the final path
-     * separator, as well as that separator itself if it is not the
-     * only remaining separator.
-     *
-     * Some specific consequences of the above:
-     *
-     * 1. A path with no separator at all is unchanged.
-     * 2. A path with a trailing separator has only that separator removed
-     * 3. A path of just the root directory is unchaged.
+     * - trailing separators are ignored
+     * - a path with no separator at all yields "."
+     * - a path consisting of just the root directory is left unchanged
      */
     void trimFilename(void) {
-        iterator first = find(OS_DIR_SEP);
-        iterator last = rfind(OS_DIR_SEP);
-        if (last == buffer.end()) {
+        iterator sep = rfindSep();
+
+        // No separator found, so return '.'
+        if (sep == buffer.end()) {
+            buffer.resize(2);
+            buffer[0] = '.';
+            buffer[1] = 0;
             return;
         }
-        if (last == first) {
-            buffer.erase(first + 1, end());
-        } else {
-            buffer.erase(last, end());
+
+        // Root. Nothing to do.
+        if (sep == buffer.begin()) {
+            return;
         }
+
+        // Trim filename
+        buffer.erase(sep, end());
     }
 
     void trimExtension(void) {
@@ -337,6 +393,9 @@ public:
 String getProcessName();
 String getCurrentDir();
 
+bool copyFile(const String &srcFileName, const String &dstFileName, bool override = true);
+
+bool removeFile(const String &fileName);
 
 } /* namespace os */
 
index a4f52093c94c125e7874a8e77f1597f056c0ab7b..75175d85f6ecb15d8fc69622e10526b23ab5bb3d 100644 (file)
@@ -35,6 +35,8 @@
 #include <windows.h>
 #elif defined(__linux__)
 #include <time.h>
+#elif defined(__APPLE__)
+#include <mach/mach_time.h>
 #else
 #include <sys/time.h>
 #endif
 namespace os {
 
     // OS dependent time frequency
-#if defined(_WIN32)
-    // runtime variable on Windows
+#if defined(_WIN32) || defined(__APPLE__)
+    // runtime variable on Windows and MacOSX
     extern long long timeFrequency;
 #elif defined(__linux__)
-    // nanoseconds
-    static const long long timeFrequency = 1000000000;
+    // nanoseconds on Linux
+    static const long long timeFrequency = 1000000000LL;
 #else
-    // microseconds on
-    static const long long timeFrequency = 1000000;
+    // microseconds on Unices
+    static const long long timeFrequency = 1000000LL;
 #endif
 
     // Time from an unknown base in a unit determined by timeFrequency
@@ -72,6 +74,13 @@ namespace os {
             return 0;
         }
         return tp.tv_sec * 1000000000LL + tp.tv_nsec;
+#elif defined(__APPLE__)
+        if (!timeFrequency) {
+            mach_timebase_info_data_t timebaseInfo;
+            mach_timebase_info(&timebaseInfo);
+            timeFrequency = 1000000000LL * timebaseInfo.denom / timebaseInfo.numer;
+        }
+        return mach_absolute_time();
 #else
         struct timeval tv;
         gettimeofday(&tv, NULL);
index 33fe427bad7370784d32c42c416e172ed97bcd89..e9306cdc6dfa0168b3bca328d5511b66bb551932 100644 (file)
@@ -76,6 +76,18 @@ String::exists(void) const
     return attrs != INVALID_FILE_ATTRIBUTES;
 }
 
+bool
+copyFile(const String &srcFileName, const String &dstFileName, bool override)
+{
+    return CopyFileA(srcFileName, dstFileName, !override);
+}
+
+bool
+removeFile(const String &srcFilename)
+{
+    return DeleteFileA(srcFilename);
+}
+
 /**
  * Determine whether an argument should be quoted.
  */
@@ -113,7 +125,6 @@ quoteArg(std::string &s, const char *arg)
     s.push_back('"');
     while (true) {
         c = *arg++;
-        switch (c)
         if (c == '\0') {
             break;
         } else if (c == '"') {
@@ -178,7 +189,7 @@ int execute(char * const * args)
 
     WaitForSingleObject(processInformation.hProcess, INFINITE);
 
-    DWORD exitCode = ~0;
+    DWORD exitCode = ~0UL;
     GetExitCodeProcess(processInformation.hProcess, &exitCode);
 
     CloseHandle(processInformation.hProcess);
@@ -264,6 +275,15 @@ unhandledExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)
         return EXCEPTION_CONTINUE_SEARCH;
     }
 
+    /*
+     * Ignore .NET exception.
+     *
+     * http://ig2600.blogspot.co.uk/2011/01/why-do-i-keep-getting-exception-code.html
+     */
+    if (pExceptionRecord->ExceptionCode == 0xe0434352) {
+        return EXCEPTION_CONTINUE_SEARCH;
+    }
+
     // Clear direction flag
 #ifdef _MSC_VER
 #ifndef _WIN64
index f333960a7adefb31a57d48165c2da5ac753bdb6e..60694fa83d92d8da1e9891e6865574d13d7e0ea2 100644 (file)
@@ -106,13 +106,15 @@ private:
 
 public:
     PickleWriter(std::ostream &_os) :
-        os(_os)
-    {
+        os(_os) {
+    }
+
+    inline void begin() {
         os.put(PROTO);
         os.put(2);
     }
 
-    ~PickleWriter() {
+    inline void end() {
         os.put(STOP);
     }
 
@@ -266,6 +268,16 @@ public:
         os.put(u.c[0]);
     }
 
+    inline void writeByteArray(const void *buf, size_t length) {
+        os.put(GLOBAL);
+        os << "__builtin__\nbytearray\n";
+        os.put(BINPUT);
+        os.put(1);
+        writeString(static_cast<const char *>(buf), length);
+        os.put(TUPLE1);
+        os.put(REDUCE);
+    }
+
 protected:
     inline void putInt16(uint16_t i) {
         os.put( i        & 0xff);
index 612a8f1504f8e3935bb7fbb608aaeb139a43cf31..4c896dbfaed52cf57f28a1f66cd2ae08545221a2 100644 (file)
 namespace trace {
 
 
+/**
+ * Enum to distuinguish the API for tools.
+ *
+ * It should never be embedded in the trace file.
+ */
 enum API {
+    API_UNKNOWN = 0,
     API_GL, // GL + GLX/WGL/CGL
     API_EGL, // GL/GLES1/GLES2/VG + EGL
+    API_DX, // All DirectX
+    API_D3D7,
+    API_D3D8,
+    API_D3D9,
+    API_D3D10,
+    API_D3D10_1,
+    API_D3D11,
 };
 
 
index c55bbb1ca324e776ad67b5cef5f72cb64376ed1e..2b8c27a3780b28f57bb4ddad5ba14aebac9cdc97 100644 (file)
@@ -24,6 +24,8 @@
  **************************************************************************/
 
 
+#include <limits>
+
 #include "formatter.hpp"
 #include "trace_dump.hpp"
 
@@ -73,7 +75,7 @@ public:
     }
 
     void visit(Null *) {
-        os << "NULL";
+        os << literal << "NULL" << normal;
     }
 
     void visit(Bool *node) {
@@ -89,11 +91,15 @@ public:
     }
 
     void visit(Float *node) {
+        std::streamsize oldPrecision = os.precision(std::numeric_limits<float>::digits10 + 1);
         os << literal << node->value << normal;
+        os.precision(oldPrecision);
     }
 
     void visit(Double *node) {
+        std::streamsize oldPrecision = os.precision(std::numeric_limits<double>::digits10 + 1);
         os << literal << node->value << normal;
+        os.precision(oldPrecision);
     }
 
     void visit(String *node) {
@@ -129,12 +135,10 @@ public:
     }
 
     void visit(Enum *node) {
-        const EnumSig *sig = node->sig;
-        for (const EnumValue *it = sig->values; it != sig->values + sig->num_values; ++it) {
-            if (it->value == node->value) {
-                os << literal << it->name << normal;
-                return;
-            }
+        const EnumValue *it = node->lookup();
+        if (it) {
+            os << literal << it->name << normal;
+            return;
         }
         os << literal << node->value << normal;
     }
@@ -143,7 +147,8 @@ public:
         unsigned long long value = bitmask->value;
         const BitmaskSig *sig = bitmask->sig;
         bool first = true;
-        for (const BitmaskFlag *it = sig->flags; value != 0 && it != sig->flags + sig->num_flags; ++it) {
+        for (const BitmaskFlag *it = sig->flags; it != sig->flags + sig->num_flags; ++it) {
+            assert(it->value || first);
             if ((it->value && (value & it->value) == it->value) ||
                 (!it->value && value == 0)) {
                 if (!first) {
@@ -153,6 +158,9 @@ public:
                 value &= ~it->value;
                 first = false;
             }
+            if (value == 0) {
+                break;
+            }
         }
         if (value || first) {
             if (!first) {
@@ -198,6 +206,10 @@ public:
         os << pointer << "0x" << std::hex << p->value << std::dec << normal;
     }
 
+    void visit(Repr *r) {
+        _visit(r->humanValue);
+    }
+
     void visit(Call *call) {
         CallFlags callFlags = call->flags;
         
index 5d47d5387b366d472777f3577980386f06f80c2a..5e5d5deb9561acf4e33de20c99390cbbc2aa4708 100644 (file)
 #include <zlib.h>
 #include <gzguts.h>
 
+// for lseek
+#ifdef _WIN32
+#include <io.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
 #include "os.hpp"
 
 #include <iostream>
@@ -60,7 +68,7 @@ protected:
     virtual bool rawSkip(size_t length);
     virtual int  rawPercentRead();
 private:
-    void *m_gzFile;
+    gzFile m_gzFile;
     double m_endOffset;
 };
 
index 4e1d9a9911d265bac1a9ef4462c174e21637704c..d5fd81b5b9eeacd6f9a6f2da06ac78a90c5353d9 100644 (file)
@@ -96,11 +96,12 @@ namespace trace {
  *         | DOUBLE double
  *         | STRING string
  *         | BLOB string
- *         | ENUM enum_sig
+ *         | ENUM enum_sig value
  *         | BITMASK bitmask_sig value
  *         | ARRAY length value+
  *         | STRUCT struct_sig value+
  *         | OPAQUE int
+ *         | REPR value value
  *
  *   call_sig = id name arg_name*
  *            | id
@@ -143,6 +144,7 @@ enum Type {
     TYPE_ARRAY,
     TYPE_STRUCT,
     TYPE_OPAQUE,
+    TYPE_REPR,
 };
 
 
index 7e926ba46db70e65c5e8ee1a732f7ce9dcde784e..86527a1f900f59959691ca740656199c417b5280 100644 (file)
@@ -85,6 +85,7 @@ bool Struct ::toBool(void) const { return true; }
 bool Array  ::toBool(void) const { return true; }
 bool Blob   ::toBool(void) const { return true; }
 bool Pointer::toBool(void) const { return value != 0; }
+bool Repr   ::toBool(void) const { return static_cast<bool>(machineValue); }
 
 
 // signed integer cast
@@ -95,6 +96,7 @@ signed long long SInt   ::toSInt(void) const { return value; }
 signed long long UInt   ::toSInt(void) const { assert(static_cast<signed long long>(value) >= 0); return static_cast<signed long long>(value); }
 signed long long Float  ::toSInt(void) const { return static_cast<signed long long>(value); }
 signed long long Double ::toSInt(void) const { return static_cast<signed long long>(value); }
+signed long long Repr   ::toSInt(void) const { return machineValue->toSInt(); }
 
 
 // unsigned integer cast
@@ -105,6 +107,7 @@ unsigned long long SInt   ::toUInt(void) const { assert(value >= 0); return stat
 unsigned long long UInt   ::toUInt(void) const { return value; }
 unsigned long long Float  ::toUInt(void) const { return static_cast<unsigned long long>(value); }
 unsigned long long Double ::toUInt(void) const { return static_cast<unsigned long long>(value); }
+unsigned long long Repr   ::toUInt(void) const { return machineValue->toUInt(); }
 
 
 // floating point cast
@@ -115,6 +118,7 @@ float SInt   ::toFloat(void) const { return static_cast<float>(value); }
 float UInt   ::toFloat(void) const { return static_cast<float>(value); }
 float Float  ::toFloat(void) const { return value; }
 float Double ::toFloat(void) const { return value; }
+float Repr   ::toFloat(void) const { return machineValue->toFloat(); }
 
 
 // floating point cast
@@ -125,6 +129,7 @@ double SInt   ::toDouble(void) const { return static_cast<double>(value); }
 double UInt   ::toDouble(void) const { return static_cast<double>(value); }
 double Float  ::toDouble(void) const { return value; }
 double Double ::toDouble(void) const { return value; }
+double Repr   ::toDouble(void) const { return machineValue->toDouble(); }
 
 
 // pointer cast
@@ -132,23 +137,27 @@ void * Value  ::toPointer(void) const { assert(0); return NULL; }
 void * Null   ::toPointer(void) const { return NULL; }
 void * Blob   ::toPointer(void) const { return buf; }
 void * Pointer::toPointer(void) const { return (void *)value; }
+void * Repr   ::toPointer(void) const { return machineValue->toPointer(); }
 
 void * Value  ::toPointer(bool bind) { assert(0); return NULL; }
 void * Null   ::toPointer(bool bind) { return NULL; }
 void * Blob   ::toPointer(bool bind) { if (bind) bound = true; return buf; }
 void * Pointer::toPointer(bool bind) { return (void *)value; }
+void * Repr   ::toPointer(bool bind) { return machineValue->toPointer(bind); }
 
 
-// pointer cast
+// unsigned int pointer cast
 unsigned long long Value  ::toUIntPtr(void) const { assert(0); return 0; }
 unsigned long long Null   ::toUIntPtr(void) const { return 0; }
 unsigned long long Pointer::toUIntPtr(void) const { return value; }
+unsigned long long Repr   ::toUIntPtr(void) const { return machineValue->toUIntPtr(); }
 
 
 // string cast
 const char * Value ::toString(void) const { assert(0); return NULL; }
 const char * Null  ::toString(void) const { return NULL; }
 const char * String::toString(void) const { return value; }
+const char * Repr  ::toString(void) const { return machineValue->toString(); }
 
 
 // virtual Value::visit()
@@ -165,6 +174,7 @@ void Struct ::visit(Visitor &visitor) { visitor.visit(this); }
 void Array  ::visit(Visitor &visitor) { visitor.visit(this); }
 void Blob   ::visit(Visitor &visitor) { visitor.visit(this); }
 void Pointer::visit(Visitor &visitor) { visitor.visit(this); }
+void Repr   ::visit(Visitor &visitor) { visitor.visit(this); }
 
 
 void Visitor::visit(Null *) { assert(0); }
@@ -180,6 +190,7 @@ void Visitor::visit(Struct *) { assert(0); }
 void Visitor::visit(Array *) { assert(0); }
 void Visitor::visit(Blob *) { assert(0); }
 void Visitor::visit(Pointer *) { assert(0); }
+void Visitor::visit(Repr *node) { node->machineValue->visit(*this); }
 
 
 static Null null;
index 7973026cd9b07884af719feefd3b7ed72ed1a2cc..bb8936e32946bc78763edb025802ce1f6adfccc4 100644 (file)
@@ -228,6 +228,17 @@ public:
     void visit(Visitor &visitor);
 
     const EnumSig *sig;
+
+    const EnumValue *
+    lookup() {
+        // TODO: use a std::map
+        for (const EnumValue *it = sig->values; it != sig->values + sig->num_values; ++it) {
+            if (it->value == value) {
+                return it;
+            }
+        }
+        return NULL;
+    }
 };
 
 
@@ -266,6 +277,11 @@ public:
     void visit(Visitor &visitor);
 
     std::vector<Value *> values;
+
+    inline size_t
+    size(void) const {
+        return values.size();
+    }
 };
 
 
@@ -304,6 +320,35 @@ public:
 };
 
 
+class Repr : public Value
+{
+public:
+    Repr(Value *human, Value *machine) :
+        humanValue(human),
+        machineValue(machine)
+    {}
+
+    /** Human-readible value */
+    Value *humanValue;
+
+    /** Machine-readible value */
+    Value *machineValue;
+    
+    virtual bool toBool(void) const;
+    virtual signed long long toSInt(void) const;
+    virtual unsigned long long toUInt(void) const;
+    virtual float toFloat(void) const;
+    virtual double toDouble(void) const;
+
+    virtual void *toPointer(void) const;
+    virtual void *toPointer(bool bind);
+    virtual unsigned long long toUIntPtr(void) const;
+    virtual const char *toString(void) const;
+
+    void visit(Visitor &visitor);
+};
+
+
 class Visitor
 {
 public:
@@ -320,6 +365,7 @@ public:
     virtual void visit(Array *);
     virtual void visit(Blob *);
     virtual void visit(Pointer *);
+    virtual void visit(Repr *);
 
 protected:
     inline void _visit(Value *value) {
index dc9634f0d36f823b635d26c7efd7bc1a1082625f..7a8c4f96e551802cfca9d8a85ae5f597e19629d5 100644 (file)
@@ -43,6 +43,7 @@ Parser::Parser() {
     file = NULL;
     next_call_no = 0;
     version = 0;
+    api = API_UNKNOWN;
 
     glGetErrorSig = NULL;
 }
@@ -65,6 +66,7 @@ bool Parser::open(const char *filename) {
         std::cerr << "error: unsupported trace format version " << version << "\n";
         return false;
     }
+    api = API_UNKNOWN;
 
     return true;
 }
@@ -232,6 +234,29 @@ Parser::parse_function_sig(void) {
         sig->offset = file->currentOffset();
         functions[id] = sig;
 
+        /**
+         * Try to autodetect the API.
+         *
+         * XXX: Ideally we would allow to mix multiple APIs in a single trace,
+         * but as it stands today, retrace is done separately for each API.
+         */
+        if (api == API_UNKNOWN) {
+            const char *n = sig->name;
+            if ((n[0] == 'g' && n[1] == 'l' && n[2] == 'X') || // glX*
+                (n[0] == 'w' && n[1] == 'g' && n[2] == 'l' && n[3] >= 'A' && n[3] <= 'Z') || // wgl[A-Z]*
+                (n[0] == 'C' && n[1] == 'G' && n[2] == 'L')) { // CGL*
+                api = trace::API_GL;
+            } else if (n[0] == 'e' && n[1] == 'g' && n[2] == 'l' && n[3] >= 'A' && n[3] <= 'Z') { // egl[A-Z]*
+                api = trace::API_EGL;
+            } else if (n[0] == 'D' &&
+                       ((n[1] == 'i' && n[2] == 'r' && n[3] == 'e' && n[4] == 'c' && n[5] == 't') || // Direct*
+                        (n[1] == '3' && n[2] == 'D'))) { // D3D*
+                api = trace::API_DX;
+            } else {
+                /* TODO */
+            }
+        }
+
         /**
          * Note down the signature of special functions for future reference.
          *
@@ -532,6 +557,9 @@ Value *Parser::parse_value(void) {
     case trace::TYPE_OPAQUE:
         value = parse_opaque();
         break;
+    case trace::TYPE_REPR:
+        value = parse_repr();
+        break;
     default:
         std::cerr << "error: unknown type " << c << "\n";
         exit(1);
@@ -588,6 +616,9 @@ void Parser::scan_value(void) {
     case trace::TYPE_OPAQUE:
         scan_opaque();
         break;
+    case trace::TYPE_REPR:
+        scan_repr();
+        break;
     default:
         std::cerr << "error: unknown type " << c << "\n";
         exit(1);
@@ -713,7 +744,7 @@ Value *Parser::parse_blob(void) {
     size_t size = read_uint();
     Blob *blob = new Blob(size);
     if (size) {
-        file->read(blob->buf, (unsigned)size);
+        file->read(blob->buf, size);
     }
     return blob;
 }
@@ -759,11 +790,24 @@ void Parser::scan_opaque() {
 }
 
 
+Value *Parser::parse_repr() {
+    Value *humanValue = parse_value();
+    Value *machineValue = parse_value();
+    return new Repr(humanValue, machineValue);
+}
+
+
+void Parser::scan_repr() {
+    scan_value();
+    scan_value();
+}
+
+
 const char * Parser::read_string(void) {
     size_t len = read_uint();
     char * value = new char[len + 1];
     if (len) {
-        file->read(value, (unsigned)len);
+        file->read(value, len);
     }
     value[len] = 0;
 #if TRACE_VERBOSE
@@ -789,7 +833,7 @@ Parser::read_sint(void) {
     c = read_byte();
     switch (c) {
     case trace::TYPE_SINT:
-        return -read_uint();
+        return -(signed long long)read_uint();
     case trace::TYPE_UINT:
         return read_uint();
     default:
index d8c5915ea3d8e3976c1b2d38e33d8e8f57a21d53..0ae3a28d682b80ad6034e1c8daa88fec91362064 100644 (file)
@@ -33,6 +33,7 @@
 #include "trace_file.hpp"
 #include "trace_format.hpp"
 #include "trace_model.hpp"
+#include "trace_api.hpp"
 
 
 namespace trace {
@@ -94,6 +95,7 @@ protected:
 
 public:
     unsigned long long version;
+    API api;
 
     Parser();
 
@@ -193,6 +195,9 @@ protected:
     Value *parse_opaque();
     void scan_opaque();
 
+    Value *parse_repr();
+    void scan_repr();
+
     const char * read_string(void);
     void skip_string(void);
 
index e5dad8459f6b7096c189cecbf15d0c3b227d3a06..fe245149e1b7ad96c5b121be69d616d87a76e118 100644 (file)
@@ -56,6 +56,38 @@ defaultCallFlags = 0;
 const Entry<CallFlags>
 callFlagTable[] = {
     { "CGLFlushDrawable",                              CALL_FLAG_END_FRAME },
+    { "IDirect3D9::CheckDeviceFormat",                 CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3D9::EnumAdapterModes",                  CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3D9::GetAdapterModeCount",               CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3D9::GetDeviceCaps",                     CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3D9Ex::CheckDeviceFormat",               CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3D9Ex::EnumAdapterModes",                CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3D9Ex::GetAdapterModeCount",             CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3D9Ex::GetDeviceCaps",                   CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3DDevice9::Clear",                       CALL_FLAG_RENDER },
+    { "IDirect3DDevice9::DrawIndexedPrimitive",        CALL_FLAG_RENDER },
+    { "IDirect3DDevice9::DrawIndexedPrimitiveUP",      CALL_FLAG_RENDER },
+    { "IDirect3DDevice9::DrawPrimitive",               CALL_FLAG_RENDER },
+    { "IDirect3DDevice9::DrawPrimitiveUP",             CALL_FLAG_RENDER },
+    { "IDirect3DDevice9::DrawRectPatch",               CALL_FLAG_RENDER },
+    { "IDirect3DDevice9::DrawTriPatch",                CALL_FLAG_RENDER },
+    { "IDirect3DDevice9::GetDeviceCaps",               CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3DDevice9::GetRenderTargetData",         CALL_FLAG_END_FRAME },
+    { "IDirect3DDevice9::Present",                     CALL_FLAG_END_FRAME },
+    { "IDirect3DDevice9::SetRenderTarget",             CALL_FLAG_SWAP_RENDERTARGET },
+    { "IDirect3DDevice9Ex::Clear",                     CALL_FLAG_RENDER },
+    { "IDirect3DDevice9Ex::DrawIndexedPrimitive",      CALL_FLAG_RENDER },
+    { "IDirect3DDevice9Ex::DrawIndexedPrimitiveUP",    CALL_FLAG_RENDER },
+    { "IDirect3DDevice9Ex::DrawPrimitive",             CALL_FLAG_RENDER },
+    { "IDirect3DDevice9Ex::DrawPrimitiveUP",           CALL_FLAG_RENDER },
+    { "IDirect3DDevice9Ex::DrawRectPatch",             CALL_FLAG_RENDER },
+    { "IDirect3DDevice9Ex::DrawTriPatch",              CALL_FLAG_RENDER },
+    { "IDirect3DDevice9Ex::GetDeviceCaps",             CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "IDirect3DDevice9Ex::GetRenderTargetData",       CALL_FLAG_END_FRAME },
+    { "IDirect3DDevice9Ex::Present",                   CALL_FLAG_END_FRAME },
+    { "IDirect3DDevice9Ex::SetRenderTarget",           CALL_FLAG_SWAP_RENDERTARGET },
+    { "IDirect3DSwapChain9::Present",                  CALL_FLAG_END_FRAME },
+    { "IDirect3DSwapChain9Ex::Present",                CALL_FLAG_END_FRAME },
     { "eglGetProcAddress",                             CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "eglQueryString",                                CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "eglSwapBuffers",                                CALL_FLAG_SWAPBUFFERS },
@@ -64,6 +96,8 @@ callFlagTable[] = {
     { "glBindFramebufferOES",                          CALL_FLAG_SWAP_RENDERTARGET },
     { "glBlitFramebuffer",                             CALL_FLAG_RENDER },
     { "glBlitFramebufferEXT",                          CALL_FLAG_RENDER },
+    { "glCallList",                                    CALL_FLAG_RENDER },
+    { "glCallLists",                                   CALL_FLAG_RENDER },
     { "glClear",                                       CALL_FLAG_RENDER },
     { "glDrawArrays",                                  CALL_FLAG_RENDER },
     { "glDrawArraysEXT",                               CALL_FLAG_RENDER },
@@ -145,6 +179,8 @@ callFlagTable[] = {
     { "glXQueryExtensionsString",                      CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "glXQueryVersion",                               CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "glXSwapBuffers",                                CALL_FLAG_SWAPBUFFERS },
+    { "wglGetCurrentContext",                          CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
+    { "wglGetCurrentDC",                               CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "wglGetDefaultProcAddress",                      CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "wglGetProcAddress",                             CALL_FLAG_NO_SIDE_EFFECTS | CALL_FLAG_VERBOSE },
     { "wglSwapBuffers",                                CALL_FLAG_SWAPBUFFERS },
diff --git a/common/trace_profiler.cpp b/common/trace_profiler.cpp
new file mode 100644 (file)
index 0000000..0f90ee2
--- /dev/null
@@ -0,0 +1,200 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "trace_profiler.hpp"
+#include "os_time.hpp"
+#include <iostream>
+#include <string.h>
+#include <sstream>
+
+namespace trace {
+Profiler::Profiler()
+    : baseGpuTime(0),
+      baseCpuTime(0),
+      minCpuTime(1000),
+      cpuTimes(false),
+      gpuTimes(true),
+      pixelsDrawn(false)
+{
+}
+
+Profiler::~Profiler()
+{
+}
+
+void Profiler::setup(bool cpuTimes_, bool gpuTimes_, bool pixelsDrawn_)
+{
+    cpuTimes = cpuTimes_;
+    gpuTimes = gpuTimes_;
+    pixelsDrawn = pixelsDrawn_;
+
+    std::cout << "# call no gpu_start gpu_dura cpu_start cpu_dura pixels program name" << std::endl;
+}
+
+int64_t Profiler::getBaseCpuTime()
+{
+    return baseCpuTime;
+}
+
+int64_t Profiler::getBaseGpuTime()
+{
+    return baseGpuTime;
+}
+
+void Profiler::setBaseCpuTime(int64_t cpuStart)
+{
+    baseCpuTime = cpuStart;
+}
+
+void Profiler::setBaseGpuTime(int64_t gpuStart)
+{
+    baseGpuTime = gpuStart;
+}
+
+bool Profiler::hasBaseTimes()
+{
+    return baseCpuTime != 0 || baseGpuTime != 0;
+}
+
+void Profiler::addCall(unsigned no,
+                       const char *name,
+                       unsigned program,
+                       int64_t pixels,
+                       int64_t gpuStart, int64_t gpuDuration,
+                       int64_t cpuStart, int64_t cpuDuration)
+{
+    if (gpuTimes && gpuStart) {
+        gpuStart -= baseGpuTime;
+    } else {
+        gpuStart = 0;
+        gpuDuration = 0;
+    }
+
+    if (cpuTimes && cpuStart) {
+        double cpuTimeScale = 1.0E9 / os::timeFrequency;
+        cpuStart = (cpuStart - baseCpuTime) * cpuTimeScale;
+        cpuDuration = cpuDuration * cpuTimeScale;
+
+        if (cpuDuration < minCpuTime) {
+            return;
+        }
+    } else {
+        cpuStart = 0;
+        cpuDuration = 0;
+    }
+
+    if (!pixelsDrawn) {
+        pixels = 0;
+    }
+
+    std::cout << "call"
+              << " " << no
+              << " " << gpuStart
+              << " " << gpuDuration
+              << " " << cpuStart
+              << " " << cpuDuration
+              << " " << pixels
+              << " " << program
+              << " " << name
+              << std::endl;
+}
+
+void Profiler::addFrameEnd()
+{
+    std::cout << "frame_end" << std::endl;
+}
+
+void Profiler::parseLine(const char* in, Profile* profile)
+{
+    std::stringstream line(in, std::ios_base::in);
+    std::string type;
+    static int64_t lastGpuTime;
+    static int64_t lastCpuTime;
+
+    if (in[0] == '#' || strlen(in) < 4)
+        return;
+
+    if (profile->programs.size() == 0 && profile->calls.size() == 0 && profile->frames.size() == 0) {
+        lastGpuTime = 0;
+        lastCpuTime = 0;
+    }
+
+    line >> type;
+
+    if (type.compare("call") == 0) {
+        Profile::Call call;
+
+        line >> call.no
+             >> call.gpuStart
+             >> call.gpuDuration
+             >> call.cpuStart
+             >> call.cpuDuration
+             >> call.pixels
+             >> call.program
+             >> call.name;
+
+        if (lastGpuTime < call.gpuStart + call.gpuDuration) {
+            lastGpuTime = call.gpuStart + call.gpuDuration;
+        }
+
+        if (lastCpuTime < call.cpuStart + call.cpuDuration) {
+            lastCpuTime = call.cpuStart + call.cpuDuration;
+        }
+
+        profile->calls.push_back(call);
+
+        if (call.pixels >= 0) {
+            if (profile->programs.size() <= call.program) {
+                profile->programs.resize(call.program + 1);
+            }
+
+            Profile::Program& program = profile->programs[call.program];
+            program.cpuTotal += call.cpuDuration;
+            program.gpuTotal += call.gpuDuration;
+            program.pixelTotal += call.pixels;
+            program.calls.push_back(profile->calls.size() - 1);
+        }
+    } else if (type.compare("frame_end") == 0) {
+        Profile::Frame frame;
+        frame.no = profile->frames.size();
+
+        if (frame.no == 0) {
+            frame.gpuStart = 0;
+            frame.cpuStart = 0;
+            frame.calls.begin = 0;
+        } else {
+            frame.gpuStart = profile->frames.back().gpuStart + profile->frames.back().gpuDuration;
+            frame.cpuStart = profile->frames.back().cpuStart + profile->frames.back().cpuDuration;
+            frame.calls.begin = profile->frames.back().calls.end + 1;
+        }
+
+        frame.gpuDuration = lastGpuTime - frame.gpuStart;
+        frame.cpuDuration = lastCpuTime - frame.cpuStart;
+        frame.calls.end = profile->calls.size() - 1;
+
+        profile->frames.push_back(frame);
+    }
+}
+}
diff --git a/common/trace_profiler.hpp b/common/trace_profiler.hpp
new file mode 100644 (file)
index 0000000..d833242
--- /dev/null
@@ -0,0 +1,123 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef TRACE_PROFILER_H
+#define TRACE_PROFILER_H
+
+#include <string>
+#include <vector>
+#include <stdint.h>
+
+namespace trace
+{
+
+struct Profile {
+    struct Call {
+        unsigned no;
+
+        unsigned program;
+
+        int64_t gpuStart;
+        int64_t gpuDuration;
+
+        int64_t cpuStart;
+        int64_t cpuDuration;
+
+        int64_t pixels;
+
+        std::string name;
+    };
+
+    struct Frame {
+        unsigned no;
+
+        int64_t gpuStart;
+        int64_t gpuDuration;
+
+        int64_t cpuStart;
+        int64_t cpuDuration;
+
+        /* Indices to profile->calls array */
+        struct {
+            unsigned begin;
+            unsigned end;
+        } calls;
+    };
+
+    struct Program {
+        Program() : gpuTotal(0), cpuTotal(0), pixelTotal(0) {}
+
+        uint64_t gpuTotal;
+        uint64_t cpuTotal;
+        uint64_t pixelTotal;
+
+        /* Indices to profile->calls array */
+        std::vector<unsigned> calls;
+    };
+
+    std::vector<Call> calls;
+    std::vector<Frame> frames;
+    std::vector<Program> programs;
+};
+
+class Profiler
+{
+public:
+    Profiler();
+    ~Profiler();
+
+    void setup(bool cpuTimes_, bool gpuTimes_, bool pixelsDrawn_);
+
+    void addCall(unsigned no,
+                 const char* name,
+                 unsigned program,
+                 int64_t pixels,
+                 int64_t gpuStart, int64_t gpuDuration,
+                 int64_t cpuStart, int64_t cpuDuration);
+
+    void addFrameEnd();
+
+    bool hasBaseTimes();
+
+    void setBaseCpuTime(int64_t cpuStart);
+    void setBaseGpuTime(int64_t gpuStart);
+
+    int64_t getBaseCpuTime();
+    int64_t getBaseGpuTime();
+
+    static void parseLine(const char* line, Profile* profile);
+
+private:
+    int64_t baseGpuTime;
+    int64_t baseCpuTime;
+    int64_t minCpuTime;
+
+    bool cpuTimes;
+    bool gpuTimes;
+    bool pixelsDrawn;
+};
+}
+
+#endif // TRACE_PROFILER_H
index 85c8bee9a0fbe4a347ea7fbe287253523119749d..8a1f56cb1b9ca88c825579c98608a6ae5a2c2db1 100644 (file)
@@ -37,75 +37,46 @@ namespace trace {
 
 
 os::String
-findFile(const char *relPath,
-         const char *absPath,
-         bool verbose)
+findScript(const char *scriptFilename)
 {
-    os::String complete;
-
-    /* First look in the same directory from which this process is
-     * running, (to support developers running a compiled program that
-     * has not been installed. */
-    os::String process_dir = os::getProcessName();
-    process_dir.trimFilename();
-
-    complete = process_dir;
-    complete.join(relPath);
-
-    if (complete.exists())
-        return complete;
-
-    /* Second, look in the directory for installed wrappers. */
-    complete = absPath;
-    if (complete.exists())
-        return complete;
-
-    if (verbose) {
-        std::cerr << "error: cannot find " << relPath << " or " << absPath << "\n";
+    os::String scriptPath;
+
+    os::String processDir = os::getProcessName();
+    processDir.trimFilename();
+
+    // Try relative build directory
+    // XXX: Just make build and install directory layout match
+    scriptPath = processDir;
+    scriptPath.join("scripts");
+    scriptPath.join(scriptFilename);
+    if (scriptPath.exists()) {
+        return scriptPath;
     }
 
-    return "";
-}
-
-
-#define SCRIPTS_SUBDIR "lib/apitrace/scripts"
-
-os::String
-findScript(const char *name)
-{
-    os::String path;
-
-#if defined(APITRACE_SOURCE_DIR)
-    // Try the absolute source  path -- useful for development or quick
-    // experiment.  Relative paths don't quite work here due to out of source
-    // trees.
-    path = APITRACE_SOURCE_DIR "/scripts";
-    path.join(name);
-    if (path.exists()) {
-        return path;
-    }
-#endif
-
+    // Try relative install directory
+    scriptPath = processDir;
 #if defined(_WIN32)
-    // Windows has no standard installation path, so find it relatively to the
-    // process name, which is assumed to be in a bin subdirectory.
-    path = os::getProcessName();
-    path.trimFilename();
-    path.join("..\\lib\\apitrace\\scripts");
-    path.join(name);
-    if (path.exists()) {
-        return path;
-    }
+    scriptPath.join("..\\lib\\scripts");
+#elif defined(__APPLE__)
+    scriptPath.join("../lib/scripts");
 #else
-    // Assume a predefined installation path on Unices
-    path = APITRACE_INSTALL_PREFIX "/lib/apitrace/scripts";
-    path.join(name);
-    if (path.exists()) {
-        return path;
+    scriptPath.join("../lib/apitrace/scripts");
+#endif
+    scriptPath.join(scriptFilename);
+    if (scriptPath.exists()) {
+        return scriptPath;
+    }
+
+#ifndef _WIN32
+    // Try absolute install directory
+    scriptPath = APITRACE_SCRIPTS_INSTALL_DIR;
+    scriptPath.join(scriptFilename);
+    if (scriptPath.exists()) {
+        return scriptPath;
     }
 #endif
 
-    std::cerr << "error: cannot find " << name << " script\n";
+    std::cerr << "error: cannot find " << scriptFilename << " script\n";
 
     return "";
 }
index beea62229d46afad1187e9b95249ac185018d3b2..1d0a31b95a291435645921620164f5ee604faf06 100644 (file)
 namespace trace {
 
 
-os::String
-findFile(const char *relPath, // path relative to the current program
-         const char *absPath, // absolute path
-         bool verbose);
-
 os::String
 findScript(const char *name);
 
index 768fd108d3541eaf1352b09c910b2c4c335bd1ea..5c88a25626c91ad77a9ba30ab5532c5dc0e80f65 100644 (file)
@@ -32,7 +32,6 @@
 
 #include "os_string.hpp"
 #include "os_process.hpp"
-#include "trace_resource.hpp"
 #include "trace_tools.hpp"
 
 
@@ -44,7 +43,6 @@ namespace trace {
 #define TRACE_VARIABLE "DYLD_LIBRARY_PATH"
 #define GL_TRACE_WRAPPER  "OpenGL"
 #elif defined(_WIN32)
-#define TRACE_VARIABLE ""
 #define GL_TRACE_WRAPPER  "opengl32.dll"
 #else
 #define TRACE_VARIABLE "LD_PRELOAD"
@@ -53,68 +51,141 @@ namespace trace {
 #endif
 
 
+static os::String
+findWrapper(const char *wrapperFilename)
+{
+    os::String wrapperPath;
+
+    os::String processDir = os::getProcessName();
+    processDir.trimFilename();
+
+    // Try relative build directory
+    // XXX: Just make build and install directory layout match
+    wrapperPath = processDir;
+    wrapperPath.join("wrappers");
+    wrapperPath.join(wrapperFilename);
+    if (wrapperPath.exists()) {
+        return wrapperPath;
+    }
+
+    // Try relative install directory
+    wrapperPath = processDir;
+#if defined(_WIN32)
+    wrapperPath.join("..\\lib\\wrappers");
+#elif defined(__APPLE__)
+    wrapperPath.join("../lib/wrappers");
+#else
+    wrapperPath.join("../lib/apitrace/wrappers");
+#endif
+    wrapperPath.join(wrapperFilename);
+    if (wrapperPath.exists()) {
+        return wrapperPath;
+    }
+
+#ifndef _WIN32
+    // Try absolute install directory
+    wrapperPath = APITRACE_WRAPPERS_INSTALL_DIR;
+    wrapperPath.join(wrapperFilename);
+    if (wrapperPath.exists()) {
+        return wrapperPath;
+    }
+#endif
+
+    return "";
+}
+
+
 int
 traceProgram(API api,
              char * const *argv,
              const char *output,
              bool verbose)
 {
-    const char *relPath;
-    const char *absPath;
+    const char *wrapperFilename;
+
+    /*
+     * TODO: simplify code
+     */
 
     switch (api) {
     case API_GL:
-        relPath = "wrappers/" GL_TRACE_WRAPPER;
-        absPath = APITRACE_WRAPPER_INSTALL_DIR "/" GL_TRACE_WRAPPER;
+        wrapperFilename = GL_TRACE_WRAPPER;
         break;
+#ifdef EGL_TRACE_WRAPPER
     case API_EGL:
-#ifndef EGL_TRACE_WRAPPER
-        std::cerr << "error: unsupported API\n";
-        return 1;
-#else
-        relPath = "wrappers/" EGL_TRACE_WRAPPER;
-        absPath = APITRACE_WRAPPER_INSTALL_DIR "/" EGL_TRACE_WRAPPER;
+        wrapperFilename = EGL_TRACE_WRAPPER;
+        break;
+#endif
+#ifdef _WIN32
+    case API_D3D7:
+        wrapperFilename = "ddraw.dll";
+        break;
+    case API_D3D8:
+        wrapperFilename = "d3d8.dll";
+        break;
+    case API_D3D9:
+        wrapperFilename = "d3d9.dll";
+        break;
+    case API_D3D10:
+        wrapperFilename = "d3d10.dll";
+        break;
+    case API_D3D10_1:
+        wrapperFilename = "d3d10_1.dll";
+        break;
+    case API_D3D11:
+        wrapperFilename = "d3d11.dll";
         break;
 #endif
     default:
-        std::cerr << "error: invalid API\n";
+        std::cerr << "error: unsupported API\n";
         return 1;
     }
 
-    os::String wrapper;
-    wrapper = findFile(relPath, absPath, verbose);
+    os::String wrapperPath = findWrapper(wrapperFilename);
 
-    if (!wrapper.length()) {
+    if (!wrapperPath.length()) {
+        std::cerr << "error: failed to find " << wrapperFilename << "\n";
         return 1;
     }
 
 #if defined(_WIN32)
+    /* On Windows copy the wrapper to the program directory.
+     */
+    os::String tmpWrapper(argv[0]);
+    tmpWrapper.trimFilename();
+    tmpWrapper.join(wrapperFilename);
 
-    std::cerr <<
-        "The 'apitrace trace' command is not supported for this operating system.\n"
-        "Instead, you will need to copy opengl32.dll, d3d8.dll, or d3d9.dll from\n"
-        APITRACE_WRAPPER_INSTALL_DIR "\n"
-        "to the directory with the application to trace, then run the application.\n";
+    if (verbose) {
+        std::cerr << wrapperPath << " -> " << tmpWrapper << "\n";
+    }
 
-    return 1;
+    if (tmpWrapper.exists()) {
+        std::cerr << "error: not overwriting " << tmpWrapper << "\n";
+        return 1;
+    }
 
-#else
+    if (!os::copyFile(wrapperPath, tmpWrapper, false)) {
+        std::cerr << "error: failed to copy " << wrapperPath << " into " << tmpWrapper << "\n";
+        return 1;
+    }
+#endif /* _WIN32 */
 
 #if defined(__APPLE__)
     /* On Mac OS X, using DYLD_LIBRARY_PATH, we actually set the
      * directory, not the file. */
-    wrapper.trimFilename();
+    wrapperPath.trimFilename();
 #endif
 
+#if defined(TRACE_VARIABLE)
     if (verbose) {
-        std::cerr << TRACE_VARIABLE << "=" << wrapper.str() << "\n";
+        std::cerr << TRACE_VARIABLE << "=" << wrapperPath.str() << "\n";
     }
-
     /* FIXME: Don't modify the current environment */
-    setenv(TRACE_VARIABLE, wrapper.str(), 1);
+    os::setEnvironment(TRACE_VARIABLE, wrapperPath.str());
+#endif /* TRACE_VARIABLE */
 
     if (output) {
-        setenv("TRACE_FILE", output, 1);
+        os::setEnvironment("TRACE_FILE", output);
     }
 
     if (verbose) {
@@ -128,13 +199,18 @@ traceProgram(API api,
 
     int status = os::execute(argv);
 
-    unsetenv(TRACE_VARIABLE);
+#if defined(TRACE_VARIABLE)
+    os::unsetEnvironment(TRACE_VARIABLE);
+#endif
+#if defined(_WIN32)
+    os::removeFile(tmpWrapper);
+#endif
+
     if (output) {
-        unsetenv("TRACE_FILE");
+        os::unsetEnvironment("TRACE_FILE");
     }
     
     return status;
-#endif
 
 }
 
index 5708e50464abd097ac80dde3ef13a7a872a0a6a0..d69e93fc9650211ca8d6418d173b027a4fa3cc26 100644 (file)
@@ -190,6 +190,10 @@ void Writer::beginStruct(const StructSig *sig) {
     }
 }
 
+void Writer::beginRepr(void) {
+    _writeByte(trace::TYPE_REPR);
+}
+
 void Writer::writeBool(bool value) {
     _writeByte(value ? trace::TYPE_TRUE : trace::TYPE_FALSE);
 }
@@ -294,13 +298,13 @@ void Writer::writeNull(void) {
     _writeByte(trace::TYPE_NULL);
 }
 
-void Writer::writeOpaque(const void *addr) {
+void Writer::writePointer(unsigned long long addr) {
     if (!addr) {
         Writer::writeNull();
         return;
     }
     _writeByte(trace::TYPE_OPAQUE);
-    _writeUInt((size_t)addr);
+    _writeUInt(addr);
 }
 
 
index e012a9b24a0cf25787f7b95182066ad96ef0cc56..a46b43edc487f15faff6f22bc68fade0a57924fa 100644 (file)
@@ -79,6 +79,9 @@ namespace trace {
         void beginStruct(const StructSig *sig);
         inline void endStruct(void) {}
 
+        void beginRepr(void);
+        inline void endRepr(void) {}
+
         void writeBool(bool value);
         void writeSInt(signed long long value);
         void writeUInt(unsigned long long value);
@@ -91,7 +94,7 @@ namespace trace {
         void writeEnum(const EnumSig *sig, signed long long value);
         void writeBitmask(const BitmaskSig *sig, unsigned long long value);
         void writeNull(void);
-        void writeOpaque(const void *ptr);
+        void writePointer(unsigned long long addr);
 
         void writeCall(Call *call);
 
index a3ab720b2dd13f9c89536e4905ed63981ead0b2f..5aeedac520febb823ad08e86aa10bd30a05a24ca 100644 (file)
@@ -89,7 +89,11 @@ LocalWriter::open(void) {
 #endif
         process.trimDirectory();
 
-        os::String prefix = os::getCurrentDir();
+#ifdef ANDROID
+       os::String prefix = "/data";
+#else
+       os::String prefix = os::getCurrentDir();
+#endif
         prefix.join(process);
 
         for (;;) {
index e54142f82b816654679b149306966954b3ac4633..c00818b070c303d9eb1557232c9ac5f840fa7124 100644 (file)
@@ -31,6 +31,8 @@
 #define _TRACE_WRITER_LOCAL_HPP_
 
 
+#include <stdint.h>
+
 #include "os_thread.hpp"
 #include "trace_writer.hpp"
 
index 96544d1502f6eb24c74343866764722f05ec70b2..2e858a233971e3434410b8daba6fb5601c66e3a9 100644 (file)
@@ -97,7 +97,14 @@ public:
     }
 
     void visit(Pointer *node) {
-        writer.writeOpaque((const void *) (size_t) node->value);
+        writer.writePointer(node->value);
+    }
+
+    void visit(Repr *node) {
+        writer.beginRepr();
+        _visit(node->humanValue);
+        _visit(node->machineValue);
+        writer.endRepr();
     }
 
     void visit(Call *call) {
diff --git a/compat.h b/compat.h
deleted file mode 100644 (file)
index f7d95a1..0000000
--- a/compat.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008-2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * MinGW compatability macros to allow using recent's DXSDK headers.
- */
-
-#ifdef __MINGW32__
-
-#define __in /**/
-#define __out /**/
-#define __inout /**/
-#define __inout_opt /**/
-#define __in_opt /**/
-#define __out_opt /**/
-#define __in_bcount(x) /**/
-#define __out_bcount(x) /**/
-#define __in_bcount_opt(x) /**/
-#define __out_bcount_opt(x) /**/
-#define __in_range(x,y) /**/
-#define __in_ecount(x) /**/
-#define __out_ecount(x) /**/
-#define __in_ecount_opt(x) /**/
-#define __out_ecount_opt(x) /**/
-#define __field_bcount(x) /**/
-#define __field_ecount(x) /**/
-#define __field_ecount_full(x) /**/
-#define __inline static __inline__
-#define __deref_out /**/
-#define __deref_out_opt /**/
-#define __deref_out_bcount(x) /**/
-#define __maybenull /**/
-#define __in_z /**/
-#define __in_z_opt /**/
-#define __out_z /**/
-#define __out_ecount_z(x) /**/
-#define __nullterminated /**/
-#define __notnull /**/
-#define __field_ecount_opt(x) /**/
-#define __range(x,y) /**/
-#define __out_ecount_part_opt(x,y) /**/
-
-#ifndef DECLSPEC_DEPRECATED
-#define DECLSPEC_DEPRECATED /**/
-#endif
-
-#ifndef DECLSPEC_NOVTABLE
-#define DECLSPEC_NOVTABLE /**/
-#endif
-
-#ifndef __MINGW64_VERSION_MAJOR
-#define INT8 signed char
-#define UINT8 unsigned char
-#define INT16 signed short
-#define UINT16 unsigned short
-#endif
-
-#endif /* __MINGW32__ */
-
diff --git a/d2d1trace.py b/d2d1trace.py
deleted file mode 100644 (file)
index 4a89e21..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-from dlltrace import DllTracer
-from specs.d2d1 import d2d1
-
-
-class D2D1Tracer(DllTracer):
-
-    def wrapArg(self, function, arg):
-        if function.name == 'D2D1CreateFactory' and arg.output:
-            print '    if (*%s) {' % arg.name
-            for iface in d2d1.interfaces:
-                print '        if (riid == IID_%s) {' % iface.name
-                print '            *%s = (LPVOID) new Wrap%s((%s *)*%s);' % (arg.name, iface.name, iface.name, arg.name)
-                print '        }'
-            print '    }'
-        else:
-            DllTracer.wrapArg(self, function, arg)
-
-
-if __name__ == '__main__':
-    print '#define INITGUID'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    print '#include "d2dimports.hpp"'
-    print
-
-    tracer = D2D1Tracer('d2d1.dll')
-    tracer.trace_api(d2d1)
diff --git a/d2dimports.hpp b/d2dimports.hpp
deleted file mode 100644 (file)
index 4a2594b..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2012 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Central place for all D2D/DWRITE includes, and respective OS dependent headers.
- */
-
-#ifndef _D2DIMPORTS_HPP_
-#define _D2DIMPORTS_HPP_
-
-#include <windows.h>
-#include <tchar.h>
-
-#include "compat.h"
-
-#include <d2d1.h>
-#include <dwrite.h>
-
-DEFINE_GUID(IID_ID2D1Resource,0x2cd90691,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1Bitmap,0xa2296057,0xea42,0x4099,0x98,0x3b,0x53,0x9f,0xb6,0x50,0x54,0x26);
-DEFINE_GUID(IID_ID2D1GradientStopCollection,0x2cd906a7,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1Brush,0x2cd906a8,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1BitmapBrush,0x2cd906aa,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1SolidColorBrush,0x2cd906a9,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1LinearGradientBrush,0x2cd906ab,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1RadialGradientBrush,0x2cd906ac,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1StrokeStyle,0x2cd9069d,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1Geometry,0x2cd906a1,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1RectangleGeometry,0x2cd906a2,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1RoundedRectangleGeometry,0x2cd906a3,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1EllipseGeometry,0x2cd906a4,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1GeometryGroup,0x2cd906a6,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1TransformedGeometry,0x2cd906bb,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1SimplifiedGeometrySink,0x2cd9069e,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1GeometrySink,0x2cd9069f,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1TessellationSink,0x2cd906c1,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1PathGeometry,0x2cd906a5,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1Mesh,0x2cd906c2,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1Layer,0x2cd9069b,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1DrawingStateBlock,0x28506e39,0xebf6,0x46a1,0xbb,0x47,0xfd,0x85,0x56,0x5a,0xb9,0x57);
-DEFINE_GUID(IID_ID2D1RenderTarget,0x2cd90694,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1BitmapRenderTarget,0x2cd90695,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1HwndRenderTarget,0x2cd90698,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
-DEFINE_GUID(IID_ID2D1GdiInteropRenderTarget,0xe0db51c3,0x6f77,0x4bae,0xb3,0xd5,0xe4,0x75,0x09,0xb3,0x58,0x38);
-DEFINE_GUID(IID_ID2D1DCRenderTarget,0x1c51bc64,0xde61,0x46fd,0x98,0x99,0x63,0xa5,0xd8,0xf0,0x39,0x50);
-DEFINE_GUID(IID_ID2D1Factory,0x06152247,0x6f50,0x465a,0x92,0x45,0x11,0x8b,0xfd,0x3b,0x60,0x07);
-
-DEFINE_GUID(IID_IDWriteFontFileLoader,0x727cad4e,0xd6af,0x4c9e,0x8a,0x08,0xd6,0x95,0xb1,0x1c,0xaa,0x49);
-DEFINE_GUID(IID_IDWriteLocalFontFileLoader,0xb2d9f3ec,0xc9fe,0x4a11,0xa2,0xec,0xd8,0x62,0x08,0xf7,0xc0,0xa2);
-DEFINE_GUID(IID_IDWriteFontFileStream,0x6d4865fe,0x0ab8,0x4d91,0x8f,0x62,0x5d,0xd6,0xbe,0x34,0xa3,0xe0);
-DEFINE_GUID(IID_IDWriteFontFile,0x739d886a,0xcef5,0x47dc,0x87,0x69,0x1a,0x8b,0x41,0xbe,0xbb,0xb0);
-DEFINE_GUID(IID_IDWriteRenderingParams,0x2f0da53a,0x2add,0x47cd,0x82,0xee,0xd9,0xec,0x34,0x68,0x8e,0x75);
-DEFINE_GUID(IID_IDWriteFontFace,0x5f49804d,0x7024,0x4d43,0xbf,0xa9,0xd2,0x59,0x84,0xf5,0x38,0x49);
-DEFINE_GUID(IID_IDWriteFontCollectionLoader,0xcca920e4,0x52f0,0x492b,0xbf,0xa8,0x29,0xc7,0x2e,0xe0,0xa4,0x68);
-DEFINE_GUID(IID_IDWriteFontFileEnumerator,0x72755049,0x5ff7,0x435d,0x83,0x48,0x4b,0xe9,0x7c,0xfa,0x6c,0x7c);
-DEFINE_GUID(IID_IDWriteLocalizedStrings,0x08256209,0x099a,0x4b34,0xb8,0x6d,0xc2,0x2b,0x11,0x0e,0x77,0x71);
-DEFINE_GUID(IID_IDWriteFontCollection,0xa84cee02,0x3eea,0x4eee,0xa8,0x27,0x87,0xc1,0xa0,0x2a,0x0f,0xcc);
-DEFINE_GUID(IID_IDWriteFontList,0x1a0d8438,0x1d97,0x4ec1,0xae,0xf9,0xa2,0xfb,0x86,0xed,0x6a,0xcb);
-DEFINE_GUID(IID_IDWriteFontFamily,0xda20d8ef,0x812a,0x4c43,0x98,0x02,0x62,0xec,0x4a,0xbd,0x7a,0xdd);
-DEFINE_GUID(IID_IDWriteFont,0xacd16696,0x8c14,0x4f5d,0x87,0x7e,0xfe,0x3f,0xc1,0xd3,0x27,0x37);
-DEFINE_GUID(IID_IDWriteTextFormat,0x9c906818,0x31d7,0x4fd3,0xa1,0x51,0x7c,0x5e,0x22,0x5d,0xb5,0x5a);
-DEFINE_GUID(IID_IDWriteTypography,0x55f1112b,0x1dc2,0x4b3c,0x95,0x41,0xf4,0x68,0x94,0xed,0x85,0xb6);
-DEFINE_GUID(IID_IDWriteNumberSubstitution,0x14885CC9,0xBAB0,0x4f90,0xB6,0xED,0x5C,0x36,0x6A,0x2C,0xD0,0x3D);
-DEFINE_GUID(IID_IDWriteTextAnalysisSource,0x688e1a58,0x5094,0x47c8,0xad,0xc8,0xfb,0xce,0xa6,0x0a,0xe9,0x2b);
-DEFINE_GUID(IID_IDWriteTextAnalysisSink,0x5810cd44,0x0ca0,0x4701,0xb3,0xfa,0xbe,0xc5,0x18,0x2a,0xe4,0xf6);
-DEFINE_GUID(IID_IDWriteTextAnalyzer,0xb7e6163e,0x7f46,0x43b4,0x84,0xb3,0xe4,0xe6,0x24,0x9c,0x36,0x5d);
-DEFINE_GUID(IID_IDWriteInlineObject,0x8339FDE3,0x106F,0x47ab,0x83,0x73,0x1C,0x62,0x95,0xEB,0x10,0xB3);
-DEFINE_GUID(IID_IDWritePixelSnapping,0xeaf3a2da,0xecf4,0x4d24,0xb6,0x44,0xb3,0x4f,0x68,0x42,0x02,0x4b);
-DEFINE_GUID(IID_IDWriteTextRenderer,0xef8a8135,0x5cc6,0x45fe,0x88,0x25,0xc5,0xa0,0x72,0x4e,0xb8,0x19);
-DEFINE_GUID(IID_IDWriteTextLayout,0x53737037,0x6d14,0x410b,0x9b,0xfe,0x0b,0x18,0x2b,0xb7,0x09,0x61);
-DEFINE_GUID(IID_IDWriteBitmapRenderTarget,0x5e5a32a3,0x8dff,0x4773,0x9f,0xf6,0x06,0x96,0xea,0xb7,0x72,0x67);
-DEFINE_GUID(IID_IDWriteGdiInterop,0x1edd9491,0x9853,0x4299,0x89,0x8f,0x64,0x32,0x98,0x3b,0x6f,0x3a);
-DEFINE_GUID(IID_IDWriteGlyphRunAnalysis,0x7d97dbf7,0xe085,0x42d4,0x81,0xe3,0x6a,0x88,0x3b,0xde,0xd1,0x18);
-DEFINE_GUID(IID_IDWriteFactory,0xb859ee5a,0xd838,0x4b5b,0xa2,0xe8,0x1a,0xdc,0x7d,0x93,0xdb,0x48);
-
-#endif /* _D2DIMPORTS_HPP_ */
diff --git a/d3d10trace.py b/d3d10trace.py
deleted file mode 100644 (file)
index 7d0fc75..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-from specs.d3d10misc import d3d10
-from dlltrace import DllTracer
-
-
-if __name__ == '__main__':
-    print '#define INITGUID'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    print '#include <windows.h>'
-    print '#include <tchar.h>'
-    print
-    print '#include "compat.h"'
-    print
-    print '#include <d3d10.h>'
-    print
-    tracer = DllTracer('d3d10.dll')
-    tracer.trace_api(d3d10)
diff --git a/d3d8trace.py b/d3d8trace.py
deleted file mode 100644 (file)
index af87c2d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-from specs.d3d8 import d3d8
-from dlltrace import DllTracer
-
-
-class D3D8Tracer(DllTracer):
-
-    def serializeArgValue(self, function, arg):
-        # Dump shaders as strings
-        if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction':
-            print '    DumpShader(trace::localWriter, %s);' % (arg.name)
-            return
-
-        DllTracer.serializeArgValue(self, function, arg)
-
-
-if __name__ == '__main__':
-    print '#define INITGUID'
-    print
-    print '#include <windows.h>'
-    print '#include <d3d8.h>'
-    print '#include "d3dshader.hpp"'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    tracer = D3D8Tracer('d3d8.dll')
-    tracer.trace_api(d3d8)
-
diff --git a/d3d9imports.hpp b/d3d9imports.hpp
deleted file mode 100644 (file)
index 3e5ce39..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Central place for all D3D9 includes, and respective OS dependent headers.
- */
-
-#ifndef _D3D9IMPORTS_HPP_
-#define _D3D9IMPORTS_HPP_
-
-#include <windows.h>
-#include <tchar.h>
-
-#include "compat.h"
-
-#include <d3d9.h>
-#include <d3dx9.h>
-
-
-#ifndef D3DFMT_A2B10G10R10_XR_BIAS
-#define D3DFMT_A2B10G10R10_XR_BIAS 119
-#endif
-
-#ifndef D3DFMT_ATI1
-#define D3DFMT_ATI1 ((D3DFORMAT)MAKEFOURCC('A','T','I','1'))
-#endif
-
-#ifndef D3DFMT_ATI2
-#define D3DFMT_ATI2 ((D3DFORMAT)MAKEFOURCC('A','T','I','2'))
-#endif
-
-#ifndef D3DFMT_AYUV
-#define D3DFMT_AYUV ((D3DFORMAT)MAKEFOURCC('A','Y','U','V'))
-#endif
-
-#ifndef D3DFMT_DF16
-#define D3DFMT_DF16 ((D3DFORMAT)MAKEFOURCC('D','F','1','6'))
-#endif
-
-#ifndef D3DFMT_DF24
-#define D3DFMT_DF24 ((D3DFORMAT)MAKEFOURCC('D','F','2','4'))
-#endif
-
-#ifndef D3DFMT_INTZ
-#define D3DFMT_INTZ ((D3DFORMAT)MAKEFOURCC('I','N','T','Z'))
-#endif
-
-#ifndef D3DFMT_NULL
-#define D3DFMT_NULL ((D3DFORMAT)MAKEFOURCC('N','U','L','L'))
-#endif
-
-#ifndef D3DFMT_NV12
-#define D3DFMT_NV12 ((D3DFORMAT)MAKEFOURCC('N','V','1','2'))
-#endif
-
-#ifndef D3DFMT_RAWZ
-#define D3DFMT_RAWZ ((D3DFORMAT)MAKEFOURCC('R','A','W','Z'))
-#endif
-
-
-#endif /* _D3D9IMPORTS_HPP_ */
diff --git a/d3d9trace.py b/d3d9trace.py
deleted file mode 100644 (file)
index 4f40194..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-from dlltrace import DllTracer
-from specs.d3d9 import d3d9
-
-
-class D3D9Tracer(DllTracer):
-
-    def serializeArgValue(self, function, arg):
-        # Dump shaders as strings
-        if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction':
-            print '    DumpShader(trace::localWriter, %s);' % (arg.name)
-            return
-
-        DllTracer.serializeArgValue(self, function, arg)
-
-    def declareWrapperInterfaceVariables(self, interface):
-        DllTracer.declareWrapperInterfaceVariables(self, interface)
-        
-        if interface.name == 'IDirect3DVertexBuffer9':
-            print '    UINT m_SizeToLock;'
-            print '    VOID *m_pbData;'
-
-    def implementWrapperInterfaceMethodBody(self, interface, base, method):
-        if interface.name == 'IDirect3DVertexBuffer9' and method.name == 'Unlock':
-            print '    if (m_pbData) {'
-            self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', 'm_SizeToLock')
-            print '    }'
-
-        DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method)
-
-        if interface.name == 'IDirect3DVertexBuffer9' and method.name == 'Lock':
-            # FIXME: handle recursive locks
-            print '    if (__result == D3D_OK && !(Flags & D3DLOCK_READONLY)) {'
-            print '        if (SizeToLock) {'
-            print '            m_SizeToLock = SizeToLock;'
-            print '        } else {'
-            print '            D3DVERTEXBUFFER_DESC Desc;'
-            print '            m_pInstance->GetDesc(&Desc);'
-            print '            m_SizeToLock = Desc.Size;'
-            print '        }'
-            print '        m_pbData = *ppbData;'
-            print '    } else {'
-            print '        m_pbData = NULL;'
-            print '    }'
-
-
-if __name__ == '__main__':
-    print '#define INITGUID'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    print '#include "d3d9imports.hpp"'
-    print '#include "d3dshader.hpp"'
-    print
-    print '''
-static inline size_t
-_declCount(const D3DVERTEXELEMENT9 *pVertexElements) {
-    size_t count = 0;
-    if (pVertexElements) {
-        while (pVertexElements[count++].Stream != 0xff)
-            ;
-    }
-    return count;
-}
-'''
-    tracer = D3D9Tracer('d3d9.dll')
-    tracer.trace_api(d3d9)
-
diff --git a/d3dshader.cpp b/d3dshader.cpp
deleted file mode 100644 (file)
index a2d5c12..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * Copyright 2008-2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <stdio.h>
-
-#include "d3dshader.hpp"
-#include "d3d9imports.hpp"
-
-
-typedef HRESULT
-(WINAPI *PD3DXDISASSEMBLESHADER)(
-    CONST DWORD *pShader,
-    BOOL EnableColorCode,
-    LPCSTR pComments,
-    LPD3DXBUFFER *ppDisassembly
-);
-
-
-void DumpShader(trace::Writer &writer, const DWORD *tokens)
-{
-    static BOOL firsttime = TRUE;
-    static HMODULE hD3DXModule = NULL;
-    static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL;
-
-    if (firsttime) {
-        if (!hD3DXModule) {
-            unsigned release;
-            int version;
-            for (release = 0; release <= 1; ++release) {
-                /* Version 41 corresponds to Mar 2009 version of DirectX Runtime / SDK */
-                for (version = 41; version >= 0; --version) {
-                    char filename[256];
-                    _snprintf(filename, sizeof(filename),
-                              "d3dx9%s%s%u.dll", release ? "" : "d", version ? "_" : "", version);
-                    hD3DXModule = LoadLibraryA(filename);
-                    if (hD3DXModule)
-                        goto found;
-                }
-            }
-found:
-            ;
-        }
-
-        if (hD3DXModule) {
-            if (!pfnD3DXDisassembleShader) {
-                pfnD3DXDisassembleShader = (PD3DXDISASSEMBLESHADER)GetProcAddress(hD3DXModule, "D3DXDisassembleShader");
-            }
-        }
-
-        firsttime = FALSE;
-    }
-
-    if (pfnD3DXDisassembleShader) {
-        LPD3DXBUFFER pDisassembly = NULL;
-        HRESULT hr;
-
-        hr = pfnD3DXDisassembleShader( (DWORD *)tokens, FALSE, NULL, &pDisassembly);
-        if (hr == D3D_OK) {
-            writer.writeString((const char *)pDisassembly->GetBufferPointer());
-        }
-
-        if (pDisassembly) {
-            pDisassembly->Release();
-        }
-
-        if (hr == D3D_OK) {
-            return;
-        }
-    }
-
-    writer.writeOpaque(tokens);
-}
diff --git a/d3dshader.hpp b/d3dshader.hpp
deleted file mode 100644 (file)
index 485df05..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * Copyright 2008-2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _D3DSHADER_HPP_
-#define _D3DSHADER_HPP_
-
-
-#include <windows.h>
-
-#include "trace_writer.hpp"
-
-void DumpShader(trace::Writer &writer, const DWORD *tokens);
-
-
-#endif /* _D3DSHADER_HPP_ */
diff --git a/ddrawtrace.py b/ddrawtrace.py
deleted file mode 100644 (file)
index 44d0f6f..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-from specs.d3d import ddraw, interfaces
-from dlltrace import DllTracer
-
-
-class DDrawTracer(DllTracer):
-
-    def traceFunctionImplBody(self, function):
-        if function.name in ('AcquireDDThreadLock', 'ReleaseDDThreadLock'):
-            self.invokeFunction(function)
-            return
-
-        DllTracer.traceFunctionImplBody(self, function)
-
-    def serializeArg(self, function, arg):
-        if function.name == 'DirectDrawCreateEx' and arg.name == 'lplpDD':
-            print '    if (*lplpDD) {'
-            for iface in interfaces:
-                print '        if (iid == IID_%s) {' % iface.name
-                print '            *lplpDD = (LPVOID) new Wrap%s((%s *)*lplpDD);' % (iface.name, iface.name)
-                print '        }'
-            print '    }'
-
-        DllTracer.serializeArg(self, function, arg)
-
-
-if __name__ == '__main__':
-    print '#define INITGUID'
-    print '#include <windows.h>'
-    print '#include <ddraw.h>'
-    print '#include <d3d.h>'
-    print
-    print '''
-
-#ifndef DDBLT_EXTENDED_FLAGS
-#define DDBLT_EXTENDED_FLAGS 0x40000000l
-#endif
-
-#ifndef DDBLT_EXTENDED_LINEAR_CONTENT
-#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l
-#endif
-
-#ifndef D3DLIGHT_PARALLELPOINT
-#define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4
-#endif
-
-#ifndef D3DLIGHT_GLSPOT
-#define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5
-#endif
-
-'''
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    tracer = DDrawTracer('ddraw.dll')
-    tracer.trace_api(ddraw)
diff --git a/dispatch.py b/dispatch.py
deleted file mode 100644 (file)
index 95bc36d..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-##########################################################################
-#
-# Copyright 2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""Generate DLL/SO dispatching functions.
-""" 
-
-
-import specs.stdapi as stdapi
-
-
-def function_pointer_type(function):
-    return '__PFN' + function.name.upper()
-
-
-def function_pointer_value(function):
-    return '__' + function.name + '_ptr'
-
-
-class Dispatcher:
-
-    def header(self):
-        # Must be implemented by derived classes, which should define, declare,
-        # or implement something like:
-        #
-        #  typedef void (*__PROC)(void);
-        #
-        #  static __PROC __getPublicProcAddress(const char *name);
-        #  static __PROC __getPrivateProcAddress(const char *name);
-        #
-        raise NotImplementedError
-
-    def dispatch_api(self, api):
-        for function in api.functions:
-            self.invokeFunction(function)
-        
-        # define standard name aliases for convenience, but only when not
-        # tracing, as that would cause symbol clashing with the tracing
-        # functions
-        print '#ifdef RETRACE'
-        for function in api.functions:
-            print '#define %s __%s' % (function.name, function.name)
-        print '#endif /* RETRACE */'
-        print
-
-    def invokeFunction(self, function):
-        ptype = function_pointer_type(function)
-        pvalue = function_pointer_value(function)
-        print 'typedef ' + function.prototype('* %s' % ptype) + ';'
-        print 'static %s %s = NULL;' % (ptype, pvalue)
-        print
-        print 'static inline ' + function.prototype('__' + function.name) + ' {'
-        print '    const char *__name = "%s";' % function.name
-        if function.type is stdapi.Void:
-            ret = ''
-        else:
-            ret = 'return '
-        self.get_true_pointer(function)
-        print '    %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args]))
-        print '}'
-        print
-
-    def isFunctionPublic(self, function):
-        return True
-
-    def get_true_pointer(self, function):
-        ptype = function_pointer_type(function)
-        pvalue = function_pointer_value(function)
-        if self.isFunctionPublic(function):
-            get_proc_address = '__getPublicProcAddress'
-        else:
-            get_proc_address = '__getPrivateProcAddress'
-        print '    if (!%s) {' % (pvalue,)
-        print '        %s = (%s)%s(__name);' % (pvalue, ptype, get_proc_address)
-        print '        if (!%s) {' % (pvalue,)
-        self.failFunction(function)
-        print '        }'
-        print '    }'
-
-    def failFunction(self, function):
-        if function.type is stdapi.Void or function.fail is not None:
-            print r'            os::log("warning: ignoring call to unavailable function %s\n", __name);'
-            if function.type is stdapi.Void:
-                assert function.fail is None
-                print '            return;' 
-            else:
-                assert function.fail is not None
-                print '            return %s;' % function.fail
-        else:
-            print r'            os::log("error: unavailable function %s\n", __name);'
-            print r'            os::abort();'
-
-
diff --git a/dispatch/.gitignore b/dispatch/.gitignore
new file mode 100644 (file)
index 0000000..213c471
--- /dev/null
@@ -0,0 +1 @@
+glproc.hpp
diff --git a/dispatch/CMakeLists.txt b/dispatch/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0dad67f
--- /dev/null
@@ -0,0 +1,55 @@
+##############################################################################
+# Dispatch
+
+include_directories (
+    ${CMAKE_CURRENT_BINARY_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+add_custom_command (
+    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
+    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glproc.py > ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp
+    DEPENDS
+        glproc.py
+        dispatch.py
+        ${CMAKE_SOURCE_DIR}/specs/wglapi.py
+        ${CMAKE_SOURCE_DIR}/specs/glxapi.py
+        ${CMAKE_SOURCE_DIR}/specs/cglapi.py
+        ${CMAKE_SOURCE_DIR}/specs/eglapi.py
+        ${CMAKE_SOURCE_DIR}/specs/glesapi.py
+        ${CMAKE_SOURCE_DIR}/specs/glapi.py
+        ${CMAKE_SOURCE_DIR}/specs/gltypes.py
+        ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+)
+
+
+# Wrap glproc.hpp as a target to prevent the command from being executed
+# multiple times simulatenously, when the targets that depend on it are built
+# in parallel.
+add_custom_target (glproc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/glproc.hpp)
+
+
+add_library (glproc_gl STATIC EXCLUDE_FROM_ALL
+    glproc_gl.cpp
+)
+
+add_dependencies (glproc_gl glproc)
+
+set_target_properties (glproc_gl PROPERTIES
+    # Ensure it can be statically linked in shared libraries
+    COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
+)
+
+if (ENABLE_EGL)
+    add_library (glproc_egl STATIC EXCLUDE_FROM_ALL
+        glproc_egl.cpp
+    )
+
+    add_dependencies (glproc_egl glproc)
+
+    set_target_properties (glproc_egl PROPERTIES
+        # Ensure it can be statically linked in shared libraries
+        COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
+    )
+endif ()
+
diff --git a/dispatch/__init__.py b/dispatch/__init__.py
new file mode 100644 (file)
index 0000000..b872135
--- /dev/null
@@ -0,0 +1 @@
+from dispatch import *
diff --git a/dispatch/compat.h b/dispatch/compat.h
new file mode 100644 (file)
index 0000000..3fc9730
--- /dev/null
@@ -0,0 +1,748 @@
+/**************************************************************************
+ *
+ * Copyright 2008-2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * MinGW compatability macros to allow using recent's DXSDK headers.
+ */
+
+#ifdef __MINGW32__
+
+
+/*
+ * Dummy definitions Standard Annotation Language (SAL) definitions
+ *
+ * These are typically defined in sal.h.
+ *
+ * http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/sal.h?view=markup
+ */
+
+#define _Always_(annos)
+#define _Analysis_noreturn_
+#define _At_(target, annos)
+#define _At_buffer_(target, iter, bound, annos)
+#define _COM_Outptr_
+#define _COM_Outptr_opt_
+#define _COM_Outptr_opt_result_maybenull_
+#define _COM_Outptr_result_maybenull_
+#define _Check_return_
+#define _Const_
+#define _Deref2_pre_readonly_
+#define _Deref_in_bound_
+#define _Deref_in_range_(lb,ub)
+#define _Deref_inout_bound_
+#define _Deref_inout_z_
+#define _Deref_inout_z_bytecap_c_(size)
+#define _Deref_inout_z_cap_c_(size)
+#define _Deref_opt_out_
+#define _Deref_opt_out_opt_
+#define _Deref_opt_out_opt_z_
+#define _Deref_opt_out_z_
+#define _Deref_out_
+#define _Deref_out_bound_
+#define _Deref_out_opt_
+#define _Deref_out_opt_z_
+#define _Deref_out_range_(lb,ub)
+#define _Deref_out_z_
+#define _Deref_out_z_bytecap_c_(size)
+#define _Deref_out_z_cap_c_(size)
+#define _Deref_post_bytecap_(size)
+#define _Deref_post_bytecap_c_(size)
+#define _Deref_post_bytecap_x_(size)
+#define _Deref_post_bytecount_(size)
+#define _Deref_post_bytecount_c_(size)
+#define _Deref_post_bytecount_x_(size)
+#define _Deref_post_cap_(size)
+#define _Deref_post_cap_c_(size)
+#define _Deref_post_cap_x_(size)
+#define _Deref_post_count_(size)
+#define _Deref_post_count_c_(size)
+#define _Deref_post_count_x_(size)
+#define _Deref_post_maybenull_
+#define _Deref_post_notnull_
+#define _Deref_post_null_
+#define _Deref_post_opt_bytecap_(size)
+#define _Deref_post_opt_bytecap_c_(size)
+#define _Deref_post_opt_bytecap_x_(size)
+#define _Deref_post_opt_bytecount_(size)
+#define _Deref_post_opt_bytecount_c_(size)
+#define _Deref_post_opt_bytecount_x_(size)
+#define _Deref_post_opt_cap_(size)
+#define _Deref_post_opt_cap_c_(size)
+#define _Deref_post_opt_cap_x_(size)
+#define _Deref_post_opt_count_(size)
+#define _Deref_post_opt_count_c_(size)
+#define _Deref_post_opt_count_x_(size)
+#define _Deref_post_opt_valid_
+#define _Deref_post_opt_valid_bytecap_(size)
+#define _Deref_post_opt_valid_bytecap_c_(size)
+#define _Deref_post_opt_valid_bytecap_x_(size)
+#define _Deref_post_opt_valid_cap_(size)
+#define _Deref_post_opt_valid_cap_c_(size)
+#define _Deref_post_opt_valid_cap_x_(size)
+#define _Deref_post_opt_z_
+#define _Deref_post_opt_z_bytecap_(size)
+#define _Deref_post_opt_z_bytecap_c_(size)
+#define _Deref_post_opt_z_bytecap_x_(size)
+#define _Deref_post_opt_z_cap_(size)
+#define _Deref_post_opt_z_cap_c_(size)
+#define _Deref_post_opt_z_cap_x_(size)
+#define _Deref_post_valid_
+#define _Deref_post_valid_bytecap_(size)
+#define _Deref_post_valid_bytecap_c_(size)
+#define _Deref_post_valid_bytecap_x_(size)
+#define _Deref_post_valid_cap_(size)
+#define _Deref_post_valid_cap_c_(size)
+#define _Deref_post_valid_cap_x_(size)
+#define _Deref_post_z_
+#define _Deref_post_z_bytecap_(size)
+#define _Deref_post_z_bytecap_c_(size)
+#define _Deref_post_z_bytecap_x_(size)
+#define _Deref_post_z_cap_(size)
+#define _Deref_post_z_cap_c_(size)
+#define _Deref_post_z_cap_x_(size)
+#define _Deref_pre_bytecap_(size)
+#define _Deref_pre_bytecap_c_(size)
+#define _Deref_pre_bytecap_x_(size)
+#define _Deref_pre_bytecount_(size)
+#define _Deref_pre_bytecount_c_(size)
+#define _Deref_pre_bytecount_x_(size)
+#define _Deref_pre_cap_(size)
+#define _Deref_pre_cap_c_(size)
+#define _Deref_pre_cap_x_(size)
+#define _Deref_pre_count_(size)
+#define _Deref_pre_count_c_(size)
+#define _Deref_pre_count_x_(size)
+#define _Deref_pre_invalid_
+#define _Deref_pre_maybenull_
+#define _Deref_pre_notnull_
+#define _Deref_pre_null_
+#define _Deref_pre_opt_bytecap_(size)
+#define _Deref_pre_opt_bytecap_c_(size)
+#define _Deref_pre_opt_bytecap_x_(size)
+#define _Deref_pre_opt_bytecount_(size)
+#define _Deref_pre_opt_bytecount_c_(size)
+#define _Deref_pre_opt_bytecount_x_(size)
+#define _Deref_pre_opt_cap_(size)
+#define _Deref_pre_opt_cap_c_(size)
+#define _Deref_pre_opt_cap_x_(size)
+#define _Deref_pre_opt_count_(size)
+#define _Deref_pre_opt_count_c_(size)
+#define _Deref_pre_opt_count_x_(size)
+#define _Deref_pre_opt_valid_
+#define _Deref_pre_opt_valid_bytecap_(size)
+#define _Deref_pre_opt_valid_bytecap_c_(size)
+#define _Deref_pre_opt_valid_bytecap_x_(size)
+#define _Deref_pre_opt_valid_cap_(size)
+#define _Deref_pre_opt_valid_cap_c_(size)
+#define _Deref_pre_opt_valid_cap_x_(size)
+#define _Deref_pre_opt_z_
+#define _Deref_pre_opt_z_bytecap_(size)
+#define _Deref_pre_opt_z_bytecap_c_(size)
+#define _Deref_pre_opt_z_bytecap_x_(size)
+#define _Deref_pre_opt_z_cap_(size)
+#define _Deref_pre_opt_z_cap_c_(size)
+#define _Deref_pre_opt_z_cap_x_(size)
+#define _Deref_pre_readonly_
+#define _Deref_pre_valid_
+#define _Deref_pre_valid_bytecap_(size)
+#define _Deref_pre_valid_bytecap_c_(size)
+#define _Deref_pre_valid_bytecap_x_(size)
+#define _Deref_pre_valid_cap_(size)
+#define _Deref_pre_valid_cap_c_(size)
+#define _Deref_pre_valid_cap_x_(size)
+#define _Deref_pre_writeonly_
+#define _Deref_pre_z_
+#define _Deref_pre_z_bytecap_(size)
+#define _Deref_pre_z_bytecap_c_(size)
+#define _Deref_pre_z_bytecap_x_(size)
+#define _Deref_pre_z_cap_(size)
+#define _Deref_pre_z_cap_c_(size)
+#define _Deref_pre_z_cap_x_(size)
+#define _Deref_prepost_bytecap_(size)
+#define _Deref_prepost_bytecap_x_(size)
+#define _Deref_prepost_bytecount_(size)
+#define _Deref_prepost_bytecount_x_(size)
+#define _Deref_prepost_cap_(size)
+#define _Deref_prepost_cap_x_(size)
+#define _Deref_prepost_count_(size)
+#define _Deref_prepost_count_x_(size)
+#define _Deref_prepost_opt_bytecap_(size)
+#define _Deref_prepost_opt_bytecap_x_(size)
+#define _Deref_prepost_opt_bytecount_(size)
+#define _Deref_prepost_opt_bytecount_x_(size)
+#define _Deref_prepost_opt_cap_(size)
+#define _Deref_prepost_opt_cap_x_(size)
+#define _Deref_prepost_opt_count_(size)
+#define _Deref_prepost_opt_count_x_(size)
+#define _Deref_prepost_opt_valid_
+#define _Deref_prepost_opt_valid_bytecap_(size)
+#define _Deref_prepost_opt_valid_bytecap_x_(size)
+#define _Deref_prepost_opt_valid_cap_(size)
+#define _Deref_prepost_opt_valid_cap_x_(size)
+#define _Deref_prepost_opt_z_
+#define _Deref_prepost_opt_z_bytecap_(size)
+#define _Deref_prepost_opt_z_cap_(size)
+#define _Deref_prepost_valid_
+#define _Deref_prepost_valid_bytecap_(size)
+#define _Deref_prepost_valid_bytecap_x_(size)
+#define _Deref_prepost_valid_cap_(size)
+#define _Deref_prepost_valid_cap_x_(size)
+#define _Deref_prepost_z_
+#define _Deref_prepost_z_bytecap_(size)
+#define _Deref_prepost_z_cap_(size)
+#define _Deref_ret_bound_
+#define _Deref_ret_opt_z_
+#define _Deref_ret_range_(lb,ub)
+#define _Deref_ret_z_
+#define _Field_range_(min,max)
+#define _Field_size_(size)
+#define _Field_size_bytes_(size)
+#define _Field_size_bytes_full_(size)
+#define _Field_size_bytes_full_opt_(size)
+#define _Field_size_bytes_opt_(size)
+#define _Field_size_bytes_part_(size, count)
+#define _Field_size_bytes_part_opt_(size, count)
+#define _Field_size_full_(size)
+#define _Field_size_full_opt_(size)
+#define _Field_size_opt_(size)
+#define _Field_size_part_(size, count)
+#define _Field_size_part_opt_(size, count)
+#define _Field_z_
+#define _Function_class_(x)
+#define _Group_(annos)
+#define _In_
+#define _In_bound_
+#define _In_bytecount_(size)
+#define _In_bytecount_c_(size)
+#define _In_bytecount_x_(size)
+#define _In_count_(size)
+#define _In_count_c_(size)
+#define _In_count_x_(size)
+#define _In_defensive_(annotes)
+#define _In_opt_
+#define _In_opt_bytecount_(size)
+#define _In_opt_bytecount_c_(size)
+#define _In_opt_bytecount_x_(size)
+#define _In_opt_count_(size)
+#define _In_opt_count_c_(size)
+#define _In_opt_count_x_(size)
+#define _In_opt_ptrdiff_count_(size)
+#define _In_opt_z_
+#define _In_opt_z_bytecount_(size)
+#define _In_opt_z_bytecount_c_(size)
+#define _In_opt_z_count_(size)
+#define _In_opt_z_count_c_(size)
+#define _In_ptrdiff_count_(size)
+#define _In_range_(lb,ub)
+#define _In_reads_(size)
+#define _In_reads_bytes_(size)
+#define _In_reads_bytes_opt_(size)
+#define _In_reads_opt_(size)
+#define _In_reads_opt_z_(size)
+#define _In_reads_or_z_(size)
+#define _In_reads_to_ptr_(ptr)
+#define _In_reads_to_ptr_opt_(ptr)
+#define _In_reads_to_ptr_opt_z_(ptr)
+#define _In_reads_to_ptr_z_(ptr)
+#define _In_reads_z_(size)
+#define _In_z_
+#define _In_z_bytecount_(size)
+#define _In_z_bytecount_c_(size)
+#define _In_z_count_(size)
+#define _In_z_count_c_(size)
+#define _Inout_
+#define _Inout_bytecap_(size)
+#define _Inout_bytecap_c_(size)
+#define _Inout_bytecap_x_(size)
+#define _Inout_bytecount_(size)
+#define _Inout_bytecount_c_(size)
+#define _Inout_bytecount_x_(size)
+#define _Inout_cap_(size)
+#define _Inout_cap_c_(size)
+#define _Inout_cap_x_(size)
+#define _Inout_count_(size)
+#define _Inout_count_c_(size)
+#define _Inout_count_x_(size)
+#define _Inout_defensive_(annotes)
+#define _Inout_opt_
+#define _Inout_opt_bytecap_(size)
+#define _Inout_opt_bytecap_c_(size)
+#define _Inout_opt_bytecap_x_(size)
+#define _Inout_opt_bytecount_(size)
+#define _Inout_opt_bytecount_c_(size)
+#define _Inout_opt_bytecount_x_(size)
+#define _Inout_opt_cap_(size)
+#define _Inout_opt_cap_c_(size)
+#define _Inout_opt_cap_x_(size)
+#define _Inout_opt_count_(size)
+#define _Inout_opt_count_c_(size)
+#define _Inout_opt_count_x_(size)
+#define _Inout_opt_ptrdiff_count_(size)
+#define _Inout_opt_z_
+#define _Inout_opt_z_bytecap_(size)
+#define _Inout_opt_z_bytecap_c_(size)
+#define _Inout_opt_z_bytecap_x_(size)
+#define _Inout_opt_z_bytecount_(size)
+#define _Inout_opt_z_bytecount_c_(size)
+#define _Inout_opt_z_cap_(size)
+#define _Inout_opt_z_cap_c_(size)
+#define _Inout_opt_z_cap_x_(size)
+#define _Inout_opt_z_count_(size)
+#define _Inout_opt_z_count_c_(size)
+#define _Inout_ptrdiff_count_(size)
+#define _Inout_updates_(size)
+#define _Inout_updates_all_(size)
+#define _Inout_updates_all_opt_(size)
+#define _Inout_updates_bytes_(size)
+#define _Inout_updates_bytes_all_(size)
+#define _Inout_updates_bytes_all_opt_(size)
+#define _Inout_updates_bytes_opt_(size)
+#define _Inout_updates_bytes_to_(size,count)
+#define _Inout_updates_bytes_to_opt_(size,count)
+#define _Inout_updates_opt_(size)
+#define _Inout_updates_opt_z_(size)
+#define _Inout_updates_to_(size,count)
+#define _Inout_updates_to_opt_(size,count)
+#define _Inout_updates_z_(size)
+#define _Inout_z_
+#define _Inout_z_bytecap_(size)
+#define _Inout_z_bytecap_c_(size)
+#define _Inout_z_bytecap_x_(size)
+#define _Inout_z_bytecount_(size)
+#define _Inout_z_bytecount_c_(size)
+#define _Inout_z_cap_(size)
+#define _Inout_z_cap_c_(size)
+#define _Inout_z_cap_x_(size)
+#define _Inout_z_count_(size)
+#define _Inout_z_count_c_(size)
+#define _Interlocked_operand_
+#define _Literal_
+#define _Maybe_raises_SEH_exception
+#define _Maybe_raises_SEH_exception_
+#define _Maybenull_
+#define _Maybevalid_
+#define _Must_inspect_result_
+#define _Notliteral_
+#define _Notnull_
+#define _Notref_
+#define _Notvalid_
+#define _NullNull_terminated_
+#define _Null_
+#define _Null_terminated_
+#define _On_failure_(annos)
+#define _Out_
+#define _Out_bound_
+#define _Out_bytecap_(size)
+#define _Out_bytecap_c_(size)
+#define _Out_bytecap_post_bytecount_(cap,count)
+#define _Out_bytecap_x_(size)
+#define _Out_bytecapcount_(capcount)
+#define _Out_bytecapcount_x_(capcount)
+#define _Out_cap_(size)
+#define _Out_cap_c_(size)
+#define _Out_cap_m_(mult,size)
+#define _Out_cap_post_count_(cap,count)
+#define _Out_cap_x_(size)
+#define _Out_capcount_(capcount)
+#define _Out_capcount_x_(capcount)
+#define _Out_defensive_(annotes)
+#define _Out_opt_
+#define _Out_opt_bytecap_(size)
+#define _Out_opt_bytecap_c_(size)
+#define _Out_opt_bytecap_post_bytecount_(cap,count)
+#define _Out_opt_bytecap_x_(size)
+#define _Out_opt_bytecapcount_(capcount)
+#define _Out_opt_bytecapcount_x_(capcount)
+#define _Out_opt_cap_(size)
+#define _Out_opt_cap_c_(size)
+#define _Out_opt_cap_m_(mult,size)
+#define _Out_opt_cap_post_count_(cap,count)
+#define _Out_opt_cap_x_(size)
+#define _Out_opt_capcount_(capcount)
+#define _Out_opt_capcount_x_(capcount)
+#define _Out_opt_ptrdiff_cap_(size)
+#define _Out_opt_z_bytecap_(size)
+#define _Out_opt_z_bytecap_c_(size)
+#define _Out_opt_z_bytecap_post_bytecount_(cap,count)
+#define _Out_opt_z_bytecap_x_(size)
+#define _Out_opt_z_bytecapcount_(capcount)
+#define _Out_opt_z_cap_(size)
+#define _Out_opt_z_cap_c_(size)
+#define _Out_opt_z_cap_m_(mult,size)
+#define _Out_opt_z_cap_post_count_(cap,count)
+#define _Out_opt_z_cap_x_(size)
+#define _Out_opt_z_capcount_(capcount)
+#define _Out_ptrdiff_cap_(size)
+#define _Out_range_(lb,ub)
+#define _Out_writes_(size)
+#define _Out_writes_all_(size)
+#define _Out_writes_all_opt_(size)
+#define _Out_writes_bytes_(size)
+#define _Out_writes_bytes_all_(size)
+#define _Out_writes_bytes_all_opt_(size)
+#define _Out_writes_bytes_opt_(size)
+#define _Out_writes_bytes_to_(size,count)
+#define _Out_writes_bytes_to_opt_(size,count)
+#define _Out_writes_opt_(size)
+#define _Out_writes_opt_z_(size)
+#define _Out_writes_to_(size,count)
+#define _Out_writes_to_opt_(size,count)
+#define _Out_writes_to_ptr_(ptr)
+#define _Out_writes_to_ptr_opt_(ptr)
+#define _Out_writes_to_ptr_opt_z_(ptr)
+#define _Out_writes_to_ptr_z_(ptr)
+#define _Out_writes_z_(size)
+#define _Out_z_bytecap_(size)
+#define _Out_z_bytecap_c_(size)
+#define _Out_z_bytecap_post_bytecount_(cap,count)
+#define _Out_z_bytecap_x_(size)
+#define _Out_z_bytecapcount_(capcount)
+#define _Out_z_cap_(size)
+#define _Out_z_cap_c_(size)
+#define _Out_z_cap_m_(mult,size)
+#define _Out_z_cap_post_count_(cap,count)
+#define _Out_z_cap_x_(size)
+#define _Out_z_capcount_(capcount)
+#define _Outptr_
+#define _Outptr_opt_
+#define _Outptr_opt_result_buffer_(size)
+#define _Outptr_opt_result_buffer_all_(size)
+#define _Outptr_opt_result_buffer_all_maybenull_(size)
+#define _Outptr_opt_result_buffer_maybenull_(size)
+#define _Outptr_opt_result_buffer_to_(size, count)
+#define _Outptr_opt_result_buffer_to_maybenull_(size, count)
+#define _Outptr_opt_result_bytebuffer_(size)
+#define _Outptr_opt_result_bytebuffer_all_(size)
+#define _Outptr_opt_result_bytebuffer_all_maybenull_(size)
+#define _Outptr_opt_result_bytebuffer_maybenull_(size)
+#define _Outptr_opt_result_bytebuffer_to_(size, count)
+#define _Outptr_opt_result_bytebuffer_to_maybenull_(size, count)
+#define _Outptr_opt_result_maybenull_
+#define _Outptr_opt_result_maybenull_z_
+#define _Outptr_opt_result_nullonfailure_
+#define _Outptr_opt_result_z_
+#define _Outptr_result_buffer_(size)
+#define _Outptr_result_buffer_all_(size)
+#define _Outptr_result_buffer_all_maybenull_(size)
+#define _Outptr_result_buffer_maybenull_(size)
+#define _Outptr_result_buffer_to_(size, count)
+#define _Outptr_result_buffer_to_maybenull_(size, count)
+#define _Outptr_result_bytebuffer_(size)
+#define _Outptr_result_bytebuffer_all_(size)
+#define _Outptr_result_bytebuffer_all_maybenull_(size)
+#define _Outptr_result_bytebuffer_maybenull_(size)
+#define _Outptr_result_bytebuffer_to_(size, count)
+#define _Outptr_result_bytebuffer_to_maybenull_(size, count)
+#define _Outptr_result_maybenull_
+#define _Outptr_result_maybenull_z_
+#define _Outptr_result_nullonfailure_
+#define _Outptr_result_z_
+#define _Outref_
+#define _Outref_result_buffer_(size)
+#define _Outref_result_buffer_all_(size)
+#define _Outref_result_buffer_all_maybenull_(size)
+#define _Outref_result_buffer_maybenull_(size)
+#define _Outref_result_buffer_to_(size, count)
+#define _Outref_result_buffer_to_maybenull_(size, count)
+#define _Outref_result_bytebuffer_(size)
+#define _Outref_result_bytebuffer_all_(size)
+#define _Outref_result_bytebuffer_all_maybenull_(size)
+#define _Outref_result_bytebuffer_maybenull_(size)
+#define _Outref_result_bytebuffer_to_(size, count)
+#define _Outref_result_bytebuffer_to_maybenull_(size, count)
+#define _Outref_result_maybenull_
+#define _Outref_result_nullonfailure_
+#define _Points_to_data_
+#define _Post_
+#define _Post_bytecap_(size)
+#define _Post_bytecount_(size)
+#define _Post_bytecount_c_(size)
+#define _Post_bytecount_x_(size)
+#define _Post_cap_(size)
+#define _Post_count_(size)
+#define _Post_count_c_(size)
+#define _Post_count_x_(size)
+#define _Post_defensive_
+#define _Post_equal_to_(expr)
+#define _Post_invalid_
+#define _Post_maybenull_
+#define _Post_maybez_
+#define _Post_notnull_
+#define _Post_null_
+#define _Post_ptr_invalid_
+#define _Post_readable_byte_size_(size)
+#define _Post_readable_size_(size)
+#define _Post_satisfies_(cond)
+#define _Post_valid_
+#define _Post_writable_byte_size_(size)
+#define _Post_writable_size_(size)
+#define _Post_z_
+#define _Post_z_bytecount_(size)
+#define _Post_z_bytecount_c_(size)
+#define _Post_z_bytecount_x_(size)
+#define _Post_z_count_(size)
+#define _Post_z_count_c_(size)
+#define _Post_z_count_x_(size)
+#define _Pre_
+#define _Pre_bytecap_(size)
+#define _Pre_bytecap_c_(size)
+#define _Pre_bytecap_x_(size)
+#define _Pre_bytecount_(size)
+#define _Pre_bytecount_c_(size)
+#define _Pre_bytecount_x_(size)
+#define _Pre_cap_(size)
+#define _Pre_cap_c_(size)
+#define _Pre_cap_c_one_
+#define _Pre_cap_for_(param)
+#define _Pre_cap_m_(mult,size)
+#define _Pre_cap_x_(size)
+#define _Pre_count_(size)
+#define _Pre_count_c_(size)
+#define _Pre_count_x_(size)
+#define _Pre_defensive_
+#define _Pre_equal_to_(expr)
+#define _Pre_invalid_
+#define _Pre_maybenull_
+#define _Pre_notnull_
+#define _Pre_null_
+#define _Pre_opt_bytecap_(size)
+#define _Pre_opt_bytecap_c_(size)
+#define _Pre_opt_bytecap_x_(size)
+#define _Pre_opt_bytecount_(size)
+#define _Pre_opt_bytecount_c_(size)
+#define _Pre_opt_bytecount_x_(size)
+#define _Pre_opt_cap_(size)
+#define _Pre_opt_cap_c_(size)
+#define _Pre_opt_cap_c_one_
+#define _Pre_opt_cap_for_(param)
+#define _Pre_opt_cap_m_(mult,size)
+#define _Pre_opt_cap_x_(size)
+#define _Pre_opt_count_(size)
+#define _Pre_opt_count_c_(size)
+#define _Pre_opt_count_x_(size)
+#define _Pre_opt_ptrdiff_cap_(ptr)
+#define _Pre_opt_ptrdiff_count_(ptr)
+#define _Pre_opt_valid_
+#define _Pre_opt_valid_bytecap_(size)
+#define _Pre_opt_valid_bytecap_c_(size)
+#define _Pre_opt_valid_bytecap_x_(size)
+#define _Pre_opt_valid_cap_(size)
+#define _Pre_opt_valid_cap_c_(size)
+#define _Pre_opt_valid_cap_x_(size)
+#define _Pre_opt_z_
+#define _Pre_opt_z_bytecap_(size)
+#define _Pre_opt_z_bytecap_c_(size)
+#define _Pre_opt_z_bytecap_x_(size)
+#define _Pre_opt_z_cap_(size)
+#define _Pre_opt_z_cap_c_(size)
+#define _Pre_opt_z_cap_x_(size)
+#define _Pre_ptrdiff_cap_(ptr)
+#define _Pre_ptrdiff_count_(ptr)
+#define _Pre_readable_byte_size_(size)
+#define _Pre_readable_size_(size)
+#define _Pre_readonly_
+#define _Pre_satisfies_(cond)
+#define _Pre_valid_
+#define _Pre_valid_bytecap_(size)
+#define _Pre_valid_bytecap_c_(size)
+#define _Pre_valid_bytecap_x_(size)
+#define _Pre_valid_cap_(size)
+#define _Pre_valid_cap_c_(size)
+#define _Pre_valid_cap_x_(size)
+#define _Pre_writable_byte_size_(size)
+#define _Pre_writable_size_(size)
+#define _Pre_writeonly_
+#define _Pre_z_
+#define _Pre_z_bytecap_(size)
+#define _Pre_z_bytecap_c_(size)
+#define _Pre_z_bytecap_x_(size)
+#define _Pre_z_cap_(size)
+#define _Pre_z_cap_c_(size)
+#define _Pre_z_cap_x_(size)
+#define _Prepost_bytecount_(size)
+#define _Prepost_bytecount_c_(size)
+#define _Prepost_bytecount_x_(size)
+#define _Prepost_count_(size)
+#define _Prepost_count_c_(size)
+#define _Prepost_count_x_(size)
+#define _Prepost_opt_bytecount_(size)
+#define _Prepost_opt_bytecount_c_(size)
+#define _Prepost_opt_bytecount_x_(size)
+#define _Prepost_opt_count_(size)
+#define _Prepost_opt_count_c_(size)
+#define _Prepost_opt_count_x_(size)
+#define _Prepost_opt_valid_
+#define _Prepost_opt_z_
+#define _Prepost_valid_
+#define _Prepost_z_
+#define _Printf_format_string_
+#define _Raises_SEH_exception_
+#define _Readable_bytes_(size)
+#define _Readable_elements_(size)
+#define _Reserved_
+#define _Result_nullonfailure_
+#define _Result_zeroonfailure_
+#define _Ret_
+#define _Ret_bound_
+#define _Ret_bytecap_(size)
+#define _Ret_bytecap_c_(size)
+#define _Ret_bytecap_x_(size)
+#define _Ret_bytecount_(size)
+#define _Ret_bytecount_c_(size)
+#define _Ret_bytecount_x_(size)
+#define _Ret_cap_(size)
+#define _Ret_cap_c_(size)
+#define _Ret_cap_x_(size)
+#define _Ret_count_(size)
+#define _Ret_count_c_(size)
+#define _Ret_count_x_(size)
+#define _Ret_maybenull_
+#define _Ret_maybenull_z_
+#define _Ret_notnull_
+#define _Ret_null_
+#define _Ret_opt_
+#define _Ret_opt_bytecap_(size)
+#define _Ret_opt_bytecap_c_(size)
+#define _Ret_opt_bytecap_x_(size)
+#define _Ret_opt_bytecount_(size)
+#define _Ret_opt_bytecount_c_(size)
+#define _Ret_opt_bytecount_x_(size)
+#define _Ret_opt_cap_(size)
+#define _Ret_opt_cap_c_(size)
+#define _Ret_opt_cap_x_(size)
+#define _Ret_opt_count_(size)
+#define _Ret_opt_count_c_(size)
+#define _Ret_opt_count_x_(size)
+#define _Ret_opt_valid_
+#define _Ret_opt_z_
+#define _Ret_opt_z_bytecap_(size)
+#define _Ret_opt_z_bytecount_(size)
+#define _Ret_opt_z_cap_(size)
+#define _Ret_opt_z_count_(size)
+#define _Ret_range_(lb,ub)
+#define _Ret_valid_
+#define _Ret_writes_(size)
+#define _Ret_writes_bytes_(size)
+#define _Ret_writes_bytes_maybenull_(size)
+#define _Ret_writes_bytes_to_(size,count)
+#define _Ret_writes_bytes_to_maybenull_(size,count)
+#define _Ret_writes_maybenull_(size)
+#define _Ret_writes_maybenull_z_(size)
+#define _Ret_writes_to_(size,count)
+#define _Ret_writes_to_maybenull_(size,count)
+#define _Ret_writes_z_(size)
+#define _Ret_z_
+#define _Ret_z_bytecap_(size)
+#define _Ret_z_bytecount_(size)
+#define _Ret_z_cap_(size)
+#define _Ret_z_count_(size)
+#define _Return_type_success_(expr)
+#define _Scanf_format_string_
+#define _Scanf_s_format_string_
+#define _Struct_size_bytes_(size)
+#define _Success_(expr)
+#define _Unchanged_(e)
+#define _Use_decl_annotations_
+#define _Valid_
+#define _When_(expr, annos)
+#define _Writable_bytes_(size)
+#define _Writable_elements_(size)
+#define __inner_callback
+#define __inner_exceptthat
+#define __inner_typefix(ctype)
+
+
+/*
+ * Dummy header annotations.
+ *
+ * These are typically defined in specstrings.h.
+ *
+ * Unfortunately these defines tend to clash with libstdc++ internal symbols.  A solution is to ensure
+ * that all needed libstdc++ headers are included before this one.
+ *
+ * See also:
+ * - http://msdn.microsoft.com/en-us/library/aa383701.aspx
+ * - http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/specstrings.h?view=markup
+ */
+
+#define __deref_out
+#define __deref_out_bcount(x)
+#define __deref_out_opt
+#define __ecount(x)
+#define __field_bcount(x)
+#define __field_ecount(x)
+#define __field_ecount_full(x)
+#define __field_ecount_opt(x)
+#define __in
+#define __in_bcount(x)
+#define __in_bcount_opt(x)
+#define __in_ecount(x)
+#define __in_ecount_opt(x)
+#define __in_opt
+#define __in_range(x,y)
+#define __in_z
+#define __in_z_opt
+#define __inout
+#define __inout_opt
+#define __maybenull
+#define __notnull
+#define __nullterminated
+#define __out
+#define __out_bcount(x)
+#define __out_bcount_full_opt(x)
+#define __out_bcount_opt(x)
+#define __out_ecount(x)
+#define __out_ecount_opt(x)
+#define __out_ecount_part_opt(x,y)
+#define __out_ecount_part_z_opt(x,y)
+#define __out_ecount_z(x)
+#define __out_opt
+#define __out_z
+#define __range(x,y)
+#define __success(x)
+
+
+#ifndef __inline
+#define __inline static __inline__
+#endif
+
+#ifndef DECLSPEC_DEPRECATED
+#define DECLSPEC_DEPRECATED
+#endif
+
+#ifndef DECLSPEC_NOVTABLE
+#define DECLSPEC_NOVTABLE
+#endif
+
+#ifndef __MINGW64_VERSION_MAJOR
+#define INT8 signed char
+#define UINT8 unsigned char
+#define INT16 signed short
+#define UINT16 unsigned short
+#endif
+
+
+#endif /* __MINGW32__ */
+
diff --git a/dispatch/d2dimports.hpp b/dispatch/d2dimports.hpp
new file mode 100644 (file)
index 0000000..4a2594b
--- /dev/null
@@ -0,0 +1,98 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Central place for all D2D/DWRITE includes, and respective OS dependent headers.
+ */
+
+#ifndef _D2DIMPORTS_HPP_
+#define _D2DIMPORTS_HPP_
+
+#include <windows.h>
+#include <tchar.h>
+
+#include "compat.h"
+
+#include <d2d1.h>
+#include <dwrite.h>
+
+DEFINE_GUID(IID_ID2D1Resource,0x2cd90691,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1Bitmap,0xa2296057,0xea42,0x4099,0x98,0x3b,0x53,0x9f,0xb6,0x50,0x54,0x26);
+DEFINE_GUID(IID_ID2D1GradientStopCollection,0x2cd906a7,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1Brush,0x2cd906a8,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1BitmapBrush,0x2cd906aa,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1SolidColorBrush,0x2cd906a9,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1LinearGradientBrush,0x2cd906ab,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1RadialGradientBrush,0x2cd906ac,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1StrokeStyle,0x2cd9069d,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1Geometry,0x2cd906a1,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1RectangleGeometry,0x2cd906a2,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1RoundedRectangleGeometry,0x2cd906a3,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1EllipseGeometry,0x2cd906a4,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1GeometryGroup,0x2cd906a6,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1TransformedGeometry,0x2cd906bb,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1SimplifiedGeometrySink,0x2cd9069e,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1GeometrySink,0x2cd9069f,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1TessellationSink,0x2cd906c1,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1PathGeometry,0x2cd906a5,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1Mesh,0x2cd906c2,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1Layer,0x2cd9069b,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1DrawingStateBlock,0x28506e39,0xebf6,0x46a1,0xbb,0x47,0xfd,0x85,0x56,0x5a,0xb9,0x57);
+DEFINE_GUID(IID_ID2D1RenderTarget,0x2cd90694,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1BitmapRenderTarget,0x2cd90695,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1HwndRenderTarget,0x2cd90698,0x12e2,0x11dc,0x9f,0xed,0x00,0x11,0x43,0xa0,0x55,0xf9);
+DEFINE_GUID(IID_ID2D1GdiInteropRenderTarget,0xe0db51c3,0x6f77,0x4bae,0xb3,0xd5,0xe4,0x75,0x09,0xb3,0x58,0x38);
+DEFINE_GUID(IID_ID2D1DCRenderTarget,0x1c51bc64,0xde61,0x46fd,0x98,0x99,0x63,0xa5,0xd8,0xf0,0x39,0x50);
+DEFINE_GUID(IID_ID2D1Factory,0x06152247,0x6f50,0x465a,0x92,0x45,0x11,0x8b,0xfd,0x3b,0x60,0x07);
+
+DEFINE_GUID(IID_IDWriteFontFileLoader,0x727cad4e,0xd6af,0x4c9e,0x8a,0x08,0xd6,0x95,0xb1,0x1c,0xaa,0x49);
+DEFINE_GUID(IID_IDWriteLocalFontFileLoader,0xb2d9f3ec,0xc9fe,0x4a11,0xa2,0xec,0xd8,0x62,0x08,0xf7,0xc0,0xa2);
+DEFINE_GUID(IID_IDWriteFontFileStream,0x6d4865fe,0x0ab8,0x4d91,0x8f,0x62,0x5d,0xd6,0xbe,0x34,0xa3,0xe0);
+DEFINE_GUID(IID_IDWriteFontFile,0x739d886a,0xcef5,0x47dc,0x87,0x69,0x1a,0x8b,0x41,0xbe,0xbb,0xb0);
+DEFINE_GUID(IID_IDWriteRenderingParams,0x2f0da53a,0x2add,0x47cd,0x82,0xee,0xd9,0xec,0x34,0x68,0x8e,0x75);
+DEFINE_GUID(IID_IDWriteFontFace,0x5f49804d,0x7024,0x4d43,0xbf,0xa9,0xd2,0x59,0x84,0xf5,0x38,0x49);
+DEFINE_GUID(IID_IDWriteFontCollectionLoader,0xcca920e4,0x52f0,0x492b,0xbf,0xa8,0x29,0xc7,0x2e,0xe0,0xa4,0x68);
+DEFINE_GUID(IID_IDWriteFontFileEnumerator,0x72755049,0x5ff7,0x435d,0x83,0x48,0x4b,0xe9,0x7c,0xfa,0x6c,0x7c);
+DEFINE_GUID(IID_IDWriteLocalizedStrings,0x08256209,0x099a,0x4b34,0xb8,0x6d,0xc2,0x2b,0x11,0x0e,0x77,0x71);
+DEFINE_GUID(IID_IDWriteFontCollection,0xa84cee02,0x3eea,0x4eee,0xa8,0x27,0x87,0xc1,0xa0,0x2a,0x0f,0xcc);
+DEFINE_GUID(IID_IDWriteFontList,0x1a0d8438,0x1d97,0x4ec1,0xae,0xf9,0xa2,0xfb,0x86,0xed,0x6a,0xcb);
+DEFINE_GUID(IID_IDWriteFontFamily,0xda20d8ef,0x812a,0x4c43,0x98,0x02,0x62,0xec,0x4a,0xbd,0x7a,0xdd);
+DEFINE_GUID(IID_IDWriteFont,0xacd16696,0x8c14,0x4f5d,0x87,0x7e,0xfe,0x3f,0xc1,0xd3,0x27,0x37);
+DEFINE_GUID(IID_IDWriteTextFormat,0x9c906818,0x31d7,0x4fd3,0xa1,0x51,0x7c,0x5e,0x22,0x5d,0xb5,0x5a);
+DEFINE_GUID(IID_IDWriteTypography,0x55f1112b,0x1dc2,0x4b3c,0x95,0x41,0xf4,0x68,0x94,0xed,0x85,0xb6);
+DEFINE_GUID(IID_IDWriteNumberSubstitution,0x14885CC9,0xBAB0,0x4f90,0xB6,0xED,0x5C,0x36,0x6A,0x2C,0xD0,0x3D);
+DEFINE_GUID(IID_IDWriteTextAnalysisSource,0x688e1a58,0x5094,0x47c8,0xad,0xc8,0xfb,0xce,0xa6,0x0a,0xe9,0x2b);
+DEFINE_GUID(IID_IDWriteTextAnalysisSink,0x5810cd44,0x0ca0,0x4701,0xb3,0xfa,0xbe,0xc5,0x18,0x2a,0xe4,0xf6);
+DEFINE_GUID(IID_IDWriteTextAnalyzer,0xb7e6163e,0x7f46,0x43b4,0x84,0xb3,0xe4,0xe6,0x24,0x9c,0x36,0x5d);
+DEFINE_GUID(IID_IDWriteInlineObject,0x8339FDE3,0x106F,0x47ab,0x83,0x73,0x1C,0x62,0x95,0xEB,0x10,0xB3);
+DEFINE_GUID(IID_IDWritePixelSnapping,0xeaf3a2da,0xecf4,0x4d24,0xb6,0x44,0xb3,0x4f,0x68,0x42,0x02,0x4b);
+DEFINE_GUID(IID_IDWriteTextRenderer,0xef8a8135,0x5cc6,0x45fe,0x88,0x25,0xc5,0xa0,0x72,0x4e,0xb8,0x19);
+DEFINE_GUID(IID_IDWriteTextLayout,0x53737037,0x6d14,0x410b,0x9b,0xfe,0x0b,0x18,0x2b,0xb7,0x09,0x61);
+DEFINE_GUID(IID_IDWriteBitmapRenderTarget,0x5e5a32a3,0x8dff,0x4773,0x9f,0xf6,0x06,0x96,0xea,0xb7,0x72,0x67);
+DEFINE_GUID(IID_IDWriteGdiInterop,0x1edd9491,0x9853,0x4299,0x89,0x8f,0x64,0x32,0x98,0x3b,0x6f,0x3a);
+DEFINE_GUID(IID_IDWriteGlyphRunAnalysis,0x7d97dbf7,0xe085,0x42d4,0x81,0xe3,0x6a,0x88,0x3b,0xde,0xd1,0x18);
+DEFINE_GUID(IID_IDWriteFactory,0xb859ee5a,0xd838,0x4b5b,0xa2,0xe8,0x1a,0xdc,0x7d,0x93,0xdb,0x48);
+
+#endif /* _D2DIMPORTS_HPP_ */
diff --git a/dispatch/d3d10_1imports.hpp b/dispatch/d3d10_1imports.hpp
new file mode 100644 (file)
index 0000000..254323e
--- /dev/null
@@ -0,0 +1,43 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Central place for all D3D10 includes, and respective OS dependent headers.
+ */
+
+#ifndef _D3D10_1IMPORTS_HPP_
+#define _D3D10_1IMPORTS_HPP_
+
+
+#include <windows.h>
+
+#include "compat.h"
+
+#include <d3d10_1.h>
+
+#include "d3derr.hpp"
+
+
+#endif /* _D3D10_1IMPORTS_HPP_ */
diff --git a/dispatch/d3d10imports.hpp b/dispatch/d3d10imports.hpp
new file mode 100644 (file)
index 0000000..d21aec8
--- /dev/null
@@ -0,0 +1,43 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Central place for all D3D10 includes, and respective OS dependent headers.
+ */
+
+#ifndef _D3D10IMPORTS_HPP_
+#define _D3D10IMPORTS_HPP_
+
+
+#include <windows.h>
+
+#include "compat.h"
+
+#include <d3d10.h>
+
+#include "d3derr.hpp"
+
+
+#endif /* _D3D10IMPORTS_HPP_ */
diff --git a/dispatch/d3d11imports.hpp b/dispatch/d3d11imports.hpp
new file mode 100644 (file)
index 0000000..eabcaf1
--- /dev/null
@@ -0,0 +1,43 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Central place for all D3D11 includes, and respective OS dependent headers.
+ */
+
+#ifndef _D3D11IMPORTS_HPP_
+#define _D3D11IMPORTS_HPP_
+
+
+#include <windows.h>
+
+#include "compat.h"
+
+#include <d3d11.h>
+
+#include "d3derr.hpp"
+
+
+#endif /* _D3D11IMPORTS_HPP_ */
diff --git a/dispatch/d3d9imports.hpp b/dispatch/d3d9imports.hpp
new file mode 100644 (file)
index 0000000..1a22a59
--- /dev/null
@@ -0,0 +1,99 @@
+/**************************************************************************
+ *
+ * Copyright 2011 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Central place for all D3D9 includes, and respective OS dependent headers.
+ */
+
+#ifndef _D3D9IMPORTS_HPP_
+#define _D3D9IMPORTS_HPP_
+
+#include <windows.h>
+
+#include "compat.h"
+
+#include <d3d9.h>
+#include <d3dx9.h>
+
+
+#ifndef D3DFMT_A2B10G10R10_XR_BIAS
+#define D3DFMT_A2B10G10R10_XR_BIAS 119
+#endif
+
+#ifndef D3DFMT_ATI1N
+#define D3DFMT_ATI1N ((D3DFORMAT)MAKEFOURCC('A','T','I','1'))
+#endif
+
+#ifndef D3DFMT_ATI2N
+#define D3DFMT_ATI2N ((D3DFORMAT)MAKEFOURCC('A','T','I','2'))
+#endif
+
+#ifndef D3DFMT_AYUV
+#define D3DFMT_AYUV ((D3DFORMAT)MAKEFOURCC('A','Y','U','V'))
+#endif
+
+#ifndef D3DFMT_DF16
+#define D3DFMT_DF16 ((D3DFORMAT)MAKEFOURCC('D','F','1','6'))
+#endif
+
+#ifndef D3DFMT_DF24
+#define D3DFMT_DF24 ((D3DFORMAT)MAKEFOURCC('D','F','2','4'))
+#endif
+
+#ifndef D3DFMT_INTZ
+#define D3DFMT_INTZ ((D3DFORMAT)MAKEFOURCC('I','N','T','Z'))
+#endif
+
+#ifndef D3DFMT_NULL
+#define D3DFMT_NULL ((D3DFORMAT)MAKEFOURCC('N','U','L','L'))
+#endif
+
+#ifndef D3DFMT_NV12
+#define D3DFMT_NV12 ((D3DFORMAT)MAKEFOURCC('N','V','1','2'))
+#endif
+
+#ifndef D3DFMT_RAWZ
+#define D3DFMT_RAWZ ((D3DFORMAT)MAKEFOURCC('R','A','W','Z'))
+#endif
+
+
+#ifndef D3DUSAGE_TEXTAPI
+#define D3DUSAGE_TEXTAPI 0x10000000L
+#endif
+
+#ifndef D3DUSAGE_RESTRICTED_CONTENT
+#define D3DUSAGE_RESTRICTED_CONTENT 0x00000800L
+#endif
+
+#ifndef D3DUSAGE_RESTRICT_SHARED_RESOURCE
+#define D3DUSAGE_RESTRICT_SHARED_RESOURCE 0x00002000L
+#endif
+
+#ifndef D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER
+#define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER 0x00001000L
+#endif
+
+
+#endif /* _D3D9IMPORTS_HPP_ */
diff --git a/dispatch/d3derr.hpp b/dispatch/d3derr.hpp
new file mode 100644 (file)
index 0000000..39a3e9c
--- /dev/null
@@ -0,0 +1,63 @@
+/**************************************************************************
+ *
+ * Copyright 2012 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * D3DERR return codes.
+ *
+ * These were defined in d3dx10.h/d3dx11.h on DirectX SDK, and moved to
+ * winerror.h on Windows 8 SDK.
+ *
+ * See also:
+ * - http://msdn.microsoft.com/en-us/library/windows/desktop/ff476174.aspx
+ * - http://msdn.microsoft.com/en-us/library/windows/desktop/bb205278.aspx
+ * - http://msdn.microsoft.com/en-us/library/windows/desktop/bb172554.aspx
+ */
+
+#ifndef _D3DERR_HPP_
+#define _D3DERR_HPP_
+
+
+#ifndef _FACD3D
+#define _FACD3D  0x876
+#endif
+
+#ifndef MAKE_D3DHRESULT
+#define MAKE_D3DHRESULT(code) MAKE_HRESULT(1, _FACD3D, code)
+#endif
+
+#ifndef MAKE_D3DSTATUS
+#define MAKE_D3DSTATUS(code) MAKE_HRESULT(0, _FACD3D, code)
+#endif
+
+#ifndef D3DERR_INVALIDCALL
+#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156)
+#endif
+
+#ifndef D3DERR_WASSTILLDRAWING
+#define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540)
+#endif
+
+
+#endif /* _D3DERR_HPP_ */
diff --git a/dispatch/dispatch.py b/dispatch/dispatch.py
new file mode 100644 (file)
index 0000000..4580166
--- /dev/null
@@ -0,0 +1,124 @@
+##########################################################################
+#
+# Copyright 2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""Generate DLL/SO dispatching functions.
+""" 
+
+
+# Adjust path
+import os.path
+import sys
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
+
+
+import specs.stdapi as stdapi
+
+
+def function_pointer_type(function):
+    return 'PFN_' + function.name.upper()
+
+
+def function_pointer_value(function):
+    return '_' + function.name + '_ptr'
+
+
+class Dispatcher:
+
+    def header(self):
+        # Must be implemented by derived classes, which should define, declare,
+        # or implement something like:
+        #
+        #  typedef void (*_PROC)(void);
+        #
+        #  static _PROC _getPublicProcAddress(const char *name);
+        #  static _PROC _getPrivateProcAddress(const char *name);
+        #
+        raise NotImplementedError
+
+    def dispatchApi(self, api):
+        for function in api.functions:
+            self.dispatchFunction(api, function)
+        
+        # define standard name aliases for convenience, but only when not
+        # tracing, as that would cause symbol clashing with the tracing
+        # functions
+        print '#ifdef RETRACE'
+        for function in api.functions:
+            print '#define %s _%s' % (function.name, function.name)
+        print '#endif /* RETRACE */'
+        print
+
+    def dispatchFunction(self, api, function):
+        ptype = function_pointer_type(function)
+        pvalue = function_pointer_value(function)
+        print 'typedef ' + function.prototype('* %s' % ptype) + ';'
+        print 'static %s %s = NULL;' % (ptype, pvalue)
+        print
+        print 'static inline ' + function.prototype('_' + function.name) + ' {'
+        print '    const char *_name = "%s";' % function.name
+        if function.type is stdapi.Void:
+            ret = ''
+        else:
+            ret = 'return '
+        self.invokeGetProcAddress(api, function)
+        print '    %s%s(%s);' % (ret, pvalue, ', '.join([str(arg.name) for arg in function.args]))
+        print '}'
+        print
+
+    def isFunctionPublic(self, api, function):
+        return True
+
+    def getProcAddressName(self, api, function):
+        if self.isFunctionPublic(api, function):
+            return '_getPublicProcAddress'
+        else:
+            return '_getPrivateProcAddress'
+
+    def invokeGetProcAddress(self, api, function):
+        ptype = function_pointer_type(function)
+        pvalue = function_pointer_value(function)
+        getProcAddressName = self.getProcAddressName(api, function)
+        print '    if (!%s) {' % (pvalue,)
+        print '        %s = (%s)%s(_name);' % (pvalue, ptype, getProcAddressName)
+        print '        if (!%s) {' % (pvalue,)
+        self.failFunction(function)
+        print '        }'
+        print '    }'
+
+    def failFunction(self, function):
+        if function.type is stdapi.Void or function.fail is not None:
+            print r'            os::log("warning: ignoring call to unavailable function %s\n", _name);'
+            if function.type is stdapi.Void:
+                assert function.fail is None
+                print '            return;' 
+            else:
+                assert function.fail is not None
+                print '            return %s;' % function.fail
+        else:
+            print r'            os::log("error: unavailable function %s\n", _name);'
+            print r'            os::abort();'
+
+
diff --git a/dispatch/eglimports.hpp b/dispatch/eglimports.hpp
new file mode 100644 (file)
index 0000000..7f22e70
--- /dev/null
@@ -0,0 +1,94 @@
+/**************************************************************************
+ *
+ * Copyright 2011 LunarG, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Central place for all EGL and client API includes.  It can be included
+ * directly, or indirectly through glimports.h.
+ */
+
+#ifndef _EGLIMPORTS_HPP_
+#define _EGLIMPORTS_HPP_
+
+
+#include <KHR/khrplatform.h>
+
+#ifdef _GDI32_
+/* Prevent __declspec(dllimport) attribute */
+#undef KHRONOS_APICALL
+#define KHRONOS_APICALL
+#endif
+
+// EGL
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+/* Prevent collision with Trace::Bool */
+#undef Bool
+
+
+// OpenGL ES
+#include <GLES/glplatform.h>
+#include <GLES2/gl2platform.h>
+
+
+// OpenGL ES 1.1
+typedef int32_t  GLfixed;
+typedef int32_t  GLclampx;
+
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_PALETTE4_RGB8_OES                                    0x8B90
+#define GL_PALETTE4_RGBA8_OES                                   0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92
+#define GL_PALETTE4_RGBA4_OES                                   0x8B93
+#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94
+#define GL_PALETTE8_RGB8_OES                                    0x8B95
+#define GL_PALETTE8_RGBA8_OES                                   0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97
+#define GL_PALETTE8_RGBA4_OES                                   0x8B98
+#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99
+#endif
+
+#ifndef GL_OES_point_size_array
+#define GL_POINT_SIZE_ARRAY_OES                                 0x8B9C
+#define GL_POINT_SIZE_ARRAY_TYPE_OES                            0x898A
+#define GL_POINT_SIZE_ARRAY_STRIDE_OES                          0x898B
+#define GL_POINT_SIZE_ARRAY_POINTER_OES                         0x898C
+#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES                  0x8B9F
+#endif
+
+// avoid conflict with GL_EXT_framebuffer_multisample
+#define GL_EXT_multisampled_render_to_texture
+
+#undef _glext_h_
+#include "GLES/glext.h"
+
+
+// OpenGL ES 2.0
+
+// avoid conflicting with GL_NV_multisample_coverage
+#define GL_NV_coverage_sample
+#include "GLES2/gl2ext.h"
+
+
+#endif /* _EGLIMPORTS_HPP_ */
diff --git a/dispatch/glimports.hpp b/dispatch/glimports.hpp
new file mode 100644 (file)
index 0000000..773d50f
--- /dev/null
@@ -0,0 +1,122 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Central place for all GL includes, and respective OS dependent headers.
+ */
+
+#ifndef _GLIMPORTS_HPP_
+#define _GLIMPORTS_HPP_
+
+
+#if defined(_WIN32)
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN 1
+#  endif
+#  include <windows.h>
+#elif defined(__APPLE__)
+#elif defined(HAVE_X11)
+#  include <X11/Xlib.h>
+#endif /* !_WIN32 */
+
+
+#include <GL/gl.h>
+#include <GL/glext.h>
+
+
+// GL_NVX_gpu_memory_info
+#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX          0x9047
+#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX    0x9048
+#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX  0x9049
+#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX            0x904A
+#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX            0x904B
+
+
+#if defined(_WIN32)
+
+#include <GL/wglext.h>
+
+#ifndef PFD_SUPPORT_DIRECTDRAW
+#define PFD_SUPPORT_DIRECTDRAW 0x00002000
+#endif
+#ifndef PFD_SUPPORT_COMPOSITION
+#define PFD_SUPPORT_COMPOSITION 0x00008000
+#endif
+
+#ifndef WGL_SWAPMULTIPLE_MAX
+
+extern "C"
+typedef struct _WGLSWAP
+{
+    HDC hdc;
+    UINT uiFlags;
+} WGLSWAP, *PWGLSWAP, FAR *LPWGLSWAP;
+
+#define WGL_SWAPMULTIPLE_MAX 16
+
+#endif /* !WGL_SWAPMULTIPLE_MAX */
+
+#elif defined(__APPLE__)
+
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/CGLIOSurface.h>
+#include <OpenGL/CGLDevice.h>
+
+#ifndef CGL_VERSION_1_3
+#define kCGLPFAOpenGLProfile 99
+#define kCGLOGLPVersion_Legacy 0x1000
+#define kCGLOGLPVersion_3_2_Core 0x3200
+#endif
+
+extern "C" {
+
+// From http://www.opensource.apple.com/source/gdb/gdb-954/libcheckpoint/cpcg.c
+typedef void * CGSConnectionID;
+typedef int CGSWindowID;
+typedef int CGSSurfaceID;
+
+CGLError CGLSetSurface(CGLContextObj ctx, CGSConnectionID cid, CGSWindowID wid, CGSSurfaceID sid);
+CGLError CGLGetSurface(CGLContextObj ctx, CGSConnectionID* cid, CGSWindowID* wid, CGSSurfaceID* sid);
+CGLError CGLUpdateContext(CGLContextObj ctx);
+
+}
+
+#else
+
+#ifdef HAVE_X11
+#include <GL/glx.h>
+#include <GL/glxext.h>
+#endif
+
+/* Prevent collision with trace::Bool */
+#undef Bool
+
+#endif
+
+
+#include "eglimports.hpp"
+
+
+#endif /* _GLIMPORTS_HPP_ */
diff --git a/dispatch/glproc.py b/dispatch/glproc.py
new file mode 100644 (file)
index 0000000..abf4f00
--- /dev/null
@@ -0,0 +1,544 @@
+##########################################################################
+#
+# Copyright 2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""Generated an header, glproc.hpp, which does pretty much what GLEW does, but
+covers all the functions we support.
+""" 
+
+
+from dispatch import Dispatcher
+import specs.stdapi as stdapi
+from specs.glapi import glapi
+from specs.glxapi import glxapi
+from specs.wglapi import wglapi
+from specs.cglapi import cglapi
+from specs.eglapi import eglapi
+from specs.glesapi import glesapi
+
+
+# See http://www.opengl.org/registry/ABI/
+public_symbols = set([
+    # GL 1.2 and ARB_multitexture
+    "glAccum",
+    "glAlphaFunc",
+    "glAreTexturesResident",
+    "glArrayElement",
+    "glBegin",
+    "glBindTexture",
+    "glBitmap",
+    "glBlendFunc",
+    "glCallList",
+    "glCallLists",
+    "glClear",
+    "glClearAccum",
+    "glClearColor",
+    "glClearDepth",
+    "glClearIndex",
+    "glClearStencil",
+    "glClipPlane",
+    "glColor3b",
+    "glColor3bv",
+    "glColor3d",
+    "glColor3dv",
+    "glColor3f",
+    "glColor3fv",
+    "glColor3i",
+    "glColor3iv",
+    "glColor3s",
+    "glColor3sv",
+    "glColor3ub",
+    "glColor3ubv",
+    "glColor3ui",
+    "glColor3uiv",
+    "glColor3us",
+    "glColor3usv",
+    "glColor4b",
+    "glColor4bv",
+    "glColor4d",
+    "glColor4dv",
+    "glColor4f",
+    "glColor4fv",
+    "glColor4i",
+    "glColor4iv",
+    "glColor4s",
+    "glColor4sv",
+    "glColor4ub",
+    "glColor4ubv",
+    "glColor4ui",
+    "glColor4uiv",
+    "glColor4us",
+    "glColor4usv",
+    "glColorMask",
+    "glColorMaterial",
+    "glColorPointer",
+    "glCopyPixels",
+    "glCopyTexImage1D",
+    "glCopyTexImage2D",
+    "glCopyTexSubImage1D",
+    "glCopyTexSubImage2D",
+    "glCullFace",
+    "glDeleteLists",
+    "glDeleteTextures",
+    "glDepthFunc",
+    "glDepthMask",
+    "glDepthRange",
+    "glDisable",
+    "glDisableClientState",
+    "glDrawArrays",
+    "glDrawBuffer",
+    "glDrawElements",
+    "glDrawPixels",
+    "glEdgeFlag",
+    "glEdgeFlagPointer",
+    "glEdgeFlagv",
+    "glEnable",
+    "glEnableClientState",
+    "glEnd",
+    "glEndList",
+    "glEvalCoord1d",
+    "glEvalCoord1dv",
+    "glEvalCoord1f",
+    "glEvalCoord1fv",
+    "glEvalCoord2d",
+    "glEvalCoord2dv",
+    "glEvalCoord2f",
+    "glEvalCoord2fv",
+    "glEvalMesh1",
+    "glEvalMesh2",
+    "glEvalPoint1",
+    "glEvalPoint2",
+    "glFeedbackBuffer",
+    "glFinish",
+    "glFlush",
+    "glFogf",
+    "glFogfv",
+    "glFogi",
+    "glFogiv",
+    "glFrontFace",
+    "glFrustum",
+    "glGenLists",
+    "glGenTextures",
+    "glGetBooleanv",
+    "glGetClipPlane",
+    "glGetDoublev",
+    "glGetError",
+    "glGetFloatv",
+    "glGetIntegerv",
+    "glGetLightfv",
+    "glGetLightiv",
+    "glGetMapdv",
+    "glGetMapfv",
+    "glGetMapiv",
+    "glGetMaterialfv",
+    "glGetMaterialiv",
+    "glGetPixelMapfv",
+    "glGetPixelMapuiv",
+    "glGetPixelMapusv",
+    "glGetPointerv",
+    "glGetPolygonStipple",
+    "glGetString",
+    "glGetTexEnvfv",
+    "glGetTexEnviv",
+    "glGetTexGendv",
+    "glGetTexGenfv",
+    "glGetTexGeniv",
+    "glGetTexImage",
+    "glGetTexLevelParameterfv",
+    "glGetTexLevelParameteriv",
+    "glGetTexParameterfv",
+    "glGetTexParameteriv",
+    "glHint",
+    "glIndexMask",
+    "glIndexPointer",
+    "glIndexd",
+    "glIndexdv",
+    "glIndexf",
+    "glIndexfv",
+    "glIndexi",
+    "glIndexiv",
+    "glIndexs",
+    "glIndexsv",
+    "glIndexub",
+    "glIndexubv",
+    "glInitNames",
+    "glInterleavedArrays",
+    "glIsEnabled",
+    "glIsList",
+    "glIsTexture",
+    "glLightModelf",
+    "glLightModelfv",
+    "glLightModeli",
+    "glLightModeliv",
+    "glLightf",
+    "glLightfv",
+    "glLighti",
+    "glLightiv",
+    "glLineStipple",
+    "glLineWidth",
+    "glListBase",
+    "glLoadIdentity",
+    "glLoadMatrixd",
+    "glLoadMatrixf",
+    "glLoadName",
+    "glLogicOp",
+    "glMap1d",
+    "glMap1f",
+    "glMap2d",
+    "glMap2f",
+    "glMapGrid1d",
+    "glMapGrid1f",
+    "glMapGrid2d",
+    "glMapGrid2f",
+    "glMaterialf",
+    "glMaterialfv",
+    "glMateriali",
+    "glMaterialiv",
+    "glMatrixMode",
+    "glMultMatrixd",
+    "glMultMatrixf",
+    "glNewList",
+    "glNormal3b",
+    "glNormal3bv",
+    "glNormal3d",
+    "glNormal3dv",
+    "glNormal3f",
+    "glNormal3fv",
+    "glNormal3i",
+    "glNormal3iv",
+    "glNormal3s",
+    "glNormal3sv",
+    "glNormalPointer",
+    "glOrtho",
+    "glPassThrough",
+    "glPixelMapfv",
+    "glPixelMapuiv",
+    "glPixelMapusv",
+    "glPixelStoref",
+    "glPixelStorei",
+    "glPixelTransferf",
+    "glPixelTransferi",
+    "glPixelZoom",
+    "glPointSize",
+    "glPolygonMode",
+    "glPolygonOffset",
+    "glPolygonStipple",
+    "glPopAttrib",
+    "glPopClientAttrib",
+    "glPopMatrix",
+    "glPopName",
+    "glPrioritizeTextures",
+    "glPushAttrib",
+    "glPushClientAttrib",
+    "glPushMatrix",
+    "glPushName",
+    "glRasterPos2d",
+    "glRasterPos2dv",
+    "glRasterPos2f",
+    "glRasterPos2fv",
+    "glRasterPos2i",
+    "glRasterPos2iv",
+    "glRasterPos2s",
+    "glRasterPos2sv",
+    "glRasterPos3d",
+    "glRasterPos3dv",
+    "glRasterPos3f",
+    "glRasterPos3fv",
+    "glRasterPos3i",
+    "glRasterPos3iv",
+    "glRasterPos3s",
+    "glRasterPos3sv",
+    "glRasterPos4d",
+    "glRasterPos4dv",
+    "glRasterPos4f",
+    "glRasterPos4fv",
+    "glRasterPos4i",
+    "glRasterPos4iv",
+    "glRasterPos4s",
+    "glRasterPos4sv",
+    "glReadBuffer",
+    "glReadPixels",
+    "glRectd",
+    "glRectdv",
+    "glRectf",
+    "glRectfv",
+    "glRecti",
+    "glRectiv",
+    "glRects",
+    "glRectsv",
+    "glRenderMode",
+    "glRotated",
+    "glRotatef",
+    "glScaled",
+    "glScalef",
+    "glScissor",
+    "glSelectBuffer",
+    "glShadeModel",
+    "glStencilFunc",
+    "glStencilMask",
+    "glStencilOp",
+    "glTexCoord1d",
+    "glTexCoord1dv",
+    "glTexCoord1f",
+    "glTexCoord1fv",
+    "glTexCoord1i",
+    "glTexCoord1iv",
+    "glTexCoord1s",
+    "glTexCoord1sv",
+    "glTexCoord2d",
+    "glTexCoord2dv",
+    "glTexCoord2f",
+    "glTexCoord2fv",
+    "glTexCoord2i",
+    "glTexCoord2iv",
+    "glTexCoord2s",
+    "glTexCoord2sv",
+    "glTexCoord3d",
+    "glTexCoord3dv",
+    "glTexCoord3f",
+    "glTexCoord3fv",
+    "glTexCoord3i",
+    "glTexCoord3iv",
+    "glTexCoord3s",
+    "glTexCoord3sv",
+    "glTexCoord4d",
+    "glTexCoord4dv",
+    "glTexCoord4f",
+    "glTexCoord4fv",
+    "glTexCoord4i",
+    "glTexCoord4iv",
+    "glTexCoord4s",
+    "glTexCoord4sv",
+    "glTexCoordPointer",
+    "glTexEnvf",
+    "glTexEnvfv",
+    "glTexEnvi",
+    "glTexEnviv",
+    "glTexGend",
+    "glTexGendv",
+    "glTexGenf",
+    "glTexGenfv",
+    "glTexGeni",
+    "glTexGeniv",
+    "glTexImage1D",
+    "glTexImage2D",
+    "glTexParameterf",
+    "glTexParameterfv",
+    "glTexParameteri",
+    "glTexParameteriv",
+    "glTexSubImage1D",
+    "glTexSubImage2D",
+    "glTranslated",
+    "glTranslatef",
+    "glVertex2d",
+    "glVertex2dv",
+    "glVertex2f",
+    "glVertex2fv",
+    "glVertex2i",
+    "glVertex2iv",
+    "glVertex2s",
+    "glVertex2sv",
+    "glVertex3d",
+    "glVertex3dv",
+    "glVertex3f",
+    "glVertex3fv",
+    "glVertex3i",
+    "glVertex3iv",
+    "glVertex3s",
+    "glVertex3sv",
+    "glVertex4d",
+    "glVertex4dv",
+    "glVertex4f",
+    "glVertex4fv",
+    "glVertex4i",
+    "glVertex4iv",
+    "glVertex4s",
+    "glVertex4sv",
+    "glVertexPointer",
+    "glViewport",
+
+    # GLX 1.3 and GLX_ARB_get_proc_address
+    "glXChooseVisual",
+    "glXCreateContext",
+    "glXDestroyContext",
+    "glXMakeCurrent",
+    "glXCopyContext",
+    "glXSwapBuffers",
+    "glXCreateGLXPixmap",
+    "glXDestroyGLXPixmap",
+    "glXQueryExtension",
+    "glXQueryVersion",
+    "glXIsDirect",
+    "glXGetConfig",
+    "glXGetCurrentContext",
+    "glXGetCurrentDrawable",
+    "glXWaitGL",
+    "glXWaitX",
+    "glXUseXFont",
+    "glXQueryExtensionsString",
+    "glXQueryServerString",
+    "glXGetClientString",
+    "glXGetCurrentDisplay",
+    "glXChooseFBConfig",
+    "glXGetFBConfigAttrib",
+    "glXGetFBConfigs",
+    "glXGetVisualFromFBConfig",
+    "glXCreateWindow",
+    "glXDestroyWindow",
+    "glXCreatePixmap",
+    "glXDestroyPixmap",
+    "glXCreatePbuffer",
+    "glXDestroyPbuffer",
+    "glXQueryDrawable",
+    "glXCreateNewContext",
+    "glXMakeContextCurrent",
+    "glXGetCurrentReadDrawable",
+    "glXQueryContext",
+    "glXSelectEvent",
+    "glXGetSelectedEvent",
+    "glXGetProcAddressARB",
+    "glXGetProcAddress",
+    
+    # WGL
+    #"glDebugEntry",
+    "wglChoosePixelFormat",
+    "wglCopyContext",
+    "wglCreateContext",
+    "wglCreateLayerContext",
+    "wglDeleteContext",
+    "wglDescribeLayerPlane",
+    "wglDescribePixelFormat",
+    "wglGetCurrentContext",
+    "wglGetCurrentDC",
+    "wglGetDefaultProcAddress",
+    "wglGetLayerPaletteEntries",
+    "wglGetPixelFormat",
+    "wglGetProcAddress",
+    "wglMakeCurrent",
+    "wglRealizeLayerPalette",
+    "wglSetLayerPaletteEntries",
+    "wglSetPixelFormat",
+    "wglShareLists",
+    "wglSwapBuffers",
+    "wglSwapLayerBuffers",
+    "wglSwapMultipleBuffers",
+    "wglUseFontBitmapsA",
+    "wglUseFontBitmapsW",
+    "wglUseFontOutlinesA",
+    "wglUseFontOutlinesW",
+
+])
+
+# EGL 1.4
+public_symbols.update([
+   "eglBindAPI",
+   "eglBindTexImage",
+   "eglChooseConfig",
+   "eglCopyBuffers",
+   "eglCreateContext",
+   "eglCreatePbufferFromClientBuffer",
+   "eglCreatePbufferSurface",
+   "eglCreatePixmapSurface",
+   "eglCreateWindowSurface",
+   "eglDestroyContext",
+   "eglDestroySurface",
+   "eglGetConfigAttrib",
+   "eglGetConfigs",
+   "eglGetCurrentContext",
+   "eglGetCurrentDisplay",
+   "eglGetCurrentSurface",
+   "eglGetDisplay",
+   "eglGetError",
+   "eglGetProcAddress",
+   "eglInitialize",
+   "eglMakeCurrent",
+   "eglQueryAPI",
+   "eglQueryContext",
+   "eglQueryString",
+   "eglQuerySurface",
+   "eglReleaseTexImage",
+   "eglReleaseThread",
+   "eglSurfaceAttrib",
+   "eglSwapBuffers",
+   "eglSwapInterval",
+   "eglTerminate",
+   "eglWaitClient",
+   "eglWaitGL",
+   "eglWaitNative",
+])
+
+class GlDispatcher(Dispatcher):
+
+    def header(self):
+        print '''
+#if defined(_WIN32)
+extern HMODULE _libGlHandle;
+#else
+extern void * _libGlHandle;
+#endif
+
+void * _getPublicProcAddress(const char *procName);
+void * _getPrivateProcAddress(const char *procName);
+'''
+        
+    def isFunctionPublic(self, api, function):
+        return function.name in public_symbols or function.name.startswith('CGL')
+
+
+if __name__ == '__main__':
+    print
+    print '#ifndef _GLPROC_HPP_'
+    print '#define _GLPROC_HPP_'
+    print 
+    print '#include "glimports.hpp"'
+    print '#include "os.hpp"'
+    print
+    dispatcher = GlDispatcher()
+    print
+    dispatcher.header()
+    print
+    dispatcher.dispatchApi(eglapi)
+    print
+    print '#if defined(_WIN32)'
+    print
+    dispatcher.dispatchApi(wglapi)
+    print
+    print '#elif defined(__APPLE__)'
+    print
+    dispatcher.dispatchApi(cglapi)
+    print
+    print '#elif defined(HAVE_X11)'
+    print
+    dispatcher.dispatchApi(glxapi)
+    print
+    print '#endif'
+    print
+    dispatcher.dispatchApi(glapi)
+    print
+    dispatcher.dispatchApi(glesapi)
+    print
+
+    print '#endif /* !_GLPROC_HPP_ */'
+    print
diff --git a/dispatch/glproc_egl.cpp b/dispatch/glproc_egl.cpp
new file mode 100644 (file)
index 0000000..5f93b14
--- /dev/null
@@ -0,0 +1,151 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "glproc.hpp"
+
+
+#if !defined(_WIN32)
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE // for dladdr
+#endif
+#include <dlfcn.h>
+#endif
+
+
+/*
+ * Handle to the true OpenGL library.
+ * XXX: Not really used yet.
+ */
+#if defined(_WIN32)
+HMODULE _libGlHandle = NULL;
+#else
+void *_libGlHandle = NULL;
+#endif
+
+
+
+#if defined(_WIN32)
+
+#error Unsupported
+
+#elif defined(__APPLE__)
+
+#error Unsupported
+
+#else
+
+/*
+ * Lookup a public EGL/GL/GLES symbol
+ *
+ * The spec states that eglGetProcAddress should only be used for non-core
+ * (extensions) entry-points.  Core entry-points should be taken directly from
+ * the API specific libraries.
+ *
+ * We cannot tell here which API a symbol is meant for here (as some are
+ * exported by many).  So this code assumes that the appropriate shared
+ * libraries have been loaded previously (either dlopened with RTLD_GLOBAL, or
+ * as part of the executable dependencies), and that their symbols available
+ * for quering via dlsym(RTLD_NEXT, ...).
+ */
+void *
+_getPublicProcAddress(const char *procName)
+{
+#if defined(ANDROID)
+    /*
+     * Android does not support LD_PRELOAD.  It is assumed that applications
+     * are explicitely loading egltrace.so.
+     */
+
+    if (procName[0] == 'e' && procName[1] == 'g' && procName[2] == 'l') {
+        static void *libEGL = NULL;
+        if (!libEGL) {
+            libEGL = dlopen("libEGL.so", RTLD_LOCAL | RTLD_LAZY);
+            if (!libEGL) {
+                return NULL;
+            }
+        }
+        return dlsym(libEGL, procName);
+    }
+
+    if (procName[0] == 'g' && procName[1] == 'l') {
+        /* TODO: Use GLESv1/GLESv2 on a per-context basis. */
+        static void *sym = NULL;
+
+        static void *libGLESv2 = NULL;
+        if (!libGLESv2) {
+            libGLESv2 = dlopen("libGLESv2.so", RTLD_LOCAL | RTLD_LAZY);
+        }
+        if (libGLESv2) {
+            sym = dlsym(libGLESv2, procName);
+        }
+        if (sym) {
+            return sym;
+        }
+
+        static void *libGLESv1 = NULL;
+        if (!libGLESv1) {
+            libGLESv1 = dlopen("libGLESv1_CM.so", RTLD_LOCAL | RTLD_LAZY);
+        }
+        if (libGLESv1) {
+            sym = dlsym(libGLESv1, procName);
+        }
+        if (sym) {
+            return sym;
+        }
+    }
+
+    return NULL;
+#else
+    return dlsym(RTLD_NEXT, procName);
+#endif
+}
+
+/*
+ * Lookup a private EGL/GL/GLES symbol
+ *
+ * Private symbols should always be available through eglGetProcAddress, and
+ * they are guaranteed to work with any context bound (regardless of the API).
+ *
+ * However, per issue#57, eglGetProcAddress returns garbage on some
+ * implementations, and the spec states that implementations may choose to also
+ * export extension functions publicly, so we always attempt dlsym before
+ * eglGetProcAddress to mitigate that.
+ */
+void *
+_getPrivateProcAddress(const char *procName)
+{
+    void *proc;
+    proc = _getPublicProcAddress(procName);
+    if (!proc &&
+        ((procName[0] == 'e' && procName[1] == 'g' && procName[2] == 'l') ||
+         (procName[0] == 'g' && procName[1] == 'l'))) {
+        proc = (void *) _eglGetProcAddress(procName);
+    }
+
+    return proc;
+}
+
+#endif
diff --git a/dispatch/glproc_gl.cpp b/dispatch/glproc_gl.cpp
new file mode 100644 (file)
index 0000000..8e1216f
--- /dev/null
@@ -0,0 +1,230 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "glproc.hpp"
+
+
+#if !defined(_WIN32)
+#include <unistd.h> // for symlink
+#include <dlfcn.h>
+#endif
+
+
+/*
+ * Handle to the true OpenGL library.
+ */
+#if defined(_WIN32)
+HMODULE _libGlHandle = NULL;
+#else
+void *_libGlHandle = NULL;
+#endif
+
+
+
+#if defined(_WIN32)
+
+void *
+_getPublicProcAddress(const char *procName)
+{
+    if (!_libGlHandle) {
+        char szDll[MAX_PATH] = {0};
+        
+        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
+            return NULL;
+        }
+        
+        strcat(szDll, "\\\\opengl32.dll");
+        
+        _libGlHandle = LoadLibraryA(szDll);
+        if (!_libGlHandle) {
+            os::log("apitrace: error: couldn't load %s\n", szDll);
+            return NULL;
+        }
+    }
+        
+    return (void *)GetProcAddress(_libGlHandle, procName);
+}
+
+
+void *
+_getPrivateProcAddress(const char *procName) {
+    return (void *)_wglGetProcAddress(procName);
+}
+
+
+#elif defined(__APPLE__)
+
+
+/*
+ * Path to the true OpenGL framework
+ */
+static const char *libgl_filename = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
+
+
+/*
+ * Lookup a libGL symbol
+ */
+void * _libgl_sym(const char *symbol)
+{
+    void *result;
+
+    if (!_libGlHandle) {
+        /* 
+         * Unfortunately we can't just dlopen the true dynamic library because
+         * DYLD_LIBRARY_PATH/DYLD_FRAMEWORK_PATH take precedence, even for
+         * absolute paths.  So we create a temporary symlink, and dlopen that
+         * instead.
+         */
+
+        char temp_filename[] = "/tmp/tmp.XXXXXX";
+
+        if (mktemp(temp_filename) != NULL) {
+            if (symlink(libgl_filename, temp_filename) == 0) {
+                _libGlHandle = dlopen(temp_filename, RTLD_LOCAL | RTLD_NOW | RTLD_FIRST);
+                remove(temp_filename);
+            }
+        }
+
+        if (!_libGlHandle) {
+            os::log("apitrace: error: couldn't load %s\n", libgl_filename);
+            os::abort();
+            return NULL;
+        }
+    }
+
+    result = dlsym(_libGlHandle, symbol);
+
+#if 0
+    if (result && result == dlsym(RTLD_SELF, symbol)) {
+        os::log("apitrace: error: symbol lookup recursion\n");
+        os::abort();
+        return NULL;
+    }
+#endif
+
+    return result;
+}
+
+
+void *
+_getPublicProcAddress(const char *procName)
+{
+    return _libgl_sym(procName);
+}
+
+void *
+_getPrivateProcAddress(const char *procName)
+{
+    return _libgl_sym(procName);
+}
+
+
+#else
+
+
+/*
+ * Invoke the true dlopen() function.
+ */
+static void *
+_dlopen(const char *filename, int flag)
+{
+    typedef void * (*PFNDLOPEN)(const char *, int);
+    static PFNDLOPEN dlopen_ptr = NULL;
+
+    if (!dlopen_ptr) {
+        dlopen_ptr = (PFNDLOPEN)dlsym(RTLD_NEXT, "dlopen");
+        if (!dlopen_ptr) {
+            os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n");
+            return NULL;
+        }
+    }
+
+    return dlopen_ptr(filename, flag);
+}
+
+
+/*
+ * Lookup a libGL symbol
+ */
+void * _libgl_sym(const char *symbol)
+{
+    void *result;
+
+    if (!_libGlHandle) {
+        /*
+         * The app doesn't directly link against libGL.so, nor does it directly
+         * dlopen it.  So we have to load it ourselves.
+         */
+
+        const char * libgl_filename = getenv("TRACE_LIBGL");
+
+        if (!libgl_filename) {
+            /*
+             * Try to use whatever libGL.so the library is linked against.
+             */
+
+            result = dlsym(RTLD_NEXT, symbol);
+            if (result) {
+                _libGlHandle = RTLD_NEXT;
+                return result;
+            }
+
+            libgl_filename = "libGL.so.1";
+        }
+
+        /*
+         * It would have been preferable to use RTLD_LOCAL to ensure that the
+         * application can never access libGL.so symbols directly, but this
+         * won't work, given libGL.so often loads a driver specific SO and
+         * exposes symbols to it.
+         */
+
+        _libGlHandle = _dlopen(libgl_filename, RTLD_GLOBAL | RTLD_LAZY);
+        if (!_libGlHandle) {
+            os::log("apitrace: error: couldn't find libGL.so\n");
+            return NULL;
+        }
+    }
+
+    return dlsym(_libGlHandle, symbol);
+}
+
+
+void *
+_getPublicProcAddress(const char *procName)
+{
+    return _libgl_sym(procName);
+}
+
+void *
+_getPrivateProcAddress(const char *procName)
+{
+    return (void *)_glXGetProcAddressARB((const GLubyte *)procName);
+}
+
+
+#endif 
+
diff --git a/dlltrace.py b/dlltrace.py
deleted file mode 100644 (file)
index 647b238..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-"""Trace code generation for Windows DLLs."""
-
-
-from dispatch import Dispatcher
-from trace import Tracer
-
-
-class DllTracer(Tracer):
-
-    def __init__(self, dllname):
-        self.dllname = dllname
-    
-    def header(self, api):
-        print '''
-static HINSTANCE g_hDll = NULL;
-
-static PROC
-__getPublicProcAddress(LPCSTR lpProcName)
-{
-    if (!g_hDll) {
-        char szDll[MAX_PATH] = {0};
-        
-        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
-            return NULL;
-        }
-        
-        strcat(szDll, "\\\\%s");
-        
-        g_hDll = LoadLibraryA(szDll);
-        if (!g_hDll) {
-            return NULL;
-        }
-    }
-        
-    return GetProcAddress(g_hDll, lpProcName);
-}
-
-''' % self.dllname
-
-        dispatcher = Dispatcher()
-        dispatcher.dispatch_api(api)
-
-        Tracer.header(self, api)
-
diff --git a/dwritetrace.py b/dwritetrace.py
deleted file mode 100644 (file)
index f480433..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-from dlltrace import DllTracer
-from specs.dwrite import dwrite
-from specs.d2d1 import d2d1 # cyclic dependency
-
-
-class DWriteTracer(DllTracer):
-
-    def wrapArg(self, function, arg):
-        if function.name == 'DWriteCreateFactory' and arg.output:
-            print '    if (*%s) {' % arg.name
-            for iface in dwrite.interfaces:
-                print '        if (iid == IID_%s) {' % iface.name
-                print '            *%s = new Wrap%s(static_cast<%s *>(*%s));' % (arg.name, iface.name, iface.name, arg.name)
-                print '        }'
-            print '    }'
-        else:
-            DllTracer.wrapArg(self, function, arg)
-
-
-if __name__ == '__main__':
-    print '#define INITGUID'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    print '#define DWRITE_EXPORT WINAPI'
-    print
-    print '#include "d2dimports.hpp"'
-    print
-
-    tracer = DWriteTracer('dwrite.dll')
-    tracer.trace_api(dwrite)
diff --git a/eglimports.hpp b/eglimports.hpp
deleted file mode 100644 (file)
index ece78cf..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 LunarG, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Central place for all EGL and client API includes.  It can be included
- * directly, or indirectly through glimports.h.
- */
-
-#ifndef _EGLIMPORTS_HPP_
-#define _EGLIMPORTS_HPP_
-
-
-// OpenGL
-#ifndef __gl_h_
-
-// Prevent including system's glext.h
-#define __glext_h_
-
-#include <GL/gl.h>
-
-// Include our own glext.h
-#undef __glext_h_
-#include "glext/glext.h"
-
-#ifndef GL_TEXTURE_INDEX_SIZE_EXT
-#define GL_TEXTURE_INDEX_SIZE_EXT         0x80ED
-#endif
-
-#endif /* __gl_h_ */
-
-
-#ifdef HAVE_EGL
-
-// EGL
-#include "EGL/egl.h"
-#include "EGL/eglext.h"
-/* Prevent collision with Trace::Bool */
-#undef Bool
-
-
-// OpenGL ES
-#include <GLES/glplatform.h>
-#include <GLES2/gl2platform.h>
-
-#else // HAVE_EGL
-
-// We always include GLES headers below to have the types and enums defined.
-// For that to work without GLES platform headers, we need to define GL_API,
-// GL_APICALL, and GL_APIENTRY.  It does not matter what they are defined to.
-// When we hit here, EGL/GLES support is disabled and all we need from the
-// headers are the types and enums.
-
-#ifndef GL_API
-#define GL_API GLAPI
-#endif
-
-#ifndef GL_APICALL
-#define GL_APICALL GLAPI
-#endif
-
-#ifndef GL_APIENTRY
-#define GL_APIENTRY APIENTRY
-#endif
-
-#endif //! HAVE_EGL
-
-
-// OpenGL ES 1.1
-typedef int32_t  GLfixed;
-typedef int32_t  GLclampx;
-
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_PALETTE4_RGB8_OES                                    0x8B90
-#define GL_PALETTE4_RGBA8_OES                                   0x8B91
-#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92
-#define GL_PALETTE4_RGBA4_OES                                   0x8B93
-#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94
-#define GL_PALETTE8_RGB8_OES                                    0x8B95
-#define GL_PALETTE8_RGBA8_OES                                   0x8B96
-#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97
-#define GL_PALETTE8_RGBA4_OES                                   0x8B98
-#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99
-#endif
-
-#ifndef GL_OES_point_size_array
-#define GL_POINT_SIZE_ARRAY_OES                                 0x8B9C
-#define GL_POINT_SIZE_ARRAY_TYPE_OES                            0x898A
-#define GL_POINT_SIZE_ARRAY_STRIDE_OES                          0x898B
-#define GL_POINT_SIZE_ARRAY_POINTER_OES                         0x898C
-#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES                  0x8B9F
-#endif
-
-#undef __glext_h_
-#include "GLES/glext.h"
-
-
-// OpenGL ES 2.0
-
-// avoid conflicting with GL_NV_multisample_coverage
-#define GL_NV_coverage_sample
-#include "GLES2/gl2ext.h"
-
-
-#endif /* _EGLIMPORTS_HPP_ */
diff --git a/egltrace.py b/egltrace.py
deleted file mode 100644 (file)
index e16367a..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-##########################################################################
-#
-# Copyright 2011 LunarG, Inc.
-# All Rights Reserved.
-#
-# Based on glxtrace.py, which has
-#
-#   Copyright 2011 Jose Fonseca
-#   Copyright 2008-2010 VMware, Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""EGL tracing generator."""
-
-
-from specs.stdapi import API
-from specs.glapi import glapi
-from specs.eglapi import eglapi
-from specs.glesapi import glesapi
-from gltrace import GlTracer
-from dispatch import function_pointer_type, function_pointer_value
-
-
-class EglTracer(GlTracer):
-
-    def isFunctionPublic(self, function):
-        # The symbols visible in libEGL.so can vary, so expose them all
-        return True
-
-    def traceFunctionImplBody(self, function):
-        GlTracer.traceFunctionImplBody(self, function)
-
-        if function.name == 'eglMakeCurrent':
-            print '    // update the profile'
-            print '    if (ctx != EGL_NO_CONTEXT) {'
-            print '        EGLint api = EGL_OPENGL_ES_API, version = 1;'
-            print '        tracer_context *tr = __get_context();'
-            print '        __eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);'
-            print '        __eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &version);'
-            print '        if (api == EGL_OPENGL_API)'
-            print '            tr->profile = PROFILE_COMPAT;'
-            print '        else if (version == 1)'
-            print '            tr->profile = PROFILE_ES1;'
-            print '        else'
-            print '            tr->profile = PROFILE_ES2;'
-            print '    }'
-
-    def wrapRet(self, function, instance):
-        GlTracer.wrapRet(self, function, instance)
-
-        if function.name == "eglGetProcAddress":
-            print '    %s = __unwrap_proc_addr(procname, %s);' % (instance, instance)
-
-
-if __name__ == '__main__':
-    print '#include <stdlib.h>'
-    print '#include <string.h>'
-    print '#include <dlfcn.h>'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print
-    print '// To validate our prototypes'
-    print '#define GL_GLEXT_PROTOTYPES'
-    print '#define EGL_EGLEXT_PROTOTYPES'
-    print
-    print '#include "glproc.hpp"'
-    print '#include "glsize.hpp"'
-    print
-    print 'static __eglMustCastToProperFunctionPointerType __unwrap_proc_addr(const char * procname, __eglMustCastToProperFunctionPointerType procPtr);'
-    print
-
-    api = API()
-    api.addApi(eglapi)
-    api.addApi(glapi)
-    api.addApi(glesapi)
-    tracer = EglTracer()
-    tracer.trace_api(api)
-
-    print 'static __eglMustCastToProperFunctionPointerType __unwrap_proc_addr(const char * procname, __eglMustCastToProperFunctionPointerType procPtr) {'
-    print '    if (!procPtr) {'
-    print '        return procPtr;'
-    print '    }'
-    for f in api.functions:
-        ptype = function_pointer_type(f)
-        pvalue = function_pointer_value(f)
-        print '    if (!strcmp("%s", procname)) {' % f.name
-        print '        %s = (%s)procPtr;' % (pvalue, ptype)
-        print '        return (__eglMustCastToProperFunctionPointerType)&%s;' % (f.name,)
-        print '    }'
-    print '    os::log("apitrace: warning: unknown function \\"%s\\"\\n", procname);'
-    print '    return procPtr;'
-    print '}'
-    print
-    print r'''
-
-
-/*
- * Invoke the true dlopen() function.
- */
-static void *__dlopen(const char *filename, int flag)
-{
-    typedef void * (*PFNDLOPEN)(const char *, int);
-    static PFNDLOPEN dlopen_ptr = NULL;
-
-    if (!dlopen_ptr) {
-        dlopen_ptr = (PFNDLOPEN)dlsym(RTLD_NEXT, "dlopen");
-        if (!dlopen_ptr) {
-            os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n");
-            return NULL;
-        }
-    }
-
-    return dlopen_ptr(filename, flag);
-}
-
-
-/*
- * Several applications, such as Quake3, use dlopen("libGL.so.1"), but
- * LD_PRELOAD does not intercept symbols obtained via dlopen/dlsym, therefore
- * we need to intercept the dlopen() call here, and redirect to our wrapper
- * shared object.
- */
-extern "C" PUBLIC
-void * dlopen(const char *filename, int flag)
-{
-    bool intercept = false;
-
-    if (filename) {
-        intercept =
-            strcmp(filename, "libEGL.so") == 0 ||
-            strcmp(filename, "libEGL.so.1") == 0 ||
-            strcmp(filename, "libGLESv1_CM.so") == 0 ||
-            strcmp(filename, "libGLESv1_CM.so.1") == 0 ||
-            strcmp(filename, "libGLESv2.so") == 0 ||
-            strcmp(filename, "libGLESv2.so.2") == 0 ||
-            strcmp(filename, "libGL.so") == 0 ||
-            strcmp(filename, "libGL.so.1") == 0;
-
-        if (intercept) {
-            os::log("apitrace: redirecting dlopen(\"%s\", 0x%x)\n", filename, flag);
-
-            /* The current dispatch implementation relies on core entry-points to be globally available, so force this.
-             *
-             * TODO: A better approach would be note down the entry points here and
-             * use them latter. Another alternative would be to reopen the library
-             * with RTLD_NOLOAD | RTLD_GLOBAL.
-             */
-            flag &= ~RTLD_LOCAL;
-            flag |= RTLD_GLOBAL;
-        }
-    }
-
-    void *handle = __dlopen(filename, flag);
-
-    if (intercept) {
-        // Get the file path for our shared object, and use it instead
-        static int dummy = 0xdeedbeef;
-        Dl_info info;
-        if (dladdr(&dummy, &info)) {
-            handle = __dlopen(info.dli_fname, flag);
-        } else {
-            os::log("apitrace: warning: dladdr() failed\n");
-        }
-    }
-
-    return handle;
-}
-
-
-
-'''
diff --git a/glcaps.cpp b/glcaps.cpp
deleted file mode 100644 (file)
index 2f16b63..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/*
- * Manipulation of GL extensions.
- *
- * So far we insert GREMEDY extensions, but in the future we could also clamp
- * the GL extensions to core GL versions here.
- */
-
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <string>
-#include <map>
-
-#include "glproc.hpp"
-#include "gltrace.hpp"
-
-
-namespace gltrace {
-
-
-typedef std::map<std::string, const char *> ExtensionsMap;
-
-// Cache of the translated extensions strings
-static ExtensionsMap extensionsMap;
-
-
-// Additional extensions to be advertised
-static const char *extra_extensions[] = {
-    "GL_GREMEDY_string_marker",
-    "GL_GREMEDY_frame_terminator",
-};
-#define NUM_EXTRA_EXTENSIONS (sizeof(extra_extensions)/sizeof(extra_extensions[0]))
-
-
-/**
- * Translate the GL extensions string, adding new extensions.
- */
-static const char *
-overrideExtensionsString(const char *extensions)
-{
-    size_t i;
-
-    ExtensionsMap::const_iterator it = extensionsMap.find(extensions);
-    if (it != extensionsMap.end()) {
-        return it->second;
-    }
-
-    size_t extensions_len = strlen(extensions);
-
-    size_t extra_extensions_len = 0;
-    for (i = 0; i < NUM_EXTRA_EXTENSIONS; ++i) {
-        const char * extra_extension = extra_extensions[i];
-        size_t extra_extension_len = strlen(extra_extension);
-        extra_extensions_len += extra_extension_len + 1;
-    }
-
-    // We use malloc memory instead of a std::string because we need to ensure
-    // that extensions strings will not move in memory as the extensionsMap is
-    // updated.
-    size_t new_extensions_len = extensions_len + 1 + extra_extensions_len + 1;
-    char *new_extensions = (char *)malloc(new_extensions_len);
-    if (!new_extensions) {
-        return extensions;
-    }
-
-    if (extensions_len) {
-        memcpy(new_extensions, extensions, extensions_len);
-
-        // Add space separator if necessary
-        if (new_extensions[extensions_len - 1] != ' ') {
-            new_extensions[extensions_len++] = ' ';
-        }
-    }
-
-    for (i = 0; i < NUM_EXTRA_EXTENSIONS; ++i) {
-        const char * extra_extension = extra_extensions[i];
-        size_t extra_extension_len = strlen(extra_extension);
-        memcpy(new_extensions + extensions_len, extra_extension, extra_extension_len);
-        extensions_len += extra_extension_len;
-        new_extensions[extensions_len++] = ' ';
-    }
-    new_extensions[extensions_len++] = '\0';
-    assert(extensions_len <= new_extensions_len);
-
-    extensionsMap[extensions] = new_extensions;
-
-    return new_extensions;
-}
-
-
-const GLubyte *
-__glGetString_override(GLenum name)
-{
-    const GLubyte *result = __glGetString(name);
-
-    if (result) {
-        switch (name) {
-        case GL_EXTENSIONS:
-            result = (const GLubyte *)overrideExtensionsString((const char *)result);
-            break;
-        default:
-            break;
-        }
-    }
-
-    return result;
-}
-
-
-void
-__glGetIntegerv_override(GLenum pname, GLint *params)
-{
-    __glGetIntegerv(pname, params);
-
-    if (params) {
-        switch (pname) {
-        case GL_NUM_EXTENSIONS:
-            *params += NUM_EXTRA_EXTENSIONS;
-            break;
-        default:
-            break;
-        }
-    }
-}
-
-
-const GLubyte *
-__glGetStringi_override(GLenum name, GLuint index)
-{
-    switch (name) {
-    case GL_EXTENSIONS:
-        {
-            GLint num_extensions = 0;
-            __glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
-            if ((GLuint)num_extensions <= index && index < (GLuint)num_extensions + NUM_EXTRA_EXTENSIONS) {
-                return (const GLubyte *)extra_extensions[index - (GLuint)num_extensions];
-            }
-        }
-        break;
-    default:
-        break;
-    }
-
-    return __glGetStringi(name, index);
-}
-
-
-} /* namespace gltrace */
-
diff --git a/glimports.hpp b/glimports.hpp
deleted file mode 100644 (file)
index 9d60c82..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Central place for all GL includes, and respective OS dependent headers.
- */
-
-#ifndef _GLIMPORTS_HPP_
-#define _GLIMPORTS_HPP_
-
-
-// Prevent including MacOSX's glext.h which lives in OpenGL/glext.h and not
-// GL/glext.h
-#define __glext_h_
-
-
-// Some functions take GLenum disguised as GLint.  Apple noticed and fixed it
-// in the Mac OS X 10.6.x gl.h headers.  Regardless, C++ typechecking rules
-// force the wrappers to match the prototype precisely.
-#if defined(__APPLE__)
-#  include <AvailabilityMacros.h> // for MAC_OS_X_VERSION_10_7
-#  if defined(MAC_OS_X_VERSION_10_7)
-#    define GLenum_int GLint
-#  else
-#    define GLenum_int GLenum
-#  endif
-#else
-#  define GLenum_int GLint
-#endif
-
-
-#if defined(_WIN32)
-
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif
-
-#include <windows.h>
-#include <GL/gl.h>
-
-#elif defined(__APPLE__)
-
-#include <OpenGL/gl.h>
-
-#else
-
-#ifdef HAVE_X11
-#include <X11/Xlib.h>
-#endif
-
-#include <GL/gl.h>
-
-#endif /* !_WIN32 */
-
-
-// Include our own glext.h
-#undef __glext_h_
-#include <GL/glext.h>
-
-
-#ifndef GL_TEXTURE_INDEX_SIZE_EXT
-#define GL_TEXTURE_INDEX_SIZE_EXT         0x80ED
-#endif
-
-// GL_NVX_gpu_memory_info
-#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX          0x9047
-#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX    0x9048
-#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX  0x9049
-#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX            0x904A
-#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX            0x904B
-
-
-#if defined(_WIN32)
-
-#include <GL/wglext.h>
-
-#define GLAPIENTRY __stdcall
-
-#ifndef PFD_SUPPORT_DIRECTDRAW
-#define PFD_SUPPORT_DIRECTDRAW 0x00002000
-#endif
-#ifndef PFD_SUPPORT_COMPOSITION
-#define PFD_SUPPORT_COMPOSITION 0x00008000
-#endif
-
-#ifndef WGL_SWAPMULTIPLE_MAX
-
-extern "C"
-typedef struct _WGLSWAP
-{
-    HDC hdc;
-    UINT uiFlags;
-} WGLSWAP, *PWGLSWAP, FAR *LPWGLSWAP;
-
-#define WGL_SWAPMULTIPLE_MAX 16
-
-#endif /* !WGL_SWAPMULTIPLE_MAX */
-
-#elif defined(__APPLE__)
-
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/CGLIOSurface.h>
-#include <OpenGL/CGLDevice.h>
-
-#ifndef CGL_VERSION_1_3
-#define kCGLPFAOpenGLProfile 99
-#define kCGLOGLPVersion_Legacy 0x1000
-#define kCGLOGLPVersion_3_2_Core 0x3200
-#endif
-
-extern "C" {
-
-// From http://www.opensource.apple.com/source/gdb/gdb-954/libcheckpoint/cpcg.c
-typedef void * CGSConnectionID;
-typedef int CGSWindowID;
-typedef int CGSSurfaceID;
-
-CGLError CGLSetSurface(CGLContextObj ctx, CGSConnectionID cid, CGSWindowID wid, CGSSurfaceID sid);
-CGLError CGLGetSurface(CGLContextObj ctx, CGSConnectionID* cid, CGSWindowID* wid, CGSSurfaceID* sid);
-CGLError CGLUpdateContext(CGLContextObj ctx);
-
-}
-
-#else
-
-#ifdef HAVE_X11
-#include <GL/glx.h>
-#include <GL/glxext.h>
-#endif
-
-/* Prevent collision with trace::Bool */
-#undef Bool
-
-#endif
-
-
-#include "eglimports.hpp"
-
-
-#endif /* _GLIMPORTS_HPP_ */
diff --git a/glproc.py b/glproc.py
deleted file mode 100644 (file)
index 95ab80f..0000000
--- a/glproc.py
+++ /dev/null
@@ -1,540 +0,0 @@
-##########################################################################
-#
-# Copyright 2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""Generated an header, glproc.hpp, which does pretty much what GLEW does, but
-covers all the functions we support.
-""" 
-
-
-import specs.stdapi as stdapi
-from dispatch import Dispatcher
-from specs.glapi import glapi
-from specs.glxapi import glxapi
-from specs.wglapi import wglapi
-from specs.cglapi import cglapi
-from specs.eglapi import eglapi
-from specs.glesapi import glesapi
-
-
-# See http://www.opengl.org/registry/ABI/
-public_symbols = set([
-    # GL 1.2 and ARB_multitexture
-    "glAccum",
-    "glAlphaFunc",
-    "glAreTexturesResident",
-    "glArrayElement",
-    "glBegin",
-    "glBindTexture",
-    "glBitmap",
-    "glBlendFunc",
-    "glCallList",
-    "glCallLists",
-    "glClear",
-    "glClearAccum",
-    "glClearColor",
-    "glClearDepth",
-    "glClearIndex",
-    "glClearStencil",
-    "glClipPlane",
-    "glColor3b",
-    "glColor3bv",
-    "glColor3d",
-    "glColor3dv",
-    "glColor3f",
-    "glColor3fv",
-    "glColor3i",
-    "glColor3iv",
-    "glColor3s",
-    "glColor3sv",
-    "glColor3ub",
-    "glColor3ubv",
-    "glColor3ui",
-    "glColor3uiv",
-    "glColor3us",
-    "glColor3usv",
-    "glColor4b",
-    "glColor4bv",
-    "glColor4d",
-    "glColor4dv",
-    "glColor4f",
-    "glColor4fv",
-    "glColor4i",
-    "glColor4iv",
-    "glColor4s",
-    "glColor4sv",
-    "glColor4ub",
-    "glColor4ubv",
-    "glColor4ui",
-    "glColor4uiv",
-    "glColor4us",
-    "glColor4usv",
-    "glColorMask",
-    "glColorMaterial",
-    "glColorPointer",
-    "glCopyPixels",
-    "glCopyTexImage1D",
-    "glCopyTexImage2D",
-    "glCopyTexSubImage1D",
-    "glCopyTexSubImage2D",
-    "glCullFace",
-    "glDeleteLists",
-    "glDeleteTextures",
-    "glDepthFunc",
-    "glDepthMask",
-    "glDepthRange",
-    "glDisable",
-    "glDisableClientState",
-    "glDrawArrays",
-    "glDrawBuffer",
-    "glDrawElements",
-    "glDrawPixels",
-    "glEdgeFlag",
-    "glEdgeFlagPointer",
-    "glEdgeFlagv",
-    "glEnable",
-    "glEnableClientState",
-    "glEnd",
-    "glEndList",
-    "glEvalCoord1d",
-    "glEvalCoord1dv",
-    "glEvalCoord1f",
-    "glEvalCoord1fv",
-    "glEvalCoord2d",
-    "glEvalCoord2dv",
-    "glEvalCoord2f",
-    "glEvalCoord2fv",
-    "glEvalMesh1",
-    "glEvalMesh2",
-    "glEvalPoint1",
-    "glEvalPoint2",
-    "glFeedbackBuffer",
-    "glFinish",
-    "glFlush",
-    "glFogf",
-    "glFogfv",
-    "glFogi",
-    "glFogiv",
-    "glFrontFace",
-    "glFrustum",
-    "glGenLists",
-    "glGenTextures",
-    "glGetBooleanv",
-    "glGetClipPlane",
-    "glGetDoublev",
-    "glGetError",
-    "glGetFloatv",
-    "glGetIntegerv",
-    "glGetLightfv",
-    "glGetLightiv",
-    "glGetMapdv",
-    "glGetMapfv",
-    "glGetMapiv",
-    "glGetMaterialfv",
-    "glGetMaterialiv",
-    "glGetPixelMapfv",
-    "glGetPixelMapuiv",
-    "glGetPixelMapusv",
-    "glGetPointerv",
-    "glGetPolygonStipple",
-    "glGetString",
-    "glGetTexEnvfv",
-    "glGetTexEnviv",
-    "glGetTexGendv",
-    "glGetTexGenfv",
-    "glGetTexGeniv",
-    "glGetTexImage",
-    "glGetTexLevelParameterfv",
-    "glGetTexLevelParameteriv",
-    "glGetTexParameterfv",
-    "glGetTexParameteriv",
-    "glHint",
-    "glIndexMask",
-    "glIndexPointer",
-    "glIndexd",
-    "glIndexdv",
-    "glIndexf",
-    "glIndexfv",
-    "glIndexi",
-    "glIndexiv",
-    "glIndexs",
-    "glIndexsv",
-    "glIndexub",
-    "glIndexubv",
-    "glInitNames",
-    "glInterleavedArrays",
-    "glIsEnabled",
-    "glIsList",
-    "glIsTexture",
-    "glLightModelf",
-    "glLightModelfv",
-    "glLightModeli",
-    "glLightModeliv",
-    "glLightf",
-    "glLightfv",
-    "glLighti",
-    "glLightiv",
-    "glLineStipple",
-    "glLineWidth",
-    "glListBase",
-    "glLoadIdentity",
-    "glLoadMatrixd",
-    "glLoadMatrixf",
-    "glLoadName",
-    "glLogicOp",
-    "glMap1d",
-    "glMap1f",
-    "glMap2d",
-    "glMap2f",
-    "glMapGrid1d",
-    "glMapGrid1f",
-    "glMapGrid2d",
-    "glMapGrid2f",
-    "glMaterialf",
-    "glMaterialfv",
-    "glMateriali",
-    "glMaterialiv",
-    "glMatrixMode",
-    "glMultMatrixd",
-    "glMultMatrixf",
-    "glNewList",
-    "glNormal3b",
-    "glNormal3bv",
-    "glNormal3d",
-    "glNormal3dv",
-    "glNormal3f",
-    "glNormal3fv",
-    "glNormal3i",
-    "glNormal3iv",
-    "glNormal3s",
-    "glNormal3sv",
-    "glNormalPointer",
-    "glOrtho",
-    "glPassThrough",
-    "glPixelMapfv",
-    "glPixelMapuiv",
-    "glPixelMapusv",
-    "glPixelStoref",
-    "glPixelStorei",
-    "glPixelTransferf",
-    "glPixelTransferi",
-    "glPixelZoom",
-    "glPointSize",
-    "glPolygonMode",
-    "glPolygonOffset",
-    "glPolygonStipple",
-    "glPopAttrib",
-    "glPopClientAttrib",
-    "glPopMatrix",
-    "glPopName",
-    "glPrioritizeTextures",
-    "glPushAttrib",
-    "glPushClientAttrib",
-    "glPushMatrix",
-    "glPushName",
-    "glRasterPos2d",
-    "glRasterPos2dv",
-    "glRasterPos2f",
-    "glRasterPos2fv",
-    "glRasterPos2i",
-    "glRasterPos2iv",
-    "glRasterPos2s",
-    "glRasterPos2sv",
-    "glRasterPos3d",
-    "glRasterPos3dv",
-    "glRasterPos3f",
-    "glRasterPos3fv",
-    "glRasterPos3i",
-    "glRasterPos3iv",
-    "glRasterPos3s",
-    "glRasterPos3sv",
-    "glRasterPos4d",
-    "glRasterPos4dv",
-    "glRasterPos4f",
-    "glRasterPos4fv",
-    "glRasterPos4i",
-    "glRasterPos4iv",
-    "glRasterPos4s",
-    "glRasterPos4sv",
-    "glReadBuffer",
-    "glReadPixels",
-    "glRectd",
-    "glRectdv",
-    "glRectf",
-    "glRectfv",
-    "glRecti",
-    "glRectiv",
-    "glRects",
-    "glRectsv",
-    "glRenderMode",
-    "glRotated",
-    "glRotatef",
-    "glScaled",
-    "glScalef",
-    "glScissor",
-    "glSelectBuffer",
-    "glShadeModel",
-    "glStencilFunc",
-    "glStencilMask",
-    "glStencilOp",
-    "glTexCoord1d",
-    "glTexCoord1dv",
-    "glTexCoord1f",
-    "glTexCoord1fv",
-    "glTexCoord1i",
-    "glTexCoord1iv",
-    "glTexCoord1s",
-    "glTexCoord1sv",
-    "glTexCoord2d",
-    "glTexCoord2dv",
-    "glTexCoord2f",
-    "glTexCoord2fv",
-    "glTexCoord2i",
-    "glTexCoord2iv",
-    "glTexCoord2s",
-    "glTexCoord2sv",
-    "glTexCoord3d",
-    "glTexCoord3dv",
-    "glTexCoord3f",
-    "glTexCoord3fv",
-    "glTexCoord3i",
-    "glTexCoord3iv",
-    "glTexCoord3s",
-    "glTexCoord3sv",
-    "glTexCoord4d",
-    "glTexCoord4dv",
-    "glTexCoord4f",
-    "glTexCoord4fv",
-    "glTexCoord4i",
-    "glTexCoord4iv",
-    "glTexCoord4s",
-    "glTexCoord4sv",
-    "glTexCoordPointer",
-    "glTexEnvf",
-    "glTexEnvfv",
-    "glTexEnvi",
-    "glTexEnviv",
-    "glTexGend",
-    "glTexGendv",
-    "glTexGenf",
-    "glTexGenfv",
-    "glTexGeni",
-    "glTexGeniv",
-    "glTexImage1D",
-    "glTexImage2D",
-    "glTexParameterf",
-    "glTexParameterfv",
-    "glTexParameteri",
-    "glTexParameteriv",
-    "glTexSubImage1D",
-    "glTexSubImage2D",
-    "glTranslated",
-    "glTranslatef",
-    "glVertex2d",
-    "glVertex2dv",
-    "glVertex2f",
-    "glVertex2fv",
-    "glVertex2i",
-    "glVertex2iv",
-    "glVertex2s",
-    "glVertex2sv",
-    "glVertex3d",
-    "glVertex3dv",
-    "glVertex3f",
-    "glVertex3fv",
-    "glVertex3i",
-    "glVertex3iv",
-    "glVertex3s",
-    "glVertex3sv",
-    "glVertex4d",
-    "glVertex4dv",
-    "glVertex4f",
-    "glVertex4fv",
-    "glVertex4i",
-    "glVertex4iv",
-    "glVertex4s",
-    "glVertex4sv",
-    "glVertexPointer",
-    "glViewport",
-
-    # GLX 1.3 and GLX_ARB_get_proc_address
-    "glXChooseVisual",
-    "glXCreateContext",
-    "glXDestroyContext",
-    "glXMakeCurrent",
-    "glXCopyContext",
-    "glXSwapBuffers",
-    "glXCreateGLXPixmap",
-    "glXDestroyGLXPixmap",
-    "glXQueryExtension",
-    "glXQueryVersion",
-    "glXIsDirect",
-    "glXGetConfig",
-    "glXGetCurrentContext",
-    "glXGetCurrentDrawable",
-    "glXWaitGL",
-    "glXWaitX",
-    "glXUseXFont",
-    "glXQueryExtensionsString",
-    "glXQueryServerString",
-    "glXGetClientString",
-    "glXGetCurrentDisplay",
-    "glXChooseFBConfig",
-    "glXGetFBConfigAttrib",
-    "glXGetFBConfigs",
-    "glXGetVisualFromFBConfig",
-    "glXCreateWindow",
-    "glXDestroyWindow",
-    "glXCreatePixmap",
-    "glXDestroyPixmap",
-    "glXCreatePbuffer",
-    "glXDestroyPbuffer",
-    "glXQueryDrawable",
-    "glXCreateNewContext",
-    "glXMakeContextCurrent",
-    "glXGetCurrentReadDrawable",
-    "glXQueryContext",
-    "glXSelectEvent",
-    "glXGetSelectedEvent",
-    "glXGetProcAddressARB",
-    "glXGetProcAddress",
-    
-    # WGL
-    #"glDebugEntry",
-    "wglChoosePixelFormat",
-    "wglCopyContext",
-    "wglCreateContext",
-    "wglCreateLayerContext",
-    "wglDeleteContext",
-    "wglDescribeLayerPlane",
-    "wglDescribePixelFormat",
-    "wglGetCurrentContext",
-    "wglGetCurrentDC",
-    "wglGetDefaultProcAddress",
-    "wglGetLayerPaletteEntries",
-    "wglGetPixelFormat",
-    "wglGetProcAddress",
-    "wglMakeCurrent",
-    "wglRealizeLayerPalette",
-    "wglSetLayerPaletteEntries",
-    "wglSetPixelFormat",
-    "wglShareLists",
-    "wglSwapBuffers",
-    "wglSwapLayerBuffers",
-    "wglSwapMultipleBuffers",
-    "wglUseFontBitmapsA",
-    "wglUseFontBitmapsW",
-    "wglUseFontOutlinesA",
-    "wglUseFontOutlinesW",
-
-])
-
-# EGL 1.4
-public_symbols.update([
-   "eglBindAPI",
-   "eglBindTexImage",
-   "eglChooseConfig",
-   "eglCopyBuffers",
-   "eglCreateContext",
-   "eglCreatePbufferFromClientBuffer",
-   "eglCreatePbufferSurface",
-   "eglCreatePixmapSurface",
-   "eglCreateWindowSurface",
-   "eglDestroyContext",
-   "eglDestroySurface",
-   "eglGetConfigAttrib",
-   "eglGetConfigs",
-   "eglGetCurrentContext",
-   "eglGetCurrentDisplay",
-   "eglGetCurrentSurface",
-   "eglGetDisplay",
-   "eglGetError",
-   "eglGetProcAddress",
-   "eglInitialize",
-   "eglMakeCurrent",
-   "eglQueryAPI",
-   "eglQueryContext",
-   "eglQueryString",
-   "eglQuerySurface",
-   "eglReleaseTexImage",
-   "eglReleaseThread",
-   "eglSurfaceAttrib",
-   "eglSwapBuffers",
-   "eglSwapInterval",
-   "eglTerminate",
-   "eglWaitClient",
-   "eglWaitGL",
-   "eglWaitNative",
-])
-
-class GlDispatcher(Dispatcher):
-
-    def header(self):
-        print '''
-#if defined(_WIN32)
-extern HINSTANCE __libGlHandle;
-#else
-extern void * __libGlHandle;
-#endif
-
-void * __getPublicProcAddress(const char *procName);
-void * __getPrivateProcAddress(const char *procName);
-'''
-        
-    def isFunctionPublic(self, function):
-        return function.name in public_symbols or function.name.startswith('CGL')
-
-
-if __name__ == '__main__':
-    print
-    print '#ifndef _GLPROC_HPP_'
-    print '#define _GLPROC_HPP_'
-    print 
-    print '#include "glimports.hpp"'
-    print '#include "os.hpp"'
-    print
-    print
-    dispatcher = GlDispatcher()
-    dispatcher.header()
-    print '#if defined(TRACE_EGL)'
-    print
-    dispatcher.dispatch_api(eglapi)
-    print '#elif defined(_WIN32)'
-    print
-    dispatcher.dispatch_api(wglapi)
-    print '#elif defined(__APPLE__)'
-    dispatcher.dispatch_api(cglapi)
-    print '#else'
-    print
-    dispatcher.dispatch_api(glxapi)
-    print '#endif'
-    print
-    dispatcher.dispatch_api(glapi)
-    print
-    dispatcher.dispatch_api(glesapi)
-    print
-
-    print '#endif /* !_GLPROC_HPP_ */'
-    print
diff --git a/glproc_egl.cpp b/glproc_egl.cpp
deleted file mode 100644 (file)
index 7ba7b5c..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "glproc.hpp"
-
-
-#if !defined(_WIN32)
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE // for dladdr
-#endif
-#include <dlfcn.h>
-#endif
-
-
-/*
- * Handle to the true OpenGL library.
- * XXX: Not really used yet.
- */
-#if defined(_WIN32)
-HINSTANCE __libGlHandle = NULL;
-#else
-void *__libGlHandle = NULL;
-#endif
-
-
-
-#if defined(_WIN32)
-
-#error Unsupported
-
-#elif defined(__APPLE__)
-
-#error Unsupported
-
-#else
-
-/*
- * Lookup a public EGL/GL/GLES symbol
- *
- * The spec states that eglGetProcAddress should only be used for non-core
- * (extensions) entry-points.  Core entry-points should be taken directly from
- * the API specific libraries.
- *
- * We cannot tell here which API a symbol is meant for here (as some are
- * exported by many).  So this code assumes that the appropriate shared
- * libraries have been loaded previously (either dlopened with RTLD_GLOBAL, or
- * as part of the executable dependencies), and that their symbols available
- * for quering via dlsym(RTLD_NEXT, ...).
- */
-void *
-__getPublicProcAddress(const char *procName)
-{
-    return dlsym(RTLD_NEXT, procName);
-}
-
-/*
- * Lookup a private EGL/GL/GLES symbol
- *
- * Private symbols should always be available through eglGetProcAddress, and
- * they are guaranteed to work with any context bound (regardless of the API).
- *
- * However, per issue#57, eglGetProcAddress returns garbage on some
- * implementations, and the spec states that implementations may choose to also
- * export extension functions publicly, so we always attempt dlsym before
- * eglGetProcAddress to mitigate that.
- */
-void *
-__getPrivateProcAddress(const char *procName)
-{
-    void *proc;
-    proc = dlsym(RTLD_NEXT, procName);
-    if (!proc && procName[0] == 'g' && procName[1] == 'l')
-        proc = (void *) __eglGetProcAddress(procName);
-
-    return proc;
-}
-
-#endif
diff --git a/glproc_gl.cpp b/glproc_gl.cpp
deleted file mode 100644 (file)
index d032e8b..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "glproc.hpp"
-
-
-#if !defined(_WIN32)
-#include <unistd.h> // for symlink
-#include <dlfcn.h>
-#endif
-
-
-/*
- * Handle to the true OpenGL library.
- */
-#if defined(_WIN32)
-HINSTANCE __libGlHandle = NULL;
-#else
-void *__libGlHandle = NULL;
-#endif
-
-
-
-#if defined(_WIN32)
-
-void *
-__getPublicProcAddress(const char *procName)
-{
-    if (!__libGlHandle) {
-        char szDll[MAX_PATH] = {0};
-        
-        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
-            return NULL;
-        }
-        
-        strcat(szDll, "\\\\opengl32.dll");
-        
-        __libGlHandle = LoadLibraryA(szDll);
-        if (!__libGlHandle) {
-            os::log("apitrace: error: couldn't load %s\n", szDll);
-            return NULL;
-        }
-    }
-        
-    return (void *)GetProcAddress(__libGlHandle, procName);
-}
-
-
-void *
-__getPrivateProcAddress(const char *procName) {
-    return (void *)__wglGetProcAddress(procName);
-}
-
-
-#elif defined(__APPLE__)
-
-
-/*
- * Path to the true OpenGL framework
- */
-static const char *libgl_filename = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
-
-
-/*
- * Lookup a libGL symbol
- */
-void * __libgl_sym(const char *symbol)
-{
-    void *result;
-
-    if (!__libGlHandle) {
-        /* 
-         * Unfortunately we can't just dlopen the true dynamic library because
-         * DYLD_LIBRARY_PATH/DYLD_FRAMEWORK_PATH take precedence, even for
-         * absolute paths.  So we create a temporary symlink, and dlopen that
-         * instead.
-         */
-
-        char temp_filename[] = "/tmp/tmp.XXXXXX";
-
-        if (mktemp(temp_filename) != NULL) {
-            if (symlink(libgl_filename, temp_filename) == 0) {
-                __libGlHandle = dlopen(temp_filename, RTLD_LOCAL | RTLD_NOW | RTLD_FIRST);
-                remove(temp_filename);
-            }
-        }
-
-        if (!__libGlHandle) {
-            os::log("apitrace: error: couldn't load %s\n", libgl_filename);
-            os::abort();
-            return NULL;
-        }
-    }
-
-    result = dlsym(__libGlHandle, symbol);
-
-#ifndef RETRACE
-    if (result == dlsym(RTLD_SELF, symbol)) {
-        os::log("apitrace: error: symbol lookup recursion\n");
-        os::abort();
-        return NULL;
-    }
-#endif
-
-    return result;
-}
-
-
-void *
-__getPublicProcAddress(const char *procName)
-{
-    return __libgl_sym(procName);
-}
-
-void *
-__getPrivateProcAddress(const char *procName)
-{
-    return __libgl_sym(procName);
-}
-
-
-#else
-
-
-/*
- * Invoke the true dlopen() function.
- */
-static void *
-__dlopen(const char *filename, int flag)
-{
-    typedef void * (*PFNDLOPEN)(const char *, int);
-    static PFNDLOPEN dlopen_ptr = NULL;
-
-    if (!dlopen_ptr) {
-        dlopen_ptr = (PFNDLOPEN)dlsym(RTLD_NEXT, "dlopen");
-        if (!dlopen_ptr) {
-            os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n");
-            return NULL;
-        }
-    }
-
-    return dlopen_ptr(filename, flag);
-}
-
-
-/*
- * Lookup a libGL symbol
- */
-void * __libgl_sym(const char *symbol)
-{
-    void *result;
-
-    if (!__libGlHandle) {
-        /*
-         * The app doesn't directly link against libGL.so, nor does it directly
-         * dlopen it.  So we have to load it ourselves.
-         */
-
-        const char * libgl_filename = getenv("TRACE_LIBGL");
-
-        if (!libgl_filename) {
-            /*
-             * Try to use whatever libGL.so the library is linked against.
-             */
-
-            result = dlsym(RTLD_NEXT, symbol);
-            if (result) {
-                __libGlHandle = RTLD_NEXT;
-                return result;
-            }
-
-            libgl_filename = "libGL.so.1";
-        }
-
-        /*
-         * It would have been preferable to use RTLD_LOCAL to ensure that the
-         * application can never access libGL.so symbols directly, but this
-         * won't work, given libGL.so often loads a driver specific SO and
-         * exposes symbols to it.
-         */
-
-        __libGlHandle = __dlopen(libgl_filename, RTLD_GLOBAL | RTLD_LAZY);
-        if (!__libGlHandle) {
-            os::log("apitrace: error: couldn't find libGL.so\n");
-            return NULL;
-        }
-    }
-
-    return dlsym(__libGlHandle, symbol);
-}
-
-
-void *
-__getPublicProcAddress(const char *procName)
-{
-    return __libgl_sym(procName);
-}
-
-void *
-__getPrivateProcAddress(const char *procName)
-{
-    return (void *)__glXGetProcAddressARB((const GLubyte *)procName);
-}
-
-
-#endif 
-
diff --git a/glretrace.hpp b/glretrace.hpp
deleted file mode 100644 (file)
index 8353522..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _GLRETRACE_HPP_
-#define _GLRETRACE_HPP_
-
-#include "trace_parser.hpp"
-#include "glws.hpp"
-#include "retrace.hpp"
-
-
-namespace glretrace {
-
-
-extern bool double_buffer;
-extern bool insideGlBeginEnd;
-extern trace::Parser parser;
-extern glws::Profile defaultProfile;
-extern glws::Visual *visual[glws::PROFILE_MAX];
-extern glws::Drawable *drawable;
-extern glws::Context *context;
-
-extern unsigned frame;
-extern long long startTime;
-extern bool wait;
-
-extern bool benchmark;
-
-extern unsigned dump_state;
-
-void
-checkGlError(trace::Call &call);
-
-extern const retrace::Entry gl_callbacks[];
-extern const retrace::Entry cgl_callbacks[];
-extern const retrace::Entry glx_callbacks[];
-extern const retrace::Entry wgl_callbacks[];
-extern const retrace::Entry egl_callbacks[];
-
-void frame_complete(trace::Call &call);
-
-void updateDrawable(int width, int height);
-
-} /* namespace glretrace */
-
-
-#endif /* _GLRETRACE_HPP_ */
diff --git a/glretrace.py b/glretrace.py
deleted file mode 100644 (file)
index 8dfc340..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
-##########################################################################
-#
-# Copyright 2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""GL retracer generator."""
-
-
-import specs.stdapi as stdapi
-import specs.glapi as glapi
-import specs.glesapi as glesapi
-from retrace import Retracer
-
-
-class GlRetracer(Retracer):
-
-    table_name = 'glretrace::gl_callbacks'
-
-    def retraceFunction(self, function):
-        Retracer.retraceFunction(self, function)
-
-    array_pointer_function_names = set((
-        "glVertexPointer",
-        "glNormalPointer",
-        "glColorPointer",
-        "glIndexPointer",
-        "glTexCoordPointer",
-        "glEdgeFlagPointer",
-        "glFogCoordPointer",
-        "glSecondaryColorPointer",
-
-        "glInterleavedArrays",
-
-        "glVertexPointerEXT",
-        "glNormalPointerEXT",
-        "glColorPointerEXT",
-        "glIndexPointerEXT",
-        "glTexCoordPointerEXT",
-        "glEdgeFlagPointerEXT",
-        "glFogCoordPointerEXT",
-        "glSecondaryColorPointerEXT",
-
-        "glVertexAttribPointer",
-        "glVertexAttribPointerARB",
-        "glVertexAttribPointerNV",
-        "glVertexAttribIPointer",
-        "glVertexAttribIPointerEXT",
-        "glVertexAttribLPointer",
-        "glVertexAttribLPointerEXT",
-        
-        #"glMatrixIndexPointerARB",
-    ))
-
-    draw_array_function_names = set([
-        "glDrawArrays",
-        "glDrawArraysEXT",
-        "glDrawArraysIndirect",
-        "glDrawArraysInstanced",
-        "glDrawArraysInstancedARB",
-        "glDrawArraysInstancedEXT",
-        "glDrawArraysInstancedBaseInstance",
-        "glDrawMeshArraysSUN",
-        "glMultiDrawArrays",
-        "glMultiDrawArraysEXT",
-        "glMultiModeDrawArraysIBM",
-    ])
-
-    draw_elements_function_names = set([
-        "glDrawElements",
-        "glDrawElementsBaseVertex",
-        "glDrawElementsIndirect",
-        "glDrawElementsInstanced",
-        "glDrawElementsInstancedARB",
-        "glDrawElementsInstancedEXT",
-        "glDrawElementsInstancedBaseVertex",
-        "glDrawElementsInstancedBaseInstance",
-        "glDrawElementsInstancedBaseVertexBaseInstance",
-        "glDrawRangeElements",
-        "glDrawRangeElementsEXT",
-        "glDrawRangeElementsBaseVertex",
-        "glMultiDrawElements",
-        "glMultiDrawElementsBaseVertex",
-        "glMultiDrawElementsEXT",
-        "glMultiModeDrawElementsIBM",
-    ])
-
-    draw_indirect_function_names = set([
-        "glDrawArraysIndirect",
-        "glDrawElementsIndirect",
-    ])
-
-    misc_draw_function_names = set([
-        "glClear",
-        "glEnd",
-        "glDrawPixels",
-        "glBlitFramebuffer",
-        "glBlitFramebufferEXT",
-    ])
-
-    bind_framebuffer_function_names = set([
-        "glBindFramebuffer",
-        "glBindFramebufferEXT",
-        "glBindFramebufferOES",
-    ])
-
-    # Names of the functions that can pack into the current pixel buffer
-    # object.  See also the ARB_pixel_buffer_object specification.
-    pack_function_names = set([
-        'glGetCompressedTexImage',
-        'glGetConvolutionFilter',
-        'glGetHistogram',
-        'glGetMinmax',
-        'glGetPixelMapfv',
-        'glGetPixelMapuiv',
-        'glGetPixelMapusv',
-        'glGetPolygonStipple',
-        'glGetSeparableFilter',
-        'glGetTexImage',
-        'glReadPixels',
-        'glGetnCompressedTexImageARB',
-        'glGetnConvolutionFilterARB',
-        'glGetnHistogramARB',
-        'glGetnMinmaxARB',
-        'glGetnPixelMapfvARB',
-        'glGetnPixelMapuivARB',
-        'glGetnPixelMapusvARB',
-        'glGetnPolygonStippleARB',
-        'glGetnSeparableFilterARB',
-        'glGetnTexImageARB',
-        'glReadnPixelsARB',
-    ])
-
-    map_function_names = set([
-        'glMapBuffer',
-        'glMapBufferARB',
-        'glMapBufferOES',
-        'glMapBufferRange',
-        'glMapNamedBufferEXT',
-        'glMapNamedBufferRangeEXT'
-    ])
-
-    unmap_function_names = set([
-        'glUnmapBuffer',
-        'glUnmapBufferARB',
-        'glUnmapBufferOES',
-        'glUnmapNamedBufferEXT',
-    ])
-
-    def retraceFunctionBody(self, function):
-        is_array_pointer = function.name in self.array_pointer_function_names
-        is_draw_array = function.name in self.draw_array_function_names
-        is_draw_elements = function.name in self.draw_elements_function_names
-        is_misc_draw = function.name in self.misc_draw_function_names
-
-        if is_array_pointer or is_draw_array or is_draw_elements:
-            print '    if (glretrace::parser.version < 1) {'
-
-            if is_array_pointer or is_draw_array:
-                print '        GLint __array_buffer = 0;'
-                print '        glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);'
-                print '        if (!__array_buffer) {'
-                self.failFunction(function)
-                print '        }'
-
-            if is_draw_elements:
-                print '        GLint __element_array_buffer = 0;'
-                print '        glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &__element_array_buffer);'
-                print '        if (!__element_array_buffer) {'
-                self.failFunction(function)
-                print '        }'
-            
-            print '    }'
-
-        # When no pack buffer object is bound, the pack functions are no-ops.
-        if function.name in self.pack_function_names:
-            print '    GLint __pack_buffer = 0;'
-            print '    glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &__pack_buffer);'
-            print '    if (!__pack_buffer) {'
-            print '        return;'
-            print '    }'
-
-        # Pre-snapshots
-        if function.name in self.bind_framebuffer_function_names:
-            print '    assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);'
-        if function.name == 'glFrameTerminatorGREMEDY':
-            print '    glretrace::frame_complete(call);'
-            return
-
-        Retracer.retraceFunctionBody(self, function)
-
-        # Post-snapshots
-        if function.name in ('glFlush', 'glFinish'):
-            print '    if (!glretrace::double_buffer) {'
-            print '        glretrace::frame_complete(call);'
-            print '    }'
-        if is_draw_array or is_draw_elements or is_misc_draw:
-            print '    assert(call.flags & trace::CALL_FLAG_RENDER);'
-
-
-    def invokeFunction(self, function):
-        # Infer the drawable size from GL calls
-        if function.name == "glViewport":
-            print '    glretrace::updateDrawable(x + width, y + height);'
-        if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'):
-            # Some applications do all their rendering in a framebuffer, and
-            # then just blit to the drawable without ever calling glViewport.
-            print '    glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));'
-
-        if function.name == "glEnd":
-            print '    glretrace::insideGlBeginEnd = false;'
-
-        if function.name.startswith('gl') and not function.name.startswith('glX'):
-            print r'    if (!glretrace::context && !glretrace::benchmark && !retrace::profiling) {'
-            print r'        retrace::warning(call) << "no current context\n";'
-            print r'    }'
-
-        if function.name == 'memcpy':
-            print '    if (!dest || !src || !n) return;'
-        
-        Retracer.invokeFunction(self, function)
-
-        # Error checking
-        if function.name == "glBegin":
-            print '    glretrace::insideGlBeginEnd = true;'
-        elif function.name.startswith('gl'):
-            # glGetError is not allowed inside glBegin/glEnd
-            print '    if (!glretrace::benchmark && !retrace::profiling && !glretrace::insideGlBeginEnd) {'
-            print '        glretrace::checkGlError(call);'
-            if function.name in ('glProgramStringARB', 'glProgramStringNV'):
-                print r'        GLint error_position = -1;'
-                print r'        glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);'
-                print r'        if (error_position != -1) {'
-                print r'            const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);'
-                print r'            retrace::warning(call) << error_string << "\n";'
-                print r'        }'
-            if function.name == 'glCompileShader':
-                print r'        GLint compile_status = 0;'
-                print r'        glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);'
-                print r'        if (!compile_status) {'
-                print r'             GLint info_log_length = 0;'
-                print r'             glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);'
-                print r'             GLchar *infoLog = new GLchar[info_log_length];'
-                print r'             glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);'
-                print r'             retrace::warning(call) << infoLog << "\n";'
-                print r'             delete [] infoLog;'
-                print r'        }'
-            if function.name == 'glLinkProgram':
-                print r'        GLint link_status = 0;'
-                print r'        glGetProgramiv(program, GL_LINK_STATUS, &link_status);'
-                print r'        if (!link_status) {'
-                print r'             GLint info_log_length = 0;'
-                print r'             glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);'
-                print r'             GLchar *infoLog = new GLchar[info_log_length];'
-                print r'             glGetProgramInfoLog(program, info_log_length, NULL, infoLog);'
-                print r'             retrace::warning(call) << infoLog << "\n";'
-                print r'             delete [] infoLog;'
-                print r'        }'
-            if function.name == 'glCompileShaderARB':
-                print r'        GLint compile_status = 0;'
-                print r'        glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);'
-                print r'        if (!compile_status) {'
-                print r'             GLint info_log_length = 0;'
-                print r'             glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
-                print r'             GLchar *infoLog = new GLchar[info_log_length];'
-                print r'             glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);'
-                print r'             retrace::warning(call) << infoLog << "\n";'
-                print r'             delete [] infoLog;'
-                print r'        }'
-            if function.name == 'glLinkProgramARB':
-                print r'        GLint link_status = 0;'
-                print r'        glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);'
-                print r'        if (!link_status) {'
-                print r'             GLint info_log_length = 0;'
-                print r'             glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
-                print r'             GLchar *infoLog = new GLchar[info_log_length];'
-                print r'             glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);'
-                print r'             retrace::warning(call) << infoLog << "\n";'
-                print r'             delete [] infoLog;'
-                print r'        }'
-            if function.name in self.map_function_names:
-                print r'        if (!__result) {'
-                print r'             retrace::warning(call) << "failed to map buffer\n";'
-                print r'        }'
-            if function.name in ('glGetAttribLocation', 'glGetAttribLocationARB'):
-                print r'    GLint __orig_result = call.ret->toSInt();'
-                print r'    if (__result != __orig_result) {'
-                print r'        retrace::warning(call) << "vertex attrib location mismatch " << __orig_result << " -> " << __result << "\n";'
-                print r'    }'
-            if function.name in ('glCheckFramebufferStatus', 'glCheckFramebufferStatusEXT', 'glCheckNamedFramebufferStatusEXT'):
-                print r'    GLint __orig_result = call.ret->toSInt();'
-                print r'    if (__orig_result == GL_FRAMEBUFFER_COMPLETE &&'
-                print r'        __result != GL_FRAMEBUFFER_COMPLETE) {'
-                print r'        retrace::warning(call) << "incomplete framebuffer (" << glstate::enumToString(__result) << ")\n";'
-                print r'    }'
-            print '    }'
-
-            # Query the buffer length for whole buffer mappings
-            if function.name in self.map_function_names:
-                if 'length' in function.argNames():
-                    assert 'BufferRange' in function.name
-                else:
-                    assert 'BufferRange' not in function.name
-                    print r'    GLint length = 0;'
-                    if function.name in ('glMapBuffer', 'glMapBufferOES'):
-                        print r'    glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);'
-                    elif function.name == 'glMapBufferARB':
-                        print r'    glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);'
-                    elif function.name == 'glMapNamedBufferEXT':
-                        print r'    glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);'
-                    else:
-                        assert False
-            # Destroy the buffer mapping
-            if function.name in self.unmap_function_names:
-                print r'        GLvoid *ptr = NULL;'
-                if function.name == 'glUnmapBuffer':
-                    print r'            glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);'
-                elif function.name == 'glUnmapBufferARB':
-                    print r'            glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);'
-                elif function.name == 'glUnmapBufferOES':
-                    print r'            glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);'
-                elif function.name == 'glUnmapNamedBufferEXT':
-                    print r'            glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);'
-                else:
-                    assert False
-                print r'        if (ptr) {'
-                print r'            retrace::delRegionByPointer(ptr);'
-                print r'        }'
-
-    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
-        if function.name in self.array_pointer_function_names and arg.name == 'pointer':
-            print '    %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)
-            return
-
-        if function.name in self.draw_elements_function_names and arg.name == 'indices' or\
-           function.name in self.draw_indirect_function_names and arg.name == 'indirect':
-            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
-            return
-
-        # Handle pointer with offsets into the current pack pixel buffer
-        # object.
-        if function.name in self.pack_function_names and arg.output:
-            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
-            return
-
-        if arg.type is glapi.GLlocation \
-           and 'program' not in function.argNames():
-            print '    GLint program = -1;'
-            print '    glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
-        
-        if arg.type is glapi.GLlocationARB \
-           and 'programObj' not in function.argNames():
-            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'
-
-        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)
-
-        # Don't try to use more samples than the implementation supports
-        if arg.name == 'samples':
-            assert arg.type is glapi.GLsizei
-            print '    GLint max_samples = 0;'
-            print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
-            print '    if (samples > max_samples) {'
-            print '        samples = max_samples;'
-            print '    }'
-
-
-if __name__ == '__main__':
-    print r'''
-#include <string.h>
-
-#include "glproc.hpp"
-#include "glretrace.hpp"
-#include "glstate.hpp"
-
-
-'''
-    api = glapi.glapi
-    api.addApi(glesapi.glesapi)
-    retracer = GlRetracer()
-    retracer.retraceApi(api)
diff --git a/glretrace_cgl.cpp b/glretrace_cgl.cpp
deleted file mode 100644 (file)
index 63b94b4..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <string.h>
-
-#include "glproc.hpp"
-#include "retrace.hpp"
-#include "glretrace.hpp"
-
-
-using namespace glretrace;
-
-
-typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
-typedef std::map<unsigned long long, glws::Context *> ContextMap;
-static DrawableMap drawable_map;
-static ContextMap context_map;
-static glws::Context *sharedContext = NULL;
-
-
-static glws::Drawable *
-getDrawable(unsigned long drawable_id) {
-    if (drawable_id == 0) {
-        return NULL;
-    }
-
-    /* XXX: Support multiple drawables. */
-    drawable_id = 1;
-
-    DrawableMap::const_iterator it;
-    it = drawable_map.find(drawable_id);
-    if (it == drawable_map.end()) {
-        return (drawable_map[drawable_id] = glws::createDrawable(visual[glretrace::defaultProfile]));
-    }
-
-    return it->second;
-}
-
-
-static glws::Context *
-getContext(unsigned long long ctx) {
-    if (ctx == 0) {
-        return NULL;
-    }
-
-    ContextMap::const_iterator it;
-    it = context_map.find(ctx);
-    if (it == context_map.end()) {
-        glws::Context *context;
-        context_map[ctx] = context = glws::createContext(visual[glretrace::defaultProfile], sharedContext, glretrace::defaultProfile);
-        if (!sharedContext) {
-            sharedContext = context;
-        }
-        return context;
-    }
-
-    return it->second;
-}
-
-
-static void retrace_CGLSetCurrentContext(trace::Call &call) {
-    unsigned long long ctx = call.arg(0).toUIntPtr();
-
-    glws::Drawable *new_drawable = getDrawable(ctx);
-    glws::Context *new_context = getContext(ctx);
-
-    bool result = glws::makeCurrent(new_drawable, new_context);
-
-    if (new_drawable && new_context && result) {
-        drawable = new_drawable;
-        context = new_context;
-    } else {
-        drawable = NULL;
-        context = NULL;
-    }
-}
-
-
-static void retrace_CGLFlushDrawable(trace::Call &call) {
-    if (drawable && context) {
-        if (double_buffer) {
-            drawable->swapBuffers();
-        } else {
-            glFlush();
-        }
-
-        frame_complete(call);
-    }
-}
-
-
-const retrace::Entry glretrace::cgl_callbacks[] = {
-    {"CGLSetCurrentContext", &retrace_CGLSetCurrentContext},
-    {"CGLGetCurrentContext", &retrace::ignore},
-    {"CGLEnable", &retrace::ignore},
-    {"CGLDisable", &retrace::ignore},
-    {"CGLSetParameter", &retrace::ignore},
-    {"CGLGetParameter", &retrace::ignore},
-    {"CGLFlushDrawable", &retrace_CGLFlushDrawable},
-    {NULL, NULL},
-};
-
diff --git a/glretrace_egl.cpp b/glretrace_egl.cpp
deleted file mode 100644 (file)
index e4178e3..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 LunarG, Inc.
- * All Rights Reserved.
- *
- * Based on glretrace_glx.cpp, which has
- *
- *   Copyright 2011 Jose Fonseca
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "glproc.hpp"
-#include "retrace.hpp"
-#include "glretrace.hpp"
-#include "os.hpp"
-
-#ifndef EGL_OPENGL_ES_API
-#define EGL_OPENGL_ES_API              0x30A0
-#define EGL_OPENVG_API                 0x30A1
-#define EGL_OPENGL_API                 0x30A2
-#define EGL_CONTEXT_CLIENT_VERSION     0x3098
-#endif
-
-
-using namespace glretrace;
-
-
-typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
-typedef std::map<unsigned long long, glws::Context *> ContextMap;
-typedef std::map<unsigned long long, glws::Profile> ProfileMap;
-static DrawableMap drawable_map;
-static ContextMap context_map;
-static ProfileMap profile_map;
-
-static unsigned int current_api = EGL_OPENGL_ES_API;
-static glws::Profile last_profile = glws::PROFILE_COMPAT;
-
-static glws::Drawable *
-getDrawable(unsigned long long surface_ptr) {
-    if (surface_ptr == 0) {
-        return NULL;
-    }
-
-    DrawableMap::const_iterator it;
-    it = drawable_map.find(surface_ptr);
-
-    return (it != drawable_map.end()) ? it->second : NULL;
-}
-
-static glws::Context *
-getContext(unsigned long long context_ptr) {
-    if (context_ptr == 0) {
-        return NULL;
-    }
-
-    ContextMap::const_iterator it;
-    it = context_map.find(context_ptr);
-
-    return (it != context_map.end()) ? it->second : NULL;
-}
-
-static void createDrawable(unsigned long long orig_config, unsigned long long orig_surface)
-{
-    ProfileMap::iterator it = profile_map.find(orig_config);
-    glws::Profile profile;
-
-    // If the requested config is associated with a profile, use that
-    // profile. Otherwise, assume that the last used profile is what
-    // the user wants.
-    if (it != profile_map.end()) {
-        profile = it->second;
-    } else {
-        profile = last_profile;
-    }
-
-    glws::Visual *visual = glretrace::visual[profile];
-
-    glws::Drawable *drawable = glws::createDrawable(visual);
-    drawable_map[orig_surface] = drawable;
-}
-
-static void retrace_eglCreateWindowSurface(trace::Call &call) {
-    unsigned long long orig_config = call.arg(1).toUIntPtr();
-    unsigned long long orig_surface = call.ret->toUIntPtr();
-    createDrawable(orig_config, orig_surface);
-}
-
-static void retrace_eglCreatePbufferSurface(trace::Call &call) {
-    unsigned long long orig_config = call.arg(1).toUIntPtr();
-    unsigned long long orig_surface = call.ret->toUIntPtr();
-    createDrawable(orig_config, orig_surface);
-    // TODO: Respect the pbuffer dimensions too
-}
-
-static void retrace_eglDestroySurface(trace::Call &call) {
-    unsigned long long orig_surface = call.arg(1).toUIntPtr();
-
-    DrawableMap::iterator it;
-    it = drawable_map.find(orig_surface);
-
-    if (it != drawable_map.end()) {
-        if (it->second != drawable) {
-            // TODO: reference count
-            delete it->second;
-        }
-        drawable_map.erase(it);
-    }
-}
-
-static void retrace_eglBindAPI(trace::Call &call) {
-    current_api = call.arg(0).toUInt();
-}
-
-static void retrace_eglCreateContext(trace::Call &call) {
-    unsigned long long orig_context = call.ret->toUIntPtr();
-    unsigned long long orig_config = call.arg(1).toUIntPtr();
-    glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
-    trace::Array *attrib_array = dynamic_cast<trace::Array *>(&call.arg(3));
-    glws::Profile profile;
-
-    switch (current_api) {
-    case EGL_OPENGL_API:
-        profile = glws::PROFILE_COMPAT;
-        break;
-    case EGL_OPENGL_ES_API:
-    default:
-        profile = glws::PROFILE_ES1;
-        if (attrib_array) {
-            for (int i = 0; i < attrib_array->values.size(); i += 2) {
-                int v = attrib_array->values[i]->toSInt();
-                if (v == EGL_CONTEXT_CLIENT_VERSION) {
-                    v = attrib_array->values[i + 1]->toSInt();
-                    if (v == 2)
-                        profile = glws::PROFILE_ES2;
-                    break;
-                }
-            }
-        }
-        break;
-    }
-
-
-    glws::Context *context = glws::createContext(glretrace::visual[profile], share_context, profile);
-    if (!context) {
-        const char *name;
-        switch (profile) {
-        case glws::PROFILE_COMPAT:
-            name = "OpenGL";
-            break;
-        case glws::PROFILE_ES1:
-            name = "OpenGL ES 1.1";
-            break;
-        case glws::PROFILE_ES2:
-            name = "OpenGL ES 2.0";
-            break;
-        default:
-            name = "unknown";
-            break;
-        }
-
-        retrace::warning(call) << "Failed to create " << name << " context.\n";
-        os::abort();
-    }
-
-    context_map[orig_context] = context;
-    profile_map[orig_config] = profile;
-    last_profile = profile;
-}
-
-static void retrace_eglDestroyContext(trace::Call &call) {
-    unsigned long long orig_context = call.arg(1).toUIntPtr();
-
-    ContextMap::iterator it;
-    it = context_map.find(orig_context);
-
-    if (it != context_map.end()) {
-        delete it->second;
-        context_map.erase(it);
-    }
-}
-
-static void retrace_eglMakeCurrent(trace::Call &call) {
-    glws::Drawable *new_drawable = getDrawable(call.arg(1).toUIntPtr());
-    glws::Context *new_context = getContext(call.arg(3).toUIntPtr());
-
-    if (new_drawable == drawable && new_context == context) {
-        return;
-    }
-
-    if (drawable && context) {
-        glFlush();
-        if (!double_buffer) {
-            frame_complete(call);
-        }
-    }
-
-    bool result = glws::makeCurrent(new_drawable, new_context);
-
-    if (new_drawable && new_context && result) {
-        drawable = new_drawable;
-        context = new_context;
-    } else {
-        drawable = NULL;
-        context = NULL;
-    }
-}
-
-
-static void retrace_eglSwapBuffers(trace::Call &call) {
-    frame_complete(call);
-
-    if (double_buffer) {
-        drawable->swapBuffers();
-    } else {
-        glFlush();
-    }
-}
-
-const retrace::Entry glretrace::egl_callbacks[] = {
-    {"eglGetError", &retrace::ignore},
-    {"eglGetDisplay", &retrace::ignore},
-    {"eglInitialize", &retrace::ignore},
-    {"eglTerminate", &retrace::ignore},
-    {"eglQueryString", &retrace::ignore},
-    {"eglGetConfigs", &retrace::ignore},
-    {"eglChooseConfig", &retrace::ignore},
-    {"eglGetConfigAttrib", &retrace::ignore},
-    {"eglCreateWindowSurface", &retrace_eglCreateWindowSurface},
-    {"eglCreatePbufferSurface", &retrace_eglCreatePbufferSurface},
-    //{"eglCreatePixmapSurface", &retrace::ignore},
-    {"eglDestroySurface", &retrace_eglDestroySurface},
-    {"eglQuerySurface", &retrace::ignore},
-    {"eglBindAPI", &retrace_eglBindAPI},
-    {"eglQueryAPI", &retrace::ignore},
-    //{"eglWaitClient", &retrace::ignore},
-    //{"eglReleaseThread", &retrace::ignore},
-    //{"eglCreatePbufferFromClientBuffer", &retrace::ignore},
-    //{"eglSurfaceAttrib", &retrace::ignore},
-    //{"eglBindTexImage", &retrace::ignore},
-    //{"eglReleaseTexImage", &retrace::ignore},
-    {"eglSwapInterval", &retrace::ignore},
-    {"eglCreateContext", &retrace_eglCreateContext},
-    {"eglDestroyContext", &retrace_eglDestroyContext},
-    {"eglMakeCurrent", &retrace_eglMakeCurrent},
-    {"eglGetCurrentContext", &retrace::ignore},
-    {"eglGetCurrentSurface", &retrace::ignore},
-    {"eglGetCurrentDisplay", &retrace::ignore},
-    {"eglQueryContext", &retrace::ignore},
-    {"eglWaitGL", &retrace::ignore},
-    {"eglWaitNative", &retrace::ignore},
-    {"eglSwapBuffers", &retrace_eglSwapBuffers},
-    //{"eglCopyBuffers", &retrace::ignore},
-    {"eglGetProcAddress", &retrace::ignore},
-    {NULL, NULL},
-};
diff --git a/glretrace_glx.cpp b/glretrace_glx.cpp
deleted file mode 100644 (file)
index a3b80f2..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "glproc.hpp"
-#include "retrace.hpp"
-#include "glretrace.hpp"
-
-
-using namespace glretrace;
-
-
-typedef std::map<unsigned long, glws::Drawable *> DrawableMap;
-typedef std::map<unsigned long long, glws::Context *> ContextMap;
-static DrawableMap drawable_map;
-static ContextMap context_map;
-
-
-static glws::Drawable *
-getDrawable(unsigned long drawable_id) {
-    if (drawable_id == 0) {
-        return NULL;
-    }
-
-    DrawableMap::const_iterator it;
-    it = drawable_map.find(drawable_id);
-    if (it == drawable_map.end()) {
-        return (drawable_map[drawable_id] = glws::createDrawable(visual[glretrace::defaultProfile]));
-    }
-
-    return it->second;
-}
-
-static glws::Context *
-getContext(unsigned long long context_ptr) {
-    if (context_ptr == 0) {
-        return NULL;
-    }
-
-    ContextMap::const_iterator it;
-    it = context_map.find(context_ptr);
-    if (it == context_map.end()) {
-        return (context_map[context_ptr] = glws::createContext(visual[glretrace::defaultProfile], NULL, glretrace::defaultProfile));
-    }
-
-    return it->second;
-}
-
-static void retrace_glXCreateContext(trace::Call &call) {
-    unsigned long long orig_context = call.ret->toUIntPtr();
-    glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
-
-    glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
-    context_map[orig_context] = context;
-}
-
-static void retrace_glXCreateContextAttribsARB(trace::Call &call) {
-    unsigned long long orig_context = call.ret->toUIntPtr();
-    glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
-
-    glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
-    context_map[orig_context] = context;
-}
-
-static void retrace_glXMakeCurrent(trace::Call &call) {
-    glws::Drawable *new_drawable = getDrawable(call.arg(1).toUInt());
-    glws::Context *new_context = getContext(call.arg(2).toUIntPtr());
-
-    if (new_drawable == drawable && new_context == context) {
-        return;
-    }
-
-    if (drawable && context) {
-        glFlush();
-        if (!double_buffer) {
-            frame_complete(call);
-        }
-    }
-
-    bool result = glws::makeCurrent(new_drawable, new_context);
-
-    if (new_drawable && new_context && result) {
-        drawable = new_drawable;
-        context = new_context;
-    } else {
-        drawable = NULL;
-        context = NULL;
-    }
-}
-
-
-static void retrace_glXDestroyContext(trace::Call &call) {
-    glws::Context *context = getContext(call.arg(1).toUIntPtr());
-
-    if (!context) {
-        return;
-    }
-
-    delete context;
-}
-
-static void retrace_glXSwapBuffers(trace::Call &call) {
-    frame_complete(call);
-    if (double_buffer) {
-        drawable->swapBuffers();
-    } else {
-        glFlush();
-    }
-}
-
-static void retrace_glXCreateNewContext(trace::Call &call) {
-    unsigned long long orig_context = call.ret->toUIntPtr();
-    glws::Context *share_context = getContext(call.arg(3).toUIntPtr());
-
-    glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
-    context_map[orig_context] = context;
-}
-
-static void retrace_glXMakeContextCurrent(trace::Call &call) {
-    glws::Drawable *new_drawable = getDrawable(call.arg(1).toUInt());
-    glws::Context *new_context = getContext(call.arg(3).toUIntPtr());
-
-    if (new_drawable == drawable && new_context == context) {
-        return;
-    }
-
-    if (drawable && context) {
-        glFlush();
-        if (!double_buffer) {
-            frame_complete(call);
-        }
-    }
-
-    bool result = glws::makeCurrent(new_drawable, new_context);
-
-    if (new_drawable && new_context && result) {
-        drawable = new_drawable;
-        context = new_context;
-    } else {
-        drawable = NULL;
-        context = NULL;
-    }
-}
-
-const retrace::Entry glretrace::glx_callbacks[] = {
-    //{"glXBindChannelToWindowSGIX", &retrace_glXBindChannelToWindowSGIX},
-    //{"glXBindSwapBarrierNV", &retrace_glXBindSwapBarrierNV},
-    //{"glXBindSwapBarrierSGIX", &retrace_glXBindSwapBarrierSGIX},
-    //{"glXBindTexImageEXT", &retrace_glXBindTexImageEXT},
-    //{"glXChannelRectSGIX", &retrace_glXChannelRectSGIX},
-    //{"glXChannelRectSyncSGIX", &retrace_glXChannelRectSyncSGIX},
-    {"glXChooseFBConfig", &retrace::ignore},
-    {"glXChooseFBConfigSGIX", &retrace::ignore},
-    {"glXChooseVisual", &retrace::ignore},
-    //{"glXCopyContext", &retrace_glXCopyContext},
-    //{"glXCopyImageSubDataNV", &retrace_glXCopyImageSubDataNV},
-    //{"glXCopySubBufferMESA", &retrace_glXCopySubBufferMESA},
-    {"glXCreateContextAttribsARB", &retrace_glXCreateContextAttribsARB},
-    {"glXCreateContext", &retrace_glXCreateContext},
-    //{"glXCreateContextWithConfigSGIX", &retrace_glXCreateContextWithConfigSGIX},
-    //{"glXCreateGLXPbufferSGIX", &retrace_glXCreateGLXPbufferSGIX},
-    //{"glXCreateGLXPixmap", &retrace_glXCreateGLXPixmap},
-    //{"glXCreateGLXPixmapWithConfigSGIX", &retrace_glXCreateGLXPixmapWithConfigSGIX},
-    {"glXCreateNewContext", &retrace_glXCreateNewContext},
-    //{"glXCreatePbuffer", &retrace_glXCreatePbuffer},
-    //{"glXCreatePixmap", &retrace_glXCreatePixmap},
-    //{"glXCreateWindow", &retrace_glXCreateWindow},
-    //{"glXCushionSGI", &retrace_glXCushionSGI},
-    {"glXDestroyContext", &retrace_glXDestroyContext},
-    //{"glXDestroyGLXPbufferSGIX", &retrace_glXDestroyGLXPbufferSGIX},
-    //{"glXDestroyGLXPixmap", &retrace_glXDestroyGLXPixmap},
-    //{"glXDestroyPbuffer", &retrace_glXDestroyPbuffer},
-    //{"glXDestroyPixmap", &retrace_glXDestroyPixmap},
-    //{"glXDestroyWindow", &retrace_glXDestroyWindow},
-    //{"glXFreeContextEXT", &retrace_glXFreeContextEXT},
-    {"glXGetAGPOffsetMESA", &retrace::ignore},
-    {"glXGetClientString", &retrace::ignore},
-    {"glXGetConfig", &retrace::ignore},
-    {"glXGetContextIDEXT", &retrace::ignore},
-    {"glXGetCurrentContext", &retrace::ignore},
-    {"glXGetCurrentDisplayEXT", &retrace::ignore},
-    {"glXGetCurrentDisplay", &retrace::ignore},
-    {"glXGetCurrentDrawable", &retrace::ignore},
-    {"glXGetCurrentReadDrawable", &retrace::ignore},
-    {"glXGetCurrentReadDrawableSGI", &retrace::ignore},
-    {"glXGetFBConfigAttrib", &retrace::ignore},
-    {"glXGetFBConfigAttribSGIX", &retrace::ignore},
-    {"glXGetFBConfigFromVisualSGIX", &retrace::ignore},
-    {"glXGetFBConfigs", &retrace::ignore},
-    {"glXGetMscRateOML", &retrace::ignore},
-    {"glXGetProcAddressARB", &retrace::ignore},
-    {"glXGetProcAddress", &retrace::ignore},
-    {"glXGetSelectedEvent", &retrace::ignore},
-    {"glXGetSelectedEventSGIX", &retrace::ignore},
-    {"glXGetSyncValuesOML", &retrace::ignore},
-    {"glXGetVideoSyncSGI", &retrace::ignore},
-    {"glXGetVisualFromFBConfig", &retrace::ignore},
-    {"glXGetVisualFromFBConfigSGIX", &retrace::ignore},
-    //{"glXImportContextEXT", &retrace_glXImportContextEXT},
-    {"glXIsDirect", &retrace::ignore},
-    //{"glXJoinSwapGroupNV", &retrace_glXJoinSwapGroupNV},
-    //{"glXJoinSwapGroupSGIX", &retrace_glXJoinSwapGroupSGIX},
-    {"glXMakeContextCurrent", &retrace_glXMakeContextCurrent},
-    //{"glXMakeCurrentReadSGI", &retrace_glXMakeCurrentReadSGI},
-    {"glXMakeCurrent", &retrace_glXMakeCurrent},
-    {"glXQueryChannelDeltasSGIX", &retrace::ignore},
-    {"glXQueryChannelRectSGIX", &retrace::ignore},
-    {"glXQueryContextInfoEXT", &retrace::ignore},
-    {"glXQueryContext", &retrace::ignore},
-    {"glXQueryDrawable", &retrace::ignore},
-    {"glXQueryExtension", &retrace::ignore},
-    {"glXQueryExtensionsString", &retrace::ignore},
-    {"glXQueryFrameCountNV", &retrace::ignore},
-    {"glXQueryGLXPbufferSGIX", &retrace::ignore},
-    {"glXQueryMaxSwapBarriersSGIX", &retrace::ignore},
-    {"glXQueryMaxSwapGroupsNV", &retrace::ignore},
-    {"glXQueryServerString", &retrace::ignore},
-    {"glXQuerySwapGroupNV", &retrace::ignore},
-    {"glXQueryVersion", &retrace::ignore},
-    //{"glXReleaseBuffersMESA", &retrace_glXReleaseBuffersMESA},
-    //{"glXReleaseTexImageEXT", &retrace_glXReleaseTexImageEXT},
-    //{"glXResetFrameCountNV", &retrace_glXResetFrameCountNV},
-    //{"glXSelectEvent", &retrace_glXSelectEvent},
-    //{"glXSelectEventSGIX", &retrace_glXSelectEventSGIX},
-    //{"glXSet3DfxModeMESA", &retrace_glXSet3DfxModeMESA},
-    //{"glXSwapBuffersMscOML", &retrace_glXSwapBuffersMscOML},
-    {"glXSwapBuffers", &retrace_glXSwapBuffers},
-    //{"glXSwapIntervalEXT", &retrace_glXSwapIntervalEXT},
-    //{"glXSwapIntervalSGI", &retrace_glXSwapIntervalSGI},
-    //{"glXUseXFont", &retrace_glXUseXFont},
-    {"glXWaitForMscOML", &retrace::ignore},
-    {"glXWaitForSbcOML", &retrace::ignore},
-    {"glXWaitGL", &retrace::ignore},
-    {"glXWaitVideoSyncSGI", &retrace::ignore},
-    {"glXWaitX", &retrace::ignore},
-    {NULL, NULL},
-};
-
diff --git a/glretrace_main.cpp b/glretrace_main.cpp
deleted file mode 100644 (file)
index 785d6fe..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <string.h>
-
-#include "os_string.hpp"
-#include "os_time.hpp"
-#include "image.hpp"
-#include "retrace.hpp"
-#include "trace_callset.hpp"
-#include "glproc.hpp"
-#include "glstate.hpp"
-#include "glretrace.hpp"
-
-
-namespace glretrace {
-
-bool double_buffer = true;
-bool insideGlBeginEnd = false;
-trace::Parser parser;
-glws::Profile defaultProfile = glws::PROFILE_COMPAT;
-glws::Visual *visual[glws::PROFILE_MAX];
-glws::Drawable *drawable = NULL;
-glws::Context *context = NULL;
-
-unsigned frame = 0;
-long long startTime = 0;
-bool wait = false;
-
-bool benchmark = false;
-static const char *compare_prefix = NULL;
-static const char *snapshot_prefix = NULL;
-static trace::CallSet snapshot_frequency;
-static trace::CallSet compare_frequency;
-
-unsigned dump_state = ~0;
-
-void
-checkGlError(trace::Call &call) {
-    GLenum error = glGetError();
-    if (error == GL_NO_ERROR) {
-        return;
-    }
-
-    std::ostream & os = retrace::warning(call);
-
-    os << "glGetError(";
-    os << call.name();
-    os << ") = ";
-
-    switch (error) {
-    case GL_INVALID_ENUM:
-        os << "GL_INVALID_ENUM";
-        break;
-    case GL_INVALID_VALUE:
-        os << "GL_INVALID_VALUE";
-        break;
-    case GL_INVALID_OPERATION:
-        os << "GL_INVALID_OPERATION";
-        break;
-    case GL_STACK_OVERFLOW:
-        os << "GL_STACK_OVERFLOW";
-        break;
-    case GL_STACK_UNDERFLOW:
-        os << "GL_STACK_UNDERFLOW";
-        break;
-    case GL_OUT_OF_MEMORY:
-        os << "GL_OUT_OF_MEMORY";
-        break;
-    case GL_INVALID_FRAMEBUFFER_OPERATION:
-        os << "GL_INVALID_FRAMEBUFFER_OPERATION";
-        break;
-    case GL_TABLE_TOO_LARGE:
-        os << "GL_TABLE_TOO_LARGE";
-        break;
-    default:
-        os << error;
-        break;
-    }
-    os << "\n";
-}
-
-/**
- * Grow the current drawble.
- *
- * We need to infer the drawable size from GL calls because the drawable sizes
- * are specified by OS specific calls which we do not trace.
- */
-void
-updateDrawable(int width, int height) {
-    if (!drawable) {
-        return;
-    }
-
-    if (drawable->visible &&
-        width  <= drawable->width &&
-        height <= drawable->height) {
-        return;
-    }
-
-    // Ignore zero area viewports
-    if (width == 0 || height == 0) {
-        return;
-    }
-
-    // Check for bound framebuffer last, as this may have a performance impact.
-    GLint draw_framebuffer = 0;
-    glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer);
-    if (draw_framebuffer != 0) {
-        return;
-    }
-
-    drawable->resize(width, height);
-    drawable->show();
-
-    glScissor(0, 0, width, height);
-}
-
-
-static void
-snapshot(unsigned call_no) {
-    assert(snapshot_prefix || compare_prefix);
-
-    if (!drawable) {
-        return;
-    }
-
-    image::Image *ref = NULL;
-
-    if (compare_prefix) {
-        os::String filename = os::String::format("%s%010u.png", compare_prefix, call_no);
-        ref = image::readPNG(filename);
-        if (!ref) {
-            return;
-        }
-        if (retrace::verbosity >= 0) {
-            std::cout << "Read " << filename << "\n";
-        }
-    }
-
-    image::Image *src = glstate::getDrawBufferImage();
-    if (!src) {
-        return;
-    }
-
-    if (snapshot_prefix) {
-        if (snapshot_prefix[0] == '-' && snapshot_prefix[1] == 0) {
-            char comment[21];
-            snprintf(comment, sizeof comment, "%u", call_no);
-            src->writePNM(std::cout, comment);
-        } else {
-            os::String filename = os::String::format("%s%010u.png", snapshot_prefix, call_no);
-            if (src->writePNG(filename) && retrace::verbosity >= 0) {
-                std::cout << "Wrote " << filename << "\n";
-            }
-        }
-    }
-
-    if (ref) {
-        std::cout << "Snapshot " << call_no << " average precision of " << src->compare(*ref) << " bits\n";
-        delete ref;
-    }
-
-    delete src;
-}
-
-
-void frame_complete(trace::Call &call) {
-    ++frame;
-
-    if (!drawable) {
-        return;
-    }
-
-    if (!drawable->visible) {
-        retrace::warning(call) << "could not infer drawable size (glViewport never called)\n";
-    }
-}
-
-
-static void display(void) {
-    retrace::Retracer retracer;
-
-    retracer.addCallbacks(gl_callbacks);
-    retracer.addCallbacks(glx_callbacks);
-    retracer.addCallbacks(wgl_callbacks);
-    retracer.addCallbacks(cgl_callbacks);
-    retracer.addCallbacks(egl_callbacks);
-
-    startTime = os::getTime();
-    trace::Call *call;
-
-    while ((call = parser.parse_call())) {
-        bool swapRenderTarget = call->flags & trace::CALL_FLAG_SWAP_RENDERTARGET;
-        bool doSnapshot =
-            snapshot_frequency.contains(*call) ||
-            compare_frequency.contains(*call)
-        ;
-
-        // For calls which cause rendertargets to be swaped, we take the
-        // snapshot _before_ swapping the rendertargets.
-        if (doSnapshot && swapRenderTarget) {
-            if (call->flags & trace::CALL_FLAG_END_FRAME) {
-                // For swapbuffers/presents we still use this call number,
-                // spite not have been executed yet.
-                snapshot(call->no);
-            } else {
-                // Whereas for ordinate fbo/rendertarget changes we use the
-                // previous call's number.
-                snapshot(call->no - 1);
-            }
-        }
-
-        retracer.retrace(*call);
-
-        if (doSnapshot && !swapRenderTarget) {
-            snapshot(call->no);
-        }
-
-        if (!insideGlBeginEnd &&
-            drawable && context &&
-            call->no >= dump_state) {
-            glstate::dumpCurrentContext(std::cout);
-            exit(0);
-        }
-
-        delete call;
-    }
-
-    // Reached the end of trace
-    glFlush();
-
-    long long endTime = os::getTime();
-    float timeInterval = (endTime - startTime) * (1.0 / os::timeFrequency);
-
-    if ((retrace::verbosity >= -1) || (retrace::profiling)) {
-        std::cout << 
-            "Rendered " << frame << " frames"
-            " in " <<  timeInterval << " secs,"
-            " average of " << (frame/timeInterval) << " fps\n";
-    }
-
-    if (wait) {
-        while (glws::processEvents()) {}
-    } else {
-        exit(0);
-    }
-}
-
-
-static void usage(void) {
-    std::cout << 
-        "Usage: glretrace [OPTION] TRACE\n"
-        "Replay TRACE.\n"
-        "\n"
-        "  -b           benchmark mode (no error checking or warning messages)\n"
-        "  -p           profiling mode (run whole trace, dump profiling info)\n"
-        "  -c PREFIX    compare against snapshots\n"
-        "  -C CALLSET   calls to compare (default is every frame)\n"
-        "  -core        use core profile\n"
-        "  -db          use a double buffer visual (default)\n"
-        "  -sb          use a single buffer visual\n"
-        "  -s PREFIX    take snapshots; `-` for PNM stdout output\n"
-        "  -S CALLSET   calls to snapshot (default is every frame)\n"
-        "  -v           increase output verbosity\n"
-        "  -D CALLNO    dump state at specific call no\n"
-        "  -w           wait on final frame\n";
-}
-
-extern "C"
-int main(int argc, char **argv)
-{
-    assert(compare_frequency.empty());
-    assert(snapshot_frequency.empty());
-
-    int i;
-    for (i = 1; i < argc; ++i) {
-        const char *arg = argv[i];
-
-        if (arg[0] != '-') {
-            break;
-        }
-
-        if (!strcmp(arg, "--")) {
-            break;
-        } else if (!strcmp(arg, "-b")) {
-            benchmark = true;
-            retrace::verbosity = -1;
-            glws::debug = false;
-        } else if (!strcmp(arg, "-p")) {
-            retrace::profiling = true;
-            retrace::verbosity = -1;
-            glws::debug = false;
-        } else if (!strcmp(arg, "-c")) {
-            compare_prefix = argv[++i];
-            if (compare_frequency.empty()) {
-                compare_frequency = trace::CallSet(trace::FREQUENCY_FRAME);
-            }
-        } else if (!strcmp(arg, "-C")) {
-            compare_frequency = trace::CallSet(argv[++i]);
-            if (compare_prefix == NULL) {
-                compare_prefix = "";
-            }
-        } else if (!strcmp(arg, "-D")) {
-            dump_state = atoi(argv[++i]);
-            retrace::verbosity = -2;
-        } else if (!strcmp(arg, "-core")) {
-            defaultProfile = glws::PROFILE_CORE;
-        } else if (!strcmp(arg, "-db")) {
-            double_buffer = true;
-        } else if (!strcmp(arg, "-sb")) {
-            double_buffer = false;
-        } else if (!strcmp(arg, "--help")) {
-            usage();
-            return 0;
-        } else if (!strcmp(arg, "-s")) {
-            snapshot_prefix = argv[++i];
-            if (snapshot_frequency.empty()) {
-                snapshot_frequency = trace::CallSet(trace::FREQUENCY_FRAME);
-            }
-            if (snapshot_prefix[0] == '-' && snapshot_prefix[1] == 0) {
-                retrace::verbosity = -2;
-            }
-        } else if (!strcmp(arg, "-S")) {
-            snapshot_frequency = trace::CallSet(argv[++i]);
-            if (snapshot_prefix == NULL) {
-                snapshot_prefix = "";
-            }
-        } else if (!strcmp(arg, "-v")) {
-            ++retrace::verbosity;
-        } else if (!strcmp(arg, "-w")) {
-            wait = true;
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
-            usage();
-            return 1;
-        }
-    }
-
-    glws::init();
-    visual[glws::PROFILE_COMPAT] = glws::createVisual(double_buffer, glws::PROFILE_COMPAT);
-    visual[glws::PROFILE_CORE] = glws::createVisual(double_buffer, glws::PROFILE_CORE);
-    visual[glws::PROFILE_ES1] = glws::createVisual(double_buffer, glws::PROFILE_ES1);
-    visual[glws::PROFILE_ES2] = glws::createVisual(double_buffer, glws::PROFILE_ES2);
-
-    for ( ; i < argc; ++i) {
-        if (!parser.open(argv[i])) {
-            std::cerr << "error: failed to open " << argv[i] << "\n";
-            return 1;
-        }
-
-        display();
-
-        parser.close();
-    }
-
-    for (int n = 0; n < glws::PROFILE_MAX; n++) {
-        delete visual[n];
-    }
-
-    glws::cleanup();
-
-    return 0;
-}
-
-} /* namespace glretrace */
diff --git a/glretrace_wgl.cpp b/glretrace_wgl.cpp
deleted file mode 100644 (file)
index 447d177..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "glproc.hpp"
-#include "retrace.hpp"
-#include "glretrace.hpp"
-
-
-using namespace glretrace;
-
-
-typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
-typedef std::map<unsigned long long, glws::Context *> ContextMap;
-static DrawableMap drawable_map;
-static DrawableMap pbuffer_map;
-static ContextMap context_map;
-
-
-static glws::Drawable *
-getDrawable(unsigned long long hdc) {
-    if (hdc == 0) {
-        return NULL;
-    }
-
-    DrawableMap::const_iterator it;
-    it = drawable_map.find(hdc);
-    if (it == drawable_map.end()) {
-        return (drawable_map[hdc] = glws::createDrawable(visual[glretrace::defaultProfile]));
-    }
-
-    return it->second;
-}
-
-static void retrace_wglCreateContext(trace::Call &call) {
-    unsigned long long orig_context = call.ret->toUIntPtr();
-    glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], NULL, glretrace::defaultProfile);
-    context_map[orig_context] = context;
-}
-
-static void retrace_wglDeleteContext(trace::Call &call) {
-}
-
-static void retrace_wglMakeCurrent(trace::Call &call) {
-    if (drawable && context) {
-        glFlush();
-        if (!double_buffer) {
-            frame_complete(call);
-        }
-    }
-    
-    glws::Drawable *new_drawable = getDrawable(call.arg(0).toUIntPtr());
-    glws::Context *new_context = context_map[call.arg(1).toUIntPtr()];
-
-    bool result = glws::makeCurrent(new_drawable, new_context);
-
-    if (new_drawable && new_context && result) {
-        drawable = new_drawable;
-        context = new_context;
-    } else {
-        drawable = NULL;
-        context = NULL;
-    }
-}
-
-static void retrace_wglCopyContext(trace::Call &call) {
-}
-
-static void retrace_wglChoosePixelFormat(trace::Call &call) {
-}
-
-static void retrace_wglDescribePixelFormat(trace::Call &call) {
-}
-
-static void retrace_wglSetPixelFormat(trace::Call &call) {
-}
-
-static void retrace_wglSwapBuffers(trace::Call &call) {
-    frame_complete(call);
-    if (double_buffer) {
-        drawable->swapBuffers();
-    } else {
-        glFlush();
-    }
-}
-
-static void retrace_wglShareLists(trace::Call &call) {
-    unsigned long long hglrc1 = call.arg(0).toUIntPtr();
-    unsigned long long hglrc2 = call.arg(1).toUIntPtr();
-
-    glws::Context *share_context = context_map[hglrc1];
-    glws::Context *old_context = context_map[hglrc2];
-
-    glws::Context *new_context =
-        glws::createContext(old_context->visual, share_context, glretrace::defaultProfile);
-    if (new_context) {
-        if (context == old_context) {
-            glws::makeCurrent(drawable, new_context);
-        }
-
-        context_map[hglrc2] = new_context;
-        
-        delete old_context;
-    }
-}
-
-static void retrace_wglCreateLayerContext(trace::Call &call) {
-    retrace_wglCreateContext(call);
-}
-
-static void retrace_wglDescribeLayerPlane(trace::Call &call) {
-}
-
-static void retrace_wglSetLayerPaletteEntries(trace::Call &call) {
-}
-
-static void retrace_wglRealizeLayerPalette(trace::Call &call) {
-}
-
-static void retrace_wglSwapLayerBuffers(trace::Call &call) {
-    retrace_wglSwapBuffers(call);
-}
-
-static void retrace_wglUseFontBitmapsA(trace::Call &call) {
-}
-
-static void retrace_wglUseFontBitmapsW(trace::Call &call) {
-}
-
-static void retrace_wglSwapMultipleBuffers(trace::Call &call) {
-}
-
-static void retrace_wglUseFontOutlinesA(trace::Call &call) {
-}
-
-static void retrace_wglUseFontOutlinesW(trace::Call &call) {
-}
-
-static void retrace_wglCreateBufferRegionARB(trace::Call &call) {
-}
-
-static void retrace_wglDeleteBufferRegionARB(trace::Call &call) {
-}
-
-static void retrace_wglSaveBufferRegionARB(trace::Call &call) {
-}
-
-static void retrace_wglRestoreBufferRegionARB(trace::Call &call) {
-}
-
-static void retrace_wglChoosePixelFormatARB(trace::Call &call) {
-}
-
-static void retrace_wglMakeContextCurrentARB(trace::Call &call) {
-}
-
-static void retrace_wglCreatePbufferARB(trace::Call &call) {
-    int iWidth = call.arg(2).toUInt();
-    int iHeight = call.arg(3).toUInt();
-
-    unsigned long long orig_pbuffer = call.ret->toUIntPtr();
-    glws::Drawable *drawable = glws::createDrawable(glretrace::visual[glretrace::defaultProfile]);
-
-    drawable->resize(iWidth, iHeight);
-    drawable->show();
-
-    pbuffer_map[orig_pbuffer] = drawable;
-}
-
-static void retrace_wglGetPbufferDCARB(trace::Call &call) {
-    glws::Drawable *pbuffer = pbuffer_map[call.arg(0).toUIntPtr()];
-
-    unsigned long long orig_hdc = call.ret->toUIntPtr();
-
-    drawable_map[orig_hdc] = pbuffer;
-}
-
-static void retrace_wglReleasePbufferDCARB(trace::Call &call) {
-}
-
-static void retrace_wglDestroyPbufferARB(trace::Call &call) {
-}
-
-static void retrace_wglQueryPbufferARB(trace::Call &call) {
-}
-
-static void retrace_wglBindTexImageARB(trace::Call &call) {
-}
-
-static void retrace_wglReleaseTexImageARB(trace::Call &call) {
-}
-
-static void retrace_wglSetPbufferAttribARB(trace::Call &call) {
-}
-
-static void retrace_wglCreateContextAttribsARB(trace::Call &call) {
-    unsigned long long orig_context = call.ret->toUIntPtr();
-    glws::Context *share_context = NULL;
-
-    if (call.arg(1).toPointer()) {
-        share_context = context_map[call.arg(1).toUIntPtr()];
-    }
-
-    glws::Context *context = glws::createContext(glretrace::visual[glretrace::defaultProfile], share_context, glretrace::defaultProfile);
-    context_map[orig_context] = context;
-}
-
-static void retrace_wglMakeContextCurrentEXT(trace::Call &call) {
-}
-
-static void retrace_wglChoosePixelFormatEXT(trace::Call &call) {
-}
-
-static void retrace_wglSwapIntervalEXT(trace::Call &call) {
-}
-
-static void retrace_wglAllocateMemoryNV(trace::Call &call) {
-}
-
-static void retrace_wglFreeMemoryNV(trace::Call &call) {
-}
-
-static void retrace_glAddSwapHintRectWIN(trace::Call &call) {
-}
-
-static void retrace_wglGetProcAddress(trace::Call &call) {
-}
-
-const retrace::Entry glretrace::wgl_callbacks[] = {
-    {"glAddSwapHintRectWIN", &retrace_glAddSwapHintRectWIN},
-    {"wglAllocateMemoryNV", &retrace_wglAllocateMemoryNV},
-    {"wglBindTexImageARB", &retrace_wglBindTexImageARB},
-    {"wglChoosePixelFormat", &retrace_wglChoosePixelFormat},
-    {"wglChoosePixelFormatARB", &retrace_wglChoosePixelFormatARB},
-    {"wglChoosePixelFormatEXT", &retrace_wglChoosePixelFormatEXT},
-    {"wglCopyContext", &retrace_wglCopyContext},
-    {"wglCreateBufferRegionARB", &retrace_wglCreateBufferRegionARB},
-    {"wglCreateContext", &retrace_wglCreateContext},
-    {"wglCreateContextAttribsARB", &retrace_wglCreateContextAttribsARB},
-    {"wglCreateLayerContext", &retrace_wglCreateLayerContext},
-    {"wglCreatePbufferARB", &retrace_wglCreatePbufferARB},
-    {"wglDeleteBufferRegionARB", &retrace_wglDeleteBufferRegionARB},
-    {"wglDeleteContext", &retrace_wglDeleteContext},
-    {"wglDescribeLayerPlane", &retrace_wglDescribeLayerPlane},
-    {"wglDescribePixelFormat", &retrace_wglDescribePixelFormat},
-    {"wglDestroyPbufferARB", &retrace_wglDestroyPbufferARB},
-    {"wglFreeMemoryNV", &retrace_wglFreeMemoryNV},
-    {"wglGetCurrentContext", &retrace::ignore},
-    {"wglGetCurrentDC", &retrace::ignore},
-    {"wglGetCurrentReadDCARB", &retrace::ignore},
-    {"wglGetCurrentReadDCEXT", &retrace::ignore},
-    {"wglGetDefaultProcAddress", &retrace::ignore},
-    {"wglGetExtensionsStringARB", &retrace::ignore},
-    {"wglGetExtensionsStringEXT", &retrace::ignore},
-    {"wglGetLayerPaletteEntries", &retrace::ignore},
-    {"wglGetPbufferDCARB", &retrace_wglGetPbufferDCARB},
-    {"wglGetPixelFormat", &retrace::ignore},
-    {"wglGetPixelFormatAttribfvARB", &retrace::ignore},
-    {"wglGetPixelFormatAttribfvEXT", &retrace::ignore},
-    {"wglGetPixelFormatAttribivARB", &retrace::ignore},
-    {"wglGetPixelFormatAttribivEXT", &retrace::ignore},
-    {"wglGetProcAddress", &retrace_wglGetProcAddress},
-    {"wglGetSwapIntervalEXT", &retrace::ignore},
-    {"wglMakeContextCurrentARB", &retrace_wglMakeContextCurrentARB},
-    {"wglMakeContextCurrentEXT", &retrace_wglMakeContextCurrentEXT},
-    {"wglMakeCurrent", &retrace_wglMakeCurrent},
-    {"wglQueryPbufferARB", &retrace_wglQueryPbufferARB},
-    {"wglRealizeLayerPalette", &retrace_wglRealizeLayerPalette},
-    {"wglReleasePbufferDCARB", &retrace_wglReleasePbufferDCARB},
-    {"wglReleaseTexImageARB", &retrace_wglReleaseTexImageARB},
-    {"wglRestoreBufferRegionARB", &retrace_wglRestoreBufferRegionARB},
-    {"wglSaveBufferRegionARB", &retrace_wglSaveBufferRegionARB},
-    {"wglSetLayerPaletteEntries", &retrace_wglSetLayerPaletteEntries},
-    {"wglSetPbufferAttribARB", &retrace_wglSetPbufferAttribARB},
-    {"wglSetPixelFormat", &retrace_wglSetPixelFormat},
-    {"wglShareLists", &retrace_wglShareLists},
-    {"wglSwapBuffers", &retrace_wglSwapBuffers},
-    {"wglSwapIntervalEXT", &retrace_wglSwapIntervalEXT},
-    {"wglSwapLayerBuffers", &retrace_wglSwapLayerBuffers},
-    {"wglSwapMultipleBuffers", &retrace_wglSwapMultipleBuffers},
-    {"wglUseFontBitmapsA", &retrace_wglUseFontBitmapsA},
-    {"wglUseFontBitmapsW", &retrace_wglUseFontBitmapsW},
-    {"wglUseFontOutlinesA", &retrace_wglUseFontOutlinesA},
-    {"wglUseFontOutlinesW", &retrace_wglUseFontOutlinesW},
-    {NULL, NULL}
-};
-
diff --git a/glsize.hpp b/glsize.hpp
deleted file mode 100644 (file)
index d81cdf1..0000000
+++ /dev/null
@@ -1,786 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * Copyright 2010 VMware, Inc.
- * Copyright 2004 IBM Corporation
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- * 
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
- * AUTHORS,
- * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Auxiliary functions to compute the size of array/blob arguments, depending.
- */
-
-#ifndef _GL_SIZE_HPP_
-#define _GL_SIZE_HPP_
-
-
-#include <string.h>
-
-#include "os.hpp"
-#include "glimports.hpp"
-
-
-static inline size_t
-__gl_type_size(GLenum type)
-{
-    switch (type) {
-    case GL_BOOL:
-    case GL_BYTE:
-    case GL_UNSIGNED_BYTE:
-        return 1;
-    case GL_SHORT:
-    case GL_UNSIGNED_SHORT:
-    case GL_2_BYTES:
-    case GL_HALF_FLOAT:
-        return 2;
-    case GL_3_BYTES:
-        return 3;
-    case GL_INT:
-    case GL_UNSIGNED_INT:
-    case GL_FLOAT:
-    case GL_4_BYTES:
-    case GL_FIXED:
-        return 4;
-    case GL_DOUBLE:
-        return 8;
-    default:
-        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
-        return 0;
-    }
-}
-
-static inline void
-__gl_uniform_size(GLenum type, GLenum &elemType, GLint &numElems) {
-    switch (type) {
-    case GL_FLOAT:
-        elemType = GL_FLOAT;
-        numElems = 1;
-        break;
-    case GL_FLOAT_VEC2:
-        elemType = GL_FLOAT;
-        numElems = 2;
-        break;
-    case GL_FLOAT_VEC3:
-        elemType = GL_FLOAT;
-        numElems = 3;
-        break;
-    case GL_FLOAT_VEC4:
-        elemType = GL_FLOAT;
-        numElems = 4;
-        break;
-    case GL_DOUBLE:
-        elemType = GL_DOUBLE;
-        numElems = 1;
-        break;
-    case GL_DOUBLE_VEC2:
-        elemType = GL_DOUBLE;
-        numElems = 2;
-        break;
-    case GL_DOUBLE_VEC3:
-        elemType = GL_DOUBLE;
-        numElems = 3;
-        break;
-    case GL_DOUBLE_VEC4:
-        elemType = GL_DOUBLE;
-        numElems = 4;
-        break;
-    case GL_INT:
-        elemType = GL_INT;
-        numElems = 1;
-        break;
-    case GL_INT_VEC2:
-        elemType = GL_INT;
-        numElems = 2;
-        break;
-    case GL_INT_VEC3:
-        elemType = GL_INT;
-        numElems = 3;
-        break;
-    case GL_INT_VEC4:
-        elemType = GL_INT;
-        numElems = 4;
-        break;
-    case GL_UNSIGNED_INT:
-        elemType = GL_UNSIGNED_INT;
-        numElems = 1;
-        break;
-    case GL_UNSIGNED_INT_VEC2:
-        elemType = GL_UNSIGNED_INT;
-        numElems = 2;
-        break;
-    case GL_UNSIGNED_INT_VEC3:
-        elemType = GL_UNSIGNED_INT;
-        numElems = 3;
-        break;
-    case GL_UNSIGNED_INT_VEC4:
-        elemType = GL_UNSIGNED_INT;
-        numElems = 4;
-        break;
-    case GL_BOOL:
-        elemType = GL_BOOL;
-        numElems = 1;
-        break;
-    case GL_BOOL_VEC2:
-        elemType = GL_BOOL;
-        numElems = 2;
-        break;
-    case GL_BOOL_VEC3:
-        elemType = GL_BOOL;
-        numElems = 3;
-        break;
-    case GL_BOOL_VEC4:
-        elemType = GL_BOOL;
-        numElems = 4;
-        break;
-    case GL_FLOAT_MAT2:
-        elemType = GL_FLOAT;
-        numElems = 2*2;
-        break;
-    case GL_FLOAT_MAT3:
-        elemType = GL_FLOAT;
-        numElems = 3*3;
-        break;
-    case GL_FLOAT_MAT4:
-        elemType = GL_FLOAT;
-        numElems = 4*4;
-        break;
-    case GL_FLOAT_MAT2x3:
-        elemType = GL_FLOAT;
-        numElems = 2*3;
-        break;
-    case GL_FLOAT_MAT2x4:
-        elemType = GL_FLOAT;
-        numElems = 2*4;
-        break;
-    case GL_FLOAT_MAT3x2:
-        elemType = GL_FLOAT;
-        numElems = 3*2;
-        break;
-    case GL_FLOAT_MAT3x4:
-        elemType = GL_FLOAT;
-        numElems = 3*4;
-        break;
-    case GL_FLOAT_MAT4x2:
-        elemType = GL_FLOAT;
-        numElems = 4*2;
-        break;
-    case GL_FLOAT_MAT4x3:
-        elemType = GL_FLOAT;
-        numElems = 4*3;
-        break;
-    case GL_DOUBLE_MAT2:
-        elemType = GL_DOUBLE;
-        numElems = 2*2;
-        break;
-    case GL_DOUBLE_MAT3:
-        elemType = GL_DOUBLE;
-        numElems = 3*3;
-        break;
-    case GL_DOUBLE_MAT4:
-        elemType = GL_DOUBLE;
-        numElems = 4*4;
-        break;
-    case GL_DOUBLE_MAT2x3:
-        elemType = GL_DOUBLE;
-        numElems = 2*3;
-        break;
-    case GL_DOUBLE_MAT2x4:
-        elemType = GL_DOUBLE;
-        numElems = 2*4;
-        break;
-    case GL_DOUBLE_MAT3x2:
-        elemType = GL_DOUBLE;
-        numElems = 3*2;
-        break;
-    case GL_DOUBLE_MAT3x4:
-        elemType = GL_DOUBLE;
-        numElems = 3*4;
-        break;
-    case GL_DOUBLE_MAT4x2:
-        elemType = GL_DOUBLE;
-        numElems = 4*2;
-        break;
-    case GL_DOUBLE_MAT4x3:
-        elemType = GL_DOUBLE;
-        numElems = 4*3;
-        break;
-    case GL_SAMPLER_1D:
-    case GL_SAMPLER_2D:
-    case GL_SAMPLER_3D:
-    case GL_SAMPLER_CUBE:
-    case GL_SAMPLER_1D_SHADOW:
-    case GL_SAMPLER_2D_SHADOW:
-    case GL_SAMPLER_1D_ARRAY:
-    case GL_SAMPLER_2D_ARRAY:
-    case GL_SAMPLER_CUBE_MAP_ARRAY:
-    case GL_SAMPLER_1D_ARRAY_SHADOW:
-    case GL_SAMPLER_2D_ARRAY_SHADOW:
-    case GL_SAMPLER_2D_MULTISAMPLE:
-    case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
-    case GL_SAMPLER_CUBE_SHADOW:
-    case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
-    case GL_SAMPLER_BUFFER:
-    case GL_SAMPLER_2D_RECT:
-    case GL_SAMPLER_2D_RECT_SHADOW:
-    case GL_INT_SAMPLER_1D:
-    case GL_INT_SAMPLER_2D:
-    case GL_INT_SAMPLER_3D:
-    case GL_INT_SAMPLER_CUBE:
-    case GL_INT_SAMPLER_1D_ARRAY:
-    case GL_INT_SAMPLER_2D_ARRAY:
-    case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
-    case GL_INT_SAMPLER_2D_MULTISAMPLE:
-    case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
-    case GL_INT_SAMPLER_BUFFER:
-    case GL_INT_SAMPLER_2D_RECT:
-    case GL_UNSIGNED_INT_SAMPLER_1D:
-    case GL_UNSIGNED_INT_SAMPLER_2D:
-    case GL_UNSIGNED_INT_SAMPLER_3D:
-    case GL_UNSIGNED_INT_SAMPLER_CUBE:
-    case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
-    case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
-    case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
-    case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
-    case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
-    case GL_UNSIGNED_INT_SAMPLER_BUFFER:
-    case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
-        elemType = GL_INT;
-        numElems = 1;
-        break;
-    default:
-        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
-        elemType = GL_NONE;
-        numElems = 0;
-        return;
-    }
-}
-    
-static inline size_t
-__glArrayPointer_size(GLint size, GLenum type, GLsizei stride, GLsizei maxIndex)
-{
-    size_t elementSize = size*__gl_type_size(type);
-    if (!stride) {
-        stride = (GLsizei)elementSize;
-    }
-    return stride*maxIndex + elementSize;
-}
-
-#define __glVertexPointer_size(size, type, stride, maxIndex) __glArrayPointer_size(size, type, stride, maxIndex)
-#define __glNormalPointer_size(type, stride, maxIndex) __glArrayPointer_size(3, type, stride, maxIndex)
-#define __glColorPointer_size(size, type, stride, maxIndex) __glArrayPointer_size(size, type, stride, maxIndex)
-#define __glIndexPointer_size(type, stride, maxIndex) __glArrayPointer_size(1, type, stride, maxIndex)
-#define __glTexCoordPointer_size(size, type, stride, maxIndex) __glArrayPointer_size(size, type, stride, maxIndex)
-#define __glEdgeFlagPointer_size(stride, maxIndex) __glArrayPointer_size(1, GL_BOOL, stride, maxIndex)
-#define __glFogCoordPointer_size(type, stride, maxIndex) __glArrayPointer_size(1, type, stride, maxIndex)
-#define __glSecondaryColorPointer_size(size, type, stride, maxIndex) __glArrayPointer_size(size, type, stride, maxIndex)
-#define __glVertexAttribPointer_size(size, type, normalized, stride, maxIndex) __glArrayPointer_size(size, type, stride, maxIndex)
-#define __glVertexAttribPointerARB_size(size, type, normalized, stride, maxIndex) __glArrayPointer_size(size, type, stride, maxIndex)
-#define __glVertexAttribPointerNV_size(size, type, stride, maxIndex) __glArrayPointer_size(size, type, stride, maxIndex)
-
-static inline GLuint
-__glDrawArrays_maxindex(GLint first, GLsizei count)
-{
-    if (!count) {
-        return 0;
-    }
-    return first + count - 1;
-}
-
-#define __glDrawArraysEXT_maxindex __glDrawArrays_maxindex
-
-static inline GLuint
-__glDrawElementsBaseVertex_maxindex(GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex)
-{
-    GLvoid *temp = 0;
-    GLint __element_array_buffer = 0;
-
-    if (!count) {
-        return 0;
-    }
-
-    __glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &__element_array_buffer);
-    if (__element_array_buffer) {
-        // Read indices from index buffer object
-        GLintptr offset = (GLintptr)indices;
-        GLsizeiptr size = count*__gl_type_size(type);
-        GLvoid *temp = malloc(size);
-        if (!temp) {
-            return 0;
-        }
-        memset(temp, 0, size);
-        __glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, offset, size, temp);
-        indices = temp;
-    } else {
-        if (!indices) {
-            return 0;
-        }
-    }
-
-    GLuint maxindex = 0;
-    GLsizei i;
-    if (type == GL_UNSIGNED_BYTE) {
-        const GLubyte *p = (const GLubyte *)indices;
-        for (i = 0; i < count; ++i) {
-            if (p[i] > maxindex) {
-                maxindex = p[i];
-            }
-        }
-    } else if (type == GL_UNSIGNED_SHORT) {
-        const GLushort *p = (const GLushort *)indices;
-        for (i = 0; i < count; ++i) {
-            if (p[i] > maxindex) {
-                maxindex = p[i];
-            }
-        }
-    } else if (type == GL_UNSIGNED_INT) {
-        const GLuint *p = (const GLuint *)indices;
-        for (i = 0; i < count; ++i) {
-            if (p[i] > maxindex) {
-                maxindex = p[i];
-            }
-        }
-    } else {
-        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
-    }
-
-    if (__element_array_buffer) {
-        free(temp);
-    }
-
-    maxindex += basevertex;
-
-    return maxindex;
-}
-
-#define __glDrawRangeElementsBaseVertex_maxindex(start, end, count, type, indices, basevertex) __glDrawElementsBaseVertex_maxindex(count, type, indices, basevertex)
-
-#define __glDrawElements_maxindex(count, type, indices) __glDrawElementsBaseVertex_maxindex(count, type, indices, 0);
-#define __glDrawRangeElements_maxindex(start, end, count, type, indices) __glDrawElements_maxindex(count, type, indices)
-#define __glDrawRangeElementsEXT_maxindex __glDrawRangeElements_maxindex
-
-/* FIXME take in consideration instancing */
-#define __glDrawArraysInstanced_maxindex(first, count, primcount) __glDrawArrays_maxindex(first, count)
-#define __glDrawElementsInstanced_maxindex(count, type, indices, primcount) __glDrawElements_maxindex(count, type, indices)
-#define __glDrawElementsInstancedBaseVertex_maxindex(count, type, indices, primcount, basevertex) __glDrawElementsBaseVertex_maxindex(count, type, indices, basevertex)
-#define __glDrawRangeElementsInstanced_maxindex(start, end, count, type, indices, primcount) __glDrawRangeElements_maxindex(start, end, count, type, indices)
-#define __glDrawRangeElementsInstancedBaseVertex_maxindex(start, end, count, type, indices, primcount, basevertex) __glDrawRangeElementsBaseVertex_maxindex(start, end, count, type, indices, basevertex)
-
-#define __glDrawArraysInstancedBaseInstance_maxindex(first, count, primcount, baseinstance) __glDrawArrays_maxindex(first, count)
-#define __glDrawElementsInstancedBaseInstance_maxindex(count, type, indices, primcount, baseinstance) __glDrawElements_maxindex(count, type, indices)
-#define __glDrawElementsInstancedBaseVertexBaseInstance_maxindex(count, type, indices, primcount, basevertex, baseinstance) __glDrawElementsBaseVertex_maxindex(count, type, indices, basevertex)
-
-#define __glDrawArraysInstancedARB_maxindex __glDrawArraysInstanced_maxindex
-#define __glDrawElementsInstancedARB_maxindex __glDrawElementsInstanced_maxindex
-#define __glDrawArraysInstancedEXT_maxindex __glDrawArraysInstanced_maxindex
-#define __glDrawElementsInstancedEXT_maxindex __glDrawElementsInstanced_maxindex
-
-static inline GLuint
-__glDrawArraysIndirect_maxindex(const GLvoid *indirect) {
-    os::log("apitrace: warning: %s: unsupported\n", __FUNCTION__);
-    return 0;
-}
-
-static inline GLuint
-__glDrawElementsIndirect_maxindex(GLenum type, const GLvoid *indirect) {
-    os::log("apitrace: warning: %s: unsupported\n", __FUNCTION__);
-    return 0;
-}
-
-static inline GLuint
-__glMultiDrawArrays_maxindex(const GLint *first, const GLsizei *count, GLsizei primcount) {
-    GLuint maxindex = 0;
-    for (GLsizei prim = 0; prim < primcount; ++prim) {
-        GLuint maxindex_prim = __glDrawArrays_maxindex(first[prim], count[prim]);
-        maxindex = std::max(maxindex, maxindex_prim);
-    }
-    return maxindex;
-}
-
-static inline GLuint
-__glMultiDrawElements_maxindex(const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount) {
-    GLuint maxindex = 0;
-    for (GLsizei prim = 0; prim < primcount; ++prim) {
-        GLuint maxindex_prim = __glDrawElements_maxindex(count[prim], type, indices[prim]);
-        maxindex = std::max(maxindex, maxindex_prim);
-    }
-    return maxindex;
-}
-
-static inline GLuint
-__glMultiDrawElementsBaseVertex_maxindex(const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint * basevertex) {
-    GLuint maxindex = 0;
-    for (GLsizei prim = 0; prim < primcount; ++prim) {
-        GLuint maxindex_prim = __glDrawElementsBaseVertex_maxindex(count[prim], type, indices[prim], basevertex[prim]);
-        maxindex = std::max(maxindex, maxindex_prim);
-    }
-    return maxindex;
-}
-
-#define __glMultiDrawArraysEXT_maxindex __glMultiDrawArrays_maxindex
-#define __glMultiDrawElementsEXT_maxindex __glMultiDrawElements_maxindex
-
-#define __glMultiModeDrawArraysIBM_maxindex(first, count, primcount, modestride) __glMultiDrawArrays_maxindex(first, count, primcount)
-#define __glMultiModeDrawElementsIBM_maxindex(count, type, indices, primcount, modestride) __glMultiDrawElements_maxindex(count, type, (const GLvoid **)indices, primcount)
-
-
-static inline size_t
-__glCallLists_size(GLsizei n, GLenum type)
-{
-    return n*__gl_type_size(type);
-}
-
-static inline size_t
-__glMap1d_size(GLenum target, GLint stride, GLint order)
-{
-    if (order < 1) {
-        return 0;
-    }
-
-    GLint channels;
-    switch (target) {
-    case GL_MAP1_INDEX:
-    case GL_MAP1_TEXTURE_COORD_1:
-        channels = 1;
-        break;
-    case GL_MAP1_TEXTURE_COORD_2:
-        channels = 2;
-        break;
-    case GL_MAP1_NORMAL:
-    case GL_MAP1_TEXTURE_COORD_3:
-    case GL_MAP1_VERTEX_3:
-        channels = 3;
-        break;
-    case GL_MAP1_COLOR_4:
-    case GL_MAP1_TEXTURE_COORD_4:
-    case GL_MAP1_VERTEX_4:
-        channels = 4;
-        break;
-    default:
-        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target);
-        return 0;
-    }
-
-    if (stride < channels) {
-        return 0;
-    }
-
-    return channels + stride * (order - 1);
-}
-
-#define __glMap1f_size __glMap1d_size
-
-static inline size_t
-__glMap2d_size(GLenum target, GLint ustride, GLint uorder, GLint vstride, GLint vorder)
-{
-    if (uorder < 1 || vorder < 1) {
-        return 0;
-    }
-
-    GLint channels;
-    switch (target) {
-    case GL_MAP2_INDEX:
-    case GL_MAP2_TEXTURE_COORD_1:
-        channels = 1;
-        break;
-    case GL_MAP2_TEXTURE_COORD_2:
-        channels = 2;
-        break;
-    case GL_MAP2_NORMAL:
-    case GL_MAP2_TEXTURE_COORD_3:
-    case GL_MAP2_VERTEX_3:
-        channels = 3;
-        break;
-    case GL_MAP2_COLOR_4:
-    case GL_MAP2_TEXTURE_COORD_4:
-    case GL_MAP2_VERTEX_4:
-        channels = 4;
-        break;
-    default:
-        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target);
-        return 0;
-    }
-
-    if (ustride < channels || vstride < channels) {
-        return 0;
-    }
-
-    return channels + 
-           ustride * (uorder - 1) +
-           vstride * (vorder - 1);
-}
-
-#define __glMap2f_size __glMap2d_size
-
-static inline unsigned
-__gl_format_channels(GLenum format) {
-    switch (format) {
-    case GL_COLOR_INDEX:
-    case GL_RED:
-    case GL_GREEN:
-    case GL_BLUE:
-    case GL_ALPHA:
-    case GL_INTENSITY:
-    case GL_LUMINANCE:
-    case GL_DEPTH_COMPONENT:
-    case GL_STENCIL_INDEX:
-        return 1;
-    case GL_DEPTH_STENCIL:
-    case GL_LUMINANCE_ALPHA:
-    case GL_RG:
-    case GL_HILO_NV:
-    case GL_DSDT_NV:
-        return 2;
-    case GL_RGB:
-    case GL_BGR:
-    case GL_DSDT_MAG_NV:
-        return 3;
-    case GL_RGBA:
-    case GL_BGRA:
-    case GL_ABGR_EXT:
-    case GL_CMYK_EXT:
-    case GL_DSDT_MAG_VIB_NV:
-        return 4;
-    case GL_CMYKA_EXT:
-        return 5;
-    default:
-        os::log("apitrace: warning: %s: unexpected format GLenum 0x%04X\n", __FUNCTION__, format);
-        return 0;
-    }
-}
-
-template<class X>
-static inline bool
-_is_pot(X x) {
-    return (x & (x - 1)) == 0;
-}
-
-template<class X, class Y>
-static inline X
-_align(X x, Y y) {
-    return (x + (y - 1)) & ~(y - 1);
-}
-
-static inline size_t
-__gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLboolean has_unpack_subimage) {
-    unsigned num_channels = __gl_format_channels(format);
-
-    unsigned bits_per_pixel;
-    switch (type) {
-    case GL_BITMAP:
-        bits_per_pixel = 1;
-        break;
-    case GL_BYTE:
-    case GL_UNSIGNED_BYTE:
-        bits_per_pixel = 8 * num_channels;
-        break;
-    case GL_SHORT:
-    case GL_UNSIGNED_SHORT:
-    case GL_HALF_FLOAT:
-        bits_per_pixel = 16 * num_channels;
-        break;
-    case GL_INT:
-    case GL_UNSIGNED_INT:
-    case GL_FLOAT:
-        bits_per_pixel = 32 * num_channels;
-        break;
-    case GL_UNSIGNED_BYTE_3_3_2:
-    case GL_UNSIGNED_BYTE_2_3_3_REV:
-        bits_per_pixel = 8;
-        break;
-    case GL_UNSIGNED_SHORT_4_4_4_4:
-    case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-    case GL_UNSIGNED_SHORT_5_5_5_1:
-    case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-    case GL_UNSIGNED_SHORT_5_6_5:
-    case GL_UNSIGNED_SHORT_5_6_5_REV:
-    case GL_UNSIGNED_SHORT_8_8_MESA:
-    case GL_UNSIGNED_SHORT_8_8_REV_MESA:
-        bits_per_pixel = 16;
-        break;
-    case GL_UNSIGNED_INT_8_8_8_8:
-    case GL_UNSIGNED_INT_8_8_8_8_REV:
-    case GL_UNSIGNED_INT_10_10_10_2:
-    case GL_UNSIGNED_INT_2_10_10_10_REV:
-    case GL_UNSIGNED_INT_24_8:
-    case GL_UNSIGNED_INT_10F_11F_11F_REV:
-    case GL_UNSIGNED_INT_5_9_9_9_REV:
-    case GL_UNSIGNED_INT_S8_S8_8_8_NV:
-    case GL_UNSIGNED_INT_8_8_S8_S8_REV_NV:
-        bits_per_pixel = 32;
-        break;
-    case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
-        bits_per_pixel = 64;
-        break;
-    default:
-        os::log("apitrace: warning: %s: unexpected type GLenum 0x%04X\n", __FUNCTION__, type);
-        bits_per_pixel = 0;
-        break;
-    }
-
-    GLint alignment = 4;
-    GLint row_length = 0;
-    GLint image_height = 0;
-    GLint skip_rows = 0;
-    GLint skip_pixels = 0;
-    GLint skip_images = 0;
-
-    __glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
-    if (has_unpack_subimage) {
-        __glGetIntegerv(GL_UNPACK_ROW_LENGTH,   &row_length);
-        __glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &image_height);
-        __glGetIntegerv(GL_UNPACK_SKIP_ROWS,    &skip_rows);
-        __glGetIntegerv(GL_UNPACK_SKIP_PIXELS,  &skip_pixels);
-        __glGetIntegerv(GL_UNPACK_SKIP_IMAGES,  &skip_images);
-    }
-
-    if (row_length <= 0) {
-        row_length = width;
-    }
-
-    size_t row_stride = (row_length*bits_per_pixel + 7)/8;
-
-    if ((GLint)bits_per_pixel < alignment*8 &&
-        (bits_per_pixel & 7) == 0 &&
-        _is_pot(bits_per_pixel)) {
-        row_stride = _align(row_stride, alignment);
-    }
-
-    if (image_height <= 0) {
-        image_height = height;
-    }
-
-    /* XXX: GL_UNPACK_IMAGE_HEIGHT and GL_UNPACK_SKIP_IMAGES should probably
-     * not be considered for pixel rectangles. */
-
-    size_t image_stride = image_height*row_stride;
-
-    size_t size = depth*image_stride;
-
-    size += (skip_pixels*bits_per_pixel + 7)/8;
-    size += skip_rows*row_stride;
-    size += skip_images*image_stride;
-
-    return size;
-}
-
-// note that can_unpack_subimage() is generated by gltrace.py
-#define __glTexImage3D_size(format, type, width, height, depth) __gl_image_size(format, type, width, height, depth, can_unpack_subimage())
-#define __glTexImage2D_size(format, type, width, height)        __gl_image_size(format, type, width, height, 1, can_unpack_subimage())
-#define __glTexImage1D_size(format, type, width)                __gl_image_size(format, type, width, 1, 1, can_unpack_subimage())
-
-#define __glTexSubImage3D_size(format, type, width, height, depth) __glTexImage3D_size(format, type, width, height, depth)
-#define __glTexSubImage2D_size(format, type, width, height)        __glTexImage2D_size(format, type, width, height)
-#define __glTexSubImage1D_size(format, type, width)                __glTexImage1D_size(format, type, width)
-
-#define __glTexImage3DEXT_size __glTexImage3D_size
-#define __glTexImage2DEXT_size __glTexImage2D_size
-#define __glTexImage1DEXT_size __glTexImage1D_size
-#define __glTexSubImage3DEXT_size __glTexSubImage3D_size
-#define __glTexSubImage2DEXT_size __glTexSubImage2D_size
-#define __glTexSubImage1DEXT_size __glTexSubImage1D_size
-
-#define __glTextureImage3DEXT_size __glTexImage3D_size
-#define __glTextureImage2DEXT_size __glTexImage2D_size
-#define __glTextureImage1DEXT_size __glTexImage1D_size
-#define __glTextureSubImage3DEXT_size __glTexSubImage3D_size
-#define __glTextureSubImage2DEXT_size __glTexSubImage2D_size
-#define __glTextureSubImage1DEXT_size __glTexSubImage1D_size
-
-#define __glMultiTexImage3DEXT_size __glTexImage3D_size
-#define __glMultiTexImage2DEXT_size __glTexImage2D_size
-#define __glMultiTexImage1DEXT_size __glTexImage1D_size
-#define __glMultiTexSubImage3DEXT_size __glTexSubImage3D_size
-#define __glMultiTexSubImage2DEXT_size __glTexSubImage2D_size
-#define __glMultiTexSubImage1DEXT_size __glTexSubImage1D_size
-
-#define __glDrawPixels_size(format, type, width, height) __glTexImage2D_size(format, type, width, height)
-#define __glConvolutionFilter1D_size(format, type, width) __glTexImage1D_size(format, type, width)
-#define __glConvolutionFilter2D_size(format, type, width, height) __glTexImage2D_size(format, type, width, height)
-#define __glColorTable_size(format, type, width) __glTexImage1D_size(format, type, width)
-#define __glColorSubTable_size(format, type, count) __glColorTable_size(format, type, count)
-
-#define __glBitmap_size(width, height) __glTexImage2D_size(GL_COLOR_INDEX, GL_BITMAP, width, height)
-#define __glPolygonStipple_size() __glBitmap_size(32, 32)
-
-static inline size_t
-__glClearBuffer_size(GLenum buffer)
-{
-    switch (buffer) {
-    case GL_COLOR:
-    case GL_FRONT:
-    case GL_BACK:
-    case GL_LEFT:
-    case GL_RIGHT:
-    case GL_FRONT_AND_BACK:
-        return 4;
-    case GL_DEPTH:
-    case GL_STENCIL:
-        return 1;
-    default:
-        os::log("apitrace: warning: %s: unexpected buffer GLenum 0x%04X\n", __FUNCTION__, buffer);
-        return 0;
-    }
-}
-
-/* 
- * attribute list, terminated by the given terminator.
- */
-template<class T>
-static inline size_t
-__AttribList_size(const T *pAttribList, const T terminator = static_cast<T>(0))
-{
-    size_t size = 0;
-
-    if (pAttribList) {
-        do {
-            ++size;
-        } while (*pAttribList++ != terminator);
-    }
-
-    return size;
-}
-
-
-/*
- * (key, value) attribute list, terminated by the given terminator.
- */
-template<class T>
-static inline size_t
-__AttribPairList_size(const T *pAttribList, const T terminator = static_cast<T>(0))
-{
-    size_t size = 0;
-
-    if (pAttribList) {
-        while (pAttribList[size] != terminator) {
-            size += 2;
-        }
-        // terminator also counts
-        ++size;
-    }
-
-    return size;
-}
-
-
-#endif /* _GL_SIZE_HPP_ */
diff --git a/glstate.cpp b/glstate.cpp
deleted file mode 100644 (file)
index d54764c..0000000
+++ /dev/null
@@ -1,1445 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <string.h>
-
-#include <algorithm>
-#include <iostream>
-#include <map>
-#include <sstream>
-
-#include "image.hpp"
-#include "json.hpp"
-#include "glproc.hpp"
-#include "glsize.hpp"
-#include "glstate.hpp"
-
-
-#ifdef __APPLE__
-
-#include <Carbon/Carbon.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-OSStatus CGSGetSurfaceBounds(CGSConnectionID, CGWindowID, CGSSurfaceID, CGRect *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __APPLE__ */
-
-
-namespace glstate {
-
-
-static inline void
-resetPixelPackState(void) {
-    glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
-    glPixelStorei(GL_PACK_SWAP_BYTES, GL_FALSE);
-    glPixelStorei(GL_PACK_LSB_FIRST, GL_FALSE);
-    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
-    glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
-    glPixelStorei(GL_PACK_SKIP_ROWS, 0);
-    glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
-    glPixelStorei(GL_PACK_SKIP_IMAGES, 0);
-    glPixelStorei(GL_PACK_ALIGNMENT, 1);
-    glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
-}
-
-
-static inline void
-restorePixelPackState(void) {
-    glPopClientAttrib();
-}
-
-
-// Mapping from shader type to shader source, used to accumulated the sources
-// of different shaders with same type.
-typedef std::map<std::string, std::string> ShaderMap;
-
-
-static void
-getShaderSource(ShaderMap &shaderMap, GLuint shader)
-{
-    if (!shader) {
-        return;
-    }
-
-    GLint shader_type = 0;
-    glGetShaderiv(shader, GL_SHADER_TYPE, &shader_type);
-    if (!shader_type) {
-        return;
-    }
-
-    GLint source_length = 0;
-    glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &source_length);
-    if (!source_length) {
-        return;
-    }
-
-    GLchar *source = new GLchar[source_length];
-    GLsizei length = 0;
-    source[0] = 0;
-    glGetShaderSource(shader, source_length, &length, source);
-
-    shaderMap[enumToString(shader_type)] += source;
-
-    delete [] source;
-}
-
-
-static void
-getShaderObjSource(ShaderMap &shaderMap, GLhandleARB shaderObj)
-{
-    if (!shaderObj) {
-        return;
-    }
-
-    GLint object_type = 0;
-    glGetObjectParameterivARB(shaderObj, GL_OBJECT_TYPE_ARB, &object_type);
-    if (object_type != GL_SHADER_OBJECT_ARB) {
-        return;
-    }
-
-    GLint shader_type = 0;
-    glGetObjectParameterivARB(shaderObj, GL_OBJECT_SUBTYPE_ARB, &shader_type);
-    if (!shader_type) {
-        return;
-    }
-
-    GLint source_length = 0;
-    glGetObjectParameterivARB(shaderObj, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &source_length);
-    if (!source_length) {
-        return;
-    }
-
-    GLcharARB *source = new GLcharARB[source_length];
-    GLsizei length = 0;
-    source[0] = 0;
-    glGetShaderSource(shaderObj, source_length, &length, source);
-
-    shaderMap[enumToString(shader_type)] += source;
-
-    delete [] source;
-}
-
-
-static inline void
-dumpProgram(JSONWriter &json, GLint program)
-{
-    GLint attached_shaders = 0;
-    glGetProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders);
-    if (!attached_shaders) {
-        return;
-    }
-
-    ShaderMap shaderMap;
-
-    GLuint *shaders = new GLuint[attached_shaders];
-    GLsizei count = 0;
-    glGetAttachedShaders(program, attached_shaders, &count, shaders);
-    std::sort(shaders, shaders + count);
-    for (GLsizei i = 0; i < count; ++ i) {
-       getShaderSource(shaderMap, shaders[i]);
-    }
-    delete [] shaders;
-
-    for (ShaderMap::const_iterator it = shaderMap.begin(); it != shaderMap.end(); ++it) {
-        json.beginMember(it->first);
-        json.writeString(it->second);
-        json.endMember();
-    }
-}
-
-
-static inline void
-dumpProgramObj(JSONWriter &json, GLhandleARB programObj)
-{
-    GLint attached_shaders = 0;
-    glGetObjectParameterivARB(programObj, GL_OBJECT_ATTACHED_OBJECTS_ARB, &attached_shaders);
-    if (!attached_shaders) {
-        return;
-    }
-
-    ShaderMap shaderMap;
-
-    GLhandleARB *shaderObjs = new GLhandleARB[attached_shaders];
-    GLsizei count = 0;
-    glGetAttachedObjectsARB(programObj, attached_shaders, &count, shaderObjs);
-    std::sort(shaderObjs, shaderObjs + count);
-    for (GLsizei i = 0; i < count; ++ i) {
-       getShaderObjSource(shaderMap, shaderObjs[i]);
-    }
-    delete [] shaderObjs;
-
-    for (ShaderMap::const_iterator it = shaderMap.begin(); it != shaderMap.end(); ++it) {
-        json.beginMember(it->first);
-        json.writeString(it->second);
-        json.endMember();
-    }
-}
-
-/*
- * When fetching the uniform name of an array we usually get name[0]
- * so we need to cut the trailing "[0]" in order to properly construct
- * array names later. Otherwise we endup with stuff like
- * uniformArray[0][0],
- * uniformArray[0][1],
- * instead of
- * uniformArray[0],
- * uniformArray[1].
- */
-static std::string
-resolveUniformName(const GLchar *name,  GLint size)
-{
-    std::string qualifiedName(name);
-    if (size > 1) {
-        std::string::size_type nameLength = qualifiedName.length();
-        static const char * const arrayStart = "[0]";
-        static const int arrayStartLen = 3;
-        if (qualifiedName.rfind(arrayStart) == (nameLength - arrayStartLen)) {
-            qualifiedName = qualifiedName.substr(0, nameLength - 3);
-        }
-    }
-    return qualifiedName;
-}
-
-static void
-dumpUniform(JSONWriter &json, GLint program, GLint size, GLenum type, const GLchar *name) {
-    GLenum elemType;
-    GLint numElems;
-    __gl_uniform_size(type, elemType, numElems);
-    if (elemType == GL_NONE) {
-        return;
-    }
-
-    GLfloat fvalues[4*4];
-    GLdouble dvalues[4*4];
-    GLint ivalues[4*4];
-    GLuint uivalues[4*4];
-
-    GLint i, j;
-
-    std::string qualifiedName = resolveUniformName(name, size);
-
-    for (i = 0; i < size; ++i) {
-        std::stringstream ss;
-        ss << qualifiedName;
-
-        if (size > 1) {
-            ss << '[' << i << ']';
-        }
-
-        std::string elemName = ss.str();
-
-        json.beginMember(elemName);
-
-        GLint location = glGetUniformLocation(program, elemName.c_str());
-
-        if (numElems > 1) {
-            json.beginArray();
-        }
-
-        switch (elemType) {
-        case GL_FLOAT:
-            glGetUniformfv(program, location, fvalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeNumber(fvalues[j]);
-            }
-            break;
-        case GL_DOUBLE:
-            glGetUniformdv(program, location, dvalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeNumber(dvalues[j]);
-            }
-            break;
-        case GL_INT:
-            glGetUniformiv(program, location, ivalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeNumber(ivalues[j]);
-            }
-            break;
-        case GL_UNSIGNED_INT:
-            glGetUniformuiv(program, location, uivalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeNumber(uivalues[j]);
-            }
-            break;
-        case GL_BOOL:
-            glGetUniformiv(program, location, ivalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeBool(ivalues[j]);
-            }
-            break;
-        default:
-            assert(0);
-            break;
-        }
-
-        if (numElems > 1) {
-            json.endArray();
-        }
-
-        json.endMember();
-    }
-}
-
-
-static void
-dumpUniformARB(JSONWriter &json, GLhandleARB programObj, GLint size, GLenum type, const GLchar *name) {
-
-    GLenum elemType;
-    GLint numElems;
-    __gl_uniform_size(type, elemType, numElems);
-    if (elemType == GL_NONE) {
-        return;
-    }
-
-    GLfloat fvalues[4*4];
-    GLint ivalues[4*4];
-
-    GLint i, j;
-
-    std::string qualifiedName = resolveUniformName(name, size);
-
-    for (i = 0; i < size; ++i) {
-        std::stringstream ss;
-        ss << qualifiedName;
-
-        if (size > 1) {
-            ss << '[' << i << ']';
-        }
-
-        std::string elemName = ss.str();
-
-        json.beginMember(elemName);
-
-        GLint location = glGetUniformLocationARB(programObj, elemName.c_str());
-
-        if (numElems > 1) {
-            json.beginArray();
-        }
-
-        switch (elemType) {
-        case GL_DOUBLE:
-            // glGetUniformdvARB does not exists
-        case GL_FLOAT:
-            glGetUniformfvARB(programObj, location, fvalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeNumber(fvalues[j]);
-            }
-            break;
-        case GL_UNSIGNED_INT:
-            // glGetUniformuivARB does not exists
-        case GL_INT:
-            glGetUniformivARB(programObj, location, ivalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeNumber(ivalues[j]);
-            }
-            break;
-        case GL_BOOL:
-            glGetUniformivARB(programObj, location, ivalues);
-            for (j = 0; j < numElems; ++j) {
-                json.writeBool(ivalues[j]);
-            }
-            break;
-        default:
-            assert(0);
-            break;
-        }
-
-        if (numElems > 1) {
-            json.endArray();
-        }
-
-        json.endMember();
-    }
-}
-
-
-static inline void
-dumpProgramUniforms(JSONWriter &json, GLint program)
-{
-    GLint active_uniforms = 0;
-    glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &active_uniforms);
-    if (!active_uniforms) {
-        return;
-    }
-
-    GLint active_uniform_max_length = 0;
-    glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &active_uniform_max_length);
-    GLchar *name = new GLchar[active_uniform_max_length];
-    if (!name) {
-        return;
-    }
-
-    for (GLint index = 0; index < active_uniforms; ++index) {
-        GLsizei length = 0;
-        GLint size = 0;
-        GLenum type = GL_NONE;
-        glGetActiveUniform(program, index, active_uniform_max_length, &length, &size, &type, name);
-
-        dumpUniform(json, program, size, type, name);
-    }
-
-    delete [] name;
-}
-
-
-static inline void
-dumpProgramObjUniforms(JSONWriter &json, GLhandleARB programObj)
-{
-    GLint active_uniforms = 0;
-    glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &active_uniforms);
-    if (!active_uniforms) {
-        return;
-    }
-
-    GLint active_uniform_max_length = 0;
-    glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &active_uniform_max_length);
-    GLchar *name = new GLchar[active_uniform_max_length];
-    if (!name) {
-        return;
-    }
-
-    for (GLint index = 0; index < active_uniforms; ++index) {
-        GLsizei length = 0;
-        GLint size = 0;
-        GLenum type = GL_NONE;
-        glGetActiveUniformARB(programObj, index, active_uniform_max_length, &length, &size, &type, name);
-
-        dumpUniformARB(json, programObj, size, type, name);
-    }
-
-    delete [] name;
-}
-
-
-static inline void
-dumpArbProgram(JSONWriter &json, GLenum target)
-{
-    if (!glIsEnabled(target)) {
-        return;
-    }
-
-    GLint program_length = 0;
-    glGetProgramivARB(target, GL_PROGRAM_LENGTH_ARB, &program_length);
-    if (!program_length) {
-        return;
-    }
-
-    GLchar *source = new GLchar[program_length + 1];
-    source[0] = 0;
-    glGetProgramStringARB(target, GL_PROGRAM_STRING_ARB, source);
-    source[program_length] = 0;
-
-    json.beginMember(enumToString(target));
-    json.writeString(source);
-    json.endMember();
-
-    delete [] source;
-}
-
-
-static inline void
-dumpArbProgramUniforms(JSONWriter &json, GLenum target, const char *prefix)
-{
-    if (!glIsEnabled(target)) {
-        return;
-    }
-
-    GLint program_parameters = 0;
-    glGetProgramivARB(target, GL_PROGRAM_PARAMETERS_ARB, &program_parameters);
-    if (!program_parameters) {
-        return;
-    }
-
-    GLint max_program_local_parameters = 0;
-    glGetProgramivARB(target, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &max_program_local_parameters);
-    for (GLint index = 0; index < max_program_local_parameters; ++index) {
-        GLdouble params[4] = {0, 0, 0, 0};
-        glGetProgramLocalParameterdvARB(target, index, params);
-
-        if (!params[0] && !params[1] && !params[2] && !params[3]) {
-            continue;
-        }
-
-        char name[256];
-        snprintf(name, sizeof name, "%sprogram.local[%i]", prefix, index);
-
-        json.beginMember(name);
-        json.beginArray();
-        json.writeNumber(params[0]);
-        json.writeNumber(params[1]);
-        json.writeNumber(params[2]);
-        json.writeNumber(params[3]);
-        json.endArray();
-        json.endMember();
-    }
-
-    GLint max_program_env_parameters = 0;
-    glGetProgramivARB(target, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &max_program_env_parameters);
-    for (GLint index = 0; index < max_program_env_parameters; ++index) {
-        GLdouble params[4] = {0, 0, 0, 0};
-        glGetProgramEnvParameterdvARB(target, index, params);
-
-        if (!params[0] && !params[1] && !params[2] && !params[3]) {
-            continue;
-        }
-
-        char name[256];
-        snprintf(name, sizeof name, "%sprogram.env[%i]", prefix, index);
-
-        json.beginMember(name);
-        json.beginArray();
-        json.writeNumber(params[0]);
-        json.writeNumber(params[1]);
-        json.writeNumber(params[2]);
-        json.writeNumber(params[3]);
-        json.endArray();
-        json.endMember();
-    }
-}
-
-
-static inline void
-dumpShadersUniforms(JSONWriter &json)
-{
-    GLint program = 0;
-    glGetIntegerv(GL_CURRENT_PROGRAM, &program);
-
-    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
-
-    json.beginMember("shaders");
-    json.beginObject();
-    if (program) {
-        dumpProgram(json, program);
-    } else if (programObj) {
-        dumpProgramObj(json, programObj);
-    } else {
-        dumpArbProgram(json, GL_FRAGMENT_PROGRAM_ARB);
-        dumpArbProgram(json, GL_VERTEX_PROGRAM_ARB);
-    }
-    json.endObject();
-    json.endMember(); // shaders
-
-    json.beginMember("uniforms");
-    json.beginObject();
-    if (program) {
-        dumpProgramUniforms(json, program);
-    } else if (programObj) {
-        dumpProgramObjUniforms(json, programObj);
-    } else {
-        dumpArbProgramUniforms(json, GL_FRAGMENT_PROGRAM_ARB, "fp.");
-        dumpArbProgramUniforms(json, GL_VERTEX_PROGRAM_ARB, "vp.");
-    }
-    json.endObject();
-    json.endMember(); // uniforms
-}
-
-
-static inline void
-dumpTextureImage(JSONWriter &json, GLenum target, GLint level)
-{
-    GLint width, height = 1, depth = 1;
-    GLint format;
-
-    glGetTexLevelParameteriv(target, level, GL_TEXTURE_INTERNAL_FORMAT, &format);
-
-    width = 0;
-    glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
-
-    if (target != GL_TEXTURE_1D) {
-        height = 0;
-        glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
-        if (target == GL_TEXTURE_3D) {
-            depth = 0;
-            glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
-        }
-    }
-
-    if (width <= 0 || height <= 0 || depth <= 0) {
-        return;
-    } else {
-        char label[512];
-
-        GLint active_texture = GL_TEXTURE0;
-        glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
-        snprintf(label, sizeof label, "%s, %s, level = %d",
-                 enumToString(active_texture), enumToString(target), level);
-
-        json.beginMember(label);
-
-        json.beginObject();
-
-        // Tell the GUI this is no ordinary object, but an image
-        json.writeStringMember("__class__", "image");
-
-        json.writeNumberMember("__width__", width);
-        json.writeNumberMember("__height__", height);
-        json.writeNumberMember("__depth__", depth);
-
-        json.writeStringMember("__format__", enumToString(format));
-
-        // Hardcoded for now, but we could chose types more adequate to the
-        // texture internal format
-        json.writeStringMember("__type__", "uint8");
-        json.writeBoolMember("__normalized__", true);
-        json.writeNumberMember("__channels__", 4);
-
-        GLubyte *pixels = new GLubyte[depth*width*height*4];
-
-        resetPixelPackState();
-
-        glGetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
-
-        restorePixelPackState();
-
-        json.beginMember("__data__");
-        char *pngBuffer;
-        int pngBufferSize;
-        image::writePixelsToBuffer(pixels, width, height, 4, true, &pngBuffer, &pngBufferSize);
-        json.writeBase64(pngBuffer, pngBufferSize);
-        free(pngBuffer);
-        json.endMember(); // __data__
-
-        delete [] pixels;
-        json.endObject();
-    }
-}
-
-
-static inline void
-dumpTexture(JSONWriter &json, GLenum target, GLenum binding)
-{
-    GLint texture_binding = 0;
-    glGetIntegerv(binding, &texture_binding);
-    if (!glIsEnabled(target) && !texture_binding) {
-        return;
-    }
-
-    GLint level = 0;
-    do {
-        GLint width = 0, height = 0;
-        glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
-        glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
-        if (!width || !height) {
-            break;
-        }
-
-        if (target == GL_TEXTURE_CUBE_MAP) {
-            for (int face = 0; face < 6; ++face) {
-                dumpTextureImage(json, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level);
-            }
-        } else {
-            dumpTextureImage(json, target, level);
-        }
-
-        ++level;
-    } while(true);
-}
-
-
-static inline void
-dumpTextures(JSONWriter &json)
-{
-    json.beginMember("textures");
-    json.beginObject();
-    GLint active_texture = GL_TEXTURE0;
-    glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
-    GLint max_texture_coords = 0;
-    glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);
-    GLint max_combined_texture_image_units = 0;
-    glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);
-    GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);
-    for (GLint unit = 0; unit < max_units; ++unit) {
-        GLenum texture = GL_TEXTURE0 + unit;
-        glActiveTexture(texture);
-        dumpTexture(json, GL_TEXTURE_1D, GL_TEXTURE_BINDING_1D);
-        dumpTexture(json, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D);
-        dumpTexture(json, GL_TEXTURE_3D, GL_TEXTURE_BINDING_3D);
-        dumpTexture(json, GL_TEXTURE_RECTANGLE, GL_TEXTURE_BINDING_RECTANGLE);
-        dumpTexture(json, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BINDING_CUBE_MAP);
-    }
-    glActiveTexture(active_texture);
-    json.endObject();
-    json.endMember(); // textures
-}
-
-
-static bool
-getDrawableBounds(GLint *width, GLint *height) {
-#if defined(_WIN32)
-
-    HDC hDC = wglGetCurrentDC();
-    if (!hDC) {
-        return false;
-    }
-
-    HWND hWnd = WindowFromDC(hDC);
-    RECT rect;
-
-    if (!GetClientRect(hWnd, &rect)) {
-       return false;
-    }
-
-    *width  = rect.right  - rect.left;
-    *height = rect.bottom - rect.top;
-
-#elif defined(__APPLE__)
-
-    CGLContextObj ctx = CGLGetCurrentContext();
-    if (ctx == NULL) {
-        return false;
-    }
-
-    CGSConnectionID cid;
-    CGSWindowID wid;
-    CGSSurfaceID sid;
-
-    if (CGLGetSurface(ctx, &cid, &wid, &sid) != kCGLNoError) {
-        return false;
-    }
-
-    CGRect rect;
-
-    if (CGSGetSurfaceBounds(cid, wid, sid, &rect) != 0) {
-        return false;
-    }
-
-    *width = rect.size.width;
-    *height = rect.size.height;
-
-#else
-
-#if !TRACE_EGL
-    Display *display;
-    Drawable drawable;
-    Window root;
-    int x, y;
-    unsigned int w, h, bw, depth;
-
-    display = glXGetCurrentDisplay();
-    if (!display) {
-        return false;
-    }
-
-    drawable = glXGetCurrentDrawable();
-    if (drawable == None) {
-        return false;
-    }
-
-    if (!XGetGeometry(display, drawable, &root, &x, &y, &w, &h, &bw, &depth)) {
-        return false;
-    }
-
-    *width = w;
-    *height = h;
-#else
-    return false;
-#endif
-
-#endif
-
-    return true;
-}
-
-
-static const GLenum texture_bindings[][2] = {
-    {GL_TEXTURE_1D, GL_TEXTURE_BINDING_1D},
-    {GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D},
-    {GL_TEXTURE_3D, GL_TEXTURE_BINDING_3D},
-    {GL_TEXTURE_RECTANGLE, GL_TEXTURE_BINDING_RECTANGLE},
-    {GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BINDING_CUBE_MAP}
-};
-
-
-static bool
-bindTexture(GLint texture, GLenum &target, GLint &bound_texture)
-{
-
-    for (unsigned i = 0; i < sizeof(texture_bindings)/sizeof(texture_bindings[0]); ++i) {
-        target  = texture_bindings[i][0];
-
-        GLenum binding = texture_bindings[i][1];
-
-        while (glGetError() != GL_NO_ERROR)
-            ;
-
-        glGetIntegerv(binding, &bound_texture);
-        glBindTexture(target, texture);
-
-        if (glGetError() == GL_NO_ERROR) {
-            return true;
-        }
-
-        glBindTexture(target, bound_texture);
-    }
-
-    target = GL_NONE;
-
-    return false;
-}
-
-
-static bool
-getTextureLevelSize(GLint texture, GLint level, GLint *width, GLint *height)
-{
-    *width = 0;
-    *height = 0;
-
-    GLenum target;
-    GLint bound_texture = 0;
-    if (!bindTexture(texture, target, bound_texture)) {
-        return false;
-    }
-
-    glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, width);
-    glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, height);
-
-    glBindTexture(target, bound_texture);
-
-    return *width > 0 && *height > 0;
-}
-
-
-static GLenum
-getTextureLevelFormat(GLint texture, GLint level)
-{
-    GLenum target;
-    GLint bound_texture = 0;
-    if (!bindTexture(texture, target, bound_texture)) {
-        return GL_NONE;
-    }
-
-    GLint format = GL_NONE;
-    glGetTexLevelParameteriv(target, level, GL_TEXTURE_INTERNAL_FORMAT, &format);
-
-    glBindTexture(target, bound_texture);
-
-    return format;
-}
-
-
-
-static bool
-getRenderbufferSize(GLint renderbuffer, GLint *width, GLint *height)
-{
-    GLint bound_renderbuffer = 0;
-    glGetIntegerv(GL_RENDERBUFFER_BINDING, &bound_renderbuffer);
-    glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
-
-    *width = 0;
-    *height = 0;
-    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, width);
-    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, height);
-
-    glBindRenderbuffer(GL_RENDERBUFFER, bound_renderbuffer);
-    
-    return *width > 0 && *height > 0;
-}
-
-
-static GLenum
-getRenderbufferFormat(GLint renderbuffer)
-{
-    GLint bound_renderbuffer = 0;
-    glGetIntegerv(GL_RENDERBUFFER_BINDING, &bound_renderbuffer);
-    glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
-
-    GLint format = GL_NONE;
-    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_INTERNAL_FORMAT, &format);
-
-    glBindRenderbuffer(GL_RENDERBUFFER, bound_renderbuffer);
-    
-    return format;
-}
-
-
-static bool
-getFramebufferAttachmentSize(GLenum target, GLenum attachment, GLint *width, GLint *height)
-{
-    GLint object_type = GL_NONE;
-    glGetFramebufferAttachmentParameteriv(target, attachment,
-                                          GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
-                                          &object_type);
-    if (object_type == GL_NONE) {
-        return false;
-    }
-
-    GLint object_name = 0;
-    glGetFramebufferAttachmentParameteriv(target, attachment,
-                                          GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
-                                          &object_name);
-    if (object_name == 0) {
-        return false;
-    }
-
-    if (object_type == GL_RENDERBUFFER) {
-        return getRenderbufferSize(object_name, width, height);
-    } else if (object_type == GL_TEXTURE) {
-        GLint texture_level = 0;
-        glGetFramebufferAttachmentParameteriv(target, attachment,
-                                              GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
-                                              &texture_level);
-        return getTextureLevelSize(object_name, texture_level, width, height);
-    } else {
-        std::cerr << "warning: unexpected GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = " << object_type << "\n";
-        return false;
-    }
-}
-
-
-
-static GLint
-getFramebufferAttachmentFormat(GLenum target, GLenum attachment)
-{
-    GLint object_type = GL_NONE;
-    glGetFramebufferAttachmentParameteriv(target, attachment,
-                                          GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
-                                          &object_type);
-    if (object_type == GL_NONE) {
-        return GL_NONE;
-    }
-
-    GLint object_name = 0;
-    glGetFramebufferAttachmentParameteriv(target, attachment,
-                                          GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
-                                          &object_name);
-    if (object_name == 0) {
-        return GL_NONE;
-    }
-
-    if (object_type == GL_RENDERBUFFER) {
-        return getRenderbufferFormat(object_name);
-    } else if (object_type == GL_TEXTURE) {
-        GLint texture_level = 0;
-        glGetFramebufferAttachmentParameteriv(target, attachment,
-                                              GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
-                                              &texture_level);
-        return getTextureLevelFormat(object_name, texture_level);
-    } else {
-        std::cerr << "warning: unexpected GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = " << object_type << "\n";
-        return GL_NONE;
-    }
-}
-
-
-
-image::Image *
-getDrawBufferImage() {
-    GLenum format = GL_RGB;
-    GLint channels = __gl_format_channels(format);
-    if (channels > 4) {
-        return NULL;
-    }
-
-    GLint draw_framebuffer = 0;
-    glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer);
-
-    GLint draw_buffer = GL_NONE;
-    GLint width, height;
-    if (draw_framebuffer) {
-        glGetIntegerv(GL_DRAW_BUFFER0, &draw_buffer);
-        if (draw_buffer == GL_NONE) {
-            return NULL;
-        }
-
-        if (!getFramebufferAttachmentSize(GL_DRAW_FRAMEBUFFER, draw_buffer, &width, &height)) {
-            return NULL;
-        }
-    } else {
-        glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
-        if (draw_buffer == GL_NONE) {
-            return NULL;
-        }
-
-        if (!getDrawableBounds(&width, &height)) {
-            return NULL;
-        }
-    }
-
-    image::Image *image = new image::Image(width, height, channels, true);
-    if (!image) {
-        return NULL;
-    }
-
-    while (glGetError() != GL_NO_ERROR) {}
-
-    GLint read_framebuffer = 0;
-    glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_framebuffer);
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, draw_framebuffer);
-
-    GLint read_buffer = 0;
-    glGetIntegerv(GL_READ_BUFFER, &read_buffer);
-    glReadBuffer(draw_buffer);
-
-    // TODO: reset imaging state too
-    resetPixelPackState();
-
-    glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, image->pixels);
-
-    restorePixelPackState();
-    glReadBuffer(read_buffer);
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, read_framebuffer);
-
-    GLenum error = glGetError();
-    if (error != GL_NO_ERROR) {
-        do {
-            std::cerr << "warning: " << enumToString(error) << " while getting snapshot\n";
-            error = glGetError();
-        } while(error != GL_NO_ERROR);
-        delete image;
-        return NULL;
-    }
-     
-    return image;
-}
-
-
-/**
- * Dump the image of the currently bound read buffer.
- */
-static inline void
-dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format,
-                    GLint internalFormat = GL_NONE)
-{
-    GLint channels = __gl_format_channels(format);
-
-    json.beginObject();
-
-    // Tell the GUI this is no ordinary object, but an image
-    json.writeStringMember("__class__", "image");
-
-    json.writeNumberMember("__width__", width);
-    json.writeNumberMember("__height__", height);
-    json.writeNumberMember("__depth__", 1);
-
-    json.writeStringMember("__format__", enumToString(internalFormat));
-
-    // Hardcoded for now, but we could chose types more adequate to the
-    // texture internal format
-    json.writeStringMember("__type__", "uint8");
-    json.writeBoolMember("__normalized__", true);
-    json.writeNumberMember("__channels__", channels);
-
-    GLubyte *pixels = new GLubyte[width*height*channels];
-
-    // TODO: reset imaging state too
-    resetPixelPackState();
-
-    glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, pixels);
-
-    restorePixelPackState();
-
-    json.beginMember("__data__");
-    char *pngBuffer;
-    int pngBufferSize;
-    image::writePixelsToBuffer(pixels, width, height, channels, true, &pngBuffer, &pngBufferSize);
-    //std::cerr <<" Before = "<<(width * height * channels * sizeof *pixels)
-    //          <<", after = "<<pngBufferSize << ", ratio = " << double(width * height * channels * sizeof *pixels)/pngBufferSize;
-    json.writeBase64(pngBuffer, pngBufferSize);
-    free(pngBuffer);
-    json.endMember(); // __data__
-
-    delete [] pixels;
-    json.endObject();
-}
-
-
-static inline GLuint
-downsampledFramebuffer(GLuint oldFbo, GLint drawbuffer,
-                       GLint colorRb, GLint depthRb, GLint stencilRb,
-                       GLuint *rbs, GLint *numRbs)
-{
-    GLuint fbo;
-    GLint format;
-    GLint w, h;
-
-    *numRbs = 0;
-
-    glGenFramebuffers(1, &fbo);
-    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
-
-    glBindRenderbuffer(GL_RENDERBUFFER, colorRb);
-    glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                 GL_RENDERBUFFER_WIDTH, &w);
-    glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                 GL_RENDERBUFFER_HEIGHT, &h);
-    glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                 GL_RENDERBUFFER_INTERNAL_FORMAT, &format);
-
-    glGenRenderbuffers(1, &rbs[*numRbs]);
-    glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
-    glRenderbufferStorage(GL_RENDERBUFFER, format, w, h);
-    glFramebufferRenderbuffer(GL_FRAMEBUFFER, drawbuffer,
-                              GL_RENDERBUFFER, rbs[*numRbs]);
-
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
-    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
-    glDrawBuffer(drawbuffer);
-    glReadBuffer(drawbuffer);
-    glBlitFramebuffer(0, 0, w, h, 0, 0, w, h,
-                      GL_COLOR_BUFFER_BIT, GL_NEAREST);
-    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
-    ++*numRbs;
-
-    if (stencilRb == depthRb && stencilRb) {
-        //combined depth and stencil buffer
-        glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
-        glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                     GL_RENDERBUFFER_WIDTH, &w);
-        glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                     GL_RENDERBUFFER_HEIGHT, &h);
-        glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                     GL_RENDERBUFFER_INTERNAL_FORMAT, &format);
-
-        glGenRenderbuffers(1, &rbs[*numRbs]);
-        glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
-        glRenderbufferStorage(GL_RENDERBUFFER, format, w, h);
-        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
-                                  GL_RENDERBUFFER, rbs[*numRbs]);
-        glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
-        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
-        glBlitFramebuffer(0, 0, w, h, 0, 0, w, h,
-                          GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
-        glBindFramebuffer(GL_FRAMEBUFFER, fbo);
-        ++*numRbs;
-    } else {
-        if (depthRb) {
-            glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                         GL_RENDERBUFFER_WIDTH, &w);
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                         GL_RENDERBUFFER_HEIGHT, &h);
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                         GL_RENDERBUFFER_INTERNAL_FORMAT, &format);
-
-            glGenRenderbuffers(1, &rbs[*numRbs]);
-            glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
-            glRenderbufferStorage(GL_RENDERBUFFER, format, w, h);
-            glFramebufferRenderbuffer(GL_FRAMEBUFFER,
-                                      GL_DEPTH_ATTACHMENT,
-                                      GL_RENDERBUFFER, rbs[*numRbs]);
-            glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
-            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
-            glDrawBuffer(GL_DEPTH_ATTACHMENT);
-            glReadBuffer(GL_DEPTH_ATTACHMENT);
-            glBlitFramebuffer(0, 0, w, h, 0, 0, w, h,
-                              GL_DEPTH_BUFFER_BIT, GL_NEAREST);
-            ++*numRbs;
-        }
-        if (stencilRb) {
-            glBindRenderbuffer(GL_RENDERBUFFER, stencilRb);
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                         GL_RENDERBUFFER_WIDTH, &w);
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                         GL_RENDERBUFFER_HEIGHT, &h);
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER,
-                                     GL_RENDERBUFFER_INTERNAL_FORMAT, &format);
-
-            glGenRenderbuffers(1, &rbs[*numRbs]);
-            glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
-            glRenderbufferStorage(GL_RENDERBUFFER, format, w, h);
-            glFramebufferRenderbuffer(GL_FRAMEBUFFER,
-                                      GL_STENCIL_ATTACHMENT,
-                                      GL_RENDERBUFFER, rbs[*numRbs]);
-            glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
-            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
-            glDrawBuffer(GL_STENCIL_ATTACHMENT);
-            glReadBuffer(GL_STENCIL_ATTACHMENT);
-            glBlitFramebuffer(0, 0, w, h, 0, 0, w, h,
-                              GL_STENCIL_BUFFER_BIT, GL_NEAREST);
-            ++*numRbs;
-        }
-    }
-
-    return fbo;
-}
-
-
-/**
- * Dump images of current draw drawable/window.
- */
-static void
-dumpDrawableImages(JSONWriter &json)
-{
-    GLint width, height;
-
-    if (!getDrawableBounds(&width, &height)) {
-        return;
-    }
-
-    GLint draw_buffer = GL_NONE;
-    glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
-    glReadBuffer(draw_buffer);
-
-    if (draw_buffer != GL_NONE) {
-        GLint read_buffer = GL_NONE;
-        glGetIntegerv(GL_READ_BUFFER, &read_buffer);
-
-        GLint alpha_bits = 0;
-#if 0
-        // XXX: Ignore alpha until we are able to match the traced visual
-        glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
-#endif
-        GLenum format = alpha_bits ? GL_RGBA : GL_RGB;
-        json.beginMember(enumToString(draw_buffer));
-        dumpReadBufferImage(json, width, height, format);
-        json.endMember();
-
-        glReadBuffer(read_buffer);
-    }
-
-    GLint depth_bits = 0;
-    glGetIntegerv(GL_DEPTH_BITS, &depth_bits);
-    if (depth_bits) {
-        json.beginMember("GL_DEPTH_COMPONENT");
-        dumpReadBufferImage(json, width, height, GL_DEPTH_COMPONENT);
-        json.endMember();
-    }
-
-    GLint stencil_bits = 0;
-    glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
-    if (stencil_bits) {
-        json.beginMember("GL_STENCIL_INDEX");
-        dumpReadBufferImage(json, width, height, GL_STENCIL_INDEX);
-        json.endMember();
-    }
-}
-
-
-/**
- * Dump the specified framebuffer attachment.
- *
- * In the case of a color attachment, it assumes it is already bound for read.
- */
-static void
-dumpFramebufferAttachment(JSONWriter &json, GLenum target, GLenum attachment, GLenum format)
-{
-    GLint width = 0, height = 0;
-    if (!getFramebufferAttachmentSize(target, attachment, &width, &height)) {
-        return;
-    }
-
-    GLint internalFormat = getFramebufferAttachmentFormat(target, attachment);
-
-    json.beginMember(enumToString(attachment));
-    dumpReadBufferImage(json, width, height, format, internalFormat);
-    json.endMember();
-}
-
-
-static void
-dumpFramebufferAttachments(JSONWriter &json, GLenum target)
-{
-    GLint read_framebuffer = 0;
-    glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_framebuffer);
-
-    GLint read_buffer = GL_NONE;
-    glGetIntegerv(GL_READ_BUFFER, &read_buffer);
-
-    GLint max_draw_buffers = 1;
-    glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
-    GLint max_color_attachments = 0;
-    glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
-
-    for (GLint i = 0; i < max_draw_buffers; ++i) {
-        GLint draw_buffer = GL_NONE;
-        glGetIntegerv(GL_DRAW_BUFFER0 + i, &draw_buffer);
-        if (draw_buffer != GL_NONE) {
-            glReadBuffer(draw_buffer);
-            GLint attachment;
-            if (draw_buffer >= GL_COLOR_ATTACHMENT0 && draw_buffer < GL_COLOR_ATTACHMENT0 + max_color_attachments) {
-                attachment = draw_buffer;
-            } else {
-                std::cerr << "warning: unexpected GL_DRAW_BUFFER" << i << " = " << draw_buffer << "\n";
-                attachment = GL_COLOR_ATTACHMENT0;
-            }
-            GLint alpha_size = 0;
-            glGetFramebufferAttachmentParameteriv(target, attachment,
-                                                  GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
-                                                  &alpha_size);
-            GLenum format = alpha_size ? GL_RGBA : GL_RGB;
-            dumpFramebufferAttachment(json, target, attachment, format);
-        }
-    }
-
-    glReadBuffer(read_buffer);
-
-    dumpFramebufferAttachment(json, target, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT);
-    dumpFramebufferAttachment(json, target, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX);
-
-    glBindFramebuffer(GL_READ_FRAMEBUFFER, read_framebuffer);
-}
-
-
-static void
-dumpFramebuffer(JSONWriter &json)
-{
-    json.beginMember("framebuffer");
-    json.beginObject();
-
-    GLint boundDrawFbo = 0, boundReadFbo = 0;
-    glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &boundDrawFbo);
-    glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &boundReadFbo);
-    if (!boundDrawFbo) {
-        dumpDrawableImages(json);
-    } else {
-        GLint colorRb = 0, stencilRb = 0, depthRb = 0;
-        GLint draw_buffer0 = GL_NONE;
-        glGetIntegerv(GL_DRAW_BUFFER0, &draw_buffer0);
-        bool multisample = false;
-
-        GLint boundRb = 0;
-        glGetIntegerv(GL_RENDERBUFFER_BINDING, &boundRb);
-
-        GLint object_type;
-        glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, draw_buffer0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);
-        if (object_type == GL_RENDERBUFFER) {
-            glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, draw_buffer0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &colorRb);
-            glBindRenderbuffer(GL_RENDERBUFFER, colorRb);
-            GLint samples = 0;
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
-            if (samples) {
-                multisample = true;
-            }
-        }
-
-        glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);
-        if (object_type == GL_RENDERBUFFER) {
-            glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &depthRb);
-            glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
-            GLint samples = 0;
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
-            if (samples) {
-                multisample = true;
-            }
-        }
-
-        glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);
-        if (object_type == GL_RENDERBUFFER) {
-            glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &stencilRb);
-            glBindRenderbuffer(GL_RENDERBUFFER, stencilRb);
-            GLint samples = 0;
-            glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
-            if (samples) {
-                multisample = true;
-            }
-        }
-
-        glBindRenderbuffer(GL_RENDERBUFFER, boundRb);
-
-        GLuint rbs[3];
-        GLint numRbs = 0;
-        GLuint fboCopy = 0;
-
-        if (multisample) {
-            // glReadPixels doesnt support multisampled buffers so we need
-            // to blit the fbo to a temporary one
-            fboCopy = downsampledFramebuffer(boundDrawFbo, draw_buffer0,
-                                             colorRb, depthRb, stencilRb,
-                                             rbs, &numRbs);
-        }
-
-        dumpFramebufferAttachments(json, GL_DRAW_FRAMEBUFFER);
-
-        if (multisample) {
-            glBindRenderbuffer(GL_RENDERBUFFER_BINDING, boundRb);
-            glDeleteRenderbuffers(numRbs, rbs);
-            glDeleteFramebuffers(1, &fboCopy);
-        }
-
-        glBindFramebuffer(GL_READ_FRAMEBUFFER, boundReadFbo);
-        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, boundDrawFbo);
-    }
-
-    json.endObject();
-    json.endMember(); // framebuffer
-}
-
-
-static const GLenum bindings[] = {
-    GL_DRAW_BUFFER,
-    GL_READ_BUFFER,
-    GL_PIXEL_PACK_BUFFER_BINDING,
-    GL_PIXEL_UNPACK_BUFFER_BINDING,
-    GL_TEXTURE_BINDING_1D,
-    GL_TEXTURE_BINDING_2D,
-    GL_TEXTURE_BINDING_3D,
-    GL_TEXTURE_BINDING_RECTANGLE,
-    GL_TEXTURE_BINDING_CUBE_MAP,
-    GL_DRAW_FRAMEBUFFER_BINDING,
-    GL_READ_FRAMEBUFFER_BINDING,
-    GL_RENDERBUFFER_BINDING,
-    GL_DRAW_BUFFER0,
-    GL_DRAW_BUFFER1,
-    GL_DRAW_BUFFER2,
-    GL_DRAW_BUFFER3,
-    GL_DRAW_BUFFER4,
-    GL_DRAW_BUFFER5,
-    GL_DRAW_BUFFER6,
-    GL_DRAW_BUFFER7,
-};
-
-
-#define NUM_BINDINGS sizeof(bindings)/sizeof(bindings[0])
-
-
-void dumpCurrentContext(std::ostream &os)
-{
-    JSONWriter json(os);
-
-#ifndef NDEBUG
-    GLint old_bindings[NUM_BINDINGS];
-    for (unsigned i = 0; i < NUM_BINDINGS; ++i) {
-        old_bindings[i] = 0;
-        glGetIntegerv(bindings[i], &old_bindings[i]);
-    }
-#endif
-
-    dumpParameters(json);
-    dumpShadersUniforms(json);
-    dumpTextures(json);
-    dumpFramebuffer(json);
-
-#ifndef NDEBUG
-    for (unsigned i = 0; i < NUM_BINDINGS; ++i) {
-        GLint new_binding = 0;
-        glGetIntegerv(bindings[i], &new_binding);
-        if (new_binding != old_bindings[i]) {
-            std::cerr << "warning: " << enumToString(bindings[i]) << " was clobbered\n";
-        }
-    }
-#endif
-
-}
-
-
-} /* namespace glstate */
diff --git a/glstate.hpp b/glstate.hpp
deleted file mode 100644 (file)
index 0a83a59..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _GLSTATE_HPP_
-#define _GLSTATE_HPP_
-
-
-#include <ostream>
-
-#include "glimports.hpp"
-
-
-class JSONWriter;
-
-
-namespace image {
-    class Image;
-}
-
-
-namespace glstate {
-
-
-const char *enumToString(GLenum pname);
-
-void dumpEnum(JSONWriter &json, GLenum pname);
-
-void dumpParameters(JSONWriter &json);
-
-void dumpCurrentContext(std::ostream &os);
-
-image::Image *
-getDrawBufferImage(void);
-
-
-} /* namespace glstate */
-
-
-#endif /* _GLSTATE_HPP_ */
diff --git a/glstate.py b/glstate.py
deleted file mode 100644 (file)
index 90ef5b0..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-##########################################################################
-#
-# Copyright 2011 Jose Fonseca
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-'''Generate code to dump most GL state into JSON.'''
-
-
-from specs.stdapi import *
-
-from specs.gltypes import *
-from specs.glparams import *
-
-
-texture_targets = [
-    ('GL_TEXTURE_1D', 'GL_TEXTURE_BINDING_1D'),
-    ('GL_TEXTURE_2D', 'GL_TEXTURE_BINDING_2D'),
-    ('GL_TEXTURE_3D', 'GL_TEXTURE_BINDING_3D'),
-    ('GL_TEXTURE_RECTANGLE', 'GL_TEXTURE_BINDING_RECTANGLE'),
-    ('GL_TEXTURE_CUBE_MAP', 'GL_TEXTURE_BINDING_CUBE_MAP')
-]
-
-framebuffer_targets = [
-    ('GL_DRAW_FRAMEBUFFER', 'GL_DRAW_FRAMEBUFFER_BINDING'),
-    ('GL_READ_FRAMEBUFFER', 'GL_READ_FRAMEBUFFER_BINDING'),
-]
-
-class GetInflector:
-    '''Objects that describes how to inflect.'''
-
-    reduced_types = {
-        B: I,
-        E: I,
-        I: F,
-    }
-
-    def __init__(self, radical, inflections, suffix = ''):
-        self.radical = radical
-        self.inflections = inflections
-        self.suffix = suffix
-
-    def reduced_type(self, type):
-        if type in self.inflections:
-            return type
-        if type in self.reduced_types:
-            return self.reduced_type(self.reduced_types[type])
-        raise NotImplementedError
-
-    def inflect(self, type):
-        return self.radical + self.inflection(type) + self.suffix
-
-    def inflection(self, type):
-        type = self.reduced_type(type)
-        assert type in self.inflections
-        return self.inflections[type]
-
-    def __str__(self):
-        return self.radical + self.suffix
-
-
-class StateGetter(Visitor):
-    '''Type visitor that is able to extract the state via one of the glGet*
-    functions.
-
-    It will declare any temporary variable
-    '''
-
-    def __init__(self, radical, inflections, suffix=''):
-        self.inflector = GetInflector(radical, inflections)
-        self.suffix = suffix
-
-    def iter(self):
-        for function, type, count, name in parameters:
-            inflection = self.inflector.radical + self.suffix
-            if inflection not in function.split(','):
-                continue
-            if type is X:
-                continue
-            yield type, count, name
-
-    def __call__(self, *args):
-        pname = args[-1]
-
-        for type, count, name in self.iter():
-            if name == pname:
-                if count != 1:
-                    type = Array(type, str(count))
-
-                return type, self.visit(type, args)
-
-        raise NotImplementedError
-
-    def temp_name(self, args):
-        '''Return the name of a temporary variable to hold the state.'''
-        pname = args[-1]
-
-        return pname[3:].lower()
-
-    def visitConst(self, const, args):
-        return self.visit(const.type, args)
-
-    def visitScalar(self, type, args):
-        temp_name = self.temp_name(args)
-        elem_type = self.inflector.reduced_type(type)
-        inflection = self.inflector.inflect(type)
-        if inflection.endswith('v'):
-            print '    %s %s = 0;' % (elem_type, temp_name)
-            print '    %s(%s, &%s);' % (inflection + self.suffix, ', '.join(args), temp_name)
-        else:
-            print '    %s %s = %s(%s);' % (elem_type, temp_name, inflection + self.suffix, ', '.join(args))
-        return temp_name
-
-    def visitString(self, string, args):
-        temp_name = self.temp_name(args)
-        inflection = self.inflector.inflect(string)
-        assert not inflection.endswith('v')
-        print '    %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection + self.suffix, ', '.join(args))
-        return temp_name
-
-    def visitAlias(self, alias, args):
-        return self.visitScalar(alias, args)
-
-    def visitEnum(self, enum, args):
-        return self.visit(GLint, args)
-
-    def visitBitmask(self, bitmask, args):
-        return self.visit(GLint, args)
-
-    def visitArray(self, array, args):
-        temp_name = self.temp_name(args)
-        if array.length == '1':
-            return self.visit(array.type)
-        elem_type = self.inflector.reduced_type(array.type)
-        inflection = self.inflector.inflect(array.type)
-        assert inflection.endswith('v')
-        print '    %s %s[%s + 1];' % (elem_type, temp_name, array.length)
-        print '    memset(%s, 0, %s * sizeof *%s);' % (temp_name, array.length, temp_name)
-        print '    %s[%s] = (%s)0xdeadc0de;' % (temp_name, array.length, elem_type)
-        print '    %s(%s, %s);' % (inflection + self.suffix, ', '.join(args), temp_name)
-        # Simple buffer overflow detection
-        print '    assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array.length, elem_type)
-        return temp_name
-
-    def visitOpaque(self, pointer, args):
-        temp_name = self.temp_name(args)
-        inflection = self.inflector.inflect(pointer)
-        assert inflection.endswith('v')
-        print '    GLvoid *%s;' % temp_name
-        print '    %s(%s, &%s);' % (inflection + self.suffix, ', '.join(args), temp_name)
-        return temp_name
-
-
-glGet = StateGetter('glGet', {
-    B: 'Booleanv',
-    I: 'Integerv',
-    F: 'Floatv',
-    D: 'Doublev',
-    S: 'String',
-    P: 'Pointerv',
-})
-
-glGetMaterial = StateGetter('glGetMaterial', {I: 'iv', F: 'fv'})
-glGetLight = StateGetter('glGetLight', {I: 'iv', F: 'fv'})
-glGetVertexAttrib = StateGetter('glGetVertexAttrib', {I: 'iv', F: 'fv', D: 'dv', P: 'Pointerv'})
-glGetTexParameter = StateGetter('glGetTexParameter', {I: 'iv', F: 'fv'})
-glGetTexEnv = StateGetter('glGetTexEnv', {I: 'iv', F: 'fv'})
-glGetTexLevelParameter = StateGetter('glGetTexLevelParameter', {I: 'iv', F: 'fv'})
-glGetShader = StateGetter('glGetShaderiv', {I: 'iv'})
-glGetProgram = StateGetter('glGetProgram', {I: 'iv'})
-glGetProgramARB = StateGetter('glGetProgram', {I: 'iv', F: 'fv', S: 'Stringv'}, 'ARB')
-glGetFramebufferAttachmentParameter = StateGetter('glGetFramebufferAttachmentParameter', {I: 'iv'})
-
-
-class JsonWriter(Visitor):
-    '''Type visitor that will dump a value of the specified type through the
-    JSON writer.
-    
-    It expects a previously declared JSONWriter instance named "json".'''
-
-    def visitLiteral(self, literal, instance):
-        if literal.kind == 'Bool':
-            print '    json.writeBool(%s);' % instance
-        elif literal.kind in ('SInt', 'Uint', 'Float', 'Double'):
-            print '    json.writeNumber(%s);' % instance
-        else:
-            raise NotImplementedError
-
-    def visitString(self, string, instance):
-        assert string.length is None
-        print '    json.writeString((const char *)%s);' % instance
-
-    def visitEnum(self, enum, instance):
-        if enum.expr == 'GLenum':
-            print '    dumpEnum(json, %s);' % instance
-        else:
-            print '    json.writeNumber(%s);' % instance
-
-    def visitBitmask(self, bitmask, instance):
-        raise NotImplementedError
-
-    def visitAlias(self, alias, instance):
-        self.visit(alias.type, instance)
-
-    def visitOpaque(self, opaque, instance):
-        print '    json.writeNumber((size_t)%s);' % instance
-
-    __index = 0
-
-    def visitArray(self, array, instance):
-        index = '__i%u' % JsonWriter.__index
-        JsonWriter.__index += 1
-        print '    json.beginArray();'
-        print '    for (unsigned %s = 0; %s < %s; ++%s) {' % (index, index, array.length, index)
-        self.visit(array.type, '%s[%s]' % (instance, index))
-        print '    }'
-        print '    json.endArray();'
-
-
-
-class StateDumper:
-    '''Class to generate code to dump all GL state in JSON format via
-    stdout.'''
-
-    def __init__(self):
-        pass
-
-    def dump(self):
-        print '#include <string.h>'
-        print
-        print '#include "json.hpp"'
-        print '#include "glproc.hpp"'
-        print '#include "glsize.hpp"'
-        print '#include "glstate.hpp"'
-        print
-        print 'namespace glstate {'
-        print
-
-        print 'const char *'
-        print 'enumToString(GLenum pname)'
-        print '{'
-        print '    switch (pname) {'
-        for name in GLenum.values:
-            print '    case %s:' % name
-            print '        return "%s";' % name
-        print '    default:'
-        print '        return NULL;'
-        print '    }'
-        print '}'
-        print
-
-        print 'static void'
-        print 'dumpFramebufferAttachementParameters(JSONWriter &json, GLenum target, GLenum attachment)'
-        print '{'
-        self.dump_attachment_parameters('target', 'attachment')
-        print '}'
-        print
-
-        print 'void'
-        print 'dumpEnum(JSONWriter &json, GLenum pname)'
-        print '{'
-        print '    const char *s = enumToString(pname);'
-        print '    if (s) {'
-        print '        json.writeString(s);'
-        print '    } else {'
-        print '        json.writeNumber(pname);'
-        print '    }'
-        print '}'
-        print
-
-        print 'void dumpParameters(JSONWriter &json)'
-        print '{'
-        print '    json.beginMember("parameters");'
-        print '    json.beginObject();'
-        
-        self.dump_atoms(glGet)
-        
-        self.dump_material_params()
-        self.dump_light_params()
-        self.dump_vertex_attribs()
-        self.dump_program_params()
-        self.dump_texture_parameters()
-        self.dump_framebuffer_parameters()
-
-        print '    json.endObject();'
-        print '    json.endMember(); // parameters'
-        print '}'
-        print
-        
-        print '} /*namespace glstate */'
-
-    def dump_material_params(self):
-        for face in ['GL_FRONT', 'GL_BACK']:
-            print '    json.beginMember("%s");' % face
-            print '    json.beginObject();'
-            self.dump_atoms(glGetMaterial, face)
-            print '    json.endObject();'
-        print
-
-    def dump_light_params(self):
-        print '    GLint max_lights = 0;'
-        print '    __glGetIntegerv(GL_MAX_LIGHTS, &max_lights);'
-        print '    for (GLint index = 0; index < max_lights; ++index) {'
-        print '        GLenum light = GL_LIGHT0 + index;'
-        print '        if (glIsEnabled(light)) {'
-        print '            char name[32];'
-        print '            snprintf(name, sizeof name, "GL_LIGHT%i", index);'
-        print '            json.beginMember(name);'
-        print '            json.beginObject();'
-        self.dump_atoms(glGetLight, '    GL_LIGHT0 + index')
-        print '            json.endObject();'
-        print '            json.endMember(); // GL_LIGHTi'
-        print '        }'
-        print '    }'
-        print
-
-    def texenv_param_target(self, name):
-        if name == 'GL_TEXTURE_LOD_BIAS':
-           return 'GL_TEXTURE_FILTER_CONTROL'
-        elif name == 'GL_COORD_REPLACE':
-           return 'GL_POINT_SPRITE'
-        else:
-           return 'GL_TEXTURE_ENV'
-
-    def dump_texenv_params(self):
-        for target in ['GL_TEXTURE_ENV', 'GL_TEXTURE_FILTER_CONTROL', 'GL_POINT_SPRITE']:
-            print '    {'
-            print '        json.beginMember("%s");' % target
-            print '        json.beginObject();'
-            for _, _, name in glGetTexEnv.iter():
-                if self.texenv_param_target(name) == target:
-                    self.dump_atom(glGetTexEnv, target, name) 
-            print '        json.endObject();'
-            print '    }'
-
-    def dump_vertex_attribs(self):
-        print '    GLint max_vertex_attribs = 0;'
-        print '    __glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs);'
-        print '    for (GLint index = 0; index < max_vertex_attribs; ++index) {'
-        print '        char name[32];'
-        print '        snprintf(name, sizeof name, "GL_VERTEX_ATTRIB_ARRAY%i", index);'
-        print '        json.beginMember(name);'
-        print '        json.beginObject();'
-        self.dump_atoms(glGetVertexAttrib, 'index')
-        print '        json.endObject();'
-        print '        json.endMember(); // GL_VERTEX_ATTRIB_ARRAYi'
-        print '    }'
-        print
-
-    program_targets = [
-        'GL_FRAGMENT_PROGRAM_ARB',
-        'GL_VERTEX_PROGRAM_ARB',
-    ]
-
-    def dump_program_params(self):
-        for target in self.program_targets:
-            print '    if (glIsEnabled(%s)) {' % target
-            print '        json.beginMember("%s");' % target
-            print '        json.beginObject();'
-            self.dump_atoms(glGetProgramARB, target)
-            print '        json.endObject();'
-            print '    }'
-
-    def dump_texture_parameters(self):
-        print '    {'
-        print '        GLint active_texture = GL_TEXTURE0;'
-        print '        glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);'
-        print '        GLint max_texture_coords = 0;'
-        print '        glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);'
-        print '        GLint max_combined_texture_image_units = 0;'
-        print '        glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);'
-        print '        GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);'
-        print '        for (GLint unit = 0; unit < max_units; ++unit) {'
-        print '            char name[32];'
-        print '            snprintf(name, sizeof name, "GL_TEXTURE%i", unit);'
-        print '            json.beginMember(name);'
-        print '            glActiveTexture(GL_TEXTURE0 + unit);'
-        print '            json.beginObject();'
-        print '            GLboolean enabled;'
-        print '            GLint binding;'
-        print
-        for target, binding in texture_targets:
-            print '            // %s' % target
-            print '            enabled = GL_FALSE;'
-            print '            glGetBooleanv(%s, &enabled);' % target
-            print '            json.writeBoolMember("%s", enabled);' % target
-            print '            binding = 0;'
-            print '            glGetIntegerv(%s, &binding);' % binding
-            print '            json.writeNumberMember("%s", binding);' % binding
-            print '            if (enabled || binding) {'
-            print '                json.beginMember("%s");' % target
-            print '                json.beginObject();'
-            self.dump_atoms(glGetTexParameter, target)
-            # We only dump the first level parameters
-            self.dump_atoms(glGetTexLevelParameter, target, "0")
-            print '                json.endObject();'
-            print '                json.endMember(); // %s' % target
-            print '            }'
-            print
-        print '            if (unit < max_texture_coords) {'
-        self.dump_texenv_params()
-        print '            }'
-        print '            json.endObject();'
-        print '            json.endMember(); // GL_TEXTUREi'
-        print '        }'
-        print '        glActiveTexture(active_texture);'
-        print '    }'
-        print
-
-    def dump_framebuffer_parameters(self):
-        print '    {'
-        print '        GLint max_color_attachments = 0;'
-        print '        glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);'
-        print '        GLint framebuffer;'
-        for target, binding in framebuffer_targets:
-            print '            // %s' % target
-            print '            framebuffer = 0;'
-            print '            glGetIntegerv(%s, &framebuffer);' % binding
-            print '            if (framebuffer) {'
-            print '                json.beginMember("%s");' % target
-            print '                json.beginObject();'
-            print '                for (GLint i = 0; i < max_color_attachments; ++i) {'
-            print '                    GLint color_attachment = GL_COLOR_ATTACHMENT0 + i;'
-            print '                    dumpFramebufferAttachementParameters(json, %s, color_attachment);' % target
-            print '                }'
-            print '                dumpFramebufferAttachementParameters(json, %s, GL_DEPTH_ATTACHMENT);' % target
-            print '                dumpFramebufferAttachementParameters(json, %s, GL_STENCIL_ATTACHMENT);' % target
-            print '                json.endObject();'
-            print '                json.endMember(); // %s' % target
-            print '            }'
-            print
-        print '    }'
-        print
-
-    def dump_attachment_parameters(self, target, attachment):
-        print '            {'
-        print '                GLint object_type = GL_NONE;'
-        print '                glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);' % (target, attachment)
-        print '                if (object_type != GL_NONE) {'
-        print '                    json.beginMember(enumToString(%s));' % attachment
-        print '                    json.beginObject();'
-        self.dump_atoms(glGetFramebufferAttachmentParameter, target, attachment)
-        print '                    json.endObject();'
-        print '                    json.endMember(); // GL_x_ATTACHMENT'
-        print '                }'
-        print '            }'
-
-    def dump_atoms(self, getter, *args):
-        for _, _, name in getter.iter():
-            self.dump_atom(getter, *(args + (name,))) 
-
-    def dump_atom(self, getter, *args):
-        name = args[-1]
-
-        # Avoid crash on MacOSX
-        # XXX: The right fix would be to look at the support extensions..
-        import platform
-        if name == 'GL_SAMPLER_BINDING' and platform.system() == 'Darwin':
-            return
-
-        print '        // %s' % name
-        print '        {'
-        #print '            assert(glGetError() == GL_NO_ERROR);'
-        type, value = getter(*args)
-        print '            if (glGetError() != GL_NO_ERROR) {'
-        #print '                std::cerr << "warning: %s(%s) failed\\n";' % (inflection, name)
-        print '                while (glGetError() != GL_NO_ERROR) {}'
-        print '            } else {'
-        print '                json.beginMember("%s");' % name
-        JsonWriter().visit(type, value)
-        print '                json.endMember();'
-        print '            }'
-        print '        }'
-        print
-
-
-if __name__ == '__main__':
-    StateDumper().dump()
diff --git a/gltrace.hpp b/gltrace.hpp
deleted file mode 100644 (file)
index 53c8039..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _GLTRACE_HPP_
-#define _GLTRACE_HPP_
-
-
-#include "glimports.hpp"
-
-
-namespace gltrace {
-
-
-const GLubyte *
-__glGetString_override(GLenum name);
-
-void
-__glGetIntegerv_override(GLenum pname, GLint *params);
-
-const GLubyte *
-__glGetStringi_override(GLenum name, GLuint index);
-
-
-} /* namespace gltrace */
-
-
-#endif /* _GLRETRACE_HPP_ */
diff --git a/gltrace.py b/gltrace.py
deleted file mode 100644 (file)
index d2babe4..0000000
+++ /dev/null
@@ -1,939 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""GL tracing generator."""
-
-
-import specs.stdapi as stdapi
-import specs.glapi as glapi
-import specs.glparams as glparams
-from specs.glxapi import glxapi
-from trace import Tracer
-
-
-class TypeGetter(stdapi.Visitor):
-    '''Determine which glGet*v function that matches the specified type.'''
-
-    def __init__(self, prefix = 'glGet', long_suffix = True, ext_suffix = ''):
-        self.prefix = prefix
-        self.long_suffix = long_suffix
-        self.ext_suffix = ext_suffix
-
-    def visitConst(self, const):
-        return self.visit(const.type)
-
-    def visitAlias(self, alias):
-        if alias.expr == 'GLboolean':
-            if self.long_suffix:
-                suffix = 'Booleanv'
-                arg_type = alias.expr
-            else:
-                suffix = 'iv'
-                arg_type = 'GLint'
-        elif alias.expr == 'GLdouble':
-            if self.long_suffix:
-                suffix = 'Doublev'
-                arg_type = alias.expr
-            else:
-                suffix = 'dv'
-                arg_type = alias.expr
-        elif alias.expr == 'GLfloat':
-            if self.long_suffix:
-                suffix = 'Floatv'
-                arg_type = alias.expr
-            else:
-                suffix = 'fv'
-                arg_type = alias.expr
-        elif alias.expr in ('GLint', 'GLuint', 'GLsizei'):
-            if self.long_suffix:
-                suffix = 'Integerv'
-                arg_type = 'GLint'
-            else:
-                suffix = 'iv'
-                arg_type = 'GLint'
-        else:
-            print alias.expr
-            assert False
-        function_name = self.prefix + suffix + self.ext_suffix
-        return function_name, arg_type
-    
-    def visitEnum(self, enum):
-        return self.visit(glapi.GLint)
-
-    def visitBitmask(self, bitmask):
-        return self.visit(glapi.GLint)
-
-    def visitOpaque(self, pointer):
-        return self.prefix + 'Pointerv' + self.ext_suffix, 'GLvoid *'
-
-
-class GlTracer(Tracer):
-
-    arrays = [
-        ("Vertex", "VERTEX"),
-        ("Normal", "NORMAL"),
-        ("Color", "COLOR"),
-        ("Index", "INDEX"),
-        ("TexCoord", "TEXTURE_COORD"),
-        ("EdgeFlag", "EDGE_FLAG"),
-        ("FogCoord", "FOG_COORD"),
-        ("SecondaryColor", "SECONDARY_COLOR"),
-    ]
-    arrays.reverse()
-
-    # arrays available in PROFILE_ES1
-    arrays_es1 = ("Vertex", "Normal", "Color", "TexCoord")
-
-    def header(self, api):
-        Tracer.header(self, api)
-
-        print '#include "gltrace.hpp"'
-        print
-        print 'enum tracer_context_profile {'
-        print '    PROFILE_COMPAT,'
-        print '    PROFILE_ES1,'
-        print '    PROFILE_ES2,'
-        print '};'
-        print
-        print 'struct tracer_context {'
-        print '    enum tracer_context_profile profile;'
-        print '    bool user_arrays;'
-        print '    bool user_arrays_arb;'
-        print '    bool user_arrays_nv;'
-        print '};'
-        print
-        
-        # Which glVertexAttrib* variant to use
-        print 'enum vertex_attrib {'
-        print '    VERTEX_ATTRIB,'
-        print '    VERTEX_ATTRIB_ARB,'
-        print '    VERTEX_ATTRIB_NV,'
-        print '};'
-        print
-        print 'static tracer_context *__get_context(void)'
-        print '{'
-        print '    // TODO return the context set by other APIs (GLX, EGL, and etc.)'
-        print '    static tracer_context __ctx = { PROFILE_COMPAT, false, false, false };'
-        print '    return &__ctx;'
-        print '}'
-        print
-        print 'static vertex_attrib __get_vertex_attrib(void) {'
-        print '    tracer_context *ctx = __get_context();'
-        print '    if (ctx->user_arrays_arb || ctx->user_arrays_nv) {'
-        print '        GLboolean __vertex_program = GL_FALSE;'
-        print '        __glGetBooleanv(GL_VERTEX_PROGRAM_ARB, &__vertex_program);'
-        print '        if (__vertex_program) {'
-        print '            if (ctx->user_arrays_nv) {'
-        print '                GLint __vertex_program_binding_nv = 0;'
-        print '                __glGetIntegerv(GL_VERTEX_PROGRAM_BINDING_NV, &__vertex_program_binding_nv);'
-        print '                if (__vertex_program_binding_nv) {'
-        print '                    return VERTEX_ATTRIB_NV;'
-        print '                }'
-        print '            }'
-        print '            return VERTEX_ATTRIB_ARB;'
-        print '        }'
-        print '    }'
-        print '    return VERTEX_ATTRIB;'
-        print '}'
-        print
-
-        # Whether we need user arrays
-        print 'static inline bool __need_user_arrays(void)'
-        print '{'
-        print '    tracer_context *ctx = __get_context();'
-        print '    if (!ctx->user_arrays) {'
-        print '        return false;'
-        print '    }'
-        print
-
-        for camelcase_name, uppercase_name in self.arrays:
-            # in which profile is the array available?
-            profile_check = 'ctx->profile == PROFILE_COMPAT'
-            if camelcase_name in self.arrays_es1:
-                profile_check = '(' + profile_check + ' || ctx->profile == PROFILE_ES1)';
-
-            function_name = 'gl%sPointer' % camelcase_name
-            enable_name = 'GL_%s_ARRAY' % uppercase_name
-            binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name
-            print '    // %s' % function_name
-            print '  if (%s) {' % profile_check
-            self.array_prolog(api, uppercase_name)
-            print '    if (__glIsEnabled(%s)) {' % enable_name
-            print '        GLint __binding = 0;'
-            print '        __glGetIntegerv(%s, &__binding);' % binding_name
-            print '        if (!__binding) {'
-            self.array_cleanup(api, uppercase_name)
-            print '            return true;'
-            print '        }'
-            print '    }'
-            self.array_epilog(api, uppercase_name)
-            print '  }'
-            print
-
-        print '    // ES1 does not support generic vertex attributes'
-        print '    if (ctx->profile == PROFILE_ES1)'
-        print '        return false;'
-        print
-        print '    vertex_attrib __vertex_attrib = __get_vertex_attrib();'
-        print
-        print '    // glVertexAttribPointer'
-        print '    if (__vertex_attrib == VERTEX_ATTRIB) {'
-        print '        GLint __max_vertex_attribs = 0;'
-        print '        __glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &__max_vertex_attribs);'
-        print '        for (GLint index = 0; index < __max_vertex_attribs; ++index) {'
-        print '            GLint __enabled = 0;'
-        print '            __glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &__enabled);'
-        print '            if (__enabled) {'
-        print '                GLint __binding = 0;'
-        print '                __glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &__binding);'
-        print '                if (!__binding) {'
-        print '                    return true;'
-        print '                }'
-        print '            }'
-        print '        }'
-        print '    }'
-        print
-        print '    // glVertexAttribPointerARB'
-        print '    if (__vertex_attrib == VERTEX_ATTRIB_ARB) {'
-        print '        GLint __max_vertex_attribs = 0;'
-        print '        __glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &__max_vertex_attribs);'
-        print '        for (GLint index = 0; index < __max_vertex_attribs; ++index) {'
-        print '            GLint __enabled = 0;'
-        print '            __glGetVertexAttribivARB(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB, &__enabled);'
-        print '            if (__enabled) {'
-        print '                GLint __binding = 0;'
-        print '                __glGetVertexAttribivARB(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB, &__binding);'
-        print '                if (!__binding) {'
-        print '                    return true;'
-        print '                }'
-        print '            }'
-        print '        }'
-        print '    }'
-        print
-        print '    // glVertexAttribPointerNV'
-        print '    if (__vertex_attrib == VERTEX_ATTRIB_NV) {'
-        print '        for (GLint index = 0; index < 16; ++index) {'
-        print '            GLint __enabled = 0;'
-        print '            __glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &__enabled);'
-        print '            if (__enabled) {'
-        print '                return true;'
-        print '            }'
-        print '        }'
-        print '    }'
-        print
-
-        print '    return false;'
-        print '}'
-        print
-
-        print 'static void __trace_user_arrays(GLuint maxindex);'
-        print
-
-        print 'struct buffer_mapping {'
-        print '    void *map;'
-        print '    GLint length;'
-        print '    bool write;'
-        print '    bool explicit_flush;'
-        print '};'
-        print
-        for target in self.buffer_targets:
-            print 'struct buffer_mapping __%s_mapping;' % target.lower();
-        print
-        print 'static inline struct buffer_mapping *'
-        print 'get_buffer_mapping(GLenum target) {'
-        print '    switch (target) {'
-        for target in self.buffer_targets:
-            print '    case GL_%s:' % target
-            print '        return & __%s_mapping;' % target.lower()
-        print '    default:'
-        print '        os::log("apitrace: warning: unknown buffer target 0x%04X\\n", target);'
-        print '        return NULL;'
-        print '    }'
-        print '}'
-        print
-
-        # Generate a helper function to determine whether a parameter name
-        # refers to a symbolic value or not
-        print 'static bool'
-        print 'is_symbolic_pname(GLenum pname) {'
-        print '    switch (pname) {'
-        for function, type, count, name in glparams.parameters:
-            if type is glapi.GLenum:
-                print '    case %s:' % name
-        print '        return true;'
-        print '    default:'
-        print '        return false;'
-        print '    }'
-        print '}'
-        print
-        
-        # Generate a helper function to determine whether a parameter value is
-        # potentially symbolic or not; i.e., if the value can be represented in
-        # an enum or not
-        print 'template<class T>'
-        print 'static inline bool'
-        print 'is_symbolic_param(T param) {'
-        print '    return static_cast<T>(static_cast<GLenum>(param)) == param;'
-        print '}'
-        print
-
-        # Generate a helper function to know how many elements a parameter has
-        print 'static size_t'
-        print '__gl_param_size(GLenum pname) {'
-        print '    switch (pname) {'
-        for function, type, count, name in glparams.parameters:
-            if type is not None:
-                print '    case %s: return %u;' % (name, count)
-        print '    case GL_COMPRESSED_TEXTURE_FORMATS: {'
-        print '            GLint num_compressed_texture_formats = 0;'
-        print '            __glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num_compressed_texture_formats);'
-        print '            return num_compressed_texture_formats;'
-        print '        }'
-        print '    default:'
-        print r'        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);'
-        print '        return 1;'
-        print '    }'
-        print '}'
-        print
-
-        # states such as GL_UNPACK_ROW_LENGTH are not available in GLES
-        print 'static inline bool'
-        print 'can_unpack_subimage(void) {'
-        print '    tracer_context *ctx = __get_context();'
-        print '    return (ctx->profile == PROFILE_COMPAT);'
-        print '}'
-        print
-
-    array_pointer_function_names = set((
-        "glVertexPointer",
-        "glNormalPointer",
-        "glColorPointer",
-        "glIndexPointer",
-        "glTexCoordPointer",
-        "glEdgeFlagPointer",
-        "glFogCoordPointer",
-        "glSecondaryColorPointer",
-        
-        "glInterleavedArrays",
-
-        "glVertexPointerEXT",
-        "glNormalPointerEXT",
-        "glColorPointerEXT",
-        "glIndexPointerEXT",
-        "glTexCoordPointerEXT",
-        "glEdgeFlagPointerEXT",
-        "glFogCoordPointerEXT",
-        "glSecondaryColorPointerEXT",
-
-        "glVertexAttribPointer",
-        "glVertexAttribPointerARB",
-        "glVertexAttribPointerNV",
-        "glVertexAttribIPointer",
-        "glVertexAttribIPointerEXT",
-        "glVertexAttribLPointer",
-        "glVertexAttribLPointerEXT",
-        
-        #"glMatrixIndexPointerARB",
-    ))
-
-    draw_function_names = set((
-        'glDrawArrays',
-        'glDrawElements',
-        'glDrawRangeElements',
-        'glMultiDrawArrays',
-        'glMultiDrawElements',
-        'glDrawArraysInstanced',
-        "glDrawArraysInstancedBaseInstance",
-        'glDrawElementsInstanced',
-        'glDrawArraysInstancedARB',
-        'glDrawElementsInstancedARB',
-        'glDrawElementsBaseVertex',
-        'glDrawRangeElementsBaseVertex',
-        'glDrawElementsInstancedBaseVertex',
-        "glDrawElementsInstancedBaseInstance",
-        "glDrawElementsInstancedBaseVertexBaseInstance",
-        'glMultiDrawElementsBaseVertex',
-        'glDrawArraysIndirect',
-        'glDrawElementsIndirect',
-        'glDrawArraysEXT',
-        'glDrawRangeElementsEXT',
-        'glDrawRangeElementsEXT_size',
-        'glMultiDrawArraysEXT',
-        'glMultiDrawElementsEXT',
-        'glMultiModeDrawArraysIBM',
-        'glMultiModeDrawElementsIBM',
-        'glDrawArraysInstancedEXT',
-        'glDrawElementsInstancedEXT',
-    ))
-
-    interleaved_formats = [
-         'GL_V2F',
-         'GL_V3F',
-         'GL_C4UB_V2F',
-         'GL_C4UB_V3F',
-         'GL_C3F_V3F',
-         'GL_N3F_V3F',
-         'GL_C4F_N3F_V3F',
-         'GL_T2F_V3F',
-         'GL_T4F_V4F',
-         'GL_T2F_C4UB_V3F',
-         'GL_T2F_C3F_V3F',
-         'GL_T2F_N3F_V3F',
-         'GL_T2F_C4F_N3F_V3F',
-         'GL_T4F_C4F_N3F_V4F',
-    ]
-
-    def traceFunctionImplBody(self, function):
-        # Defer tracing of user array pointers...
-        if function.name in self.array_pointer_function_names:
-            print '    GLint __array_buffer = 0;'
-            print '    __glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);'
-            print '    if (!__array_buffer) {'
-            print '        tracer_context *ctx = __get_context();'
-            print '        ctx->user_arrays = true;'
-            if function.name == "glVertexAttribPointerARB":
-                print '        ctx->user_arrays_arb = true;'
-            if function.name == "glVertexAttribPointerNV":
-                print '        ctx->user_arrays_nv = true;'
-            self.invokeFunction(function)
-
-            # And also break down glInterleavedArrays into the individual calls
-            if function.name == 'glInterleavedArrays':
-                print
-
-                # Initialize the enable flags
-                for camelcase_name, uppercase_name in self.arrays:
-                    flag_name = '__' + uppercase_name.lower()
-                    print '        GLboolean %s = GL_FALSE;' % flag_name
-                print
-
-                # Switch for the interleaved formats
-                print '        switch (format) {'
-                for format in self.interleaved_formats:
-                    print '            case %s:' % format
-                    for camelcase_name, uppercase_name in self.arrays:
-                        flag_name = '__' + uppercase_name.lower()
-                        if format.find('_' + uppercase_name[0]) >= 0:
-                            print '                %s = GL_TRUE;' % flag_name
-                    print '                break;'
-                print '            default:'
-                print '               return;'
-                print '        }'
-                print
-
-                # Emit fake glEnableClientState/glDisableClientState flags
-                for camelcase_name, uppercase_name in self.arrays:
-                    flag_name = '__' + uppercase_name.lower()
-                    enable_name = 'GL_%s_ARRAY' % uppercase_name
-
-                    # Emit a fake function
-                    print '        {'
-                    print '            static const trace::FunctionSig &__sig = %s ? __glEnableClientState_sig : __glDisableClientState_sig;' % flag_name
-                    print '            unsigned __call = trace::localWriter.beginEnter(&__sig);'
-                    print '            trace::localWriter.beginArg(0);'
-                    self.serializeValue(glapi.GLenum, enable_name)
-                    print '            trace::localWriter.endArg();'
-                    print '            trace::localWriter.endEnter();'
-                    print '            trace::localWriter.beginLeave(__call);'
-                    print '            trace::localWriter.endLeave();'
-                    print '        }'
-
-            print '        return;'
-            print '    }'
-
-        # ... to the draw calls
-        if function.name in self.draw_function_names:
-            print '    if (__need_user_arrays()) {'
-            arg_names = ', '.join([arg.name for arg in function.args[1:]])
-            print '        GLuint maxindex = __%s_maxindex(%s);' % (function.name, arg_names)
-            print '        __trace_user_arrays(maxindex);'
-            print '    }'
-        
-        # Emit a fake memcpy on buffer uploads
-        if function.name in ('glUnmapBuffer', 'glUnmapBufferARB', 'glUnmapBufferOES'):
-            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
-            print '    if (mapping && mapping->write && !mapping->explicit_flush) {'
-            self.emit_memcpy('mapping->map', 'mapping->map', 'mapping->length')
-            print '    }'
-        if function.name == 'glUnmapNamedBufferEXT':
-            print '    GLint access = 0;'
-            print '    glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_ACCESS, &access);'
-            print '    if ((access & GL_MAP_WRITE_BIT) & !(access & GL_MAP_FLUSH_EXPLICIT_BIT)) {'
-            print '        GLvoid *map = NULL;'
-            print '        glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);'
-            print '        GLint length = 0;'
-            print '        glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_MAP_LENGTH, &length);'
-            self.emit_memcpy('map', 'map', 'length')
-            print '    }'
-        if function.name in ('glFlushMappedBufferRange', 'glFlushMappedBufferRangeAPPLE'):
-            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
-            print '    if (mapping) {'
-            if function.name.endswith('APPLE'):
-                 print '        GLsizeiptr length = size;'
-                 print '        mapping->explicit_flush = true;'
-            print '        //assert(offset + length <= mapping->length);'
-            self.emit_memcpy('(char *)mapping->map + offset', '(const char *)mapping->map + offset', 'length')
-            print '    }'
-        if function.name == 'glFlushMappedNamedBufferRangeEXT':
-            print '    GLvoid *map = NULL;'
-            print '    glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);'
-            print '    if (map) {'
-            self.emit_memcpy('(char *)map + offset', '(const char *)map + offset', 'length')
-            print '    }'
-
-        # Don't leave vertex attrib locations to chance.  Instead emit fake
-        # glBindAttribLocation calls to ensure that the same locations will be
-        # used when retracing.  Trying to remap locations after the fact would
-        # be an herculian task given that vertex attrib locations appear in
-        # many entry-points, including non-shader related ones.
-        if function.name == 'glLinkProgram':
-            Tracer.invokeFunction(self, function)
-            print '    GLint active_attributes = 0;'
-            print '    __glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active_attributes);'
-            print '    for (GLint attrib = 0; attrib < active_attributes; ++attrib) {'
-            print '        GLint size = 0;'
-            print '        GLenum type = 0;'
-            print '        GLchar name[256];'
-            # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256
-            print '        __glGetActiveAttrib(program, attrib, sizeof name, NULL, &size, &type, name);'
-            print "        if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {"
-            print '            GLint location = __glGetAttribLocation(program, name);'
-            print '            if (location >= 0) {'
-            bind_function = glapi.glapi.get_function_by_name('glBindAttribLocation')
-            self.fake_call(bind_function, ['program', 'location', 'name'])
-            print '            }'
-            print '        }'
-            print '    }'
-        if function.name == 'glLinkProgramARB':
-            Tracer.invokeFunction(self, function)
-            print '    GLint active_attributes = 0;'
-            print '    __glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &active_attributes);'
-            print '    for (GLint attrib = 0; attrib < active_attributes; ++attrib) {'
-            print '        GLint size = 0;'
-            print '        GLenum type = 0;'
-            print '        GLcharARB name[256];'
-            # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256
-            print '        __glGetActiveAttribARB(programObj, attrib, sizeof name, NULL, &size, &type, name);'
-            print "        if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {"
-            print '            GLint location = __glGetAttribLocationARB(programObj, name);'
-            print '            if (location >= 0) {'
-            bind_function = glapi.glapi.get_function_by_name('glBindAttribLocationARB')
-            self.fake_call(bind_function, ['programObj', 'location', 'name'])
-            print '            }'
-            print '        }'
-            print '    }'
-
-        Tracer.traceFunctionImplBody(self, function)
-
-    gremedy_functions = [
-        'glStringMarkerGREMEDY',
-        'glFrameTerminatorGREMEDY',
-    ]
-
-    def invokeFunction(self, function):
-        if function.name in ('glLinkProgram', 'glLinkProgramARB'):
-            # These functions have been dispatched already
-            return
-
-        # We implement the GREMEDY extensions, not the driver
-        if function.name in self.gremedy_functions:
-            return
-
-        if function.name in ('glXGetProcAddress', 'glXGetProcAddressARB', 'wglGetProcAddress'):
-            if_ = 'if'
-            for gremedy_function in self.gremedy_functions:
-                print '    %s (strcmp("%s", (const char *)%s) == 0) {' % (if_, gremedy_function, function.args[0].name)
-                print '        __result = (%s)&%s;' % (function.type, gremedy_function)
-                print '    }'
-                if_ = 'else if'
-            print '    else {'
-            Tracer.invokeFunction(self, function)
-            print '    }'
-            return
-
-        # Override GL extensions
-        if function.name in ('glGetString', 'glGetIntegerv', 'glGetStringi'):
-            Tracer.invokeFunction(self, function, prefix = 'gltrace::__', suffix = '_override')
-            return
-
-        Tracer.invokeFunction(self, function)
-
-    buffer_targets = [
-        'ARRAY_BUFFER',
-        'ELEMENT_ARRAY_BUFFER',
-        'PIXEL_PACK_BUFFER',
-        'PIXEL_UNPACK_BUFFER',
-        'UNIFORM_BUFFER',
-        'TEXTURE_BUFFER',
-        'TRANSFORM_FEEDBACK_BUFFER',
-        'COPY_READ_BUFFER',
-        'COPY_WRITE_BUFFER',
-        'DRAW_INDIRECT_BUFFER',
-        'ATOMIC_COUNTER_BUFFER',
-    ]
-
-    def wrapRet(self, function, instance):
-        Tracer.wrapRet(self, function, instance)
-
-            
-        if function.name in ('glMapBuffer', 'glMapBufferARB', 'glMapBufferOES'):
-            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
-            print '    if (mapping) {'
-            print '        mapping->map = %s;' % (instance)
-            print '        mapping->length = 0;'
-            print '        __glGetBufferParameteriv(target, GL_BUFFER_SIZE, &mapping->length);'
-            print '        mapping->write = (access != GL_READ_ONLY);'
-            print '        mapping->explicit_flush = false;'
-            print '    }'
-
-        if function.name == 'glMapBufferRange':
-            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
-            print '    if (mapping) {'
-            print '        mapping->map = %s;' % (instance)
-            print '        mapping->length = length;'
-            print '        mapping->write = access & GL_MAP_WRITE_BIT;'
-            print '        mapping->explicit_flush = access & GL_MAP_FLUSH_EXPLICIT_BIT;'
-            print '    }'
-
-    boolean_names = [
-        'GL_FALSE',
-        'GL_TRUE',
-    ]
-
-    def gl_boolean(self, value):
-        return self.boolean_names[int(bool(value))]
-
-    # Names of the functions that unpack from a pixel buffer object.  See the
-    # ARB_pixel_buffer_object specification.
-    unpack_function_names = set([
-        'glBitmap',
-        'glColorSubTable',
-        'glColorTable',
-        'glCompressedTexImage1D',
-        'glCompressedTexImage2D',
-        'glCompressedTexImage3D',
-        'glCompressedTexSubImage1D',
-        'glCompressedTexSubImage2D',
-        'glCompressedTexSubImage3D',
-        'glConvolutionFilter1D',
-        'glConvolutionFilter2D',
-        'glDrawPixels',
-        'glMultiTexImage1DEXT',
-        'glMultiTexImage2DEXT',
-        'glMultiTexImage3DEXT',
-        'glMultiTexSubImage1DEXT',
-        'glMultiTexSubImage2DEXT',
-        'glMultiTexSubImage3DEXT',
-        'glPixelMapfv',
-        'glPixelMapuiv',
-        'glPixelMapusv',
-        'glPolygonStipple',
-        'glSeparableFilter2D',
-        'glTexImage1D',
-        'glTexImage1DEXT',
-        'glTexImage2D',
-        'glTexImage2DEXT',
-        'glTexImage3D',
-        'glTexImage3DEXT',
-        'glTexSubImage1D',
-        'glTexSubImage1DEXT',
-        'glTexSubImage2D',
-        'glTexSubImage2DEXT',
-        'glTexSubImage3D',
-        'glTexSubImage3DEXT',
-        'glTextureImage1DEXT',
-        'glTextureImage2DEXT',
-        'glTextureImage3DEXT',
-        'glTextureSubImage1DEXT',
-        'glTextureSubImage2DEXT',
-        'glTextureSubImage3DEXT',
-    ])
-
-    def serializeArgValue(self, function, arg):
-        if function.name in self.draw_function_names and arg.name == 'indices':
-            print '    GLint __element_array_buffer = 0;'
-            print '    __glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &__element_array_buffer);'
-            print '    if (!__element_array_buffer) {'
-            if isinstance(arg.type, stdapi.Array):
-                print '        trace::localWriter.beginArray(%s);' % arg.type.length
-                print '        for(GLsizei i = 0; i < %s; ++i) {' % arg.type.length
-                print '            trace::localWriter.beginElement();'
-                print '            trace::localWriter.writeBlob(%s[i], count[i]*__gl_type_size(type));' % (arg.name)
-                print '            trace::localWriter.endElement();'
-                print '        }'
-                print '        trace::localWriter.endArray();'
-            else:
-                print '        trace::localWriter.writeBlob(%s, count*__gl_type_size(type));' % (arg.name)
-            print '    } else {'
-            Tracer.serializeArgValue(self, function, arg)
-            print '    }'
-            return
-
-        # Recognize offsets instead of blobs when a PBO is bound
-        if function.name in self.unpack_function_names \
-           and (isinstance(arg.type, stdapi.Blob) \
-                or (isinstance(arg.type, stdapi.Const) \
-                    and isinstance(arg.type.type, stdapi.Blob))):
-            print '    {'
-            print '        tracer_context *ctx = __get_context();'
-            print '        GLint __unpack_buffer = 0;'
-            print '        if (ctx->profile == PROFILE_COMPAT)'
-            print '            __glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &__unpack_buffer);'
-            print '        if (__unpack_buffer) {'
-            print '            trace::localWriter.writeOpaque(%s);' % arg.name
-            print '        } else {'
-            Tracer.serializeArgValue(self, function, arg)
-            print '        }'
-            print '    }'
-            return
-
-        # Several GL state functions take GLenum symbolic names as
-        # integer/floats; so dump the symbolic name whenever possible
-        if function.name.startswith('gl') \
-           and arg.type in (glapi.GLint, glapi.GLfloat, glapi.GLdouble) \
-           and arg.name == 'param':
-            assert arg.index > 0
-            assert function.args[arg.index - 1].name == 'pname'
-            assert function.args[arg.index - 1].type == glapi.GLenum
-            print '    if (is_symbolic_pname(pname) && is_symbolic_param(%s)) {' % arg.name
-            self.serializeValue(glapi.GLenum, arg.name)
-            print '    } else {'
-            Tracer.serializeArgValue(self, function, arg)
-            print '    }'
-            return
-
-        Tracer.serializeArgValue(self, function, arg)
-
-    def footer(self, api):
-        Tracer.footer(self, api)
-
-        # A simple state tracker to track the pointer values
-        # update the state
-        print 'static void __trace_user_arrays(GLuint maxindex)'
-        print '{'
-        print '    tracer_context *ctx = __get_context();'
-
-        for camelcase_name, uppercase_name in self.arrays:
-            # in which profile is the array available?
-            profile_check = 'ctx->profile == PROFILE_COMPAT'
-            if camelcase_name in self.arrays_es1:
-                profile_check = '(' + profile_check + ' || ctx->profile == PROFILE_ES1)';
-
-            function_name = 'gl%sPointer' % camelcase_name
-            enable_name = 'GL_%s_ARRAY' % uppercase_name
-            binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name
-            function = api.get_function_by_name(function_name)
-
-            print '    // %s' % function.prototype()
-            print '  if (%s) {' % profile_check
-            self.array_trace_prolog(api, uppercase_name)
-            self.array_prolog(api, uppercase_name)
-            print '    if (__glIsEnabled(%s)) {' % enable_name
-            print '        GLint __binding = 0;'
-            print '        __glGetIntegerv(%s, &__binding);' % binding_name
-            print '        if (!__binding) {'
-
-            # Get the arguments via glGet*
-            for arg in function.args:
-                arg_get_enum = 'GL_%s_ARRAY_%s' % (uppercase_name, arg.name.upper())
-                arg_get_function, arg_type = TypeGetter().visit(arg.type)
-                print '            %s %s = 0;' % (arg_type, arg.name)
-                print '            __%s(%s, &%s);' % (arg_get_function, arg_get_enum, arg.name)
-            
-            arg_names = ', '.join([arg.name for arg in function.args[:-1]])
-            print '            size_t __size = __%s_size(%s, maxindex);' % (function.name, arg_names)
-
-            # Emit a fake function
-            self.array_trace_intermezzo(api, uppercase_name)
-            print '            unsigned __call = trace::localWriter.beginEnter(&__%s_sig);' % (function.name,)
-            for arg in function.args:
-                assert not arg.output
-                print '            trace::localWriter.beginArg(%u);' % (arg.index,)
-                if arg.name != 'pointer':
-                    self.serializeValue(arg.type, arg.name)
-                else:
-                    print '            trace::localWriter.writeBlob((const void *)%s, __size);' % (arg.name)
-                print '            trace::localWriter.endArg();'
-            
-            print '            trace::localWriter.endEnter();'
-            print '            trace::localWriter.beginLeave(__call);'
-            print '            trace::localWriter.endLeave();'
-            print '        }'
-            print '    }'
-            self.array_epilog(api, uppercase_name)
-            self.array_trace_epilog(api, uppercase_name)
-            print '  }'
-            print
-
-        # Samething, but for glVertexAttribPointer*
-        #
-        # Some variants of glVertexAttribPointer alias conventional and generic attributes:
-        # - glVertexAttribPointer: no
-        # - glVertexAttribPointerARB: implementation dependent
-        # - glVertexAttribPointerNV: yes
-        #
-        # This means that the implementations of these functions do not always
-        # alias, and they need to be considered independently.
-        #
-        print '    // ES1 does not support generic vertex attributes'
-        print '    if (ctx->profile == PROFILE_ES1)'
-        print '        return;'
-        print
-        print '    vertex_attrib __vertex_attrib = __get_vertex_attrib();'
-        print
-        for suffix in ['', 'ARB', 'NV']:
-            if suffix:
-                SUFFIX = '_' + suffix
-            else:
-                SUFFIX = suffix
-            function_name = 'glVertexAttribPointer' + suffix
-            function = api.get_function_by_name(function_name)
-
-            print '    // %s' % function.prototype()
-            print '    if (__vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX
-            if suffix == 'NV':
-                print '        GLint __max_vertex_attribs = 16;'
-            else:
-                print '        GLint __max_vertex_attribs = 0;'
-                print '        __glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &__max_vertex_attribs);'
-            print '        for (GLint index = 0; index < __max_vertex_attribs; ++index) {'
-            print '            GLint __enabled = 0;'
-            if suffix == 'NV':
-                print '            __glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &__enabled);'
-            else:
-                print '            __glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED%s, &__enabled);' % (suffix, SUFFIX)
-            print '            if (__enabled) {'
-            print '                GLint __binding = 0;'
-            if suffix != 'NV':
-                # It doesn't seem possible to use VBOs with NV_vertex_program.
-                print '                __glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &__binding);' % (suffix, SUFFIX)
-            print '                if (!__binding) {'
-
-            # Get the arguments via glGet*
-            for arg in function.args[1:]:
-                if suffix == 'NV':
-                    arg_get_enum = 'GL_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX)
-                else:
-                    arg_get_enum = 'GL_VERTEX_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX)
-                arg_get_function, arg_type = TypeGetter('glGetVertexAttrib', False, suffix).visit(arg.type)
-                print '                    %s %s = 0;' % (arg_type, arg.name)
-                print '                    __%s(index, %s, &%s);' % (arg_get_function, arg_get_enum, arg.name)
-            
-            arg_names = ', '.join([arg.name for arg in function.args[1:-1]])
-            print '                    size_t __size = __%s_size(%s, maxindex);' % (function.name, arg_names)
-
-            # Emit a fake function
-            print '                    unsigned __call = trace::localWriter.beginEnter(&__%s_sig);' % (function.name,)
-            for arg in function.args:
-                assert not arg.output
-                print '                    trace::localWriter.beginArg(%u);' % (arg.index,)
-                if arg.name != 'pointer':
-                    self.serializeValue(arg.type, arg.name)
-                else:
-                    print '                    trace::localWriter.writeBlob((const void *)%s, __size);' % (arg.name)
-                print '                    trace::localWriter.endArg();'
-            
-            print '                    trace::localWriter.endEnter();'
-            print '                    trace::localWriter.beginLeave(__call);'
-            print '                    trace::localWriter.endLeave();'
-            print '                }'
-            print '            }'
-            print '        }'
-            print '    }'
-            print
-
-        print '}'
-        print
-
-    #
-    # Hooks for glTexCoordPointer, which is identical to the other array
-    # pointers except the fact that it is indexed by glClientActiveTexture.
-    #
-
-    def array_prolog(self, api, uppercase_name):
-        if uppercase_name == 'TEXTURE_COORD':
-            print '    GLint client_active_texture = 0;'
-            print '    __glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &client_active_texture);'
-            print '    GLint max_texture_coords = 0;'
-            print '    if (ctx->profile == PROFILE_COMPAT)'
-            print '        __glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);'
-            print '    else'
-            print '        __glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_coords);'
-            print '    for (GLint unit = 0; unit < max_texture_coords; ++unit) {'
-            print '        GLint texture = GL_TEXTURE0 + unit;'
-            print '        __glClientActiveTexture(texture);'
-
-    def array_trace_prolog(self, api, uppercase_name):
-        if uppercase_name == 'TEXTURE_COORD':
-            print '    bool client_active_texture_dirty = false;'
-
-    def array_epilog(self, api, uppercase_name):
-        if uppercase_name == 'TEXTURE_COORD':
-            print '    }'
-        self.array_cleanup(api, uppercase_name)
-
-    def array_cleanup(self, api, uppercase_name):
-        if uppercase_name == 'TEXTURE_COORD':
-            print '    __glClientActiveTexture(client_active_texture);'
-        
-    def array_trace_intermezzo(self, api, uppercase_name):
-        if uppercase_name == 'TEXTURE_COORD':
-            print '    if (texture != client_active_texture || client_active_texture_dirty) {'
-            print '        client_active_texture_dirty = true;'
-            self.fake_glClientActiveTexture_call(api, "texture");
-            print '    }'
-
-    def array_trace_epilog(self, api, uppercase_name):
-        if uppercase_name == 'TEXTURE_COORD':
-            print '    if (client_active_texture_dirty) {'
-            self.fake_glClientActiveTexture_call(api, "client_active_texture");
-            print '    }'
-
-    def fake_glClientActiveTexture_call(self, api, texture):
-        function = api.get_function_by_name('glClientActiveTexture')
-        self.fake_call(function, [texture])
-
-    def fake_call(self, function, args):
-        print '            unsigned __fake_call = trace::localWriter.beginEnter(&__%s_sig);' % (function.name,)
-        for arg, instance in zip(function.args, args):
-            assert not arg.output
-            print '            trace::localWriter.beginArg(%u);' % (arg.index,)
-            self.serializeValue(arg.type, instance)
-            print '            trace::localWriter.endArg();'
-        print '            trace::localWriter.endEnter();'
-        print '            trace::localWriter.beginLeave(__fake_call);'
-        print '            trace::localWriter.endLeave();'
-
-
-
-
-
-
-
-
-
-
-
diff --git a/glws.cpp b/glws.cpp
deleted file mode 100644 (file)
index c5c41eb..0000000
--- a/glws.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "glws.hpp"
-
-
-namespace glws {
-
-
-bool debug = true;
-
-
-bool
-checkExtension(const char *extName, const char *extString)
-{
-   const char *p = extString;
-   const char *q = extName;
-   char c;
-   do {
-       c = *p++;
-       if (c == '\0' || c == ' ') {
-           if (q && *q == '\0') {
-               return true;
-           } else {
-               q = extName;
-           }
-       } else {
-           if (q && *q == c) {
-               ++q;
-           } else {
-               q = 0;
-           }
-       }
-   } while (c);
-   return false;
-}
-
-
-} /* namespace glws */
diff --git a/glws.hpp b/glws.hpp
deleted file mode 100644 (file)
index 9afebf4..0000000
--- a/glws.hpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-/*
- * Abstraction for GL window system specific APIs (GLX, WGL).
- */
-
-#ifndef _GLWS_HPP_
-#define _GLWS_HPP_
-
-
-#include <vector>
-
-
-namespace glws {
-
-
-enum Profile {
-    PROFILE_COMPAT = 0,
-    PROFILE_CORE,
-    PROFILE_ES1,
-    PROFILE_ES2,
-    PROFILE_MAX
-};
-
-
-extern bool debug;
-
-
-bool
-checkExtension(const char *extName, const char *extString);
-
-
-template< class T >
-class Attributes {
-protected:
-    std::vector<T> attribs;
-
-public:
-    void add(T param) {
-        attribs.push_back(param);
-    }
-
-    void add(T pname, T pvalue) {
-        add(pname);
-        add(pvalue);
-    }
-
-    void end(T terminator = 0) {
-        add(terminator);
-    }
-
-    operator T * (void) {
-        return &attribs[0];
-    }
-
-    operator const T * (void) const {
-        return &attribs[0];
-    }
-};
-
-
-class Visual
-{
-public:
-    unsigned long redMask;
-    unsigned long greenMask;
-    unsigned long blueMask;
-    unsigned long alphaMask;
-    bool doubleBuffer;
-
-    virtual ~Visual() {}
-};
-
-
-class Drawable
-{
-public:
-    const Visual *visual;
-    int width;
-    int height;
-    bool visible;
-
-    Drawable(const Visual *vis, int w, int h) :
-        visual(vis),
-        width(w),
-        height(h),
-        visible(false)
-    {}
-
-    virtual ~Drawable() {}
-    
-    virtual void
-    resize(int w, int h) {
-        width = w;
-        height = h;
-    }
-
-    virtual void
-    show(void) {
-        visible = true;
-    }
-
-    virtual void swapBuffers(void) = 0;
-};
-
-
-class Context
-{
-public:
-    const Visual *visual;
-    Profile profile;
-    
-    Context(const Visual *vis, Profile prof) :
-        visual(vis),
-        profile(prof)
-    {}
-
-    virtual ~Context() {}
-};
-
-
-void
-init(void);
-
-void
-cleanup(void);
-
-Visual *
-createVisual(bool doubleBuffer = false, Profile profile = PROFILE_COMPAT);
-
-Drawable *
-createDrawable(const Visual *visual, int width = 32, int height = 32);
-
-Context *
-createContext(const Visual *visual, Context *shareContext = 0, Profile profile = PROFILE_COMPAT);
-
-bool
-makeCurrent(Drawable *drawable, Context *context);
-
-bool
-processEvents(void);
-
-
-} /* namespace glws */
-
-
-#endif /* _GLWS_HPP_ */
diff --git a/glws_cocoa.mm b/glws_cocoa.mm
deleted file mode 100644 (file)
index 7f696fa..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/**
- * Minimal Cocoa integration.
- *
- * See also:
- * - http://developer.apple.com/library/mac/#samplecode/CocoaGL/Introduction/Intro.html
- * - http://developer.apple.com/library/mac/#samplecode/Cocoa_With_Carbon_or_CPP/Introduction/Intro.html
- * - http://developer.apple.com/library/mac/#samplecode/glut/Introduction/Intro.html
- * - http://developer.apple.com/library/mac/#samplecode/GLEssentials/Introduction/Intro.html
- * - http://www.glfw.org/
- */
-
-
-#include <stdlib.h>
-#include <iostream>
-
-#include <Cocoa/Cocoa.h>
-
-#include "glws.hpp"
-
-
-namespace glws {
-
-
-NSAutoreleasePool *autoreleasePool = nil;
-
-
-class CocoaVisual : public Visual
-{
-public:
-    NSOpenGLPixelFormat *pixelFormat;
-
-    CocoaVisual(NSOpenGLPixelFormat *pf) :
-        pixelFormat(pf)
-    {}
-
-    ~CocoaVisual() {
-        [pixelFormat release];
-    }
-};
-
-class CocoaDrawable : public Drawable
-{
-public:
-    NSWindow *window;
-    NSOpenGLContext *currentContext;
-
-    CocoaDrawable(const Visual *vis, int w, int h) :
-        Drawable(vis, w, h),
-        currentContext(nil)
-    {
-        NSOpenGLPixelFormat *pixelFormat = static_cast<const CocoaVisual *>(visual)->pixelFormat;
-
-        NSRect winRect = NSMakeRect(0, 0, w, h);
-
-        window = [[NSWindow alloc]
-                         initWithContentRect:winRect
-                                   styleMask:NSTitledWindowMask |
-                                             NSClosableWindowMask |
-                                             NSMiniaturizableWindowMask
-                                     backing:NSBackingStoreRetained
-                                       defer:NO];
-        assert(window != nil);
-
-        NSOpenGLView *view = [[NSOpenGLView alloc]
-                              initWithFrame:winRect
-                                pixelFormat:pixelFormat];
-        assert(view != nil);
-
-        [window setContentView:view];
-        [window setTitle:@"glretrace"];
-
-    }
-
-    ~CocoaDrawable() {
-        [window release];
-    }
-
-    void
-    resize(int w, int h) {
-        if (w == width && h == height) {
-            return;
-        }
-
-        [window setContentSize:NSMakeSize(w, h)];
-
-        if (currentContext != nil) {
-            [currentContext update];
-            [window makeKeyAndOrderFront:nil];
-            [currentContext setView:[window contentView]];
-            [currentContext makeCurrentContext];
-        }
-
-        Drawable::resize(w, h);
-    }
-
-    void show(void) {
-        if (visible) {
-            return;
-        }
-
-        // TODO
-
-        Drawable::show();
-    }
-
-    void swapBuffers(void) {
-        if (currentContext != nil) {
-            [currentContext flushBuffer];
-        }
-    }
-};
-
-
-class CocoaContext : public Context
-{
-public:
-    NSOpenGLContext *context;
-
-    CocoaContext(const Visual *vis, Profile prof, NSOpenGLContext *ctx) :
-        Context(vis, prof),
-        context(ctx)
-    {}
-
-    ~CocoaContext() {
-        [context release];
-    }
-};
-
-
-void
-init(void) {
-    [NSApplication sharedApplication];
-
-    autoreleasePool = [[NSAutoreleasePool alloc] init];
-
-    [NSApp finishLaunching];
-}
-
-
-void
-cleanup(void) {
-    [autoreleasePool release];
-}
-
-
-Visual *
-createVisual(bool doubleBuffer, Profile profile) {
-    if (profile != PROFILE_COMPAT &&
-        profile != PROFILE_CORE) {
-        return nil;
-    }
-
-    Attributes<NSOpenGLPixelFormatAttribute> attribs;
-
-    attribs.add(NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)1);
-    attribs.add(NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24);
-    if (doubleBuffer) {
-        attribs.add(NSOpenGLPFADoubleBuffer);
-    }
-    attribs.add(NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)1);
-    attribs.add(NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)1);
-    if (profile == PROFILE_CORE) {
-#if CGL_VERSION_1_3
-        attribs.add(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
-#else
-       return NULL;
-#endif
-    }
-    attribs.end();
-
-    NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc]
-                                     initWithAttributes:attribs];
-
-    return new CocoaVisual(pixelFormat);
-}
-
-Drawable *
-createDrawable(const Visual *visual, int width, int height)
-{
-    return new CocoaDrawable(visual, width, height);
-}
-
-Context *
-createContext(const Visual *visual, Context *shareContext, Profile profile)
-{
-    NSOpenGLPixelFormat *pixelFormat = static_cast<const CocoaVisual *>(visual)->pixelFormat;
-    NSOpenGLContext *share_context = nil;
-    NSOpenGLContext *context;
-
-    if (profile != PROFILE_COMPAT &&
-        profile != PROFILE_CORE) {
-        return nil;
-    }
-
-    if (shareContext) {
-        share_context = static_cast<CocoaContext*>(shareContext)->context;
-    }
-
-    context = [[NSOpenGLContext alloc]
-               initWithFormat:pixelFormat
-               shareContext:share_context];
-    assert(context != nil);
-
-    return new CocoaContext(visual, profile, context);
-}
-
-bool
-makeCurrent(Drawable *drawable, Context *context)
-{
-    if (!drawable || !context) {
-        [NSOpenGLContext clearCurrentContext];
-    } else {
-        CocoaDrawable *cocoaDrawable = static_cast<CocoaDrawable *>(drawable);
-        CocoaContext *cocoaContext = static_cast<CocoaContext *>(context);
-
-        [cocoaDrawable->window makeKeyAndOrderFront:nil];
-        [cocoaContext->context setView:[cocoaDrawable->window contentView]];
-        [cocoaContext->context makeCurrentContext];
-
-        cocoaDrawable->currentContext = cocoaContext->context;
-    }
-
-    return TRUE;
-}
-
-bool
-processEvents(void) {
-   NSEvent* event;
-
-    do {
-        event = [NSApp nextEventMatchingMask:NSAnyEventMask
-                                   untilDate:[NSDate distantPast]
-                                      inMode:NSDefaultRunLoopMode
-                                     dequeue:YES];
-        if (event)
-            [NSApp sendEvent:event];
-    } while (event);
-
-    return true;
-}
-
-
-} /* namespace glws */
diff --git a/glws_egl_xlib.cpp b/glws_egl_xlib.cpp
deleted file mode 100644 (file)
index 6655781..0000000
+++ /dev/null
@@ -1,441 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 LunarG, Inc.
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include <iostream>
-
-#include <dlfcn.h>
-
-#include "glproc.hpp"
-#include "glws.hpp"
-
-
-namespace glws {
-
-
-static Display *display = NULL;
-static EGLDisplay eglDisplay = EGL_NO_DISPLAY;
-static int screen = 0;
-
-
-class EglVisual : public Visual
-{
-public:
-    EGLConfig config;
-    XVisualInfo *visinfo;
-
-    EglVisual() :
-        config(0),
-        visinfo(0)
-    {}
-
-    ~EglVisual() {
-        XFree(visinfo);
-    }
-};
-
-
-static void describeEvent(const XEvent &event) {
-    if (0) {
-        switch (event.type) {
-        case ConfigureNotify:
-            std::cerr << "ConfigureNotify";
-            break;
-        case Expose:
-            std::cerr << "Expose";
-            break;
-        case KeyPress:
-            std::cerr << "KeyPress";
-            break;
-        case MapNotify:
-            std::cerr << "MapNotify";
-            break;
-        case ReparentNotify:
-            std::cerr << "ReparentNotify";
-            break;
-        default:
-            std::cerr << "Event " << event.type;
-        }
-        std::cerr << " " << event.xany.window << "\n";
-    }
-}
-
-class EglDrawable : public Drawable
-{
-public:
-    Window window;
-    EGLSurface surface;
-    EGLint api;
-
-    EglDrawable(const Visual *vis, int w, int h) :
-        Drawable(vis, w, h), api(EGL_OPENGL_ES_API)
-    {
-        XVisualInfo *visinfo = static_cast<const EglVisual *>(visual)->visinfo;
-
-        Window root = RootWindow(display, screen);
-
-        /* window attributes */
-        XSetWindowAttributes attr;
-        attr.background_pixel = 0;
-        attr.border_pixel = 0;
-        attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
-        attr.event_mask = StructureNotifyMask;
-
-        unsigned long mask;
-        mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
-
-        int x = 0, y = 0;
-
-        window = XCreateWindow(
-            display, root,
-            x, y, width, height,
-            0,
-            visinfo->depth,
-            InputOutput,
-            visinfo->visual,
-            mask,
-            &attr);
-
-        XSizeHints sizehints;
-        sizehints.x = x;
-        sizehints.y = y;
-        sizehints.width  = width;
-        sizehints.height = height;
-        sizehints.flags = USSize | USPosition;
-        XSetNormalHints(display, window, &sizehints);
-
-        const char *name = "glretrace";
-        XSetStandardProperties(
-            display, window, name, name,
-            None, (char **)NULL, 0, &sizehints);
-
-        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-
-        EGLConfig config = static_cast<const EglVisual *>(visual)->config;
-        surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL);
-    }
-
-    void waitForEvent(int type) {
-        XEvent event;
-        do {
-            XWindowEvent(display, window, StructureNotifyMask, &event);
-            describeEvent(event);
-        } while (event.type != type);
-    }
-
-    ~EglDrawable() {
-        eglDestroySurface(eglDisplay, surface);
-        eglWaitClient();
-        XDestroyWindow(display, window);
-        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-    }
-
-    void
-    resize(int w, int h) {
-        if (w == width && h == height) {
-            return;
-        }
-
-        eglWaitClient();
-
-        // We need to ensure that pending events are processed here, and XSync
-        // with discard = True guarantees that, but it appears the limited
-        // event processing we do so far is sufficient
-        //XSync(display, True);
-
-        Drawable::resize(w, h);
-
-        XResizeWindow(display, window, w, h);
-
-        // Tell the window manager to respect the requested size
-        XSizeHints size_hints;
-        size_hints.max_width  = size_hints.min_width  = w;
-        size_hints.max_height = size_hints.min_height = h;
-        size_hints.flags = PMinSize | PMaxSize;
-        XSetWMNormalHints(display, window, &size_hints);
-
-        waitForEvent(ConfigureNotify);
-
-        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-    }
-
-    void show(void) {
-        if (visible) {
-            return;
-        }
-
-        eglWaitClient();
-
-        XMapWindow(display, window);
-
-        waitForEvent(MapNotify);
-
-        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-
-        Drawable::show();
-    }
-
-    void swapBuffers(void) {
-        eglBindAPI(api);
-        eglSwapBuffers(eglDisplay, surface);
-    }
-};
-
-
-class EglContext : public Context
-{
-public:
-    EGLContext context;
-
-    EglContext(const Visual *vis, Profile prof, EGLContext ctx) :
-        Context(vis, prof),
-        context(ctx)
-    {}
-
-    ~EglContext() {
-        eglDestroyContext(eglDisplay, context);
-    }
-};
-
-/**
- * Load the symbols from the specified shared object into global namespace, so
- * that they can be later found by dlsym(RTLD_NEXT, ...);
- */
-static void
-load(const char *filename)
-{
-    if (!dlopen(filename, RTLD_GLOBAL | RTLD_LAZY)) {
-        std::cerr << "error: unable to open " << filename << "\n";
-        exit(1);
-    }
-}
-
-void
-init(void) {
-    load("libEGL.so.1");
-
-    display = XOpenDisplay(NULL);
-    if (!display) {
-        std::cerr << "error: unable to open display " << XDisplayName(NULL) << "\n";
-        exit(1);
-    }
-
-    screen = DefaultScreen(display);
-
-    eglDisplay = eglGetDisplay((EGLNativeDisplayType)display);
-    if (eglDisplay == EGL_NO_DISPLAY) {
-        std::cerr << "error: unable to get EGL display\n";
-        XCloseDisplay(display);
-        exit(1);
-    }
-
-    EGLint major, minor;
-    if (!eglInitialize(eglDisplay, &major, &minor)) {
-        std::cerr << "error: unable to initialize EGL display\n";
-        XCloseDisplay(display);
-        exit(1);
-    }
-}
-
-void
-cleanup(void) {
-    if (display) {
-        eglTerminate(eglDisplay);
-        XCloseDisplay(display);
-        display = NULL;
-    }
-}
-
-Visual *
-createVisual(bool doubleBuffer, Profile profile) {
-    EglVisual *visual = new EglVisual();
-    // possible combinations
-    const EGLint api_bits_gl[7] = {
-        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT,
-        EGL_OPENGL_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_BIT,
-        EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_ES_BIT,
-    };
-    const EGLint api_bits_gles1[7] = {
-        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT,
-        EGL_OPENGL_ES_BIT,
-        EGL_OPENGL_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_BIT,
-        EGL_OPENGL_ES2_BIT,
-    };
-    const EGLint api_bits_gles2[7] = {
-        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_BIT | EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_ES2_BIT,
-        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT,
-        EGL_OPENGL_BIT,
-        EGL_OPENGL_ES_BIT,
-    };
-    const EGLint *api_bits;
-
-    switch(profile) {
-    case PROFILE_COMPAT:
-        api_bits = api_bits_gl;
-        break;
-    case PROFILE_ES1:
-        api_bits = api_bits_gles1;
-        break;
-    case PROFILE_ES2:
-        api_bits = api_bits_gles2;
-        break;
-    default:
-        return NULL;
-    };
-
-    for (int i = 0; i < 7; i++) {
-        Attributes<EGLint> attribs;
-
-        attribs.add(EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
-        attribs.add(EGL_RED_SIZE, 1);
-        attribs.add(EGL_GREEN_SIZE, 1);
-        attribs.add(EGL_BLUE_SIZE, 1);
-        attribs.add(EGL_ALPHA_SIZE, 1);
-        attribs.add(EGL_DEPTH_SIZE, 1);
-        attribs.add(EGL_STENCIL_SIZE, 1);
-        attribs.add(EGL_RENDERABLE_TYPE, api_bits[i]);
-        attribs.end(EGL_NONE);
-
-        EGLint num_configs, vid;
-        if (eglChooseConfig(eglDisplay, attribs, &visual->config, 1, &num_configs) &&
-            num_configs == 1 &&
-            eglGetConfigAttrib(eglDisplay, visual->config, EGL_NATIVE_VISUAL_ID, &vid)) {
-            XVisualInfo templ;
-            int num_visuals;
-
-            templ.visualid = vid;
-            visual->visinfo = XGetVisualInfo(display, VisualIDMask, &templ, &num_visuals);
-            break;
-        }
-    }
-
-    assert(visual->visinfo);
-
-    return visual;
-}
-
-Drawable *
-createDrawable(const Visual *visual, int width, int height)
-{
-    return new EglDrawable(visual, width, height);
-}
-
-Context *
-createContext(const Visual *_visual, Context *shareContext, Profile profile)
-{
-    const EglVisual *visual = static_cast<const EglVisual *>(_visual);
-    EGLContext share_context = EGL_NO_CONTEXT;
-    EGLContext context;
-    Attributes<EGLint> attribs;
-
-    if (shareContext) {
-        share_context = static_cast<EglContext*>(shareContext)->context;
-    }
-
-    EGLint api = eglQueryAPI();
-
-    switch (profile) {
-    case PROFILE_COMPAT:
-        load("libGL.so.1");
-        eglBindAPI(EGL_OPENGL_API);
-        break;
-    case PROFILE_CORE:
-        assert(0);
-        return NULL;
-    case PROFILE_ES1:
-        load("libGLESv1_CM.so.1");
-        eglBindAPI(EGL_OPENGL_ES_API);
-        break;
-    case PROFILE_ES2:
-        load("libGLESv2.so.2");
-        eglBindAPI(EGL_OPENGL_ES_API);
-        attribs.add(EGL_CONTEXT_CLIENT_VERSION, 2);
-        break;
-    default:
-        return NULL;
-    }
-
-    attribs.end(EGL_NONE);
-
-    context = eglCreateContext(eglDisplay, visual->config, share_context, attribs);
-    if (!context)
-        return NULL;
-
-    eglBindAPI(api);
-
-    return new EglContext(visual, profile, context);
-}
-
-bool
-makeCurrent(Drawable *drawable, Context *context)
-{
-    if (!drawable || !context) {
-        return eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-    } else {
-        EglDrawable *eglDrawable = static_cast<EglDrawable *>(drawable);
-        EglContext *eglContext = static_cast<EglContext *>(context);
-        EGLBoolean ok;
-
-        ok = eglMakeCurrent(eglDisplay, eglDrawable->surface,
-                            eglDrawable->surface, eglContext->context);
-
-        if (ok) {
-            EGLint api;
-
-            eglQueryContext(eglDisplay, eglContext->context,
-                            EGL_CONTEXT_CLIENT_TYPE, &api);
-
-            eglDrawable->api = api;
-        }
-
-        return ok;
-    }
-}
-
-bool
-processEvents(void) {
-    while (XPending(display) > 0) {
-        XEvent event;
-        XNextEvent(display, &event);
-        describeEvent(event);
-    }
-    return true;
-}
-
-
-} /* namespace glws */
diff --git a/glws_glx.cpp b/glws_glx.cpp
deleted file mode 100644 (file)
index c151db1..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include <iostream>
-
-#include "glproc.hpp"
-#include "glws.hpp"
-
-
-namespace glws {
-
-
-static Display *display = NULL;
-static int screen = 0;
-
-static unsigned glxVersion = 0;
-static const char *extensions = 0;
-static bool has_GLX_ARB_create_context = false;
-
-
-class GlxVisual : public Visual
-{
-public:
-    GLXFBConfig fbconfig;
-    XVisualInfo *visinfo;
-
-    GlxVisual() :
-        fbconfig(0),
-        visinfo(0)
-    {}
-
-    ~GlxVisual() {
-        XFree(visinfo);
-    }
-};
-
-
-static void describeEvent(const XEvent &event) {
-    if (0) {
-        switch (event.type) {
-        case ConfigureNotify:
-            std::cerr << "ConfigureNotify";
-            break;
-        case Expose:
-            std::cerr << "Expose";
-            break;
-        case KeyPress:
-            std::cerr << "KeyPress";
-            break;
-        case MapNotify:
-            std::cerr << "MapNotify";
-            break;
-        case ReparentNotify:
-            std::cerr << "ReparentNotify";
-            break;
-        default:
-            std::cerr << "Event " << event.type;
-        }
-        std::cerr << " " << event.xany.window << "\n";
-    }
-}
-
-class GlxDrawable : public Drawable
-{
-public:
-    Window window;
-
-    GlxDrawable(const Visual *vis, int w, int h) :
-        Drawable(vis, w, h)
-    {
-        XVisualInfo *visinfo = static_cast<const GlxVisual *>(visual)->visinfo;
-
-        Window root = RootWindow(display, screen);
-
-        /* window attributes */
-        XSetWindowAttributes attr;
-        attr.background_pixel = 0;
-        attr.border_pixel = 0;
-        attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
-        attr.event_mask = StructureNotifyMask;
-
-        unsigned long mask;
-        mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
-
-        int x = 0, y = 0;
-
-        window = XCreateWindow(
-            display, root,
-            x, y, width, height,
-            0,
-            visinfo->depth,
-            InputOutput,
-            visinfo->visual,
-            mask,
-            &attr);
-
-        XSizeHints sizehints;
-        sizehints.x = x;
-        sizehints.y = y;
-        sizehints.width  = width;
-        sizehints.height = height;
-        sizehints.flags = USSize | USPosition;
-        XSetNormalHints(display, window, &sizehints);
-
-        const char *name = "glretrace";
-        XSetStandardProperties(
-            display, window, name, name,
-            None, (char **)NULL, 0, &sizehints);
-
-        glXWaitX();
-    }
-
-    void waitForEvent(int type) {
-        XEvent event;
-        do {
-            XWindowEvent(display, window, StructureNotifyMask, &event);
-            describeEvent(event);
-        } while (event.type != type);
-    }
-
-    ~GlxDrawable() {
-        XDestroyWindow(display, window);
-    }
-
-    void
-    resize(int w, int h) {
-        if (w == width && h == height) {
-            return;
-        }
-
-        glXWaitGL();
-
-        // We need to ensure that pending events are processed here, and XSync
-        // with discard = True guarantees that, but it appears the limited
-        // event processing we do so far is sufficient
-        //XSync(display, True);
-
-        Drawable::resize(w, h);
-
-        XResizeWindow(display, window, w, h);
-
-        // Tell the window manager to respect the requested size
-        XSizeHints size_hints;
-        size_hints.max_width  = size_hints.min_width  = w;
-        size_hints.max_height = size_hints.min_height = h;
-        size_hints.flags = PMinSize | PMaxSize;
-        XSetWMNormalHints(display, window, &size_hints);
-
-        waitForEvent(ConfigureNotify);
-
-        glXWaitX();
-    }
-
-    void show(void) {
-        if (visible) {
-            return;
-        }
-
-        glXWaitGL();
-
-        XMapWindow(display, window);
-
-        waitForEvent(MapNotify);
-
-        glXWaitX();
-
-        Drawable::show();
-    }
-
-    void swapBuffers(void) {
-        glXSwapBuffers(display, window);
-    }
-};
-
-
-class GlxContext : public Context
-{
-public:
-    GLXContext context;
-
-    GlxContext(const Visual *vis, Profile prof, GLXContext ctx) :
-        Context(vis, prof),
-        context(ctx)
-    {}
-
-    ~GlxContext() {
-        glXDestroyContext(display, context);
-    }
-};
-
-void
-init(void) {
-    display = XOpenDisplay(NULL);
-    if (!display) {
-        std::cerr << "error: unable to open display " << XDisplayName(NULL) << "\n";
-        exit(1);
-    }
-
-    screen = DefaultScreen(display);
-
-    int major = 0, minor = 0;
-    glXQueryVersion(display, &major, &minor);
-    glxVersion = (major << 8) | minor;
-
-    extensions = glXQueryExtensionsString(display, screen);
-    has_GLX_ARB_create_context = checkExtension("GLX_ARB_create_context", extensions);
-}
-
-void
-cleanup(void) {
-    if (display) {
-        XCloseDisplay(display);
-        display = NULL;
-    }
-}
-
-Visual *
-createVisual(bool doubleBuffer, Profile profile) {
-    if (profile != PROFILE_COMPAT &&
-        profile != PROFILE_CORE) {
-        return NULL;
-    }
-
-    GlxVisual *visual = new GlxVisual;
-
-    if (glxVersion >= 0x0103) {
-        Attributes<int> attribs;
-        attribs.add(GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT);
-        attribs.add(GLX_RENDER_TYPE, GLX_RGBA_BIT);
-        attribs.add(GLX_RED_SIZE, 1);
-        attribs.add(GLX_GREEN_SIZE, 1);
-        attribs.add(GLX_BLUE_SIZE, 1);
-        attribs.add(GLX_ALPHA_SIZE, 1);
-        attribs.add(GLX_DOUBLEBUFFER, doubleBuffer ? GL_TRUE : GL_FALSE);
-        attribs.add(GLX_DEPTH_SIZE, 1);
-        attribs.add(GLX_STENCIL_SIZE, 1);
-        attribs.end();
-
-        int num_configs = 0;
-        GLXFBConfig * fbconfigs;
-        fbconfigs = glXChooseFBConfig(display, screen, attribs, &num_configs);
-        assert(num_configs && fbconfigs);
-        visual->fbconfig = fbconfigs[0];
-        assert(visual->fbconfig);
-        visual->visinfo = glXGetVisualFromFBConfig(display, visual->fbconfig);
-        assert(visual->visinfo);
-    } else {
-        Attributes<int> attribs;
-        attribs.add(GLX_RGBA);
-        attribs.add(GLX_RED_SIZE, 1);
-        attribs.add(GLX_GREEN_SIZE, 1);
-        attribs.add(GLX_BLUE_SIZE, 1);
-        attribs.add(GLX_ALPHA_SIZE, 1);
-        if (doubleBuffer) {
-            attribs.add(GLX_DOUBLEBUFFER);
-        }
-        attribs.add(GLX_DEPTH_SIZE, 1);
-        attribs.add(GLX_STENCIL_SIZE, 1);
-        attribs.end();
-
-        visual->visinfo = glXChooseVisual(display, screen, attribs);
-    }
-
-    return visual;
-}
-
-Drawable *
-createDrawable(const Visual *visual, int width, int height)
-{
-    return new GlxDrawable(visual, width, height);
-}
-
-Context *
-createContext(const Visual *_visual, Context *shareContext, Profile profile)
-{
-    const GlxVisual *visual = static_cast<const GlxVisual *>(_visual);
-    GLXContext share_context = NULL;
-    GLXContext context;
-
-    if (shareContext) {
-        share_context = static_cast<GlxContext*>(shareContext)->context;
-    }
-
-    if (glxVersion >= 0x0104 && has_GLX_ARB_create_context) {
-        Attributes<int> attribs;
-        
-        attribs.add(GLX_RENDER_TYPE, GLX_RGBA_TYPE);
-        if (debug) {
-            attribs.add(GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB);
-        }
-
-        switch (profile) {
-        case PROFILE_COMPAT:
-            break;
-        case PROFILE_CORE:
-            // XXX: This will invariable return a 3.2 context, when supported.
-            // We probably should have a PROFILE_CORE_XX per version.
-            attribs.add(GLX_CONTEXT_MAJOR_VERSION_ARB, 3);
-            attribs.add(GLX_CONTEXT_MINOR_VERSION_ARB, 2);
-            attribs.add(GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB);
-            break;
-        default:
-            return NULL;
-        }
-        
-        attribs.end();
-
-        context = glXCreateContextAttribsARB(display, visual->fbconfig, share_context, True, attribs);
-    } else {
-        if (profile != PROFILE_COMPAT) {
-            return NULL;
-        }
-
-        if (glxVersion >= 0x103) {
-            context = glXCreateNewContext(display, visual->fbconfig, GLX_RGBA_TYPE, share_context, True);
-        } else {
-            context = glXCreateContext(display, visual->visinfo, share_context, True);
-        }
-    }
-
-    if (!context) {
-        return NULL;
-    }
-
-    return new GlxContext(visual, profile, context);
-}
-
-bool
-makeCurrent(Drawable *drawable, Context *context)
-{
-    if (!drawable || !context) {
-        return glXMakeCurrent(display, None, NULL);
-    } else {
-        GlxDrawable *glxDrawable = static_cast<GlxDrawable *>(drawable);
-        GlxContext *glxContext = static_cast<GlxContext *>(context);
-
-        return glXMakeCurrent(display, glxDrawable->window, glxContext->context);
-    }
-}
-
-bool
-processEvents(void) {
-    while (XPending(display) > 0) {
-        XEvent event;
-        XNextEvent(display, &event);
-        describeEvent(event);
-    }
-    return true;
-}
-
-
-} /* namespace glws */
diff --git a/glws_wgl.cpp b/glws_wgl.cpp
deleted file mode 100644 (file)
index 59f4786..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "glproc.hpp"
-#include "glws.hpp"
-
-
-namespace glws {
-
-
-static LRESULT CALLBACK
-WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-    MINMAXINFO *pMMI;
-    switch (uMsg) {
-    case WM_GETMINMAXINFO:
-        // Allow to create a window bigger than the desktop
-        pMMI = (MINMAXINFO *)lParam;
-        pMMI->ptMaxSize.x = 60000;
-        pMMI->ptMaxSize.y = 60000;
-        pMMI->ptMaxTrackSize.x = 60000;
-        pMMI->ptMaxTrackSize.y = 60000;
-        break;
-    default:
-        break;
-    }
-
-    return DefWindowProc(hWnd, uMsg, wParam, lParam);
-}
-
-
-class WglDrawable : public Drawable
-{
-public:
-    DWORD dwExStyle;
-    DWORD dwStyle;
-    HWND hWnd;
-    HDC hDC;
-    PIXELFORMATDESCRIPTOR pfd;
-    int iPixelFormat;
-
-    WglDrawable(const Visual *vis, int width, int height) :
-        Drawable(vis, width, height)
-    {
-        static bool first = TRUE;
-        RECT rect;
-
-        if (first) {
-            WNDCLASS wc;
-            memset(&wc, 0, sizeof wc);
-            wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
-            wc.hCursor = LoadCursor(NULL, IDC_ARROW);
-            wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
-            wc.lpfnWndProc = WndProc;
-            wc.lpszClassName = "glretrace";
-            wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
-            RegisterClass(&wc);
-            first = FALSE;
-        }
-
-        dwExStyle = 0;
-        dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW;
-
-        int x = 0, y = 0;
-
-        rect.left = x;
-        rect.top = y;
-        rect.right = rect.left + width;
-        rect.bottom = rect.top + height;
-
-        AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
-
-        hWnd = CreateWindowEx(dwExStyle,
-                              "glretrace", /* wc.lpszClassName */
-                              NULL,
-                              dwStyle,
-                              0, /* x */
-                              0, /* y */
-                              rect.right - rect.left, /* width */
-                              rect.bottom - rect.top, /* height */
-                              NULL,
-                              NULL,
-                              NULL,
-                              NULL);
-        hDC = GetDC(hWnd);
-   
-        memset(&pfd, 0, sizeof pfd);
-        pfd.cColorBits = 4;
-        pfd.cRedBits = 1;
-        pfd.cGreenBits = 1;
-        pfd.cBlueBits = 1;
-        pfd.cAlphaBits = 1;
-        pfd.cDepthBits = 1;
-        pfd.cStencilBits = 1;
-        pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
-        pfd.iLayerType = PFD_MAIN_PLANE;
-        pfd.iPixelType = PFD_TYPE_RGBA;
-        pfd.nSize = sizeof(pfd);
-        pfd.nVersion = 1;
-
-        if (visual->doubleBuffer) {
-           pfd.dwFlags |= PFD_DOUBLEBUFFER;
-        }
-
-        iPixelFormat = ChoosePixelFormat(hDC, &pfd);
-
-        SetPixelFormat(hDC, iPixelFormat, &pfd);
-    }
-
-    ~WglDrawable() {
-        ReleaseDC(hWnd, hDC);
-        DestroyWindow(hWnd);
-    }
-    
-    void
-    resize(int w, int h) {
-        if (w == width && h == height) {
-            return;
-        }
-
-        RECT rClient, rWindow;
-        GetClientRect(hWnd, &rClient);
-        GetWindowRect(hWnd, &rWindow);
-        w += (rWindow.right  - rWindow.left) - rClient.right;
-        h += (rWindow.bottom - rWindow.top)  - rClient.bottom;
-        SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, w, h, SWP_NOMOVE);
-
-        Drawable::resize(w, h);
-    }
-
-    void show(void) {
-        if (visible) {
-            return;
-        }
-
-        ShowWindow(hWnd, SW_SHOW);
-
-        Drawable::show();
-    }
-
-    void swapBuffers(void) {
-        SwapBuffers(hDC);
-
-        // Drain message queue to prevent window from being considered
-        // non-responsive
-        MSG msg;
-        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
-            TranslateMessage(&msg);
-            DispatchMessage(&msg);
-        }
-    }
-};
-
-
-class WglContext : public Context
-{
-public:
-    HGLRC hglrc;
-    WglContext *shareContext;
-
-    WglContext(const Visual *vis, Profile prof, WglContext *share) :
-        Context(vis, prof),
-        hglrc(0),
-        shareContext(share)
-    {}
-
-    ~WglContext() {
-        if (hglrc) {
-            wglDeleteContext(hglrc);
-        }
-    }
-};
-
-
-void
-init(void) {
-    /*
-     * OpenGL library must be loaded by the time we call GDI.
-     */
-    __libGlHandle = LoadLibraryA("OPENGL32");
-}
-
-void
-cleanup(void) {
-}
-
-Visual *
-createVisual(bool doubleBuffer, Profile profile) {
-    if (profile != PROFILE_COMPAT) {
-        return NULL;
-    }
-
-    Visual *visual = new Visual();
-
-    visual->doubleBuffer = doubleBuffer;
-
-    return visual;
-}
-
-Drawable *
-createDrawable(const Visual *visual, int width, int height)
-{
-    return new WglDrawable(visual, width, height);
-}
-
-Context *
-createContext(const Visual *visual, Context *shareContext, Profile profile)
-{
-    if (profile != PROFILE_COMPAT) {
-        return NULL;
-    }
-
-    return new WglContext(visual, profile, static_cast<WglContext *>(shareContext));
-}
-
-bool
-makeCurrent(Drawable *drawable, Context *context)
-{
-    if (!drawable || !context) {
-        return wglMakeCurrent(NULL, NULL);
-    } else {
-        WglDrawable *wglDrawable = static_cast<WglDrawable *>(drawable);
-        WglContext *wglContext = static_cast<WglContext *>(context);
-
-        if (!wglContext->hglrc) {
-            wglContext->hglrc = wglCreateContext(wglDrawable->hDC);
-            if (!wglContext->hglrc) {
-                return false;
-            }
-            if (wglContext->shareContext) {
-                wglShareLists(wglContext->shareContext->hglrc,
-                              wglContext->hglrc);
-            }
-        }
-
-        return wglMakeCurrent(wglDrawable->hDC, wglContext->hglrc);
-    }
-}
-
-bool
-processEvents(void) {
-    // TODO
-    return true;
-}
-
-
-} /* namespace glws */
diff --git a/glxtrace.py b/glxtrace.py
deleted file mode 100644 (file)
index b8dac38..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-##########################################################################
-#
-# Copyright 2011 Jose Fonseca
-# Copyright 2008-2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""GLX tracing generator."""
-
-
-from specs.stdapi import API
-from specs.glapi import glapi
-from specs.glxapi import glxapi
-from gltrace import GlTracer
-from dispatch import function_pointer_type, function_pointer_value
-
-
-class GlxTracer(GlTracer):
-
-    def isFunctionPublic(self, function):
-        # The symbols visible in libGL.so can vary, so expose them all
-        return True
-
-    def wrapRet(self, function, instance):
-        GlTracer.wrapRet(self, function, instance)
-
-        if function.name in ("glXGetProcAddress", "glXGetProcAddressARB"):
-            print '    %s = __unwrap_proc_addr(procName, %s);' % (instance, instance)
-
-
-if __name__ == '__main__':
-    print
-    print '#include <stdlib.h>'
-    print '#include <string.h>'
-    print
-    print '#ifndef _GNU_SOURCE'
-    print '#define _GNU_SOURCE // for dladdr'
-    print '#endif'
-    print '#include <dlfcn.h>'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print
-    print '// To validate our prototypes'
-    print '#define GL_GLEXT_PROTOTYPES'
-    print '#define GLX_GLXEXT_PROTOTYPES'
-    print
-    print '#include "glproc.hpp"'
-    print '#include "glsize.hpp"'
-    print
-    print 'static __GLXextFuncPtr __unwrap_proc_addr(const GLubyte * procName, __GLXextFuncPtr procPtr);'
-    print
-
-    api = API()
-    api.addApi(glxapi)
-    api.addApi(glapi)
-    tracer = GlxTracer()
-    tracer.trace_api(api)
-
-    print 'static __GLXextFuncPtr __unwrap_proc_addr(const GLubyte * procName, __GLXextFuncPtr procPtr) {'
-    print '    if (!procPtr) {'
-    print '        return procPtr;'
-    print '    }'
-    for f in api.functions:
-        ptype = function_pointer_type(f)
-        pvalue = function_pointer_value(f)
-        print '    if (strcmp("%s", (const char *)procName) == 0) {' % f.name
-        print '        %s = (%s)procPtr;' % (pvalue, ptype)
-        print '        return (__GLXextFuncPtr)&%s;' % (f.name,)
-        print '    }'
-    print '    os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);'
-    print '    return procPtr;'
-    print '}'
-    print
-    print r'''
-
-
-/*
- * Invoke the true dlopen() function.
- */
-static void *__dlopen(const char *filename, int flag)
-{
-    typedef void * (*PFNDLOPEN)(const char *, int);
-    static PFNDLOPEN dlopen_ptr = NULL;
-
-    if (!dlopen_ptr) {
-        dlopen_ptr = (PFNDLOPEN)dlsym(RTLD_NEXT, "dlopen");
-        if (!dlopen_ptr) {
-            os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n");
-            return NULL;
-        }
-    }
-
-    return dlopen_ptr(filename, flag);
-}
-
-
-/*
- * Several applications, such as Quake3, use dlopen("libGL.so.1"), but
- * LD_PRELOAD does not intercept symbols obtained via dlopen/dlsym, therefore
- * we need to intercept the dlopen() call here, and redirect to our wrapper
- * shared object.
- */
-extern "C" PUBLIC
-void * dlopen(const char *filename, int flag)
-{
-    void *handle;
-
-    handle = __dlopen(filename, flag);
-
-    const char * libgl_filename = getenv("TRACE_LIBGL");
-
-    if (filename && handle && !libgl_filename) {
-        if (0) {
-            os::log("apitrace: warning: dlopen(\"%s\", 0x%x)\n", filename, flag);
-        }
-
-        // FIXME: handle absolute paths and other versions
-        if (strcmp(filename, "libGL.so") == 0 ||
-            strcmp(filename, "libGL.so.1") == 0) {
-
-            // Use the true libGL.so handle instead of RTLD_NEXT from now on
-            __libGlHandle = handle;
-
-            // Get the file path for our shared object, and use it instead
-            static int dummy = 0xdeedbeef;
-            Dl_info info;
-            if (dladdr(&dummy, &info)) {
-                os::log("apitrace: redirecting dlopen(\"%s\", 0x%x)\n", filename, flag);
-                handle = __dlopen(info.dli_fname, flag);
-            } else {
-                os::log("apitrace: warning: dladdr() failed\n");
-            }
-        }
-    }
-
-    return handle;
-}
-
-
-
-'''
index f464cb0798acf39a5006e0cddbf2b3680c6ebbea..ece66434a1ad922e502bb58583e0294144450118 100644 (file)
@@ -14,6 +14,8 @@ set(qapitrace_SRCS
    jumpwidget.cpp
    mainwindow.cpp
    main.cpp
+   profiledialog.cpp
+   profiletablemodel.cpp
    retracer.cpp
    saverthread.cpp
    searchwidget.cpp
@@ -22,7 +24,16 @@ set(qapitrace_SRCS
    tracedialog.cpp
    traceloader.cpp
    traceprocess.cpp
+   trimprocess.cpp
    vertexdatainterpreter.cpp
+   graphing/frameaxiswidget.cpp
+   graphing/graphwidget.cpp
+   graphing/graphaxiswidget.cpp
+   graphing/graphview.cpp
+   graphing/heatmapview.cpp
+   graphing/heatmapverticalaxiswidget.cpp
+   graphing/histogramview.cpp
+   graphing/timeaxiswidget.cpp
  )
 
 qt4_automoc(${qapitrace_SRCS})
@@ -34,6 +45,8 @@ set(qapitrace_UIS
    ui/imageviewer.ui
    ui/jumpwidget.ui
    ui/mainwindow.ui
+   ui/profiledialog.ui
+   ui/profilereplaydialog.ui
    ui/retracerdialog.ui
    ui/settings.ui
    ui/tracedialog.ui
@@ -49,7 +62,14 @@ include_directories(${QT_INCLUDES} ${QJSON_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_D
 
 add_executable(qapitrace ${qapitrace_SRCS} ${qapitrace_UIS_H})
 
-target_link_libraries(qapitrace common ${QJSON_LIBRARIES} ${QT_LIBRARIES} )
+target_link_libraries (qapitrace
+    common
+    ${PNG_LIBRARIES}
+    ${ZLIB_LIBRARIES}
+    ${SNAPPY_LIBRARIES}
+    ${QJSON_LIBRARIES}
+    ${QT_LIBRARIES}
+)
 
 ########### install files ###############
 
index 11ed3a5ca03d5c59c96b8c7bc05c67e2e5583bf8..9ad9f24ad535fe729cb478164b30410727014401 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "apitracecall.h"
 #include "apitracemodel.h"
+#include "thumbnail.h"
 
 #include <QApplication>
 #include <QDebug>
@@ -27,35 +28,47 @@ void ApiCallDelegate::paint(QPainter *painter,
     Q_ASSERT(index.column() == 0);
 
     if (event) {
-        QPoint offset;
+        QPoint offset = option.rect.topLeft();
         QStaticText text = event->staticText();
+        QSize textSize = text.size().toSize();
         //text.setTextWidth(option.rect.width());
         //QStyledItemDelegate::paint(painter, option, index);
         QStyle *style = QApplication::style();
         style->drawControl(QStyle::CE_ItemViewItem, &option, painter, 0);
+
+        // draw thumbnail of frame
+        if (event->type() == ApiTraceEvent::Frame) {
+            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
+            const QImage & thumbnail = frame->thumbnail();
+            if (!thumbnail.isNull()) {
+                painter->drawImage(offset, thumbnail);
+                offset += QPoint(textSize.height() + thumbnail.width(), option.rect.height()/2 - textSize.height()/2);
+            }
+        }
+
         if (event->hasState()) {
-            QPixmap px = m_stateEmblem.pixmap(option.rect.height(),
-                                              option.rect.height());
+            QPixmap px = m_stateEmblem.pixmap(textSize.height(),
+                                              textSize.height());
             painter->drawPixmap(option.rect.topLeft(), px);
-            offset = QPoint(option.rect.height() + 5, 0);
+            offset += QPoint(textSize.height() + 5, 0);
         }
         if (event->type() == ApiTraceEvent::Call) {
             ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
             if (call->hasError()) {
-                QPixmap px = m_errorEmblem.pixmap(option.rect.height(),
-                                                  option.rect.height());
-                painter->drawPixmap(option.rect.topLeft() + offset, px);
-                offset += QPoint(option.rect.height() + 5, 0);
+                QPixmap px = m_errorEmblem.pixmap(textSize.height(),
+                                                  textSize.height());
+                painter->drawPixmap(offset, px);
+                offset += QPoint(textSize.height() + 5, 0);
             }
             if (call->edited()) {
-                QPixmap px = m_editEmblem.pixmap(option.rect.height(),
-                                                 option.rect.height());
-                painter->drawPixmap(option.rect.topLeft() + offset, px);
-                offset += QPoint(option.rect.height() + 5, 0);
+                QPixmap px = m_editEmblem.pixmap(textSize.height(),
+                                                 textSize.height());
+                painter->drawPixmap(offset, px);
+                offset += QPoint(textSize.height() + 5, 0);
             }
         }
 
-        painter->drawStaticText(option.rect.topLeft() + offset, text);
+        painter->drawStaticText(offset, text);
     } else {
         QStyledItemDelegate::paint(painter, option, index);
     }
@@ -64,8 +77,8 @@ void ApiCallDelegate::paint(QPainter *painter,
 QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option,
                                 const QModelIndex &index) const
 {
-    ApiTraceEvent *event =
-        index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+    QVariant var = index.data(ApiTraceModel::EventRole);
+    ApiTraceEvent *event = var.value<ApiTraceEvent*>();
 
 #ifndef __APPLE__
     /* XXX: This fails on MacOSX, but seems safe to ignore */
@@ -76,7 +89,21 @@ QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option,
         QStaticText text = event->staticText();
         //text.setTextWidth(option.rect.width());
         //qDebug()<<"text size = "<<text.size();
-        return text.size().toSize();
+        QSize size = text.size().toSize();
+
+        // Adjust for thumbnail
+        if (event->type() == ApiTraceEvent::Frame) {
+            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
+            const QImage & thumbnail = frame->thumbnail();
+            if (!thumbnail.isNull()) {
+                size.rwidth() += thumbnail.width();
+                if (size.height() < thumbnail.height()) {
+                    size.setHeight(thumbnail.height());
+                }
+            }
+        }
+
+        return size;
     }
     return QStyledItemDelegate::sizeHint(option, index);
 }
index 7bf3c8fe5f20c8531d27a4a4feacbfc320c5ad6c..bfc6cfdf128038d6e6b18a6afb057ebeb53e50e2 100644 (file)
@@ -1,4 +1,5 @@
 #include "apisurface.h"
+#include "thumbnail.h"
 
 #include <QDebug>
 #include <QSysInfo>
@@ -31,7 +32,7 @@ void ApiSurface::contentsFromBase64(const QByteArray &base64)
 {
     QByteArray dataArray = QByteArray::fromBase64(base64);
     m_image.loadFromData(dataArray, "png");
-    m_thumb = m_image.scaled(64, 64, Qt::KeepAspectRatio);
+    m_thumb = thumbnail(m_image);
 }
 
 QImage ApiSurface::image() const
index 5758b0750a3acb0ca743af3908bafe6a21d59796..6a8ebe2cd043a4608191db584f2b78274ba09143 100644 (file)
@@ -8,8 +8,7 @@
 #include <QThread>
 
 ApiTrace::ApiTrace()
-    : m_frameMarker(ApiTrace::FrameMarker_SwapBuffers),
-      m_needsSaving(false)
+    : m_needsSaving(false)
 {
     m_loader = new TraceLoader();
 
@@ -23,6 +22,8 @@ ApiTrace::ApiTrace()
             SIGNAL(frameContentsLoaded(ApiTraceFrame*,QVector<ApiTraceCall*>,quint64)),
             this,
             SLOT(loaderFrameLoaded(ApiTraceFrame*,QVector<ApiTraceCall*>,quint64)));
+    connect(m_loader, SIGNAL(guessedApi(int)),
+            this, SLOT(guessedApi(int)));
     connect(m_loader, SIGNAL(finishedParsing()),
             this, SLOT(finishedParsing()));
     connect(this, SIGNAL(loaderSearch(ApiTrace::SearchRequest)),
@@ -73,29 +74,6 @@ ApiTrace::~ApiTrace()
     delete m_saver;
 }
 
-bool ApiTrace::isCallAFrameMarker(const ApiTraceCall *call,
-                                  ApiTrace::FrameMarker marker)
-{
-    if (!call) {
-        return false;
-    }
-
-    switch (marker) {
-    case FrameMarker_SwapBuffers:
-        return call->flags() & trace::CALL_FLAG_END_FRAME;
-    case FrameMarker_Flush:
-        return call->name() == QLatin1String("glFlush");
-    case FrameMarker_Finish:
-        return call->name() == QLatin1String("glFinish");
-    case FrameMarker_Clear:
-        return call->name() == QLatin1String("glClear");
-    }
-
-    Q_ASSERT(!"unknown frame marker");
-
-    return false;
-}
-
 bool ApiTrace::isEmpty() const
 {
     return m_frames.isEmpty();
@@ -110,12 +88,7 @@ QString ApiTrace::fileName() const
     return m_fileName;
 }
 
-ApiTrace::FrameMarker ApiTrace::frameMarker() const
-{
-    return m_frameMarker;
-}
-
-QList<ApiTraceFrame*> ApiTrace::frames() const
+const QList<ApiTraceFrame*> & ApiTrace::frames() const
 {
     return m_frames;
 }
@@ -257,7 +230,7 @@ bool ApiTrace::isSaving() const
 
 bool ApiTrace::hasErrors() const
 {
-    return !m_errors.isEmpty();
+    return !m_errors.isEmpty() || !m_queuedErrors.isEmpty();
 }
 
 void ApiTrace::loadFrame(ApiTraceFrame *frame)
@@ -269,11 +242,23 @@ void ApiTrace::loadFrame(ApiTraceFrame *frame)
     }
 }
 
+void ApiTrace::guessedApi(int api)
+{
+    m_api = static_cast<trace::API>(api);
+}
+
+trace::API ApiTrace::api() const
+{
+    return m_api;
+}
+
 void ApiTrace::finishedParsing()
 {
-    ApiTraceFrame *firstFrame = m_frames[0];
-    if (firstFrame && !firstFrame->isLoaded()) {
-        loadFrame(firstFrame);
+    if (!m_frames.isEmpty()) {
+        ApiTraceFrame *firstFrame = m_frames[0];
+        if (firstFrame && !firstFrame->isLoaded()) {
+            loadFrame(firstFrame);
+        }
     }
 }
 
@@ -450,7 +435,7 @@ int ApiTrace::callInFrame(int callIdx) const
 {
     unsigned numCalls = 0;
 
-    for (int frameIdx = 0; frameIdx <= m_frames.size(); ++frameIdx) {
+    for (int frameIdx = 0; frameIdx < m_frames.size(); ++frameIdx) {
         const ApiTraceFrame *frame = m_frames[frameIdx];
         unsigned numCallsInFrame =  frame->isLoaded()
                 ? frame->numChildren()
@@ -496,4 +481,21 @@ bool ApiTrace::isFrameLoading(ApiTraceFrame *frame) const
     return m_loadingFrames.contains(frame);
 }
 
+void ApiTrace::bindThumbnailsToFrames(const QList<QImage> &thumbnails)
+{
+    QList<ApiTraceFrame *> frames = m_frames;
+
+    QList<QImage>::const_iterator thumbnail = thumbnails.begin();
+
+    foreach (ApiTraceFrame *frame, frames) {
+        if (thumbnail != thumbnails.end()) {
+            frame->setThumbnail(*thumbnail);
+
+            ++thumbnail;
+
+            emit changed(frame);
+        }
+    }
+}
+
 #include "apitrace.moc"
index 2833f60cddf90d5063cf7b40d8f951d5b1e0181c..04e295cd7e39470476990d834b5085be7bf77997 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "apitracecall.h"
 
+#include "trace_api.hpp"
+
 #include <QObject>
 #include <QSet>
 
@@ -14,12 +16,6 @@ class ApiTrace : public QObject
 {
     Q_OBJECT
 public:
-    enum FrameMarker {
-        FrameMarker_SwapBuffers,
-        FrameMarker_Flush,
-        FrameMarker_Finish,
-        FrameMarker_Clear
-    };
     enum SearchResult {
         SearchResult_NotFound,
         SearchResult_Found,
@@ -51,8 +47,6 @@ public:
         Qt::CaseSensitivity cs;
     };
 
-    static bool isCallAFrameMarker(const ApiTraceCall *call,
-                                   FrameMarker marker);
 public:
     ApiTrace();
     ~ApiTrace();
@@ -61,13 +55,11 @@ public:
 
     QString fileName() const;
 
-    FrameMarker frameMarker() const;
-
     ApiTraceState defaultState() const;
 
     ApiTraceCall *callWithIndex(int idx) const;
 
-    QList<ApiTraceFrame*> frames() const;
+    const QList<ApiTraceFrame*> & frames() const;
     ApiTraceFrame *frameAt(int idx) const;
     int numFrames() const;
     int numCallsInFrame(int idx) const;
@@ -83,6 +75,8 @@ public:
 
     bool hasErrors() const;
 
+    trace::API api() const;
+
 public slots:
     void setFileName(const QString &name);
     void save();
@@ -100,6 +94,7 @@ public slots:
     void findCallIndex(int index);
     void setCallError(const ApiTraceError &error);
 
+    void bindThumbnailsToFrames(const QList<QImage> &thumbnails);
 
 signals:
     void loadTrace(const QString &name);
@@ -109,7 +104,7 @@ signals:
     void finishedLoadingTrace();
     void invalidated();
     void framesInvalidated();
-    void changed(ApiTraceCall *call);
+    void changed(ApiTraceEvent *event);
     void startedSaving();
     void saved();
     void findResult(const ApiTrace::SearchRequest &request,
@@ -133,6 +128,7 @@ signals:
 private slots:
     void addFrames(const QList<ApiTraceFrame*> &frames);
     void slotSaved();
+    void guessedApi(int api);
     void finishedParsing();
     void loaderFrameLoaded(ApiTraceFrame *frame,
                            const QVector<ApiTraceCall*> &calls,
@@ -149,8 +145,7 @@ private:
     QString m_tempFileName;
 
     QList<ApiTraceFrame*> m_frames;
-
-    FrameMarker m_frameMarker;
+    trace::API m_api;
 
     TraceLoader *m_loader;
     QThread     *m_loaderThread;
index 267dc0980edeaaa7ea02c26de9e981d25e96b6fa..907e10aa08294fc878549708a92e074fc9eb2681 100644 (file)
@@ -227,6 +227,12 @@ void VariantVisitor::visit(trace::Pointer *ptr)
     m_variant = QVariant::fromValue(ApiPointer(ptr->value));
 }
 
+void VariantVisitor::visit(trace::Repr *repr)
+{
+    /* TODO: Preserve both the human and machine value */
+    repr->humanValue->visit(*this);
+}
+
 ApiTraceEnumSignature::ApiTraceEnumSignature(const trace::EnumSig *sig)
 {
     for (const trace::EnumValue *it = sig->values;
@@ -336,7 +342,6 @@ void ApiBitmask::init(const trace::Bitmask *bitmask)
     m_value = bitmask->value;
     for (const trace::BitmaskFlag *it = bitmask->sig->flags;
          it != bitmask->sig->flags + bitmask->sig->num_flags; ++it) {
-        assert(it->value);
         QPair<QString, unsigned long long> pair;
 
         pair.first = QString::fromStdString(it->name);
@@ -351,10 +356,10 @@ QString ApiBitmask::toString() const
     QString str;
     unsigned long long value = m_value;
     bool first = true;
-    for (Signature::const_iterator it = m_sig.begin();
-         value != 0 && it != m_sig.end(); ++it) {
-        Q_ASSERT(it->second);
-        if ((value & it->second) == it->second) {
+    for (Signature::const_iterator it = m_sig.begin(); it != m_sig.end(); ++it) {
+        Q_ASSERT(it->second || first);
+        if ((it->second && (value & it->second) == it->second) ||
+            (!it->second && value == 0)) {
             if (!first) {
                 str += QLatin1String(" | ");
             }
@@ -362,6 +367,9 @@ QString ApiBitmask::toString() const
             value &= ~it->second;
             first = false;
         }
+        if (value == 0) {
+            break;
+        }
     }
     if (value || first) {
         if (!first) {
@@ -1197,3 +1205,13 @@ unsigned ApiTraceFrame::lastCallIndex() const
         return m_lastCallIndex;
     }
 }
+
+void ApiTraceFrame::setThumbnail(const QImage & thumbnail)
+{
+    m_thumbnail = thumbnail;
+}
+
+const QImage & ApiTraceFrame::thumbnail() const
+{
+    return m_thumbnail;
+}
index 3a9faafd495e851c281609d5c7c94e9431020c7d..6c6b6074b6dcae2799e1f4a750cdc293120c3f53 100644 (file)
@@ -33,6 +33,7 @@ public:
     virtual void visit(trace::Array *array);
     virtual void visit(trace::Blob *blob);
     virtual void visit(trace::Pointer *ptr);
+    virtual void visit(trace::Repr *ptr);
 
     QVariant variant() const
     {
@@ -335,6 +336,10 @@ public:
 
     void setLastCallIndex(unsigned index);
     unsigned lastCallIndex() const;
+
+    void setThumbnail(const QImage & thumbnail);
+    const QImage & thumbnail() const;
+
 private:
     ApiTrace *m_parentTrace;
     quint64 m_binaryDataSize;
@@ -342,6 +347,7 @@ private:
     bool m_loaded;
     unsigned m_callsToLoad;
     unsigned m_lastCallIndex;
+    QImage m_thumbnail;
 };
 Q_DECLARE_METATYPE(ApiTraceFrame*);
 
index 7303ae1c31e836bb2e507fe9b5fd34af657fa574..0863c1b5bc0eb19ad1b649b9d83442483a2fc5ad 100644 (file)
@@ -248,8 +248,8 @@ void ApiTraceModel::setApiTrace(ApiTrace *trace)
             this, SLOT(beginAddingFrames(int, int)));
     connect(m_trace, SIGNAL(endAddingFrames()),
             this, SLOT(endAddingFrames()));
-    connect(m_trace, SIGNAL(changed(ApiTraceCall*)),
-            this, SLOT(callChanged(ApiTraceCall*)));
+    connect(m_trace, SIGNAL(changed(ApiTraceEvent*)),
+            this, SLOT(changed(ApiTraceEvent*)));
     connect(m_trace, SIGNAL(beginLoadingFrame(ApiTraceFrame*,int)),
             this, SLOT(beginLoadingFrame(ApiTraceFrame*,int)));
     connect(m_trace, SIGNAL(endLoadingFrame(ApiTraceFrame*)),
@@ -294,7 +294,7 @@ void ApiTraceModel::stateSetOnEvent(ApiTraceEvent *event)
         emit dataChanged(index, index);
     } else if (event->type() == ApiTraceEvent::Frame) {
         ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
-        const QList<ApiTraceFrame*> frames = m_trace->frames();
+        const QList<ApiTraceFrame*> frames = m_trace->frames();
         int row = frames.indexOf(frame);
         QModelIndex index = createIndex(row, 0, frame);
         emit dataChanged(index, index);
@@ -318,6 +318,15 @@ QModelIndex ApiTraceModel::indexForCall(ApiTraceCall *call) const
     return createIndex(row, 0, call);
 }
 
+void ApiTraceModel::changed(ApiTraceEvent *event)
+{
+    if (event->type() == ApiTraceEvent::Call) {
+        callChanged(static_cast<ApiTraceCall*>(event));
+    } else if (event->type() == ApiTraceEvent::Frame) {
+        frameChanged(static_cast<ApiTraceFrame*>(event));
+    }
+}
+
 void ApiTraceModel::callChanged(ApiTraceCall *call)
 {
     ApiTrace *trace = call->parentFrame()->parentTrace();
@@ -339,6 +348,14 @@ void ApiTraceModel::callChanged(ApiTraceCall *call)
     emit dataChanged(index, index);
 }
 
+void ApiTraceModel::frameChanged(ApiTraceFrame *frame)
+{
+    const QList<ApiTraceFrame*> & frames = m_trace->frames();
+    int row = frames.indexOf(frame);
+    QModelIndex index = createIndex(row, 0, frame);
+    emit dataChanged(index, index);
+}
+
 void ApiTraceModel::endAddingFrames()
 {
     endInsertRows();
index fe6b5cea69deb5f0702c8af239066b1db5b806bb..e7354aa6350191ad55aee5a8abe9d675079dfeeb 100644 (file)
@@ -54,7 +54,9 @@ private slots:
     void invalidateFrames();
     void beginAddingFrames(int oldCount, int numAdded);
     void endAddingFrames();
+    void changed(ApiTraceEvent *event);
     void callChanged(ApiTraceCall *call);
+    void frameChanged(ApiTraceFrame *frame);
     void beginLoadingFrame(ApiTraceFrame *frame, int numAdded);
     void endLoadingFrame(ApiTraceFrame *frame);
 
diff --git a/gui/calldurationgraph.h b/gui/calldurationgraph.h
new file mode 100644 (file)
index 0000000..0c7e8c9
--- /dev/null
@@ -0,0 +1,173 @@
+#ifndef CALLDURATIONGRAPH_H
+#define CALLDURATIONGRAPH_H
+
+#include "graphing/graphwidget.h"
+#include "trace_profiler.hpp"
+#include "profiling.h"
+
+/**
+ * Wrapper for call duration graphs.
+ *
+ * This implements the transformSelectionIn and transformSelectionOut to
+ * allow sharing the selection between the graphs and the heatmap as they
+ * are using different scales. The duration graphs have call.no on the X-axis
+ * whereas the heatmap has time on the X axis.
+ */
+class CallDurationGraph : public GraphWidget {
+public:
+    CallDurationGraph(QWidget* parent = 0) :
+        GraphWidget(parent),
+        m_profile(NULL)
+    {
+    }
+
+    void setProfile(const trace::Profile* profile)
+    {
+        m_profile = profile;
+    }
+
+protected:
+    /* Transform from time-based horizontal selection to call no based. */
+    virtual SelectionState transformSelectionIn(SelectionState state)
+    {
+        if (!m_profile || state.type != SelectionState::Horizontal) {
+            return state;
+        }
+
+        qint64 timeStart = state.start;
+        qint64 timeEnd = state.end;
+
+        std::vector<trace::Profile::Call>::const_iterator itr;
+
+        itr =
+            Profiling::binarySearchTimespan<
+                trace::Profile::Call,
+                &trace::Profile::Call::cpuStart,
+                &trace::Profile::Call::cpuDuration>
+            (m_profile->calls.begin(), m_profile->calls.end(), timeStart, true);
+
+        state.start = itr - m_profile->calls.begin();
+
+        itr =
+            Profiling::binarySearchTimespan<
+                trace::Profile::Call,
+                &trace::Profile::Call::cpuStart,
+                &trace::Profile::Call::cpuDuration>
+            (m_profile->calls.begin(), m_profile->calls.end(), timeEnd, true);
+
+        state.end = itr - m_profile->calls.begin();
+
+        return state;
+    }
+
+    virtual SelectionState transformSelectionOut(SelectionState state)
+    {
+        if (!m_profile || state.type != SelectionState::Horizontal) {
+            return state;
+        }
+
+        qint64 start = qMax<qint64>(0, state.start);
+        qint64 end = qMin<qint64>(state.end, m_profile->calls.size());
+
+        /* Call based -> time based */
+        state.start = m_profile->calls[start].cpuStart;
+        state.end = m_profile->calls[end].cpuStart + m_profile->calls[end].cpuDuration;
+
+        return state;
+    }
+
+private:
+    const trace::Profile* m_profile;
+};
+
+/* Data provider for call duration graphs */
+class CallDurationDataProvider : public GraphDataProvider {
+public:
+    CallDurationDataProvider(const trace::Profile* profile, bool gpu) :
+        m_gpu(gpu),
+        m_profile(profile),
+        m_selectionState(NULL)
+    {
+    }
+
+    virtual qint64 size() const
+    {
+        return m_profile ? m_profile->calls.size() : 0;
+    }
+
+    virtual bool selected(qint64 index) const
+    {
+        if (m_selectionState) {
+            if (m_selectionState->type == SelectionState::Horizontal) {
+                if (m_selectionState->start <= index && index < m_selectionState->end) {
+                    return true;
+                }
+            } else if (m_selectionState->type == SelectionState::Vertical) {
+                return m_profile->calls[index].program == m_selectionState->start;
+            }
+        }
+
+        return false;
+    }
+
+    virtual void setSelectionState(SelectionState* state)
+    {
+        m_selectionState = state;
+    }
+
+    virtual qint64 value(qint64 index) const
+    {
+        if (m_gpu) {
+            return m_profile->calls[index].gpuDuration;
+        } else {
+            return m_profile->calls[index].cpuDuration;
+        }
+    }
+
+    virtual void itemDoubleClicked(qint64 index) const
+    {
+        if (!m_profile) {
+            return;
+        }
+
+        if (index < 0 || index >= m_profile->calls.size()) {
+            return;
+        }
+
+        const trace::Profile::Call& call = m_profile->calls[index];
+        Profiling::jumpToCall(call.no);
+    }
+
+    virtual QString itemTooltip(qint64 index) const
+    {
+        if (!m_profile) {
+            return QString();
+        }
+
+        if (index < 0 || index >= m_profile->calls.size()) {
+            return QString();
+        }
+
+        const trace::Profile::Call& call = m_profile->calls[index];
+
+        QString text;
+        text  = QString::fromStdString(call.name);
+        text += QString("\nCall: %1").arg(call.no);
+        text += QString("\nCPU Duration: %1").arg(Profiling::getTimeString(call.cpuDuration));
+
+        if (call.pixels >= 0) {
+            text += QString("\nGPU Duration: %1").arg(Profiling::getTimeString(call.gpuDuration));
+            text += QString("\nPixels Drawn: %1").arg(QLocale::system().toString((qlonglong)call.pixels));
+            text += QString("\nProgram: %1").arg(call.program);
+        }
+
+        return text;
+    }
+
+private:
+    bool m_gpu;
+    const trace::Profile* m_profile;
+    SelectionState* m_selectionState;
+};
+
+#endif
diff --git a/gui/graphing/frameaxiswidget.cpp b/gui/graphing/frameaxiswidget.cpp
new file mode 100644 (file)
index 0000000..ad5d868
--- /dev/null
@@ -0,0 +1,99 @@
+#include "frameaxiswidget.h"
+
+#include <QPainter>
+
+FrameAxisWidget::FrameAxisWidget(QWidget* parent) :
+    GraphAxisWidget(parent),
+    m_data(NULL)
+{
+    setSelectable(GraphAxisWidget::Range);
+}
+
+void FrameAxisWidget::setDataProvider(FrameDataProvider* data)
+{
+    delete m_data;
+    m_data = data;
+}
+
+void FrameAxisWidget::paintEvent(QPaintEvent *)
+{
+    if (!m_data || m_orientation != GraphAxisWidget::Horizontal) {
+        /* TODO: Vertical axis support */
+        return;
+    }
+
+    QPainter painter(this);
+    painter.setPen(Qt::black);
+    painter.setBrush(Qt::lightGray);
+    painter.drawRect(0, 0, width() - 1, height() - 1);
+
+    qint64 range = m_valueEnd - m_valueBegin;
+    double dxdv = width() / (double)range;
+    double scroll = dxdv * m_valueBegin;
+    int lastLabel = -9999;
+
+    /* Iterate over frames, drawing a label when there is space to do so */
+    for (unsigned i = 0; i < m_data->size(); ++i) {
+        static const int padding = 4;
+        qint64 start = m_data->frameStart(i);
+        qint64 end = m_data->frameEnd(i);
+        bool visible = false;
+
+        if (start > m_valueEnd) {
+            break;
+        }
+
+        if (end < m_valueBegin) {
+            visible = false;
+        }
+
+        double left = dxdv * start;
+        double right = dxdv * end;
+        QString text = QString("%1").arg(i);
+
+        int width = painter.fontMetrics().width(text) + padding * 2;
+
+        if (right > scroll) {
+            visible = true;
+        }
+
+        if (left - lastLabel > width) {
+            lastLabel = left + width;
+
+            if (visible) {
+                int textX;
+
+                if (left < scroll && right - left > width) {
+                    if (right - scroll > width) {
+                        textX = 0;
+                    } else {
+                        textX = right - scroll - width;
+                    }
+                } else {
+                    textX = left - scroll;
+                }
+
+                painter.drawText(textX + padding, 0, width - padding, height() - 5, Qt::AlignLeft | Qt::AlignVCenter, text);
+                painter.drawLine(left - scroll, height() / 2, left - scroll, height() - 1);
+            }
+        } else if (visible) {
+            painter.drawLine(left - scroll, height() * 3/4.0, left - scroll, height() - 1);
+        }
+    }
+
+    /* Draw selection */
+    if (hasSelection()) {
+        double left = (dxdv * m_selectionState->start) - scroll;
+        double right = (dxdv * m_selectionState->end) - scroll;
+
+        painter.setPen(Qt::green);
+
+        if (left >= 0 && left <= width()) {
+            painter.drawLine(left, 0, left, height());
+        }
+
+        if (right >= 0 && right <= width()) {
+            painter.drawLine(right, 0, right, height());
+        }
+    }
+}
diff --git a/gui/graphing/frameaxiswidget.h b/gui/graphing/frameaxiswidget.h
new file mode 100644 (file)
index 0000000..db091d9
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef FRAMEAXISWIDGET_H
+#define FRAMEAXISWIDGET_H
+
+#include "graphaxiswidget.h"
+
+class FrameDataProvider {
+public:
+    /* Number of frames */
+    virtual unsigned size() const = 0;
+
+    /* Start and end values of frame */
+    virtual qint64 frameStart(unsigned frame) const = 0;
+    virtual qint64 frameEnd(unsigned frame) const = 0;
+};
+
+/**
+ * A generic axis which will draw frame numbers over a period of values.
+ * Frames designated by start / end values.
+ */
+class FrameAxisWidget : public GraphAxisWidget {
+public:
+    FrameAxisWidget(QWidget* parent = 0);
+
+    void setDataProvider(FrameDataProvider* data);
+
+    virtual void paintEvent(QPaintEvent *e);
+
+protected:
+    FrameDataProvider* m_data;
+};
+
+#endif
diff --git a/gui/graphing/graphaxiswidget.cpp b/gui/graphing/graphaxiswidget.cpp
new file mode 100644 (file)
index 0000000..0adeadd
--- /dev/null
@@ -0,0 +1,141 @@
+#include "graphaxiswidget.h"
+
+#include <QMouseEvent>
+
+GraphAxisWidget::GraphAxisWidget(QWidget* parent) :
+    QWidget(parent),
+    m_selectable(None),
+    m_selectionState(NULL)
+{
+}
+
+
+bool GraphAxisWidget::hasSelection()
+{
+    if (!m_selectionState) {
+        return false;
+    }
+
+    if (m_selectionState->type == SelectionState::Horizontal && m_orientation == GraphAxisWidget::Horizontal) {
+        return true;
+    }
+
+    if (m_selectionState->type == SelectionState::Vertical && m_orientation == GraphAxisWidget::Vertical) {
+        return true;
+    }
+
+    return false;
+}
+
+
+void GraphAxisWidget::setSelectable(SelectionStyle selectable)
+{
+    m_selectable = selectable;
+}
+
+
+void GraphAxisWidget::setSelectionState(SelectionState* state)
+{
+    m_selectionState = state;
+}
+
+
+void GraphAxisWidget::setOrientation(Orientation v)
+{
+    m_orientation = v;
+
+    if (m_orientation == Horizontal) {
+        setMinimumWidth(60);
+    } else {
+        setMinimumHeight(60);
+    }
+}
+
+
+void GraphAxisWidget::mouseMoveEvent(QMouseEvent *e)
+{
+    if (m_selectable == None) {
+        return;
+    }
+
+    int pos, max;
+
+    if (m_orientation == Horizontal) {
+        pos = e->x();
+        max = width();
+    } else {
+        pos = e->y();
+        max = height();
+    }
+
+    double value = m_valueEnd - m_valueBegin;
+    value *= pos / (double)max;
+    value += m_valueBegin;
+
+    if (e->buttons().testFlag(Qt::LeftButton)) {
+        m_selectionState->start = qMin<qint64>(m_mousePressValue, value);
+        m_selectionState->end = qMax<qint64>(m_mousePressValue, value);
+        m_selectionState->type = m_orientation == Horizontal ? SelectionState::Horizontal : SelectionState::Vertical;
+        emit selectionChanged();
+        update();
+    }
+}
+
+
+void GraphAxisWidget::mousePressEvent(QMouseEvent *e)
+{
+    if (m_selectable == None) {
+        return;
+    }
+
+    int pos, max;
+
+    if (m_orientation == Horizontal) {
+        pos = e->x();
+        max = width();
+    } else {
+        pos = e->y();
+        max = height();
+    }
+
+    double value = m_valueEnd - m_valueBegin;
+    value *= pos / (double)max;
+    value += m_valueBegin;
+
+    m_mousePressPosition = e->pos();
+    m_mousePressValue = value;
+}
+
+
+void GraphAxisWidget::mouseReleaseEvent(QMouseEvent *e)
+{
+    if (m_selectable == None) {
+        return;
+    }
+
+    int dx = qAbs(m_mousePressPosition.x() - e->x());
+    int dy = qAbs(m_mousePressPosition.y() - e->y());
+
+    if (dx + dy < 2) {
+        m_selectionState->type = SelectionState::None;
+        emit selectionChanged();
+    }
+}
+
+
+void GraphAxisWidget::setRange(qint64 min, qint64 max)
+{
+    m_valueMin = min;
+    m_valueMax = max;
+    update();
+}
+
+
+void GraphAxisWidget::setView(qint64 start, qint64 end)
+{
+    m_valueBegin = start;
+    m_valueEnd = end;
+    update();
+}
+
+#include "graphaxiswidget.moc"
diff --git a/gui/graphing/graphaxiswidget.h b/gui/graphing/graphaxiswidget.h
new file mode 100644 (file)
index 0000000..6ae0080
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef GRAPHAXISWIDGET_H
+#define GRAPHAXISWIDGET_H
+
+#include "graphing.h"
+
+#include <QWidget>
+
+/**
+ * The generic base class of all graph axes.
+ *
+ * Handles orientation, simple selections, and view area.
+ */
+class GraphAxisWidget : public QWidget {
+    Q_OBJECT
+public:
+    enum Orientation {
+        Horizontal,
+        Vertical
+    };
+
+    enum SelectionStyle {
+        None,
+        Single,
+        Range
+    };
+
+public:
+    GraphAxisWidget(QWidget* parent = 0);
+    virtual ~GraphAxisWidget(){}
+
+    /* Is this axis part of the active selection */
+    bool hasSelection();
+
+    void setSelectable(SelectionStyle selectable);
+    void setSelectionState(SelectionState* state);
+
+    void setOrientation(Orientation v);
+
+    virtual void mouseMoveEvent(QMouseEvent *e);
+    virtual void mousePressEvent(QMouseEvent *e);
+    virtual void mouseReleaseEvent(QMouseEvent *e);
+
+public slots:
+    /* The minimum and maximum values of this axis */
+    void setRange(qint64 min, qint64 max);
+
+    /* The currently visible range of values */
+    void setView(qint64 start, qint64 end);
+
+signals:
+    void selectionChanged();
+
+protected:
+    Orientation m_orientation;
+
+    /* The min/max value of this axis */
+    qint64 m_valueMin;
+    qint64 m_valueMax;
+
+    /* The highest and lowest currently visible value */
+    qint64 m_valueBegin;
+    qint64 m_valueEnd;
+
+    /* Selection */
+    SelectionStyle m_selectable;
+    SelectionState* m_selectionState;
+
+    /* Mouse tracking */
+    QPoint m_mousePressPosition;
+    qint64 m_mousePressValue;
+};
+
+#endif
diff --git a/gui/graphing/graphing.h b/gui/graphing/graphing.h
new file mode 100644 (file)
index 0000000..35b4a91
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef GRAPHING_H
+#define GRAPHING_H
+
+#include <QString>
+
+/**
+ * A simple struct to hold a horizontal or vertical selection
+ */
+struct SelectionState {
+    enum SelectionType {
+        None,
+        Horizontal,
+        Vertical
+    };
+
+    SelectionType type;
+    qint64 start;
+    qint64 end;
+};
+
+
+/**
+ * Fairly generic data provider for graphs
+ */
+class GraphDataProvider {
+public:
+    virtual ~GraphDataProvider(){}
+
+    /* Number of elements in graph */
+    virtual qint64 size() const = 0;
+
+    /* Returns value for index */
+    virtual qint64 value(qint64 index) const = 0;
+
+    /* Is the item at index selected */
+    virtual bool selected(qint64 index) const = 0;
+
+    /* Get mouse hover tooltip for item */
+    virtual QString itemTooltip(qint64 index) const = 0;
+
+    /* Called on item double click */
+    virtual void itemDoubleClicked(qint64 index) const = 0;
+
+    /* Set pointer to selection state */
+    virtual void setSelectionState(SelectionState* state) = 0;
+};
+
+#endif
diff --git a/gui/graphing/graphlabelwidget.h b/gui/graphing/graphlabelwidget.h
new file mode 100644 (file)
index 0000000..49c0cd4
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef GRAPHLABELWIDGET_H
+#define GRAPHLABELWIDGET_H
+
+#include <QWidget>
+#include <QPainter>
+
+/**
+ * A very simple label widget, basically a box with text in.
+ */
+class GraphLabelWidget : public QWidget {
+public:
+    GraphLabelWidget(QString text = QString(), QWidget* parent = 0) :
+        QWidget(parent),
+        m_flags(Qt::AlignHCenter | Qt::AlignVCenter),
+        m_text(text)
+    {
+    }
+
+    void setText(const QString& text)
+    {
+        m_text = text;
+    }
+
+    void setFlags(int flags)
+    {
+        m_flags = flags;
+    }
+
+    virtual void paintEvent(QPaintEvent *)
+    {
+        QPainter painter(this);
+        painter.setPen(Qt::black);
+        painter.fillRect(rect(), Qt::lightGray);
+        painter.drawText(rect(), m_flags, m_text);
+    }
+
+protected:
+    int m_flags;
+    QString m_text;
+};
+
+#endif
diff --git a/gui/graphing/graphview.cpp b/gui/graphing/graphview.cpp
new file mode 100644 (file)
index 0000000..6ecac57
--- /dev/null
@@ -0,0 +1,187 @@
+#include "graphview.h"
+
+#include <QMouseEvent>
+#include <QApplication>
+
+GraphView::GraphView(QWidget* parent) :
+    QWidget(parent),
+    m_selectionState(NULL),
+    m_viewLeft(0),
+    m_viewRight(0),
+    m_viewBottom(0),
+    m_viewTop(0),
+    m_graphLeft(0),
+    m_graphRight(0),
+    m_graphBottom(0),
+    m_graphTop(0),
+    m_viewWidth(0),
+    m_viewWidthMin(0),
+    m_viewWidthMax(0),
+    m_viewHeight(0),
+    m_viewHeightMin(0),
+    m_viewHeightMax(0)
+{
+    memset(&m_previous, -1, sizeof(m_previous));
+}
+
+void GraphView::update()
+{
+    if (m_graphLeft != m_previous.m_graphLeft || m_graphRight != m_previous.m_graphRight) {
+        m_previous.m_graphLeft = m_graphLeft;
+        m_previous.m_graphRight = m_graphRight;
+
+        emit horizontalRangeChanged(m_graphLeft, m_graphRight);
+    }
+
+    if (m_viewLeft != m_previous.m_viewLeft || m_viewRight != m_previous.m_viewRight) {
+        m_previous.m_viewLeft = m_viewLeft;
+        m_previous.m_viewRight = m_viewRight;
+
+        emit horizontalViewChanged(m_viewLeft, m_viewRight);
+    }
+
+    if (m_graphBottom != m_previous.m_graphBottom || m_graphTop != m_previous.m_graphTop) {
+        m_previous.m_graphBottom = m_graphBottom;
+        m_previous.m_graphTop = m_graphTop;
+
+        emit verticalRangeChanged(m_graphBottom, m_graphTop);
+    }
+
+    if (m_viewBottom != m_previous.m_viewBottom || m_viewTop != m_previous.m_viewTop) {
+        m_previous.m_viewBottom = m_viewBottom;
+        m_previous.m_viewTop = m_viewTop;
+
+        emit verticalViewChanged(m_viewBottom, m_viewTop);
+    }
+
+    QWidget::update();
+}
+
+void GraphView::resizeEvent(QResizeEvent *)
+{
+    m_viewHeight = height();
+    m_viewHeightMin = m_viewHeight;
+    m_viewHeightMax = m_viewHeight;
+
+    m_viewTop = m_viewBottom + m_viewHeight;
+
+    update();
+}
+
+void GraphView::wheelEvent(QWheelEvent *e)
+{
+    int zoomPercent = 10;
+
+    /* If holding Ctrl key then zoom 2x faster */
+    if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
+        zoomPercent = 20;
+    }
+
+    /* Zoom view by adjusting width */
+    double dt = m_viewWidth;
+    double size = dt;
+    size *= -e->delta();
+
+    /* Zoom deltas normally come in increments of 120 */
+    size /= 120 * (100 / zoomPercent);
+
+    m_viewWidth += size;
+    m_viewWidth = qBound(m_viewWidthMin, m_viewWidth, m_viewWidthMax);
+
+    /* Scroll view to zoom around mouse */
+    dt -= m_viewWidth;
+    dt *= e->x();
+    dt /= width();
+
+    m_viewLeft = dt + m_viewLeft;
+    m_viewLeft = qBound(m_graphLeft, m_viewLeft, m_graphRight - m_viewWidth);
+    m_viewRight = m_viewLeft + m_viewWidth;
+
+    update();
+}
+
+void GraphView::mouseMoveEvent(QMouseEvent *e)
+{
+    if (e->buttons().testFlag(Qt::LeftButton)) {
+        /* Horizontal scroll */
+        double dvdx = m_viewWidth / (double)width();
+        dvdx *= m_mousePressPosition.x() - e->pos().x();
+
+        m_viewLeft = m_mousePressViewLeft + dvdx;
+        m_viewLeft = qBound(m_graphLeft, m_viewLeft, m_graphRight - m_viewWidth);
+        m_viewRight = m_viewLeft + m_viewWidth;
+
+        /* Vertical scroll */
+        double dvdy = m_viewHeight / (double)height();
+        dvdy *= m_mousePressPosition.y() - e->pos().y();
+
+        m_viewBottom = m_mousePressViewBottom + dvdy;
+        m_viewBottom = qBound(m_graphBottom, m_viewBottom, m_graphTop - m_viewHeight);
+        m_viewTop = m_viewBottom + m_viewHeight;
+
+        update();
+    }
+}
+
+void GraphView::mousePressEvent(QMouseEvent *e)
+{
+    m_mousePressPosition = e->pos();
+    m_mousePressViewLeft = m_viewLeft;
+    m_mousePressViewBottom = m_viewBottom;
+}
+
+void GraphView::mouseDoubleClickEvent(QMouseEvent *e)
+{
+    if (m_selectionState) {
+        m_selectionState->type = SelectionState::None;
+        emit selectionChanged();
+    }
+}
+
+void GraphView::setSelectionState(SelectionState* state)
+{
+    m_selectionState = state;
+}
+
+void GraphView::setHorizontalView(qint64 start, qint64 end)
+{
+    m_viewLeft = qBound(m_graphLeft, start, m_graphRight - (end - start));
+    m_viewRight = qBound(m_graphLeft, end, m_graphRight);
+    m_viewWidth = m_viewRight - m_viewLeft;
+    update();
+}
+
+void GraphView::setVerticalView(qint64 start, qint64 end)
+{
+    m_viewBottom = qBound(m_graphBottom, start, m_graphTop - (end - start));
+    m_viewTop = qBound(m_graphBottom, end, m_graphTop);
+    m_viewHeight = m_viewTop - m_viewBottom;
+    update();
+}
+
+void GraphView::setDefaultView(qint64 min, qint64 max)
+{
+    m_graphLeft = min;
+    m_graphRight = max;
+    m_viewWidth = max - min;
+
+    m_viewWidthMin = 1;
+    m_viewWidthMax = m_viewWidth;
+
+    m_viewLeft = min;
+    m_viewRight = max;
+
+    m_viewHeight = height();
+    m_viewHeightMin = m_viewHeight;
+    m_viewHeightMax = m_viewHeight;
+
+    m_viewBottom = 0;
+    m_viewTop = m_viewHeight;
+
+    m_graphBottom = 0;
+    m_graphTop = m_viewHeight;
+
+    update();
+}
+
+#include "graphview.moc"
diff --git a/gui/graphing/graphview.h b/gui/graphing/graphview.h
new file mode 100644 (file)
index 0000000..6b881d4
--- /dev/null
@@ -0,0 +1,93 @@
+#ifndef GRAPHVIEW_H
+#define GRAPHVIEW_H
+
+#include "graphing.h"
+
+#include <QWidget>
+
+/**
+ * The generic base class for a graph's view, this is the component that
+ * displays the actual data for the graph.
+ *
+ * - Stores the view area within the graph
+ * - Simple user interaction such as translating and zooming with mouse
+ * - Selection tracking synchronised with axis
+ */
+class GraphView : public QWidget {
+    Q_OBJECT
+public:
+    GraphView(QWidget* parent = 0);
+    virtual ~GraphView(){}
+
+    virtual void update();
+
+    virtual void resizeEvent(QResizeEvent *);
+
+    virtual void wheelEvent(QWheelEvent *e);
+    virtual void mouseMoveEvent(QMouseEvent *e);
+    virtual void mousePressEvent(QMouseEvent *e);
+    virtual void mouseDoubleClickEvent(QMouseEvent *e);
+
+    virtual void setSelectionState(SelectionState* state);
+
+    void setHorizontalView(qint64 start, qint64 end);
+    void setVerticalView(qint64 start, qint64 end);
+
+protected:
+    void setDefaultView(qint64 min, qint64 max);
+
+signals:
+    void selectionChanged();
+
+    void verticalViewChanged(qint64 start, qint64 end);
+    void verticalRangeChanged(qint64 min, qint64 max);
+
+    void horizontalRangeChanged(qint64 min, qint64 max);
+    void horizontalViewChanged(qint64 start, qint64 end);
+
+protected:
+    /* Viewport area */
+    qint64 m_viewLeft;
+    qint64 m_viewRight;
+    qint64 m_viewBottom;
+    qint64 m_viewTop;
+
+    /* Graph limits */
+    qint64 m_graphLeft;
+    qint64 m_graphRight;
+    qint64 m_graphBottom;
+    qint64 m_graphTop;
+
+    /* Viewport width (m_viewRight - m_viewLeft), used for zoom */
+    qint64 m_viewWidth;
+    qint64 m_viewWidthMin;
+    qint64 m_viewWidthMax;
+
+    /* Viewport height (m_viewTop - m_viewBottom), used for zoom */
+    qint64 m_viewHeight;
+    qint64 m_viewHeightMin;
+    qint64 m_viewHeightMax;
+
+    /* Mouse tracking */
+    QPoint m_mousePressPosition;
+    qint64 m_mousePressViewLeft;
+    qint64 m_mousePressViewBottom;
+
+    /* Selection */
+    SelectionState* m_selectionState;
+
+    /* State from the last update() call */
+    struct PreviousUpdate {
+        qint64 m_viewLeft;
+        qint64 m_viewRight;
+        qint64 m_viewBottom;
+        qint64 m_viewTop;
+
+        qint64 m_graphLeft;
+        qint64 m_graphRight;
+        qint64 m_graphBottom;
+        qint64 m_graphTop;
+    } m_previous;
+};
+
+#endif
diff --git a/gui/graphing/graphwidget.cpp b/gui/graphing/graphwidget.cpp
new file mode 100644 (file)
index 0000000..88a86cc
--- /dev/null
@@ -0,0 +1,583 @@
+#include "graphwidget.h"
+
+#include <QScrollBar>
+
+GraphWidget::GraphWidget(QWidget* parent) :
+    QWidget(parent),
+    m_view(NULL),
+    m_label(NULL),
+    m_axisTop(NULL),
+    m_axisLeft(NULL),
+    m_axisRight(NULL),
+    m_axisBottom(NULL),
+    m_horizontalScrollbar(NULL),
+    m_horizontalMin(0),
+    m_horizontalMax(0),
+    m_horizontalStart(0),
+    m_horizontalEnd(0),
+    m_horizontalScrollbarPolicy(Qt::ScrollBarAlwaysOff),
+    m_verticalScrollbar(NULL),
+    m_verticalMin(0),
+    m_verticalMax(0),
+    m_verticalStart(0),
+    m_verticalEnd(0),
+    m_verticalScrollbarPolicy(Qt::ScrollBarAlwaysOff)
+{
+    m_selection.type = SelectionState::None;
+
+    m_verticalScrollbar = new QScrollBar(this);
+    m_verticalScrollbar->setOrientation(Qt::Vertical);
+    m_verticalScrollbar->hide();
+    m_verticalScrollbar->resize(m_verticalScrollbar->sizeHint());
+
+    m_horizontalScrollbar = new QScrollBar(this);
+    m_horizontalScrollbar->setOrientation(Qt::Horizontal);
+    m_horizontalScrollbar->hide();
+    m_horizontalScrollbar->resize(m_horizontalScrollbar->sizeHint());
+
+    updateLayout();
+    setAutoFillBackground(true);
+}
+
+
+GraphView* GraphWidget::view()
+{
+    return m_view;
+}
+
+
+GraphLabelWidget* GraphWidget::label()
+{
+    return m_label;
+}
+
+
+GraphAxisWidget* GraphWidget::axis(AxisPosition pos)
+{
+    switch(pos) {
+        case AxisTop:
+            return m_axisTop;
+
+        case AxisLeft:
+            return m_axisLeft;
+
+        case AxisRight:
+            return m_axisRight;
+
+        case AxisBottom:
+            return m_axisBottom;
+
+        default:
+            return NULL;
+    }
+}
+
+
+void GraphWidget::setView(GraphView* view)
+{
+    delete m_view;
+    m_view = view;
+
+    updateConnections();
+
+    m_view->setSelectionState(&m_selection);
+    m_view->show();
+    m_view->update();
+}
+
+
+void GraphWidget::setLabel(GraphLabelWidget* label)
+{
+    delete m_label;
+    m_label = label;
+}
+
+
+void GraphWidget::setAxis(AxisPosition pos, GraphAxisWidget* axis)
+{
+    switch(pos) {
+        case AxisTop:
+            delete m_axisTop;
+            m_axisTop = axis;
+            m_axisTop->setOrientation(GraphAxisWidget::Horizontal);
+            m_axisTop->setSelectionState(&m_selection);
+            break;
+
+        case AxisLeft:
+            delete m_axisLeft;
+            m_axisLeft = axis;
+            m_axisLeft->setOrientation(GraphAxisWidget::Vertical);
+            m_axisLeft->setSelectionState(&m_selection);
+            break;
+
+        case AxisRight:
+            delete m_axisRight;
+            m_axisRight = axis;
+            m_axisRight->setOrientation(GraphAxisWidget::Vertical);
+            m_axisRight->setSelectionState(&m_selection);
+            break;
+
+        case AxisBottom:
+            delete m_axisBottom;
+            m_axisBottom = axis;
+            m_axisBottom->setOrientation(GraphAxisWidget::Horizontal);
+            m_axisBottom->setSelectionState(&m_selection);
+            break;
+    }
+
+    updateConnections();
+    updateSelection();
+    axis->show();
+}
+
+
+void GraphWidget::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy)
+{
+    m_horizontalScrollbarPolicy = policy;
+    updateScrollbars();
+}
+
+
+void GraphWidget::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy)
+{
+    m_verticalScrollbarPolicy = policy;
+    updateScrollbars();
+}
+
+
+void GraphWidget::resizeEvent(QResizeEvent *e)
+{
+    updateLayout();
+    update();
+}
+
+
+/* Used if a selection would be shared between graphs with different axis */
+SelectionState GraphWidget::transformSelectionIn(SelectionState state)
+{
+    return state;
+}
+
+
+/* Used if a selection would be shared between graphs with different axis */
+SelectionState GraphWidget::transformSelectionOut(SelectionState state)
+{
+    return state;
+}
+
+
+/* Update the scrollbars based on current view */
+void GraphWidget::updateScrollbars()
+{
+    /* Vertical scroll bar */
+    qint64 size = (m_verticalMax - m_verticalMin) - (m_verticalEnd - m_verticalStart);
+
+    if (size <= INT_MAX) {
+        m_verticalScrollbar->setValue(m_verticalStart - m_verticalMin);
+        m_verticalScrollbar->setPageStep(m_verticalEnd - m_verticalStart);
+        m_verticalScrollbar->setRange(0, size);
+    } else {
+        /* QScrollBar only supports up to INT_MAX values,
+         * here we must scale our values to match this */
+        double curSize = m_verticalEnd - m_verticalStart;
+        double pages = (m_verticalMax - m_verticalMin) / curSize;
+        double value = (m_verticalStart - m_verticalMin) / curSize;
+
+        m_verticalScrollbar->setValue(value);
+        m_verticalScrollbar->setPageStep(1);
+        m_verticalScrollbar->setRange(0, pages);
+    }
+
+    /* Adhere to scrollbar policy */
+    bool visible = false;
+
+    if (m_verticalScrollbarPolicy == Qt::ScrollBarAlwaysOn) {
+        visible = true;
+    } else if (m_verticalScrollbarPolicy == Qt::ScrollBarAlwaysOff) {
+        visible = false;
+    } else if (m_verticalScrollbarPolicy == Qt::ScrollBarAsNeeded) {
+        visible = m_verticalMin != m_verticalStart || m_verticalMax != m_verticalEnd;
+    }
+
+    if (visible != m_verticalScrollbar->isVisible()) {
+        m_verticalScrollbar->setVisible(visible);
+        updateLayout();
+    }
+
+    /* Horizontal scroll bar */
+    size = (m_horizontalMax - m_horizontalMin) - (m_horizontalEnd - m_horizontalStart);
+
+    if (size <= INT_MAX) {
+        m_horizontalScrollbar->setValue(m_horizontalStart - m_horizontalMin);
+        m_horizontalScrollbar->setPageStep(m_horizontalEnd - m_horizontalStart);
+        m_horizontalScrollbar->setRange(0, size);
+    } else {
+        /* QScrollBar only supports up to INT_MAX values,
+         * here we must scale our values to match this */
+        double dxdv = INT_MAX / (double)size;
+        double value = (m_horizontalStart - m_horizontalMin) * dxdv;
+        double pageStep = (m_horizontalEnd - m_horizontalStart) * dxdv;
+
+        m_horizontalScrollbar->setValue((int)value);
+        m_horizontalScrollbar->setPageStep((int)pageStep);
+        m_horizontalScrollbar->setRange(0, INT_MAX);
+    }
+
+    /* Adhere to scrollbar policy */
+    visible = false;
+
+    if (m_horizontalScrollbarPolicy == Qt::ScrollBarAlwaysOn) {
+        visible = true;
+    } else if (m_horizontalScrollbarPolicy == Qt::ScrollBarAlwaysOff) {
+        visible = false;
+    } else if (m_horizontalScrollbarPolicy == Qt::ScrollBarAsNeeded) {
+        visible =  m_horizontalMin != m_horizontalStart || m_horizontalMax != m_horizontalEnd;
+    }
+
+    if (visible != m_horizontalScrollbar->isVisible()) {
+        m_horizontalScrollbar->setVisible(visible);
+        updateLayout();
+    }
+}
+
+
+/* Update all signal / slot connections */
+void GraphWidget::updateConnections()
+{
+    if (m_view) {
+        connect(m_view, SIGNAL(selectionChanged()), this, SLOT(updateSelection()), Qt::UniqueConnection);
+
+        connect(m_view, SIGNAL(horizontalViewChanged(qint64,qint64)), this, SLOT(horizontalViewChange(qint64,qint64)), Qt::UniqueConnection);
+        connect(m_view, SIGNAL(horizontalRangeChanged(qint64,qint64)), this, SLOT(horizontalRangeChange(qint64,qint64)), Qt::UniqueConnection);
+
+        connect(m_view, SIGNAL(verticalViewChanged(qint64,qint64)), this, SLOT(verticalViewChange(qint64,qint64)), Qt::UniqueConnection);
+        connect(m_view, SIGNAL(verticalRangeChanged(qint64,qint64)), this, SLOT(verticalRangeChange(qint64,qint64)), Qt::UniqueConnection);
+    }
+
+    if (m_axisTop) {
+        if (m_view) {
+            connect(m_view, SIGNAL(horizontalViewChanged(qint64,qint64)), m_axisTop, SLOT(setView(qint64,qint64)), Qt::UniqueConnection);
+            connect(m_view, SIGNAL(horizontalRangeChanged(qint64,qint64)), m_axisTop, SLOT(setRange(qint64,qint64)), Qt::UniqueConnection);
+        }
+
+        connect(m_axisTop, SIGNAL(selectionChanged()), this, SLOT(updateSelection()), Qt::UniqueConnection);
+    }
+
+    if (m_axisLeft) {
+        if (m_view) {
+            connect(m_view, SIGNAL(verticalViewChanged(qint64,qint64)), m_axisLeft, SLOT(setView(qint64,qint64)), Qt::UniqueConnection);
+            connect(m_view, SIGNAL(verticalRangeChanged(qint64,qint64)), m_axisLeft, SLOT(setRange(qint64,qint64)), Qt::UniqueConnection);
+        }
+
+        connect(m_axisLeft, SIGNAL(selectionChanged()), this, SLOT(updateSelection()), Qt::UniqueConnection);
+    }
+
+    if (m_axisRight) {
+        if (m_view) {
+            connect(m_view, SIGNAL(verticalViewChanged(qint64,qint64)), m_axisRight, SLOT(setView(qint64,qint64)), Qt::UniqueConnection);
+            connect(m_view, SIGNAL(verticalRangeChanged(qint64,qint64)), m_axisRight, SLOT(setRange(qint64,qint64)), Qt::UniqueConnection);
+        }
+
+        connect(m_axisRight, SIGNAL(selectionChanged()), this, SLOT(updateSelection()), Qt::UniqueConnection);
+    }
+
+    if (m_axisBottom) {
+        if (m_view) {
+            connect(m_view, SIGNAL(horizontalViewChanged(qint64,qint64)), m_axisBottom, SLOT(setView(qint64,qint64)), Qt::UniqueConnection);
+            connect(m_view, SIGNAL(horizontalRangeChanged(qint64,qint64)), m_axisBottom, SLOT(setRange(qint64,qint64)), Qt::UniqueConnection);
+        }
+
+        connect(m_axisBottom, SIGNAL(selectionChanged()), this, SLOT(updateSelection()), Qt::UniqueConnection);
+    }
+
+    if (m_horizontalScrollbar) {
+        connect(m_horizontalScrollbar, SIGNAL(actionTriggered(int)), this, SLOT(horizontalScrollAction(int)));
+    }
+
+    if (m_verticalScrollbar) {
+        connect(m_verticalScrollbar, SIGNAL(actionTriggered(int)), this, SLOT(verticalScrollAction(int)));
+    }
+}
+
+
+/* Recalculate the layout */
+void GraphWidget::updateLayout()
+{
+    int x, y;
+    int padX = 0, padY = 0;
+
+    if (m_axisTop) {
+        padY += m_axisTop->height();
+    }
+
+    if (m_axisBottom) {
+        padY += m_axisBottom->height();
+    }
+
+    if (m_axisLeft) {
+        padX += m_axisLeft->width();
+    }
+
+    if (m_axisRight) {
+        padX += m_axisRight->width();
+    }
+
+    if (m_horizontalScrollbar->isVisible()) {
+        padY += m_horizontalScrollbar->height();
+    }
+
+    if (m_verticalScrollbar->isVisible()) {
+        padX += m_verticalScrollbar->width();
+    }
+
+    if (m_axisTop) {
+        x = m_axisLeft ? m_axisLeft->width() : 0;
+        y = 0;
+
+        m_axisTop->move(x, y);
+        m_axisTop->resize(width() - padX, m_axisTop->height());
+    }
+
+    if (m_axisBottom) {
+        x = m_axisLeft ? m_axisLeft->width() : 0;
+        y = height() - m_axisBottom->height();
+
+        if (m_horizontalScrollbar->isVisible())  {
+            y -= m_horizontalScrollbar->height();
+        }
+
+        m_axisBottom->move(x, y);
+        m_axisBottom->resize(width() - padX, m_axisBottom->height());
+    }
+
+    if (m_axisLeft) {
+        x = 0;
+        y = m_axisTop ? m_axisTop->height() : 0;
+
+        m_axisLeft->move(x, y);
+        m_axisLeft->resize(m_axisLeft->width(), height() - padY);
+    }
+
+    if (m_axisRight) {
+        x = width() - m_axisRight->width();
+        y = m_axisTop ? m_axisTop->height() : 0;
+
+        if (m_verticalScrollbar->isVisible())  {
+            x -= m_verticalScrollbar->width();
+        }
+
+        m_axisRight->move(x, y);
+        m_axisRight->resize(m_axisRight->width(), height() - padY);
+    }
+
+    if (m_view) {
+        x = m_axisLeft ? m_axisLeft->width() : 0;
+        y = m_axisTop ? m_axisTop->height() : 0;
+
+        m_view->move(x, y);
+        m_view->resize(width() - padX, height() - padY);
+    }
+
+    if (m_label) {
+        if (m_axisTop && m_axisLeft) {
+            m_label->move(0, 0);
+            m_label->resize(m_axisLeft->width(), m_axisTop->height());
+        }
+    }
+
+    if (m_verticalScrollbar) {
+        m_verticalScrollbar->move(width() - m_verticalScrollbar->width(), 0);
+
+        if (m_horizontalScrollbar) {
+            m_verticalScrollbar->resize(m_verticalScrollbar->width(), height() - m_horizontalScrollbar->height());
+        } else {
+            m_verticalScrollbar->resize(m_verticalScrollbar->width(), height());
+        }
+    }
+
+    if (m_horizontalScrollbar) {
+        m_horizontalScrollbar->move(0, height() - m_horizontalScrollbar->height());
+
+        if (m_verticalScrollbar) {
+            m_horizontalScrollbar->resize(width() - m_verticalScrollbar->width(), m_horizontalScrollbar->height());
+        } else {
+            m_horizontalScrollbar->resize(width(), m_horizontalScrollbar->height());
+        }
+    }
+}
+
+
+void GraphWidget::setSelection(SelectionState state)
+{
+    m_selection = transformSelectionIn(state);
+    updateSelection(false);
+}
+
+
+void GraphWidget::setHorizontalView(qint64 start, qint64 end)
+{
+    if (m_view) {
+        m_view->setHorizontalView(start, end);
+    }
+}
+
+
+void GraphWidget::setVerticalView(qint64 start, qint64 end)
+{
+    if (m_view) {
+        m_view->setVerticalView(start, end);
+    }
+}
+
+
+/* Called when the view is translated / zoomed */
+void GraphWidget::verticalViewChange(qint64 start, qint64 end)
+{
+    m_verticalStart = start;
+    m_verticalEnd = end;
+    updateScrollbars();
+
+    emit verticalViewChanged(start, end);
+}
+
+
+void GraphWidget::verticalRangeChange(qint64 start, qint64 end)
+{
+    m_verticalMin = start;
+    m_verticalMax = end;
+    updateScrollbars();
+
+    emit verticalRangeChanged(start, end);
+}
+
+
+void GraphWidget::horizontalViewChange(qint64 start, qint64 end)
+{
+    m_horizontalStart = start;
+    m_horizontalEnd = end;
+    updateScrollbars();
+
+    emit horizontalViewChanged(start, end);
+}
+
+
+void GraphWidget::horizontalRangeChange(qint64 start, qint64 end)
+{
+    m_horizontalMin = start;
+    m_horizontalMax = end;
+    updateScrollbars();
+
+    emit horizontalRangeChanged(start, end);
+}
+
+
+/* User interaction with horizontal scroll bar */
+void GraphWidget::horizontalScrollAction(int /*action*/)
+{
+    int value = m_horizontalScrollbar->sliderPosition();
+    qint64 size = (m_horizontalMax - m_horizontalMin) - (m_horizontalEnd - m_horizontalStart);
+
+    /* Calculate the new scroll values */
+    if (size <= INT_MAX) {
+        m_horizontalEnd -= m_horizontalStart;
+        m_horizontalStart = value + m_horizontalMin;
+        m_horizontalEnd += value;
+    } else {
+        /* QScrollBar only supports up to INT_MAX values, here we must scale
+         * our values to match this */
+        double dxdv = INT_MAX / (double)size;
+
+        size = m_horizontalEnd - m_horizontalStart;
+        m_horizontalStart = value / dxdv + m_horizontalMin;
+        m_horizontalEnd = m_horizontalStart + size;
+    }
+
+    /* Update view */
+    if (m_view) {
+        m_view->setHorizontalView(m_horizontalStart, m_horizontalEnd);
+    }
+
+    /* Update horizontal axes */
+    if (m_axisTop) {
+        m_axisTop->setView(m_horizontalStart, m_horizontalEnd);
+    }
+
+    if (m_axisBottom) {
+        m_axisBottom->setView(m_horizontalStart, m_horizontalEnd);
+    }
+
+    /* Inform the world of our changes! */
+    emit horizontalViewChanged(m_horizontalStart, m_horizontalEnd);
+}
+
+
+/* User interaction with vertical scroll bar */
+void GraphWidget::verticalScrollAction(int /*action*/)
+{
+    int value = m_verticalScrollbar->sliderPosition();
+    qint64 size = (m_verticalMax - m_verticalMin) - (m_verticalEnd - m_verticalStart);
+
+    /* Calculate the new scroll values */
+    if (size <= INT_MAX) {
+        m_verticalEnd -= m_verticalStart;
+        m_verticalStart = value + m_verticalMin;
+        m_verticalEnd += value;
+    } else {
+        /* QScrollBar only supports up to INT_MAX values, here we must scale
+         * our values to match this */
+        double dxdv = INT_MAX / (double)size;
+
+        size = m_verticalEnd - m_verticalStart;
+        m_verticalStart = value / dxdv + m_verticalMin;
+        m_verticalEnd = m_verticalStart + size;
+    }
+
+    /* Update view */
+    if (m_view) {
+        m_view->setVerticalView(m_verticalStart, m_verticalEnd);
+    }
+
+    /* Update vertical axes */
+    if (m_axisLeft) {
+        m_axisLeft->setView(m_verticalStart, m_verticalEnd);
+    }
+
+    if (m_axisRight) {
+        m_axisRight->setView(m_verticalStart, m_verticalEnd);
+    }
+
+    /* Inform the world of our changes! */
+    emit verticalViewChanged(m_verticalStart, m_verticalEnd);
+}
+
+
+/* Update child elements when selection changes */
+void GraphWidget::updateSelection(bool emitSignal)
+{
+    if (m_view) {
+        m_view->update();
+    }
+
+    if (m_axisTop) {
+        m_axisTop->update();
+    }
+
+    if (m_axisLeft) {
+        m_axisLeft->update();
+    }
+
+    if (m_axisRight) {
+        m_axisRight->update();
+    }
+
+    if (m_axisBottom) {
+        m_axisBottom->update();
+    }
+
+    if (emitSignal) {
+        emit selectionChanged(transformSelectionOut(m_selection));
+    }
+}
+
+
+#include "graphwidget.moc"
diff --git a/gui/graphing/graphwidget.h b/gui/graphing/graphwidget.h
new file mode 100644 (file)
index 0000000..16b7786
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef GRAPHWIDGET_H
+#define GRAPHWIDGET_H
+
+#include "graphview.h"
+#include "graphaxiswidget.h"
+#include "graphlabelwidget.h"
+
+class QScrollBar;
+
+/**
+ * The generic GraphWidget class which combines the elements of a graph,
+ * the axis, view, scrollbars and label.
+ */
+class GraphWidget : public QWidget {
+    Q_OBJECT
+public:
+    enum AxisPosition {
+        AxisTop,
+        AxisLeft,
+        AxisRight,
+        AxisBottom
+    };
+
+public:
+    GraphWidget(QWidget* parent = 0);
+    virtual ~GraphWidget(){}
+
+    GraphView* view();
+    GraphLabelWidget* label();
+    GraphAxisWidget* axis(AxisPosition pos);
+
+    void setView(GraphView* view);
+    void setLabel(GraphLabelWidget* label);
+    void setAxis(AxisPosition pos, GraphAxisWidget* axis);
+
+    void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy);
+    void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy);
+
+    virtual void resizeEvent(QResizeEvent *e);
+
+protected:
+    /* Used if a selection would be shared between graphs with different axis */
+    virtual SelectionState transformSelectionIn(SelectionState state);
+    virtual SelectionState transformSelectionOut(SelectionState state);
+
+    /* Update the scrollbars based on current view */
+    void updateScrollbars();
+
+    /* Update all signal / slot connections */
+    void updateConnections();
+
+    /* Recalculate child widget layout */
+    void updateLayout();
+
+public slots:
+    void setSelection(SelectionState state);
+
+    /* Set view areas */
+    void setHorizontalView(qint64 start, qint64 end);
+    void setVerticalView(qint64 start, qint64 end);
+
+protected slots:
+    /* View changed by translation / zooming */
+    void verticalViewChange(qint64 start, qint64 end);
+    void verticalRangeChange(qint64 start, qint64 end);
+    void horizontalViewChange(qint64 start, qint64 end);
+    void horizontalRangeChange(qint64 start, qint64 end);
+
+    /* User interaction with scroll bars */
+    void horizontalScrollAction(int action);
+    void verticalScrollAction(int action);
+
+    /* Update child elements when selection changes */
+    void updateSelection(bool emitSignal = true);
+
+signals:
+    void selectionChanged(SelectionState state);
+
+    void verticalViewChanged(qint64 start, qint64 end);
+    void verticalRangeChanged(qint64 start, qint64 end);
+
+    void horizontalViewChanged(qint64 start, qint64 end);
+    void horizontalRangeChanged(qint64 start, qint64 end);
+
+protected:
+    SelectionState m_selection;
+
+    GraphView* m_view;
+
+    GraphLabelWidget* m_label;
+
+    GraphAxisWidget* m_axisTop;
+    GraphAxisWidget* m_axisLeft;
+    GraphAxisWidget* m_axisRight;
+    GraphAxisWidget* m_axisBottom;
+
+    QScrollBar* m_horizontalScrollbar;
+    qint64 m_horizontalMin;
+    qint64 m_horizontalMax;
+    qint64 m_horizontalStart;
+    qint64 m_horizontalEnd;
+    Qt::ScrollBarPolicy m_horizontalScrollbarPolicy;
+
+    QScrollBar* m_verticalScrollbar;
+    qint64 m_verticalMin;
+    qint64 m_verticalMax;
+    qint64 m_verticalStart;
+    qint64 m_verticalEnd;
+    Qt::ScrollBarPolicy m_verticalScrollbarPolicy;
+};
+
+#endif
diff --git a/gui/graphing/heatmapverticalaxiswidget.cpp b/gui/graphing/heatmapverticalaxiswidget.cpp
new file mode 100644 (file)
index 0000000..ae127c0
--- /dev/null
@@ -0,0 +1,82 @@
+#include "heatmapverticalaxiswidget.h"
+
+#include <qmath.h>
+#include <QPainter>
+#include <QMouseEvent>
+
+HeatmapVerticalAxisWidget::HeatmapVerticalAxisWidget(QWidget* parent) :
+    GraphAxisWidget(parent),
+    m_data(NULL)
+{
+    m_rowHeight = 20;
+}
+
+void HeatmapVerticalAxisWidget::setDataProvider(HeatmapDataProvider* data)
+{
+    delete m_data;
+    m_data = data;
+
+    m_valueMin = 0;
+    m_valueMax = (data->dataRows() + data->headerRows()) * m_rowHeight;
+
+    m_valueBegin = m_valueMin;
+    m_valueEnd = m_valueMax;
+
+    update();
+}
+
+void HeatmapVerticalAxisWidget::mouseDoubleClickEvent(QMouseEvent *e)
+{
+    if (e->pos().y() < m_data->headerRows() * m_rowHeight) {
+        m_selectionState->type = SelectionState::None;
+        emit selectionChanged();
+    } else {
+        int row = e->pos().y();
+        row -= m_data->headerRows() * m_rowHeight;
+        row += m_valueBegin;
+        row /= m_rowHeight;
+
+        if (row >= m_data->dataRows()) {
+            m_selectionState->type = SelectionState::None;
+            emit selectionChanged();
+        } else {
+            m_selectionState->type = SelectionState::Vertical;
+            m_selectionState->start = m_data->dataRowAt(row);
+            m_selectionState->end = m_selectionState->start;
+            emit selectionChanged();
+        }
+    }
+}
+
+void HeatmapVerticalAxisWidget::paintEvent(QPaintEvent *)
+{
+    if (!m_data) {
+        return;
+    }
+
+    QPainter painter(this);
+    painter.setPen(Qt::black);
+    painter.setBrush(Qt::lightGray);
+    painter.drawRect(0, 0, width() - 1, height() - 1);
+
+    /* Draw scrollable rows */
+    painter.translate(0, m_data->headerRows() * m_rowHeight - m_valueBegin % m_rowHeight);
+    int rowStart = m_valueBegin / m_rowHeight;
+    int rowEnd = qMin<int>(qCeil(m_valueEnd / (double)m_rowHeight), m_data->dataRows());
+
+    for (unsigned i = rowStart; i < rowEnd; ++i) {
+        painter.drawText(0, 0, width(), m_rowHeight, Qt::AlignHCenter | Qt::AlignVCenter, m_data->dataLabel(i));
+        painter.drawLine(0, m_rowHeight, width(), m_rowHeight);
+        painter.translate(0, m_rowHeight);
+    }
+
+    /* Draw fixed position headers */
+    painter.resetTransform();
+    painter.drawRect(0, 0, width() - 1, m_data->headerRows() * m_rowHeight);
+
+    for (unsigned i = 0; i < m_data->headerRows(); ++i) {
+        painter.drawText(0, 0, width(), m_rowHeight, Qt::AlignHCenter | Qt::AlignVCenter, m_data->headerLabel(i));
+        painter.drawLine(0, m_rowHeight, width(), m_rowHeight);
+        painter.translate(0, m_rowHeight);
+    }
+}
diff --git a/gui/graphing/heatmapverticalaxiswidget.h b/gui/graphing/heatmapverticalaxiswidget.h
new file mode 100644 (file)
index 0000000..ca64adb
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef HEATMAPVERTICALAXISWIDGET_H
+#define HEATMAPVERTICALAXISWIDGET_H
+
+#include "heatmapview.h"
+#include "graphaxiswidget.h"
+
+/**
+ * Vertical axis specifically for heatmap displaying header and data rows
+ */
+class HeatmapVerticalAxisWidget : public GraphAxisWidget {
+public:
+    HeatmapVerticalAxisWidget(QWidget* parent);
+
+    void setDataProvider(HeatmapDataProvider* data);
+
+    virtual void mouseDoubleClickEvent(QMouseEvent *e);
+    virtual void paintEvent(QPaintEvent *);
+
+protected:
+    int m_rowHeight;
+    HeatmapDataProvider* m_data;
+};
+
+#endif
diff --git a/gui/graphing/heatmapview.cpp b/gui/graphing/heatmapview.cpp
new file mode 100644 (file)
index 0000000..9bb485c
--- /dev/null
@@ -0,0 +1,276 @@
+#include "heatmapview.h"
+
+#include <qmath.h>
+#include <QToolTip>
+#include <QPainter>
+#include <QMouseEvent>
+
+HeatmapView::HeatmapView(QWidget* parent) :
+    GraphView(parent),
+    m_data(NULL)
+{
+    m_rowHeight = 20;
+    setMouseTracking(true);
+}
+
+
+void HeatmapView::setDataProvider(HeatmapDataProvider* data)
+{
+    delete m_data;
+    m_data = data;
+
+    if (m_data) {
+        m_data->setSelectionState(m_selectionState);
+
+        setDefaultView(m_data->start(), m_data->end());
+
+        m_viewWidthMin = 1000;
+
+        m_graphBottom = 0;
+        m_graphTop = (m_data->headerRows() + m_data->dataRows()) * m_rowHeight;
+    } else {
+        setDefaultView(0, 0);
+        m_graphBottom = m_graphTop = 0;
+    }
+
+    update();
+}
+
+
+void HeatmapView::setSelectionState(SelectionState* state)
+{
+    if (m_data) {
+        m_data->setSelectionState(state);
+    }
+
+    GraphView::setSelectionState(state);
+}
+
+
+void HeatmapView::mouseMoveEvent(QMouseEvent *e)
+{
+    GraphView::mouseMoveEvent(e);
+
+    if (e->buttons() || !m_data) {
+        QToolTip::hideText();
+        return;
+    }
+
+    qint64 index = itemAtPosition(e->pos());
+
+    if (index >= 0) {
+        QToolTip::showText(e->globalPos(), m_data->itemTooltip(index));
+    } else {
+        QToolTip::hideText();
+    }
+}
+
+
+void HeatmapView::mouseDoubleClickEvent(QMouseEvent *e)
+{
+    if (m_data && e->button() == Qt::LeftButton) {
+        qint64 index = itemAtPosition(e->pos());
+
+        if (index >= 0) {
+            m_data->itemDoubleClicked(index);
+            return;
+        }
+    }
+
+    GraphView::mouseDoubleClickEvent(e);
+}
+
+
+void HeatmapView::paintEvent(QPaintEvent *)
+{
+    if (!m_data) {
+        return;
+    }
+
+    QPainter painter(this);
+    painter.fillRect(0, m_data->headerRows() * m_rowHeight, width(), height(), Qt::white);
+
+    /* Draw data rows */
+    painter.translate(0, m_data->headerRows() * m_rowHeight - m_viewBottom % m_rowHeight);
+    int rowStart = m_viewBottom / m_rowHeight;
+    int rowEnd = qMin<int>(qCeil(m_viewTop / (double)m_rowHeight), m_data->dataRows());
+
+    for (unsigned i = rowStart; i < rowEnd; ++i) {
+        HeatmapRowIterator* itr = m_data->dataRowIterator(i, m_viewLeft, m_viewRight, width());
+        paintRow(painter, itr);
+        painter.translate(0, m_rowHeight);
+        delete itr;
+    }
+
+    /* Draw Header */
+    painter.resetTransform();
+    painter.fillRect(0, 0, width(), m_data->headerRows() * m_rowHeight, Qt::white);
+
+    for (unsigned i = 0; i < m_data->headerRows(); ++i) {
+        HeatmapRowIterator* itr = m_data->headerRowIterator(i, m_viewLeft, m_viewRight, width());
+        paintRow(painter, itr);
+        painter.translate(0, m_rowHeight);
+        delete itr;
+    }
+
+    /* Draw Axis Lines */
+    painter.resetTransform();
+    painter.setPen(Qt::black);
+    painter.drawLine(0, m_rowHeight, width(), m_rowHeight);
+    painter.drawLine(0, m_rowHeight * 2, width(), m_rowHeight * 2);
+
+    painter.setPen(QColor(240, 240, 240));
+    painter.translate(0, m_data->headerRows() * m_rowHeight - m_viewBottom % m_rowHeight);
+
+    for (unsigned i = rowStart; i < rowEnd; ++i) {
+        painter.drawLine(0, m_rowHeight, width(), m_rowHeight);
+        painter.translate(0, m_rowHeight);
+    }
+
+    /* Draw selection borders */
+    painter.resetTransform();
+    painter.setPen(Qt::green);
+
+    if (m_selectionState->type == SelectionState::Horizontal) {
+        double dxdt = width() / (double)m_viewWidth;
+        double scroll = m_viewLeft * dxdt;
+        double left = (m_selectionState->start * dxdt) - scroll;
+        double right = (m_selectionState->end * dxdt) - scroll;
+
+        /* Highlight time */
+        if (left >= 0 && left <= width()) {
+            painter.drawLine(left, 0, left, height());
+        }
+
+        if (right >= 0 && right <= width()) {
+            painter.drawLine(right, 0, right, height());
+        }
+    } else if (m_selectionState->type == SelectionState::Vertical) {
+        /* Highlight row */
+        int row = m_selectionState->start;
+
+        for (unsigned i = rowStart; i < rowEnd; ++i) {
+            if (m_data->dataRowAt(i) == row) {
+                row = i - rowStart;
+
+                painter.translate(0, m_data->headerRows() * m_rowHeight - m_viewBottom % m_rowHeight);
+                painter.drawLine(0, (row + 1) * m_rowHeight, width(), (row + 1) * m_rowHeight);
+
+                if (row > 0) {
+                    painter.drawLine(0, row * m_rowHeight, width(), row * m_rowHeight);
+                }
+
+                break;
+            }
+        }
+    }
+}
+
+
+void HeatmapView::paintRow(QPainter& painter, HeatmapRowIterator* itr)
+{
+    bool selection = m_selectionState ? m_selectionState->type != SelectionState::None : false;
+
+    while (itr->next())
+    {
+        double heat = itr->heat();
+        int width = itr->width();
+        int x = itr->step();
+
+        /* Gamma correction */
+        heat = qPow(heat, 1.0 / 2.0);
+
+        if (width == 1) {
+            /* Draw single line */
+            if (selection) {
+                double selectedHeat = itr->selectedHeat();
+
+                if (selectedHeat >= 0.999) {
+                    heat = 255.0 - qBound(0.0, heat * 255.0, 255.0);
+
+                    if (itr->isGpu()) {
+                        painter.setPen(QColor(255, heat, heat));
+                    } else {
+                        painter.setPen(QColor(heat, heat, 255));
+                    }
+
+                    painter.drawLine(x, 0, x, m_rowHeight - 1);
+                } else {
+                    heat = 255.0 - qBound(0.0, heat * 100.0, 100.0);
+                    painter.setPen(QColor(heat, heat, heat));
+                    painter.drawLine(x, 0, x, m_rowHeight - 1);
+
+                    if (selectedHeat > 0.001) {
+                        selectedHeat = qPow(selectedHeat, 1.0 / 2.0);
+                        selectedHeat = qBound(0.0, selectedHeat * 255.0, 255.0);
+
+                        if (itr->isGpu()) {
+                            painter.setPen(QColor(255, 0, 0, selectedHeat));
+                        } else {
+                            painter.setPen(QColor(0, 0, 255, selectedHeat));
+                        }
+
+                        painter.drawLine(x, 0, x, m_rowHeight - 1);
+                    }
+                }
+            } else {
+                heat = qBound(0.0, heat * 255.0, 255.0);
+
+                if (itr->isGpu()) {
+                    painter.setPen(QColor(255, 255 - heat, 255 - heat));
+                } else {
+                    painter.setPen(QColor(255 - heat, 255 - heat, 255));
+                }
+
+                painter.drawLine(x, 0, x, m_rowHeight - 1);
+            }
+        } else {
+            double selectedHeat = itr->selectedHeat();
+
+            if (selection && selectedHeat < 0.9) {
+                painter.fillRect(x, 0, width, m_rowHeight, QColor(255 - 100, 255 - 100, 255 - 100));
+            } else if (itr->isGpu()) {
+                painter.fillRect(x, 0, width, m_rowHeight, QColor(255, 0, 0));
+            } else {
+                painter.fillRect(x, 0, width, m_rowHeight, QColor(0, 0, 255));
+            }
+
+            if (width > 6) {
+                painter.setPen(Qt::white);
+                QString elided = painter.fontMetrics().elidedText(itr->label(), Qt::ElideRight, width - 1);
+
+                painter.drawText(x + 1, 0, width - 1, m_rowHeight - 1,
+                                 Qt::AlignLeft | Qt::AlignVCenter,
+                                 elided);
+            }
+        }
+    }
+}
+
+
+qint64 HeatmapView::itemAtPosition(QPoint pos)
+{
+    if (!m_data) {
+        return -1;
+    }
+
+    double t = m_viewWidth / (double)width();
+    t *= pos.x();
+    t += m_viewLeft;
+
+    qint64 time = (qint64)t;
+    qint64 index;
+
+    if (pos.y() < m_data->headerRows() * m_rowHeight) {
+        int row = pos.y() / m_rowHeight;
+        index = m_data->headerItemAt(row, time);
+    } else {
+        int row = pos.y();
+        row -= m_data->headerRows() * m_rowHeight;
+        row += m_viewBottom;
+        row /= m_rowHeight;
+        index = m_data->dataItemAt(row, time);
+    }
+
+    return index;
+}
diff --git a/gui/graphing/heatmapview.h b/gui/graphing/heatmapview.h
new file mode 100644 (file)
index 0000000..781c9a7
--- /dev/null
@@ -0,0 +1,124 @@
+#ifndef HEATMAPVIEW_H
+#define HEATMAPVIEW_H
+
+#include "graphview.h"
+
+/**
+ * The heatmap iterator will only return data when there is something to draw,
+ * this allows much faster access to the data in the case where the view is
+ * zoomed out to the point of where there is multiple calls in one pixel,
+ * it automagically calculates the heat for that pixel.
+ */
+class HeatmapRowIterator {
+public:
+    virtual ~HeatmapRowIterator(){}
+
+    /* Go to the next visible heat map */
+    virtual bool next() = 0;
+
+    /* Is the current value GPU or CPU heat */
+    virtual bool isGpu() const = 0;
+
+    /* Current step (normally x coordinate) */
+    virtual int step() const = 0;
+
+    /* Current width (in steps) */
+    virtual int width() const = 0;
+
+    /* Current heat */
+    virtual float heat() const = 0;
+
+    /* Heat value for selected calls */
+    virtual float selectedHeat() const = 0;
+
+    /* Label only used when there is a single call in this heat */
+    virtual QString label() const = 0;
+};
+
+
+/**
+ * Data provider for the whole heatmap
+ */
+class HeatmapDataProvider {
+public:
+    virtual ~HeatmapDataProvider(){}
+
+    /* The start and end values (time on x-axis) for the heatmap */
+    virtual qint64 start() const = 0;
+    virtual qint64 end() const = 0;
+
+    /*
+     * Header rows (fixed at top of heatmap view)
+     */
+
+    /* Header row count */
+    virtual unsigned headerRows() const = 0;
+
+    /* Label to be used in the vertical axis */
+    virtual QString headerLabel(unsigned row) const = 0;
+
+    /* Get identifier (program no) for row */
+    virtual qint64 headerRowAt(unsigned row) const = 0;
+
+    /* Get item at row and time */
+    virtual qint64 headerItemAt(unsigned row, qint64 time) const = 0;
+
+    /* Get iterator for a row between start and end time for steps */
+    virtual HeatmapRowIterator* headerRowIterator(int row, qint64 start, qint64 end, int steps) const = 0;
+
+    /*
+     * Data rows (scrollable in heatmap view)
+     */
+
+    /* Data row count */
+    virtual unsigned dataRows() const = 0;
+
+    /* Label to be used in the vertical axis */
+    virtual QString dataLabel(unsigned row) const = 0;
+
+    /* Get identifier (program no) for row */
+    virtual qint64 dataRowAt(unsigned row) const = 0;
+
+    /* Get item at row and time */
+    virtual qint64 dataItemAt(unsigned row, qint64 time) const = 0;
+
+    /* Get iterator for a row between start and end time for steps */
+    virtual HeatmapRowIterator* dataRowIterator(int row, qint64 start, qint64 end, int steps) const = 0;
+
+    /* Handle double click on item */
+    virtual void itemDoubleClicked(qint64 index) const = 0;
+
+    /* Get mouse over tooltip for item */
+    virtual QString itemTooltip(qint64 index) const = 0;
+
+    /* Set the selection */
+    virtual void setSelectionState(SelectionState* state) = 0;
+};
+
+
+/**
+ * A not very generic heatmap for row based data
+ */
+class HeatmapView : public GraphView {
+public:
+    HeatmapView(QWidget* parent);
+
+    void setDataProvider(HeatmapDataProvider* data);
+    void setSelectionState(SelectionState* state);
+
+    virtual void mouseMoveEvent(QMouseEvent *e);
+    virtual void mouseDoubleClickEvent(QMouseEvent *e);
+
+    virtual void paintEvent(QPaintEvent *e);
+    virtual void paintRow(QPainter& painter, HeatmapRowIterator* itr);
+
+
+protected:
+    qint64 itemAtPosition(QPoint pos);
+
+protected:
+    int m_rowHeight;
+    HeatmapDataProvider* m_data;
+};
+
+#endif
diff --git a/gui/graphing/histogramview.cpp b/gui/graphing/histogramview.cpp
new file mode 100644 (file)
index 0000000..0b94577
--- /dev/null
@@ -0,0 +1,258 @@
+#include "histogramview.h"
+
+#include <QPen>
+#include <QBrush>
+#include <qmath.h>
+#include <QPainter>
+#include <QToolTip>
+#include <QMouseEvent>
+
+HistogramView::HistogramView(QWidget* parent) :
+    GraphView(parent),
+    m_data(NULL)
+{
+    setMouseTracking(true);
+
+    m_gradientUnselected.setColorAt(0.9, QColor(200, 200, 200));
+    m_gradientUnselected.setColorAt(0.0, QColor(220, 220, 220));
+
+    m_gradientSelected.setColorAt(0.9, QColor(0, 0, 210));
+    m_gradientSelected.setColorAt(0.0, QColor(130, 130, 255));
+}
+
+
+void HistogramView::setDataProvider(GraphDataProvider* data)
+{
+    delete m_data;
+    m_data = data;
+
+    if (m_data) {
+        m_data->setSelectionState(m_selectionState);
+        setDefaultView(0, m_data->size());
+        m_viewWidthMin = 10;
+    } else {
+        setDefaultView(0, 0);
+    }
+}
+
+
+void HistogramView::setSelectionState(SelectionState* state)
+{
+    if (m_data) {
+        m_data->setSelectionState(state);
+    }
+
+    GraphView::setSelectionState(state);
+}
+
+
+void HistogramView::setSelectedGradient(const QLinearGradient& gradient)
+{
+    m_gradientSelected = gradient;
+}
+
+
+void HistogramView::setUnelectedGradient(const QLinearGradient& gradient)
+{
+    m_gradientUnselected = gradient;
+}
+
+
+void HistogramView::mouseMoveEvent(QMouseEvent *e)
+{
+    GraphView::mouseMoveEvent(e);
+
+    if (e->buttons() || !m_data) {
+        QToolTip::hideText();
+        return;
+    }
+
+    qint64 index = itemAtPosition(e->pos());
+    qint64 time = valueAtPosition(e->pos());
+
+    if (m_data->value(index) >= time) {
+        QToolTip::showText(e->globalPos(), m_data->itemTooltip(index));
+    } else {
+        QToolTip::hideText();
+    }
+}
+
+
+void HistogramView::mouseDoubleClickEvent(QMouseEvent *e)
+{
+    if (e->button() == Qt::LeftButton) {
+        qint64 index = itemAtPosition(e->pos());
+        qint64 time = valueAtPosition(e->pos());
+
+        if (m_data->value(index) >= time) {
+            m_data->itemDoubleClicked(index);
+            return;
+        }
+    }
+
+    GraphView::mouseDoubleClickEvent(e);
+}
+
+
+void HistogramView::update()
+{
+    m_graphBottom = 0;
+    m_graphTop = 0;
+
+    if (m_data) {
+        for (qint64 i = m_viewLeft; i < m_viewRight; ++i) {
+            qint64 value = m_data->value(i);
+
+            if (value > m_graphTop) {
+                m_graphTop = value;
+            }
+        }
+    }
+
+    GraphView::update();
+}
+
+
+void HistogramView::resizeEvent(QResizeEvent *)
+{
+    m_gradientSelected.setStart(0, height());
+    m_gradientUnselected.setStart(0, height());
+}
+
+
+/* Draw the histogram
+ *
+ * When the view is zoomed such that there is more than one item occupying a single pixel
+ * the one with the highest value will be displayed.
+ */
+void HistogramView::paintEvent(QPaintEvent *)
+{
+    if (!m_data) {
+        return;
+    }
+
+    QBrush selectedBrush = QBrush(m_gradientSelected);
+    QPen selectedPen = QPen(selectedBrush, 1);
+
+    QBrush unselectedBrush = QBrush(m_gradientUnselected);
+    QPen unselectedPen = QPen(unselectedBrush, 1);
+
+    QPainter painter(this);
+    painter.fillRect(0, 0, width(), height(), Qt::white);
+
+    double dydv = height() / (double)m_graphTop;
+    double dxdv = width() / (double)(m_viewRight - m_viewLeft);
+    bool selection = m_selectionState && m_selectionState->type != SelectionState::None;
+
+    if (dxdv < 1.0) {
+        /* Less than one pixel per item */
+        qint64 longestValue = m_graphBottom;
+        qint64 longestSelected = m_graphBottom;
+        int lastX = 0;
+        double x = 0;
+
+        if (selection) {
+            painter.setPen(unselectedPen);
+        } else {
+            painter.setPen(selectedPen);
+        }
+
+        for (qint64 i = m_viewLeft; i < m_viewRight; ++i) {
+            qint64 value = m_data->value(i);
+            int ix;
+
+            if (value > longestValue) {
+                longestValue = value;
+            }
+
+            if (selection && m_data->selected(i) && value > longestSelected) {
+                longestSelected = value;
+            }
+
+            x += dxdv;
+            ix = (int)x;
+
+            if (lastX != ix) {
+                painter.drawLine(lastX, height(), lastX, height() - (longestValue * dydv));
+
+                if (selection && longestSelected > m_graphBottom) {
+                    painter.setPen(selectedPen);
+                    painter.drawLine(lastX, height(), lastX, height() - (longestSelected * dydv));
+                    painter.setPen(unselectedPen);
+                    longestSelected = m_graphBottom;
+                }
+
+                longestValue = m_graphBottom;
+                lastX = ix;
+            }
+        }
+    } else {
+        /* Draw rectangles for graph */
+        double x = 0;
+
+        for (qint64 i = m_viewLeft; i < m_viewRight; ++i, x += dxdv) {
+            qint64 value = m_data->value(i);
+            int y = qMax<int>(1, value * dydv);
+
+            if (!selection || m_data->selected(i)) {
+                painter.fillRect(x, height() - y, dxdv, y, selectedBrush);
+            } else {
+                painter.fillRect(x, height() - y, dxdv, y, unselectedBrush);
+            }
+        }
+    }
+
+    /* Draw the borders for the selection */
+    if (m_selectionState && m_selectionState->type == SelectionState::Horizontal) {
+        double dxdt = width() / (double)m_viewWidth;
+        double scroll = m_viewLeft * dxdt;
+        double left = (m_selectionState->start * dxdt) - scroll;
+        double right = (m_selectionState->end * dxdt) - scroll;
+
+        painter.setPen(Qt::green);
+
+        if (left >= 0 && left <= width()) {
+            painter.drawLine(left, 0, left, height());
+        }
+
+        if (right >= 0 && right <= width()) {
+            painter.drawLine(right, 0, right, height());
+        }
+    }
+}
+
+
+/* Find the item with the highest value at pos.x() +/- 1,
+ * the mouse must be within the bar height-wise.
+ */
+qint64 HistogramView::itemAtPosition(QPoint pos) {
+    double dvdx = m_viewWidth / (double)width();
+
+    qint64 left = qFloor(dvdx) * (pos.x() - 1) + m_viewLeft;
+    qint64 right = qCeil(dvdx) * (pos.x() + 1) + m_viewLeft;
+
+    qint64 longestIndex = 0;
+    qint64 longestValue = 0;
+
+    left = qBound<qint64>(0, left, m_data->size() - 1);
+    right = qBound<qint64>(0, right, m_data->size() - 1);
+
+    for (qint64 i = left; i <= right; ++i) {
+        if (m_data->value(i) > longestValue) {
+            longestValue = m_data->value(i);
+            longestIndex = i;
+        }
+    }
+
+    return longestIndex;
+}
+
+
+/* Return the value at position */
+qint64 HistogramView::valueAtPosition(QPoint pos) {
+    double value = m_graphTop / (double)height();
+    value *= height() - pos.y();
+    value += m_graphBottom;
+    return (qint64)value;
+}
+
diff --git a/gui/graphing/histogramview.h b/gui/graphing/histogramview.h
new file mode 100644 (file)
index 0000000..563d664
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef HISTOGRAMVIEW_H
+#define HISTOGRAMVIEW_H
+
+#include "graphview.h"
+
+/**
+ * Histogram graph view.
+ *
+ * When the view is zoomed such that there is more than one item occupying
+ * a single pixel the one with the highest value will be displayed.
+ */
+class HistogramView : public GraphView {
+public:
+    HistogramView(QWidget* parent);
+
+    void setDataProvider(GraphDataProvider* data);
+    void setSelectionState(SelectionState* state);
+
+    /* Gradient colours for selected and unselected items */
+    void setSelectedGradient(const QLinearGradient& gradient);
+    void setUnelectedGradient(const QLinearGradient& gradient);
+
+    virtual void mouseMoveEvent(QMouseEvent *e);
+    virtual void mouseDoubleClickEvent(QMouseEvent *e);
+
+    virtual void update();
+    virtual void resizeEvent(QResizeEvent *e);
+    virtual void paintEvent(QPaintEvent *e);
+
+protected:
+    qint64 itemAtPosition(QPoint pos);
+    qint64 valueAtPosition(QPoint pos);
+
+protected:
+    QLinearGradient m_gradientSelected;
+    QLinearGradient m_gradientUnselected;
+
+    GraphDataProvider* m_data;
+};
+
+#endif
diff --git a/gui/graphing/timeaxiswidget.cpp b/gui/graphing/timeaxiswidget.cpp
new file mode 100644 (file)
index 0000000..cebabf7
--- /dev/null
@@ -0,0 +1,80 @@
+#include "timeaxiswidget.h"
+#include "profiling.h"
+
+#include <qmath.h>
+#include <QPainter>
+
+TimeAxisWidget::TimeAxisWidget(QWidget* parent) :
+    GraphAxisWidget(parent)
+{
+}
+
+void TimeAxisWidget::paintEvent(QPaintEvent *)
+{
+    /* TODO: Support selections? */
+    /* TODO: Vertical scrolling? */
+
+    QPainter painter(this);
+    painter.setPen(Qt::black);
+    painter.setBrush(Qt::lightGray);
+    painter.drawRect(0, 0, width() - 1, height() - 1);
+
+    if (m_orientation == GraphAxisWidget::Vertical) {
+        int axisHeight = height() - 1;
+        int fontHeight = painter.fontMetrics().height();
+        int ticks     = axisHeight / (fontHeight * 2);
+
+        double range  = m_valueMax - m_valueMin;
+        double step   = range / (double)ticks;
+        double step10 = qPow(10.0, qFloor(qLn(step) / qLn(10.0)));
+        step = qFloor((step / step10) * 2) * (step10 / 2);
+
+        if (step <= 0) {
+            return;
+        }
+
+        painter.resetTransform();
+
+        for (double tick = 0; tick <= range; tick += step) {
+            int y = axisHeight - ((tick / range) * axisHeight);
+
+            painter.drawLine(width() - 8, y, width(), y);
+
+            painter.drawText(0,
+                             qBound(0, y - fontHeight / 2, axisHeight - fontHeight),
+                             width() - 10,
+                             fontHeight,
+                             Qt::AlignRight | Qt::AlignVCenter,
+                             Profiling::getTimeString(tick, m_valueMax));
+        }
+    } else {
+        int axisWidth = width() - 1;
+        int fontWidth = painter.fontMetrics().width("0.000 ns");
+        int fontHeight= painter.fontMetrics().height();
+        int ticks     = axisWidth / (fontWidth * 2);
+
+        double range  = m_valueMax - m_valueMin;
+        double step   = range / (double)ticks;
+        double step10 = qPow(10.0, qFloor(qLn(step) / qLn(10.0)));
+        step = qFloor((step / step10) * 2) * (step10 / 2);
+
+        if (step <= 0) {
+            return;
+        }
+
+        painter.resetTransform();
+
+        for (double tick = 0; tick <= range; tick += step) {
+            int x = (tick / range) * axisWidth;
+
+            painter.drawLine(x, 0, x, 8);
+
+            painter.drawText(qBound(0, x - fontWidth / 2, axisWidth - fontWidth),
+                             8,
+                             fontWidth,
+                             fontHeight,
+                             Qt::AlignHCenter | Qt::AlignTop,
+                             Profiling::getTimeString(tick, m_valueMax));
+        }
+    }
+}
diff --git a/gui/graphing/timeaxiswidget.h b/gui/graphing/timeaxiswidget.h
new file mode 100644 (file)
index 0000000..836651c
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef TIMEAXISWIDGET_H
+#define TIMEAXISWIDGET_H
+
+#include "graphaxiswidget.h"
+
+/**
+ * A simple axis that draws text using getTimeString to nicely format time values
+ */
+class TimeAxisWidget : public GraphAxisWidget {
+public:
+    TimeAxisWidget(QWidget* parent = 0);
+
+    virtual void paintEvent(QPaintEvent *e);
+};
+
+#endif
index 4a11da5308d4c786d347cfc8472edc88e84115a7..0e0657a3d60e265cd5d20c85815e69f881933e21 100644 (file)
@@ -1,5 +1,6 @@
 #include "imageviewer.h"
 
+#include <QDebug>
 #include <QDesktopWidget>
 #include <QPainter>
 #include <QPixmap>
@@ -10,6 +11,17 @@ ImageViewer::ImageViewer(QWidget *parent)
 {
     setupUi(this);
 
+    connect(lowerSpinBox, SIGNAL(valueChanged(double)),
+            SLOT(slotUpdate()));
+    connect(upperSpinBox, SIGNAL(valueChanged(double)),
+            SLOT(slotUpdate()));
+    connect(flipCheckBox, SIGNAL(stateChanged(int)),
+            SLOT(slotUpdate()));
+    connect(opaqueCheckBox, SIGNAL(stateChanged(int)),
+            SLOT(slotUpdate()));
+    connect(alphaCheckBox, SIGNAL(stateChanged(int)),
+            SLOT(slotUpdate()));
+
     QPixmap px(32, 32);
     QPainter p(&px);
     p.fillRect(0, 0, 32, 32, Qt::white);
@@ -27,8 +39,82 @@ ImageViewer::ImageViewer(QWidget *parent)
 void ImageViewer::setImage(const QImage &image)
 {
     m_image = image;
-    QPixmap px = QPixmap::fromImage(image);
+    m_temp = m_image;
+    QPixmap px = QPixmap::fromImage(m_temp);
+    imageLabel->setPixmap(px);
+    updateGeometry();
+}
+
+static inline int clamp(int x)
+{
+    if (x <= 0) {
+        return 0;
+    }
+    if (x > 255) {
+        return 255;
+    }
+    return x;
+}
+
+void ImageViewer::slotUpdate()
+{
+    m_temp = m_image.mirrored(false, flipCheckBox->isChecked());
+
+    double lowerValue = lowerSpinBox->value();
+    double upperValue = upperSpinBox->value();
+
+    bool opaque = opaqueCheckBox->isChecked();
+    bool alpha  = alphaCheckBox->isChecked();
+
+    if (lowerValue != 0.0 || upperValue != 1.0 || opaque || alpha) {
+        /*
+         * Rescale the image.
+         *
+         * XXX: This would be much more useful if done with the full precision
+         * of the original image
+         */
+
+        int offset = - lowerValue * 255;
+        int scale = 256 / (upperValue - lowerValue);
+
+        m_temp = m_temp.convertToFormat(QImage::Format_ARGB32);
+
+        if (0) {
+            qDebug()
+                << "offset = " << offset << "\n"
+                << "scale = " << scale << "\n";
+        }
+
+        int width = m_temp.width();
+        int height = m_temp.height();
+
+        int aMask = opaque ? 0xff : 0;
+
+        for (int y = 0; y < height; ++y) {
+            QRgb *scanline = (QRgb *)m_temp.scanLine(y);
+            for (int x = 0; x < width; ++x) {
+                QRgb pixel = scanline[x];
+                int r = qRed(pixel);
+                int g = qGreen(pixel);
+                int b = qBlue(pixel);
+                int a = qAlpha(pixel);
+                if (alpha) {
+                    a = clamp(((a + offset) * scale) >> 8);
+                    scanline[x] = qRgba(a, a, a, 0xff);
+                } else {
+                    r = clamp(((r + offset) * scale) >> 8);
+                    g = clamp(((g + offset) * scale) >> 8);
+                    b = clamp(((b + offset) * scale) >> 8);
+                    a |= aMask;
+                    scanline[x] = qRgba(r, g, b, a);
+                }
+            }
+        }
+    }
+
+    QPixmap px = QPixmap::fromImage(m_temp);
     imageLabel->setPixmap(px);
+
     updateGeometry();
 }
 
index 16bc7f2ab0b5c0f6e0e10b6955b5cb5a26fc9549..e8781182ebf8ae88343f4f6d0110934f469f97ef 100644 (file)
@@ -13,8 +13,13 @@ public:
     void setImage(const QImage &image);
 
     QSize sizeHint() const;
+
+private slots:
+    void slotUpdate();
+
 private:
     QImage m_image;
+    QImage m_temp;
 };
 
 
index d7af53dde789c219e76dae1428254f3b58337dfd..0ed50ed8f2b33506f931f570d9662430d59712ec 100644 (file)
@@ -6,12 +6,14 @@
 #include <QApplication>
 #include <QMetaType>
 #include <QVariant>
+#include <QImage>
 
 Q_DECLARE_METATYPE(QList<ApiTraceFrame*>);
 Q_DECLARE_METATYPE(QVector<ApiTraceCall*>);
 Q_DECLARE_METATYPE(Qt::CaseSensitivity);
 Q_DECLARE_METATYPE(ApiTrace::SearchResult);
 Q_DECLARE_METATYPE(ApiTrace::SearchRequest);
+Q_DECLARE_METATYPE(QList<QImage>);
 
 static void usage(void)
 {
@@ -20,6 +22,7 @@ static void usage(void)
 
 int main(int argc, char **argv)
 {
+    QApplication::setGraphicsSystem("raster");
     QApplication app(argc, argv);
 
     qRegisterMetaType<QList<ApiTraceFrame*> >();
@@ -28,6 +31,7 @@ int main(int argc, char **argv)
     qRegisterMetaType<Qt::CaseSensitivity>();
     qRegisterMetaType<ApiTrace::SearchResult>();
     qRegisterMetaType<ApiTrace::SearchRequest>();
+    qRegisterMetaType<QList<QImage> >();
     QStringList args = app.arguments();
 
     int i = 1;
index d37162ba7e227c10df01cedc1fc5e0310586ae8a..caf9e370236ebed41d8aa29409cc3e253b1457a4 100644 (file)
@@ -8,14 +8,19 @@
 #include "argumentseditor.h"
 #include "imageviewer.h"
 #include "jumpwidget.h"
+#include "profiledialog.h"
 #include "retracer.h"
 #include "searchwidget.h"
 #include "settingsdialog.h"
 #include "shaderssourcewidget.h"
 #include "tracedialog.h"
 #include "traceprocess.h"
+#include "trimprocess.h"
+#include "thumbnail.h"
 #include "ui_retracerdialog.h"
+#include "ui_profilereplaydialog.h"
 #include "vertexdatainterpreter.h"
+#include "trace_profiler.hpp"
 
 #include <QAction>
 #include <QApplication>
@@ -47,6 +52,15 @@ MainWindow::MainWindow()
     initConnections();
 }
 
+MainWindow::~MainWindow()
+{
+    delete m_trace;
+    m_trace = 0;
+
+    delete m_proxyModel;
+    delete m_model;
+}
+
 void MainWindow::createTrace()
 {
     if (!m_traceProcess->canTrace()) {
@@ -61,6 +75,7 @@ void MainWindow::createTrace()
     if (dialog.exec() == QDialog::Accepted) {
         qDebug()<< "App : " <<dialog.applicationPath();
         qDebug()<< "  Arguments: "<<dialog.arguments();
+        m_traceProcess->setApi(dialog.api());
         m_traceProcess->setExecutablePath(dialog.applicationPath());
         m_traceProcess->setArguments(dialog.arguments());
         m_traceProcess->start();
@@ -147,6 +162,10 @@ void MainWindow::callItemSelected(const QModelIndex &index)
     }
 }
 
+void MainWindow::callItemActivated(const QModelIndex &index) {
+    lookupState();
+}
+
 void MainWindow::replayStart()
 {
     if (m_trace->isSaving()) {
@@ -157,21 +176,52 @@ void MainWindow::replayStart()
                "Please wait until it finishes and try again."));
         return;
     }
+
     QDialog dlg;
     Ui_RetracerDialog dlgUi;
     dlgUi.setupUi(&dlg);
 
     dlgUi.doubleBufferingCB->setChecked(
         m_retracer->isDoubleBuffered());
+
     dlgUi.errorCheckCB->setChecked(
         !m_retracer->isBenchmarking());
 
     if (dlg.exec() == QDialog::Accepted) {
         m_retracer->setDoubleBuffered(
             dlgUi.doubleBufferingCB->isChecked());
+
         m_retracer->setBenchmarking(
             !dlgUi.errorCheckCB->isChecked());
-        replayTrace(false);
+
+        m_retracer->setProfiling(false, false, false);
+
+        replayTrace(false, false);
+    }
+}
+
+void MainWindow::replayProfile()
+{
+    if (m_trace->isSaving()) {
+        QMessageBox::warning(
+            this,
+            tr("Trace Saving"),
+            tr("QApiTrace is currently saving the edited trace file. "
+               "Please wait until it finishes and try again."));
+        return;
+    }
+
+    QDialog dlg;
+    Ui_ProfileReplayDialog dlgUi;
+    dlgUi.setupUi(&dlg);
+
+    if (dlg.exec() == QDialog::Accepted) {
+        m_retracer->setProfiling(
+            dlgUi.gpuTimesCB->isChecked(),
+            dlgUi.cpuTimesCB->isChecked(),
+            dlgUi.pixelsDrawnCB->isChecked());
+
+        replayTrace(false, false);
     }
 }
 
@@ -180,7 +230,9 @@ void MainWindow::replayStop()
     m_retracer->quit();
     m_ui.actionStop->setEnabled(false);
     m_ui.actionReplay->setEnabled(true);
+    m_ui.actionProfile->setEnabled(true);
     m_ui.actionLookupState->setEnabled(true);
+    m_ui.actionShowThumbnails->setEnabled(true);
 }
 
 void MainWindow::newTraceFile(const QString &fileName)
@@ -192,43 +244,47 @@ void MainWindow::newTraceFile(const QString &fileName)
 
     if (fileName.isEmpty()) {
         m_ui.actionReplay->setEnabled(false);
+        m_ui.actionProfile->setEnabled(false);
         m_ui.actionLookupState->setEnabled(false);
+        m_ui.actionShowThumbnails->setEnabled(false);
         setWindowTitle(tr("QApiTrace"));
     } else {
         QFileInfo info(fileName);
         m_ui.actionReplay->setEnabled(true);
+        m_ui.actionProfile->setEnabled(true);
         m_ui.actionLookupState->setEnabled(true);
+        m_ui.actionShowThumbnails->setEnabled(true);
+        m_ui.actionTrim->setEnabled(true);
         setWindowTitle(
             tr("QApiTrace - %1").arg(info.fileName()));
     }
 }
 
-void MainWindow::replayFinished(const QString &output)
+void MainWindow::replayFinished(const QString &message)
 {
     m_ui.actionStop->setEnabled(false);
     m_ui.actionReplay->setEnabled(true);
+    m_ui.actionProfile->setEnabled(true);
     m_ui.actionLookupState->setEnabled(true);
+    m_ui.actionShowThumbnails->setEnabled(true);
 
     m_progressBar->hide();
-    if (output.length() < 80) {
-        statusBar()->showMessage(output);
-    }
+    statusBar()->showMessage(message, 2000);
     m_stateEvent = 0;
     m_ui.actionShowErrorsDock->setEnabled(m_trace->hasErrors());
     m_ui.errorsDock->setVisible(m_trace->hasErrors());
     if (!m_trace->hasErrors()) {
         m_ui.errorsTreeWidget->clear();
     }
-
-    statusBar()->showMessage(
-        tr("Replaying finished!"), 2000);
 }
 
 void MainWindow::replayError(const QString &message)
 {
     m_ui.actionStop->setEnabled(false);
     m_ui.actionReplay->setEnabled(true);
+    m_ui.actionProfile->setEnabled(true);
     m_ui.actionLookupState->setEnabled(true);
+    m_ui.actionShowThumbnails->setEnabled(true);
     m_stateEvent = 0;
     m_nonDefaultsLookupEvent = 0;
 
@@ -254,6 +310,7 @@ void MainWindow::finishedLoadingTrace()
     if (!m_trace) {
         return;
     }
+    m_api = m_trace->api();
     QFileInfo info(m_trace->fileName());
     statusBar()->showMessage(
         tr("Loaded %1").arg(info.fileName()), 3000);
@@ -263,7 +320,7 @@ void MainWindow::finishedLoadingTrace()
     }
 }
 
-void MainWindow::replayTrace(bool dumpState)
+void MainWindow::replayTrace(bool dumpState, bool dumpThumbnails)
 {
     if (m_trace->fileName().isEmpty()) {
         return;
@@ -272,6 +329,7 @@ void MainWindow::replayTrace(bool dumpState)
     m_retracer->setFileName(m_trace->fileName());
     m_retracer->setAPI(m_api);
     m_retracer->setCaptureState(dumpState);
+    m_retracer->setCaptureThumbnails(dumpThumbnails);
     if (m_retracer->captureState() && m_selectedEvent) {
         int index = 0;
         if (m_selectedEvent->type() == ApiTraceEvent::Call) {
@@ -295,15 +353,45 @@ void MainWindow::replayTrace(bool dumpState)
 
     m_ui.actionStop->setEnabled(true);
     m_progressBar->show();
-    if (dumpState) {
+    if (dumpState || dumpThumbnails) {
+        if (dumpState && dumpThumbnails) {
+            statusBar()->showMessage(
+                tr("Looking up the state and capturing thumbnails..."));
+        } else if (dumpState) {
+            statusBar()->showMessage(
+                tr("Looking up the state..."));
+        } else if (dumpThumbnails) {
+            statusBar()->showMessage(
+                tr("Capturing thumbnails..."));
+        }
+    } else if (m_retracer->isProfiling()) {
         statusBar()->showMessage(
-            tr("Looking up the state..."));
+                    tr("Profiling draw calls in trace file..."));
     } else {
         statusBar()->showMessage(
             tr("Replaying the trace file..."));
     }
 }
 
+void MainWindow::trimEvent()
+{
+
+    int trimIndex;
+    if (m_trimEvent->type() == ApiTraceEvent::Call) {
+        ApiTraceCall *call = static_cast<ApiTraceCall*>(m_trimEvent);
+        trimIndex = call->index();
+    } else if (m_trimEvent->type() == ApiTraceEvent::Frame) {
+        ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(m_trimEvent);
+        const QList<ApiTraceFrame*> frames = m_trace->frames();
+        trimIndex = frame->lastCallIndex();
+    }
+
+    m_trimProcess->setTracePath(m_trace->fileName());
+    m_trimProcess->setTrimIndex(trimIndex);
+
+    m_trimProcess->start();
+}
+
 void MainWindow::lookupState()
 {
     if (!m_selectedEvent) {
@@ -321,16 +409,24 @@ void MainWindow::lookupState()
         return;
     }
     m_stateEvent = m_selectedEvent;
-    replayTrace(true);
+    replayTrace(true, false);
 }
 
-MainWindow::~MainWindow()
+void MainWindow::showThumbnails()
 {
-    delete m_trace;
-    m_trace = 0;
+    replayTrace(false, true);
+}
 
-    delete m_proxyModel;
-    delete m_model;
+void MainWindow::trim()
+{
+    if (!m_selectedEvent) {
+        QMessageBox::warning(
+            this, tr("Unknown Event"),
+            tr("To trim select a frame or an event in the event list."));
+        return;
+    }
+    m_trimEvent = m_selectedEvent;
+    trimEvent();
 }
 
 static void
@@ -530,7 +626,7 @@ void MainWindow::fillStateForFrame()
     if (textures.isEmpty() && fbos.isEmpty()) {
         m_ui.surfacesTab->setDisabled(false);
     } else {
-        m_ui.surfacesTreeWidget->setIconSize(QSize(64, 64));
+        m_ui.surfacesTreeWidget->setIconSize(QSize(THUMBNAIL_SIZE, THUMBNAIL_SIZE));
         if (!textures.isEmpty()) {
             QTreeWidgetItem *textureItem =
                 new QTreeWidgetItem(m_ui.surfacesTreeWidget);
@@ -571,12 +667,9 @@ void MainWindow::fillStateForFrame()
 void MainWindow::showSettings()
 {
     SettingsDialog dialog;
-    dialog.setAPI(m_api);
     dialog.setFilterModel(m_proxyModel);
 
     dialog.exec();
-
-    m_api = dialog.getAPI();
 }
 
 void MainWindow::openHelp(const QUrl &url)
@@ -705,6 +798,9 @@ void MainWindow::initObjects()
     m_searchWidget->hide();
 
     m_traceProcess = new TraceProcess(this);
+    m_trimProcess = new TrimProcess(this);
+
+    m_profileDialog = new ProfileDialog();
 }
 
 void MainWindow::initConnections()
@@ -719,8 +815,8 @@ void MainWindow::initConnections()
             this, SLOT(slotStartedSaving()));
     connect(m_trace, SIGNAL(saved()),
             this, SLOT(slotSaved()));
-    connect(m_trace, SIGNAL(changed(ApiTraceCall*)),
-            this, SLOT(slotTraceChanged(ApiTraceCall*)));
+    connect(m_trace, SIGNAL(changed(ApiTraceEvent*)),
+            this, SLOT(slotTraceChanged(ApiTraceEvent*)));
     connect(m_trace, SIGNAL(findResult(ApiTrace::SearchRequest,ApiTrace::SearchResult,ApiTraceCall*)),
             this, SLOT(slotSearchResult(ApiTrace::SearchRequest,ApiTrace::SearchResult,ApiTraceCall*)));
     connect(m_trace, SIGNAL(foundFrameStart(ApiTraceFrame*)),
@@ -736,6 +832,10 @@ void MainWindow::initConnections()
             this, SLOT(replayError(const QString&)));
     connect(m_retracer, SIGNAL(foundState(ApiTraceState*)),
             this, SLOT(replayStateFound(ApiTraceState*)));
+    connect(m_retracer, SIGNAL(foundProfile(trace::Profile*)),
+            this, SLOT(replayProfileFound(trace::Profile*)));
+    connect(m_retracer, SIGNAL(foundThumbnails(const QList<QImage>&)),
+            this, SLOT(replayThumbnailsFound(const QList<QImage>&)));
     connect(m_retracer, SIGNAL(retraceErrors(const QList<ApiTraceError>&)),
             this, SLOT(slotRetraceErrors(const QList<ApiTraceError>&)));
 
@@ -769,15 +869,23 @@ void MainWindow::initConnections()
 
     connect(m_ui.actionReplay, SIGNAL(triggered()),
             this, SLOT(replayStart()));
+    connect(m_ui.actionProfile, SIGNAL(triggered()),
+            this, SLOT(replayProfile()));
     connect(m_ui.actionStop, SIGNAL(triggered()),
             this, SLOT(replayStop()));
     connect(m_ui.actionLookupState, SIGNAL(triggered()),
             this, SLOT(lookupState()));
+    connect(m_ui.actionTrim, SIGNAL(triggered()),
+            this, SLOT(trim()));
+    connect(m_ui.actionShowThumbnails, SIGNAL(triggered()),
+            this, SLOT(showThumbnails()));
     connect(m_ui.actionOptions, SIGNAL(triggered()),
             this, SLOT(showSettings()));
 
     connect(m_ui.callView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
             this, SLOT(callItemSelected(const QModelIndex &)));
+    connect(m_ui.callView, SIGNAL(doubleClicked(const QModelIndex &)),
+            this, SLOT(callItemActivated(const QModelIndex &)));
     connect(m_ui.callView, SIGNAL(customContextMenuRequested(QPoint)),
             this, SLOT(customContextMenuRequested(QPoint)));
 
@@ -809,6 +917,11 @@ void MainWindow::initConnections()
     connect(m_traceProcess, SIGNAL(error(const QString&)),
             SLOT(traceError(const QString&)));
 
+    connect(m_trimProcess, SIGNAL(trimmedFile(const QString&)),
+            SLOT(createdTrim(const QString&)));
+    connect(m_trimProcess, SIGNAL(error(const QString&)),
+            SLOT(trimError(const QString&)));
+
     connect(m_ui.errorsDock, SIGNAL(visibilityChanged(bool)),
             m_ui.actionShowErrorsDock, SLOT(setChecked(bool)));
     connect(m_ui.actionShowErrorsDock, SIGNAL(triggered(bool)),
@@ -816,6 +929,26 @@ void MainWindow::initConnections()
     connect(m_ui.errorsTreeWidget,
             SIGNAL(itemActivated(QTreeWidgetItem*, int)),
             this, SLOT(slotErrorSelected(QTreeWidgetItem*)));
+
+    connect(m_ui.actionShowProfileDialog, SIGNAL(triggered(bool)),
+            m_profileDialog, SLOT(show()));
+    connect(m_profileDialog, SIGNAL(jumpToCall(int)),
+            this, SLOT(slotJumpTo(int)));
+}
+
+void MainWindow::closeEvent(QCloseEvent * event)
+{
+    m_profileDialog->close();
+    QMainWindow::closeEvent(event);
+}
+
+void MainWindow::replayProfileFound(trace::Profile *profile)
+{
+    m_ui.actionShowProfileDialog->setEnabled(true);
+    m_profileDialog->setProfile(profile);
+    m_profileDialog->show();
+    m_profileDialog->activateWindow();
+    m_profileDialog->setFocus();
 }
 
 void MainWindow::replayStateFound(ApiTraceState *state)
@@ -831,6 +964,12 @@ void MainWindow::replayStateFound(ApiTraceState *state)
     m_nonDefaultsLookupEvent = 0;
 }
 
+void MainWindow::replayThumbnailsFound(const QList<QImage> &thumbnails)
+{
+    m_ui.callView->setUniformRowHeights(false);
+    m_trace->bindThumbnailsToFrames(thumbnails);
+}
+
 void MainWindow::slotGoTo()
 {
     m_searchWidget->hide();
@@ -856,6 +995,21 @@ void MainWindow::traceError(const QString &msg)
             msg);
 }
 
+void MainWindow::createdTrim(const QString &path)
+{
+    qDebug()<<"Done trimming "<<path;
+
+    newTraceFile(path);
+}
+
+void MainWindow::trimError(const QString &msg)
+{
+    QMessageBox::warning(
+            this,
+            tr("Trim Error"),
+            msg);
+}
+
 void MainWindow::slotSearch()
 {
     m_jumpWidget->hide();
@@ -1006,11 +1160,14 @@ ApiTraceFrame * MainWindow::selectedFrame() const
     return NULL;
 }
 
-void MainWindow::slotTraceChanged(ApiTraceCall *call)
+void MainWindow::slotTraceChanged(ApiTraceEvent *event)
 {
-    Q_ASSERT(call);
-    if (call == m_selectedEvent) {
-        m_ui.detailsWebView->setHtml(call->toHtml());
+    Q_ASSERT(event);
+    if (event == m_selectedEvent) {
+        if (event->type() == ApiTraceEvent::Call) {
+            ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
+            m_ui.detailsWebView->setHtml(call->toHtml());
+        }
     }
 }
 
@@ -1219,6 +1376,7 @@ void MainWindow::slotFoundFrameStart(ApiTraceFrame *frame)
         QModelIndex idx = m_proxyModel->indexForCall(call);
         if (idx.isValid()) {
             m_ui.callView->setCurrentIndex(idx);
+            m_ui.callView->scrollTo(idx, QAbstractItemView::PositionAtTop);
             break;
         }
         ++itr;
@@ -1241,6 +1399,7 @@ void MainWindow::slotFoundFrameEnd(ApiTraceFrame *frame)
         QModelIndex idx = m_proxyModel->indexForCall(call);
         if (idx.isValid()) {
             m_ui.callView->setCurrentIndex(idx);
+            m_ui.callView->scrollTo(idx, QAbstractItemView::PositionAtBottom);
             break;
         }
     } while (itr != calls.constBegin());
@@ -1248,9 +1407,12 @@ void MainWindow::slotFoundFrameEnd(ApiTraceFrame *frame)
 
 void MainWindow::slotJumpToResult(ApiTraceCall *call)
 {
-    QModelIndex index = m_proxyModel->indexForCall(call);
-    if (index.isValid()) {
-        m_ui.callView->setCurrentIndex(index);
+    QModelIndex idx = m_proxyModel->indexForCall(call);
+    if (idx.isValid()) {
+        activateWindow();
+        m_ui.callView->setFocus();
+        m_ui.callView->setCurrentIndex(idx);
+        m_ui.callView->scrollTo(idx, QAbstractItemView::PositionAtCenter);
     } else {
         statusBar()->showMessage(tr("Call has been filtered out."));
     }
index 59c9ba78010f6bcd0e0ab9a5f2b43d4d19062daf..2248127f76aae57b8acd4728c7b090ad628564da 100644 (file)
@@ -8,6 +8,8 @@
 
 #include <QMainWindow>
 #include <QProcess>
+#include <QList>
+#include <QImage>
 
 class ApiTrace;
 class ApiTraceCall;
@@ -27,8 +29,12 @@ class Retracer;
 class SearchWidget;
 class ShadersSourceWidget;
 class TraceProcess;
+class TrimProcess;
+class ProfileDialog;
 class VertexDataInterpreter;
 
+namespace trace { struct Profile; }
+
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
@@ -41,17 +47,23 @@ public slots:
 
 private slots:
     void callItemSelected(const QModelIndex &index);
+    void callItemActivated(const QModelIndex &index);
     void createTrace();
     void openTrace();
     void replayStart();
+    void replayProfile();
     void replayStop();
-    void replayFinished(const QString &output);
+    void replayFinished(const QString &message);
     void replayStateFound(ApiTraceState *state);
+    void replayProfileFound(trace::Profile *state);
+    void replayThumbnailsFound(const QList<QImage> &thumbnails);
     void replayError(const QString &msg);
     void startedLoadingTrace();
     void loadProgess(int percent);
     void finishedLoadingTrace();
     void lookupState();
+    void showThumbnails();
+    void trim();
     void showSettings();
     void openHelp(const QUrl &url);
     void showSurfacesMenu(const QPoint &pos);
@@ -61,6 +73,8 @@ private slots:
     void slotJumpTo(int callNum);
     void createdTrace(const QString &path);
     void traceError(const QString &msg);
+    void createdTrim(const QString &path);
+    void trimError(const QString &msg);
     void slotSearch();
     void slotSearchNext(const QString &str, Qt::CaseSensitivity sensitivity);
     void slotSearchPrev(const QString &str, Qt::CaseSensitivity sensitivity);
@@ -71,7 +85,7 @@ private slots:
     void slotSaved();
     void slotGoFrameStart();
     void slotGoFrameEnd();
-    void slotTraceChanged(ApiTraceCall *call);
+    void slotTraceChanged(ApiTraceEvent *event);
     void slotRetraceErrors(const QList<ApiTraceError> &errors);
     void slotErrorSelected(QTreeWidgetItem *current);
     void slotSearchResult(const ApiTrace::SearchRequest &request,
@@ -85,7 +99,8 @@ private:
     void initObjects();
     void initConnections();
     void newTraceFile(const QString &fileName);
-    void replayTrace(bool dumpState);
+    void replayTrace(bool dumpState, bool dumpThumbnails);
+    void trimEvent();
     void fillStateForFrame();
 
     /* there's a difference between selected frame/call and
@@ -97,6 +112,8 @@ private:
     ApiTraceFrame *currentFrame() const;
     ApiTraceCall *currentCall() const;
 
+protected:
+    virtual void closeEvent(QCloseEvent * event);
 
 private:
     Ui_MainWindow m_ui;
@@ -115,6 +132,8 @@ private:
 
     ApiTraceEvent *m_stateEvent;
 
+    ApiTraceEvent *m_trimEvent;
+
     Retracer *m_retracer;
 
     VertexDataInterpreter *m_vdataInterpreter;
@@ -124,9 +143,13 @@ private:
 
     TraceProcess *m_traceProcess;
 
+    TrimProcess *m_trimProcess;
+
     ArgumentsEditor *m_argsEditor;
 
     ApiTraceEvent *m_nonDefaultsLookupEvent;
+
+    ProfileDialog* m_profileDialog;
 };
 
 
diff --git a/gui/profiledialog.cpp b/gui/profiledialog.cpp
new file mode 100644 (file)
index 0000000..a9892cf
--- /dev/null
@@ -0,0 +1,265 @@
+#include "profiledialog.h"
+#include "profiletablemodel.h"
+#include <QSortFilterProxyModel>
+
+#include "graphing/histogramview.h"
+#include "graphing/timeaxiswidget.h"
+#include "graphing/frameaxiswidget.h"
+#include "graphing/heatmapverticalaxiswidget.h"
+#include "profileheatmap.h"
+
+/* Handy function to allow selection of a call in main window */
+ProfileDialog* g_profileDialog = 0;
+
+void Profiling::jumpToCall(int index)
+{
+    if (g_profileDialog) {
+        g_profileDialog->showCall(index);
+    }
+}
+
+/* Provides frame numbers based off call index */
+class FrameCallDataProvider : public FrameDataProvider {
+public:
+    FrameCallDataProvider(const trace::Profile* profile)
+    {
+        m_profile = profile;
+    }
+
+    unsigned size() const {
+        return m_profile->frames.size();
+    }
+
+    qint64 frameStart(unsigned index) const {
+        return m_profile->frames[index].calls.begin;
+    }
+
+    qint64 frameEnd(unsigned index) const {
+        return m_profile->frames[index].calls.end;
+    }
+
+private:
+    const trace::Profile* m_profile;
+};
+
+/* Provides frame numbers based off time */
+class FrameTimeDataProvider : public FrameDataProvider {
+public:
+    FrameTimeDataProvider(const trace::Profile* profile)
+    {
+        m_profile = profile;
+    }
+
+    unsigned size() const {
+        return m_profile->frames.size();
+    }
+
+    qint64 frameStart(unsigned index) const {
+        return m_profile->frames[index].cpuStart;
+    }
+
+    qint64 frameEnd(unsigned index) const {
+        return m_profile->frames[index].cpuStart + m_profile->frames[index].cpuDuration;
+    }
+
+private:
+    const trace::Profile* m_profile;
+};
+
+ProfileDialog::ProfileDialog(QWidget *parent)
+    : QDialog(parent),
+      m_profile(0)
+{
+    setupUi(this);
+    g_profileDialog = this;
+
+    /* Gradients for call duration histograms */
+    QLinearGradient cpuGradient;
+    cpuGradient.setColorAt(0.9, QColor(0, 0, 210));
+    cpuGradient.setColorAt(0.0, QColor(130, 130, 255));
+
+    QLinearGradient gpuGradient;
+    gpuGradient.setColorAt(0.9, QColor(210, 0, 0));
+    gpuGradient.setColorAt(0.0, QColor(255, 130, 130));
+
+
+    /* Setup heatmap timeline */
+    m_timeline->setLabel(new GraphLabelWidget("Frames ", m_timeline));
+    m_timeline->label()->setFlags(Qt::AlignVCenter | Qt::AlignRight);
+
+    m_timeline->setView(new HeatmapView(m_timeline));
+
+    m_timeline->setAxis(GraphWidget::AxisTop, new FrameAxisWidget(m_timeline));
+    m_timeline->setAxis(GraphWidget::AxisLeft, new HeatmapVerticalAxisWidget(m_timeline));
+    m_timeline->axis(GraphWidget::AxisLeft)->resize(80, 0);
+
+    m_timeline->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+    m_timeline->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+
+
+    /* Setup Cpu call duration histogram */
+    m_cpuGraph->setLabel(new GraphLabelWidget("CPU", m_cpuGraph));
+
+    m_cpuGraph->setAxis(GraphWidget::AxisTop, new FrameAxisWidget(m_cpuGraph));
+    m_cpuGraph->setAxis(GraphWidget::AxisLeft, new TimeAxisWidget(m_cpuGraph));
+    m_cpuGraph->axis(GraphWidget::AxisLeft)->resize(80, 0);
+
+    HistogramView* cpuView = new HistogramView(m_cpuGraph);
+    cpuView->setSelectedGradient(cpuGradient);
+    m_cpuGraph->setView(cpuView);
+
+
+    /* Setup Gpu call duration histogram */
+    m_gpuGraph->setLabel(new GraphLabelWidget("GPU", m_gpuGraph));
+
+    m_gpuGraph->setAxis(GraphWidget::AxisTop, new FrameAxisWidget(m_gpuGraph));
+    m_gpuGraph->setAxis(GraphWidget::AxisLeft, new TimeAxisWidget(m_gpuGraph));
+    m_gpuGraph->axis(GraphWidget::AxisLeft)->resize(80, 0);
+
+    HistogramView* gpuView = new HistogramView(m_gpuGraph);
+    gpuView->setSelectedGradient(gpuGradient);
+    m_gpuGraph->setView(gpuView);
+
+
+    /* Synchronise selections */
+    connect(m_timeline, SIGNAL(selectionChanged(SelectionState)), m_cpuGraph, SLOT(setSelection(SelectionState)));
+    connect(m_timeline, SIGNAL(selectionChanged(SelectionState)), m_gpuGraph, SLOT(setSelection(SelectionState)));
+
+    connect(m_cpuGraph, SIGNAL(selectionChanged(SelectionState)), m_timeline, SLOT(setSelection(SelectionState)));
+    connect(m_cpuGraph, SIGNAL(selectionChanged(SelectionState)), m_gpuGraph, SLOT(setSelection(SelectionState)));
+
+    connect(m_gpuGraph, SIGNAL(selectionChanged(SelectionState)), m_timeline, SLOT(setSelection(SelectionState)));
+    connect(m_gpuGraph, SIGNAL(selectionChanged(SelectionState)), m_cpuGraph, SLOT(setSelection(SelectionState)));
+
+    connect(m_timeline, SIGNAL(selectionChanged(SelectionState)), this, SLOT(graphSelectionChanged(SelectionState)));
+    connect(m_cpuGraph, SIGNAL(selectionChanged(SelectionState)), this, SLOT(graphSelectionChanged(SelectionState)));
+    connect(m_gpuGraph, SIGNAL(selectionChanged(SelectionState)), this, SLOT(graphSelectionChanged(SelectionState)));
+
+
+    /* Synchronise views between cpuGraph and gpuGraph */
+    connect(m_cpuGraph, SIGNAL(horizontalViewChanged(qint64,qint64)), m_gpuGraph, SLOT(setHorizontalView(qint64,qint64)));
+    connect(m_gpuGraph, SIGNAL(horizontalViewChanged(qint64,qint64)), m_cpuGraph, SLOT(setHorizontalView(qint64,qint64)));
+}
+
+
+ProfileDialog::~ProfileDialog()
+{
+    delete m_profile;
+}
+
+
+void ProfileDialog::showCall(int call)
+{
+    emit jumpToCall(call);
+}
+
+
+void ProfileDialog::tableDoubleClicked(const QModelIndex& index)
+{
+    ProfileTableModel* model = (ProfileTableModel*)m_table->model();
+
+    if (!model) {
+        return;
+    }
+
+    const trace::Profile::Call* call = model->getJumpCall(index);
+
+    if (call) {
+        emit jumpToCall(call->no);
+    } else {
+        unsigned program = model->getProgram(index);
+
+        SelectionState state;
+        state.type = SelectionState::Vertical;
+        state.end = state.start = program;
+
+        m_timeline->setSelection(state);
+        m_cpuGraph->setSelection(state);
+        m_gpuGraph->setSelection(state);
+    }
+}
+
+
+void ProfileDialog::setProfile(trace::Profile* profile)
+{
+
+    if (profile && profile->frames.size()) {
+        HeatmapVerticalAxisWidget* programAxis;
+        FrameAxisWidget* frameAxis;
+        HistogramView* histogram;
+        HeatmapView* heatmap;
+
+
+        /* Setup data providers for Cpu graph */
+        m_cpuGraph->setProfile(profile);
+        histogram = (HistogramView*)m_cpuGraph->view();
+        frameAxis = (FrameAxisWidget*)m_cpuGraph->axis(GraphWidget::AxisTop);
+
+        histogram->setDataProvider(new CallDurationDataProvider(profile, false));
+        frameAxis->setDataProvider(new FrameCallDataProvider(profile));
+
+        /* Setup data provider for Gpu graph */
+        m_gpuGraph->setProfile(profile);
+        histogram = (HistogramView*)m_gpuGraph->view();
+        frameAxis = (FrameAxisWidget*)m_gpuGraph->axis(GraphWidget::AxisTop);
+
+        histogram->setDataProvider(new CallDurationDataProvider(profile, true));
+        frameAxis->setDataProvider(new FrameCallDataProvider(profile));
+
+        /* Setup data provider for heatmap timeline */
+        heatmap = (HeatmapView*)m_timeline->view();
+        frameAxis = (FrameAxisWidget*)m_timeline->axis(GraphWidget::AxisTop);
+        programAxis = (HeatmapVerticalAxisWidget*)m_timeline->axis(GraphWidget::AxisLeft);
+
+        heatmap->setDataProvider(new ProfileHeatmapDataProvider(profile));
+        frameAxis->setDataProvider(new FrameTimeDataProvider(profile));
+        programAxis->setDataProvider(new ProfileHeatmapDataProvider(profile));
+
+        /* Setup data model for table view */
+        ProfileTableModel* model = new ProfileTableModel(m_table);
+        model->setProfile(profile);
+
+        delete m_table->model();
+        m_table->setModel(model);
+        m_table->update(QModelIndex());
+        m_table->sortByColumn(2, Qt::DescendingOrder);
+        m_table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
+        m_table->resizeColumnsToContents();
+
+        /* Reset selection */
+        SelectionState emptySelection;
+        emptySelection.type = SelectionState::None;
+        m_cpuGraph->setSelection(emptySelection);
+        m_gpuGraph->setSelection(emptySelection);
+        m_timeline->setSelection(emptySelection);
+    }
+
+    delete m_profile;
+    m_profile = profile;
+}
+
+
+void ProfileDialog::graphSelectionChanged(SelectionState state)
+{
+    ProfileTableModel* model = (ProfileTableModel*)m_table->model();
+
+    if (!model) {
+        return;
+    }
+
+    if (state.type == SelectionState::None) {
+        model->selectNone();
+    } else if (state.type == SelectionState::Horizontal) {
+        model->selectTime(state.start, state.end);
+    } else if (state.type == SelectionState::Vertical) {
+        model->selectProgram(state.start);
+    }
+
+    m_table->reset();
+
+    if (state.type == SelectionState::Vertical) {
+        m_table->selectRow(model->getRowIndex(state.start));
+    }
+}
+
+#include "profiledialog.moc"
diff --git a/gui/profiledialog.h b/gui/profiledialog.h
new file mode 100644 (file)
index 0000000..862d068
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef PROFILEDIALOG_H
+#define PROFILEDIALOG_H
+
+#include "ui_profiledialog.h"
+#include <QDialog>
+
+namespace trace { struct Profile; }
+
+class ProfileDialog : public QDialog, public Ui_ProfileDialog
+{
+    Q_OBJECT
+
+public:
+    ProfileDialog(QWidget *parent = 0);
+    ~ProfileDialog();
+    
+    void setProfile(trace::Profile* profile);
+    void showCall(int call);
+
+public slots:
+    void tableDoubleClicked(const QModelIndex& index);
+    void graphSelectionChanged(SelectionState state);
+
+signals:
+    void jumpToCall(int call);
+
+private:
+    trace::Profile *m_profile;
+};
+
+#endif
diff --git a/gui/profileheatmap.h b/gui/profileheatmap.h
new file mode 100644 (file)
index 0000000..e50ea26
--- /dev/null
@@ -0,0 +1,470 @@
+#ifndef PROFILEHEATMAP_H
+#define PROFILEHEATMAP_H
+
+#include "graphing/heatmapview.h"
+#include "profiling.h"
+
+/**
+ * Data providers for a heatmap based off the trace::Profile call data
+ */
+
+class ProfileHeatmapRowIterator : public HeatmapRowIterator {
+public:
+    ProfileHeatmapRowIterator(const trace::Profile* profile, qint64 start, qint64 end, int steps, bool gpu, int program = -1) :
+        m_profile(profile),
+        m_step(-1),
+        m_stepWidth(1),
+        m_stepCount(steps),
+        m_index(0),
+        m_timeStart(start),
+        m_timeEnd(end),
+        m_useGpu(gpu),
+        m_program(program),
+        m_selected(false),
+        m_timeSelection(false),
+        m_programSelection(false)
+    {
+        m_timeWidth = m_timeEnd - m_timeStart;
+    }
+
+    virtual bool next()
+    {
+        unsigned maxIndex = m_program == -1 ? m_profile->calls.size() : m_profile->programs[m_program].calls.size();
+
+        if (m_index >= maxIndex) {
+            return false;
+        }
+
+        double dtds = m_timeWidth / (double)m_stepCount;
+
+        qint64 heatDuration = 0;
+        qint64 programHeatDuration = 0;
+        m_heat = 0.0f;
+        m_step += m_stepWidth;
+        m_stepWidth = 1;
+
+        m_selected = false;
+
+        /* Iterator through calls until step != lastStep */
+        for (; m_index < maxIndex; ++m_index)
+        {
+            const trace::Profile::Call* call;
+
+            if (m_program == -1) {
+                call = &m_profile->calls[m_index];
+            } else {
+                call = &m_profile->calls[ m_profile->programs[m_program].calls[m_index] ];
+            }
+
+            qint64 start, duration, end;
+
+            if (m_useGpu) {
+                start = call->gpuStart;
+                duration = call->gpuDuration;
+
+                if (call->pixels < 0) {
+                    continue;
+                }
+            } else {
+                start = call->cpuStart;
+                duration = call->cpuDuration;
+            }
+
+            end = start + duration;
+
+            if (end < m_timeStart) {
+                continue;
+            }
+
+            if (start > m_timeEnd) {
+                m_index = m_profile->calls.size();
+                break;
+            }
+
+            double left  = timeToStep(start);
+            double right = timeToStep(end);
+
+            int leftStep = left;
+            int rightStep = right;
+
+            if (leftStep > m_step) {
+                break;
+            }
+
+            if (m_programSelection && call->program == m_programSel) {
+                m_selected = true;
+            }
+
+            if (rightStep - leftStep > 1) {
+                m_label = QString::fromStdString(call->name);
+                m_step = left;
+                m_stepWidth = rightStep - leftStep;
+                heatDuration = dtds;
+                ++m_index;
+                break;
+            }
+
+            if (leftStep < m_step) {
+                qint64 rightTime = stepToTime(rightStep);
+                heatDuration += end - rightTime;
+
+                if (m_programSelection && call->program == m_programSel) {
+                    programHeatDuration += end - rightTime;
+                }
+            } else if (leftStep == rightStep) {
+                heatDuration += duration;
+
+                if (m_programSelection && call->program == m_programSel) {
+                    programHeatDuration += duration;
+                }
+            } else if (rightStep - leftStep == 1) {
+                qint64 rightTime = stepToTime(rightStep);
+                heatDuration += rightTime - start;
+
+                if (m_programSelection && call->program == m_programSel) {
+                    programHeatDuration += rightTime - start;
+                }
+
+                break;
+            }
+        }
+
+        m_heat = heatDuration / dtds;
+        m_programHeat = programHeatDuration / dtds;
+
+        if (m_timeSelection) {
+            qint64 time = stepToTime(m_step);
+
+            if (time >= m_timeSelStart && time <= m_timeSelEnd) {
+                m_programHeat = 1.0;
+            }
+        }
+
+        if (m_programSelection && (m_program == m_programSel || (m_selected && m_stepWidth > 1))) {
+            m_programHeat = 1.0;
+        }
+
+        if (m_programHeat > 0) {
+            m_selected = true;
+        }
+
+        return true;
+    }
+
+    virtual bool isGpu() const
+    {
+        return m_useGpu;
+    }
+
+    virtual float heat() const
+    {
+        return m_heat;
+    }
+
+    virtual float selectedHeat() const
+    {
+        return m_programHeat;
+    }
+
+    virtual int step() const
+    {
+        return m_step;
+    }
+
+    virtual int width() const
+    {
+        return m_stepWidth;
+    }
+
+    virtual QString label() const
+    {
+        return m_label;
+    }
+
+    void setProgramSelection(int program)
+    {
+        m_programSelection = true;
+        m_programSel = program;
+    }
+
+    void setTimeSelection(qint64 start, qint64 end)
+    {
+        m_timeSelection = true;
+        m_timeSelStart = start;
+        m_timeSelEnd = end;
+    }
+
+private:
+    double timeToStep(qint64 time) const
+    {
+        double pos = time;
+        pos -= m_timeStart;
+        pos /= m_timeWidth;
+        pos *= m_stepCount;
+        return pos;
+    }
+
+    qint64 stepToTime(int pos) const
+    {
+        double time = pos;
+        time /= m_stepCount;
+        time *= m_timeWidth;
+        time += m_timeStart;
+        return (qint64)time;
+    }
+
+private:
+    const trace::Profile* m_profile;
+
+    int m_step;
+    int m_stepWidth;
+    int m_stepCount;
+
+    unsigned m_index;
+
+    float m_heat;
+
+    qint64 m_timeStart;
+    qint64 m_timeEnd;
+    qint64 m_timeWidth;
+
+    bool m_useGpu;
+    int m_program;
+
+    QString m_label;
+
+    bool m_selected;
+
+    bool m_timeSelection;
+    qint64 m_timeSelStart;
+    qint64 m_timeSelEnd;
+
+    bool m_programSelection;
+    int m_programSel;
+
+    float m_programHeat;
+};
+
+class ProfileHeatmapDataProvider : public HeatmapDataProvider {
+protected:
+    enum SelectionType {
+        None,
+        Time,
+        Program
+    };
+
+public:
+    ProfileHeatmapDataProvider(trace::Profile* profile) :
+        m_profile(profile),
+        m_selectionState(NULL)
+    {
+        sortRows();
+    }
+
+    virtual qint64 start() const
+    {
+        return m_profile->frames.front().cpuStart;
+    }
+
+    virtual qint64 end() const
+    {
+        return m_profile->frames.back().cpuStart + m_profile->frames.back().cpuDuration;
+    }
+
+    virtual unsigned dataRows() const
+    {
+        return m_rowPrograms.size();
+    }
+
+    virtual QString dataLabel(unsigned row) const
+    {
+        if (row >= m_rowPrograms.size()) {
+            return QString();
+        } else {
+            return QString("%1").arg(m_rowPrograms[row]);
+        }
+    }
+
+    virtual qint64 dataRowAt(unsigned row) const
+    {
+        if (row >= m_rowPrograms.size()) {
+            return 0;
+        } else {
+            return m_rowPrograms[row];
+        }
+    }
+
+    virtual HeatmapRowIterator* dataRowIterator(int row, qint64 start, qint64 end, int steps) const
+    {
+        ProfileHeatmapRowIterator* itr = new ProfileHeatmapRowIterator(m_profile, start, end, steps, true, m_rowPrograms[row]);
+
+        if (m_selectionState) {
+            if (m_selectionState->type == SelectionState::Horizontal) {
+                itr->setTimeSelection(m_selectionState->start, m_selectionState->end);
+            } else if (m_selectionState->type == SelectionState::Vertical) {
+                itr->setProgramSelection(m_selectionState->start);
+            }
+        }
+
+        return itr;
+    }
+
+    virtual unsigned headerRows() const
+    {
+        return 2;
+    }
+
+    virtual qint64 headerRowAt(unsigned row) const
+    {
+        return row;
+    }
+
+    virtual QString headerLabel(unsigned row) const
+    {
+        if (row == 0) {
+            return "CPU";
+        } else if (row == 1) {
+            return "GPU";
+        } else {
+            return QString();
+        }
+    }
+
+    virtual HeatmapRowIterator* headerRowIterator(int row, qint64 start, qint64 end, int steps) const
+    {
+        ProfileHeatmapRowIterator* itr = new ProfileHeatmapRowIterator(m_profile, start, end, steps, row != 0);
+
+        if (m_selectionState) {
+            if (m_selectionState->type == SelectionState::Horizontal) {
+                itr->setTimeSelection(m_selectionState->start, m_selectionState->end);
+            } else if (m_selectionState->type == SelectionState::Vertical) {
+                itr->setProgramSelection(m_selectionState->start);
+            }
+        }
+
+        return itr;
+    }
+
+    virtual qint64 dataItemAt(unsigned row, qint64 time) const
+    {
+        if (row >= m_rowPrograms.size()) {
+            return -1;
+        }
+
+        unsigned program = m_rowPrograms[row];
+
+        std::vector<unsigned>::const_iterator item =
+                Profiling::binarySearchTimespanIndexed
+                    (m_profile->calls, m_profile->programs[program].calls.begin(), m_profile->programs[program].calls.end(), time);
+
+        if (item == m_profile->programs[program].calls.end()) {
+            return -1;
+        }
+
+        return *item;
+    }
+
+    virtual qint64 headerItemAt(unsigned row, qint64 time) const
+    {
+        if (row >= m_rowPrograms.size()) {
+            return -1;
+        }
+
+        if (row == 0) {
+            /* CPU */
+            std::vector<trace::Profile::Call>::const_iterator item =
+                    Profiling::binarySearchTimespan<trace::Profile::Call,
+                                        &trace::Profile::Call::cpuStart,
+                                        &trace::Profile::Call::cpuDuration>
+                    (m_profile->calls.begin(), m_profile->calls.end(), time);
+
+            if (item != m_profile->calls.end()) {
+                return item - m_profile->calls.begin();
+            }
+        } else if (row == 1) {
+            /* GPU */
+            for (unsigned i = 0; i < m_rowPrograms.size(); ++i) {
+                qint64 index = dataItemAt(i, time);
+
+                if (index != -1) {
+                    return index;
+                }
+            }
+        }
+
+        return -1;
+    }
+
+    virtual void itemDoubleClicked(qint64 index) const
+    {
+        if (index < 0 || index >= m_profile->calls.size()) {
+            return;
+        }
+
+        const trace::Profile::Call& call = m_profile->calls[index];
+        Profiling::jumpToCall(call.no);
+    }
+
+    virtual QString itemTooltip(qint64 index) const
+    {
+        if (index >= m_profile->calls.size()) {
+            return QString();
+        }
+
+        const trace::Profile::Call& call = m_profile->calls[index];
+
+        QString text;
+        text  = QString::fromStdString(call.name);
+
+        text += QString("\nCall: %1").arg(call.no);
+        text += QString("\nCPU Start: %1").arg(Profiling::getTimeString(call.cpuStart));
+        text += QString("\nCPU Duration: %1").arg(Profiling::getTimeString(call.cpuDuration));
+
+        if (call.pixels >= 0) {
+            text += QString("\nGPU Start: %1").arg(Profiling::getTimeString(call.gpuStart));
+            text += QString("\nGPU Duration: %1").arg(Profiling::getTimeString(call.gpuDuration));
+            text += QString("\nPixels Drawn: %1").arg(QLocale::system().toString((qlonglong)call.pixels));
+        }
+
+        return text;
+    }
+
+    virtual void setSelectionState(SelectionState* state)
+    {
+        m_selectionState = state;
+    }
+
+private:
+    void sortRows()
+    {
+        typedef QPair<quint64, unsigned> Pair;
+        std::vector<Pair> gpu;
+
+        /* Map shader to visible row */
+        for (std::vector<trace::Profile::Program>::const_iterator itr = m_profile->programs.begin(); itr != m_profile->programs.end(); ++itr) {
+            const trace::Profile::Program& program = *itr;
+            unsigned no = itr -  m_profile->programs.begin();
+
+            if (program.gpuTotal > 0) {
+                gpu.push_back(Pair(program.gpuTotal, no));
+            }
+        }
+
+        /* Sort the shaders by most used gpu */
+        qSort(gpu);
+
+        /* Create row order */
+        m_rowPrograms.clear();
+
+        for (std::vector<Pair>::const_reverse_iterator itr = gpu.rbegin(); itr != gpu.rend(); ++itr) {
+            m_rowPrograms.push_back(itr->second);
+        }
+    }
+
+protected:
+    trace::Profile* m_profile;
+    std::vector<int> m_rowPrograms;
+    SelectionState* m_selectionState;
+};
+
+#endif
diff --git a/gui/profiletablemodel.cpp b/gui/profiletablemodel.cpp
new file mode 100644 (file)
index 0000000..11a0d0c
--- /dev/null
@@ -0,0 +1,331 @@
+#include "profiletablemodel.h"
+#include "profiledialog.h"
+#include "profiling.h"
+
+#include <QLocale>
+
+typedef trace::Profile::Call Call;
+typedef trace::Profile::Frame Frame;
+typedef trace::Profile::Program Program;
+
+enum {
+    COLUMN_PROGRAM,
+    COLUMN_USAGES,
+    COLUMN_GPU_TIME,
+    COLUMN_CPU_TIME,
+    COLUMN_PIXELS_DRAWN,
+    COLUMN_GPU_AVERAGE,
+    COLUMN_CPU_AVERAGE,
+    COLUMN_PIXELS_AVERAGE,
+    MAX_COLUMN
+};
+
+static QString columnNames[] = {
+    QString("Program"),
+    QString("Calls"),
+    QString("Total GPU Time"),
+    QString("Total CPU Time"),
+    QString("Total Pixels Drawn"),
+    QString("Avg GPU Time"),
+    QString("Avg CPU Time"),
+    QString("Avg Pixels Drawn")
+};
+
+ProfileTableModel::ProfileTableModel(QObject *parent)
+    : QAbstractTableModel(parent),
+      m_profile(0),
+      m_sortColumn(COLUMN_GPU_TIME),
+      m_sortOrder(Qt::DescendingOrder)
+{
+}
+
+
+void ProfileTableModel::setProfile(trace::Profile* profile)
+{
+    m_profile = profile;
+    m_timeMin = m_profile->frames.front().cpuStart;
+    m_timeMax = m_profile->frames.back().cpuStart + m_profile->frames.back().cpuDuration;
+    updateModel();
+}
+
+
+/**
+ * Set selection to nothing
+ */
+void ProfileTableModel::selectNone()
+{
+    m_timeMin = m_timeMax = 0;
+    updateModel();
+    sort(m_sortColumn, m_sortOrder);
+}
+
+
+/**
+ * Set selection to program
+ */
+void ProfileTableModel::selectProgram(unsigned /*program*/)
+{
+    /* We have no program based selection for table */
+    selectNone();
+}
+
+
+/**
+ * Set selection to a period of time
+ */
+void ProfileTableModel::selectTime(int64_t start, int64_t end)
+{
+    m_timeMin = start;
+    m_timeMax = end;
+
+    updateModel();
+    sort(m_sortColumn, m_sortOrder);
+}
+
+
+/**
+ * Creates the row data from trace profile
+ */
+void ProfileTableModel::updateModel()
+{
+    if (m_timeMin == m_timeMax) {
+        m_timeMin = m_profile->frames.front().cpuStart;
+        m_timeMax = m_profile->frames.back().cpuStart + m_profile->frames.back().cpuDuration;
+    }
+
+    for (QList<ProfileTableRow>::iterator itr = m_rowData.begin(); itr != m_rowData.end(); ++itr) {
+        ProfileTableRow& row = *itr;
+
+        row.uses = 0;
+        row.pixels = 0;
+        row.gpuTime = 0;
+        row.cpuTime = 0;
+        row.longestCpu = NULL;
+        row.longestGpu = NULL;
+        row.longestPixel = NULL;
+    }
+
+    for (std::vector<Program>::const_iterator itr = m_profile->programs.begin(); itr != m_profile->programs.end(); ++itr) {
+        ProfileTableRow* row = NULL;
+        const Program& program = *itr;
+
+        for (std::vector<unsigned>::const_iterator jtr = program.calls.begin(); jtr != program.calls.end(); ++jtr) {
+            const Call& call = m_profile->calls[*jtr];
+
+            if (call.cpuStart > m_timeMax) {
+                break;
+            }
+
+            if (call.cpuStart + call.cpuDuration < m_timeMin) {
+                continue;
+            }
+
+            if (!row) {
+                row = getRow(itr - m_profile->programs.begin());
+            }
+
+            row->uses++;
+            row->pixels  += call.pixels;
+            row->gpuTime += call.gpuDuration;
+            row->cpuTime += call.cpuDuration;
+
+            if (!row->longestGpu || row->longestGpu->gpuDuration < call.gpuDuration) {
+                row->longestGpu = &call;
+            }
+
+            if (!row->longestCpu || row->longestCpu->cpuDuration < call.cpuDuration) {
+                row->longestCpu = &call;
+            }
+
+            if (!row->longestPixel || row->longestPixel->pixels < call.pixels) {
+                row->longestPixel = &call;
+            }
+        }
+    }
+}
+
+
+/**
+ * Get the appropriate call associated with an item in the table
+ */
+const trace::Profile::Call *ProfileTableModel::getJumpCall(const QModelIndex & index) const {
+    const ProfileTableRow& row = m_rowData[index.row()];
+
+    switch(index.column()) {
+    case COLUMN_GPU_TIME:
+    case COLUMN_GPU_AVERAGE:
+        return row.longestGpu;
+    case COLUMN_CPU_TIME:
+    case COLUMN_CPU_AVERAGE:
+        return row.longestCpu;
+    case COLUMN_PIXELS_DRAWN:
+    case COLUMN_PIXELS_AVERAGE:
+        return row.longestPixel;
+    }
+
+    return NULL;
+}
+
+
+/**
+ * Get the shader program associated with an item in the table
+ */
+unsigned ProfileTableModel::getProgram(const QModelIndex & index) const
+{
+    const ProfileTableRow& row = m_rowData[index.row()];
+    return row.program;
+}
+
+
+/**
+ * Get the row index for a shader program
+ */
+int ProfileTableModel::getRowIndex(unsigned program) const
+{
+    for (int i = 0; i < m_rowData.size(); ++i) {
+        if (m_rowData[i].program == program)
+            return i;
+    }
+
+    return -1;
+}
+
+
+/**
+ * Get the row data for a shader program
+ */
+ProfileTableRow* ProfileTableModel::getRow(unsigned program) {
+    for (QList<ProfileTableRow>::iterator itr = m_rowData.begin(); itr != m_rowData.end(); ++itr) {
+        if (itr->program == program)
+            return &*itr;
+    }
+
+    m_rowData.append(ProfileTableRow(program));
+    return &m_rowData.back();
+}
+
+
+int ProfileTableModel::rowCount(const QModelIndex & parent) const
+{
+    if (!parent.isValid()) {
+        return m_rowData.size();
+    } else {
+        return 0;
+    }
+}
+
+
+int ProfileTableModel::columnCount(const QModelIndex & /*parent*/) const
+{
+    return MAX_COLUMN;
+}
+
+
+QVariant ProfileTableModel::data(const QModelIndex &index, int role) const
+{
+    if (!index.isValid()) {
+        return QVariant();
+    }
+
+    if (role == Qt::DisplayRole) {
+        const ProfileTableRow& row = m_rowData[index.row()];
+
+        switch(index.column()) {
+        case COLUMN_PROGRAM:
+            return row.program;
+        case COLUMN_USAGES:
+            return QLocale::system().toString(row.uses);
+        case COLUMN_GPU_TIME:
+            return Profiling::getTimeString(row.gpuTime);
+        case COLUMN_CPU_TIME:
+            return Profiling::getTimeString(row.cpuTime);
+        case COLUMN_PIXELS_DRAWN:
+            return QLocale::system().toString((qlonglong)row.pixels);
+        case COLUMN_GPU_AVERAGE:
+            return Profiling::getTimeString((row.uses <= 0) ? 0 : (row.gpuTime / row.uses));
+        case COLUMN_CPU_AVERAGE:
+            return Profiling::getTimeString((row.uses <= 0) ? 0 : (row.cpuTime / row.uses));
+        case COLUMN_PIXELS_AVERAGE:
+            return QLocale::system().toString((row.uses <= 0) ? 0 : (row.pixels / row.uses));
+        }
+    } else if (role == Qt::TextAlignmentRole) {
+        return Qt::AlignRight;
+    }
+
+    return QVariant();
+}
+
+
+QVariant ProfileTableModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+    if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+        if (section >= 0 && section < MAX_COLUMN) {
+            return columnNames[section];
+        }
+    }
+
+    return QVariant();
+}
+
+
+class ProgramSorter {
+public:
+    ProgramSorter(int column, Qt::SortOrder order)
+        : mSortColumn(column),
+          mSortOrder(order)
+    {
+    }
+
+    bool operator()(const ProfileTableRow &p1, const ProfileTableRow &p2) const
+    {
+        bool result = true;
+
+        switch(mSortColumn) {
+        case COLUMN_PROGRAM:
+            result = p1.program < p2.program;
+            break;
+        case COLUMN_USAGES:
+            result = p1.uses < p2.uses;
+            break;
+        case COLUMN_GPU_TIME:
+            result = p1.gpuTime < p2.gpuTime;
+            break;
+        case COLUMN_CPU_TIME:
+            result = p1.cpuTime < p2.cpuTime;
+            break;
+        case COLUMN_PIXELS_DRAWN:
+            result = p1.pixels < p2.pixels;
+            break;
+        case COLUMN_GPU_AVERAGE:
+            result = ((p1.uses <= 0) ? 0 : (p1.gpuTime / p1.uses)) < ((p2.uses <= 0) ? 0 : (p2.gpuTime / p2.uses));
+            break;
+        case COLUMN_CPU_AVERAGE:
+            result = ((p1.uses <= 0) ? 0 : (p1.cpuTime / p1.uses)) < ((p2.uses <= 0) ? 0 : (p2.cpuTime / p2.uses));
+            break;
+        case COLUMN_PIXELS_AVERAGE:
+            result = ((p1.uses <= 0) ? 0 : (p1.pixels / p1.uses)) < ((p2.uses <= 0) ? 0 : (p2.pixels / p2.uses));
+            break;
+        }
+
+        if (mSortOrder == Qt::DescendingOrder) {
+            return !result;
+        } else {
+            return result;
+        }
+    }
+
+private:
+    int mSortColumn;
+    Qt::SortOrder mSortOrder;
+};
+
+
+void ProfileTableModel::sort(int column, Qt::SortOrder order) {
+    m_sortColumn = column;
+    m_sortOrder = order;
+    qSort(m_rowData.begin(), m_rowData.end(), ProgramSorter(column, order));
+    emit dataChanged(createIndex(0, 0), createIndex(m_rowData.size(), MAX_COLUMN));
+}
+
+
+#include "profiletablemodel.moc"
diff --git a/gui/profiletablemodel.h b/gui/profiletablemodel.h
new file mode 100644 (file)
index 0000000..da17550
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef PROFILETABLEMODEL_H
+#define PROFILETABLEMODEL_H
+
+#include <QAbstractTableModel>
+#include "trace_profiler.hpp"
+
+struct ProfileTableRow
+{
+    ProfileTableRow(unsigned no)
+        : program(no),
+          uses(0),
+          gpuTime(0),
+          cpuTime(0),
+          pixels(0),
+          longestGpu(0),
+          longestCpu(0),
+          longestPixel(0)
+    {
+    }
+
+    unsigned program;
+    qulonglong uses;
+    qulonglong gpuTime;
+    qulonglong cpuTime;
+    qulonglong pixels;
+
+    const trace::Profile::Call* longestGpu;
+    const trace::Profile::Call* longestCpu;
+    const trace::Profile::Call* longestPixel;
+};
+
+class ProfileTableModel : public QAbstractTableModel
+{
+    Q_OBJECT
+
+public:
+    ProfileTableModel(QObject *parent = NULL);
+
+    void setProfile(trace::Profile* profile);
+
+    void selectNone();
+    void selectProgram(unsigned program);
+    void selectTime(int64_t start, int64_t end);
+
+    int getRowIndex(unsigned program) const;
+    unsigned getProgram(const QModelIndex & index) const;
+    const trace::Profile::Call* getJumpCall(const QModelIndex & index) const;
+
+    virtual int rowCount(const QModelIndex & parent) const;
+    virtual int columnCount(const QModelIndex & parent) const;
+
+    virtual QVariant data(const QModelIndex &index, int role) const;
+    virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+    virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+private:
+    void updateModel();
+    ProfileTableRow* getRow(unsigned program);
+
+private:
+    QList<ProfileTableRow> m_rowData;
+    trace::Profile *m_profile;
+    int64_t m_timeMin;
+    int64_t m_timeMax;
+    int m_sortColumn;
+    Qt::SortOrder m_sortOrder;
+};
+
+#endif // PROFILEMODEL_H
diff --git a/gui/profiling.h b/gui/profiling.h
new file mode 100644 (file)
index 0000000..a5b1266
--- /dev/null
@@ -0,0 +1,128 @@
+#ifndef PROFILING_H
+#define PROFILING_H
+
+#include <QString>
+#include <QLocale>
+#include "trace_profiler.hpp"
+
+class Profiling {
+public:
+    /**
+     * Select and show the call in main window.
+     */
+    static void jumpToCall(int index);
+
+    /**
+     * Convert a CPU / GPU time to a textual representation.
+     * This includes automatic unit selection.
+     */
+    static QString getTimeString(int64_t time, int64_t unitTime = 0)
+    {
+        QString text;
+        QString unit = " ns";
+        double unitScale = 1;
+
+        if (unitTime == 0) {
+            unitTime = time;
+        }
+
+        if (unitTime >= 60e9) {
+            int64_t mins = time / 60e9;
+            text += QString("%1 m ").arg(mins);
+
+            time -= mins * 60e9;
+            unit = " s";
+            unitScale = 1e9;
+        } else if (unitTime >= 1e9) {
+            unit = " s";
+            unitScale = 1e9;
+        } else if (unitTime >= 1e6) {
+            unit = " ms";
+            unitScale = 1e6;
+        } else if (unitTime >= 1e3) {
+            unit = QString::fromUtf8(" µs");
+            unitScale = 1e3;
+        }
+
+        /* 3 decimal places */
+        text += QString("%1").arg(time / unitScale, 0, 'f', 3);
+
+        /* Remove trailing 0 */
+        while(text.endsWith('0'))
+            text.truncate(text.length() - 1);
+
+        /* Remove trailing decimal point */
+        if (text.endsWith(QLocale::system().decimalPoint()))
+            text.truncate(text.length() - 1);
+
+        return text + unit;
+    }
+
+    template<typename val_ty, int64_t val_ty::* mem_ptr_start, int64_t val_ty::* mem_ptr_dura>
+    static typename std::vector<val_ty>::const_iterator binarySearchTimespan(
+            typename std::vector<val_ty>::const_iterator begin,
+            typename std::vector<val_ty>::const_iterator end,
+            int64_t time,
+            bool nearest = false)
+    {
+        int lower = 0;
+        int upper = end - begin;
+        int pos = (lower + upper) / 2;
+        typename std::vector<val_ty>::const_iterator itr = begin + pos;
+
+        while (!((*itr).*mem_ptr_start <= time && (*itr).*mem_ptr_start + (*itr).*mem_ptr_dura > time) && (lower <= upper)) {
+            if ((*itr).*mem_ptr_start > time) {
+                upper = pos - 1;
+            } else {
+                lower = pos + 1;
+            }
+
+            pos = (lower + upper) / 2;
+            itr = begin + pos;
+        }
+
+        if (nearest || lower <= upper) {
+            return itr;
+        } else {
+            return end;
+        }
+    }
+
+    static std::vector<unsigned>::const_iterator binarySearchTimespanIndexed(
+            const std::vector<trace::Profile::Call>& calls,
+            std::vector<unsigned>::const_iterator begin,
+            std::vector<unsigned>::const_iterator end,
+            int64_t time,
+            bool nearest = false)
+    {
+        int lower = 0;
+        int upper = end - begin - 1;
+        int pos = (lower + upper) / 2;
+        std::vector<unsigned>::const_iterator itr = begin + pos;
+
+        while (lower <= upper) {
+            const trace::Profile::Call& call = calls[*itr];
+
+            if (call.gpuStart <= time && call.gpuStart + call.gpuDuration > time) {
+                break;
+            }
+
+            if (call.gpuStart > time) {
+                upper = pos - 1;
+            } else {
+                lower = pos + 1;
+            }
+
+            pos = (lower + upper) / 2;
+            itr = begin + pos;
+        }
+
+        if (nearest || lower <= upper) {
+            return itr;
+        } else {
+            return end;
+        }
+    }
+};
+
+#endif
index 17ac14d7d8d13a97da4f2e1a61455770e9b1104d..592c1a4215d66bf947294236c953bf71beb00d1a 100644 (file)
 #include "retracer.h"
 
 #include "apitracecall.h"
+#include "thumbnail.h"
+
+#include "image.hpp"
+
+#include "trace_profiler.hpp"
 
 #include <QDebug>
 #include <QVariant>
+#include <QList>
+#include <QImage>
 
 #include <qjson/parser.h>
 
+/**
+ * Wrapper around a QProcess which enforces IO to block .
+ *
+ * Several QIODevice users (notably QJSON) expect blocking semantics, e.g.,
+ * they expect that QIODevice::read() will blocked until the requested ammount
+ * of bytes is read or end of file is reached. But by default QProcess, does
+ * not block.  And passing QIODevice::Unbuffered mitigates but does not fully
+ * address the problem either.
+ *
+ * This class wraps around QProcess, providing QIODevice interface, while
+ * ensuring that all reads block.
+ *
+ * This class also works around a bug in QProcess::atEnd() implementation.
+ *
+ * See also:
+ * - http://qt-project.org/wiki/Simple_Crypt_IO_Device
+ * - http://qt-project.org/wiki/Custom_IO_Device
+ */
+class BlockingIODevice : public QIODevice
+{
+    /* We don't use the Q_OBJECT in this class given we don't declare any
+     * signals and slots or use any other services provided by Qt's meta-object
+     * system. */
+public:
+    BlockingIODevice(QProcess * io);
+    bool isSequential() const;
+    bool atEnd() const;
+    bool waitForReadyRead(int msecs = -1);
+
+protected:
+    qint64 readData(char * data, qint64 maxSize);
+    qint64 writeData(const char * data, qint64 maxSize);
+
+private:
+    QProcess *m_device;
+};
+
+BlockingIODevice::BlockingIODevice(QProcess * io) :
+    m_device(io)
+{
+    /*
+     * We pass QIODevice::Unbuffered to prevent the base QIODevice class to do
+     * its own buffering on top of the overridden readData() method.
+     *
+     * The only buffering used will be to satisfy QIODevice::peek() and
+     * QIODevice::ungetChar().
+     */
+    setOpenMode(ReadOnly | Unbuffered);
+}
+
+bool BlockingIODevice::isSequential() const
+{
+    return true;
+}
+
+bool BlockingIODevice::atEnd() const
+{
+    /*
+     * XXX: QProcess::atEnd() documentation is wrong -- it will return true
+     * even when the process is running --, so we try to workaround that here.
+     */
+    if (m_device->atEnd()) {
+        if (m_device->state() == QProcess::Running) {
+            if (!m_device->waitForReadyRead(-1)) {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+bool BlockingIODevice::waitForReadyRead(int msecs)
+{
+    Q_UNUSED(msecs);
+    return true;
+}
+
+qint64 BlockingIODevice::readData(char * data, qint64 maxSize)
+{
+    qint64 bytesToRead = maxSize;
+    qint64 readSoFar = 0;
+    do {
+        qint64 chunkSize = m_device->read(data + readSoFar, bytesToRead);
+        if (chunkSize < 0) {
+            if (readSoFar) {
+                return readSoFar;
+            } else {
+                return chunkSize;
+            }
+        }
+        Q_ASSERT(chunkSize <= bytesToRead);
+        bytesToRead -= chunkSize;
+        readSoFar += chunkSize;
+        if (bytesToRead) {
+            if (!m_device->waitForReadyRead(-1)) {
+                qDebug() << "waitForReadyRead failed\n";
+                break;
+            }
+        }
+    } while(bytesToRead);
+
+    return readSoFar;
+}
+
+qint64 BlockingIODevice::writeData(const char * data, qint64 maxSize)
+{
+    Q_ASSERT(false);
+    return -1;
+}
+
+Q_DECLARE_METATYPE(QList<ApiTraceError>);
+
 Retracer::Retracer(QObject *parent)
     : QThread(parent),
       m_benchmarking(false),
       m_doubleBuffered(true),
       m_captureState(false),
-      m_captureCall(0)
+      m_captureCall(0),
+      m_profileGpu(false),
+      m_profileCpu(false),
+      m_profilePixels(false)
 {
+    qRegisterMetaType<QList<ApiTraceError> >();
+
 #ifdef Q_OS_WIN
     QString format = QLatin1String("%1;");
 #else
@@ -63,6 +187,33 @@ void Retracer::setDoubleBuffered(bool db)
     m_doubleBuffered = db;
 }
 
+bool Retracer::isProfilingGpu() const
+{
+    return m_profileGpu;
+}
+
+bool Retracer::isProfilingCpu() const
+{
+    return m_profileCpu;
+}
+
+bool Retracer::isProfilingPixels() const
+{
+    return m_profilePixels;
+}
+
+bool Retracer::isProfiling() const
+{
+    return m_profileGpu || m_profileCpu || m_profilePixels;
+}
+
+void Retracer::setProfiling(bool gpu, bool cpu, bool pixels)
+{
+    m_profileGpu = gpu;
+    m_profileCpu = cpu;
+    m_profilePixels = pixels;
+}
+
 void Retracer::setCaptureAtCallNumber(qlonglong num)
 {
     m_captureCall = num;
@@ -83,69 +234,83 @@ void Retracer::setCaptureState(bool enable)
     m_captureState = enable;
 }
 
-
-void Retracer::run()
+bool Retracer::captureThumbnails() const
 {
-    RetraceProcess *retrace = new RetraceProcess();
-    retrace->process()->setProcessEnvironment(m_processEnvironment);
-
-    retrace->setFileName(m_fileName);
-    retrace->setAPI(m_api);
-    retrace->setBenchmarking(m_benchmarking);
-    retrace->setDoubleBuffered(m_doubleBuffered);
-    retrace->setCaptureState(m_captureState);
-    retrace->setCaptureAtCallNumber(m_captureCall);
-
-    connect(retrace, SIGNAL(finished(const QString&)),
-            this, SLOT(cleanup()));
-    connect(retrace, SIGNAL(error(const QString&)),
-            this, SLOT(cleanup()));
-    connect(retrace, SIGNAL(finished(const QString&)),
-            this, SIGNAL(finished(const QString&)));
-    connect(retrace, SIGNAL(error(const QString&)),
-            this, SIGNAL(error(const QString&)));
-    connect(retrace, SIGNAL(foundState(ApiTraceState*)),
-            this, SIGNAL(foundState(ApiTraceState*)));
-    connect(retrace, SIGNAL(retraceErrors(const QList<ApiTraceError>&)),
-            this, SIGNAL(retraceErrors(const QList<ApiTraceError>&)));
-
-    retrace->start();
-
-    exec();
-
-    /* means we need to kill the process */
-    if (retrace->process()->state() != QProcess::NotRunning) {
-        retrace->terminate();
-    }
-
-    delete retrace;
+    return m_captureThumbnails;
 }
 
+void Retracer::setCaptureThumbnails(bool enable)
+{
+    m_captureThumbnails = enable;
+}
 
-void RetraceProcess::start()
+/**
+ * Starting point for the retracing thread.
+ *
+ * Overrides QThread::run().
+ */
+void Retracer::run()
 {
+    QString msg = QLatin1String("Replay finished!");
+
+    /*
+     * Construct command line
+     */
+
     QString prog;
     QStringList arguments;
 
-    if (m_api == trace::API_GL) {
+    switch (m_api) {
+    case trace::API_GL:
         prog = QLatin1String("glretrace");
-    } else if (m_api == trace::API_EGL) {
+        break;
+    case trace::API_EGL:
         prog = QLatin1String("eglretrace");
-    } else {
-        assert(0);
+        break;
+    case trace::API_DX:
+    case trace::API_D3D7:
+    case trace::API_D3D8:
+    case trace::API_D3D9:
+    case trace::API_D3D10:
+    case trace::API_D3D10_1:
+    case trace::API_D3D11:
+#ifdef Q_OS_WIN
+        prog = QLatin1String("d3dretrace");
+#else
+        prog = QLatin1String("wine");
+        arguments << QLatin1String("d3dretrace.exe");
+#endif
+        break;
+    default:
+        emit finished(QLatin1String("Unsupported API"));
         return;
     }
 
-    if (m_doubleBuffered) {
-        arguments << QLatin1String("-db");
-    } else {
-        arguments << QLatin1String("-sb");
-    }
-
     if (m_captureState) {
         arguments << QLatin1String("-D");
         arguments << QString::number(m_captureCall);
+    } else if (m_captureThumbnails) {
+        arguments << QLatin1String("-s"); // emit snapshots
+        arguments << QLatin1String("-"); // emit to stdout
+    } else if (isProfiling()) {
+        if (m_profileGpu) {
+            arguments << QLatin1String("-pgpu");
+        }
+
+        if (m_profileCpu) {
+            arguments << QLatin1String("-pcpu");
+        }
+
+        if (m_profilePixels) {
+            arguments << QLatin1String("-ppd");
+        }
     } else {
+        if (m_doubleBuffered) {
+            arguments << QLatin1String("-db");
+        } else {
+            arguments << QLatin1String("-sb");
+        }
+
         if (m_benchmarking) {
             arguments << QLatin1String("-b");
         }
@@ -153,164 +318,187 @@ void RetraceProcess::start()
 
     arguments << m_fileName;
 
-    m_process->start(prog, arguments);
-}
-
-
-void RetraceProcess::replayFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
-    QByteArray output = m_process->readAllStandardOutput();
-    QString msg;
-    QString errStr = m_process->readAllStandardError();
-
-#if 0
-    qDebug()<<"Process finished = ";
-    qDebug()<<"\terr = "<<errStr;
-    qDebug()<<"\tout = "<<output;
-#endif
+    /*
+     * Start the process.
+     */
 
-    if (exitStatus != QProcess::NormalExit) {
-        msg = QLatin1String("Process crashed");
-    } else if (exitCode != 0) {
-        msg = QLatin1String("Process exited with non zero exit code");
-    } else {
-        if (m_captureState) {
-            bool ok = false;
-            QVariantMap parsedJson = m_jsonParser->parse(output, &ok).toMap();
-            ApiTraceState *state = new ApiTraceState(parsedJson);
-            emit foundState(state);
-            msg = tr("State fetched.");
-        } else {
-            msg = QString::fromUtf8(output);
-        }
-    }
+    QProcess process;
 
-    QStringList errorLines = errStr.split('\n');
-    QList<ApiTraceError> errors;
-    QRegExp regexp("(^\\d+): +(\\b\\w+\\b): (.+$)");
-    foreach(QString line, errorLines) {
-        if (regexp.indexIn(line) != -1) {
-            ApiTraceError error;
-            error.callIndex = regexp.cap(1).toInt();
-            error.type = regexp.cap(2);
-            error.message = regexp.cap(3);
-            errors.append(error);
-        }
-    }
-    if (!errors.isEmpty()) {
-        emit retraceErrors(errors);
+    process.start(prog, arguments, QIODevice::ReadOnly);
+    if (!process.waitForStarted(-1)) {
+        emit finished(QLatin1String("Could not start process"));
+        return;
     }
-    emit finished(msg);
-}
 
-void RetraceProcess::replayError(QProcess::ProcessError err)
-{
     /*
-     * XXX: this function is likely unnecessary and should be eliminated given
-     * that replayFinished is always called, even on errors.
+     * Process standard output
      */
 
+    QList<QImage> thumbnails;
+    QVariantMap parsedJson;
+    trace::Profile* profile = NULL;
+
+    process.setReadChannel(QProcess::StandardOutput);
+    if (process.waitForReadyRead(-1)) {
+        BlockingIODevice io(&process);
+
+        if (m_captureState) {
+            /*
+             * Parse JSON from the output.
+             *
+             * XXX: QJSON's scanner is inneficient as it abuses single
+             * character QIODevice::peek (not cheap), instead of maintaining a
+             * lookahead character on its own.
+             */
+
+            bool ok = false;
+            QJson::Parser jsonParser;
 #if 0
-    qDebug()<<"Process error = "<<err;
-    qDebug()<<"\terr = "<<m_process->readAllStandardError();
-    qDebug()<<"\tout = "<<m_process->readAllStandardOutput();
+            parsedJson = jsonParser.parse(&io, &ok).toMap();
+#else
+            /*
+             * XXX: QJSON expects blocking IO, and it looks like
+             * BlockingIODevice does not work reliably in all cases.
+             */
+            process.waitForFinished(-1);
+            parsedJson = jsonParser.parse(&process, &ok).toMap();
 #endif
+            if (!ok) {
+                msg = QLatin1String("failed to parse JSON");
+            }
+        } else if (m_captureThumbnails) {
+            /*
+             * Parse concatenated PNM images from output.
+             */
 
-    emit error(
-        tr("Couldn't execute the replay file '%1'").arg(m_fileName));
-}
+            while (!io.atEnd()) {
+                unsigned channels = 0;
+                unsigned width = 0;
+                unsigned height = 0;
 
-Q_DECLARE_METATYPE(QList<ApiTraceError>);
-RetraceProcess::RetraceProcess(QObject *parent)
-    : QObject(parent)
-{
-    m_process = new QProcess(this);
-    m_jsonParser = new QJson::Parser();
+                char header[512];
+                qint64 headerSize = 0;
+                int headerLines = 3; // assume no optional comment line
 
-    qRegisterMetaType<QList<ApiTraceError> >();
+                for (int headerLine = 0; headerLine < headerLines; ++headerLine) {
+                    qint64 headerRead = io.readLine(&header[headerSize], sizeof(header) - headerSize);
 
-    connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
-            this, SLOT(replayFinished(int, QProcess::ExitStatus)));
-    connect(m_process, SIGNAL(error(QProcess::ProcessError)),
-            this, SLOT(replayError(QProcess::ProcessError)));
-}
+                    // if header actually contains optional comment line, ...
+                    if (headerLine == 1 && header[headerSize] == '#') {
+                        ++headerLines;
+                    }
 
-QProcess * RetraceProcess::process() const
-{
-    return m_process;
-}
+                    headerSize += headerRead;
+                }
 
-QString RetraceProcess::fileName() const
-{
-    return m_fileName;
-}
+                const char *headerEnd = image::readPNMHeader(header, headerSize, &channels, &width, &height);
 
-void RetraceProcess::setFileName(const QString &name)
-{
-    m_fileName = name;
-}
+                // if invalid PNM header was encountered, ...
+                if (header == headerEnd) {
+                    qDebug() << "error: invalid snapshot stream encountered";
+                    break;
+                }
 
-void RetraceProcess::setAPI(trace::API api)
-{
-    m_api = api;
-}
+                // qDebug() << "channels: " << channels << ", width: " << width << ", height: " << height";
 
-bool RetraceProcess::isBenchmarking() const
-{
-    return m_benchmarking;
-}
+                QImage snapshot = QImage(width, height, channels == 1 ? QImage::Format_Mono : QImage::Format_RGB888);
 
-void RetraceProcess::setBenchmarking(bool bench)
-{
-    m_benchmarking = bench;
-}
+                int rowBytes = channels * width;
+                for (int y = 0; y < height; ++y) {
+                    unsigned char *scanLine = snapshot.scanLine(y);
+                    qint64 readBytes = io.read((char *) scanLine, rowBytes);
+                    Q_ASSERT(readBytes == rowBytes);
+                }
 
-bool RetraceProcess::isDoubleBuffered() const
-{
-    return m_doubleBuffered;
-}
+                QImage thumb = thumbnail(snapshot);
+                thumbnails.append(thumb);
+            }
 
-void RetraceProcess::setDoubleBuffered(bool db)
-{
-    m_doubleBuffered = db;
-}
+            Q_ASSERT(process.state() != QProcess::Running);
+        } else if (isProfiling()) {
+            profile = new trace::Profile();
 
-void RetraceProcess::setCaptureAtCallNumber(qlonglong num)
-{
-    m_captureCall = num;
-}
+            while (!io.atEnd()) {
+                char line[256];
+                qint64 lineLength;
 
-qlonglong RetraceProcess::captureAtCallNumber() const
-{
-    return m_captureCall;
-}
+                lineLength = io.readLine(line, 256);
 
-bool RetraceProcess::captureState() const
-{
-    return m_captureState;
-}
+                if (lineLength == -1)
+                    break;
 
-void RetraceProcess::setCaptureState(bool enable)
-{
-    m_captureState = enable;
-}
+                trace::Profiler::parseLine(line, profile);
+            }
+        } else {
+            QByteArray output;
+            output = process.readAllStandardOutput();
+            if (output.length() < 80) {
+                msg = QString::fromUtf8(output);
+            }
+        }
+    }
 
-void RetraceProcess::terminate()
-{
-    if (m_process) {
-        m_process->terminate();
-        emit finished(tr("Process terminated."));
+    /*
+     * Wait for process termination
+     */
+
+    process.waitForFinished(-1);
+
+    if (process.exitStatus() != QProcess::NormalExit) {
+        msg = QLatin1String("Process crashed");
+    } else if (process.exitCode() != 0) {
+        msg = QLatin1String("Process exited with non zero exit code");
     }
-}
 
-void Retracer::cleanup()
-{
-    quit();
-}
+    /*
+     * Parse errors.
+     */
 
-RetraceProcess::~RetraceProcess()
-{
-    delete m_jsonParser;
+    QList<ApiTraceError> errors;
+    process.setReadChannel(QProcess::StandardError);
+    QRegExp regexp("(^\\d+): +(\\b\\w+\\b): ([^\\r\\n]+)[\\r\\n]*$");
+    while (!process.atEnd()) {
+        QString line = process.readLine();
+        if (regexp.indexIn(line) != -1) {
+            ApiTraceError error;
+            error.callIndex = regexp.cap(1).toInt();
+            error.type = regexp.cap(2);
+            error.message = regexp.cap(3);
+            errors.append(error);
+        } else if (!errors.isEmpty()) {
+            // Probably a multiligne message
+            ApiTraceError &previous = errors.last();
+            if (line.endsWith("\n")) {
+                line.chop(1);
+            }
+            previous.message.append('\n');
+            previous.message.append(line);
+        }
+    }
+
+    /*
+     * Emit signals
+     */
+
+    if (m_captureState) {
+        ApiTraceState *state = new ApiTraceState(parsedJson);
+        emit foundState(state);
+        msg = QLatin1String("State fetched.");
+    }
+
+    if (m_captureThumbnails && !thumbnails.isEmpty()) {
+        emit foundThumbnails(thumbnails);
+    }
+
+    if (isProfiling() && profile) {
+        emit foundProfile(profile);
+    }
+
+    if (!errors.isEmpty()) {
+        emit retraceErrors(errors);
+    }
+
+    emit finished(msg);
 }
 
 #include "retracer.moc"
index e5c391bcb23e91a7b5169601910589dac3d54770..e889d8887cf3753ce609d86daefa6233d7134ddf 100644 (file)
@@ -8,63 +8,8 @@
 #include <QProcess>
 
 class ApiTraceState;
-namespace QJson {
-    class Parser;
-}
 
-/* internal class used by the retracer to run
- * in the thread */
-class RetraceProcess : public QObject
-{
-    Q_OBJECT
-public:
-    RetraceProcess(QObject *parent=0);
-    ~RetraceProcess();
-
-    QProcess *process() const;
-
-    QString fileName() const;
-    void setFileName(const QString &name);
-
-    void setAPI(trace::API api);
-
-    bool isBenchmarking() const;
-    void setBenchmarking(bool bench);
-
-    bool isDoubleBuffered() const;
-    void setDoubleBuffered(bool db);
-
-    void setCaptureAtCallNumber(qlonglong num);
-    qlonglong captureAtCallNumber() const;
-
-    bool captureState() const;
-    void setCaptureState(bool enable);
-
-public slots:
-    void start();
-    void terminate();
-
-signals:
-    void finished(const QString &output);
-    void error(const QString &msg);
-    void foundState(ApiTraceState *state);
-    void retraceErrors(const QList<ApiTraceError> &errors);
-
-private slots:
-    void replayFinished(int exitCode, QProcess::ExitStatus exitStatus);
-    void replayError(QProcess::ProcessError err);
-
-private:
-    QString m_fileName;
-    trace::API m_api;
-    bool m_benchmarking;
-    bool m_doubleBuffered;
-    bool m_captureState;
-    qlonglong m_captureCall;
-
-    QProcess *m_process;
-    QJson::Parser *m_jsonParser;
-};
+namespace trace { struct Profile; }
 
 class Retracer : public QThread
 {
@@ -83,30 +28,43 @@ public:
     bool isDoubleBuffered() const;
     void setDoubleBuffered(bool db);
 
+    bool isProfilingGpu() const;
+    bool isProfilingCpu() const;
+    bool isProfilingPixels() const;
+    bool isProfiling() const;
+    void setProfiling(bool gpu, bool cpu, bool pixels);
+
     void setCaptureAtCallNumber(qlonglong num);
     qlonglong captureAtCallNumber() const;
 
     bool captureState() const;
     void setCaptureState(bool enable);
 
+    bool captureThumbnails() const;
+    void setCaptureThumbnails(bool enable);
+
 signals:
     void finished(const QString &output);
     void foundState(ApiTraceState *state);
+    void foundProfile(trace::Profile *profile);
+    void foundThumbnails(const QList<QImage> &thumbnails);
     void error(const QString &msg);
     void retraceErrors(const QList<ApiTraceError> &errors);
 
 protected:
     virtual void run();
 
-private slots:
-    void cleanup();
 private:
     QString m_fileName;
     trace::API m_api;
     bool m_benchmarking;
     bool m_doubleBuffered;
     bool m_captureState;
+    bool m_captureThumbnails;
     qlonglong m_captureCall;
+    bool m_profileGpu;
+    bool m_profileCpu;
+    bool m_profilePixels;
 
     QProcessEnvironment m_processEnvironment;
 };
index 54ef5d24a82840b85d2d4bbf42e5e0f5df8304b1..4ad83c5876c5caf1267d80cc8c8029bdc18b7c93 100644 (file)
@@ -189,11 +189,7 @@ writeValue(trace::Writer &writer, const QVariant &var, unsigned &id)
             deleteStructSig(str);
         } else if (type == pointerType) {
             ApiPointer apiPtr = var.value<ApiPointer>();
-            //writer.beginArray(1);
-            //writer.beginElement();
-            writer.writeOpaque((const void*)apiPtr.value());
-            //writer.endElement();
-            //writer.endArray();
+            writer.writePointer(apiPtr.value());
         } else if (type == enumType) {
             ApiEnum apiEnum = var.value<ApiEnum>();
             trace::EnumSig *sig = createEnumSig(apiEnum, ++id);
@@ -251,7 +247,10 @@ public:
     virtual void visit(trace::String *node)
     {
         QString str = m_variant.toString();
-        m_editedValue = new trace::String(str.toLocal8Bit().constData());
+        char *newString = new char[str.length() + 1];
+        QByteArray ba = str.toLocal8Bit();
+        strcpy(newString, ba.constData());
+        m_editedValue = new trace::String(newString);
     }
 
     virtual void visit(trace::Enum *e)
@@ -277,7 +276,6 @@ public:
         trace::Array *newArray = new trace::Array(vals.count());
         for (int i = 0; i < vals.count(); ++i) {
             EditVisitor visitor(vals[i]);
-
             array->values[i]->visit(visitor);
             if (array->values[i] == visitor.value()) {
                 //non-editabled
@@ -286,7 +284,7 @@ public:
                 return;
             }
 
-            newArray->values.push_back(visitor.value());
+            newArray->values[i] = visitor.value();
         }
         m_editedValue = newArray;
     }
index 42d8d83fff1e30c827cb2bc684382445ff6e043e..c44b10740ec97d9f4e631b4acfd23ad7b27f6970 100644 (file)
@@ -145,15 +145,4 @@ void SettingsDialog::setFilterModel(ApiTraceFilter *filter)
     filtersFromModel(m_filter);
 }
 
-void SettingsDialog::setAPI(trace::API api)
-{
-    apiComboBox->setCurrentIndex(static_cast<int>(api));
-}
-
-trace::API SettingsDialog::getAPI(void)
-{
-    return static_cast<trace::API>(apiComboBox->currentIndex());
-
-}
-
 #include "settingsdialog.moc"
index 768398220a60282ed185619f2a573b23f0ea5b71..b676b9df643c1376a6873c5e263d83f6a68dcfdc 100644 (file)
@@ -16,8 +16,6 @@ public:
     void accept();
 
     void setFilterModel(ApiTraceFilter *filter);
-    void setAPI(trace::API api);
-    trace::API getAPI(void);
 private slots:
     void changeRegexp(const QString &name);
     void regexpChanged(const QString &pattern);
diff --git a/gui/thumbnail.h b/gui/thumbnail.h
new file mode 100644 (file)
index 0000000..2315564
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef THUMBNAIL_H
+#define THUMBNAIL_H
+
+#define THUMBNAIL_SIZE 64
+
+#include <QImage>
+
+inline QImage
+thumbnail(const QImage &image, Qt::TransformationMode transformationMode = Qt::FastTransformation) {
+    return image.scaled(THUMBNAIL_SIZE, THUMBNAIL_SIZE, Qt::KeepAspectRatio, transformationMode);
+}
+
+#endif
index bed517368ff243c147774b3f254ddd1e25b0e86f..fcfdf4661241ff30858f0f5332d83fbd30bcc126 100644 (file)
@@ -9,10 +9,27 @@ TraceDialog::TraceDialog(QWidget *parent)
 {
     setupUi(this);
 
+    apiComboBox->addItem("GL");
+#ifdef Q_OS_WIN
+    apiComboBox->addItem("D3D7");
+    apiComboBox->addItem("D3D8");
+    apiComboBox->addItem("D3D9");
+    apiComboBox->addItem("D3D10");
+    apiComboBox->addItem("D3D10_1");
+    apiComboBox->addItem("D3D11");
+#else
+    apiComboBox->addItem("EGL");
+#endif
+
     connect(browseButton, SIGNAL(clicked()),
             this, SLOT(browse()));
 }
 
+QString TraceDialog::api() const
+{
+    return apiComboBox->currentText().toLower();
+}
+
 QString TraceDialog::applicationPath() const
 {
     return applicationEdit->text();
index d5e502ddc60d8279b65930ef4a745c847162ff91..0ebe13ad7bc30a54cadafc414013c72f3cfb0b1a 100644 (file)
@@ -12,6 +12,7 @@ public:
 
     void accept();
 
+    QString api() const;
     QString applicationPath() const;
     QStringList arguments() const;
 
index 7cb07f00aa1331e814c6d7025deffe76498a36fc..2ad32b1fb4d73523dc4219650ee5ac6cd93a85d6 100644 (file)
@@ -20,8 +20,7 @@ apiCallFromTraceCall(const trace::Call *call,
 }
 
 TraceLoader::TraceLoader(QObject *parent)
-    : QObject(parent),
-      m_frameMarker(ApiTrace::FrameMarker_SwapBuffers)
+    : QObject(parent)
 {
 }
 
@@ -61,6 +60,7 @@ void TraceLoader::loadTrace(const QString &filename)
         //Load the entire file into memory
         parseTrace();
     }
+    emit guessedApi(static_cast<int>(m_parser.api));
     emit finishedParsing();
 }
 
@@ -69,34 +69,6 @@ void TraceLoader::loadFrame(ApiTraceFrame *currentFrame)
     fetchFrameContents(currentFrame);
 }
 
-void TraceLoader::setFrameMarker(ApiTrace::FrameMarker marker)
-{
-    m_frameMarker = marker;
-}
-
-bool TraceLoader::isCallAFrameMarker(const trace::Call *call) const
-{
-    std::string name = call->name();
-
-    switch (m_frameMarker) {
-    case ApiTrace::FrameMarker_SwapBuffers:
-        return  name.find("SwapBuffers") != std::string::npos ||
-                name == "CGLFlushDrawable" ||
-                name == "glFrameTerminatorGREMEDY";
-        break;
-    case ApiTrace::FrameMarker_Flush:
-        return name == "glFlush";
-        break;
-    case ApiTrace::FrameMarker_Finish:
-        return name == "glFinish";
-        break;
-    case ApiTrace::FrameMarker_Clear:
-        return name == "glClear";
-        break;
-    }
-    return false;
-}
-
 int TraceLoader::numberOfFrames() const
 {
     return m_frameBookmarks.size();
@@ -104,7 +76,7 @@ int TraceLoader::numberOfFrames() const
 
 int TraceLoader::numberOfCallsInFrame(int frameIdx) const
 {
-    if (frameIdx > m_frameBookmarks.size()) {
+    if (frameIdx >= m_frameBookmarks.size()) {
         return 0;
     }
     FrameBookmarks::const_iterator itr =
@@ -147,7 +119,7 @@ void TraceLoader::scanTrace()
     while ((call = m_parser.scan_call())) {
         ++numOfCalls;
 
-        if (isCallAFrameMarker(call)) {
+        if (call->flags & trace::CALL_FLAG_END_FRAME) {
             FrameBookmark frameBookmark(startBookmark);
             frameBookmark.numberOfCalls = numOfCalls;
 
@@ -217,8 +189,7 @@ void TraceLoader::parseTrace()
                     apiCall->arguments()[apiCall->binaryDataIndex()].toByteArray();
             binaryDataSize += data.size();
         }
-        if (ApiTrace::isCallAFrameMarker(apiCall,
-                                         m_frameMarker)) {
+        if (call->flags & trace::CALL_FLAG_END_FRAME) {
             calls.squeeze();
             currentFrame->setCalls(calls, binaryDataSize);
             calls.clear();
@@ -386,7 +357,7 @@ int TraceLoader::callInFrame(int callIdx) const
 {
     unsigned numCalls = 0;
 
-    for (int frameIdx = 0; frameIdx <= m_frameBookmarks.size(); ++frameIdx) {
+    for (int frameIdx = 0; frameIdx < m_frameBookmarks.size(); ++frameIdx) {
         const FrameBookmark &frameBookmark = m_frameBookmarks[frameIdx];
         unsigned firstCall = numCalls;
         unsigned endCall = numCalls + frameBookmark.numberOfCalls;
@@ -452,7 +423,7 @@ TraceLoader::fetchFrameContents(ApiTraceFrame *currentFrame)
 
                 delete call;
 
-                if (ApiTrace::isCallAFrameMarker(apiCall, m_frameMarker)) {
+                if (apiCall->flags() & trace::CALL_FLAG_END_FRAME) {
                     break;
                 }
 
index 3a310bad260489aed17b665616c8ebcc43943932..0954078219fba68bd3e188b72d56027cd3b01d7b 100644 (file)
@@ -27,7 +27,6 @@ public:
 public slots:
     void loadTrace(const QString &filename);
     void loadFrame(ApiTraceFrame *frame);
-    void setFrameMarker(ApiTrace::FrameMarker marker);
     void findFrameStart(ApiTraceFrame *frame);
     void findFrameEnd(ApiTraceFrame *frame);
     void findCallIndex(int index);
@@ -36,6 +35,7 @@ public slots:
 signals:
     void startedParsing();
     void parsed(int percent);
+    void guessedApi(int api);
     void finishedParsing();
 
     void framesLoaded(const QList<ApiTraceFrame*> &frames);
@@ -62,11 +62,11 @@ private:
         trace::ParseBookmark start;
         int numberOfCalls;
     };
-    bool isCallAFrameMarker(const trace::Call *call) const;
     int numberOfFrames() const;
     int numberOfCallsInFrame(int frameIdx) const;
 
     void loadHelpFile();
+    void guessApi(const trace::Call *call);
     void scanTrace();
     void parseTrace();
 
@@ -84,7 +84,6 @@ private:
 
 private:
     trace::Parser m_parser;
-    ApiTrace::FrameMarker m_frameMarker;
 
     typedef QMap<int, FrameBookmark> FrameBookmarks;
     FrameBookmarks m_frameBookmarks;
index 67cc64a252807145bee3be82ed3ef610afaae4c2..6f4d0b9350da147249bbf1e522fd8c51d6de4384 100644 (file)
@@ -16,10 +16,6 @@ TraceProcess::TraceProcess(QObject *parent)
     connect(m_process, SIGNAL(error(QProcess::ProcessError)),
             this, SLOT(traceError(QProcess::ProcessError)));
 
-#ifdef Q_OS_WIN
-    qWarning()<<"Windows tracing isn't supported right now!";
-    m_canTrace = false;
-#else
 #ifdef Q_OS_WIN
     QString format = QLatin1String("%1;");
 #else
@@ -29,13 +25,17 @@ TraceProcess::TraceProcess(QObject *parent)
     QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
     env.insert("PATH", buildPath + env.value("PATH"));
     qputenv("PATH", env.value("PATH").toLatin1());
-#endif
 }
 
 TraceProcess::~TraceProcess()
 {
 }
 
+void TraceProcess::setApi(const QString &str)
+{
+    m_api = str;
+}
+
 void TraceProcess::setExecutablePath(const QString &str)
 {
     m_execPath = str;
@@ -98,6 +98,8 @@ void TraceProcess::start()
     QStringList arguments;
 
     arguments << QLatin1String("trace");
+    arguments << QLatin1String("--api");
+    arguments << m_api;
     arguments << QLatin1String("--output");
     arguments << m_tracePath;
     arguments << QLatin1String("--");
index b65f41c548ab0e3a1b909077195a567eedeaabf7..343bac967cf6fddf6c64557fe8a457fde17441bf 100644 (file)
@@ -13,6 +13,7 @@ public:
 
     bool canTrace() const;
 
+    void setApi(const QString &str);
     void setExecutablePath(const QString &str);
     QString executablePath() const;
 
@@ -31,6 +32,7 @@ private slots:
     void traceError(QProcess::ProcessError err);
 
 private:
+    QString m_api;
     QString m_execPath;
     QStringList m_args;
     QString m_tracePath;
diff --git a/gui/trimprocess.cpp b/gui/trimprocess.cpp
new file mode 100644 (file)
index 0000000..c23475d
--- /dev/null
@@ -0,0 +1,120 @@
+#include "trimprocess.h"
+#include "apitrace.h"
+
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+
+TrimProcess::TrimProcess(QObject *parent)
+    : QObject(parent)
+{
+    m_process = new QProcess(this);
+
+    connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
+            this, SLOT(trimFinished()));
+    connect(m_process, SIGNAL(error(QProcess::ProcessError)),
+            this, SLOT(trimError(QProcess::ProcessError)));
+
+#ifdef Q_OS_WIN
+    QString format = QLatin1String("%1;");
+#else
+    QString format = QLatin1String("%1:");
+#endif
+    QString buildPath = format.arg(APITRACE_BINARY_DIR);
+    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+    env.insert("PATH", buildPath + env.value("PATH"));
+    qputenv("PATH", env.value("PATH").toLatin1());
+}
+
+TrimProcess::~TrimProcess()
+{
+}
+
+void TrimProcess::trimFinished()
+{
+    // consume verbose output spew
+    QByteArray outputStrings = m_process->readAllStandardOutput();
+    QByteArray errorStrings = m_process->readAllStandardError();
+#if 0
+    qDebug()<<"trim finished on " << m_trimPath;
+    qDebug()<<"\terr = "<<errorStrings;
+    qDebug()<<"\tout = "<<outputStrings;
+#endif
+    emit trimmedFile(m_trimPath);
+}
+
+void TrimProcess::trimError(QProcess::ProcessError err)
+{
+    // consume verbose output spew
+    QByteArray outputStrings = m_process->readAllStandardOutput();
+    QByteArray errorStrings = m_process->readAllStandardError();
+#if 1
+    qDebug()<<"trace error = "<<m_tracePath;
+    qDebug()<<"\terr = "<<errorStrings;
+    qDebug()<<"\tout = "<<outputStrings;
+#endif
+    emit error(errorStrings);
+}
+
+
+void TrimProcess::start()
+{
+    QStringList arguments;
+
+    QString outputFormat = QLatin1String("--output=%1");
+    QString outputArgument = outputFormat
+                                .arg(m_trimPath);
+
+    QString callSetFormat = QLatin1String("--calls=0-%1");
+    QString callSetArgument = callSetFormat
+                                .arg(m_trimIndex);
+
+    arguments << QLatin1String("trim");
+    arguments << outputArgument;
+    arguments << callSetArgument;
+    arguments << m_tracePath;
+
+    m_process->start(QLatin1String("apitrace"), arguments);
+}
+
+int TrimProcess::trimIndex()
+{
+    return m_trimIndex;
+}
+
+void TrimProcess::setTrimIndex(int trimIndex)
+{
+    m_trimIndex = trimIndex;
+
+    updateTrimPath();
+}
+
+void TrimProcess::setTracePath(const QString &str)
+{
+    m_tracePath = str;
+
+    updateTrimPath();
+}
+
+QString TrimProcess::tracePath() const
+{
+    return m_tracePath;
+}
+
+void TrimProcess::updateTrimPath()
+{
+
+    QFileInfo fi(m_tracePath);
+    QString baseName = fi.baseName();
+    QString path = fi.path();
+
+    QString format = QString::fromLatin1("%1/%2.%3.trim.trace");
+
+    m_trimPath = format
+                  .arg(path)
+                  .arg(baseName)
+                  .arg(m_trimIndex);
+}
+
+#include "trimprocess.moc"
diff --git a/gui/trimprocess.h b/gui/trimprocess.h
new file mode 100644 (file)
index 0000000..1cc796c
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef TRIMPROCESS_H
+#define TRIMPROCESS_H
+
+#include "apitrace.h"
+
+#include <QObject>
+#include <QProcess>
+
+class TrimProcess : public QObject
+{
+    Q_OBJECT
+public:
+    TrimProcess(QObject *parent=0);
+    ~TrimProcess();
+
+    void setTrimIndex(int trimIndex);
+    int trimIndex();
+
+    void setTracePath(const QString &str);
+    QString tracePath() const;
+
+private:
+    void updateTrimPath();
+
+public slots:
+    void start();
+
+signals:
+    void trimmedFile(const QString &trimPath);
+    void error(const QString &msg);
+
+private slots:
+    void trimFinished();
+    void trimError(QProcess::ProcessError err);
+
+private:
+    QStringList m_args;
+    QString m_tracePath;
+    QString m_trimPath;
+    ApiTraceEvent *m_trimEvent;
+    int m_trimIndex;
+    QProcess *m_process;
+};
+
+#endif
index 3ae2dadcb7d6377631d622411932f87d61cb0bac..a595ba790a4b8604f303fda282ca41e22adadbd4 100644 (file)
      </widget>
     </widget>
    </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="lowerLabel">
+       <property name="text">
+        <string>Lower</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDoubleSpinBox" name="lowerSpinBox">
+       <property name="singleStep">
+        <double>0.050000000000000</double>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="upperLabel">
+       <property name="text">
+        <string>Upper</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDoubleSpinBox" name="upperSpinBox">
+       <property name="singleStep">
+        <double>0.050000000000000</double>
+       </property>
+       <property name="value">
+        <double>1.000000000000000</double>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="flipCheckBox">
+       <property name="text">
+        <string>Flip</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="opaqueCheckBox">
+       <property name="text">
+        <string>Opaque</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="alphaCheckBox">
+       <property name="text">
+        <string>Alpha</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
   </layout>
  </widget>
  <resources/>
index 5b48dc28d54c872845d0f57bb3ddaf611b71f25f..7cbb3d1e3bea979532b80bd7bdbf620b80822d9a 100644 (file)
     <addaction name="actionGo"/>
     <addaction name="actionGoFrameStart"/>
     <addaction name="actionGoFrameEnd"/>
-    <addaction name="separator"/>
-    <addaction name="actionShowErrorsDock"/>
    </widget>
    <widget class="QMenu" name="menu_Trace">
     <property name="title">
      <string>&amp;Trace</string>
     </property>
     <addaction name="actionReplay"/>
+    <addaction name="actionProfile"/>
     <addaction name="actionStop"/>
     <addaction name="actionLookupState"/>
+    <addaction name="actionShowThumbnails"/>
+    <addaction name="actionTrim"/>
     <addaction name="separator"/>
     <addaction name="actionOptions"/>
    </widget>
+   <widget class="QMenu" name="menuView">
+    <property name="title">
+     <string>&amp;View</string>
+    </property>
+    <addaction name="actionShowErrorsDock"/>
+    <addaction name="actionShowProfileDialog"/>
+   </widget>
    <addaction name="menuFile"/>
    <addaction name="menuEdit"/>
+   <addaction name="menuView"/>
    <addaction name="menu_Trace"/>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
     <string>Ctrl+L</string>
    </property>
   </action>
+  <action name="actionShowThumbnails">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="text">
+    <string>Show &amp;Thumbnails</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+T</string>
+   </property>
+  </action>
+  <action name="actionTrim">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="text">
+    <string>Tr&amp;im</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+I</string>
+   </property>
+  </action>
   <action name="actionOptions">
    <property name="text">
     <string>Options</string>
     <bool>false</bool>
    </property>
    <property name="text">
-    <string>Show Errors Dock</string>
+    <string>Show &amp;Errors Dock</string>
+   </property>
+  </action>
+  <action name="actionShowProfileDialog">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="text">
+    <string>Show &amp;Profile Results</string>
+   </property>
+  </action>
+  <action name="actionProfile">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="text">
+    <string>&amp;Profile</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+P</string>
    </property>
   </action>
   <zorder>stateDock</zorder>
diff --git a/gui/ui/profiledialog.ui b/gui/ui/profiledialog.ui
new file mode 100644 (file)
index 0000000..bbcfbe9
--- /dev/null
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProfileDialog</class>
+ <widget class="QDialog" name="ProfileDialog">
+  <property name="windowModality">
+   <enum>Qt::NonModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1105</width>
+    <height>804</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Profile Results</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true"/>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QSplitter" name="splitter">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="opaqueResize">
+      <bool>false</bool>
+     </property>
+     <widget class="GraphWidget" name="m_timeline" native="true">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+        <horstretch>0</horstretch>
+        <verstretch>1</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="focusPolicy">
+       <enum>Qt::WheelFocus</enum>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <property name="margin">
+        <number>0</number>
+       </property>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="graphContainer" native="true">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="minimumSize">
+       <size>
+        <width>0</width>
+        <height>200</height>
+       </size>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <property name="margin">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="CallDurationGraph" name="m_gpuGraph" native="true">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
+         </property>
+         <property name="focusPolicy">
+          <enum>Qt::WheelFocus</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="CallDurationGraph" name="m_cpuGraph" native="true">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QTableView" name="m_table">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="editTriggers">
+       <set>QAbstractItemView::NoEditTriggers</set>
+      </property>
+      <property name="selectionMode">
+       <enum>QAbstractItemView::SingleSelection</enum>
+      </property>
+      <property name="selectionBehavior">
+       <enum>QAbstractItemView::SelectRows</enum>
+      </property>
+      <property name="verticalScrollMode">
+       <enum>QAbstractItemView::ScrollPerPixel</enum>
+      </property>
+      <property name="horizontalScrollMode">
+       <enum>QAbstractItemView::ScrollPerPixel</enum>
+      </property>
+      <property name="sortingEnabled">
+       <bool>true</bool>
+      </property>
+      <property name="wordWrap">
+       <bool>false</bool>
+      </property>
+      <attribute name="verticalHeaderVisible">
+       <bool>false</bool>
+      </attribute>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>GraphWidget</class>
+   <extends>QWidget</extends>
+   <header>graphing/graphwidget.h</header>
+   <container>1</container>
+  </customwidget>
+  <customwidget>
+   <class>CallDurationGraph</class>
+   <extends>QWidget</extends>
+   <header>calldurationgraph.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>m_table</sender>
+   <signal>doubleClicked(QModelIndex)</signal>
+   <receiver>ProfileDialog</receiver>
+   <slot>tableDoubleClicked(QModelIndex)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>895</x>
+     <y>220</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>511</x>
+     <y>383</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <signal>jumpToCall(int)</signal>
+  <slot>setVerticalScrollMax(int)</slot>
+  <slot>setHorizontalScrollMax(int)</slot>
+  <slot>tableDoubleClicked(QModelIndex)</slot>
+  <slot>selectTime(int64_t,int64_t)</slot>
+  <slot>selectProgram(unsigned)</slot>
+  <slot>selectNone()</slot>
+ </slots>
+</ui>
diff --git a/gui/ui/profilereplaydialog.ui b/gui/ui/profilereplaydialog.ui
new file mode 100644 (file)
index 0000000..f5991ae
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProfileReplayDialog</class>
+ <widget class="QDialog" name="ProfileReplayDialog">
+  <property name="windowModality">
+   <enum>Qt::ApplicationModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>353</width>
+    <height>165</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Profile Configuration</string>
+  </property>
+  <property name="whatsThis">
+   <string>Allows setting options on the profiling process.</string>
+  </property>
+  <property name="modal">
+   <bool>true</bool>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QGroupBox" name="profileGroup">
+     <property name="title">
+      <string>Profiling</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <item>
+       <widget class="QCheckBox" name="gpuTimesCB">
+        <property name="text">
+         <string>GPU times</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="cpuTimesCB">
+        <property name="text">
+         <string>CPU times</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="pixelsDrawnCB">
+        <property name="text">
+         <string>Pixels drawn per call</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>ProfileReplayDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>176</x>
+     <y>142</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>176</x>
+     <y>82</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>ProfileReplayDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>176</x>
+     <y>142</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>176</x>
+     <y>82</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 683557d62e826e6305ecb59d7b4d1105d71d48ef..1d2da3e9c4dace78a2aaee5cd49d7b4e5b90bc14 100644 (file)
    <string>QApiTrace Settings</string>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <widget class="QGroupBox" name="apiGroupBox">
-     <property name="title">
-      <string>API</string>
-     </property>
-     <layout class="QVBoxLayout" name="verticalLayout_4">
-      <item>
-       <widget class="QComboBox" name="apiComboBox">
-        <item>
-         <property name="text">
-          <string>GL</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>EGL</string>
-         </property>
-        </item>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
    <item>
     <widget class="QGroupBox" name="groupBox">
      <property name="sizePolicy">
index 149881f7427714162303944e76d110ab6af875a8..a3e5240a540b2ec44a2751557b9652650bb567f5 100644 (file)
    <string>Dialog</string>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="text">
+        <string>API:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="apiComboBox"/>
+     </item>
+    </layout>
+   </item>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
diff --git a/helpers/d3dsize.hpp b/helpers/d3dsize.hpp
new file mode 100644 (file)
index 0000000..156fdd2
--- /dev/null
@@ -0,0 +1,379 @@
+/**************************************************************************
+ *
+ * Copyright 2012 Jose Fonseca
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * AUTHORS,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/*
+ * Auxiliary functions to compute the size of array/blob arguments.
+ */
+
+#ifndef _D3D_SIZE_HPP_
+#define _D3D_SIZE_HPP_
+
+
+/* We purposedly don't include any D3D header, so that this header can be used
+ * with all D3D versions. */
+
+#include <assert.h>
+
+#include "os.hpp"
+
+
+static inline size_t
+_vertexCount(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount)
+{
+    switch (PrimitiveType) {
+    case D3DPT_POINTLIST:
+        return PrimitiveCount;
+    case D3DPT_LINELIST:
+        return PrimitiveCount*2;
+    case D3DPT_LINESTRIP:
+        return PrimitiveCount + 1;
+    case D3DPT_TRIANGLELIST:
+        return PrimitiveCount * 3;
+    case D3DPT_TRIANGLESTRIP:
+        return PrimitiveCount + 2;
+    case D3DPT_TRIANGLEFAN:
+        return PrimitiveCount + 1;
+    default:
+        os::log("apitrace: warning: %s: unknown D3DPRIMITIVETYPE %u\n", __FUNCTION__, PrimitiveType);
+        return 0;
+    }
+}
+
+
+static inline size_t
+_vertexDataSize(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, UINT VertexStride) {
+    return _vertexCount(PrimitiveType, PrimitiveCount) * VertexStride;
+}
+
+
+static inline size_t
+_indexDataSize(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, D3DFORMAT IndexDataFormat) {
+    UINT IndexStride;
+    switch (IndexDataFormat) {
+    case D3DFMT_INDEX16:
+        IndexStride = 2;
+        break;
+    case D3DFMT_INDEX32:
+        IndexStride = 4;
+        break;
+    default:
+        os::log("apitrace: warning: %s: unexpected index D3DFORMAT %u\n", __FUNCTION__, IndexDataFormat);
+        return 0;
+    }
+    return _vertexCount(PrimitiveType, PrimitiveCount) * IndexStride;
+}
+
+
+#if DIRECT3D_VERSION >= 0x0800
+
+/*
+ * Return the number of tokens for a given shader.
+ */
+static inline size_t
+_shaderSize(const DWORD *pFunction)
+{
+    DWORD dwLength = 0;
+
+    while (true) {
+        DWORD dwToken = pFunction[dwLength++];
+
+        switch (dwToken & D3DSI_OPCODE_MASK) {
+        case D3DSIO_COMMENT:
+            dwLength += (dwToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT;
+            break;
+
+        case D3DSIO_END:
+            if (dwToken != D3DSIO_END) {
+                os::log("apitrace: warning: %s: malformed END token\n", __FUNCTION__);
+            }
+            return dwLength * sizeof *pFunction;
+        }
+    }
+}
+
+
+static size_t
+_getLockSize(D3DFORMAT Format, UINT Width, UINT Height, INT RowPitch, UINT Depth = 1, INT SlicePitch = 0) {
+    if (Width == 0 || Height == 0 || Depth == 0) {
+        return 0;
+    }
+
+    if (RowPitch < 0) {
+        os::log("apitrace: warning: %s: negative row pitch %i\n", __FUNCTION__, RowPitch);
+        return 0;
+    }
+
+    if (SlicePitch < 0) {
+        os::log("apitrace: warning: %s: negative slice pitch %i\n", __FUNCTION__, SlicePitch);
+        return 0;
+    }
+
+    switch ((DWORD)Format) {
+    case D3DFMT_DXT1:
+    case D3DFMT_DXT2:
+    case D3DFMT_DXT3:
+    case D3DFMT_DXT4:
+    case D3DFMT_DXT5:
+        Width  = (Width  + 3) / 4;
+        Height = (Height + 3) / 4;
+        break;
+
+    case D3DFMT_ATI1N:
+    case D3DFMT_ATI2N:
+        /*
+         * Because these are unsupported formats, RowPitch is not set to the
+         * number of bytes between row of blocks, but instead in such way that
+         * Height * RowPitch will match the expected size.
+         */
+        break;
+
+    case D3DFMT_UYVY:
+    case D3DFMT_R8G8_B8G8:
+    case D3DFMT_YUY2:
+    case D3DFMT_G8R8_G8B8:
+        Width = (Width + 1) / 2;
+        break;
+
+    case D3DFMT_NV12:
+        return (Height + ((Height + 1) / 2)) * RowPitch;
+
+    case D3DFMT_NULL:
+        return 0;
+
+    default:
+        break;
+    }
+
+    (void)Width;
+
+    size_t size = Height * RowPitch;
+
+    if (Depth > 1) {
+        size += (Depth - 1) * SlicePitch;
+    }
+
+    return size;
+}
+
+
+#endif /* DIRECT3D_VERSION >= 0x0800 */
+
+
+#if DIRECT3D_VERSION >= 0x0900
+
+
+static inline void
+_getLockInfo(IDirect3DVertexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData,
+             void * & pLockedData, size_t & LockedSize) {
+    pLockedData = *ppbData;
+    LockedSize = 0;
+
+    if (SizeToLock == 0) {
+        D3DVERTEXBUFFER_DESC Desc;
+        HRESULT hr = pBuffer->GetDesc(&Desc);
+        if (FAILED(hr)) {
+            return;
+        }
+        LockedSize = Desc.Size;
+    } else {
+        LockedSize = SizeToLock;
+    }
+}
+
+
+static inline void
+_getLockInfo(IDirect3DIndexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData,
+             void * & pLockedData, size_t & LockedSize) {
+    pLockedData = *ppbData;
+    LockedSize = 0;
+
+    if (SizeToLock == 0) {
+        D3DINDEXBUFFER_DESC Desc;
+        HRESULT hr = pBuffer->GetDesc(&Desc);
+        if (FAILED(hr)) {
+            return;
+        }
+        LockedSize = Desc.Size;
+    } else {
+        LockedSize = SizeToLock;
+    }
+}
+
+
+static inline void
+_getLockInfo(IDirect3DSurface9 *pSurface, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect,
+             void * & pLockedData, size_t & LockedSize) {
+    pLockedData = pLockedRect->pBits;
+    LockedSize = 0;
+
+    HRESULT hr;
+
+    D3DSURFACE_DESC Desc;
+    hr = pSurface->GetDesc(&Desc);
+    if (FAILED(hr)) {
+        return;
+    }
+
+    UINT Width;
+    UINT Height;
+    if (pRect) {
+        Width  = pRect->right  - pRect->left;
+        Height = pRect->bottom - pRect->top;
+    } else {
+        Width  = Desc.Width;
+        Height = Desc.Height;
+    }
+
+    LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DTexture9 *pTexture, UINT Level, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect,
+             void * & pLockedData, size_t & LockedSize) {
+    pLockedData = pLockedRect->pBits;
+    LockedSize = 0;
+
+    HRESULT hr;
+
+    D3DSURFACE_DESC Desc;
+    hr = pTexture->GetLevelDesc(Level, &Desc);
+    if (FAILED(hr)) {
+        return;
+    }
+
+    UINT Width;
+    UINT Height;
+    if (pRect) {
+        Width  = pRect->right  - pRect->left;
+        Height = pRect->bottom - pRect->top;
+    } else {
+        Width  = Desc.Width;
+        Height = Desc.Height;
+    }
+
+    LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DCubeTexture9 *pTexture, D3DCUBEMAP_FACES FaceType, UINT Level, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect,
+             void * & pLockedData, size_t & LockedSize) {
+    pLockedData = pLockedRect->pBits;
+    LockedSize = 0;
+
+    HRESULT hr;
+
+    (void)FaceType;
+
+    D3DSURFACE_DESC Desc;
+    hr = pTexture->GetLevelDesc(Level, &Desc);
+    if (FAILED(hr)) {
+        return;
+    }
+
+    UINT Width;
+    UINT Height;
+    if (pRect) {
+        Width  = pRect->right  - pRect->left;
+        Height = pRect->bottom - pRect->top;
+    } else {
+        Width  = Desc.Width;
+        Height = Desc.Height;
+    }
+
+    LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DVolume9 *pVolume, const D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox,
+             void * & pLockedData, size_t & LockedSize) {
+    pLockedData = pLockedVolume->pBits;
+    LockedSize = 0;
+
+    HRESULT hr;
+
+    D3DVOLUME_DESC Desc;
+    hr = pVolume->GetDesc(&Desc);
+    if (FAILED(hr)) {
+        return;
+    }
+
+    UINT Width;
+    UINT Height;
+    UINT Depth;
+    if (pBox) {
+        Width  = pBox->Right  - pBox->Left;
+        Height = pBox->Bottom - pBox->Top;
+        Depth  = pBox->Back   - pBox->Front;
+    } else {
+        Width  = Desc.Width;
+        Height = Desc.Height;
+        Depth  = Desc.Depth;
+    }
+
+    LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedVolume->RowPitch, Depth, pLockedVolume->SlicePitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DVolumeTexture9 *pTexture, UINT Level, const D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox,
+             void * & pLockedData, size_t & LockedSize) {
+    pLockedData = pLockedVolume->pBits;
+    LockedSize = 0;
+
+    HRESULT hr;
+
+    D3DVOLUME_DESC Desc;
+    hr = pTexture->GetLevelDesc(Level, &Desc);
+    if (FAILED(hr)) {
+        return;
+    }
+
+    UINT Width;
+    UINT Height;
+    UINT Depth;
+    if (pBox) {
+        Width  = pBox->Right  - pBox->Left;
+        Height = pBox->Bottom - pBox->Top;
+        Depth  = pBox->Back   - pBox->Front;
+    } else {
+        Width  = Desc.Width;
+        Height = Desc.Height;
+        Depth  = Desc.Depth;
+    }
+
+    LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedVolume->RowPitch, Depth, pLockedVolume->SlicePitch);
+}
+
+
+#endif /* DIRECT3D_VERSION >= 0x0900 */
+
+
+#endif /* _D3D_SIZE_HPP_ */
diff --git a/helpers/eglsize.cpp b/helpers/eglsize.cpp
new file mode 100644 (file)
index 0000000..4f2dfdc
--- /dev/null
@@ -0,0 +1,217 @@
+/*********************************************************************
+ *
+ * Copyright 2012 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+/*
+ * Auxiliary functions to compute the size of array/blob arguments.
+ */
+
+#include <string.h>
+
+#include "os_thread.hpp"
+#include "glimports.hpp"
+#include "glproc.hpp"
+#include "glsize.hpp"
+#include "eglsize.hpp"
+#include "assert.h"
+
+
+static int
+bisect_val(int min, int max, bool is_valid_val(int val))
+{
+    bool valid;
+
+    while (1) {
+        int try_val = min + (max - min + 1) / 2;
+
+        valid = is_valid_val(try_val);
+        if (min == max)
+            break;
+
+        if (valid)
+            min = try_val;
+        else
+            max = try_val - 1;
+    }
+
+    return valid ? min : -1;
+}
+
+static bool
+is_valid_width(int val)
+{
+    _glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, val, 1);
+    return _glGetError() == GL_NO_ERROR;
+}
+
+static bool
+is_valid_height(int val)
+{
+    _glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, val);
+    return _glGetError() == GL_NO_ERROR;
+}
+
+static int
+detect_size(int *width_ret, int *height_ret)
+{
+    GLint max_tex_size;
+    int width;
+    int height;
+
+    max_tex_size = 0;
+    _glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);
+
+    width = bisect_val(1, max_tex_size, is_valid_width);
+    if (width < 0)
+        return -1;
+
+    height = bisect_val(1, max_tex_size, is_valid_height);
+    if (height < 0)
+        return -1;
+
+    *width_ret = width;
+    *height_ret = height;
+
+    return 0;
+}
+
+/* XXX */
+static inline bool
+can_unpack_subimage(void) {
+    return false;
+}
+
+static void
+_eglCreateImageKHR_get_image_size(EGLImageKHR image, image_info *info)
+{
+    GLuint fbo = 0;
+    GLuint orig_fbo = 0;
+    GLuint texture = 0;
+    GLuint orig_texture;
+    GLenum status;
+
+    _glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)&orig_fbo);
+    _glGenFramebuffers(1, &fbo);
+    _glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    _glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&orig_texture);
+    _glGenTextures(1, &texture);
+    _glBindTexture(GL_TEXTURE_2D, texture);
+
+    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+
+    info->width = 0;
+    info->height = 0;
+
+    _glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+                            GL_TEXTURE_2D, texture, 0);
+    status = _glCheckFramebufferStatus(GL_FRAMEBUFFER);
+    if (status == GL_FRAMEBUFFER_COMPLETE) {
+        if (detect_size(&info->width, &info->height) != 0)
+            os::log("%s: can't detect image size\n", __func__);
+    } else {
+        os::log("%s: error: %x\n", __func__, status);
+    }
+
+    /* Don't leak errors to the traced application. */
+    (void)_glGetError();
+
+    _glBindTexture(GL_TEXTURE_2D, orig_texture);
+    _glDeleteTextures(1, &texture);
+
+    _glBindFramebuffer(GL_FRAMEBUFFER, orig_fbo);
+    _glDeleteFramebuffers(1, &fbo);
+}
+
+static void
+get_texture_2d_image(image_info *info)
+{
+    GLuint fbo = 0;
+    GLint prev_fbo = 0;
+    GLint texture;
+    GLenum status;
+
+    _glGetIntegerv(GL_TEXTURE_BINDING_2D, &texture);
+    if (!texture)
+        return;
+
+    _glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prev_fbo);
+    _glGenFramebuffers(1, &fbo);
+    _glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    _glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+                            texture, 0);
+    status = _glCheckFramebufferStatus(GL_FRAMEBUFFER);
+    if (status != GL_FRAMEBUFFER_COMPLETE)
+        os::log("%s: error: %d\n", __func__, status);
+    _glReadPixels(0, 0, info->width, info->height, info->format, info->type, info->pixels);
+    /* Don't leak errors to the traced application. */
+    (void)_glGetError();
+
+    _glBindFramebuffer(GL_FRAMEBUFFER, prev_fbo);
+    _glDeleteFramebuffers(1, &fbo);
+}
+
+struct image_info *
+_EGLImageKHR_get_image_info(GLenum target, EGLImageKHR image)
+{
+    GLuint tex;
+    GLuint bound_tex;
+    struct image_info *info;
+
+    info = new image_info;
+
+    memset(info, 0, sizeof *info);
+
+    info->internalformat = GL_RGBA;
+    info->format = GL_RGBA;
+    info->type = GL_UNSIGNED_BYTE;
+
+    _eglCreateImageKHR_get_image_size(image, info);
+
+    _glGenTextures(1, &tex);
+    _glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&bound_tex);
+    _glBindTexture(GL_TEXTURE_2D, tex);
+    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+
+    info->size = _glTexImage2D_size(info->format, info->type, info->width, info->height);
+    info->pixels = malloc(info->size);
+
+    get_texture_2d_image(info);
+    _glBindTexture(GL_TEXTURE_2D, bound_tex);
+    _glDeleteBuffers(1, &tex);
+
+    return info;
+}
+
+void
+_EGLImageKHR_free_image_info(struct image_info *info)
+{
+    free(info->pixels);
+    delete info;
+}
+
+
diff --git a/helpers/eglsize.hpp b/helpers/eglsize.hpp
new file mode 100644 (file)
index 0000000..a2014f6
--- /dev/null
@@ -0,0 +1,57 @@
+
+/*********************************************************************
+ *
+ * Copyright 2012 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+/*
+ * Auxiliary functions to compute the size of array/blob arguments.
+ */
+#ifndef _EGLSIZE_HPP_
+#define _EGLSIZE_HPP_
+
+
+#include "glimports.hpp"
+
+
+struct image_info
+{
+    GLint internalformat;
+    GLsizei width;
+    GLsizei height;
+    GLenum format;
+    GLenum type;
+    GLsizei size;
+    GLvoid * pixels;
+};
+
+struct image_info *
+_EGLImageKHR_get_image_info(GLenum target, EGLImageKHR image);
+
+void
+_EGLImageKHR_free_image_info(struct image_info *info);
+
+
+#endif
diff --git a/helpers/glsize.hpp b/helpers/glsize.hpp
new file mode 100644 (file)
index 0000000..6ffba68
--- /dev/null
@@ -0,0 +1,815 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * Copyright 2010 VMware, Inc.
+ * Copyright 2004 IBM Corporation
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * AUTHORS,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Auxiliary functions to compute the size of array/blob arguments, depending.
+ */
+
+#ifndef _GL_SIZE_HPP_
+#define _GL_SIZE_HPP_
+
+
+#include <string.h>
+
+#include <algorithm>
+
+#include "os.hpp"
+#include "glimports.hpp"
+
+
+static inline size_t
+_gl_type_size(GLenum type)
+{
+    switch (type) {
+    case GL_BOOL:
+    case GL_BYTE:
+    case GL_UNSIGNED_BYTE:
+        return 1;
+    case GL_SHORT:
+    case GL_UNSIGNED_SHORT:
+    case GL_2_BYTES:
+    case GL_HALF_FLOAT:
+        return 2;
+    case GL_3_BYTES:
+        return 3;
+    case GL_INT:
+    case GL_UNSIGNED_INT:
+    case GL_FLOAT:
+    case GL_4_BYTES:
+    case GL_FIXED:
+        return 4;
+    case GL_DOUBLE:
+        return 8;
+    default:
+        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
+        return 0;
+    }
+}
+
+static inline void
+_gl_uniform_size(GLenum type, GLenum &elemType, GLint &numCols, GLint &numRows) {
+    numCols = 1;
+    numRows = 1;
+
+    switch (type) {
+    case GL_FLOAT:
+        elemType = GL_FLOAT;
+        break;
+    case GL_FLOAT_VEC2:
+        elemType = GL_FLOAT;
+        numCols = 2;
+        break;
+    case GL_FLOAT_VEC3:
+        elemType = GL_FLOAT;
+        numCols = 3;
+        break;
+    case GL_FLOAT_VEC4:
+        elemType = GL_FLOAT;
+        numCols = 4;
+        break;
+    case GL_DOUBLE:
+        elemType = GL_DOUBLE;
+        break;
+    case GL_DOUBLE_VEC2:
+        elemType = GL_DOUBLE;
+        numCols = 2;
+        break;
+    case GL_DOUBLE_VEC3:
+        elemType = GL_DOUBLE;
+        numCols = 3;
+        break;
+    case GL_DOUBLE_VEC4:
+        elemType = GL_DOUBLE;
+        numCols = 4;
+        break;
+    case GL_INT:
+        elemType = GL_INT;
+        break;
+    case GL_INT_VEC2:
+        elemType = GL_INT;
+        numCols = 2;
+        break;
+    case GL_INT_VEC3:
+        elemType = GL_INT;
+        numCols = 3;
+        break;
+    case GL_INT_VEC4:
+        elemType = GL_INT;
+        numCols = 4;
+        break;
+    case GL_UNSIGNED_INT:
+        elemType = GL_UNSIGNED_INT;
+        break;
+    case GL_UNSIGNED_INT_VEC2:
+        elemType = GL_UNSIGNED_INT;
+        numCols = 2;
+        break;
+    case GL_UNSIGNED_INT_VEC3:
+        elemType = GL_UNSIGNED_INT;
+        numCols = 3;
+        break;
+    case GL_UNSIGNED_INT_VEC4:
+        elemType = GL_UNSIGNED_INT;
+        numCols = 4;
+        break;
+    case GL_BOOL:
+        elemType = GL_BOOL;
+        break;
+    case GL_BOOL_VEC2:
+        elemType = GL_BOOL;
+        numCols = 2;
+        break;
+    case GL_BOOL_VEC3:
+        elemType = GL_BOOL;
+        numCols = 3;
+        break;
+    case GL_BOOL_VEC4:
+        elemType = GL_BOOL;
+        numCols = 4;
+        break;
+    case GL_FLOAT_MAT2:
+        elemType = GL_FLOAT;
+        numCols = 2;
+        numRows = 2;
+        break;
+    case GL_FLOAT_MAT3:
+        elemType = GL_FLOAT;
+        numCols = 3;
+        numRows = 3;
+        break;
+    case GL_FLOAT_MAT4:
+        elemType = GL_FLOAT;
+        numCols = 4;
+        numRows = 4;
+        break;
+    case GL_FLOAT_MAT2x3:
+        elemType = GL_FLOAT;
+        numCols = 2;
+        numRows = 3;
+        break;
+    case GL_FLOAT_MAT2x4:
+        elemType = GL_FLOAT;
+        numCols = 2;
+        numRows = 4;
+        break;
+    case GL_FLOAT_MAT3x2:
+        elemType = GL_FLOAT;
+        numCols = 3;
+        numRows = 2;
+        break;
+    case GL_FLOAT_MAT3x4:
+        elemType = GL_FLOAT;
+        numCols = 3;
+        numRows = 4;
+        break;
+    case GL_FLOAT_MAT4x2:
+        elemType = GL_FLOAT;
+        numCols = 4;
+        numRows = 2;
+        break;
+    case GL_FLOAT_MAT4x3:
+        elemType = GL_FLOAT;
+        numCols = 4;
+        numRows = 3;
+        break;
+    case GL_DOUBLE_MAT2:
+        elemType = GL_DOUBLE;
+        numCols = 2;
+        numRows = 2;
+        break;
+    case GL_DOUBLE_MAT3:
+        elemType = GL_DOUBLE;
+        numCols = 3;
+        numRows = 3;
+        break;
+    case GL_DOUBLE_MAT4:
+        elemType = GL_DOUBLE;
+        numCols = 4;
+        numRows = 4;
+        break;
+    case GL_DOUBLE_MAT2x3:
+        elemType = GL_DOUBLE;
+        numCols = 2;
+        numRows = 3;
+        break;
+    case GL_DOUBLE_MAT2x4:
+        elemType = GL_DOUBLE;
+        numCols = 2;
+        numRows = 4;
+        break;
+    case GL_DOUBLE_MAT3x2:
+        elemType = GL_DOUBLE;
+        numCols = 3;
+        numRows = 2;
+        break;
+    case GL_DOUBLE_MAT3x4:
+        elemType = GL_DOUBLE;
+        numCols = 3;
+        numRows = 4;
+        break;
+    case GL_DOUBLE_MAT4x2:
+        elemType = GL_DOUBLE;
+        numCols = 4;
+        numRows = 2;
+        break;
+    case GL_DOUBLE_MAT4x3:
+        elemType = GL_DOUBLE;
+        numCols = 4;
+        numRows = 3;
+        break;
+    case GL_SAMPLER_1D:
+    case GL_SAMPLER_2D:
+    case GL_SAMPLER_3D:
+    case GL_SAMPLER_CUBE:
+    case GL_SAMPLER_1D_SHADOW:
+    case GL_SAMPLER_2D_SHADOW:
+    case GL_SAMPLER_1D_ARRAY:
+    case GL_SAMPLER_2D_ARRAY:
+    case GL_SAMPLER_CUBE_MAP_ARRAY:
+    case GL_SAMPLER_1D_ARRAY_SHADOW:
+    case GL_SAMPLER_2D_ARRAY_SHADOW:
+    case GL_SAMPLER_2D_MULTISAMPLE:
+    case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
+    case GL_SAMPLER_CUBE_SHADOW:
+    case GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW:
+    case GL_SAMPLER_BUFFER:
+    case GL_SAMPLER_2D_RECT:
+    case GL_SAMPLER_2D_RECT_SHADOW:
+    case GL_INT_SAMPLER_1D:
+    case GL_INT_SAMPLER_2D:
+    case GL_INT_SAMPLER_3D:
+    case GL_INT_SAMPLER_CUBE:
+    case GL_INT_SAMPLER_1D_ARRAY:
+    case GL_INT_SAMPLER_2D_ARRAY:
+    case GL_INT_SAMPLER_CUBE_MAP_ARRAY:
+    case GL_INT_SAMPLER_2D_MULTISAMPLE:
+    case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
+    case GL_INT_SAMPLER_BUFFER:
+    case GL_INT_SAMPLER_2D_RECT:
+    case GL_UNSIGNED_INT_SAMPLER_1D:
+    case GL_UNSIGNED_INT_SAMPLER_2D:
+    case GL_UNSIGNED_INT_SAMPLER_3D:
+    case GL_UNSIGNED_INT_SAMPLER_CUBE:
+    case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
+    case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+    case GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY:
+    case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
+    case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
+    case GL_UNSIGNED_INT_SAMPLER_BUFFER:
+    case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
+        elemType = GL_INT;
+        break;
+    default:
+        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
+        elemType = GL_NONE;
+        numCols = 0;
+        numRows = 0;
+        return;
+    }
+}
+    
+static inline size_t
+_glArrayPointer_size(GLint size, GLenum type, GLsizei stride, GLsizei count)
+{
+    if (!count) {
+        return 0;
+    }
+
+    size_t elementSize = size*_gl_type_size(type);
+    if (!stride) {
+        stride = (GLsizei)elementSize;
+    }
+
+    return stride*(count - 1) + elementSize;
+}
+
+#define _glVertexPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
+#define _glNormalPointer_size(type, stride, count) _glArrayPointer_size(3, type, stride, count)
+#define _glColorPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
+#define _glIndexPointer_size(type, stride, count) _glArrayPointer_size(1, type, stride, count)
+#define _glTexCoordPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
+#define _glEdgeFlagPointer_size(stride, count) _glArrayPointer_size(1, GL_BOOL, stride, count)
+#define _glFogCoordPointer_size(type, stride, count) _glArrayPointer_size(1, type, stride, count)
+#define _glSecondaryColorPointer_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
+#define _glVertexAttribPointer_size(size, type, normalized, stride, count) _glArrayPointer_size(size, type, stride, count)
+#define _glVertexAttribPointerARB_size(size, type, normalized, stride, count) _glArrayPointer_size(size, type, stride, count)
+#define _glVertexAttribPointerNV_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count)
+
+static inline GLuint
+_glDrawArrays_count(GLint first, GLsizei count)
+{
+    if (!count) {
+        return 0;
+    }
+    return first + count;
+}
+
+#define _glDrawArraysEXT_count _glDrawArrays_count
+
+static inline GLuint
+_glDrawElementsBaseVertex_count(GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex)
+{
+    GLvoid *temp = 0;
+    GLint element_array_buffer = 0;
+
+    if (!count) {
+        return 0;
+    }
+
+    _glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &element_array_buffer);
+    if (element_array_buffer) {
+        // Read indices from index buffer object
+        GLintptr offset = (GLintptr)indices;
+        GLsizeiptr size = count*_gl_type_size(type);
+        GLvoid *temp = malloc(size);
+        if (!temp) {
+            return 0;
+        }
+        memset(temp, 0, size);
+        _glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, offset, size, temp);
+        indices = temp;
+    } else {
+        if (!indices) {
+            return 0;
+        }
+    }
+
+    GLuint maxindex = 0;
+    GLsizei i;
+    if (type == GL_UNSIGNED_BYTE) {
+        const GLubyte *p = (const GLubyte *)indices;
+        for (i = 0; i < count; ++i) {
+            if (p[i] > maxindex) {
+                maxindex = p[i];
+            }
+        }
+    } else if (type == GL_UNSIGNED_SHORT) {
+        const GLushort *p = (const GLushort *)indices;
+        for (i = 0; i < count; ++i) {
+            if (p[i] > maxindex) {
+                maxindex = p[i];
+            }
+        }
+    } else if (type == GL_UNSIGNED_INT) {
+        const GLuint *p = (const GLuint *)indices;
+        for (i = 0; i < count; ++i) {
+            if (p[i] > maxindex) {
+                maxindex = p[i];
+            }
+        }
+    } else {
+        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, type);
+    }
+
+    if (element_array_buffer) {
+        free(temp);
+    }
+
+    maxindex += basevertex;
+
+    return maxindex + 1;
+}
+
+#define _glDrawRangeElementsBaseVertex_count(start, end, count, type, indices, basevertex) _glDrawElementsBaseVertex_count(count, type, indices, basevertex)
+
+#define _glDrawElements_count(count, type, indices) _glDrawElementsBaseVertex_count(count, type, indices, 0);
+#define _glDrawRangeElements_count(start, end, count, type, indices) _glDrawElements_count(count, type, indices)
+#define _glDrawRangeElementsEXT_count _glDrawRangeElements_count
+
+/* FIXME take in consideration instancing */
+#define _glDrawArraysInstanced_count(first, count, primcount) _glDrawArrays_count(first, count)
+#define _glDrawElementsInstanced_count(count, type, indices, primcount) _glDrawElements_count(count, type, indices)
+#define _glDrawElementsInstancedBaseVertex_count(count, type, indices, primcount, basevertex) _glDrawElementsBaseVertex_count(count, type, indices, basevertex)
+#define _glDrawRangeElementsInstanced_count(start, end, count, type, indices, primcount) _glDrawRangeElements_count(start, end, count, type, indices)
+#define _glDrawRangeElementsInstancedBaseVertex_count(start, end, count, type, indices, primcount, basevertex) _glDrawRangeElementsBaseVertex_count(start, end, count, type, indices, basevertex)
+
+#define _glDrawArraysInstancedBaseInstance_count(first, count, primcount, baseinstance) _glDrawArrays_count(first, count)
+#define _glDrawElementsInstancedBaseInstance_count(count, type, indices, primcount, baseinstance) _glDrawElements_count(count, type, indices)
+#define _glDrawElementsInstancedBaseVertexBaseInstance_count(count, type, indices, primcount, basevertex, baseinstance) _glDrawElementsBaseVertex_count(count, type, indices, basevertex)
+
+#define _glDrawArraysInstancedARB_count _glDrawArraysInstanced_count
+#define _glDrawElementsInstancedARB_count _glDrawElementsInstanced_count
+#define _glDrawArraysInstancedEXT_count _glDrawArraysInstanced_count
+#define _glDrawElementsInstancedEXT_count _glDrawElementsInstanced_count
+
+static inline GLuint
+_glDrawArraysIndirect_count(const GLvoid *indirect) {
+    os::log("apitrace: warning: %s: unsupported\n", __FUNCTION__);
+    return 0;
+}
+
+static inline GLuint
+_glDrawElementsIndirect_count(GLenum type, const GLvoid *indirect) {
+    os::log("apitrace: warning: %s: unsupported\n", __FUNCTION__);
+    return 0;
+}
+
+static inline GLuint
+_glMultiDrawArrays_count(const GLint *first, const GLsizei *count, GLsizei drawcount) {
+    GLuint _count = 0;
+    for (GLsizei draw = 0; draw < drawcount; ++draw) {
+        GLuint _count_draw = _glDrawArrays_count(first[draw], count[draw]);
+        _count = std::max(_count, _count_draw);
+    }
+    return _count;
+}
+
+static inline GLuint
+_glMultiDrawElements_count(const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount) {
+    GLuint _count = 0;
+    for (GLsizei draw = 0; draw < drawcount; ++draw) {
+        GLuint _count_draw = _glDrawElements_count(count[draw], type, indices[draw]);
+        _count = std::max(_count, _count_draw);
+    }
+    return _count;
+}
+
+static inline GLuint
+_glMultiDrawElementsBaseVertex_count(const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint * basevertex) {
+    GLuint _count = 0;
+    for (GLsizei draw = 0; draw < drawcount; ++draw) {
+        GLuint _count_draw = _glDrawElementsBaseVertex_count(count[draw], type, indices[draw], basevertex[draw]);
+        _count = std::max(_count, _count_draw);
+    }
+    return _count;
+}
+
+#define _glMultiDrawArraysEXT_count _glMultiDrawArrays_count
+#define _glMultiDrawElementsEXT_count _glMultiDrawElements_count
+
+#define _glMultiModeDrawArraysIBM_count(first, count, drawcount, modestride) _glMultiDrawArrays_count(first, count, drawcount)
+#define _glMultiModeDrawElementsIBM_count(count, type, indices, drawcount, modestride) _glMultiDrawElements_count(count, type, (const GLvoid **)indices, drawcount)
+
+
+static inline size_t
+_glCallLists_size(GLsizei n, GLenum type)
+{
+    return n*_gl_type_size(type);
+}
+
+static inline size_t
+_glMap1d_size(GLenum target, GLint stride, GLint order)
+{
+    if (order < 1) {
+        return 0;
+    }
+
+    GLint channels;
+    switch (target) {
+    case GL_MAP1_INDEX:
+    case GL_MAP1_TEXTURE_COORD_1:
+        channels = 1;
+        break;
+    case GL_MAP1_TEXTURE_COORD_2:
+        channels = 2;
+        break;
+    case GL_MAP1_NORMAL:
+    case GL_MAP1_TEXTURE_COORD_3:
+    case GL_MAP1_VERTEX_3:
+        channels = 3;
+        break;
+    case GL_MAP1_COLOR_4:
+    case GL_MAP1_TEXTURE_COORD_4:
+    case GL_MAP1_VERTEX_4:
+        channels = 4;
+        break;
+    default:
+        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target);
+        return 0;
+    }
+
+    if (stride < channels) {
+        return 0;
+    }
+
+    return channels + stride * (order - 1);
+}
+
+#define _glMap1f_size _glMap1d_size
+
+static inline size_t
+_glMap2d_size(GLenum target, GLint ustride, GLint uorder, GLint vstride, GLint vorder)
+{
+    if (uorder < 1 || vorder < 1) {
+        return 0;
+    }
+
+    GLint channels;
+    switch (target) {
+    case GL_MAP2_INDEX:
+    case GL_MAP2_TEXTURE_COORD_1:
+        channels = 1;
+        break;
+    case GL_MAP2_TEXTURE_COORD_2:
+        channels = 2;
+        break;
+    case GL_MAP2_NORMAL:
+    case GL_MAP2_TEXTURE_COORD_3:
+    case GL_MAP2_VERTEX_3:
+        channels = 3;
+        break;
+    case GL_MAP2_COLOR_4:
+    case GL_MAP2_TEXTURE_COORD_4:
+    case GL_MAP2_VERTEX_4:
+        channels = 4;
+        break;
+    default:
+        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, target);
+        return 0;
+    }
+
+    if (ustride < channels || vstride < channels) {
+        return 0;
+    }
+
+    return channels + 
+           ustride * (uorder - 1) +
+           vstride * (vorder - 1);
+}
+
+#define _glMap2f_size _glMap2d_size
+
+static inline unsigned
+_gl_format_channels(GLenum format) {
+    switch (format) {
+    case GL_COLOR_INDEX:
+    case GL_RED:
+    case GL_GREEN:
+    case GL_BLUE:
+    case GL_ALPHA:
+    case GL_INTENSITY:
+    case GL_LUMINANCE:
+    case GL_DEPTH_COMPONENT:
+    case GL_STENCIL_INDEX:
+        return 1;
+    case GL_DEPTH_STENCIL:
+    case GL_LUMINANCE_ALPHA:
+    case GL_RG:
+    case GL_HILO_NV:
+    case GL_DSDT_NV:
+        return 2;
+    case GL_RGB:
+    case GL_BGR:
+    case GL_DSDT_MAG_NV:
+        return 3;
+    case GL_RGBA:
+    case GL_BGRA:
+    case GL_ABGR_EXT:
+    case GL_CMYK_EXT:
+    case GL_DSDT_MAG_VIB_NV:
+        return 4;
+    case GL_CMYKA_EXT:
+        return 5;
+    default:
+        os::log("apitrace: warning: %s: unexpected format GLenum 0x%04X\n", __FUNCTION__, format);
+        return 0;
+    }
+}
+
+template<class X>
+static inline bool
+_is_pot(X x) {
+    return (x & (x - 1)) == 0;
+}
+
+template<class X, class Y>
+static inline X
+_align(X x, Y y) {
+    return (x + (y - 1)) & ~(y - 1);
+}
+
+static inline size_t
+_gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLboolean has_unpack_subimage) {
+    unsigned num_channels = _gl_format_channels(format);
+
+    unsigned bits_per_element;
+    unsigned bits_per_pixel;
+    switch (type) {
+    case GL_BITMAP:
+        bits_per_pixel = bits_per_element = 1;
+        break;
+    case GL_BYTE:
+    case GL_UNSIGNED_BYTE:
+        bits_per_element = 8;
+        bits_per_pixel = bits_per_element * num_channels;
+        break;
+    case GL_SHORT:
+    case GL_UNSIGNED_SHORT:
+    case GL_HALF_FLOAT:
+        bits_per_element = 16;
+        bits_per_pixel = bits_per_element * num_channels;
+        break;
+    case GL_INT:
+    case GL_UNSIGNED_INT:
+    case GL_FLOAT:
+        bits_per_element = 32;
+        bits_per_pixel = bits_per_element * num_channels;
+        break;
+    case GL_UNSIGNED_BYTE_3_3_2:
+    case GL_UNSIGNED_BYTE_2_3_3_REV:
+        bits_per_pixel = bits_per_element = 8;
+        break;
+    case GL_UNSIGNED_SHORT_4_4_4_4:
+    case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+    case GL_UNSIGNED_SHORT_5_5_5_1:
+    case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+    case GL_UNSIGNED_SHORT_5_6_5:
+    case GL_UNSIGNED_SHORT_5_6_5_REV:
+    case GL_UNSIGNED_SHORT_8_8_MESA:
+    case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+        bits_per_pixel = bits_per_element = 16;
+        break;
+    case GL_UNSIGNED_INT_8_8_8_8:
+    case GL_UNSIGNED_INT_8_8_8_8_REV:
+    case GL_UNSIGNED_INT_10_10_10_2:
+    case GL_UNSIGNED_INT_2_10_10_10_REV:
+    case GL_UNSIGNED_INT_24_8:
+    case GL_UNSIGNED_INT_10F_11F_11F_REV:
+    case GL_UNSIGNED_INT_5_9_9_9_REV:
+    case GL_UNSIGNED_INT_S8_S8_8_8_NV:
+    case GL_UNSIGNED_INT_8_8_S8_S8_REV_NV:
+        bits_per_pixel = bits_per_element = 32;
+        break;
+    case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
+        bits_per_pixel = bits_per_element = 64;
+        break;
+    default:
+        os::log("apitrace: warning: %s: unexpected type GLenum 0x%04X\n", __FUNCTION__, type);
+        bits_per_pixel = bits_per_element = 0;
+        break;
+    }
+
+    GLint alignment = 4;
+    GLint row_length = 0;
+    GLint image_height = 0;
+    GLint skip_rows = 0;
+    GLint skip_pixels = 0;
+    GLint skip_images = 0;
+
+    _glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+    if (has_unpack_subimage) {
+        _glGetIntegerv(GL_UNPACK_ROW_LENGTH,   &row_length);
+        _glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &image_height);
+        _glGetIntegerv(GL_UNPACK_SKIP_ROWS,    &skip_rows);
+        _glGetIntegerv(GL_UNPACK_SKIP_PIXELS,  &skip_pixels);
+        _glGetIntegerv(GL_UNPACK_SKIP_IMAGES,  &skip_images);
+    }
+
+    if (row_length <= 0) {
+        row_length = width;
+    }
+
+    size_t row_stride = (row_length*bits_per_pixel + 7)/8;
+
+    if ((bits_per_element == 1*8 ||
+         bits_per_element == 2*8 ||
+         bits_per_element == 4*8 ||
+         bits_per_element == 8*8) &&
+        (GLint)bits_per_element < alignment*8) {
+        row_stride = _align(row_stride, alignment);
+    }
+
+    if (image_height <= 0) {
+        image_height = height;
+    }
+
+    /* XXX: GL_UNPACK_IMAGE_HEIGHT and GL_UNPACK_SKIP_IMAGES should probably
+     * not be considered for pixel rectangles. */
+
+    size_t image_stride = image_height*row_stride;
+
+    size_t size = depth*image_stride;
+
+    size += (skip_pixels*bits_per_pixel + 7)/8;
+    size += skip_rows*row_stride;
+    size += skip_images*image_stride;
+
+    return size;
+}
+
+// note that can_unpack_subimage() is generated by gltrace.py
+#define _glTexImage3D_size(format, type, width, height, depth) _gl_image_size(format, type, width, height, depth, can_unpack_subimage())
+#define _glTexImage2D_size(format, type, width, height)        _gl_image_size(format, type, width, height, 1, can_unpack_subimage())
+#define _glTexImage1D_size(format, type, width)                _gl_image_size(format, type, width, 1, 1, can_unpack_subimage())
+
+#define _glTexSubImage3D_size(format, type, width, height, depth) _glTexImage3D_size(format, type, width, height, depth)
+#define _glTexSubImage2D_size(format, type, width, height)        _glTexImage2D_size(format, type, width, height)
+#define _glTexSubImage1D_size(format, type, width)                _glTexImage1D_size(format, type, width)
+
+#define _glTexImage3DEXT_size _glTexImage3D_size
+#define _glTexImage2DEXT_size _glTexImage2D_size
+#define _glTexImage1DEXT_size _glTexImage1D_size
+#define _glTexSubImage3DEXT_size _glTexSubImage3D_size
+#define _glTexSubImage2DEXT_size _glTexSubImage2D_size
+#define _glTexSubImage1DEXT_size _glTexSubImage1D_size
+
+#define _glTextureImage3DEXT_size _glTexImage3D_size
+#define _glTextureImage2DEXT_size _glTexImage2D_size
+#define _glTextureImage1DEXT_size _glTexImage1D_size
+#define _glTextureSubImage3DEXT_size _glTexSubImage3D_size
+#define _glTextureSubImage2DEXT_size _glTexSubImage2D_size
+#define _glTextureSubImage1DEXT_size _glTexSubImage1D_size
+
+#define _glMultiTexImage3DEXT_size _glTexImage3D_size
+#define _glMultiTexImage2DEXT_size _glTexImage2D_size
+#define _glMultiTexImage1DEXT_size _glTexImage1D_size
+#define _glMultiTexSubImage3DEXT_size _glTexSubImage3D_size
+#define _glMultiTexSubImage2DEXT_size _glTexSubImage2D_size
+#define _glMultiTexSubImage1DEXT_size _glTexSubImage1D_size
+
+#define _glDrawPixels_size(format, type, width, height) _glTexImage2D_size(format, type, width, height)
+#define _glConvolutionFilter1D_size(format, type, width) _glTexImage1D_size(format, type, width)
+#define _glConvolutionFilter2D_size(format, type, width, height) _glTexImage2D_size(format, type, width, height)
+#define _glColorTable_size(format, type, width) _glTexImage1D_size(format, type, width)
+#define _glColorSubTable_size(format, type, count) _glColorTable_size(format, type, count)
+
+#define _glBitmap_size(width, height) _glTexImage2D_size(GL_COLOR_INDEX, GL_BITMAP, width, height)
+#define _glPolygonStipple_size() _glBitmap_size(32, 32)
+
+static inline size_t
+_glClearBuffer_size(GLenum buffer)
+{
+    switch (buffer) {
+    case GL_COLOR:
+    case GL_FRONT:
+    case GL_BACK:
+    case GL_LEFT:
+    case GL_RIGHT:
+    case GL_FRONT_AND_BACK:
+        return 4;
+    case GL_DEPTH:
+    case GL_STENCIL:
+        return 1;
+    default:
+        os::log("apitrace: warning: %s: unexpected buffer GLenum 0x%04X\n", __FUNCTION__, buffer);
+        return 0;
+    }
+}
+
+/* 
+ * attribute list, terminated by the given terminator.
+ */
+template<class T>
+static inline size_t
+_AttribList_size(const T *pAttribList, const T terminator = static_cast<T>(0))
+{
+    size_t size = 0;
+
+    if (pAttribList) {
+        do {
+            ++size;
+        } while (*pAttribList++ != terminator);
+    }
+
+    return size;
+}
+
+
+/*
+ * (key, value) attribute list, terminated by the given terminator.
+ */
+template<class T>
+static inline size_t
+_AttribPairList_size(const T *pAttribList, const T terminator = static_cast<T>(0))
+{
+    size_t size = 0;
+
+    if (pAttribList) {
+        while (pAttribList[size] != terminator) {
+            size += 2;
+        }
+        // terminator also counts
+        ++size;
+    }
+
+    return size;
+}
+
+
+#endif /* _GL_SIZE_HPP_ */
diff --git a/retrace.cpp b/retrace.cpp
deleted file mode 100644 (file)
index d2e6d37..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <string.h>
-#include <iostream>
-
-#include "os_time.hpp"
-#include "trace_dump.hpp"
-#include "retrace.hpp"
-
-
-namespace retrace {
-
-
-int verbosity = 0;
-bool profiling = false;
-
-
-static bool call_dumped = false;
-
-
-static void dumpCall(trace::Call &call) {
-    if (verbosity >= 0 && !call_dumped) {
-        std::cout << call;
-        std::cout.flush();
-        call_dumped = true;
-    }
-}
-
-
-std::ostream &warning(trace::Call &call) {
-    dumpCall(call);
-
-    std::cerr << call.no << ": ";
-    std::cerr << "warning: ";
-
-    return std::cerr;
-}
-
-
-void ignore(trace::Call &call) {
-    (void)call;
-}
-
-void unsupported(trace::Call &call) {
-    warning(call) << "unsupported " << call.name() << " call\n";
-}
-
-inline void Retracer::addCallback(const Entry *entry) {
-    assert(entry->name);
-    assert(entry->callback);
-    map[entry->name] = entry->callback;
-}
-
-
-void Retracer::addCallbacks(const Entry *entries) {
-    while (entries->name && entries->callback) {
-        addCallback(entries++);
-    }
-}
-
-
-void Retracer::retrace(trace::Call &call) {
-    call_dumped = false;
-
-    if (verbosity >= 1) {
-        if (verbosity >= 2 ||
-            !(call.flags & trace::CALL_FLAG_VERBOSE)) {
-            dumpCall(call);
-        }
-    }
-
-    Callback callback = 0;
-
-    trace::Id id = call.sig->id;
-    if (id >= callbacks.size()) {
-        callbacks.resize(id + 1);
-        callback = 0;
-    } else {
-        callback = callbacks[id];
-    }
-
-    if (!callback) {
-        Map::const_iterator it = map.find(call.name());
-        if (it == map.end()) {
-            callback = &unsupported;
-        } else {
-            callback = it->second;
-        }
-        callbacks[id] = callback;
-    }
-
-    assert(callback);
-    assert(callbacks[id] == callback);
-
-    if (retrace::profiling) {
-        long long startTime = os::getTime();
-        callback(call);
-        long long stopTime = os::getTime();
-        float timeInterval = (stopTime - startTime) * (1.0E6 / os::timeFrequency);
-
-        std::cout
-            << call.no << " "
-            << "[" << timeInterval << " usec] "
-        ;
-        trace::dump(call, std::cout, trace::DUMP_FLAG_NO_CALL_NO | trace::DUMP_FLAG_NO_COLOR);
-    } else {
-        callback(call);
-    }
-}
-
-
-} /* namespace retrace */
diff --git a/retrace.hpp b/retrace.hpp
deleted file mode 100644 (file)
index 57b8b05..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _RETRACE_HPP_
-#define _RETRACE_HPP_
-
-#include <string.h>
-
-#include <list>
-#include <map>
-#include <ostream>
-
-#include "trace_model.hpp"
-
-
-namespace retrace {
-
-
-/**
- * Handle map.
- *
- * It is just like a regular std::map<T, T> container, but lookups of missing
- * keys return the key instead of default constructor.
- *
- * This is necessary for several GL named objects, where one can either request
- * the implementation to generate an unique name, or pick a value never used
- * before.
- *
- * XXX: In some cases, instead of returning the key, it would make more sense
- * to return an unused data value (e.g., container count).
- */
-template <class T>
-class map
-{
-private:
-    typedef std::map<T, T> base_type;
-    base_type base;
-
-public:
-
-    T & operator[] (const T &key) {
-        typename base_type::iterator it;
-        it = base.find(key);
-        if (it == base.end()) {
-            return (base[key] = key);
-        }
-        return it->second;
-    }
-    
-    const T & operator[] (const T &key) const {
-        typename base_type::const_iterator it;
-        it = base.find(key);
-        if (it == base.end()) {
-            return (base[key] = key);
-        }
-        return it->second;
-    }
-};
-
-
-void
-addRegion(unsigned long long address, void *buffer, unsigned long long size);
-
-void
-delRegionByPointer(void *ptr);
-
-void *
-toPointer(trace::Value &value, bool bind = false);
-
-
-/**
- * Output verbosity when retracing files.
- */
-extern int verbosity;
-
-/**
- * Add profiling data to the dump when retracing.
- */
-extern bool profiling;
-
-
-std::ostream &warning(trace::Call &call);
-
-
-void ignore(trace::Call &call);
-void unsupported(trace::Call &call);
-
-
-typedef void (*Callback)(trace::Call &call);
-
-struct Entry {
-    const char *name;
-    Callback callback;
-};
-
-
-struct stringComparer {
-  bool operator() (const char *a, const  char *b) const {
-    return strcmp(a, b) < 0;
-  }
-};
-
-
-extern const Entry stdc_callbacks[];
-
-
-class Retracer
-{
-    typedef std::map<const char *, Callback, stringComparer> Map;
-    Map map;
-
-    std::vector<Callback> callbacks;
-
-public:
-    Retracer() {
-        addCallbacks(stdc_callbacks);
-    }
-
-    virtual ~Retracer() {}
-
-    void addCallback(const Entry *entry);
-    void addCallbacks(const Entry *entries);
-
-    void retrace(trace::Call &call);
-};
-
-
-} /* namespace retrace */
-
-#endif /* _RETRACE_HPP_ */
diff --git a/retrace.py b/retrace.py
deleted file mode 100644 (file)
index 25e2609..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-##########################################################################
-#
-# Copyright 2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""Generic retracing code generator."""
-
-
-import sys
-
-import specs.stdapi as stdapi
-import specs.glapi as glapi
-
-
-class ConstRemover(stdapi.Rebuilder):
-    '''Type visitor which strips out const qualifiers from types.'''
-
-    def visitConst(self, const):
-        return const.type
-
-    def visitOpaque(self, opaque):
-        return opaque
-
-
-def lookupHandle(handle, value):
-    if handle.key is None:
-        return "__%s_map[%s]" % (handle.name, value)
-    else:
-        key_name, key_type = handle.key
-        return "__%s_map[%s][%s]" % (handle.name, key_name, value)
-
-
-class ValueDeserializer(stdapi.Visitor):
-
-    def visitLiteral(self, literal, lvalue, rvalue):
-        print '    %s = (%s).to%s();' % (lvalue, rvalue, literal.kind)
-
-    def visitConst(self, const, lvalue, rvalue):
-        self.visit(const.type, lvalue, rvalue)
-
-    def visitAlias(self, alias, lvalue, rvalue):
-        self.visit(alias.type, lvalue, rvalue)
-    
-    def visitEnum(self, enum, lvalue, rvalue):
-        print '    %s = (%s).toSInt();' % (lvalue, rvalue)
-
-    def visitBitmask(self, bitmask, lvalue, rvalue):
-        self.visit(bitmask.type, lvalue, rvalue)
-
-    def visitArray(self, array, lvalue, rvalue):
-        print '    const trace::Array *__a%s = dynamic_cast<const trace::Array *>(&%s);' % (array.tag, rvalue)
-        print '    if (__a%s) {' % (array.tag)
-        length = '__a%s->values.size()' % array.tag
-        print '        %s = new %s[%s];' % (lvalue, array.type, length)
-        index = '__j' + array.tag
-        print '        for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)
-        try:
-            self.visit(array.type, '%s[%s]' % (lvalue, index), '*__a%s->values[%s]' % (array.tag, index))
-        finally:
-            print '        }'
-            print '    } else {'
-            print '        %s = NULL;' % lvalue
-            print '    }'
-    
-    def visitPointer(self, pointer, lvalue, rvalue):
-        print '    const trace::Array *__a%s = dynamic_cast<const trace::Array *>(&%s);' % (pointer.tag, rvalue)
-        print '    if (__a%s) {' % (pointer.tag)
-        print '        %s = new %s;' % (lvalue, pointer.type)
-        try:
-            self.visit(pointer.type, '%s[0]' % (lvalue,), '*__a%s->values[0]' % (pointer.tag,))
-        finally:
-            print '    } else {'
-            print '        %s = NULL;' % lvalue
-            print '    }'
-
-    def visitIntPointer(self, pointer, lvalue, rvalue):
-        print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue)
-
-    def visitLinearPointer(self, pointer, lvalue, rvalue):
-        print '    %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue)
-
-    def visitHandle(self, handle, lvalue, rvalue):
-        #OpaqueValueDeserializer().visit(handle.type, lvalue, rvalue);
-        self.visit(handle.type, lvalue, rvalue);
-        new_lvalue = lookupHandle(handle, lvalue)
-        print '    if (retrace::verbosity >= 2) {'
-        print '        std::cout << "%s " << size_t(%s) << " <- " << size_t(%s) << "\\n";' % (handle.name, lvalue, new_lvalue)
-        print '    }'
-        print '    %s = %s;' % (lvalue, new_lvalue)
-    
-    def visitBlob(self, blob, lvalue, rvalue):
-        print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, blob, rvalue)
-    
-    def visitString(self, string, lvalue, rvalue):
-        print '    %s = (%s)((%s).toString());' % (lvalue, string.expr, rvalue)
-
-
-class OpaqueValueDeserializer(ValueDeserializer):
-    '''Value extractor that also understands opaque values.
-
-    Normally opaque values can't be retraced, unless they are being extracted
-    in the context of handles.'''
-
-    def visitOpaque(self, opaque, lvalue, rvalue):
-        print '    %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, opaque, rvalue)
-
-
-class SwizzledValueRegistrator(stdapi.Visitor):
-    '''Type visitor which will register (un)swizzled value pairs, to later be
-    swizzled.'''
-
-    def visitLiteral(self, literal, lvalue, rvalue):
-        pass
-
-    def visitAlias(self, alias, lvalue, rvalue):
-        self.visit(alias.type, lvalue, rvalue)
-    
-    def visitEnum(self, enum, lvalue, rvalue):
-        pass
-
-    def visitBitmask(self, bitmask, lvalue, rvalue):
-        pass
-
-    def visitArray(self, array, lvalue, rvalue):
-        print '    const trace::Array *__a%s = dynamic_cast<const trace::Array *>(&%s);' % (array.tag, rvalue)
-        print '    if (__a%s) {' % (array.tag)
-        length = '__a%s->values.size()' % array.tag
-        index = '__j' + array.tag
-        print '        for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)
-        try:
-            self.visit(array.type, '%s[%s]' % (lvalue, index), '*__a%s->values[%s]' % (array.tag, index))
-        finally:
-            print '        }'
-            print '    }'
-    
-    def visitPointer(self, pointer, lvalue, rvalue):
-        print '    const trace::Array *__a%s = dynamic_cast<const trace::Array *>(&%s);' % (pointer.tag, rvalue)
-        print '    if (__a%s) {' % (pointer.tag)
-        try:
-            self.visit(pointer.type, '%s[0]' % (lvalue,), '*__a%s->values[0]' % (pointer.tag,))
-        finally:
-            print '    }'
-    
-    def visitIntPointer(self, pointer, lvalue, rvalue):
-        pass
-    
-    def visitLinearPointer(self, pointer, lvalue, rvalue):
-        assert pointer.size is not None
-        if pointer.size is not None:
-            print r'    retrace::addRegion((%s).toUIntPtr(), %s, %s);' % (rvalue, lvalue, pointer.size)
-
-    def visitHandle(self, handle, lvalue, rvalue):
-        print '    %s __orig_result;' % handle.type
-        OpaqueValueDeserializer().visit(handle.type, '__orig_result', rvalue);
-        if handle.range is None:
-            rvalue = "__orig_result"
-            entry = lookupHandle(handle, rvalue) 
-            print "    %s = %s;" % (entry, lvalue)
-            print '    if (retrace::verbosity >= 2) {'
-            print '        std::cout << "{handle.name} " << {rvalue} << " -> " << {lvalue} << "\\n";'.format(**locals())
-            print '    }'
-        else:
-            i = '__h' + handle.tag
-            lvalue = "%s + %s" % (lvalue, i)
-            rvalue = "__orig_result + %s" % (i,)
-            entry = lookupHandle(handle, rvalue) 
-            print '    for ({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals())
-            print '        {entry} = {lvalue};'.format(**locals())
-            print '        if (retrace::verbosity >= 2) {'
-            print '            std::cout << "{handle.name} " << ({rvalue}) << " -> " << ({lvalue}) << "\\n";'.format(**locals())
-            print '        }'
-            print '    }'
-    
-    def visitBlob(self, blob, lvalue, rvalue):
-        pass
-    
-    def visitString(self, string, lvalue, rvalue):
-        pass
-
-
-class Retracer:
-
-    def retraceFunction(self, function):
-        print 'static void retrace_%s(trace::Call &call) {' % function.name
-        self.retraceFunctionBody(function)
-        print '}'
-        print
-
-    def retraceFunctionBody(self, function):
-        if not function.sideeffects:
-            print '    (void)call;'
-            return
-
-        success = True
-        for arg in function.args:
-            arg_type = ConstRemover().visit(arg.type)
-            #print '    // %s ->  %s' % (arg.type, arg_type)
-            print '    %s %s;' % (arg_type, arg.name)
-            rvalue = 'call.arg(%u)' % (arg.index,)
-            lvalue = arg.name
-            try:
-                self.extractArg(function, arg, arg_type, lvalue, rvalue)
-            except NotImplementedError:
-                success = False
-                print '    %s = 0; // FIXME' % arg.name
-        if not success:
-            print '    if (1) {'
-            self.failFunction(function)
-            print '    }'
-        self.invokeFunction(function)
-        for arg in function.args:
-            if arg.output:
-                arg_type = ConstRemover().visit(arg.type)
-                rvalue = 'call.arg(%u)' % (arg.index,)
-                lvalue = arg.name
-                try:
-                    self.regiterSwizzledValue(arg_type, lvalue, rvalue)
-                except NotImplementedError:
-                    print '    // XXX: %s' % arg.name
-        if function.type is not stdapi.Void:
-            rvalue = '*call.ret'
-            lvalue = '__result'
-            try:
-                self.regiterSwizzledValue(function.type, lvalue, rvalue)
-            except NotImplementedError:
-                print '    // XXX: result'
-        if not success:
-            if function.name[-1].islower():
-                sys.stderr.write('warning: unsupported %s call\n' % function.name)
-
-    def failFunction(self, function):
-        print '    if (retrace::verbosity >= 0) {'
-        print '        retrace::unsupported(call);'
-        print '    }'
-        print '    return;'
-
-    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
-        ValueDeserializer().visit(arg_type, lvalue, rvalue)
-    
-    def extractOpaqueArg(self, function, arg, arg_type, lvalue, rvalue):
-        OpaqueValueDeserializer().visit(arg_type, lvalue, rvalue)
-
-    def regiterSwizzledValue(self, type, lvalue, rvalue):
-        visitor = SwizzledValueRegistrator()
-        visitor.visit(type, lvalue, rvalue)
-
-    def invokeFunction(self, function):
-        arg_names = ", ".join(function.argNames())
-        if function.type is not stdapi.Void:
-            print '    %s __result;' % (function.type)
-            print '    __result = %s(%s);' % (function.name, arg_names)
-            print '    (void)__result;'
-        else:
-            print '    %s(%s);' % (function.name, arg_names)
-
-    def filterFunction(self, function):
-        return True
-
-    table_name = 'retrace::callbacks'
-
-    def retraceFunctions(self, functions):
-        functions = filter(self.filterFunction, functions)
-
-        for function in functions:
-            self.retraceFunction(function)
-
-        print 'const retrace::Entry %s[] = {' % self.table_name
-        for function in functions:
-            print '    {"%s", &retrace_%s},' % (function.name, function.name)
-        print '    {NULL, NULL}'
-        print '};'
-        print
-
-
-    def retraceApi(self, api):
-
-        print '#include "trace_parser.hpp"'
-        print '#include "retrace.hpp"'
-        print
-
-        types = api.getAllTypes()
-        handles = [type for type in types if isinstance(type, stdapi.Handle)]
-        handle_names = set()
-        for handle in handles:
-            if handle.name not in handle_names:
-                if handle.key is None:
-                    print 'static retrace::map<%s> __%s_map;' % (handle.type, handle.name)
-                else:
-                    key_name, key_type = handle.key
-                    print 'static std::map<%s, retrace::map<%s> > __%s_map;' % (key_type, handle.type, handle.name)
-                handle_names.add(handle.name)
-        print
-
-        self.retraceFunctions(api.functions)
-
diff --git a/retrace/.gitignore b/retrace/.gitignore
new file mode 100644 (file)
index 0000000..ebcad87
--- /dev/null
@@ -0,0 +1,2 @@
+glretrace_gl.cpp
+glstate_params.cpp
diff --git a/retrace/CMakeLists.txt b/retrace/CMakeLists.txt
new file mode 100644 (file)
index 0000000..63fbed6
--- /dev/null
@@ -0,0 +1,161 @@
+##############################################################################
+# API retracers
+
+include_directories (
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_SOURCE_DIR}/helpers
+    ${CMAKE_BINARY_DIR}/dispatch
+    ${CMAKE_SOURCE_DIR}/dispatch
+)
+
+add_definitions (-DRETRACE)
+
+add_custom_command (
+    OUTPUT glretrace_gl.cpp
+    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glretrace_gl.cpp
+    DEPENDS
+                glretrace.py
+                retrace.py
+                ${CMAKE_SOURCE_DIR}/specs/glapi.py
+                ${CMAKE_SOURCE_DIR}/specs/gltypes.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+)
+
+add_custom_command (
+    OUTPUT glstate_params.cpp
+    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glstate_params.py > ${CMAKE_CURRENT_BINARY_DIR}/glstate_params.cpp
+    DEPENDS
+                glstate_params.py
+                ${CMAKE_SOURCE_DIR}/specs/glparams.py
+                ${CMAKE_SOURCE_DIR}/specs/gltypes.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+)
+
+add_library (retrace_common
+    retrace.cpp
+    retrace_main.cpp
+    retrace_stdc.cpp
+    retrace_swizzle.cpp
+)
+
+target_link_libraries (retrace_common
+    common
+    ${PNG_LIBRARIES}
+    ${ZLIB_LIBRARIES}
+    ${SNAPPY_LIBRARIES}
+)
+
+add_library (glretrace_common
+    glretrace_gl.cpp
+    glretrace_cgl.cpp
+    glretrace_glx.cpp
+    glretrace_wgl.cpp
+    glretrace_egl.cpp
+    glretrace_main.cpp
+    glretrace_ws.cpp
+    glstate.cpp
+    glstate_images.cpp
+    glstate_params.cpp
+    glstate_shaders.cpp
+    glws.cpp
+)
+
+add_dependencies (glretrace_common glproc)
+
+
+if (WIN32 OR APPLE OR X11_FOUND)
+    add_executable (glretrace
+        ${glws_os}
+    )
+
+    add_dependencies (glretrace glproc)
+
+    target_link_libraries (glretrace
+        retrace_common
+        glretrace_common
+        glproc_gl
+    )
+
+    if (WIN32)
+    else ()
+        if (APPLE)
+            target_link_libraries (glretrace
+                "-framework Cocoa"
+                "-framework ApplicationServices" # CGS*
+                #"-framework OpenGL" # CGL*
+            )
+        else ()
+            target_link_libraries (glretrace ${X11_X11_LIB})
+        endif ()
+
+        target_link_libraries (glretrace
+            # gdb doesn't like when pthreads is loaded through dlopen (which happens
+            # when dlopen'ing libGL), so link pthreads to avoid this issue.  See also
+            # http://stackoverflow.com/questions/2702628/gdb-cannot-find-new-threads-generic-error
+            ${CMAKE_THREAD_LIBS_INIT}
+            dl
+        )
+
+        if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+            target_link_libraries (glretrace rt)
+        endif ()
+
+    endif ()
+
+    install (TARGETS glretrace RUNTIME DESTINATION bin) 
+endif ()
+
+if (ENABLE_EGL AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
+    add_executable (eglretrace
+        glws_egl_xlib.cpp
+    )
+
+    add_dependencies (eglretrace glproc)
+
+    target_link_libraries (eglretrace
+        retrace_common
+        glretrace_common
+        glproc_egl
+        ${X11_X11_LIB}
+        ${CMAKE_THREAD_LIBS_INIT}
+        dl
+    )
+
+    if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+        target_link_libraries (eglretrace rt)
+    endif ()
+
+    install (TARGETS eglretrace RUNTIME DESTINATION bin) 
+endif ()
+
+if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
+    add_custom_command (
+        OUTPUT d3dretrace_d3d9.cpp
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3dretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp
+        DEPENDS
+                d3dretrace.py
+                dllretrace.py
+                retrace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d9.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d9types.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d9caps.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+    )
+
+    include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR})
+    add_executable (d3dretrace
+        d3dretrace_main.cpp
+        d3dretrace_d3d9.cpp
+        d3dretrace_ws.cpp
+        d3dstate.cpp
+        d3dstate_images.cpp
+    )
+    target_link_libraries (d3dretrace
+        retrace_common
+    )
+    
+    install (TARGETS d3dretrace RUNTIME DESTINATION bin) 
+endif ()
+
diff --git a/retrace/d3dretrace.hpp b/retrace/d3dretrace.hpp
new file mode 100644 (file)
index 0000000..b552c0b
--- /dev/null
@@ -0,0 +1,63 @@
+/**************************************************************************
+ *
+ * Copyright 2012 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _D3DRETRACE_HPP_
+#define _D3DRETRACE_HPP_
+
+
+#include <windows.h>
+
+#include "retrace.hpp"
+
+
+struct IDirect3DDevice9;
+
+
+extern const char *g_szD3D9DllName;
+
+
+namespace d3dretrace {
+
+
+extern IDirect3DDevice9 *pLastDirect3DDevice9;
+
+
+extern const retrace::Entry d3d9_callbacks[];
+
+
+HWND
+createWindow(int width, int height);
+
+void
+resizeWindow(HWND hWnd, int width, int height);
+
+bool
+processEvents(void);
+
+
+} /* namespace d3dretrace */
+
+
+#endif /* _D3DRETRACE_HPP_ */
diff --git a/retrace/d3dretrace.py b/retrace/d3dretrace.py
new file mode 100644 (file)
index 0000000..ddd37b9
--- /dev/null
@@ -0,0 +1,113 @@
+##########################################################################
+#
+# Copyright 2011 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""D3D retracer generator."""
+
+
+from dllretrace import DllRetracer as Retracer
+import specs.stdapi as stdapi
+from specs.d3d9 import *
+
+
+class D3DRetracer(Retracer):
+
+    def retraceApi(self, api):
+        print 'static const GUID GUID_D3DRETRACE = {0x7D71CAC9,0x7F58,0x432C,{0xA9,0x75,0xA1,0x9F,0xCF,0xCE,0xFD,0x14}};'
+        print
+
+        self.table_name = 'd3dretrace::%s_callbacks' % api.name.lower()
+
+        Retracer.retraceApi(self, api)
+
+    def invokeInterfaceMethod(self, interface, method):
+        # keep track of the last used device for state dumping
+        if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'):
+            print r'    d3dretrace::pLastDirect3DDevice9 = _this;'
+
+        # create windows as neccessary
+        if method.name in ('CreateDevice', 'CreateDeviceEx', 'CreateAdditionalSwapChain'):
+            print r'    HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);'
+            print r'    pPresentationParameters->hDeviceWindow = hWnd;'
+            if 'hFocusWindow' in method.argNames():
+                print r'    hFocusWindow = hWnd;'
+
+        if method.name in ('Reset', 'ResetEx'):
+            print r'    if (pPresentationParameters->Windowed) {'
+            print r'        d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);'
+            print r'    }'
+
+        # notify frame has been completed
+        if method.name == 'Present':
+            print r'    retrace::frameComplete(call);'
+            print r'    hDestWindowOverride = NULL;'
+
+        if 'pSharedHandle' in method.argNames():
+            print r'    if (pSharedHandle) {'
+            print r'        retrace::warning(call) << "shared surfaces unsupported\n";'
+            print r'        pSharedHandle = NULL;'
+            print r'    }'
+
+        Retracer.invokeInterfaceMethod(self, interface, method)
+
+        # process events after presents
+        if method.name == 'Present':
+            print r'    d3dretrace::processEvents();'
+
+        # check errors
+        if str(method.type) == 'HRESULT':
+            print r'    if (FAILED(_result)) {'
+            print r'        retrace::warning(call) << "failed\n";'
+            print r'    }'
+
+        if method.name in ('Lock', 'LockRect', 'LockBox'):
+            print '    VOID *_pbData = NULL;'
+            print '    size_t _LockedSize = 0;'
+            print '    _getLockInfo(_this, %s, _pbData, _LockedSize);' % ', '.join(method.argNames()[:-1])
+            print '    _this->SetPrivateData(GUID_D3DRETRACE, &_pbData, sizeof _pbData, 0);'
+        
+        if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'):
+            print '    VOID *_pbData = 0;'
+            print '    DWORD dwSizeOfData = sizeof _pbData;'
+            print '    _this->GetPrivateData(GUID_D3DRETRACE, &_pbData, &dwSizeOfData);'
+            print '    if (_pbData) {'
+            print '        retrace::delRegionByPointer(_pbData);'
+            print '    }'
+
+
+if __name__ == '__main__':
+    print r'''
+#include <string.h>
+
+#include <iostream>
+
+#include "d3d9imports.hpp"
+#include "d3dsize.hpp"
+#include "d3dretrace.hpp"
+
+'''
+
+    retracer = D3DRetracer()
+    retracer.retraceApi(d3d9)
diff --git a/retrace/d3dretrace_main.cpp b/retrace/d3dretrace_main.cpp
new file mode 100644 (file)
index 0000000..40d53ea
--- /dev/null
@@ -0,0 +1,94 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+
+#include "os_string.hpp"
+
+#include "d3dstate.hpp"
+#include "retrace.hpp"
+#include "d3dretrace.hpp"
+
+
+IDirect3DDevice9 *
+d3dretrace::pLastDirect3DDevice9 = NULL;
+
+
+void
+retrace::setUp(void) {
+    if (retrace::debug) {
+        /* 
+         * XXX: D3D9D only works for simple things, it often introduces errors
+         * on complex traces, or traces which use unofficial D3D9 features.
+         */
+        if (0) {
+            g_szD3D9DllName = "d3d9d.dll";
+        }
+    }
+}
+
+
+void
+retrace::addCallbacks(retrace::Retracer &retracer)
+{
+    retracer.addCallbacks(d3dretrace::d3d9_callbacks);
+}
+
+
+image::Image *
+retrace::getSnapshot(void) {
+    if (!d3dretrace::pLastDirect3DDevice9) {
+        return NULL;
+    }
+
+    return d3dstate::getRenderTargetImage(d3dretrace::pLastDirect3DDevice9);
+}
+
+
+bool
+retrace::dumpState(std::ostream &os)
+{
+    if (!d3dretrace::pLastDirect3DDevice9) {
+        return false;
+    }
+
+    d3dstate::dumpDevice(os, d3dretrace::pLastDirect3DDevice9);
+
+    return true;
+}
+
+
+void
+retrace::flushRendering(void) {
+}
+
+void
+retrace::waitForInput(void) {
+}
+
+void
+retrace::cleanUp(void) {
+}
diff --git a/retrace/d3dretrace_ws.cpp b/retrace/d3dretrace_ws.cpp
new file mode 100644 (file)
index 0000000..42bd0ab
--- /dev/null
@@ -0,0 +1,151 @@
+/**************************************************************************
+ *
+ * Copyright 2012 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "d3dretrace.hpp"
+
+
+namespace d3dretrace {
+
+
+// XXX: Don't duplicate this code.
+
+static LRESULT CALLBACK
+WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    MINMAXINFO *pMMI;
+    switch (uMsg) {
+    case WM_KEYDOWN:
+        switch (wParam) {
+        case VK_ESCAPE:
+            PostMessage(hWnd, WM_CLOSE, 0, 0);
+            break;
+        }
+        break;
+    case WM_GETMINMAXINFO:
+        // Allow to create a window bigger than the desktop
+        pMMI = (MINMAXINFO *)lParam;
+        pMMI->ptMaxSize.x = 60000;
+        pMMI->ptMaxSize.y = 60000;
+        pMMI->ptMaxTrackSize.x = 60000;
+        pMMI->ptMaxTrackSize.y = 60000;
+        break;
+    case WM_CLOSE:
+        exit(0);
+        break;
+    default:
+        break;
+    }
+
+    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+
+HWND
+createWindow(int width, int height) {
+    static bool first = TRUE;
+    RECT rect;
+
+    if (first) {
+        WNDCLASS wc;
+        memset(&wc, 0, sizeof wc);
+        wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
+        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+        wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+        wc.lpfnWndProc = WndProc;
+        wc.lpszClassName = "d3dretrace";
+        wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
+        RegisterClass(&wc);
+        first = FALSE;
+    }
+
+    DWORD dwExStyle;
+    DWORD dwStyle;
+    HWND hWnd;
+
+    dwExStyle = 0;
+    dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW;
+
+    int x = 0, y = 0;
+
+    rect.left = x;
+    rect.top = y;
+    rect.right = rect.left + width;
+    rect.bottom = rect.top + height;
+
+    AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
+
+    hWnd = CreateWindowEx(dwExStyle,
+                          "d3dretrace", /* wc.lpszClassName */
+                          NULL,
+                          dwStyle,
+                          0, /* x */
+                          0, /* y */
+                          rect.right - rect.left, /* width */
+                          rect.bottom - rect.top, /* height */
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL);
+    ShowWindow(hWnd, SW_SHOW);
+    return hWnd;
+}
+
+
+void
+resizeWindow(HWND hWnd, int width, int height) {
+    RECT rClient;
+    GetClientRect(hWnd, &rClient);
+    if (width  == rClient.right  - rClient.left &&
+        height == rClient.bottom - rClient.top) {
+        return;
+    }
+
+    RECT rWindow;
+    GetWindowRect(hWnd, &rWindow);
+    width  += (rWindow.right  - rWindow.left) - rClient.right;
+    height += (rWindow.bottom - rWindow.top)  - rClient.bottom;
+    SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, width, height, SWP_NOMOVE);
+}
+
+
+bool
+processEvents(void) {
+    MSG uMsg;
+    while (PeekMessage(&uMsg, NULL, 0, 0, PM_REMOVE)) {
+        if (uMsg.message == WM_QUIT) {
+            return false;
+        }
+
+        if (!TranslateAccelerator(uMsg.hwnd, NULL, &uMsg)) {
+            TranslateMessage(&uMsg);
+            DispatchMessage(&uMsg);
+        }
+    }
+    return true;
+}
+
+
+} /* namespace d3dretrace */
diff --git a/retrace/d3dstate.cpp b/retrace/d3dstate.cpp
new file mode 100644 (file)
index 0000000..73746e7
--- /dev/null
@@ -0,0 +1,165 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <stdio.h>
+
+#include <iostream>
+
+#include "d3d9imports.hpp"
+#include "json.hpp"
+
+
+namespace d3dstate {
+
+
+typedef HRESULT
+(WINAPI *PD3DXDISASSEMBLESHADER)(
+    CONST DWORD *pShader,
+    BOOL EnableColorCode,
+    LPCSTR pComments,
+    LPD3DXBUFFER *ppDisassembly
+);
+
+
+HRESULT
+disassembleShader(const DWORD *tokens, LPD3DXBUFFER *ppDisassembly)
+{
+    static BOOL firsttime = TRUE;
+
+    /*
+     * TODO: Consider using d3dcompile_xx.dll per
+     * http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx
+     */
+
+    static HMODULE hD3DXModule = NULL;
+    static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL;
+
+    if (firsttime) {
+        if (!hD3DXModule) {
+            unsigned release;
+            int version;
+            for (release = 0; release <= 1; ++release) {
+                /* Version 41 corresponds to Mar 2009 version of DirectX Runtime / SDK */
+                for (version = 41; version >= 0; --version) {
+                    char filename[256];
+                    _snprintf(filename, sizeof(filename),
+                              "d3dx9%s%s%u.dll", release ? "" : "d", version ? "_" : "", version);
+                    hD3DXModule = LoadLibraryA(filename);
+                    if (hD3DXModule)
+                        goto found;
+                }
+            }
+found:
+            ;
+        }
+
+        if (hD3DXModule) {
+            if (!pfnD3DXDisassembleShader) {
+                pfnD3DXDisassembleShader = (PD3DXDISASSEMBLESHADER)GetProcAddress(hD3DXModule, "D3DXDisassembleShader");
+            }
+        }
+
+        firsttime = FALSE;
+    }
+
+    if (!pfnD3DXDisassembleShader) {
+        return E_FAIL;
+    }
+
+    return pfnD3DXDisassembleShader(tokens, FALSE, NULL, ppDisassembly);
+}
+
+
+template< class T >
+inline void
+dumpShader(JSONWriter &json, const char *name, T *pShader) {
+    if (!pShader) {
+        return;
+    }
+
+    HRESULT hr;
+
+    UINT SizeOfData = 0;
+
+    hr = pShader->GetFunction(NULL, &SizeOfData);
+    if (SUCCEEDED(hr)) {
+        void *pData;
+        pData = malloc(SizeOfData);
+        if (pData) {
+            hr = pShader->GetFunction(pData, &SizeOfData);
+            if (SUCCEEDED(hr)) {
+                LPD3DXBUFFER pDisassembly;
+
+                hr = disassembleShader((const DWORD *)pData, &pDisassembly);
+                if (SUCCEEDED(hr)) {
+                    json.beginMember(name);
+                    json.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */);
+                    json.endMember();
+                    pDisassembly->Release();
+                }
+
+            }
+            free(pData);
+        }
+    }
+}
+
+static void
+dumpShaders(JSONWriter &json, IDirect3DDevice9 *pDevice)
+{
+    json.beginMember("shaders");
+
+    HRESULT hr;
+    json.beginObject();
+
+    IDirect3DVertexShader9 *pVertexShader = NULL;
+    hr = pDevice->GetVertexShader(&pVertexShader);
+    if (SUCCEEDED(hr)) {
+        dumpShader(json, "vertex", pVertexShader);
+    }
+
+    IDirect3DPixelShader9 *pPixelShader = NULL;
+    hr = pDevice->GetPixelShader(&pPixelShader);
+    if (SUCCEEDED(hr)) {
+        dumpShader(json, "pixel", pPixelShader);
+    }
+
+    json.endObject();
+    json.endMember(); // shaders
+}
+
+void
+dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice)
+{
+    JSONWriter json(os);
+
+    dumpShaders(json, pDevice);
+
+    /* TODO */
+}
+
+
+} /* namespace d3dstate */
diff --git a/retrace/d3dstate.hpp b/retrace/d3dstate.hpp
new file mode 100644 (file)
index 0000000..33322a1
--- /dev/null
@@ -0,0 +1,55 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _D3DSTATE_HPP_
+#define _D3DSTATE_HPP_
+
+
+#include <iostream>
+
+
+struct IDirect3DDevice9;
+
+
+namespace image {
+    class Image;
+}
+
+
+namespace d3dstate {
+
+
+image::Image *
+getRenderTargetImage(IDirect3DDevice9 *pDevice);
+
+
+void
+dumpDevice(std::ostream &os, IDirect3DDevice9 *pDevice);
+
+
+} /* namespace d3dstate */
+
+
+#endif /* _D3DSTATE_HPP_ */
diff --git a/retrace/d3dstate_images.cpp b/retrace/d3dstate_images.cpp
new file mode 100644 (file)
index 0000000..855dede
--- /dev/null
@@ -0,0 +1,100 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <assert.h>
+
+#include "image.hpp"
+#include "d3d9imports.hpp"
+
+
+namespace d3dstate {
+
+
+image::Image *
+getRenderTargetImage(IDirect3DDevice9 *pDevice) {
+    image::Image *image = NULL;
+    IDirect3DSurface9 *pRenderTarget = NULL;
+    D3DSURFACE_DESC Desc;
+    IDirect3DSurface9 *pStagingSurface = NULL;
+    D3DLOCKED_RECT LockedRect;
+    const unsigned char *src;
+    unsigned char *dst;
+    HRESULT hr;
+
+    hr = pDevice->GetRenderTarget(0, &pRenderTarget);
+    if (FAILED(hr)) {
+        goto no_rendertarget;
+    }
+    assert(pRenderTarget);
+
+    hr = pRenderTarget->GetDesc(&Desc);
+    assert(SUCCEEDED(hr));
+    assert(Desc.Format == D3DFMT_X8R8G8B8 || Desc.Format == D3DFMT_A8R8G8B8);
+
+    hr = pDevice->CreateOffscreenPlainSurface(Desc.Width, Desc.Height, Desc.Format, D3DPOOL_SYSTEMMEM, &pStagingSurface, NULL);
+    if (FAILED(hr)) {
+        goto no_staging;
+    }
+
+    hr = pDevice->GetRenderTargetData(pRenderTarget, pStagingSurface);
+    if (FAILED(hr)) {
+        goto no_rendertargetdata;
+    }
+
+    hr = pStagingSurface->LockRect(&LockedRect, NULL, D3DLOCK_READONLY);
+    if (FAILED(hr)) {
+        goto no_rendertargetdata;
+    }
+
+    image = new image::Image(Desc.Width, Desc.Height, 3, true);
+    if (!image) {
+        goto no_image;
+    }
+
+    dst = image->start();
+    src = (const unsigned char *)LockedRect.pBits;
+    for (unsigned y = 0; y < Desc.Height; ++y) {
+        for (unsigned x = 0; x < Desc.Width; ++x) {
+            dst[3*x + 0] = src[4*x + 2];
+            dst[3*x + 1] = src[4*x + 1];
+            dst[3*x + 2] = src[4*x + 0];
+        }
+        src += LockedRect.Pitch;
+        dst += image->stride();
+    }
+
+no_image:
+    pStagingSurface->UnlockRect();
+no_rendertargetdata:
+    pStagingSurface->Release();
+no_staging:
+    pRenderTarget->Release();
+no_rendertarget:
+    return image;
+}
+
+
+} /* namespace d3dstate */
diff --git a/retrace/dllretrace.py b/retrace/dllretrace.py
new file mode 100644 (file)
index 0000000..318741c
--- /dev/null
@@ -0,0 +1,70 @@
+##########################################################################
+#
+# Copyright 2008-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from retrace import Retracer
+from dispatch import Dispatcher
+
+
+class DllDispatcher(Dispatcher):
+
+    def dispatchApi(self, api):
+        tag = api.name.upper()
+        print r'const char *g_sz%sDllName = NULL;' % (tag,)
+        print r'HMODULE g_h%sModule = NULL;' % (tag,)
+        print r''
+        print r'static PROC'
+        print r'_getPublicProcAddress(LPCSTR lpProcName) {'
+        print r'    if (!g_h%sModule) {' % tag
+        print r'        if (g_sz%sDllName) {' % tag
+        print r'            g_h%sModule = LoadLibraryA(g_sz%sDllName);' % (tag, tag)
+        print r'            if (!g_h%sModule) {' % tag
+        print r'                os::log("warning: failed to load %%s\n", g_sz%sDllName);' % tag 
+        print r'            }'
+        print r'        }'
+        print r'        if (!g_h%sModule) {' % tag
+        print r'            g_h%sModule = LoadLibraryA("%s.dll");' % (tag, api.name)
+        print r'        }'
+        print r'        if (!g_h%sModule) {' % tag
+        print r'            os::log("error: failed to load %s.dll\n");' % api.name
+        print r'            exit(1);'
+        print r'            return NULL;'
+        print r'        }'
+        print r'    }'
+        print r'    return GetProcAddress(g_h%sModule, lpProcName);' % tag
+        print r'}'
+        print r''
+
+        Dispatcher.dispatchApi(self, api)
+
+
+class DllRetracer(Retracer):
+
+    def retraceApi(self, api):
+        dispatcher = DllDispatcher()
+        dispatcher.dispatchApi(api)
+
+        Retracer.retraceApi(self, api)
+
diff --git a/retrace/glretrace.hpp b/retrace/glretrace.hpp
new file mode 100644 (file)
index 0000000..11f4d27
--- /dev/null
@@ -0,0 +1,98 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _GLRETRACE_HPP_
+#define _GLRETRACE_HPP_
+
+#include "glws.hpp"
+#include "retrace.hpp"
+
+
+namespace glretrace {
+
+struct Context {
+    Context(glws::Context* context)
+        : wsContext(context),
+          activeProgram(0),
+          used(false)
+    {
+    }
+
+    ~Context()
+    {
+        delete wsContext;
+    }
+
+    glws::Context* wsContext;
+    GLuint activeProgram;
+    bool used;
+};
+
+extern bool insideList;
+extern bool insideGlBeginEnd;
+
+
+extern glws::Drawable *currentDrawable;
+extern Context *currentContext;
+
+glws::Drawable *
+createDrawable(glws::Profile profile);
+
+glws::Drawable *
+createDrawable(void);
+
+Context *
+createContext(Context *shareContext, glws::Profile profile);
+
+Context *
+createContext(Context *shareContext = 0);
+
+bool
+makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context);
+
+
+void
+checkGlError(trace::Call &call);
+
+extern const retrace::Entry gl_callbacks[];
+extern const retrace::Entry cgl_callbacks[];
+extern const retrace::Entry glx_callbacks[];
+extern const retrace::Entry wgl_callbacks[];
+extern const retrace::Entry egl_callbacks[];
+
+void frame_complete(trace::Call &call);
+void initContext();
+
+
+void updateDrawable(int width, int height);
+
+void flushQueries();
+void beginProfile(trace::Call &call, bool isDraw);
+void endProfile(trace::Call &call, bool isDraw);
+
+} /* namespace glretrace */
+
+
+#endif /* _GLRETRACE_HPP_ */
diff --git a/retrace/glretrace.py b/retrace/glretrace.py
new file mode 100644 (file)
index 0000000..6c73e69
--- /dev/null
@@ -0,0 +1,527 @@
+##########################################################################
+#
+# Copyright 2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""GL retracer generator."""
+
+
+from retrace import Retracer
+import specs.stdapi as stdapi
+import specs.glapi as glapi
+import specs.glesapi as glesapi
+
+
+class GlRetracer(Retracer):
+
+    table_name = 'glretrace::gl_callbacks'
+
+    def retraceFunction(self, function):
+        Retracer.retraceFunction(self, function)
+
+    array_pointer_function_names = set((
+        "glVertexPointer",
+        "glNormalPointer",
+        "glColorPointer",
+        "glIndexPointer",
+        "glTexCoordPointer",
+        "glEdgeFlagPointer",
+        "glFogCoordPointer",
+        "glSecondaryColorPointer",
+
+        "glInterleavedArrays",
+
+        "glVertexPointerEXT",
+        "glNormalPointerEXT",
+        "glColorPointerEXT",
+        "glIndexPointerEXT",
+        "glTexCoordPointerEXT",
+        "glEdgeFlagPointerEXT",
+        "glFogCoordPointerEXT",
+        "glSecondaryColorPointerEXT",
+
+        "glVertexAttribPointer",
+        "glVertexAttribPointerARB",
+        "glVertexAttribPointerNV",
+        "glVertexAttribIPointer",
+        "glVertexAttribIPointerEXT",
+        "glVertexAttribLPointer",
+        "glVertexAttribLPointerEXT",
+        
+        #"glMatrixIndexPointerARB",
+    ))
+
+    draw_array_function_names = set([
+        "glDrawArrays",
+        "glDrawArraysEXT",
+        "glDrawArraysIndirect",
+        "glDrawArraysInstanced",
+        "glDrawArraysInstancedARB",
+        "glDrawArraysInstancedEXT",
+        "glDrawArraysInstancedBaseInstance",
+        "glDrawMeshArraysSUN",
+        "glMultiDrawArrays",
+        "glMultiDrawArraysEXT",
+        "glMultiModeDrawArraysIBM",
+    ])
+
+    draw_elements_function_names = set([
+        "glDrawElements",
+        "glDrawElementsBaseVertex",
+        "glDrawElementsIndirect",
+        "glDrawElementsInstanced",
+        "glDrawElementsInstancedARB",
+        "glDrawElementsInstancedEXT",
+        "glDrawElementsInstancedBaseVertex",
+        "glDrawElementsInstancedBaseInstance",
+        "glDrawElementsInstancedBaseVertexBaseInstance",
+        "glDrawRangeElements",
+        "glDrawRangeElementsEXT",
+        "glDrawRangeElementsBaseVertex",
+        "glMultiDrawElements",
+        "glMultiDrawElementsBaseVertex",
+        "glMultiDrawElementsEXT",
+        "glMultiModeDrawElementsIBM",
+    ])
+
+    draw_indirect_function_names = set([
+        "glDrawArraysIndirect",
+        "glDrawElementsIndirect",
+    ])
+
+    misc_draw_function_names = set([
+        "glCallList",
+        "glCallLists",
+        "glClear",
+        "glEnd",
+        "glDrawPixels",
+        "glBlitFramebuffer",
+        "glBlitFramebufferEXT",
+    ])
+
+    bind_framebuffer_function_names = set([
+        "glBindFramebuffer",
+        "glBindFramebufferEXT",
+        "glBindFramebufferOES",
+    ])
+
+    # Names of the functions that can pack into the current pixel buffer
+    # object.  See also the ARB_pixel_buffer_object specification.
+    pack_function_names = set([
+        'glGetCompressedTexImage',
+        'glGetConvolutionFilter',
+        'glGetHistogram',
+        'glGetMinmax',
+        'glGetPixelMapfv',
+        'glGetPixelMapuiv',
+        'glGetPixelMapusv',
+        'glGetPolygonStipple',
+        'glGetSeparableFilter',
+        'glGetTexImage',
+        'glReadPixels',
+        'glGetnCompressedTexImageARB',
+        'glGetnConvolutionFilterARB',
+        'glGetnHistogramARB',
+        'glGetnMinmaxARB',
+        'glGetnPixelMapfvARB',
+        'glGetnPixelMapuivARB',
+        'glGetnPixelMapusvARB',
+        'glGetnPolygonStippleARB',
+        'glGetnSeparableFilterARB',
+        'glGetnTexImageARB',
+        'glReadnPixelsARB',
+    ])
+
+    map_function_names = set([
+        'glMapBuffer',
+        'glMapBufferARB',
+        'glMapBufferOES',
+        'glMapBufferRange',
+        'glMapNamedBufferEXT',
+        'glMapNamedBufferRangeEXT',
+        'glMapObjectBufferATI',
+    ])
+
+    unmap_function_names = set([
+        'glUnmapBuffer',
+        'glUnmapBufferARB',
+        'glUnmapBufferOES',
+        'glUnmapNamedBufferEXT',
+        'glUnmapObjectBufferATI',
+    ])
+
+    def retraceFunctionBody(self, function):
+        is_array_pointer = function.name in self.array_pointer_function_names
+        is_draw_array = function.name in self.draw_array_function_names
+        is_draw_elements = function.name in self.draw_elements_function_names
+        is_misc_draw = function.name in self.misc_draw_function_names
+
+        if is_array_pointer or is_draw_array or is_draw_elements:
+            print '    if (retrace::parser.version < 1) {'
+
+            if is_array_pointer or is_draw_array:
+                print '        GLint _array_buffer = 0;'
+                print '        glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &_array_buffer);'
+                print '        if (!_array_buffer) {'
+                self.failFunction(function)
+                print '        }'
+
+            if is_draw_elements:
+                print '        GLint _element_array_buffer = 0;'
+                print '        glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &_element_array_buffer);'
+                print '        if (!_element_array_buffer) {'
+                self.failFunction(function)
+                print '        }'
+            
+            print '    }'
+
+        # When no pack buffer object is bound, the pack functions are no-ops.
+        if function.name in self.pack_function_names:
+            print '    GLint _pack_buffer = 0;'
+            print '    glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &_pack_buffer);'
+            print '    if (!_pack_buffer) {'
+            print '        return;'
+            print '    }'
+
+        # Pre-snapshots
+        if function.name in self.bind_framebuffer_function_names:
+            print '    assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);'
+        if function.name == 'glFrameTerminatorGREMEDY':
+            print '    glretrace::frame_complete(call);'
+            return
+
+        Retracer.retraceFunctionBody(self, function)
+
+        # Post-snapshots
+        if function.name in ('glFlush', 'glFinish'):
+            print '    if (!retrace::doubleBuffer) {'
+            print '        glretrace::frame_complete(call);'
+            print '    }'
+        if is_draw_array or is_draw_elements or is_misc_draw:
+            print '    assert(call.flags & trace::CALL_FLAG_RENDER);'
+
+
+    def invokeFunction(self, function):
+        # Infer the drawable size from GL calls
+        if function.name == "glViewport":
+            print '    glretrace::updateDrawable(x + width, y + height);'
+        if function.name == "glViewportArray":
+            # We are concerned about drawables so only care for the first viewport
+            print '    if (first == 0 && count > 0) {'
+            print '        GLfloat x = v[0], y = v[1], w = v[2], h = v[3];'
+            print '        glretrace::updateDrawable(x + w, y + h);'
+            print '    }'
+        if function.name == "glViewportIndexedf":
+            print '    if (index == 0) {'
+            print '        glretrace::updateDrawable(x + w, y + h);'
+            print '    }'
+        if function.name == "glViewportIndexedfv":
+            print '    if (index == 0) {'
+            print '        GLfloat x = v[0], y = v[1], w = v[2], h = v[3];'
+            print '        glretrace::updateDrawable(x + w, y + h);'
+            print '    }'
+        if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'):
+            # Some applications do all their rendering in a framebuffer, and
+            # then just blit to the drawable without ever calling glViewport.
+            print '    glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));'
+
+        if function.name == "glEnd":
+            print '    glretrace::insideGlBeginEnd = false;'
+
+        if function.name.startswith('gl') and not function.name.startswith('glX'):
+            print r'    if (retrace::debug && !glretrace::currentContext) {'
+            print r'        retrace::warning(call) << "no current context\n";'
+            print r'    }'
+
+        if function.name == 'memcpy':
+            print '    if (!dest || !src || !n) return;'
+
+        # Skip glEnable/Disable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) as we don't
+        # faithfully set the CONTEXT_DEBUG_BIT_ARB flags on context creation.
+        if function.name in ('glEnable', 'glDisable'):
+            print '    if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) return;'
+
+        # Destroy the buffer mapping
+        if function.name in self.unmap_function_names:
+            print r'        GLvoid *ptr = NULL;'
+            if function.name == 'glUnmapBuffer':
+                print r'            glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);'
+            elif function.name == 'glUnmapBufferARB':
+                print r'            glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);'
+            elif function.name == 'glUnmapBufferOES':
+                print r'            glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);'
+            elif function.name == 'glUnmapNamedBufferEXT':
+                print r'            glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);'
+            elif function.name == 'glUnmapObjectBufferATI':
+                # TODO
+                pass
+            else:
+                assert False
+            print r'        if (ptr) {'
+            print r'            retrace::delRegionByPointer(ptr);'
+            print r'        } else {'
+            print r'            retrace::warning(call) << "no current context\n";'
+            print r'        }'
+
+        if function.name in ('glBindProgramPipeline', 'glBindProgramPipelineEXT'):
+            # Note if glBindProgramPipeline has ever been called
+            print r'    if (pipeline) {'
+            print r'        _pipelineHasBeenBound = true;'
+            print r'    }'
+
+        profileDraw = (
+            function.name in self.draw_array_function_names or
+            function.name in self.draw_elements_function_names or
+            function.name in self.draw_indirect_function_names or
+            function.name in self.misc_draw_function_names or
+            function.name == 'glBegin'
+        )
+
+        if function.name in ('glUseProgram', 'glUseProgramObjectARB'):
+            print r'    if (glretrace::currentContext) {'
+            print r'        glretrace::currentContext->activeProgram = call.arg(0).toUInt();'
+            print r'    }'
+
+        # Only profile if not inside a list as the queries get inserted into list
+        if function.name == 'glNewList':
+            print r'    glretrace::insideList = true;'
+
+        if function.name == 'glEndList':
+            print r'    glretrace::insideList = false;'
+
+        if function.name != 'glEnd':
+            print r'    if (!glretrace::insideList && !glretrace::insideGlBeginEnd && retrace::profiling) {'
+            if profileDraw:
+                print r'        glretrace::beginProfile(call, true);'
+            else:
+                print r'        glretrace::beginProfile(call, false);'
+            print r'    }'
+
+        if function.name == 'glCreateShaderProgramv':
+            # When dumping state, break down glCreateShaderProgramv so that the
+            # shader source can be recovered.
+            print r'    if (retrace::dumpingState) {'
+            print r'        GLuint _shader = glCreateShader(type);'
+            print r'        if (_shader) {'
+            print r'            glShaderSource(_shader, count, strings, NULL);'
+            print r'            glCompileShader(_shader);'
+            print r'            const GLuint _program = glCreateProgram();'
+            print r'            if (_program) {'
+            print r'                GLint compiled = GL_FALSE;'
+            print r'                glGetShaderiv(_shader, GL_COMPILE_STATUS, &compiled);'
+            print r'                glProgramParameteri(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);'
+            print r'                if (compiled) {'
+            print r'                    glAttachShader(_program, _shader);'
+            print r'                    glLinkProgram(_program);'
+            print r'                    //glDetachShader(_program, _shader);'
+            print r'                }'
+            print r'                //append-shader-info-log-to-program-info-log'
+            print r'            }'
+            print r'            //glDeleteShader(_shader);'
+            print r'            _result = _program;'
+            print r'        } else {'
+            print r'            _result = 0;'
+            print r'        }'
+            print r'    } else {'
+            Retracer.invokeFunction(self, function)
+            print r'    }'
+        else:
+            Retracer.invokeFunction(self, function)
+
+        if function.name == "glBegin":
+            print '    glretrace::insideGlBeginEnd = true;'
+
+        print r'    if (!glretrace::insideList && !glretrace::insideGlBeginEnd && retrace::profiling) {'
+        if profileDraw:
+            print r'        glretrace::endProfile(call, true);'
+        else:
+            print r'        glretrace::endProfile(call, false);'
+        print r'    }'
+
+        # Error checking
+        if function.name.startswith('gl'):
+            # glGetError is not allowed inside glBegin/glEnd
+            print '    if (retrace::debug && !glretrace::insideGlBeginEnd) {'
+            print '        glretrace::checkGlError(call);'
+            if function.name in ('glProgramStringARB', 'glProgramStringNV'):
+                print r'        GLint error_position = -1;'
+                print r'        glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &error_position);'
+                print r'        if (error_position != -1) {'
+                print r'            const char *error_string = (const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB);'
+                print r'            retrace::warning(call) << error_string << "\n";'
+                print r'        }'
+            if function.name == 'glCompileShader':
+                print r'        GLint compile_status = 0;'
+                print r'        glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);'
+                print r'        if (!compile_status) {'
+                print r'             GLint info_log_length = 0;'
+                print r'             glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_length);'
+                print r'             GLchar *infoLog = new GLchar[info_log_length];'
+                print r'             glGetShaderInfoLog(shader, info_log_length, NULL, infoLog);'
+                print r'             retrace::warning(call) << infoLog << "\n";'
+                print r'             delete [] infoLog;'
+                print r'        }'
+            if function.name in ('glLinkProgram', 'glCreateShaderProgramv', 'glCreateShaderProgramEXT'):
+                if function.name != 'glLinkProgram':
+                    print r'        GLuint program = _result;'
+                print r'        GLint link_status = 0;'
+                print r'        glGetProgramiv(program, GL_LINK_STATUS, &link_status);'
+                print r'        if (!link_status) {'
+                print r'             GLint info_log_length = 0;'
+                print r'             glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);'
+                print r'             GLchar *infoLog = new GLchar[info_log_length];'
+                print r'             glGetProgramInfoLog(program, info_log_length, NULL, infoLog);'
+                print r'             retrace::warning(call) << infoLog << "\n";'
+                print r'             delete [] infoLog;'
+                print r'        }'
+            if function.name == 'glCompileShaderARB':
+                print r'        GLint compile_status = 0;'
+                print r'        glGetObjectParameterivARB(shaderObj, GL_OBJECT_COMPILE_STATUS_ARB, &compile_status);'
+                print r'        if (!compile_status) {'
+                print r'             GLint info_log_length = 0;'
+                print r'             glGetObjectParameterivARB(shaderObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
+                print r'             GLchar *infoLog = new GLchar[info_log_length];'
+                print r'             glGetInfoLogARB(shaderObj, info_log_length, NULL, infoLog);'
+                print r'             retrace::warning(call) << infoLog << "\n";'
+                print r'             delete [] infoLog;'
+                print r'        }'
+            if function.name == 'glLinkProgramARB':
+                print r'        GLint link_status = 0;'
+                print r'        glGetObjectParameterivARB(programObj, GL_OBJECT_LINK_STATUS_ARB, &link_status);'
+                print r'        if (!link_status) {'
+                print r'             GLint info_log_length = 0;'
+                print r'             glGetObjectParameterivARB(programObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &info_log_length);'
+                print r'             GLchar *infoLog = new GLchar[info_log_length];'
+                print r'             glGetInfoLogARB(programObj, info_log_length, NULL, infoLog);'
+                print r'             retrace::warning(call) << infoLog << "\n";'
+                print r'             delete [] infoLog;'
+                print r'        }'
+            if function.name in self.map_function_names:
+                print r'        if (!_result) {'
+                print r'             retrace::warning(call) << "failed to map buffer\n";'
+                print r'        }'
+            if function.name in self.unmap_function_names and function.type is not stdapi.Void:
+                print r'        if (!_result) {'
+                print r'             retrace::warning(call) << "failed to unmap buffer\n";'
+                print r'        }'
+            if function.name in ('glGetAttribLocation', 'glGetAttribLocationARB'):
+                print r'    GLint _origResult = call.ret->toSInt();'
+                print r'    if (_result != _origResult) {'
+                print r'        retrace::warning(call) << "vertex attrib location mismatch " << _origResult << " -> " << _result << "\n";'
+                print r'    }'
+            if function.name in ('glCheckFramebufferStatus', 'glCheckFramebufferStatusEXT', 'glCheckNamedFramebufferStatusEXT'):
+                print r'    GLint _origResult = call.ret->toSInt();'
+                print r'    if (_origResult == GL_FRAMEBUFFER_COMPLETE &&'
+                print r'        _result != GL_FRAMEBUFFER_COMPLETE) {'
+                print r'        retrace::warning(call) << "incomplete framebuffer (" << glstate::enumToString(_result) << ")\n";'
+                print r'    }'
+            print '    }'
+
+        # Query the buffer length for whole buffer mappings
+        if function.name in self.map_function_names:
+            if 'length' in function.argNames():
+                assert 'BufferRange' in function.name
+            else:
+                assert 'BufferRange' not in function.name
+                print r'    GLint length = 0;'
+                if function.name in ('glMapBuffer', 'glMapBufferOES'):
+                    print r'    glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);'
+                elif function.name == 'glMapBufferARB':
+                    print r'    glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);'
+                elif function.name == 'glMapNamedBufferEXT':
+                    print r'    glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);'
+                elif function.name == 'glMapObjectBufferATI':
+                    print r'    glGetObjectBufferivATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI, &length);'
+                else:
+                    assert False
+
+    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
+        if function.name in self.array_pointer_function_names and arg.name == 'pointer':
+            print '    %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)
+            return
+
+        if function.name in self.draw_elements_function_names and arg.name == 'indices' or\
+           function.name in self.draw_indirect_function_names and arg.name == 'indirect':
+            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
+            return
+
+        # Handle pointer with offsets into the current pack pixel buffer
+        # object.
+        if function.name in self.pack_function_names and arg.output:
+            assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque))
+            print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue)
+            return
+
+        if arg.type is glapi.GLlocation \
+           and 'program' not in function.argNames():
+            # Determine the active program for uniforms swizzling
+            print '    GLint program = -1;'
+            print '    GLint pipeline = 0;'
+            print '    if (_pipelineHasBeenBound) {'
+            print '        glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);'
+            print '    }'
+            print '    if (pipeline) {'
+            print '        glGetProgramPipelineiv(pipeline, GL_ACTIVE_PROGRAM, &program);'
+            print '    } else {'
+            print '        glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
+            print '    }'
+            print
+
+        if arg.type is glapi.GLlocationARB \
+           and 'programObj' not in function.argNames():
+            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'
+
+        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)
+
+        # Don't try to use more samples than the implementation supports
+        if arg.name == 'samples':
+            assert arg.type is glapi.GLsizei
+            print '    GLint max_samples = 0;'
+            print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
+            print '    if (samples > max_samples) {'
+            print '        samples = max_samples;'
+            print '    }'
+
+        # These parameters are referred beyond the call life-time
+        # TODO: Replace ad-hoc solution for bindable parameters with general one
+        if function.name in ('glFeedbackBuffer', 'glSelectBuffer') and arg.output:
+            print '    _allocator.bind(%s);' % arg.name
+
+
+
+if __name__ == '__main__':
+    print r'''
+#include <string.h>
+
+#include "glproc.hpp"
+#include "glretrace.hpp"
+#include "glstate.hpp"
+
+
+static bool _pipelineHasBeenBound = false;
+'''
+    api = glapi.glapi
+    api.addApi(glesapi.glesapi)
+    retracer = GlRetracer()
+    retracer.retraceApi(api)
diff --git a/retrace/glretrace_cgl.cpp b/retrace/glretrace_cgl.cpp
new file mode 100644 (file)
index 0000000..76b62fb
--- /dev/null
@@ -0,0 +1,117 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+
+#include "glproc.hpp"
+#include "retrace.hpp"
+#include "glretrace.hpp"
+
+
+using namespace glretrace;
+
+
+typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
+typedef std::map<unsigned long long, Context *> ContextMap;
+static DrawableMap drawable_map;
+static ContextMap context_map;
+static Context *sharedContext = NULL;
+
+
+static glws::Drawable *
+getDrawable(unsigned long drawable_id) {
+    if (drawable_id == 0) {
+        return NULL;
+    }
+
+    /* XXX: Support multiple drawables. */
+    drawable_id = 1;
+
+    DrawableMap::const_iterator it;
+    it = drawable_map.find(drawable_id);
+    if (it == drawable_map.end()) {
+        return (drawable_map[drawable_id] = glretrace::createDrawable());
+    }
+
+    return it->second;
+}
+
+
+static Context *
+getContext(unsigned long long ctx) {
+    if (ctx == 0) {
+        return NULL;
+    }
+
+    ContextMap::const_iterator it;
+    it = context_map.find(ctx);
+    if (it == context_map.end()) {
+        Context *context;
+        context_map[ctx] = context = glretrace::createContext(sharedContext);
+        if (!sharedContext) {
+            sharedContext = context;
+        }
+        return context;
+    }
+
+    return it->second;
+}
+
+
+static void retrace_CGLSetCurrentContext(trace::Call &call) {
+    unsigned long long ctx = call.arg(0).toUIntPtr();
+
+    glws::Drawable *new_drawable = getDrawable(ctx);
+    Context *new_context = getContext(ctx);
+
+    glretrace::makeCurrent(call, new_drawable, new_context);
+}
+
+
+static void retrace_CGLFlushDrawable(trace::Call &call) {
+    if (currentDrawable && currentContext) {
+        if (retrace::doubleBuffer) {
+            currentDrawable->swapBuffers();
+        } else {
+            glFlush();
+        }
+
+        frame_complete(call);
+    }
+}
+
+
+const retrace::Entry glretrace::cgl_callbacks[] = {
+    {"CGLSetCurrentContext", &retrace_CGLSetCurrentContext},
+    {"CGLGetCurrentContext", &retrace::ignore},
+    {"CGLEnable", &retrace::ignore},
+    {"CGLDisable", &retrace::ignore},
+    {"CGLSetParameter", &retrace::ignore},
+    {"CGLGetParameter", &retrace::ignore},
+    {"CGLFlushDrawable", &retrace_CGLFlushDrawable},
+    {NULL, NULL},
+};
+
diff --git a/retrace/glretrace_egl.cpp b/retrace/glretrace_egl.cpp
new file mode 100644 (file)
index 0000000..3f83f55
--- /dev/null
@@ -0,0 +1,267 @@
+/**************************************************************************
+ *
+ * Copyright 2011 LunarG, Inc.
+ * All Rights Reserved.
+ *
+ * Based on glretrace_glx.cpp, which has
+ *
+ *   Copyright 2011 Jose Fonseca
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "glproc.hpp"
+#include "retrace.hpp"
+#include "glretrace.hpp"
+#include "os.hpp"
+#include "eglsize.hpp"
+
+#ifndef EGL_OPENGL_ES_API
+#define EGL_OPENGL_ES_API              0x30A0
+#define EGL_OPENVG_API                 0x30A1
+#define EGL_OPENGL_API                 0x30A2
+#define EGL_CONTEXT_CLIENT_VERSION     0x3098
+#endif
+
+
+using namespace glretrace;
+
+
+typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
+typedef std::map<unsigned long long, Context *> ContextMap;
+typedef std::map<unsigned long long, glws::Profile> ProfileMap;
+static DrawableMap drawable_map;
+static ContextMap context_map;
+static ProfileMap profile_map;
+
+static unsigned int current_api = EGL_OPENGL_ES_API;
+static glws::Profile last_profile = glws::PROFILE_COMPAT;
+
+static void
+createDrawable(unsigned long long orig_config, unsigned long long orig_surface);
+
+static glws::Drawable *
+getDrawable(unsigned long long surface_ptr) {
+    if (surface_ptr == 0) {
+        return NULL;
+    }
+
+    DrawableMap::const_iterator it;
+    it = drawable_map.find(surface_ptr);
+    if (it == drawable_map.end()) {
+        // In Fennec we get the egl window surface from Java which isn't
+        // traced, so just create a drawable if it doesn't exist in here
+        createDrawable(0, surface_ptr);
+        it = drawable_map.find(surface_ptr);
+        assert(it != drawable_map.end());
+    }
+
+    return (it != drawable_map.end()) ? it->second : NULL;
+}
+
+static Context *
+getContext(unsigned long long context_ptr) {
+    if (context_ptr == 0) {
+        return NULL;
+    }
+
+    ContextMap::const_iterator it;
+    it = context_map.find(context_ptr);
+
+    return (it != context_map.end()) ? it->second : NULL;
+}
+
+static void createDrawable(unsigned long long orig_config, unsigned long long orig_surface)
+{
+    ProfileMap::iterator it = profile_map.find(orig_config);
+    glws::Profile profile;
+
+    // If the requested config is associated with a profile, use that
+    // profile. Otherwise, assume that the last used profile is what
+    // the user wants.
+    if (it != profile_map.end()) {
+        profile = it->second;
+    } else {
+        profile = last_profile;
+    }
+
+    glws::Drawable *drawable = glretrace::createDrawable(profile);
+    drawable_map[orig_surface] = drawable;
+}
+
+static void retrace_eglCreateWindowSurface(trace::Call &call) {
+    unsigned long long orig_config = call.arg(1).toUIntPtr();
+    unsigned long long orig_surface = call.ret->toUIntPtr();
+    createDrawable(orig_config, orig_surface);
+}
+
+static void retrace_eglCreatePbufferSurface(trace::Call &call) {
+    unsigned long long orig_config = call.arg(1).toUIntPtr();
+    unsigned long long orig_surface = call.ret->toUIntPtr();
+    createDrawable(orig_config, orig_surface);
+    // TODO: Respect the pbuffer dimensions too
+}
+
+static void retrace_eglDestroySurface(trace::Call &call) {
+    unsigned long long orig_surface = call.arg(1).toUIntPtr();
+
+    DrawableMap::iterator it;
+    it = drawable_map.find(orig_surface);
+
+    if (it != drawable_map.end()) {
+        if (it->second != currentDrawable) {
+            // TODO: reference count
+            delete it->second;
+        }
+        drawable_map.erase(it);
+    }
+}
+
+static void retrace_eglBindAPI(trace::Call &call) {
+    current_api = call.arg(0).toUInt();
+}
+
+static void retrace_eglCreateContext(trace::Call &call) {
+    unsigned long long orig_context = call.ret->toUIntPtr();
+    unsigned long long orig_config = call.arg(1).toUIntPtr();
+    Context *share_context = getContext(call.arg(2).toUIntPtr());
+    trace::Array *attrib_array = dynamic_cast<trace::Array *>(&call.arg(3));
+    glws::Profile profile;
+
+    switch (current_api) {
+    case EGL_OPENGL_API:
+        profile = glws::PROFILE_COMPAT;
+        break;
+    case EGL_OPENGL_ES_API:
+    default:
+        profile = glws::PROFILE_ES1;
+        if (attrib_array) {
+            for (int i = 0; i < attrib_array->values.size(); i += 2) {
+                int v = attrib_array->values[i]->toSInt();
+                if (v == EGL_CONTEXT_CLIENT_VERSION) {
+                    v = attrib_array->values[i + 1]->toSInt();
+                    if (v == 2)
+                        profile = glws::PROFILE_ES2;
+                    break;
+                }
+            }
+        }
+        break;
+    }
+
+
+    Context *context = glretrace::createContext(share_context, profile);
+    if (!context) {
+        const char *name;
+        switch (profile) {
+        case glws::PROFILE_COMPAT:
+            name = "OpenGL";
+            break;
+        case glws::PROFILE_ES1:
+            name = "OpenGL ES 1.1";
+            break;
+        case glws::PROFILE_ES2:
+            name = "OpenGL ES 2.0";
+            break;
+        default:
+            name = "unknown";
+            break;
+        }
+
+        retrace::warning(call) << "Failed to create " << name << " context.\n";
+        os::abort();
+    }
+
+    context_map[orig_context] = context;
+    profile_map[orig_config] = profile;
+    last_profile = profile;
+}
+
+static void retrace_eglDestroyContext(trace::Call &call) {
+    unsigned long long orig_context = call.arg(1).toUIntPtr();
+
+    ContextMap::iterator it;
+    it = context_map.find(orig_context);
+
+    if (it != context_map.end()) {
+        delete it->second;
+        context_map.erase(it);
+    }
+}
+
+static void retrace_eglMakeCurrent(trace::Call &call) {
+    glws::Drawable *new_drawable = getDrawable(call.arg(1).toUIntPtr());
+    Context *new_context = getContext(call.arg(3).toUIntPtr());
+
+    glretrace::makeCurrent(call, new_drawable, new_context);
+}
+
+
+static void retrace_eglSwapBuffers(trace::Call &call) {
+    frame_complete(call);
+
+    if (retrace::doubleBuffer && currentDrawable) {
+        currentDrawable->swapBuffers();
+    } else {
+        glFlush();
+    }
+}
+
+const retrace::Entry glretrace::egl_callbacks[] = {
+    {"eglGetError", &retrace::ignore},
+    {"eglGetDisplay", &retrace::ignore},
+    {"eglInitialize", &retrace::ignore},
+    {"eglTerminate", &retrace::ignore},
+    {"eglQueryString", &retrace::ignore},
+    {"eglGetConfigs", &retrace::ignore},
+    {"eglChooseConfig", &retrace::ignore},
+    {"eglGetConfigAttrib", &retrace::ignore},
+    {"eglCreateWindowSurface", &retrace_eglCreateWindowSurface},
+    {"eglCreatePbufferSurface", &retrace_eglCreatePbufferSurface},
+    //{"eglCreatePixmapSurface", &retrace::ignore},
+    {"eglDestroySurface", &retrace_eglDestroySurface},
+    {"eglQuerySurface", &retrace::ignore},
+    {"eglBindAPI", &retrace_eglBindAPI},
+    {"eglQueryAPI", &retrace::ignore},
+    //{"eglWaitClient", &retrace::ignore},
+    //{"eglReleaseThread", &retrace::ignore},
+    //{"eglCreatePbufferFromClientBuffer", &retrace::ignore},
+    //{"eglSurfaceAttrib", &retrace::ignore},
+    //{"eglBindTexImage", &retrace::ignore},
+    //{"eglReleaseTexImage", &retrace::ignore},
+    {"eglSwapInterval", &retrace::ignore},
+    {"eglCreateContext", &retrace_eglCreateContext},
+    {"eglDestroyContext", &retrace_eglDestroyContext},
+    {"eglMakeCurrent", &retrace_eglMakeCurrent},
+    {"eglGetCurrentContext", &retrace::ignore},
+    {"eglGetCurrentSurface", &retrace::ignore},
+    {"eglGetCurrentDisplay", &retrace::ignore},
+    {"eglQueryContext", &retrace::ignore},
+    {"eglWaitGL", &retrace::ignore},
+    {"eglWaitNative", &retrace::ignore},
+    {"eglSwapBuffers", &retrace_eglSwapBuffers},
+    //{"eglCopyBuffers", &retrace::ignore},
+    {"eglGetProcAddress", &retrace::ignore},
+    {"eglCreateImageKHR", &retrace::ignore},
+    {"eglDestroyImageKHR", &retrace::ignore},
+    {"glEGLImageTargetTexture2DOES", &retrace::ignore},
+    {NULL, NULL},
+};
diff --git a/retrace/glretrace_glx.cpp b/retrace/glretrace_glx.cpp
new file mode 100644 (file)
index 0000000..bc63063
--- /dev/null
@@ -0,0 +1,222 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "glproc.hpp"
+#include "retrace.hpp"
+#include "glretrace.hpp"
+
+
+using namespace glretrace;
+
+
+typedef std::map<unsigned long, glws::Drawable *> DrawableMap;
+typedef std::map<unsigned long long, Context *> ContextMap;
+static DrawableMap drawable_map;
+static ContextMap context_map;
+
+
+static glws::Drawable *
+getDrawable(unsigned long drawable_id) {
+    if (drawable_id == 0) {
+        return NULL;
+    }
+
+    DrawableMap::const_iterator it;
+    it = drawable_map.find(drawable_id);
+    if (it == drawable_map.end()) {
+        return (drawable_map[drawable_id] = glretrace::createDrawable());
+    }
+
+    return it->second;
+}
+
+static Context *
+getContext(unsigned long long context_ptr) {
+    if (context_ptr == 0) {
+        return NULL;
+    }
+
+    ContextMap::const_iterator it;
+    it = context_map.find(context_ptr);
+    if (it == context_map.end()) {
+        return (context_map[context_ptr] = glretrace::createContext());
+    }
+
+    return it->second;
+}
+
+static void retrace_glXCreateContext(trace::Call &call) {
+    unsigned long long orig_context = call.ret->toUIntPtr();
+    Context *share_context = getContext(call.arg(2).toUIntPtr());
+
+    Context *context = glretrace::createContext(share_context);
+    context_map[orig_context] = context;
+}
+
+static void retrace_glXCreateContextAttribsARB(trace::Call &call) {
+    unsigned long long orig_context = call.ret->toUIntPtr();
+    Context *share_context = getContext(call.arg(2).toUIntPtr());
+
+    Context *context = glretrace::createContext(share_context);
+    context_map[orig_context] = context;
+}
+
+static void retrace_glXMakeCurrent(trace::Call &call) {
+    glws::Drawable *new_drawable = getDrawable(call.arg(1).toUInt());
+    Context *new_context = getContext(call.arg(2).toUIntPtr());
+
+    glretrace::makeCurrent(call, new_drawable, new_context);
+}
+
+
+static void retrace_glXDestroyContext(trace::Call &call) {
+    Context *context = getContext(call.arg(1).toUIntPtr());
+
+    if (!context) {
+        return;
+    }
+
+    delete context;
+}
+
+static void retrace_glXSwapBuffers(trace::Call &call) {
+    frame_complete(call);
+    if (retrace::doubleBuffer) {
+        currentDrawable->swapBuffers();
+    } else {
+        glFlush();
+    }
+}
+
+static void retrace_glXCreateNewContext(trace::Call &call) {
+    unsigned long long orig_context = call.ret->toUIntPtr();
+    Context *share_context = getContext(call.arg(3).toUIntPtr());
+
+    Context *context = glretrace::createContext(share_context);
+    context_map[orig_context] = context;
+}
+
+static void retrace_glXMakeContextCurrent(trace::Call &call) {
+    glws::Drawable *new_drawable = getDrawable(call.arg(1).toUInt());
+    Context *new_context = getContext(call.arg(3).toUIntPtr());
+
+    glretrace::makeCurrent(call, new_drawable, new_context);
+}
+
+const retrace::Entry glretrace::glx_callbacks[] = {
+    //{"glXBindChannelToWindowSGIX", &retrace_glXBindChannelToWindowSGIX},
+    //{"glXBindSwapBarrierNV", &retrace_glXBindSwapBarrierNV},
+    //{"glXBindSwapBarrierSGIX", &retrace_glXBindSwapBarrierSGIX},
+    //{"glXBindTexImageEXT", &retrace_glXBindTexImageEXT},
+    //{"glXChannelRectSGIX", &retrace_glXChannelRectSGIX},
+    //{"glXChannelRectSyncSGIX", &retrace_glXChannelRectSyncSGIX},
+    {"glXChooseFBConfig", &retrace::ignore},
+    {"glXChooseFBConfigSGIX", &retrace::ignore},
+    {"glXChooseVisual", &retrace::ignore},
+    //{"glXCopyContext", &retrace_glXCopyContext},
+    //{"glXCopyImageSubDataNV", &retrace_glXCopyImageSubDataNV},
+    //{"glXCopySubBufferMESA", &retrace_glXCopySubBufferMESA},
+    {"glXCreateContextAttribsARB", &retrace_glXCreateContextAttribsARB},
+    {"glXCreateContext", &retrace_glXCreateContext},
+    //{"glXCreateContextWithConfigSGIX", &retrace_glXCreateContextWithConfigSGIX},
+    //{"glXCreateGLXPbufferSGIX", &retrace_glXCreateGLXPbufferSGIX},
+    //{"glXCreateGLXPixmap", &retrace_glXCreateGLXPixmap},
+    //{"glXCreateGLXPixmapWithConfigSGIX", &retrace_glXCreateGLXPixmapWithConfigSGIX},
+    {"glXCreateNewContext", &retrace_glXCreateNewContext},
+    //{"glXCreatePbuffer", &retrace_glXCreatePbuffer},
+    //{"glXCreatePixmap", &retrace_glXCreatePixmap},
+    //{"glXCreateWindow", &retrace_glXCreateWindow},
+    //{"glXCushionSGI", &retrace_glXCushionSGI},
+    {"glXDestroyContext", &retrace_glXDestroyContext},
+    //{"glXDestroyGLXPbufferSGIX", &retrace_glXDestroyGLXPbufferSGIX},
+    //{"glXDestroyGLXPixmap", &retrace_glXDestroyGLXPixmap},
+    //{"glXDestroyPbuffer", &retrace_glXDestroyPbuffer},
+    //{"glXDestroyPixmap", &retrace_glXDestroyPixmap},
+    //{"glXDestroyWindow", &retrace_glXDestroyWindow},
+    //{"glXFreeContextEXT", &retrace_glXFreeContextEXT},
+    {"glXGetAGPOffsetMESA", &retrace::ignore},
+    {"glXGetClientString", &retrace::ignore},
+    {"glXGetConfig", &retrace::ignore},
+    {"glXGetContextIDEXT", &retrace::ignore},
+    {"glXGetCurrentContext", &retrace::ignore},
+    {"glXGetCurrentDisplayEXT", &retrace::ignore},
+    {"glXGetCurrentDisplay", &retrace::ignore},
+    {"glXGetCurrentDrawable", &retrace::ignore},
+    {"glXGetCurrentReadDrawable", &retrace::ignore},
+    {"glXGetCurrentReadDrawableSGI", &retrace::ignore},
+    {"glXGetFBConfigAttrib", &retrace::ignore},
+    {"glXGetFBConfigAttribSGIX", &retrace::ignore},
+    {"glXGetFBConfigFromVisualSGIX", &retrace::ignore},
+    {"glXGetFBConfigs", &retrace::ignore},
+    {"glXGetMscRateOML", &retrace::ignore},
+    {"glXGetProcAddressARB", &retrace::ignore},
+    {"glXGetProcAddress", &retrace::ignore},
+    {"glXGetSelectedEvent", &retrace::ignore},
+    {"glXGetSelectedEventSGIX", &retrace::ignore},
+    {"glXGetSyncValuesOML", &retrace::ignore},
+    {"glXGetVideoSyncSGI", &retrace::ignore},
+    {"glXGetVisualFromFBConfig", &retrace::ignore},
+    {"glXGetVisualFromFBConfigSGIX", &retrace::ignore},
+    //{"glXImportContextEXT", &retrace_glXImportContextEXT},
+    {"glXIsDirect", &retrace::ignore},
+    //{"glXJoinSwapGroupNV", &retrace_glXJoinSwapGroupNV},
+    //{"glXJoinSwapGroupSGIX", &retrace_glXJoinSwapGroupSGIX},
+    {"glXMakeContextCurrent", &retrace_glXMakeContextCurrent},
+    //{"glXMakeCurrentReadSGI", &retrace_glXMakeCurrentReadSGI},
+    {"glXMakeCurrent", &retrace_glXMakeCurrent},
+    {"glXQueryChannelDeltasSGIX", &retrace::ignore},
+    {"glXQueryChannelRectSGIX", &retrace::ignore},
+    {"glXQueryContextInfoEXT", &retrace::ignore},
+    {"glXQueryContext", &retrace::ignore},
+    {"glXQueryDrawable", &retrace::ignore},
+    {"glXQueryExtension", &retrace::ignore},
+    {"glXQueryExtensionsString", &retrace::ignore},
+    {"glXQueryFrameCountNV", &retrace::ignore},
+    {"glXQueryGLXPbufferSGIX", &retrace::ignore},
+    {"glXQueryMaxSwapBarriersSGIX", &retrace::ignore},
+    {"glXQueryMaxSwapGroupsNV", &retrace::ignore},
+    {"glXQueryServerString", &retrace::ignore},
+    {"glXQuerySwapGroupNV", &retrace::ignore},
+    {"glXQueryVersion", &retrace::ignore},
+    //{"glXReleaseBuffersMESA", &retrace_glXReleaseBuffersMESA},
+    //{"glXReleaseTexImageEXT", &retrace_glXReleaseTexImageEXT},
+    //{"glXResetFrameCountNV", &retrace_glXResetFrameCountNV},
+    //{"glXSelectEvent", &retrace_glXSelectEvent},
+    //{"glXSelectEventSGIX", &retrace_glXSelectEventSGIX},
+    //{"glXSet3DfxModeMESA", &retrace_glXSet3DfxModeMESA},
+    //{"glXSwapBuffersMscOML", &retrace_glXSwapBuffersMscOML},
+    {"glXSwapBuffers", &retrace_glXSwapBuffers},
+    {"glXSwapIntervalEXT", &retrace::ignore},
+    {"glXSwapIntervalSGI", &retrace::ignore},
+    //{"glXUseXFont", &retrace_glXUseXFont},
+    {"glXWaitForMscOML", &retrace::ignore},
+    {"glXWaitForSbcOML", &retrace::ignore},
+    {"glXWaitGL", &retrace::ignore},
+    {"glXWaitVideoSyncSGI", &retrace::ignore},
+    {"glXWaitX", &retrace::ignore},
+    {NULL, NULL},
+};
+
diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp
new file mode 100755 (executable)
index 0000000..d857d03
--- /dev/null
@@ -0,0 +1,444 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+
+#include "retrace.hpp"
+#include "glproc.hpp"
+#include "glstate.hpp"
+#include "glretrace.hpp"
+#include "os_time.hpp"
+
+/* Synchronous debug output may reduce performance however,
+ * without it the callNo in the callback may be inaccurate
+ * as the callback may be called at any time.
+ */
+#define DEBUG_OUTPUT_SYNCHRONOUS 0
+
+namespace glretrace {
+
+bool insideList = false;
+bool insideGlBeginEnd = false;
+
+struct CallQuery
+{
+    GLuint ids[3];
+    unsigned call;
+    bool isDraw;
+    GLuint program;
+    const trace::FunctionSig *sig;
+    int64_t cpuStart;
+    int64_t cpuEnd;
+};
+
+static bool supportsElapsed = true;
+static bool supportsTimestamp = true;
+static bool supportsOcclusion = true;
+static bool supportsDebugOutput = true;
+
+static std::list<CallQuery> callQueries;
+
+static void APIENTRY
+debugOutputCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);
+
+void
+checkGlError(trace::Call &call) {
+    GLenum error = glGetError();
+    if (error == GL_NO_ERROR) {
+        return;
+    }
+
+    std::ostream & os = retrace::warning(call);
+
+    os << "glGetError(";
+    os << call.name();
+    os << ") = ";
+
+    switch (error) {
+    case GL_INVALID_ENUM:
+        os << "GL_INVALID_ENUM";
+        break;
+    case GL_INVALID_VALUE:
+        os << "GL_INVALID_VALUE";
+        break;
+    case GL_INVALID_OPERATION:
+        os << "GL_INVALID_OPERATION";
+        break;
+    case GL_STACK_OVERFLOW:
+        os << "GL_STACK_OVERFLOW";
+        break;
+    case GL_STACK_UNDERFLOW:
+        os << "GL_STACK_UNDERFLOW";
+        break;
+    case GL_OUT_OF_MEMORY:
+        os << "GL_OUT_OF_MEMORY";
+        break;
+    case GL_INVALID_FRAMEBUFFER_OPERATION:
+        os << "GL_INVALID_FRAMEBUFFER_OPERATION";
+        break;
+    case GL_TABLE_TOO_LARGE:
+        os << "GL_TABLE_TOO_LARGE";
+        break;
+    default:
+        os << error;
+        break;
+    }
+    os << "\n";
+}
+
+static void
+getCurrentTimes(int64_t& cpuTime, int64_t& gpuTime) {
+    GLuint query;
+
+    if (retrace::profilingGpuTimes && supportsTimestamp) {
+        glGenQueries(1, &query);
+        glQueryCounter(query, GL_TIMESTAMP);
+        glGetQueryObjecti64vEXT(query, GL_QUERY_RESULT, &gpuTime);
+    } else {
+        gpuTime = 0;
+    }
+
+    if (retrace::profilingCpuTimes) {
+        cpuTime = os::getTime();
+    } else {
+        cpuTime = 0;
+    }
+
+    if (retrace::profilingGpuTimes && supportsTimestamp) {
+        glDeleteQueries(1, &query);
+    }
+}
+
+static void
+completeCallQuery(CallQuery& query) {
+    /* Get call start and duration */
+    int64_t gpuStart = 0, gpuDuration = 0, cpuDuration = 0, pixels = 0;
+
+    if (query.isDraw) {
+        if (retrace::profilingGpuTimes) {
+            if (supportsTimestamp) {
+                glGetQueryObjecti64vEXT(query.ids[0], GL_QUERY_RESULT, &gpuStart);
+            }
+
+            glGetQueryObjecti64vEXT(query.ids[1], GL_QUERY_RESULT, &gpuDuration);
+        }
+
+        if (retrace::profilingPixelsDrawn) {
+            glGetQueryObjecti64vEXT(query.ids[2], GL_QUERY_RESULT, &pixels);
+        }
+
+        glDeleteQueries(3, query.ids);
+    } else {
+        pixels = -1;
+    }
+
+    if (retrace::profilingCpuTimes) {
+        cpuDuration = query.cpuEnd - query.cpuStart;
+    }
+
+    /* Add call to profile */
+    retrace::profiler.addCall(query.call, query.sig->name, query.program, pixels, gpuStart, gpuDuration, query.cpuStart, cpuDuration);
+}
+
+void
+flushQueries() {
+    for (std::list<CallQuery>::iterator itr = callQueries.begin(); itr != callQueries.end(); ++itr) {
+        completeCallQuery(*itr);
+    }
+
+    callQueries.clear();
+}
+
+void
+beginProfile(trace::Call &call, bool isDraw) {
+    /* Create call query */
+    CallQuery query;
+    query.isDraw = isDraw;
+    query.call = call.no;
+    query.sig = call.sig;
+    query.program = glretrace::currentContext ? glretrace::currentContext->activeProgram : 0;
+
+    /* GPU profiling only for draw calls */
+    if (isDraw) {
+        glGenQueries(3, query.ids);
+
+        if (retrace::profilingGpuTimes) {
+            if (supportsTimestamp) {
+                glQueryCounter(query.ids[0], GL_TIMESTAMP);
+            }
+
+            glBeginQuery(GL_TIME_ELAPSED, query.ids[1]);
+        }
+
+        if (retrace::profilingPixelsDrawn) {
+            glBeginQuery(GL_SAMPLES_PASSED, query.ids[2]);
+        }
+    }
+
+    callQueries.push_back(query);
+
+    /* CPU profiling for all calls */
+    if (retrace::profilingCpuTimes) {
+       callQueries.back().cpuStart = os::getTime();
+    }
+}
+
+void
+endProfile(trace::Call &call, bool isDraw) {
+    GLint64 time = os::getTime();
+
+    /* CPU profiling for all calls */
+    if (retrace::profilingCpuTimes) {
+        CallQuery& query = callQueries.back();
+        query.cpuEnd = time;
+    }
+
+    /* GPU profiling only for draw calls */
+    if (isDraw) {
+        if (retrace::profilingGpuTimes) {
+            glEndQuery(GL_TIME_ELAPSED);
+        }
+
+        if (retrace::profilingPixelsDrawn) {
+            glEndQuery(GL_SAMPLES_PASSED);
+        }
+    }
+}
+
+void
+initContext() {
+    const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
+
+    /* Ensure we have adequate extension support */
+    supportsTimestamp   = glws::checkExtension("GL_ARB_timer_query", extensions);
+    supportsElapsed     = glws::checkExtension("GL_EXT_timer_query", extensions) || supportsTimestamp;
+    supportsOcclusion   = glws::checkExtension("GL_ARB_occlusion_query", extensions);
+    supportsDebugOutput = glws::checkExtension("GL_ARB_debug_output", extensions);
+
+    /* Check for timer query support */
+    if (retrace::profilingGpuTimes) {
+        if (!supportsTimestamp && !supportsElapsed) {
+            std::cout << "Error: Cannot run profile, GL_EXT_timer_query extension is not supported." << std::endl;
+            exit(-1);
+        }
+
+        GLint bits = 0;
+        glGetQueryiv(GL_TIME_ELAPSED, GL_QUERY_COUNTER_BITS, &bits);
+
+        if (!bits) {
+            std::cout << "Error: Cannot run profile, GL_QUERY_COUNTER_BITS == 0." << std::endl;
+            exit(-1);
+        }
+    }
+
+    /* Check for occlusion query support */
+    if (retrace::profilingPixelsDrawn && !supportsOcclusion) {
+        std::cout << "Error: Cannot run profile, GL_ARB_occlusion_query extension is not supported." << std::endl;
+        exit(-1);
+    }
+
+    /* Setup debug message call back */
+    if (retrace::debug && supportsDebugOutput) {
+        glDebugMessageCallbackARB(&debugOutputCallback, currentContext);
+
+        if (DEBUG_OUTPUT_SYNCHRONOUS) {
+            glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
+        }
+    }
+
+    /* Sync the gpu and cpu start times */
+    if (retrace::profilingCpuTimes || retrace::profilingGpuTimes) {
+        if (!retrace::profiler.hasBaseTimes()) {
+            GLint64 gpuTime, cpuTime;
+
+            getCurrentTimes(cpuTime, gpuTime);
+            retrace::profiler.setBaseCpuTime(cpuTime);
+            retrace::profiler.setBaseGpuTime(gpuTime);
+        }
+    }
+}
+
+void
+frame_complete(trace::Call &call) {
+    if (retrace::profiling) {
+        /* Complete any remaining queries */
+        flushQueries();
+
+        /* GPU time drifts due to being relative times, not absolute and can be
+         * affected by the gpu switch between processes.
+         *
+         * To attempt to compensate we resynchronise on frame end however there is
+         * still noticeable drift within a single frame which we do not account for.
+         */
+        if (retrace::profilingCpuTimes || retrace::profilingGpuTimes) {
+            int64_t cpuTime, gpuTime, error;
+
+            getCurrentTimes(cpuTime, gpuTime);
+            cpuTime = cpuTime - retrace::profiler.getBaseCpuTime();
+            gpuTime = gpuTime - retrace::profiler.getBaseGpuTime();
+            error   = gpuTime - cpuTime * (1.0E9 / os::timeFrequency);
+
+            retrace::profiler.setBaseGpuTime(retrace::profiler.getBaseGpuTime() + error);
+        }
+
+        /* Indicate end of current frame */
+        retrace::profiler.addFrameEnd();
+    }
+
+    retrace::frameComplete(call);
+
+    if (!currentDrawable) {
+        return;
+    }
+
+    if (retrace::debug && !currentDrawable->visible) {
+        retrace::warning(call) << "could not infer drawable size (glViewport never called)\n";
+    }
+}
+
+static const char*
+getDebugOutputSource(GLenum source) {
+    switch(source) {
+    case GL_DEBUG_SOURCE_API_ARB:
+        return "API";
+    case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
+        return "Window System";
+    case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
+        return "Shader Compiler";
+    case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
+        return "Third Party";
+    case GL_DEBUG_SOURCE_APPLICATION_ARB:
+        return "Application";
+    case GL_DEBUG_SOURCE_OTHER_ARB:
+    default:
+        return "";
+    }
+}
+
+static const char*
+getDebugOutputType(GLenum type) {
+    switch(type) {
+    case GL_DEBUG_TYPE_ERROR_ARB:
+        return "error";
+    case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
+        return "deprecated behaviour";
+    case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
+        return "undefined behaviour";
+    case GL_DEBUG_TYPE_PORTABILITY_ARB:
+        return "portability issue";
+    case GL_DEBUG_TYPE_PERFORMANCE_ARB:
+        return "performance issue";
+    case GL_DEBUG_TYPE_OTHER_ARB:
+    default:
+        return "unknown issue";
+    }
+}
+
+static const char*
+getDebugOutputSeverity(GLenum severity) {
+    switch(severity) {
+    case GL_DEBUG_SEVERITY_HIGH_ARB:
+        return "High";
+    case GL_DEBUG_SEVERITY_MEDIUM_ARB:
+        return "Medium";
+    case GL_DEBUG_SEVERITY_LOW_ARB:
+        return "Low";
+    default:
+        return "usnknown";
+    }
+}
+
+static void APIENTRY
+debugOutputCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) {
+    std::cerr << retrace::callNo << ": ";
+    std::cerr << "glDebugOutputCallback: ";
+    std::cerr << getDebugOutputSeverity(severity) << " severity ";
+    std::cerr << getDebugOutputSource(source) << " " << getDebugOutputType(type);
+    std::cerr << " " << id;
+    std::cerr << ", " << message;
+    std::cerr << std::endl;
+}
+
+} /* namespace glretrace */
+
+
+void
+retrace::setUp(void) {
+    glws::init();
+}
+
+
+void
+retrace::addCallbacks(retrace::Retracer &retracer)
+{
+    retracer.addCallbacks(glretrace::gl_callbacks);
+    retracer.addCallbacks(glretrace::glx_callbacks);
+    retracer.addCallbacks(glretrace::wgl_callbacks);
+    retracer.addCallbacks(glretrace::cgl_callbacks);
+    retracer.addCallbacks(glretrace::egl_callbacks);
+}
+
+
+image::Image *
+retrace::getSnapshot(void) {
+    if (!glretrace::currentDrawable) {
+        return NULL;
+    }
+
+    return glstate::getDrawBufferImage();
+}
+
+
+bool
+retrace::dumpState(std::ostream &os)
+{
+    if (glretrace::insideGlBeginEnd ||
+        !glretrace::currentDrawable ||
+        !glretrace::currentContext) {
+        return false;
+    }
+
+    glstate::dumpCurrentContext(os);
+
+    return true;
+}
+
+void
+retrace::flushRendering(void) {
+    glretrace::flushQueries();
+    glFlush();
+}
+
+void
+retrace::waitForInput(void) {
+    while (glws::processEvents()) {
+    }
+}
+
+void
+retrace::cleanUp(void) {
+    glws::cleanup();
+}
diff --git a/retrace/glretrace_wgl.cpp b/retrace/glretrace_wgl.cpp
new file mode 100644 (file)
index 0000000..bf2f38a
--- /dev/null
@@ -0,0 +1,304 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "glproc.hpp"
+#include "retrace.hpp"
+#include "glretrace.hpp"
+
+
+using namespace glretrace;
+
+
+typedef std::map<unsigned long long, glws::Drawable *> DrawableMap;
+typedef std::map<unsigned long long, Context *> ContextMap;
+static DrawableMap drawable_map;
+static DrawableMap pbuffer_map;
+static ContextMap context_map;
+
+
+static glws::Drawable *
+getDrawable(unsigned long long hdc) {
+    if (hdc == 0) {
+        return NULL;
+    }
+
+    DrawableMap::const_iterator it;
+    it = drawable_map.find(hdc);
+    if (it == drawable_map.end()) {
+        return (drawable_map[hdc] = glretrace::createDrawable());
+    }
+
+    return it->second;
+}
+
+static void retrace_wglCreateContext(trace::Call &call) {
+    unsigned long long orig_context = call.ret->toUIntPtr();
+    Context *context = glretrace::createContext();
+    context_map[orig_context] = context;
+}
+
+static void retrace_wglDeleteContext(trace::Call &call) {
+    unsigned long long hglrc = call.arg(0).toUIntPtr();
+
+    ContextMap::iterator it;
+    it = context_map.find(hglrc);
+    if (it == context_map.end()) {
+        return;
+    }
+
+    delete it->second;
+    
+    context_map.erase(it);
+}
+
+static void retrace_wglMakeCurrent(trace::Call &call) {
+    glws::Drawable *new_drawable = getDrawable(call.arg(0).toUIntPtr());
+    Context *new_context = context_map[call.arg(1).toUIntPtr()];
+
+    glretrace::makeCurrent(call, new_drawable, new_context);
+}
+
+static void retrace_wglCopyContext(trace::Call &call) {
+}
+
+static void retrace_wglChoosePixelFormat(trace::Call &call) {
+}
+
+static void retrace_wglDescribePixelFormat(trace::Call &call) {
+}
+
+static void retrace_wglSetPixelFormat(trace::Call &call) {
+}
+
+static void retrace_wglSwapBuffers(trace::Call &call) {
+    frame_complete(call);
+    if (retrace::doubleBuffer) {
+        currentDrawable->swapBuffers();
+    } else {
+        glFlush();
+    }
+}
+
+static void retrace_wglShareLists(trace::Call &call) {
+    unsigned long long hglrc1 = call.arg(0).toUIntPtr();
+    unsigned long long hglrc2 = call.arg(1).toUIntPtr();
+
+    Context *share_context = context_map[hglrc1];
+    Context *old_context = context_map[hglrc2];
+
+    Context *new_context = glretrace::createContext(share_context);
+    if (new_context) {
+        if (currentContext == old_context) {
+            glretrace::makeCurrent(call, currentDrawable, new_context);
+        }
+
+        context_map[hglrc2] = new_context;
+        
+        delete old_context;
+    }
+}
+
+static void retrace_wglCreateLayerContext(trace::Call &call) {
+    retrace_wglCreateContext(call);
+}
+
+static void retrace_wglDescribeLayerPlane(trace::Call &call) {
+}
+
+static void retrace_wglSetLayerPaletteEntries(trace::Call &call) {
+}
+
+static void retrace_wglRealizeLayerPalette(trace::Call &call) {
+}
+
+static void retrace_wglSwapLayerBuffers(trace::Call &call) {
+    retrace_wglSwapBuffers(call);
+}
+
+static void retrace_wglUseFontBitmapsA(trace::Call &call) {
+}
+
+static void retrace_wglUseFontBitmapsW(trace::Call &call) {
+}
+
+static void retrace_wglSwapMultipleBuffers(trace::Call &call) {
+}
+
+static void retrace_wglUseFontOutlinesA(trace::Call &call) {
+}
+
+static void retrace_wglUseFontOutlinesW(trace::Call &call) {
+}
+
+static void retrace_wglCreateBufferRegionARB(trace::Call &call) {
+}
+
+static void retrace_wglDeleteBufferRegionARB(trace::Call &call) {
+}
+
+static void retrace_wglSaveBufferRegionARB(trace::Call &call) {
+}
+
+static void retrace_wglRestoreBufferRegionARB(trace::Call &call) {
+}
+
+static void retrace_wglChoosePixelFormatARB(trace::Call &call) {
+}
+
+static void retrace_wglMakeContextCurrentARB(trace::Call &call) {
+}
+
+static void retrace_wglCreatePbufferARB(trace::Call &call) {
+    int iWidth = call.arg(2).toUInt();
+    int iHeight = call.arg(3).toUInt();
+
+    unsigned long long orig_pbuffer = call.ret->toUIntPtr();
+    glws::Drawable *drawable = glretrace::createDrawable();
+
+    drawable->resize(iWidth, iHeight);
+    drawable->show();
+
+    pbuffer_map[orig_pbuffer] = drawable;
+}
+
+static void retrace_wglGetPbufferDCARB(trace::Call &call) {
+    glws::Drawable *pbuffer = pbuffer_map[call.arg(0).toUIntPtr()];
+
+    unsigned long long orig_hdc = call.ret->toUIntPtr();
+
+    drawable_map[orig_hdc] = pbuffer;
+}
+
+static void retrace_wglReleasePbufferDCARB(trace::Call &call) {
+}
+
+static void retrace_wglDestroyPbufferARB(trace::Call &call) {
+}
+
+static void retrace_wglQueryPbufferARB(trace::Call &call) {
+}
+
+static void retrace_wglBindTexImageARB(trace::Call &call) {
+}
+
+static void retrace_wglReleaseTexImageARB(trace::Call &call) {
+}
+
+static void retrace_wglSetPbufferAttribARB(trace::Call &call) {
+}
+
+static void retrace_wglCreateContextAttribsARB(trace::Call &call) {
+    unsigned long long orig_context = call.ret->toUIntPtr();
+    Context *share_context = NULL;
+
+    if (call.arg(1).toPointer()) {
+        share_context = context_map[call.arg(1).toUIntPtr()];
+    }
+
+    Context *context = glretrace::createContext(share_context);
+    context_map[orig_context] = context;
+}
+
+static void retrace_wglMakeContextCurrentEXT(trace::Call &call) {
+}
+
+static void retrace_wglChoosePixelFormatEXT(trace::Call &call) {
+}
+
+static void retrace_wglSwapIntervalEXT(trace::Call &call) {
+}
+
+static void retrace_wglAllocateMemoryNV(trace::Call &call) {
+}
+
+static void retrace_wglFreeMemoryNV(trace::Call &call) {
+}
+
+static void retrace_glAddSwapHintRectWIN(trace::Call &call) {
+}
+
+static void retrace_wglGetProcAddress(trace::Call &call) {
+}
+
+const retrace::Entry glretrace::wgl_callbacks[] = {
+    {"glAddSwapHintRectWIN", &retrace_glAddSwapHintRectWIN},
+    {"wglAllocateMemoryNV", &retrace_wglAllocateMemoryNV},
+    {"wglBindTexImageARB", &retrace_wglBindTexImageARB},
+    {"wglChoosePixelFormat", &retrace_wglChoosePixelFormat},
+    {"wglChoosePixelFormatARB", &retrace_wglChoosePixelFormatARB},
+    {"wglChoosePixelFormatEXT", &retrace_wglChoosePixelFormatEXT},
+    {"wglCopyContext", &retrace_wglCopyContext},
+    {"wglCreateBufferRegionARB", &retrace_wglCreateBufferRegionARB},
+    {"wglCreateContext", &retrace_wglCreateContext},
+    {"wglCreateContextAttribsARB", &retrace_wglCreateContextAttribsARB},
+    {"wglCreateLayerContext", &retrace_wglCreateLayerContext},
+    {"wglCreatePbufferARB", &retrace_wglCreatePbufferARB},
+    {"wglDeleteBufferRegionARB", &retrace_wglDeleteBufferRegionARB},
+    {"wglDeleteContext", &retrace_wglDeleteContext},
+    {"wglDescribeLayerPlane", &retrace_wglDescribeLayerPlane},
+    {"wglDescribePixelFormat", &retrace_wglDescribePixelFormat},
+    {"wglDestroyPbufferARB", &retrace_wglDestroyPbufferARB},
+    {"wglFreeMemoryNV", &retrace_wglFreeMemoryNV},
+    {"wglGetCurrentContext", &retrace::ignore},
+    {"wglGetCurrentDC", &retrace::ignore},
+    {"wglGetCurrentReadDCARB", &retrace::ignore},
+    {"wglGetCurrentReadDCEXT", &retrace::ignore},
+    {"wglGetDefaultProcAddress", &retrace::ignore},
+    {"wglGetExtensionsStringARB", &retrace::ignore},
+    {"wglGetExtensionsStringEXT", &retrace::ignore},
+    {"wglGetLayerPaletteEntries", &retrace::ignore},
+    {"wglGetPbufferDCARB", &retrace_wglGetPbufferDCARB},
+    {"wglGetPixelFormat", &retrace::ignore},
+    {"wglGetPixelFormatAttribfvARB", &retrace::ignore},
+    {"wglGetPixelFormatAttribfvEXT", &retrace::ignore},
+    {"wglGetPixelFormatAttribivARB", &retrace::ignore},
+    {"wglGetPixelFormatAttribivEXT", &retrace::ignore},
+    {"wglGetProcAddress", &retrace_wglGetProcAddress},
+    {"wglGetSwapIntervalEXT", &retrace::ignore},
+    {"wglMakeContextCurrentARB", &retrace_wglMakeContextCurrentARB},
+    {"wglMakeContextCurrentEXT", &retrace_wglMakeContextCurrentEXT},
+    {"wglMakeCurrent", &retrace_wglMakeCurrent},
+    {"wglQueryPbufferARB", &retrace_wglQueryPbufferARB},
+    {"wglRealizeLayerPalette", &retrace_wglRealizeLayerPalette},
+    {"wglReleasePbufferDCARB", &retrace_wglReleasePbufferDCARB},
+    {"wglReleaseTexImageARB", &retrace_wglReleaseTexImageARB},
+    {"wglRestoreBufferRegionARB", &retrace_wglRestoreBufferRegionARB},
+    {"wglSaveBufferRegionARB", &retrace_wglSaveBufferRegionARB},
+    {"wglSetLayerPaletteEntries", &retrace_wglSetLayerPaletteEntries},
+    {"wglSetPbufferAttribARB", &retrace_wglSetPbufferAttribARB},
+    {"wglSetPixelFormat", &retrace_wglSetPixelFormat},
+    {"wglShareLists", &retrace_wglShareLists},
+    {"wglSwapBuffers", &retrace_wglSwapBuffers},
+    {"wglSwapIntervalEXT", &retrace_wglSwapIntervalEXT},
+    {"wglSwapLayerBuffers", &retrace_wglSwapLayerBuffers},
+    {"wglSwapMultipleBuffers", &retrace_wglSwapMultipleBuffers},
+    {"wglUseFontBitmapsA", &retrace_wglUseFontBitmapsA},
+    {"wglUseFontBitmapsW", &retrace_wglUseFontBitmapsW},
+    {"wglUseFontOutlinesA", &retrace_wglUseFontOutlinesA},
+    {"wglUseFontOutlinesW", &retrace_wglUseFontOutlinesW},
+    {NULL, NULL}
+};
+
diff --git a/retrace/glretrace_ws.cpp b/retrace/glretrace_ws.cpp
new file mode 100644 (file)
index 0000000..bead54e
--- /dev/null
@@ -0,0 +1,193 @@
+/**************************************************************************
+ *
+ * Copyright 2011-2012 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/**
+ * Window system helpers for glretrace.
+ */
+
+
+#include <string.h>
+
+#include "retrace.hpp"
+#include "glproc.hpp"
+#include "glstate.hpp"
+#include "glretrace.hpp"
+
+
+namespace glretrace {
+
+
+glws::Drawable *currentDrawable = NULL;
+Context *currentContext = NULL;
+
+
+static glws::Visual *
+visuals[glws::PROFILE_MAX];
+
+
+inline glws::Visual *
+getVisual(glws::Profile profile) {
+    glws::Visual * & visual = visuals[profile];
+    if (!visual) {
+        visual = glws::createVisual(retrace::doubleBuffer, profile);
+    }
+    return visual;
+}
+
+
+inline glws::Profile
+getDefaultProfile(void)
+{
+    if (retrace::coreProfile) {
+        return glws::PROFILE_CORE;
+    } else {
+        return glws::PROFILE_COMPAT;
+    }
+}
+
+
+glws::Drawable *
+createDrawable(glws::Profile profile) {
+    glws::Drawable *draw = glws::createDrawable(getVisual(profile));
+    if (!draw) {
+        std::cerr << "error: failed to create OpenGL drawable\n";
+        exit(1);
+        return NULL;
+    }
+
+    return draw;
+}
+
+
+glws::Drawable *
+createDrawable(void) {
+    return glretrace::createDrawable(getDefaultProfile());
+}
+
+
+Context *
+createContext(Context *shareContext, glws::Profile profile) {
+    glws::Context *shareWsContext = shareContext ? shareContext->wsContext : NULL;
+    glws::Context *ctx = glws::createContext(getVisual(profile), shareWsContext, profile, retrace::debug);
+    if (!ctx) {
+        std::cerr << "error: failed to create OpenGL context\n";
+        exit(1);
+        return NULL;
+    }
+
+    return new Context(ctx);
+}
+
+
+Context *
+createContext(Context *shareContext) {
+    return createContext(shareContext, getDefaultProfile());
+}
+
+
+bool
+makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context)
+{
+    if (drawable == currentDrawable && context == currentContext) {
+        return true;
+    }
+
+    if (currentDrawable && currentContext) {
+        glFlush();
+        if (!retrace::doubleBuffer) {
+            frame_complete(call);
+        }
+    }
+
+    flushQueries();
+
+    bool success = glws::makeCurrent(drawable, context ? context->wsContext : NULL);
+
+    if (!success) {
+        std::cerr << "error: failed to make current OpenGL context and drawable\n";
+        exit(1);
+        return false;
+    }
+
+    if (context) {
+        if (!context->used) {
+            initContext();
+            context->used = true;
+        }
+    }
+
+    if (drawable && context) {
+        currentDrawable = drawable;
+        currentContext = context;
+    } else {
+        currentDrawable = NULL;
+        currentContext = NULL;
+    }
+
+    return true;
+}
+
+
+
+
+/**
+ * Grow the current drawble.
+ *
+ * We need to infer the drawable size from GL calls because the drawable sizes
+ * are specified by OS specific calls which we do not trace.
+ */
+void
+updateDrawable(int width, int height) {
+    if (!currentDrawable) {
+        return;
+    }
+
+    if (currentDrawable->visible &&
+        width  <= currentDrawable->width &&
+        height <= currentDrawable->height) {
+        return;
+    }
+
+    // Ignore zero area viewports
+    if (width == 0 || height == 0) {
+        return;
+    }
+
+    // Check for bound framebuffer last, as this may have a performance impact.
+    GLint draw_framebuffer = 0;
+    glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer);
+    if (draw_framebuffer != 0) {
+        return;
+    }
+
+    currentDrawable->resize(width, height);
+    currentDrawable->show();
+
+    glScissor(0, 0, width, height);
+}
+
+
+} /* namespace glretrace */
diff --git a/retrace/glstate.cpp b/retrace/glstate.cpp
new file mode 100644 (file)
index 0000000..0d5a5f3
--- /dev/null
@@ -0,0 +1,155 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+
+#include <algorithm>
+#include <iostream>
+
+#include "image.hpp"
+#include "json.hpp"
+#include "glproc.hpp"
+#include "glsize.hpp"
+#include "glstate.hpp"
+#include "glstate_internal.hpp"
+
+
+namespace glstate {
+
+
+Context::Context(void) {
+    memset(this, 0, sizeof *this);
+
+    const char *version = (const char *)glGetString(GL_VERSION);
+    if (version) {
+        if (version[0] == 'O' &&
+            version[1] == 'p' &&
+            version[2] == 'e' &&
+            version[3] == 'n' &&
+            version[4] == 'G' &&
+            version[5] == 'L' &&
+            version[6] == ' ' &&
+            version[7] == 'E' &&
+            version[8] == 'S' &&
+            (version[9] == ' ' || version[9] == '-')) {
+            ES = true;
+        }
+    }
+
+    ARB_draw_buffers = !ES;
+
+    // TODO: Check extensions we use below
+}
+
+void
+Context::resetPixelPackState(void) {
+    if (!ES) {
+        glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+        glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+        glPixelStorei(GL_PACK_SWAP_BYTES, GL_FALSE);
+        glPixelStorei(GL_PACK_LSB_FIRST, GL_FALSE);
+        glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+        glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0);
+        glPixelStorei(GL_PACK_SKIP_ROWS, 0);
+        glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+        glPixelStorei(GL_PACK_SKIP_IMAGES, 0);
+    } else {
+        packAlignment = 4;
+        glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
+    }
+    glPixelStorei(GL_PACK_ALIGNMENT, 1);
+}
+
+void
+Context::restorePixelPackState(void) {
+    if (!ES) {
+        glPopClientAttrib();
+    } else {
+        glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);
+    }
+}
+
+
+static const GLenum bindings[] = {
+    GL_DRAW_BUFFER,
+    GL_READ_BUFFER,
+    GL_PIXEL_PACK_BUFFER_BINDING,
+    GL_PIXEL_UNPACK_BUFFER_BINDING,
+    GL_TEXTURE_BINDING_1D,
+    GL_TEXTURE_BINDING_2D,
+    GL_TEXTURE_BINDING_3D,
+    GL_TEXTURE_BINDING_RECTANGLE,
+    GL_TEXTURE_BINDING_CUBE_MAP,
+    GL_DRAW_FRAMEBUFFER_BINDING,
+    GL_READ_FRAMEBUFFER_BINDING,
+    GL_RENDERBUFFER_BINDING,
+    GL_DRAW_BUFFER0,
+    GL_DRAW_BUFFER1,
+    GL_DRAW_BUFFER2,
+    GL_DRAW_BUFFER3,
+    GL_DRAW_BUFFER4,
+    GL_DRAW_BUFFER5,
+    GL_DRAW_BUFFER6,
+    GL_DRAW_BUFFER7,
+};
+
+
+#define NUM_BINDINGS sizeof(bindings)/sizeof(bindings[0])
+
+
+void dumpCurrentContext(std::ostream &os)
+{
+    JSONWriter json(os);
+
+#ifndef NDEBUG
+    GLint old_bindings[NUM_BINDINGS];
+    for (unsigned i = 0; i < NUM_BINDINGS; ++i) {
+        old_bindings[i] = 0;
+        glGetIntegerv(bindings[i], &old_bindings[i]);
+    }
+#endif
+
+    Context context;
+
+    dumpParameters(json, context);
+    dumpShadersUniforms(json, context);
+    dumpTextures(json, context);
+    dumpFramebuffer(json, context);
+
+#ifndef NDEBUG
+    for (unsigned i = 0; i < NUM_BINDINGS; ++i) {
+        GLint new_binding = 0;
+        glGetIntegerv(bindings[i], &new_binding);
+        if (new_binding != old_bindings[i]) {
+            std::cerr << "warning: " << enumToString(bindings[i]) << " was clobbered\n";
+        }
+    }
+#endif
+
+}
+
+
+} /* namespace glstate */
diff --git a/retrace/glstate.hpp b/retrace/glstate.hpp
new file mode 100644 (file)
index 0000000..6fb615f
--- /dev/null
@@ -0,0 +1,54 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _GLSTATE_HPP_
+#define _GLSTATE_HPP_
+
+
+#include <ostream>
+
+#include "glimports.hpp"
+
+
+namespace image {
+    class Image;
+}
+
+
+namespace glstate {
+
+
+const char *enumToString(GLenum pname);
+
+void dumpCurrentContext(std::ostream &os);
+
+image::Image *
+getDrawBufferImage(void);
+
+
+} /* namespace glstate */
+
+
+#endif /* _GLSTATE_HPP_ */
diff --git a/retrace/glstate_images.cpp b/retrace/glstate_images.cpp
new file mode 100644 (file)
index 0000000..6390980
--- /dev/null
@@ -0,0 +1,1189 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+
+#include <algorithm>
+#include <iostream>
+
+#include "image.hpp"
+#include "json.hpp"
+#include "glproc.hpp"
+#include "glsize.hpp"
+#include "glstate.hpp"
+#include "glstate_internal.hpp"
+
+
+#ifdef __linux__
+#include <dlfcn.h>
+#endif
+
+#ifdef __APPLE__
+
+#include <Carbon/Carbon.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSStatus CGSGetSurfaceBounds(CGSConnectionID, CGWindowID, CGSSurfaceID, CGRect *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __APPLE__ */
+
+
+/* Change thi to one to force interpreting depth buffers as RGBA, which enables
+ * visualizing full dynamic range, until we can transmit HDR images to the GUI */
+#define DEPTH_AS_RGBA 0
+
+
+namespace glstate {
+
+
+struct ImageDesc
+{
+    GLint width;
+    GLint height;
+    GLint depth;
+    GLint internalFormat;
+
+    inline
+    ImageDesc() :
+        width(0),
+        height(0),
+        depth(0),
+        internalFormat(GL_NONE)
+    {}
+
+    inline bool
+    valid(void) const {
+        return width > 0 && height > 0 && depth > 0;
+    }
+};
+
+
+/**
+ * OpenGL ES does not support glGetTexLevelParameteriv, but it is possible to
+ * probe whether a texture has a given size by crafting a dummy glTexSubImage()
+ * call.
+ */
+static bool
+probeTextureLevelSizeOES(GLenum target, GLint level, const GLint size[3]) {
+    while (glGetError() != GL_NO_ERROR)
+        ;
+
+    GLenum internalFormat = GL_RGBA;
+    GLenum type = GL_UNSIGNED_BYTE;
+    GLint dummy = 0;
+
+    switch (target) {
+    case GL_TEXTURE_2D:
+    case GL_TEXTURE_CUBE_MAP:
+    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:
+        glTexSubImage2D(target, level, size[0], size[1], 0, 0, internalFormat, type, &dummy);
+        break;
+    case GL_TEXTURE_3D_OES:
+        glTexSubImage3DOES(target, level, size[0], size[1], size[2], 0, 0, 0, internalFormat, type, &dummy);
+    default:
+        assert(0);
+        return false;
+    }
+
+    GLenum error = glGetError();
+
+    if (0) {
+        std::cerr << "(" << size[0] << ", " << size[1] << ", " << size[2] << ") = " << enumToString(error) << "\n";
+    }
+
+    if (error == GL_NO_ERROR) {
+        return true;
+    }
+
+    while (glGetError() != GL_NO_ERROR)
+        ;
+
+    return false;
+}
+
+
+/**
+ * Bisect the texture size along an axis.
+ *
+ * It is assumed that the texture exists.
+ */
+static GLint
+bisectTextureLevelSizeOES(GLenum target, GLint level, GLint axis, GLint max) {
+    GLint size[3] = {0, 0, 0};
+
+    assert(axis < 3);
+    assert(max >= 0);
+
+    GLint min = 0;
+    while (true) {
+        GLint test = (min + max) / 2;
+        if (test == min) {
+            return min;
+        }
+
+        size[axis] = test;
+
+        if (probeTextureLevelSizeOES(target, level, size)) {
+            min = test;
+        } else {
+            max = test;
+        }
+    }
+}
+
+
+/**
+ * Special path to obtain texture size on OpenGL ES, that does not rely on
+ * glGetTexLevelParameteriv
+ */
+static bool
+getActiveTextureLevelDescOES(Context &context, GLenum target, GLint level, ImageDesc &desc)
+{
+    if (target == GL_TEXTURE_1D) {
+        // OpenGL ES does not support 1D textures
+        return false;
+    }
+
+    const GLint size[3] = {1, 1, 1}; 
+    if (!probeTextureLevelSizeOES(target, level, size)) {
+        return false;
+    }
+
+    // XXX: mere guess
+    desc.internalFormat = GL_RGBA;
+
+    GLint maxSize = 0;
+    switch (target) {
+    case GL_TEXTURE_2D:
+        glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);
+        desc.width = bisectTextureLevelSizeOES(target, level, 0, maxSize);
+        desc.height = bisectTextureLevelSizeOES(target, level, 1, maxSize);
+        desc.depth = 1;
+        break;
+    case GL_TEXTURE_CUBE_MAP:
+    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:
+        glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxSize);
+        desc.width = bisectTextureLevelSizeOES(target, level, 0, maxSize);
+        desc.height = desc.width;
+        desc.depth = 1;
+        break;
+    case GL_TEXTURE_3D_OES:
+        glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_OES, &maxSize);
+        desc.width = bisectTextureLevelSizeOES(target, level, 0, maxSize);
+        desc.width = bisectTextureLevelSizeOES(target, level, 1, maxSize);
+        desc.depth = bisectTextureLevelSizeOES(target, level, 2, maxSize);
+        break;
+    default:
+        return false;
+    }
+
+    if (0) {
+        std::cerr
+            << enumToString(target) << " "
+            << level << " "
+            << desc.width << "x" << desc.height << "x" << desc.depth
+            << "\n";
+    }
+
+    return desc.valid();
+}
+
+
+static inline bool
+getActiveTextureLevelDesc(Context &context, GLenum target, GLint level, ImageDesc &desc)
+{
+    if (context.ES) {
+        return getActiveTextureLevelDescOES(context, target, level, desc);
+    }
+
+    glGetTexLevelParameteriv(target, level, GL_TEXTURE_INTERNAL_FORMAT, &desc.internalFormat);
+
+    desc.width = 0;
+    glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &desc.width);
+
+    if (target == GL_TEXTURE_1D) {
+        desc.height = 1;
+        desc.depth = 1;
+    } else {
+        desc.height = 0;
+        glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &desc.height);
+        if (target != GL_TEXTURE_3D) {
+            desc.depth = 1;
+        } else {
+            desc.depth = 0;
+            glGetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &desc.depth);
+        }
+    }
+
+    return desc.valid();
+}
+
+
+/**
+ * OpenGL ES does not support glGetTexImage. Obtain the pixels by attaching the
+ * texture to a framebuffer.
+ */
+static inline void
+getTexImageOES(GLenum target, GLint level, ImageDesc &desc, GLubyte *pixels)
+{
+    memset(pixels, 0x80, desc.height * desc.width * 4);
+
+    GLenum texture_binding = GL_NONE;
+    switch (target) {
+    case GL_TEXTURE_2D:
+        texture_binding = GL_TEXTURE_BINDING_2D;
+        break;
+    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:
+        texture_binding = GL_TEXTURE_BINDING_CUBE_MAP;
+        break;
+    case GL_TEXTURE_3D_OES:
+        texture_binding = GL_TEXTURE_BINDING_3D_OES;
+    default:
+        return;
+    }
+
+    GLint texture = 0;
+    glGetIntegerv(texture_binding, &texture);
+    if (!texture) {
+        return;
+    }
+
+    GLint prev_fbo = 0;
+    GLuint fbo = 0;
+    glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prev_fbo);
+    glGenFramebuffers(1, &fbo);
+    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    GLenum status;
+
+    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:
+        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, level);
+        status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+        if (status != GL_FRAMEBUFFER_COMPLETE) {
+            std::cerr << __FUNCTION__ << ": " << enumToString(status) << "\n";
+        }
+        glReadPixels(0, 0, desc.width, desc.height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+        break;
+    case GL_TEXTURE_3D_OES:
+        for (int i = 0; i < desc.depth; i++) {
+            glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D, texture, level, i);
+            glReadPixels(0, 0, desc.width, desc.height, GL_RGBA, GL_UNSIGNED_BYTE, pixels + 4 * i * desc.width * desc.height);
+        }
+        break;
+    }
+
+    glBindFramebuffer(GL_FRAMEBUFFER, prev_fbo);
+
+    glDeleteFramebuffers(1, &fbo);
+}
+
+
+static inline GLboolean
+isDepthFormat(GLenum internalFormat)
+{
+   switch (internalFormat) {
+   case GL_DEPTH_COMPONENT:
+   case GL_DEPTH_COMPONENT16:
+   case GL_DEPTH_COMPONENT24:
+   case GL_DEPTH_COMPONENT32:
+   case GL_DEPTH_COMPONENT32F:
+   case GL_DEPTH_COMPONENT32F_NV:
+   case GL_DEPTH_STENCIL:
+   case GL_DEPTH24_STENCIL8:
+   case GL_DEPTH32F_STENCIL8:
+   case GL_DEPTH32F_STENCIL8_NV:
+      return GL_TRUE;
+   }
+   return GL_FALSE;
+}
+
+
+static inline void
+dumpActiveTextureLevel(JSONWriter &json, Context &context, GLenum target, GLint level)
+{
+    ImageDesc desc;
+    if (!getActiveTextureLevelDesc(context, target, level, desc)) {
+        return;
+    }
+
+    char label[512];
+
+    GLint active_texture = GL_TEXTURE0;
+    glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
+    snprintf(label, sizeof label, "%s, %s, level = %d",
+             enumToString(active_texture), enumToString(target), level);
+
+    json.beginMember(label);
+
+    json.beginObject();
+
+    GLuint channels;
+    GLenum format;
+    if (!context.ES && isDepthFormat(desc.internalFormat)) {
+       format = GL_DEPTH_COMPONENT;
+       channels = 1;
+    } else {
+       format = GL_RGBA;
+       channels = 4;
+    }
+
+    // Tell the GUI this is no ordinary object, but an image
+    json.writeStringMember("__class__", "image");
+
+    json.writeNumberMember("__width__", desc.width);
+    json.writeNumberMember("__height__", desc.height);
+    json.writeNumberMember("__depth__", desc.depth);
+
+    json.writeStringMember("__format__", enumToString(desc.internalFormat));
+
+    // Hardcoded for now, but we could chose types more adequate to the
+    // texture internal format
+    json.writeStringMember("__type__", "uint8");
+    json.writeBoolMember("__normalized__", true);
+    json.writeNumberMember("__channels__", channels);
+
+    GLubyte *pixels = new GLubyte[desc.depth*desc.width*desc.height*channels];
+
+    context.resetPixelPackState();
+
+    if (context.ES) {
+        getTexImageOES(target, level, desc, pixels);
+    } else {
+        glGetTexImage(target, level, format, GL_UNSIGNED_BYTE, pixels);
+    }
+
+    context.restorePixelPackState();
+
+    json.beginMember("__data__");
+    char *pngBuffer;
+    int pngBufferSize;
+    image::writePixelsToBuffer(pixels, desc.width, desc.height, channels, true, &pngBuffer, &pngBufferSize);
+    json.writeBase64(pngBuffer, pngBufferSize);
+    free(pngBuffer);
+    json.endMember(); // __data__
+
+    delete [] pixels;
+    json.endObject();
+}
+
+
+static inline void
+dumpTexture(JSONWriter &json, Context &context, GLenum target, GLenum binding)
+{
+    GLint texture_binding = 0;
+    glGetIntegerv(binding, &texture_binding);
+    if (!glIsEnabled(target) && !texture_binding) {
+        return;
+    }
+
+    GLint level = 0;
+    do {
+        ImageDesc desc;
+        if (!getActiveTextureLevelDesc(context, target, level, desc)) {
+            break;
+        }
+
+        if (target == GL_TEXTURE_CUBE_MAP) {
+            for (int face = 0; face < 6; ++face) {
+                dumpActiveTextureLevel(json, context, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level);
+            }
+        } else {
+            dumpActiveTextureLevel(json, context, target, level);
+        }
+
+        ++level;
+    } while(true);
+}
+
+
+void
+dumpTextures(JSONWriter &json, Context &context)
+{
+    json.beginMember("textures");
+    json.beginObject();
+    GLint active_texture = GL_TEXTURE0;
+    glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
+
+    GLint max_texture_coords = 0;
+    glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);
+    GLint max_combined_texture_image_units = 0;
+    glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);
+    GLint max_units = std::max(max_combined_texture_image_units, max_texture_coords);
+
+    /*
+     * At least the Android software GL implementation doesn't return the
+     * proper value for this, but rather returns 0. The GL(ES) specification
+     * mandates a minimum value of 2, so use this as a fall-back value.
+     */
+    max_units = std::max(max_units, 2);
+
+    for (GLint unit = 0; unit < max_units; ++unit) {
+        GLenum texture = GL_TEXTURE0 + unit;
+        glActiveTexture(texture);
+        dumpTexture(json, context, GL_TEXTURE_1D, GL_TEXTURE_BINDING_1D);
+        dumpTexture(json, context, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D);
+        dumpTexture(json, context, GL_TEXTURE_3D, GL_TEXTURE_BINDING_3D);
+        dumpTexture(json, context, GL_TEXTURE_RECTANGLE, GL_TEXTURE_BINDING_RECTANGLE);
+        dumpTexture(json, context, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BINDING_CUBE_MAP);
+    }
+    glActiveTexture(active_texture);
+    json.endObject();
+    json.endMember(); // textures
+}
+
+
+static bool
+getDrawableBounds(GLint *width, GLint *height) {
+#if defined(__linux__)
+    if (dlsym(RTLD_DEFAULT, "eglGetCurrentContext")) {
+        EGLContext currentContext = eglGetCurrentContext();
+        if (currentContext == EGL_NO_CONTEXT) {
+            return false;
+        }
+
+        EGLSurface currentSurface = eglGetCurrentSurface(EGL_DRAW);
+        if (currentSurface == EGL_NO_SURFACE) {
+            return false;
+        }
+
+        EGLDisplay currentDisplay = eglGetCurrentDisplay();
+        if (currentDisplay == EGL_NO_DISPLAY) {
+            return false;
+        }
+
+        if (!eglQuerySurface(currentDisplay, currentSurface, EGL_WIDTH, width) ||
+            !eglQuerySurface(currentDisplay, currentSurface, EGL_HEIGHT, height)) {
+            return false;
+        }
+
+        return true;
+    }
+#endif
+
+#if defined(_WIN32)
+
+    HDC hDC = wglGetCurrentDC();
+    if (!hDC) {
+        return false;
+    }
+
+    HWND hWnd = WindowFromDC(hDC);
+    RECT rect;
+
+    if (!GetClientRect(hWnd, &rect)) {
+       return false;
+    }
+
+    *width  = rect.right  - rect.left;
+    *height = rect.bottom - rect.top;
+    return true;
+
+#elif defined(__APPLE__)
+
+    CGLContextObj ctx = CGLGetCurrentContext();
+    if (ctx == NULL) {
+        return false;
+    }
+
+    CGSConnectionID cid;
+    CGSWindowID wid;
+    CGSSurfaceID sid;
+
+    if (CGLGetSurface(ctx, &cid, &wid, &sid) != kCGLNoError) {
+        return false;
+    }
+
+    CGRect rect;
+
+    if (CGSGetSurfaceBounds(cid, wid, sid, &rect) != 0) {
+        return false;
+    }
+
+    *width = rect.size.width;
+    *height = rect.size.height;
+    return true;
+
+#elif defined(HAVE_X11)
+
+    Display *display;
+    Drawable drawable;
+    Window root;
+    int x, y;
+    unsigned int w, h, bw, depth;
+
+    display = glXGetCurrentDisplay();
+    if (!display) {
+        return false;
+    }
+
+    drawable = glXGetCurrentDrawable();
+    if (drawable == None) {
+        return false;
+    }
+
+    if (!XGetGeometry(display, drawable, &root, &x, &y, &w, &h, &bw, &depth)) {
+        return false;
+    }
+
+    *width = w;
+    *height = h;
+    return true;
+
+#else
+
+    return false;
+
+#endif
+}
+
+
+static const GLenum texture_bindings[][2] = {
+    {GL_TEXTURE_1D, GL_TEXTURE_BINDING_1D},
+    {GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D},
+    {GL_TEXTURE_3D, GL_TEXTURE_BINDING_3D},
+    {GL_TEXTURE_RECTANGLE, GL_TEXTURE_BINDING_RECTANGLE},
+    {GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BINDING_CUBE_MAP}
+};
+
+
+static bool
+bindTexture(GLint texture, GLenum &target, GLint &bound_texture)
+{
+
+    for (unsigned i = 0; i < sizeof(texture_bindings)/sizeof(texture_bindings[0]); ++i) {
+        target  = texture_bindings[i][0];
+
+        GLenum binding = texture_bindings[i][1];
+
+        while (glGetError() != GL_NO_ERROR)
+            ;
+
+        glGetIntegerv(binding, &bound_texture);
+        glBindTexture(target, texture);
+
+        if (glGetError() == GL_NO_ERROR) {
+            return true;
+        }
+
+        glBindTexture(target, bound_texture);
+    }
+
+    target = GL_NONE;
+
+    return false;
+}
+
+
+static bool
+getTextureLevelDesc(Context &context, GLint texture, GLint level, ImageDesc &desc)
+{
+    GLenum target;
+    GLint bound_texture = 0;
+    if (!bindTexture(texture, target, bound_texture)) {
+        return false;
+    }
+
+    getActiveTextureLevelDesc(context, target, level, desc);
+
+    glBindTexture(target, bound_texture);
+
+    return desc.valid();
+}
+
+
+static bool
+getBoundRenderbufferDesc(Context &context, ImageDesc &desc)
+{
+    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &desc.width);
+    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &desc.height);
+    desc.depth = 1;
+    
+    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_INTERNAL_FORMAT, &desc.internalFormat);
+    
+    return desc.valid();
+}
+
+
+static bool
+getRenderbufferDesc(Context &context, GLint renderbuffer, ImageDesc &desc)
+{
+    GLint bound_renderbuffer = 0;
+    glGetIntegerv(GL_RENDERBUFFER_BINDING, &bound_renderbuffer);
+    glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
+
+    getBoundRenderbufferDesc(context, desc);
+
+    glBindRenderbuffer(GL_RENDERBUFFER, bound_renderbuffer);
+    
+    return desc.valid();
+}
+
+
+static bool
+getFramebufferAttachmentDesc(Context &context, GLenum target, GLenum attachment, ImageDesc &desc)
+{
+    GLint object_type = GL_NONE;
+    glGetFramebufferAttachmentParameteriv(target, attachment,
+                                          GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
+                                          &object_type);
+    if (object_type == GL_NONE) {
+        return false;
+    }
+
+    GLint object_name = 0;
+    glGetFramebufferAttachmentParameteriv(target, attachment,
+                                          GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
+                                          &object_name);
+    if (object_name == 0) {
+        return false;
+    }
+
+    if (object_type == GL_RENDERBUFFER) {
+        return getRenderbufferDesc(context, object_name, desc);
+    } else if (object_type == GL_TEXTURE) {
+        GLint texture_level = 0;
+        glGetFramebufferAttachmentParameteriv(target, attachment,
+                                              GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
+                                              &texture_level);
+        return getTextureLevelDesc(context, object_name, texture_level, desc);
+    } else {
+        std::cerr << "warning: unexpected GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = " << object_type << "\n";
+        return false;
+    }
+}
+
+
+
+image::Image *
+getDrawBufferImage() {
+    GLenum format = GL_RGB;
+    GLint channels = _gl_format_channels(format);
+    if (channels > 4) {
+        return NULL;
+    }
+
+    Context context;
+
+    GLenum framebuffer_binding;
+    GLenum framebuffer_target;
+    if (context.ES) {
+        framebuffer_binding = GL_FRAMEBUFFER_BINDING;
+        framebuffer_target = GL_FRAMEBUFFER;
+    } else {
+        framebuffer_binding = GL_DRAW_FRAMEBUFFER_BINDING;
+        framebuffer_target = GL_DRAW_FRAMEBUFFER;
+    }
+
+    GLint draw_framebuffer = 0;
+    glGetIntegerv(framebuffer_binding, &draw_framebuffer);
+
+    GLint draw_buffer = GL_NONE;
+    ImageDesc desc;
+    if (draw_framebuffer) {
+        if (context.ARB_draw_buffers) {
+            glGetIntegerv(GL_DRAW_BUFFER0, &draw_buffer);
+            if (draw_buffer == GL_NONE) {
+                return NULL;
+            }
+        }
+
+        if (!getFramebufferAttachmentDesc(context, framebuffer_target, draw_buffer, desc)) {
+            return NULL;
+        }
+    } else {
+        if (!context.ES) {
+            glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
+            if (draw_buffer == GL_NONE) {
+                return NULL;
+            }
+        }
+
+        if (!getDrawableBounds(&desc.width, &desc.height)) {
+            return NULL;
+        }
+
+        desc.depth = 1;
+    }
+
+    GLenum type = GL_UNSIGNED_BYTE;
+
+#if DEPTH_AS_RGBA
+    if (format == GL_DEPTH_COMPONENT) {
+        type = GL_UNSIGNED_INT;
+        channels = 4;
+    }
+#endif
+
+    image::Image *image = new image::Image(desc.width, desc.height, channels, true);
+    if (!image) {
+        return NULL;
+    }
+
+    while (glGetError() != GL_NO_ERROR) {}
+
+    GLint read_framebuffer = 0;
+    GLint read_buffer = GL_NONE;
+    if (!context.ES) {
+        glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_framebuffer);
+        glBindFramebuffer(GL_READ_FRAMEBUFFER, draw_framebuffer);
+
+        glGetIntegerv(GL_READ_BUFFER, &read_buffer);
+        glReadBuffer(draw_buffer);
+    }
+
+    // TODO: reset imaging state too
+    context.resetPixelPackState();
+
+    glReadPixels(0, 0, desc.width, desc.height, format, type, image->pixels);
+
+    context.restorePixelPackState();
+
+    if (!context.ES) {
+        glReadBuffer(read_buffer);
+        glBindFramebuffer(GL_READ_FRAMEBUFFER, read_framebuffer);
+    }
+
+    GLenum error = glGetError();
+    if (error != GL_NO_ERROR) {
+        do {
+            std::cerr << "warning: " << enumToString(error) << " while getting snapshot\n";
+            error = glGetError();
+        } while(error != GL_NO_ERROR);
+        delete image;
+        return NULL;
+    }
+     
+    return image;
+}
+
+
+/**
+ * Dump the image of the currently bound read buffer.
+ */
+static inline void
+dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format,
+                    GLint internalFormat = GL_NONE)
+{
+    GLint channels = _gl_format_channels(format);
+
+    if (internalFormat == GL_NONE) {
+        internalFormat = format;
+    }
+
+    Context context;
+
+    json.beginObject();
+
+    // Tell the GUI this is no ordinary object, but an image
+    json.writeStringMember("__class__", "image");
+
+    json.writeNumberMember("__width__", width);
+    json.writeNumberMember("__height__", height);
+    json.writeNumberMember("__depth__", 1);
+
+    json.writeStringMember("__format__", enumToString(internalFormat));
+
+    // Hardcoded for now, but we could chose types more adequate to the
+    // texture internal format
+    json.writeStringMember("__type__", "uint8");
+    json.writeBoolMember("__normalized__", true);
+    json.writeNumberMember("__channels__", channels);
+
+    GLenum type = GL_UNSIGNED_BYTE;
+
+#if DEPTH_AS_RGBA
+    if (format == GL_DEPTH_COMPONENT) {
+        type = GL_UNSIGNED_INT;
+        channels = 4;
+    }
+#endif
+
+    GLubyte *pixels = new GLubyte[width*height*channels];
+
+    // TODO: reset imaging state too
+    context.resetPixelPackState();
+
+    glReadPixels(0, 0, width, height, format, type, pixels);
+
+    context.restorePixelPackState();
+
+    json.beginMember("__data__");
+    char *pngBuffer;
+    int pngBufferSize;
+    image::writePixelsToBuffer(pixels, width, height, channels, true, &pngBuffer, &pngBufferSize);
+    //std::cerr <<" Before = "<<(width * height * channels * sizeof *pixels)
+    //          <<", after = "<<pngBufferSize << ", ratio = " << double(width * height * channels * sizeof *pixels)/pngBufferSize;
+    json.writeBase64(pngBuffer, pngBufferSize);
+    free(pngBuffer);
+    json.endMember(); // __data__
+
+    delete [] pixels;
+    json.endObject();
+}
+
+
+static inline GLuint
+downsampledFramebuffer(Context &context,
+                       GLuint oldFbo, GLint drawbuffer,
+                       GLint colorRb, GLint depthRb, GLint stencilRb,
+                       GLuint *rbs, GLint *numRbs)
+{
+    GLuint fbo;
+
+
+    *numRbs = 0;
+
+    glGenFramebuffers(1, &fbo);
+    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    {
+        // color buffer
+        ImageDesc desc;
+        glBindRenderbuffer(GL_RENDERBUFFER, colorRb);
+        getBoundRenderbufferDesc(context, desc);
+
+        glGenRenderbuffers(1, &rbs[*numRbs]);
+        glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
+        glRenderbufferStorage(GL_RENDERBUFFER, desc.internalFormat, desc.width, desc.height);
+        glFramebufferRenderbuffer(GL_FRAMEBUFFER, drawbuffer,
+                                  GL_RENDERBUFFER, rbs[*numRbs]);
+
+        glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
+        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
+        glDrawBuffer(drawbuffer);
+        glReadBuffer(drawbuffer);
+        glBlitFramebuffer(0, 0, desc.width, desc.height, 0, 0, desc.width, desc.height,
+                          GL_COLOR_BUFFER_BIT, GL_NEAREST);
+        glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+        ++*numRbs;
+    }
+
+    if (stencilRb == depthRb && stencilRb) {
+        //combined depth and stencil buffer
+        ImageDesc desc;
+        glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
+        getBoundRenderbufferDesc(context, desc);
+
+        glGenRenderbuffers(1, &rbs[*numRbs]);
+        glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
+        glRenderbufferStorage(GL_RENDERBUFFER, desc.internalFormat, desc.width, desc.height);
+        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
+                                  GL_RENDERBUFFER, rbs[*numRbs]);
+        glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
+        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
+        glBlitFramebuffer(0, 0, desc.width, desc.height, 0, 0, desc.width, desc.height,
+                          GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
+        glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+        ++*numRbs;
+    } else {
+        if (depthRb) {
+            ImageDesc desc;
+            glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
+            getBoundRenderbufferDesc(context, desc);
+
+            glGenRenderbuffers(1, &rbs[*numRbs]);
+            glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
+            glRenderbufferStorage(GL_RENDERBUFFER, desc.internalFormat, desc.width, desc.height);
+            glFramebufferRenderbuffer(GL_FRAMEBUFFER,
+                                      GL_DEPTH_ATTACHMENT,
+                                      GL_RENDERBUFFER, rbs[*numRbs]);
+            glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
+            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
+            glDrawBuffer(GL_DEPTH_ATTACHMENT);
+            glReadBuffer(GL_DEPTH_ATTACHMENT);
+            glBlitFramebuffer(0, 0, desc.width, desc.height, 0, 0, desc.width, desc.height,
+                              GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+            ++*numRbs;
+        }
+        if (stencilRb) {
+            ImageDesc desc;
+            glBindRenderbuffer(GL_RENDERBUFFER, stencilRb);
+            getBoundRenderbufferDesc(context, desc);
+
+            glGenRenderbuffers(1, &rbs[*numRbs]);
+            glBindRenderbuffer(GL_RENDERBUFFER, rbs[*numRbs]);
+            glRenderbufferStorage(GL_RENDERBUFFER, desc.internalFormat, desc.width, desc.height);
+            glFramebufferRenderbuffer(GL_FRAMEBUFFER,
+                                      GL_STENCIL_ATTACHMENT,
+                                      GL_RENDERBUFFER, rbs[*numRbs]);
+            glBindFramebuffer(GL_READ_FRAMEBUFFER, oldFbo);
+            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
+            glDrawBuffer(GL_STENCIL_ATTACHMENT);
+            glReadBuffer(GL_STENCIL_ATTACHMENT);
+            glBlitFramebuffer(0, 0, desc.width, desc.height, 0, 0, desc.width, desc.height,
+                              GL_STENCIL_BUFFER_BIT, GL_NEAREST);
+            ++*numRbs;
+        }
+    }
+
+    return fbo;
+}
+
+
+/**
+ * Dump images of current draw drawable/window.
+ */
+static void
+dumpDrawableImages(JSONWriter &json, Context &context)
+{
+    GLint width, height;
+
+    if (!getDrawableBounds(&width, &height)) {
+        return;
+    }
+
+    GLint draw_buffer = GL_NONE;
+    if (context.ES) {
+        draw_buffer = GL_BACK;
+    } else {
+        glGetIntegerv(GL_DRAW_BUFFER, &draw_buffer);
+        glReadBuffer(draw_buffer);
+    }
+
+    if (draw_buffer != GL_NONE) {
+        GLint read_buffer = GL_NONE;
+        if (!context.ES) {
+            glGetIntegerv(GL_READ_BUFFER, &read_buffer);
+        }
+
+        GLint alpha_bits = 0;
+#if 0
+        // XXX: Ignore alpha until we are able to match the traced visual
+        glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
+#endif
+        GLenum format = alpha_bits ? GL_RGBA : GL_RGB;
+        json.beginMember(enumToString(draw_buffer));
+        dumpReadBufferImage(json, width, height, format);
+        json.endMember();
+
+        if (!context.ES) {
+            glReadBuffer(read_buffer);
+        }
+    }
+
+    if (!context.ES) {
+        GLint depth_bits = 0;
+        glGetIntegerv(GL_DEPTH_BITS, &depth_bits);
+        if (depth_bits) {
+            json.beginMember("GL_DEPTH_COMPONENT");
+            dumpReadBufferImage(json, width, height, GL_DEPTH_COMPONENT);
+            json.endMember();
+        }
+
+        GLint stencil_bits = 0;
+        glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
+        if (stencil_bits) {
+            json.beginMember("GL_STENCIL_INDEX");
+            dumpReadBufferImage(json, width, height, GL_STENCIL_INDEX);
+            json.endMember();
+        }
+    }
+}
+
+
+/**
+ * Dump the specified framebuffer attachment.
+ *
+ * In the case of a color attachment, it assumes it is already bound for read.
+ */
+static void
+dumpFramebufferAttachment(JSONWriter &json, Context &context, GLenum target, GLenum attachment, GLenum format)
+{
+    ImageDesc desc;
+    if (!getFramebufferAttachmentDesc(context, target, attachment, desc)) {
+        return;
+    }
+
+    json.beginMember(enumToString(attachment));
+    dumpReadBufferImage(json, desc.width, desc.height, format, desc.internalFormat);
+    json.endMember();
+}
+
+
+static void
+dumpFramebufferAttachments(JSONWriter &json, Context &context, GLenum target)
+{
+    GLint read_framebuffer = 0;
+    glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_framebuffer);
+
+    GLint read_buffer = GL_NONE;
+    glGetIntegerv(GL_READ_BUFFER, &read_buffer);
+
+    GLint max_draw_buffers = 1;
+    glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
+    GLint max_color_attachments = 0;
+    glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);
+
+    for (GLint i = 0; i < max_draw_buffers; ++i) {
+        GLint draw_buffer = GL_NONE;
+        glGetIntegerv(GL_DRAW_BUFFER0 + i, &draw_buffer);
+        if (draw_buffer != GL_NONE) {
+            glReadBuffer(draw_buffer);
+            GLint attachment;
+            if (draw_buffer >= GL_COLOR_ATTACHMENT0 && draw_buffer < GL_COLOR_ATTACHMENT0 + max_color_attachments) {
+                attachment = draw_buffer;
+            } else {
+                std::cerr << "warning: unexpected GL_DRAW_BUFFER" << i << " = " << draw_buffer << "\n";
+                attachment = GL_COLOR_ATTACHMENT0;
+            }
+            GLint alpha_size = 0;
+            glGetFramebufferAttachmentParameteriv(target, attachment,
+                                                  GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
+                                                  &alpha_size);
+            GLenum format = alpha_size ? GL_RGBA : GL_RGB;
+            dumpFramebufferAttachment(json, context, target, attachment, format);
+        }
+    }
+
+    glReadBuffer(read_buffer);
+
+    if (!context.ES) {
+        dumpFramebufferAttachment(json, context, target, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT);
+        dumpFramebufferAttachment(json, context, target, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX);
+    }
+
+    glBindFramebuffer(GL_READ_FRAMEBUFFER, read_framebuffer);
+}
+
+
+void
+dumpFramebuffer(JSONWriter &json, Context &context)
+{
+    json.beginMember("framebuffer");
+    json.beginObject();
+
+    GLint boundDrawFbo = 0, boundReadFbo = 0;
+    glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &boundDrawFbo);
+    glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &boundReadFbo);
+    if (!boundDrawFbo) {
+        dumpDrawableImages(json, context);
+    } else if (context.ES) {
+        dumpFramebufferAttachments(json, context, GL_FRAMEBUFFER);
+    } else {
+        GLint colorRb = 0, stencilRb = 0, depthRb = 0;
+        GLint draw_buffer0 = GL_NONE;
+        glGetIntegerv(GL_DRAW_BUFFER0, &draw_buffer0);
+        bool multisample = false;
+
+        GLint boundRb = 0;
+        glGetIntegerv(GL_RENDERBUFFER_BINDING, &boundRb);
+
+        GLint object_type;
+        glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, draw_buffer0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);
+        if (object_type == GL_RENDERBUFFER) {
+            glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, draw_buffer0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &colorRb);
+            glBindRenderbuffer(GL_RENDERBUFFER, colorRb);
+            GLint samples = 0;
+            glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
+            if (samples) {
+                multisample = true;
+            }
+        }
+
+        glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);
+        if (object_type == GL_RENDERBUFFER) {
+            glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &depthRb);
+            glBindRenderbuffer(GL_RENDERBUFFER, depthRb);
+            GLint samples = 0;
+            glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
+            if (samples) {
+                multisample = true;
+            }
+        }
+
+        glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);
+        if (object_type == GL_RENDERBUFFER) {
+            glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &stencilRb);
+            glBindRenderbuffer(GL_RENDERBUFFER, stencilRb);
+            GLint samples = 0;
+            glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
+            if (samples) {
+                multisample = true;
+            }
+        }
+
+        glBindRenderbuffer(GL_RENDERBUFFER, boundRb);
+
+        GLuint rbs[3];
+        GLint numRbs = 0;
+        GLuint fboCopy = 0;
+
+        if (multisample) {
+            // glReadPixels doesnt support multisampled buffers so we need
+            // to blit the fbo to a temporary one
+            fboCopy = downsampledFramebuffer(context,
+                                             boundDrawFbo, draw_buffer0,
+                                             colorRb, depthRb, stencilRb,
+                                             rbs, &numRbs);
+        }
+
+        dumpFramebufferAttachments(json, context, GL_DRAW_FRAMEBUFFER);
+
+        if (multisample) {
+            glBindRenderbuffer(GL_RENDERBUFFER_BINDING, boundRb);
+            glDeleteRenderbuffers(numRbs, rbs);
+            glDeleteFramebuffers(1, &fboCopy);
+        }
+
+        glBindFramebuffer(GL_READ_FRAMEBUFFER, boundReadFbo);
+        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, boundDrawFbo);
+    }
+
+    json.endObject();
+    json.endMember(); // framebuffer
+}
+
+
+} /* namespace glstate */
diff --git a/retrace/glstate_internal.hpp b/retrace/glstate_internal.hpp
new file mode 100644 (file)
index 0000000..a709da3
--- /dev/null
@@ -0,0 +1,73 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _GLSTATE_INTERNAL_HPP_
+#define _GLSTATE_INTERNAL_HPP_
+
+
+#include "glimports.hpp"
+
+
+class JSONWriter;
+
+
+namespace glstate {
+
+
+struct Context
+{
+    bool ES;
+
+    bool ARB_draw_buffers;
+
+    Context(void);
+
+    GLint packAlignment;
+
+    void
+    resetPixelPackState(void);
+
+    void
+    restorePixelPackState(void);
+};
+
+
+void dumpBoolean(JSONWriter &json, GLboolean value);
+
+void dumpEnum(JSONWriter &json, GLenum pname);
+
+void dumpParameters(JSONWriter &json, Context &context);
+
+void dumpShadersUniforms(JSONWriter &json, Context &context);
+
+void dumpTextures(JSONWriter &json, Context &context);
+
+void dumpFramebuffer(JSONWriter &json, Context &context);
+
+
+} /* namespace glstate */
+
+
+#endif /* _GLSTATE_INTERNAL_HPP_ */
diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py
new file mode 100644 (file)
index 0000000..a87457f
--- /dev/null
@@ -0,0 +1,527 @@
+##########################################################################
+#
+# Copyright 2011 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+'''Generate code to dump most GL state into JSON.'''
+
+
+import retrace # to adjust sys.path
+
+from specs.stdapi import *
+
+from specs.gltypes import *
+from specs.glparams import *
+
+
+texture_targets = [
+    ('GL_TEXTURE_1D', 'GL_TEXTURE_BINDING_1D'),
+    ('GL_TEXTURE_2D', 'GL_TEXTURE_BINDING_2D'),
+    ('GL_TEXTURE_3D', 'GL_TEXTURE_BINDING_3D'),
+    ('GL_TEXTURE_RECTANGLE', 'GL_TEXTURE_BINDING_RECTANGLE'),
+    ('GL_TEXTURE_CUBE_MAP', 'GL_TEXTURE_BINDING_CUBE_MAP')
+]
+
+framebuffer_targets = [
+    ('GL_DRAW_FRAMEBUFFER', 'GL_DRAW_FRAMEBUFFER_BINDING'),
+    ('GL_READ_FRAMEBUFFER', 'GL_READ_FRAMEBUFFER_BINDING'),
+]
+
+class GetInflector:
+    '''Objects that describes how to inflect.'''
+
+    reduced_types = {
+        B: I,
+        E: I,
+        I: F,
+    }
+
+    def __init__(self, radical, inflections, suffix = ''):
+        self.radical = radical
+        self.inflections = inflections
+        self.suffix = suffix
+
+    def reduced_type(self, type):
+        if type in self.inflections:
+            return type
+        if type in self.reduced_types:
+            return self.reduced_type(self.reduced_types[type])
+        raise NotImplementedError
+
+    def inflect(self, type):
+        return self.radical + self.inflection(type) + self.suffix
+
+    def inflection(self, type):
+        type = self.reduced_type(type)
+        assert type in self.inflections
+        return self.inflections[type]
+
+    def __str__(self):
+        return self.radical + self.suffix
+
+
+class StateGetter(Visitor):
+    '''Type visitor that is able to extract the state via one of the glGet*
+    functions.
+
+    It will declare any temporary variable
+    '''
+
+    def __init__(self, radical, inflections, suffix=''):
+        self.inflector = GetInflector(radical, inflections)
+        self.suffix = suffix
+
+    def iter(self):
+        for function, type, count, name in parameters:
+            inflection = self.inflector.radical + self.suffix
+            if inflection not in function.split(','):
+                continue
+            if type is X:
+                continue
+            yield type, count, name
+
+    def __call__(self, *args):
+        pname = args[-1]
+
+        for type, count, name in self.iter():
+            if name == pname:
+                if count != 1:
+                    type = Array(type, str(count))
+
+                return type, self.visit(type, args)
+
+        raise NotImplementedError
+
+    def temp_name(self, args):
+        '''Return the name of a temporary variable to hold the state.'''
+        pname = args[-1]
+
+        return pname[3:].lower()
+
+    def visitConst(self, const, args):
+        return self.visit(const.type, args)
+
+    def visitScalar(self, type, args):
+        temp_name = self.temp_name(args)
+        elem_type = self.inflector.reduced_type(type)
+        inflection = self.inflector.inflect(type)
+        if inflection.endswith('v'):
+            print '    %s %s = 0;' % (elem_type, temp_name)
+            print '    %s(%s, &%s);' % (inflection + self.suffix, ', '.join(args), temp_name)
+        else:
+            print '    %s %s = %s(%s);' % (elem_type, temp_name, inflection + self.suffix, ', '.join(args))
+        return temp_name
+
+    def visitString(self, string, args):
+        temp_name = self.temp_name(args)
+        inflection = self.inflector.inflect(string)
+        assert not inflection.endswith('v')
+        print '    %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection + self.suffix, ', '.join(args))
+        return temp_name
+
+    def visitAlias(self, alias, args):
+        return self.visitScalar(alias, args)
+
+    def visitEnum(self, enum, args):
+        return self.visitScalar(enum, args)
+
+    def visitBitmask(self, bitmask, args):
+        return self.visit(GLint, args)
+
+    def visitArray(self, array, args):
+        temp_name = self.temp_name(args)
+        if array.length == '1':
+            return self.visit(array.type)
+        elem_type = self.inflector.reduced_type(array.type)
+        inflection = self.inflector.inflect(array.type)
+        assert inflection.endswith('v')
+        print '    %s %s[%s + 1];' % (elem_type, temp_name, array.length)
+        print '    memset(%s, 0, %s * sizeof *%s);' % (temp_name, array.length, temp_name)
+        print '    %s[%s] = (%s)0xdeadc0de;' % (temp_name, array.length, elem_type)
+        print '    %s(%s, %s);' % (inflection + self.suffix, ', '.join(args), temp_name)
+        # Simple buffer overflow detection
+        print '    assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array.length, elem_type)
+        return temp_name
+
+    def visitOpaque(self, pointer, args):
+        temp_name = self.temp_name(args)
+        inflection = self.inflector.inflect(pointer)
+        assert inflection.endswith('v')
+        print '    GLvoid *%s;' % temp_name
+        print '    %s(%s, &%s);' % (inflection + self.suffix, ', '.join(args), temp_name)
+        return temp_name
+
+
+glGet = StateGetter('glGet', {
+    B: 'Booleanv',
+    I: 'Integerv',
+    F: 'Floatv',
+    D: 'Doublev',
+    S: 'String',
+    P: 'Pointerv',
+})
+
+glGetMaterial = StateGetter('glGetMaterial', {I: 'iv', F: 'fv'})
+glGetLight = StateGetter('glGetLight', {I: 'iv', F: 'fv'})
+glGetVertexAttrib = StateGetter('glGetVertexAttrib', {I: 'iv', F: 'fv', D: 'dv', P: 'Pointerv'})
+glGetTexParameter = StateGetter('glGetTexParameter', {I: 'iv', F: 'fv'})
+glGetTexEnv = StateGetter('glGetTexEnv', {I: 'iv', F: 'fv'})
+glGetTexLevelParameter = StateGetter('glGetTexLevelParameter', {I: 'iv', F: 'fv'})
+glGetShader = StateGetter('glGetShaderiv', {I: 'iv'})
+glGetProgram = StateGetter('glGetProgram', {I: 'iv'})
+glGetProgramARB = StateGetter('glGetProgram', {I: 'iv', F: 'fv', S: 'Stringv'}, 'ARB')
+glGetFramebufferAttachmentParameter = StateGetter('glGetFramebufferAttachmentParameter', {I: 'iv'})
+
+
+class JsonWriter(Visitor):
+    '''Type visitor that will dump a value of the specified type through the
+    JSON writer.
+    
+    It expects a previously declared JSONWriter instance named "json".'''
+
+    def visitLiteral(self, literal, instance):
+        if literal.kind == 'Bool':
+            print '    json.writeBool(%s);' % instance
+        elif literal.kind in ('SInt', 'Uint', 'Float', 'Double'):
+            print '    json.writeNumber(%s);' % instance
+        else:
+            raise NotImplementedError
+
+    def visitString(self, string, instance):
+        assert string.length is None
+        print '    json.writeString((const char *)%s);' % instance
+
+    def visitEnum(self, enum, instance):
+        if enum is GLboolean:
+            print '    dumpBoolean(json, %s);' % instance
+        elif enum is GLenum:
+            print '    dumpEnum(json, %s);' % instance
+        else:
+            assert False
+            print '    json.writeNumber(%s);' % instance
+
+    def visitBitmask(self, bitmask, instance):
+        raise NotImplementedError
+
+    def visitAlias(self, alias, instance):
+        self.visit(alias.type, instance)
+
+    def visitOpaque(self, opaque, instance):
+        print '    json.writeNumber((size_t)%s);' % instance
+
+    __index = 0
+
+    def visitArray(self, array, instance):
+        index = '_i%u' % JsonWriter.__index
+        JsonWriter.__index += 1
+        print '    json.beginArray();'
+        print '    for (unsigned %s = 0; %s < %s; ++%s) {' % (index, index, array.length, index)
+        self.visit(array.type, '%s[%s]' % (instance, index))
+        print '    }'
+        print '    json.endArray();'
+
+
+
+class StateDumper:
+    '''Class to generate code to dump all GL state in JSON format via
+    stdout.'''
+
+    def __init__(self):
+        pass
+
+    def dump(self):
+        print '#include <string.h>'
+        print
+        print '#include "json.hpp"'
+        print '#include "glproc.hpp"'
+        print '#include "glsize.hpp"'
+        print '#include "glstate.hpp"'
+        print '#include "glstate_internal.hpp"'
+        print
+        print 'namespace glstate {'
+        print
+
+        print 'void'
+        print 'dumpBoolean(JSONWriter &json, GLboolean value)'
+        print '{'
+        print '    switch (value) {'
+        print '    case GL_FALSE:'
+        print '        json.writeString("GL_FALSE");'
+        print '        break;'
+        print '    case GL_TRUE:'
+        print '        json.writeString("GL_TRUE");'
+        print '        break;'
+        print '    default:'
+        print '        json.writeNumber(static_cast<GLint>(value));'
+        print '        break;'
+        print '    }'
+        print '}'
+        print
+
+        print 'const char *'
+        print 'enumToString(GLenum pname)'
+        print '{'
+        print '    switch (pname) {'
+        for name in GLenum.values:
+            print '    case %s:' % name
+            print '        return "%s";' % name
+        print '    default:'
+        print '        return NULL;'
+        print '    }'
+        print '}'
+        print
+
+        print 'void'
+        print 'dumpEnum(JSONWriter &json, GLenum pname)'
+        print '{'
+        print '    const char *s = enumToString(pname);'
+        print '    if (s) {'
+        print '        json.writeString(s);'
+        print '    } else {'
+        print '        json.writeNumber(pname);'
+        print '    }'
+        print '}'
+        print
+
+        print 'static void'
+        print 'dumpFramebufferAttachementParameters(JSONWriter &json, GLenum target, GLenum attachment)'
+        print '{'
+        self.dump_attachment_parameters('target', 'attachment')
+        print '}'
+        print
+
+        print 'void dumpParameters(JSONWriter &json, Context &context)'
+        print '{'
+        print '    json.beginMember("parameters");'
+        print '    json.beginObject();'
+        
+        self.dump_atoms(glGet)
+        
+        self.dump_material_params()
+        self.dump_light_params()
+        self.dump_vertex_attribs()
+        self.dump_program_params()
+        self.dump_texture_parameters()
+        self.dump_framebuffer_parameters()
+
+        print '    json.endObject();'
+        print '    json.endMember(); // parameters'
+        print '}'
+        print
+        
+        print '} /*namespace glstate */'
+
+    def dump_material_params(self):
+        print '    if (!context.ES) {'
+        for face in ['GL_FRONT', 'GL_BACK']:
+            print '    json.beginMember("%s");' % face
+            print '    json.beginObject();'
+            self.dump_atoms(glGetMaterial, face)
+            print '    json.endObject();'
+        print '    }'
+        print
+
+    def dump_light_params(self):
+        print '    GLint max_lights = 0;'
+        print '    _glGetIntegerv(GL_MAX_LIGHTS, &max_lights);'
+        print '    for (GLint index = 0; index < max_lights; ++index) {'
+        print '        GLenum light = GL_LIGHT0 + index;'
+        print '        if (glIsEnabled(light)) {'
+        print '            char name[32];'
+        print '            snprintf(name, sizeof name, "GL_LIGHT%i", index);'
+        print '            json.beginMember(name);'
+        print '            json.beginObject();'
+        self.dump_atoms(glGetLight, '    GL_LIGHT0 + index')
+        print '            json.endObject();'
+        print '            json.endMember(); // GL_LIGHTi'
+        print '        }'
+        print '    }'
+        print
+
+    def texenv_param_target(self, name):
+        if name == 'GL_TEXTURE_LOD_BIAS':
+           return 'GL_TEXTURE_FILTER_CONTROL'
+        elif name == 'GL_COORD_REPLACE':
+           return 'GL_POINT_SPRITE'
+        else:
+           return 'GL_TEXTURE_ENV'
+
+    def dump_texenv_params(self):
+        for target in ['GL_TEXTURE_ENV', 'GL_TEXTURE_FILTER_CONTROL', 'GL_POINT_SPRITE']:
+            print '    if (!context.ES) {'
+            print '        json.beginMember("%s");' % target
+            print '        json.beginObject();'
+            for _, _, name in glGetTexEnv.iter():
+                if self.texenv_param_target(name) == target:
+                    self.dump_atom(glGetTexEnv, target, name) 
+            print '        json.endObject();'
+            print '    }'
+
+    def dump_vertex_attribs(self):
+        print '    GLint max_vertex_attribs = 0;'
+        print '    _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs);'
+        print '    for (GLint index = 0; index < max_vertex_attribs; ++index) {'
+        print '        char name[32];'
+        print '        snprintf(name, sizeof name, "GL_VERTEX_ATTRIB_ARRAY%i", index);'
+        print '        json.beginMember(name);'
+        print '        json.beginObject();'
+        self.dump_atoms(glGetVertexAttrib, 'index')
+        print '        json.endObject();'
+        print '        json.endMember(); // GL_VERTEX_ATTRIB_ARRAYi'
+        print '    }'
+        print
+
+    program_targets = [
+        'GL_FRAGMENT_PROGRAM_ARB',
+        'GL_VERTEX_PROGRAM_ARB',
+    ]
+
+    def dump_program_params(self):
+        for target in self.program_targets:
+            print '    if (glIsEnabled(%s)) {' % target
+            print '        json.beginMember("%s");' % target
+            print '        json.beginObject();'
+            self.dump_atoms(glGetProgramARB, target)
+            print '        json.endObject();'
+            print '    }'
+
+    def dump_texture_parameters(self):
+        print '    {'
+        print '        GLint active_texture = GL_TEXTURE0;'
+        print '        glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);'
+        print '        GLint max_texture_coords = 0;'
+        print '        glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);'
+        print '        GLint max_combined_texture_image_units = 0;'
+        print '        glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_combined_texture_image_units);'
+        print '        GLint max_units = std::max(std::max(max_combined_texture_image_units, max_texture_coords), 2);'
+        print '        for (GLint unit = 0; unit < max_units; ++unit) {'
+        print '            char name[32];'
+        print '            snprintf(name, sizeof name, "GL_TEXTURE%i", unit);'
+        print '            json.beginMember(name);'
+        print '            glActiveTexture(GL_TEXTURE0 + unit);'
+        print '            json.beginObject();'
+        print '            GLboolean enabled;'
+        print '            GLint binding;'
+        print
+        for target, binding in texture_targets:
+            print '            // %s' % target
+            print '            enabled = GL_FALSE;'
+            print '            glGetBooleanv(%s, &enabled);' % target
+            print '            json.beginMember("%s");' % target
+            print '            dumpBoolean(json, enabled);'
+            print '            json.endMember();'
+            print '            binding = 0;'
+            print '            glGetIntegerv(%s, &binding);' % binding
+            print '            json.writeNumberMember("%s", binding);' % binding
+            print '            if (enabled || binding) {'
+            print '                json.beginMember("%s");' % target
+            print '                json.beginObject();'
+            self.dump_atoms(glGetTexParameter, target)
+            print '                if (!context.ES) {'
+            # We only dump the first level parameters
+            self.dump_atoms(glGetTexLevelParameter, target, "0")
+            print '                }'
+            print '                json.endObject();'
+            print '                json.endMember(); // %s' % target
+            print '            }'
+            print
+        print '            if (unit < max_texture_coords) {'
+        self.dump_texenv_params()
+        print '            }'
+        print '            json.endObject();'
+        print '            json.endMember(); // GL_TEXTUREi'
+        print '        }'
+        print '        glActiveTexture(active_texture);'
+        print '    }'
+        print
+
+    def dump_framebuffer_parameters(self):
+        print '    {'
+        print '        GLint max_color_attachments = 0;'
+        print '        glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &max_color_attachments);'
+        print '        GLint framebuffer;'
+        for target, binding in framebuffer_targets:
+            print '            // %s' % target
+            print '            framebuffer = 0;'
+            print '            glGetIntegerv(%s, &framebuffer);' % binding
+            print '            if (framebuffer) {'
+            print '                json.beginMember("%s");' % target
+            print '                json.beginObject();'
+            print '                for (GLint i = 0; i < max_color_attachments; ++i) {'
+            print '                    GLint color_attachment = GL_COLOR_ATTACHMENT0 + i;'
+            print '                    dumpFramebufferAttachementParameters(json, %s, color_attachment);' % target
+            print '                }'
+            print '                dumpFramebufferAttachementParameters(json, %s, GL_DEPTH_ATTACHMENT);' % target
+            print '                dumpFramebufferAttachementParameters(json, %s, GL_STENCIL_ATTACHMENT);' % target
+            print '                json.endObject();'
+            print '                json.endMember(); // %s' % target
+            print '            }'
+            print
+        print '    }'
+        print
+
+    def dump_attachment_parameters(self, target, attachment):
+        print '            {'
+        print '                GLint object_type = GL_NONE;'
+        print '                glGetFramebufferAttachmentParameteriv(%s, %s, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &object_type);' % (target, attachment)
+        print '                if (object_type != GL_NONE) {'
+        print '                    json.beginMember(enumToString(%s));' % attachment
+        print '                    json.beginObject();'
+        self.dump_atoms(glGetFramebufferAttachmentParameter, target, attachment)
+        print '                    json.endObject();'
+        print '                    json.endMember(); // GL_x_ATTACHMENT'
+        print '                }'
+        print '            }'
+
+    def dump_atoms(self, getter, *args):
+        for _, _, name in getter.iter():
+            self.dump_atom(getter, *(args + (name,))) 
+
+    def dump_atom(self, getter, *args):
+        name = args[-1]
+
+        # Avoid crash on MacOSX
+        # XXX: The right fix would be to look at the support extensions..
+        import platform
+        if name == 'GL_SAMPLER_BINDING' and platform.system() == 'Darwin':
+            return
+
+        print '        // %s' % name
+        print '        {'
+        #print '            assert(glGetError() == GL_NO_ERROR);'
+        type, value = getter(*args)
+        print '            if (glGetError() != GL_NO_ERROR) {'
+        #print '                std::cerr << "warning: %s(%s) failed\\n";' % (inflection, name)
+        print '                while (glGetError() != GL_NO_ERROR) {}'
+        print '            } else {'
+        print '                json.beginMember("%s");' % name
+        JsonWriter().visit(type, value)
+        print '                json.endMember();'
+        print '            }'
+        print '        }'
+        print
+
+
+if __name__ == '__main__':
+    StateDumper().dump()
diff --git a/retrace/glstate_shaders.cpp b/retrace/glstate_shaders.cpp
new file mode 100644 (file)
index 0000000..a651d99
--- /dev/null
@@ -0,0 +1,742 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+
+#include <algorithm>
+#include <iostream>
+#include <map>
+#include <sstream>
+
+#include "json.hpp"
+#include "glproc.hpp"
+#include "glsize.hpp"
+#include "glstate.hpp"
+#include "glstate_internal.hpp"
+
+
+namespace glstate {
+
+
+// Mapping from shader type to shader source, used to accumulated the sources
+// of different shaders with same type.
+typedef std::map<std::string, std::string> ShaderMap;
+
+
+static void
+getShaderSource(ShaderMap &shaderMap, GLuint shader)
+{
+    if (!shader) {
+        return;
+    }
+
+    GLint shader_type = 0;
+    glGetShaderiv(shader, GL_SHADER_TYPE, &shader_type);
+    if (!shader_type) {
+        return;
+    }
+
+    GLint source_length = 0;
+    glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &source_length);
+    if (!source_length) {
+        return;
+    }
+
+    GLchar *source = new GLchar[source_length];
+    GLsizei length = 0;
+    source[0] = 0;
+    glGetShaderSource(shader, source_length, &length, source);
+
+    shaderMap[enumToString(shader_type)] += source;
+
+    delete [] source;
+}
+
+
+static void
+getShaderObjSource(ShaderMap &shaderMap, GLhandleARB shaderObj)
+{
+    if (!shaderObj) {
+        return;
+    }
+
+    GLint object_type = 0;
+    glGetObjectParameterivARB(shaderObj, GL_OBJECT_TYPE_ARB, &object_type);
+    if (object_type != GL_SHADER_OBJECT_ARB) {
+        return;
+    }
+
+    GLint shader_type = 0;
+    glGetObjectParameterivARB(shaderObj, GL_OBJECT_SUBTYPE_ARB, &shader_type);
+    if (!shader_type) {
+        return;
+    }
+
+    GLint source_length = 0;
+    glGetObjectParameterivARB(shaderObj, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &source_length);
+    if (!source_length) {
+        return;
+    }
+
+    GLcharARB *source = new GLcharARB[source_length];
+    GLsizei length = 0;
+    source[0] = 0;
+    glGetShaderSource(shaderObj, source_length, &length, source);
+
+    shaderMap[enumToString(shader_type)] += source;
+
+    delete [] source;
+}
+
+
+static inline void
+dumpProgram(JSONWriter &json, GLint program)
+{
+    GLint attached_shaders = 0;
+    glGetProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders);
+    if (!attached_shaders) {
+        return;
+    }
+
+    ShaderMap shaderMap;
+
+    GLuint *shaders = new GLuint[attached_shaders];
+    GLsizei count = 0;
+    glGetAttachedShaders(program, attached_shaders, &count, shaders);
+    std::sort(shaders, shaders + count);
+    for (GLsizei i = 0; i < count; ++ i) {
+        getShaderSource(shaderMap, shaders[i]);
+    }
+    delete [] shaders;
+
+    for (ShaderMap::const_iterator it = shaderMap.begin(); it != shaderMap.end(); ++it) {
+        json.beginMember(it->first);
+        json.writeString(it->second);
+        json.endMember();
+    }
+}
+
+
+static inline void
+dumpProgramObj(JSONWriter &json, GLhandleARB programObj)
+{
+    GLint attached_shaders = 0;
+    glGetObjectParameterivARB(programObj, GL_OBJECT_ATTACHED_OBJECTS_ARB, &attached_shaders);
+    if (!attached_shaders) {
+        return;
+    }
+
+    ShaderMap shaderMap;
+
+    GLhandleARB *shaderObjs = new GLhandleARB[attached_shaders];
+    GLsizei count = 0;
+    glGetAttachedObjectsARB(programObj, attached_shaders, &count, shaderObjs);
+    std::sort(shaderObjs, shaderObjs + count);
+    for (GLsizei i = 0; i < count; ++ i) {
+       getShaderObjSource(shaderMap, shaderObjs[i]);
+    }
+    delete [] shaderObjs;
+
+    for (ShaderMap::const_iterator it = shaderMap.begin(); it != shaderMap.end(); ++it) {
+        json.beginMember(it->first);
+        json.writeString(it->second);
+        json.endMember();
+    }
+}
+
+/**
+ * Built-in uniforms can't be queried through glGetUniform*.
+ */
+static inline bool
+isBuiltinUniform(const GLchar *name)
+{
+    return name[0] == 'g' && name[1] == 'l' && name[2] == '_';
+}
+
+/*
+ * When fetching the uniform name of an array we usually get name[0]
+ * so we need to cut the trailing "[0]" in order to properly construct
+ * array names later. Otherwise we endup with stuff like
+ * uniformArray[0][0],
+ * uniformArray[0][1],
+ * instead of
+ * uniformArray[0],
+ * uniformArray[1].
+ */
+static std::string
+resolveUniformName(const GLchar *name,  GLint size)
+{
+    std::string qualifiedName(name);
+    if (size > 1) {
+        std::string::size_type nameLength = qualifiedName.length();
+        static const char * const arrayStart = "[0]";
+        static const int arrayStartLen = 3;
+        if (qualifiedName.rfind(arrayStart) == (nameLength - arrayStartLen)) {
+            qualifiedName = qualifiedName.substr(0, nameLength - 3);
+        }
+    }
+    return qualifiedName;
+}
+
+
+static void
+dumpUniformValues(JSONWriter &json, GLenum type, const void *values, GLint matrix_stride = 0, GLboolean is_row_major = GL_FALSE) {
+    GLenum elemType;
+    GLint numCols, numRows;
+    _gl_uniform_size(type, elemType, numCols, numRows);
+    if (!numCols || !numRows) {
+        json.writeNull();
+    }
+
+    size_t elemSize = _gl_type_size(elemType);
+
+    GLint row_stride = 0;
+    GLint col_stride = 0;
+    if (is_row_major) {
+        row_stride = elemSize;
+        col_stride = matrix_stride ? matrix_stride : numRows * elemSize;
+    } else {
+        col_stride = elemSize;
+        row_stride = matrix_stride ? matrix_stride : numCols * elemSize;
+    }
+
+    if (numRows > 1) {
+        json.beginArray();
+    }
+
+    for (GLint row = 0; row < numRows; ++row) {
+        if (numCols > 1) {
+            json.beginArray();
+        }
+
+        for (GLint col = 0; col < numCols; ++col) {
+            union {
+                const GLbyte *rawvalue;
+                const GLfloat *fvalue;
+                const GLdouble *dvalue;
+                const GLint *ivalue;
+                const GLuint *uivalue;
+            } u;
+
+            u.rawvalue = (const GLbyte *)values + row*row_stride + col*col_stride;
+
+            switch (elemType) {
+            case GL_FLOAT:
+                json.writeNumber(*u.fvalue);
+                break;
+            case GL_DOUBLE:
+                json.writeNumber(*u.dvalue);
+                break;
+            case GL_INT:
+                json.writeNumber(*u.ivalue);
+                break;
+            case GL_UNSIGNED_INT:
+                json.writeNumber(*u.uivalue);
+                break;
+            case GL_BOOL:
+                json.writeBool(*u.uivalue);
+                break;
+            default:
+                assert(0);
+                json.writeNull();
+                break;
+            }
+        }
+
+        if (numCols > 1) {
+            json.endArray();
+        }
+    }
+
+    if (numRows > 1) {
+        json.endArray();
+    }
+}
+
+
+/**
+ * Dump an uniform that belows to an uniform block.
+ */
+static void
+dumpUniformBlock(JSONWriter &json, GLint program, GLint size, GLenum type, const GLchar *name, GLuint index, GLuint block_index) {
+
+    GLint offset = 0;
+    GLint array_stride = 0;
+    GLint matrix_stride = 0;
+    GLint is_row_major = GL_FALSE;
+    glGetActiveUniformsiv(program, 1, &index, GL_UNIFORM_OFFSET, &offset);
+    glGetActiveUniformsiv(program, 1, &index, GL_UNIFORM_ARRAY_STRIDE, &array_stride);
+    glGetActiveUniformsiv(program, 1, &index, GL_UNIFORM_MATRIX_STRIDE, &matrix_stride);
+    glGetActiveUniformsiv(program, 1, &index, GL_UNIFORM_IS_ROW_MAJOR, &is_row_major);
+
+    GLint slot = -1;
+    glGetActiveUniformBlockiv(program, block_index, GL_UNIFORM_BLOCK_BINDING, &slot);
+    if (slot == -1) {
+        return;
+    }
+
+    if (0) {
+        GLint active_uniform_block_max_name_length = 0;
+        glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &active_uniform_block_max_name_length);
+
+        GLchar* block_name = new GLchar[active_uniform_block_max_name_length];
+
+        GLint block_data_size = 0;
+        glGetActiveUniformBlockiv(program, index, GL_UNIFORM_BLOCK_DATA_SIZE, &block_data_size);
+
+        GLsizei length = 0;
+        glGetActiveUniformBlockName(program, index, active_uniform_block_max_name_length, &length, block_name);
+
+        std::cerr
+            << "uniform `" << name << "`, size " << size << ", type " << enumToString(type) << "\n"
+            << "  block " << block_index << ", name `" << block_name << "`, size " << block_data_size << "; binding " << slot << "; \n"
+            << "  offset " << offset << ", array stride " << array_stride << ", matrix stride " << matrix_stride << ", row_major " << is_row_major << "\n"
+        ;
+
+        delete block_name;
+    }
+
+    GLint ubo = 0;
+    glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, slot, &ubo);
+
+    GLint previous_ubo = 0;
+    glGetIntegerv(GL_UNIFORM_BUFFER_BINDING, &previous_ubo);
+
+    glBindBuffer(GL_UNIFORM_BUFFER, ubo);
+
+    const GLbyte *raw_data = (const GLbyte *)glMapBuffer(GL_UNIFORM_BUFFER, GL_READ_ONLY);
+    if (raw_data) {
+        std::string qualifiedName = resolveUniformName(name, size);
+
+        for (GLint i = 0; i < size; ++i) {
+            std::stringstream ss;
+            ss << qualifiedName;
+
+            if (size > 1) {
+                ss << '[' << i << ']';
+            }
+
+            std::string elemName = ss.str();
+
+            json.beginMember(elemName);
+
+            const GLbyte *row = raw_data + offset + array_stride*i;
+
+            dumpUniformValues(json, type, row, matrix_stride, is_row_major);
+
+            json.endMember();
+        }
+
+        glUnmapBuffer(GL_UNIFORM_BUFFER);
+    }
+
+    glBindBuffer(GL_UNIFORM_BUFFER, previous_ubo);
+}
+
+
+static void
+dumpUniform(JSONWriter &json, GLint program, GLint size, GLenum type, const GLchar *name) {
+    GLenum elemType;
+    GLint numCols, numRows;
+    _gl_uniform_size(type, elemType, numCols, numRows);
+    if (elemType == GL_NONE) {
+        return;
+    }
+
+    union {
+        GLfloat fvalues[4*4];
+        GLdouble dvalues[4*4];
+        GLint ivalues[4*4];
+        GLuint uivalues[4*4];
+    } u;
+
+    GLint i;
+
+    std::string qualifiedName = resolveUniformName(name, size);
+
+    for (i = 0; i < size; ++i) {
+        std::stringstream ss;
+        ss << qualifiedName;
+
+        if (size > 1) {
+            ss << '[' << i << ']';
+        }
+
+        std::string elemName = ss.str();
+
+        GLint location = glGetUniformLocation(program, elemName.c_str());
+        assert(location != -1);
+        if (location == -1) {
+            continue;
+        }
+
+        json.beginMember(elemName);
+
+        switch (elemType) {
+        case GL_FLOAT:
+            glGetUniformfv(program, location, u.fvalues);
+            break;
+        case GL_DOUBLE:
+            glGetUniformdv(program, location, u.dvalues);
+            break;
+        case GL_INT:
+            glGetUniformiv(program, location, u.ivalues);
+            break;
+        case GL_UNSIGNED_INT:
+            glGetUniformuiv(program, location, u.uivalues);
+            break;
+        case GL_BOOL:
+            glGetUniformiv(program, location, u.ivalues);
+            break;
+        default:
+            assert(0);
+            break;
+        }
+
+        dumpUniformValues(json, type, &u);
+
+        json.endMember();
+    }
+}
+
+
+static void
+dumpUniformARB(JSONWriter &json, GLhandleARB programObj, GLint size, GLenum type, const GLchar *name) {
+    GLenum elemType;
+    GLint numCols, numRows;
+    _gl_uniform_size(type, elemType, numCols, numRows);
+    GLint numElems = numCols * numRows;
+    if (elemType == GL_NONE) {
+        return;
+    }
+
+    GLfloat fvalues[4*4];
+    union {
+        GLdouble dvalues[4*4];
+        GLfloat fvalues[4*4];
+        GLint ivalues[4*4];
+    } u;
+
+    GLint i, j;
+
+    std::string qualifiedName = resolveUniformName(name, size);
+
+    for (i = 0; i < size; ++i) {
+        std::stringstream ss;
+        ss << qualifiedName;
+
+        if (size > 1) {
+            ss << '[' << i << ']';
+        }
+
+        std::string elemName = ss.str();
+
+        json.beginMember(elemName);
+
+        GLint location = glGetUniformLocationARB(programObj, elemName.c_str());
+        if (location == -1) {
+            continue;
+        }
+
+        switch (elemType) {
+        case GL_DOUBLE:
+            // glGetUniformdvARB does not exists
+            glGetUniformfvARB(programObj, location, fvalues);
+            for (j = 0; j < numElems; ++j) {
+                u.dvalues[j] = fvalues[j];
+            }
+            break;
+        case GL_FLOAT:
+            glGetUniformfvARB(programObj, location, fvalues);
+            break;
+        case GL_UNSIGNED_INT:
+            // glGetUniformuivARB does not exists
+        case GL_INT:
+            glGetUniformivARB(programObj, location, u.ivalues);
+            break;
+        case GL_BOOL:
+            glGetUniformivARB(programObj, location, u.ivalues);
+            break;
+        default:
+            assert(0);
+            break;
+        }
+
+        dumpUniformValues(json, type, &u);
+
+        json.endMember();
+    }
+}
+
+
+static inline void
+dumpProgramUniforms(JSONWriter &json, GLint program)
+{
+    GLint active_uniforms = 0;
+    glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &active_uniforms);
+    if (!active_uniforms) {
+        return;
+    }
+
+    GLint active_uniform_max_length = 0;
+    glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &active_uniform_max_length);
+    GLchar *name = new GLchar[active_uniform_max_length];
+    if (!name) {
+        return;
+    }
+
+    for (GLuint index = 0; (GLint)index < active_uniforms; ++index) {
+        GLsizei length = 0;
+        GLint size = 0;
+        GLenum type = GL_NONE;
+        glGetActiveUniform(program, index, active_uniform_max_length, &length, &size, &type, name);
+
+        if (isBuiltinUniform(name)) {
+            continue;
+        }
+
+        GLint location = glGetUniformLocation(program, name);
+        if (location != -1) {
+            dumpUniform(json, program, size, type, name);
+            continue;
+        }
+
+        GLint block_index = -1;
+        glGetActiveUniformsiv(program, 1, &index, GL_UNIFORM_BLOCK_INDEX, &block_index);
+        if (block_index != -1) {
+            dumpUniformBlock(json, program, size, type, name, index, block_index);
+            continue;
+        }
+
+        assert(0);
+    }
+
+    delete [] name;
+}
+
+
+static inline void
+dumpProgramObjUniforms(JSONWriter &json, GLhandleARB programObj)
+{
+    GLint active_uniforms = 0;
+    glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &active_uniforms);
+    if (!active_uniforms) {
+        return;
+    }
+
+    GLint active_uniform_max_length = 0;
+    glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB, &active_uniform_max_length);
+    GLchar *name = new GLchar[active_uniform_max_length];
+    if (!name) {
+        return;
+    }
+
+    for (GLint index = 0; index < active_uniforms; ++index) {
+        GLsizei length = 0;
+        GLint size = 0;
+        GLenum type = GL_NONE;
+        glGetActiveUniformARB(programObj, index, active_uniform_max_length, &length, &size, &type, name);
+
+    if (isBuiltinUniform(name)) {
+        continue;
+    }
+
+        dumpUniformARB(json, programObj, size, type, name);
+    }
+
+    delete [] name;
+}
+
+
+static inline void
+dumpArbProgram(JSONWriter &json, GLenum target)
+{
+    if (!glIsEnabled(target)) {
+        return;
+    }
+
+    GLint program_length = 0;
+    glGetProgramivARB(target, GL_PROGRAM_LENGTH_ARB, &program_length);
+    if (!program_length) {
+        return;
+    }
+
+    GLchar *source = new GLchar[program_length + 1];
+    source[0] = 0;
+    glGetProgramStringARB(target, GL_PROGRAM_STRING_ARB, source);
+    source[program_length] = 0;
+
+    json.beginMember(enumToString(target));
+    json.writeString(source);
+    json.endMember();
+
+    delete [] source;
+}
+
+
+static inline void
+dumpArbProgramUniforms(JSONWriter &json, GLenum target, const char *prefix)
+{
+    if (!glIsEnabled(target)) {
+        return;
+    }
+
+    GLint program_parameters = 0;
+    glGetProgramivARB(target, GL_PROGRAM_PARAMETERS_ARB, &program_parameters);
+    if (!program_parameters) {
+        return;
+    }
+
+    GLint max_program_local_parameters = 0;
+    glGetProgramivARB(target, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &max_program_local_parameters);
+    for (GLint index = 0; index < max_program_local_parameters; ++index) {
+        GLdouble params[4] = {0, 0, 0, 0};
+        glGetProgramLocalParameterdvARB(target, index, params);
+
+        if (!params[0] && !params[1] && !params[2] && !params[3]) {
+            continue;
+        }
+
+        char name[256];
+        snprintf(name, sizeof name, "%sprogram.local[%i]", prefix, index);
+
+        json.beginMember(name);
+        json.beginArray();
+        json.writeNumber(params[0]);
+        json.writeNumber(params[1]);
+        json.writeNumber(params[2]);
+        json.writeNumber(params[3]);
+        json.endArray();
+        json.endMember();
+    }
+
+    GLint max_program_env_parameters = 0;
+    glGetProgramivARB(target, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &max_program_env_parameters);
+    for (GLint index = 0; index < max_program_env_parameters; ++index) {
+        GLdouble params[4] = {0, 0, 0, 0};
+        glGetProgramEnvParameterdvARB(target, index, params);
+
+        if (!params[0] && !params[1] && !params[2] && !params[3]) {
+            continue;
+        }
+
+        char name[256];
+        snprintf(name, sizeof name, "%sprogram.env[%i]", prefix, index);
+
+        json.beginMember(name);
+        json.beginArray();
+        json.writeNumber(params[0]);
+        json.writeNumber(params[1]);
+        json.writeNumber(params[2]);
+        json.writeNumber(params[3]);
+        json.endArray();
+        json.endMember();
+    }
+}
+
+static void
+dumpProgramUniformsStage(JSONWriter &json, GLint program, const char *stage)
+{
+    if (program) {
+        json.beginMember(stage);
+        json.beginObject();
+        dumpProgramUniforms(json, program);
+        json.endObject();
+        json.endMember();
+    }
+}
+
+void
+dumpShadersUniforms(JSONWriter &json, Context &context)
+{
+    GLint pipeline = 0;
+    GLint vertex_program = 0;
+    GLint fragment_program = 0;
+    GLint geometry_program = 0;
+    GLint tess_control_program = 0;
+    GLint tess_evaluation_program = 0;
+
+    if (!context.ES) {
+        glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);
+        if (pipeline) {
+            glGetProgramPipelineiv(pipeline, GL_VERTEX_SHADER, &vertex_program);
+            glGetProgramPipelineiv(pipeline, GL_FRAGMENT_SHADER, &fragment_program);
+            glGetProgramPipelineiv(pipeline, GL_GEOMETRY_SHADER, &geometry_program);
+            glGetProgramPipelineiv(pipeline, GL_TESS_CONTROL_SHADER, &tess_control_program);
+            glGetProgramPipelineiv(pipeline, GL_TESS_EVALUATION_SHADER, &tess_evaluation_program);
+        }
+    }
+
+    GLint program = 0;
+    GLhandleARB programObj = 0;
+    if (!pipeline) {
+        glGetIntegerv(GL_CURRENT_PROGRAM, &program);
+        if (!context.ES && !program) {
+            programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
+        }
+    }
+
+    json.beginMember("shaders");
+    json.beginObject();
+    if (pipeline) {
+        dumpProgram(json, vertex_program);
+        dumpProgram(json, fragment_program);
+        dumpProgram(json, geometry_program);
+        dumpProgram(json, tess_control_program);
+        dumpProgram(json, tess_evaluation_program);
+    } else if (program) {
+        dumpProgram(json, program);
+    } else if (programObj) {
+        dumpProgramObj(json, programObj);
+    } else {
+        dumpArbProgram(json, GL_FRAGMENT_PROGRAM_ARB);
+        dumpArbProgram(json, GL_VERTEX_PROGRAM_ARB);
+    }
+    json.endObject();
+    json.endMember(); // shaders
+
+    json.beginMember("uniforms");
+    json.beginObject();
+    if (pipeline) {
+        dumpProgramUniformsStage(json, vertex_program, "GL_VERTEX_SHADER");
+        dumpProgramUniformsStage(json, fragment_program, "GL_FRAGMENT_SHADER");
+        dumpProgramUniformsStage(json, geometry_program, "GL_GEOMETRY_SHADER");
+        dumpProgramUniformsStage(json, tess_control_program, "GL_TESS_CONTROL_SHADER");
+        dumpProgramUniformsStage(json, tess_evaluation_program, "GL_TESS_EVALUATION_SHADER");
+    } else if (program) {
+        dumpProgramUniforms(json, program);
+    } else if (programObj) {
+        dumpProgramObjUniforms(json, programObj);
+    } else {
+        dumpArbProgramUniforms(json, GL_FRAGMENT_PROGRAM_ARB, "fp.");
+        dumpArbProgramUniforms(json, GL_VERTEX_PROGRAM_ARB, "vp.");
+    }
+    json.endObject();
+    json.endMember(); // uniforms
+}
+
+
+} /* namespace glstate */
diff --git a/retrace/glws.cpp b/retrace/glws.cpp
new file mode 100644 (file)
index 0000000..4e07ede
--- /dev/null
@@ -0,0 +1,59 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "glws.hpp"
+
+
+namespace glws {
+
+
+bool
+checkExtension(const char *extName, const char *extString)
+{
+   const char *p = extString;
+   const char *q = extName;
+   char c;
+   do {
+       c = *p++;
+       if (c == '\0' || c == ' ') {
+           if (q && *q == '\0') {
+               return true;
+           } else {
+               q = extName;
+           }
+       } else {
+           if (q && *q == c) {
+               ++q;
+           } else {
+               q = 0;
+           }
+       }
+   } while (c);
+   return false;
+}
+
+
+} /* namespace glws */
diff --git a/retrace/glws.hpp b/retrace/glws.hpp
new file mode 100644 (file)
index 0000000..05903a7
--- /dev/null
@@ -0,0 +1,167 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Abstraction for GL window system specific APIs (GLX, WGL).
+ */
+
+#ifndef _GLWS_HPP_
+#define _GLWS_HPP_
+
+
+#include <vector>
+
+
+namespace glws {
+
+
+enum Profile {
+    PROFILE_COMPAT = 0,
+    PROFILE_CORE,
+    PROFILE_ES1,
+    PROFILE_ES2,
+    PROFILE_MAX
+};
+
+
+bool
+checkExtension(const char *extName, const char *extString);
+
+
+template< class T >
+class Attributes {
+protected:
+    std::vector<T> attribs;
+
+public:
+    void add(T param) {
+        attribs.push_back(param);
+    }
+
+    void add(T pname, T pvalue) {
+        add(pname);
+        add(pvalue);
+    }
+
+    void end(T terminator = 0) {
+        add(terminator);
+    }
+
+    operator T * (void) {
+        return &attribs[0];
+    }
+
+    operator const T * (void) const {
+        return &attribs[0];
+    }
+};
+
+
+class Visual
+{
+public:
+    unsigned long redMask;
+    unsigned long greenMask;
+    unsigned long blueMask;
+    unsigned long alphaMask;
+    bool doubleBuffer;
+
+    virtual ~Visual() {}
+};
+
+
+class Drawable
+{
+public:
+    const Visual *visual;
+    int width;
+    int height;
+    bool visible;
+
+    Drawable(const Visual *vis, int w, int h) :
+        visual(vis),
+        width(w),
+        height(h),
+        visible(false)
+    {}
+
+    virtual ~Drawable() {}
+    
+    virtual void
+    resize(int w, int h) {
+        width = w;
+        height = h;
+    }
+
+    virtual void
+    show(void) {
+        visible = true;
+    }
+
+    virtual void swapBuffers(void) = 0;
+};
+
+
+class Context
+{
+public:
+    const Visual *visual;
+    Profile profile;
+    
+    Context(const Visual *vis, Profile prof) :
+        visual(vis),
+        profile(prof)
+    {}
+
+    virtual ~Context() {}
+};
+
+
+void
+init(void);
+
+void
+cleanup(void);
+
+Visual *
+createVisual(bool doubleBuffer = false, Profile profile = PROFILE_COMPAT);
+
+Drawable *
+createDrawable(const Visual *visual, int width = 32, int height = 32);
+
+Context *
+createContext(const Visual *visual, Context *shareContext = 0, Profile profile = PROFILE_COMPAT, bool debug = false);
+
+bool
+makeCurrent(Drawable *drawable, Context *context);
+
+bool
+processEvents(void);
+
+
+} /* namespace glws */
+
+
+#endif /* _GLWS_HPP_ */
diff --git a/retrace/glws_cocoa.mm b/retrace/glws_cocoa.mm
new file mode 100644 (file)
index 0000000..2ac3091
--- /dev/null
@@ -0,0 +1,270 @@
+/**************************************************************************
+ *
+ * Copyright 2011 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/**
+ * Minimal Cocoa integration.
+ *
+ * See also:
+ * - http://developer.apple.com/library/mac/#samplecode/CocoaGL/Introduction/Intro.html
+ * - http://developer.apple.com/library/mac/#samplecode/Cocoa_With_Carbon_or_CPP/Introduction/Intro.html
+ * - http://developer.apple.com/library/mac/#samplecode/glut/Introduction/Intro.html
+ * - http://developer.apple.com/library/mac/#samplecode/GLEssentials/Introduction/Intro.html
+ * - http://www.glfw.org/
+ */
+
+
+#include <stdlib.h>
+#include <iostream>
+
+#include <Cocoa/Cocoa.h>
+
+#include "glws.hpp"
+
+
+namespace glws {
+
+
+NSAutoreleasePool *autoreleasePool = nil;
+
+
+class CocoaVisual : public Visual
+{
+public:
+    NSOpenGLPixelFormat *pixelFormat;
+
+    CocoaVisual(NSOpenGLPixelFormat *pf) :
+        pixelFormat(pf)
+    {}
+
+    ~CocoaVisual() {
+        [pixelFormat release];
+    }
+};
+
+class CocoaDrawable : public Drawable
+{
+public:
+    NSWindow *window;
+    NSOpenGLContext *currentContext;
+
+    CocoaDrawable(const Visual *vis, int w, int h) :
+        Drawable(vis, w, h),
+        currentContext(nil)
+    {
+        NSOpenGLPixelFormat *pixelFormat = static_cast<const CocoaVisual *>(visual)->pixelFormat;
+
+        NSRect winRect = NSMakeRect(0, 0, w, h);
+
+        window = [[NSWindow alloc]
+                         initWithContentRect:winRect
+                                   styleMask:NSTitledWindowMask |
+                                             NSClosableWindowMask |
+                                             NSMiniaturizableWindowMask
+                                     backing:NSBackingStoreRetained
+                                       defer:NO];
+        assert(window != nil);
+
+        NSOpenGLView *view = [[NSOpenGLView alloc]
+                              initWithFrame:winRect
+                                pixelFormat:pixelFormat];
+        assert(view != nil);
+
+        [window setContentView:view];
+        [window setTitle:@"glretrace"];
+
+    }
+
+    ~CocoaDrawable() {
+        [window release];
+    }
+
+    void
+    resize(int w, int h) {
+        if (w == width && h == height) {
+            return;
+        }
+
+        [window setContentSize:NSMakeSize(w, h)];
+
+        if (currentContext != nil) {
+            [currentContext update];
+            [window makeKeyAndOrderFront:nil];
+            [currentContext setView:[window contentView]];
+            [currentContext makeCurrentContext];
+        }
+
+        Drawable::resize(w, h);
+    }
+
+    void show(void) {
+        if (visible) {
+            return;
+        }
+
+        // TODO
+
+        Drawable::show();
+    }
+
+    void swapBuffers(void) {
+        if (currentContext != nil) {
+            [currentContext flushBuffer];
+        }
+    }
+};
+
+
+class CocoaContext : public Context
+{
+public:
+    NSOpenGLContext *context;
+
+    CocoaContext(const Visual *vis, Profile prof, NSOpenGLContext *ctx) :
+        Context(vis, prof),
+        context(ctx)
+    {}
+
+    ~CocoaContext() {
+        [context release];
+    }
+};
+
+
+void
+init(void) {
+    [NSApplication sharedApplication];
+
+    autoreleasePool = [[NSAutoreleasePool alloc] init];
+
+    [NSApp finishLaunching];
+}
+
+
+void
+cleanup(void) {
+    [autoreleasePool release];
+}
+
+
+Visual *
+createVisual(bool doubleBuffer, Profile profile) {
+    if (profile != PROFILE_COMPAT &&
+        profile != PROFILE_CORE) {
+        return nil;
+    }
+
+    Attributes<NSOpenGLPixelFormatAttribute> attribs;
+
+    attribs.add(NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)1);
+    attribs.add(NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)24);
+    if (doubleBuffer) {
+        attribs.add(NSOpenGLPFADoubleBuffer);
+    }
+    attribs.add(NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)1);
+    attribs.add(NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)1);
+    if (profile == PROFILE_CORE) {
+#if CGL_VERSION_1_3
+        attribs.add(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
+#else
+       return NULL;
+#endif
+    }
+    attribs.end();
+
+    NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc]
+                                     initWithAttributes:attribs];
+
+    return new CocoaVisual(pixelFormat);
+}
+
+Drawable *
+createDrawable(const Visual *visual, int width, int height)
+{
+    return new CocoaDrawable(visual, width, height);
+}
+
+Context *
+createContext(const Visual *visual, Context *shareContext, Profile profile, bool debug)
+{
+    NSOpenGLPixelFormat *pixelFormat = static_cast<const CocoaVisual *>(visual)->pixelFormat;
+    NSOpenGLContext *share_context = nil;
+    NSOpenGLContext *context;
+
+    if (profile != PROFILE_COMPAT &&
+        profile != PROFILE_CORE) {
+        return nil;
+    }
+
+    if (shareContext) {
+        share_context = static_cast<CocoaContext*>(shareContext)->context;
+    }
+
+    context = [[NSOpenGLContext alloc]
+               initWithFormat:pixelFormat
+               shareContext:share_context];
+    assert(context != nil);
+
+    return new CocoaContext(visual, profile, context);
+}
+
+bool
+makeCurrent(Drawable *drawable, Context *context)
+{
+    if (!drawable || !context) {
+        [NSOpenGLContext clearCurrentContext];
+    } else {
+        CocoaDrawable *cocoaDrawable = static_cast<CocoaDrawable *>(drawable);
+        CocoaContext *cocoaContext = static_cast<CocoaContext *>(context);
+
+        [cocoaDrawable->window makeKeyAndOrderFront:nil];
+        [cocoaContext->context setView:[cocoaDrawable->window contentView]];
+        [cocoaContext->context makeCurrentContext];
+
+        cocoaDrawable->currentContext = cocoaContext->context;
+    }
+
+    return TRUE;
+}
+
+bool
+processEvents(void) {
+   NSEvent* event;
+
+    do {
+        event = [NSApp nextEventMatchingMask:NSAnyEventMask
+                                   untilDate:[NSDate distantPast]
+                                      inMode:NSDefaultRunLoopMode
+                                     dequeue:YES];
+        if (event)
+            [NSApp sendEvent:event];
+    } while (event);
+
+    return true;
+}
+
+
+} /* namespace glws */
diff --git a/retrace/glws_egl_xlib.cpp b/retrace/glws_egl_xlib.cpp
new file mode 100644 (file)
index 0000000..58824c2
--- /dev/null
@@ -0,0 +1,484 @@
+/**************************************************************************
+ *
+ * Copyright 2011 LunarG, Inc.
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include <iostream>
+
+#include <dlfcn.h>
+
+#include "glproc.hpp"
+#include "glws.hpp"
+
+
+namespace glws {
+
+
+static Display *display = NULL;
+static EGLDisplay eglDisplay = EGL_NO_DISPLAY;
+static int screen = 0;
+
+
+class EglVisual : public Visual
+{
+public:
+    EGLConfig config;
+    XVisualInfo *visinfo;
+
+    EglVisual() :
+        config(0),
+        visinfo(0)
+    {}
+
+    ~EglVisual() {
+        XFree(visinfo);
+    }
+};
+
+
+static void describeEvent(const XEvent &event) {
+    if (0) {
+        switch (event.type) {
+        case ConfigureNotify:
+            std::cerr << "ConfigureNotify";
+            break;
+        case Expose:
+            std::cerr << "Expose";
+            break;
+        case KeyPress:
+            std::cerr << "KeyPress";
+            break;
+        case MapNotify:
+            std::cerr << "MapNotify";
+            break;
+        case ReparentNotify:
+            std::cerr << "ReparentNotify";
+            break;
+        default:
+            std::cerr << "Event " << event.type;
+        }
+        std::cerr << " " << event.xany.window << "\n";
+    }
+}
+
+class EglDrawable : public Drawable
+{
+public:
+    Window window;
+    EGLSurface surface;
+    EGLint api;
+
+    EglDrawable(const Visual *vis, int w, int h) :
+        Drawable(vis, w, h), api(EGL_OPENGL_ES_API)
+    {
+        XVisualInfo *visinfo = static_cast<const EglVisual *>(visual)->visinfo;
+
+        Window root = RootWindow(display, screen);
+
+        /* window attributes */
+        XSetWindowAttributes attr;
+        attr.background_pixel = 0;
+        attr.border_pixel = 0;
+        attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
+        attr.event_mask = StructureNotifyMask;
+
+        unsigned long mask;
+        mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+        int x = 0, y = 0;
+
+        window = XCreateWindow(
+            display, root,
+            x, y, width, height,
+            0,
+            visinfo->depth,
+            InputOutput,
+            visinfo->visual,
+            mask,
+            &attr);
+
+        XSizeHints sizehints;
+        sizehints.x = x;
+        sizehints.y = y;
+        sizehints.width  = width;
+        sizehints.height = height;
+        sizehints.flags = USSize | USPosition;
+        XSetNormalHints(display, window, &sizehints);
+
+        const char *name = "glretrace";
+        XSetStandardProperties(
+            display, window, name, name,
+            None, (char **)NULL, 0, &sizehints);
+
+        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+
+        EGLConfig config = static_cast<const EglVisual *>(visual)->config;
+        surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL);
+    }
+
+    void waitForEvent(int type) {
+        XEvent event;
+        do {
+            XWindowEvent(display, window, StructureNotifyMask, &event);
+            describeEvent(event);
+        } while (event.type != type);
+    }
+
+    ~EglDrawable() {
+        eglDestroySurface(eglDisplay, surface);
+        eglWaitClient();
+        XDestroyWindow(display, window);
+        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+    }
+
+    void
+    recreate(void) {
+        EGLContext currentContext = eglGetCurrentContext();
+        EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
+        EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_DRAW);
+        bool rebindDrawSurface = currentDrawSurface == surface;
+        bool rebindReadSurface = currentReadSurface == surface;
+
+        if (rebindDrawSurface || rebindReadSurface) {
+            eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        }
+
+        eglDestroySurface(eglDisplay, surface);
+
+        EGLConfig config = static_cast<const EglVisual *>(visual)->config;
+        surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL);
+
+        if (rebindDrawSurface || rebindReadSurface) {
+            eglMakeCurrent(eglDisplay, surface, surface, currentContext);
+        }
+    }
+
+    void
+    resize(int w, int h) {
+        if (w == width && h == height) {
+            return;
+        }
+
+        eglWaitClient();
+
+        // We need to ensure that pending events are processed here, and XSync
+        // with discard = True guarantees that, but it appears the limited
+        // event processing we do so far is sufficient
+        //XSync(display, True);
+
+        Drawable::resize(w, h);
+
+        XResizeWindow(display, window, w, h);
+
+        // Tell the window manager to respect the requested size
+        XSizeHints size_hints;
+        size_hints.max_width  = size_hints.min_width  = w;
+        size_hints.max_height = size_hints.min_height = h;
+        size_hints.flags = PMinSize | PMaxSize;
+        XSetWMNormalHints(display, window, &size_hints);
+
+        waitForEvent(ConfigureNotify);
+
+        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+
+        /*
+         * Some implementations won't update the backbuffer unless we recreate
+         * the EGL surface.
+         */
+
+        int eglWidth;
+        int eglHeight;
+
+        eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
+        eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);
+
+        if (eglWidth != width || eglHeight != height) {
+            recreate();
+
+            eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth);
+            eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight);
+        }
+
+        assert(eglWidth == width);
+        assert(eglHeight == height);
+    }
+
+    void show(void) {
+        if (visible) {
+            return;
+        }
+
+        eglWaitClient();
+
+        XMapWindow(display, window);
+
+        waitForEvent(MapNotify);
+
+        eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+
+        Drawable::show();
+    }
+
+    void swapBuffers(void) {
+        eglBindAPI(api);
+        eglSwapBuffers(eglDisplay, surface);
+    }
+};
+
+
+class EglContext : public Context
+{
+public:
+    EGLContext context;
+
+    EglContext(const Visual *vis, Profile prof, EGLContext ctx) :
+        Context(vis, prof),
+        context(ctx)
+    {}
+
+    ~EglContext() {
+        eglDestroyContext(eglDisplay, context);
+    }
+};
+
+/**
+ * Load the symbols from the specified shared object into global namespace, so
+ * that they can be later found by dlsym(RTLD_NEXT, ...);
+ */
+static void
+load(const char *filename)
+{
+    if (!dlopen(filename, RTLD_GLOBAL | RTLD_LAZY)) {
+        std::cerr << "error: unable to open " << filename << "\n";
+        exit(1);
+    }
+}
+
+void
+init(void) {
+    load("libEGL.so.1");
+
+    display = XOpenDisplay(NULL);
+    if (!display) {
+        std::cerr << "error: unable to open display " << XDisplayName(NULL) << "\n";
+        exit(1);
+    }
+
+    screen = DefaultScreen(display);
+
+    eglDisplay = eglGetDisplay((EGLNativeDisplayType)display);
+    if (eglDisplay == EGL_NO_DISPLAY) {
+        std::cerr << "error: unable to get EGL display\n";
+        XCloseDisplay(display);
+        exit(1);
+    }
+
+    EGLint major, minor;
+    if (!eglInitialize(eglDisplay, &major, &minor)) {
+        std::cerr << "error: unable to initialize EGL display\n";
+        XCloseDisplay(display);
+        exit(1);
+    }
+}
+
+void
+cleanup(void) {
+    if (display) {
+        eglTerminate(eglDisplay);
+        XCloseDisplay(display);
+        display = NULL;
+    }
+}
+
+Visual *
+createVisual(bool doubleBuffer, Profile profile) {
+    EglVisual *visual = new EglVisual();
+    // possible combinations
+    const EGLint api_bits_gl[7] = {
+        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT,
+        EGL_OPENGL_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_BIT,
+        EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_ES_BIT,
+    };
+    const EGLint api_bits_gles1[7] = {
+        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT,
+        EGL_OPENGL_ES_BIT,
+        EGL_OPENGL_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_BIT,
+        EGL_OPENGL_ES2_BIT,
+    };
+    const EGLint api_bits_gles2[7] = {
+        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_BIT | EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_ES2_BIT,
+        EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT,
+        EGL_OPENGL_BIT,
+        EGL_OPENGL_ES_BIT,
+    };
+    const EGLint *api_bits;
+
+    switch(profile) {
+    case PROFILE_COMPAT:
+        api_bits = api_bits_gl;
+        break;
+    case PROFILE_ES1:
+        api_bits = api_bits_gles1;
+        break;
+    case PROFILE_ES2:
+        api_bits = api_bits_gles2;
+        break;
+    default:
+        return NULL;
+    };
+
+    for (int i = 0; i < 7; i++) {
+        Attributes<EGLint> attribs;
+
+        attribs.add(EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
+        attribs.add(EGL_RED_SIZE, 1);
+        attribs.add(EGL_GREEN_SIZE, 1);
+        attribs.add(EGL_BLUE_SIZE, 1);
+        attribs.add(EGL_ALPHA_SIZE, 1);
+        attribs.add(EGL_DEPTH_SIZE, 1);
+        attribs.add(EGL_STENCIL_SIZE, 1);
+        attribs.add(EGL_RENDERABLE_TYPE, api_bits[i]);
+        attribs.end(EGL_NONE);
+
+        EGLint num_configs, vid;
+        if (eglChooseConfig(eglDisplay, attribs, &visual->config, 1, &num_configs) &&
+            num_configs == 1 &&
+            eglGetConfigAttrib(eglDisplay, visual->config, EGL_NATIVE_VISUAL_ID, &vid)) {
+            XVisualInfo templ;
+            int num_visuals;
+
+            templ.visualid = vid;
+            visual->visinfo = XGetVisualInfo(display, VisualIDMask, &templ, &num_visuals);
+            break;
+        }
+    }
+
+    assert(visual->visinfo);
+
+    return visual;
+}
+
+Drawable *
+createDrawable(const Visual *visual, int width, int height)
+{
+    return new EglDrawable(visual, width, height);
+}
+
+Context *
+createContext(const Visual *_visual, Context *shareContext, Profile profile, bool debug)
+{
+    const EglVisual *visual = static_cast<const EglVisual *>(_visual);
+    EGLContext share_context = EGL_NO_CONTEXT;
+    EGLContext context;
+    Attributes<EGLint> attribs;
+
+    if (shareContext) {
+        share_context = static_cast<EglContext*>(shareContext)->context;
+    }
+
+    EGLint api = eglQueryAPI();
+
+    switch (profile) {
+    case PROFILE_COMPAT:
+        load("libGL.so.1");
+        eglBindAPI(EGL_OPENGL_API);
+        break;
+    case PROFILE_CORE:
+        assert(0);
+        return NULL;
+    case PROFILE_ES1:
+        load("libGLESv1_CM.so.1");
+        eglBindAPI(EGL_OPENGL_ES_API);
+        break;
+    case PROFILE_ES2:
+        load("libGLESv2.so.2");
+        eglBindAPI(EGL_OPENGL_ES_API);
+        attribs.add(EGL_CONTEXT_CLIENT_VERSION, 2);
+        break;
+    default:
+        return NULL;
+    }
+
+    attribs.end(EGL_NONE);
+
+    context = eglCreateContext(eglDisplay, visual->config, share_context, attribs);
+    if (!context)
+        return NULL;
+
+    eglBindAPI(api);
+
+    return new EglContext(visual, profile, context);
+}
+
+bool
+makeCurrent(Drawable *drawable, Context *context)
+{
+    if (!drawable || !context) {
+        return eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+    } else {
+        EglDrawable *eglDrawable = static_cast<EglDrawable *>(drawable);
+        EglContext *eglContext = static_cast<EglContext *>(context);
+        EGLBoolean ok;
+
+        ok = eglMakeCurrent(eglDisplay, eglDrawable->surface,
+                            eglDrawable->surface, eglContext->context);
+
+        if (ok) {
+            EGLint api;
+
+            eglQueryContext(eglDisplay, eglContext->context,
+                            EGL_CONTEXT_CLIENT_TYPE, &api);
+
+            eglDrawable->api = api;
+        }
+
+        return ok;
+    }
+}
+
+bool
+processEvents(void) {
+    while (XPending(display) > 0) {
+        XEvent event;
+        XNextEvent(display, &event);
+        describeEvent(event);
+    }
+    return true;
+}
+
+
+} /* namespace glws */
diff --git a/retrace/glws_glx.cpp b/retrace/glws_glx.cpp
new file mode 100644 (file)
index 0000000..1573bb9
--- /dev/null
@@ -0,0 +1,377 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include <iostream>
+
+#include "glproc.hpp"
+#include "glws.hpp"
+
+
+namespace glws {
+
+
+static Display *display = NULL;
+static int screen = 0;
+
+static unsigned glxVersion = 0;
+static const char *extensions = 0;
+static bool has_GLX_ARB_create_context = false;
+
+
+class GlxVisual : public Visual
+{
+public:
+    GLXFBConfig fbconfig;
+    XVisualInfo *visinfo;
+
+    GlxVisual() :
+        fbconfig(0),
+        visinfo(0)
+    {}
+
+    ~GlxVisual() {
+        XFree(visinfo);
+    }
+};
+
+
+static void describeEvent(const XEvent &event) {
+    if (0) {
+        switch (event.type) {
+        case ConfigureNotify:
+            std::cerr << "ConfigureNotify";
+            break;
+        case Expose:
+            std::cerr << "Expose";
+            break;
+        case KeyPress:
+            std::cerr << "KeyPress";
+            break;
+        case MapNotify:
+            std::cerr << "MapNotify";
+            break;
+        case ReparentNotify:
+            std::cerr << "ReparentNotify";
+            break;
+        default:
+            std::cerr << "Event " << event.type;
+        }
+        std::cerr << " " << event.xany.window << "\n";
+    }
+}
+
+class GlxDrawable : public Drawable
+{
+public:
+    Window window;
+
+    GlxDrawable(const Visual *vis, int w, int h) :
+        Drawable(vis, w, h)
+    {
+        XVisualInfo *visinfo = static_cast<const GlxVisual *>(visual)->visinfo;
+
+        Window root = RootWindow(display, screen);
+
+        /* window attributes */
+        XSetWindowAttributes attr;
+        attr.background_pixel = 0;
+        attr.border_pixel = 0;
+        attr.colormap = XCreateColormap(display, root, visinfo->visual, AllocNone);
+        attr.event_mask = StructureNotifyMask;
+
+        unsigned long mask;
+        mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+        int x = 0, y = 0;
+
+        window = XCreateWindow(
+            display, root,
+            x, y, width, height,
+            0,
+            visinfo->depth,
+            InputOutput,
+            visinfo->visual,
+            mask,
+            &attr);
+
+        XSizeHints sizehints;
+        sizehints.x = x;
+        sizehints.y = y;
+        sizehints.width  = width;
+        sizehints.height = height;
+        sizehints.flags = USSize | USPosition;
+        XSetNormalHints(display, window, &sizehints);
+
+        const char *name = "glretrace";
+        XSetStandardProperties(
+            display, window, name, name,
+            None, (char **)NULL, 0, &sizehints);
+
+        glXWaitX();
+    }
+
+    void waitForEvent(int type) {
+        XEvent event;
+        do {
+            XWindowEvent(display, window, StructureNotifyMask, &event);
+            describeEvent(event);
+        } while (event.type != type);
+    }
+
+    ~GlxDrawable() {
+        XDestroyWindow(display, window);
+    }
+
+    void
+    resize(int w, int h) {
+        if (w == width && h == height) {
+            return;
+        }
+
+        glXWaitGL();
+
+        // We need to ensure that pending events are processed here, and XSync
+        // with discard = True guarantees that, but it appears the limited
+        // event processing we do so far is sufficient
+        //XSync(display, True);
+
+        Drawable::resize(w, h);
+
+        XResizeWindow(display, window, w, h);
+
+        // Tell the window manager to respect the requested size
+        XSizeHints size_hints;
+        size_hints.max_width  = size_hints.min_width  = w;
+        size_hints.max_height = size_hints.min_height = h;
+        size_hints.flags = PMinSize | PMaxSize;
+        XSetWMNormalHints(display, window, &size_hints);
+
+        waitForEvent(ConfigureNotify);
+
+        glXWaitX();
+    }
+
+    void show(void) {
+        if (visible) {
+            return;
+        }
+
+        glXWaitGL();
+
+        XMapWindow(display, window);
+
+        waitForEvent(MapNotify);
+
+        glXWaitX();
+
+        Drawable::show();
+    }
+
+    void swapBuffers(void) {
+        glXSwapBuffers(display, window);
+    }
+};
+
+
+class GlxContext : public Context
+{
+public:
+    GLXContext context;
+
+    GlxContext(const Visual *vis, Profile prof, GLXContext ctx) :
+        Context(vis, prof),
+        context(ctx)
+    {}
+
+    ~GlxContext() {
+        glXDestroyContext(display, context);
+    }
+};
+
+void
+init(void) {
+    display = XOpenDisplay(NULL);
+    if (!display) {
+        std::cerr << "error: unable to open display " << XDisplayName(NULL) << "\n";
+        exit(1);
+    }
+
+    screen = DefaultScreen(display);
+
+    int major = 0, minor = 0;
+    glXQueryVersion(display, &major, &minor);
+    glxVersion = (major << 8) | minor;
+
+    extensions = glXQueryExtensionsString(display, screen);
+    has_GLX_ARB_create_context = checkExtension("GLX_ARB_create_context", extensions);
+}
+
+void
+cleanup(void) {
+    if (display) {
+        XCloseDisplay(display);
+        display = NULL;
+    }
+}
+
+Visual *
+createVisual(bool doubleBuffer, Profile profile) {
+    if (profile != PROFILE_COMPAT &&
+        profile != PROFILE_CORE) {
+        return NULL;
+    }
+
+    GlxVisual *visual = new GlxVisual;
+
+    if (glxVersion >= 0x0103) {
+        Attributes<int> attribs;
+        attribs.add(GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT);
+        attribs.add(GLX_RENDER_TYPE, GLX_RGBA_BIT);
+        attribs.add(GLX_RED_SIZE, 1);
+        attribs.add(GLX_GREEN_SIZE, 1);
+        attribs.add(GLX_BLUE_SIZE, 1);
+        attribs.add(GLX_ALPHA_SIZE, 1);
+        attribs.add(GLX_DOUBLEBUFFER, doubleBuffer ? GL_TRUE : GL_FALSE);
+        attribs.add(GLX_DEPTH_SIZE, 1);
+        attribs.add(GLX_STENCIL_SIZE, 1);
+        attribs.end();
+
+        int num_configs = 0;
+        GLXFBConfig * fbconfigs;
+        fbconfigs = glXChooseFBConfig(display, screen, attribs, &num_configs);
+        assert(num_configs && fbconfigs);
+        visual->fbconfig = fbconfigs[0];
+        assert(visual->fbconfig);
+        visual->visinfo = glXGetVisualFromFBConfig(display, visual->fbconfig);
+        assert(visual->visinfo);
+    } else {
+        Attributes<int> attribs;
+        attribs.add(GLX_RGBA);
+        attribs.add(GLX_RED_SIZE, 1);
+        attribs.add(GLX_GREEN_SIZE, 1);
+        attribs.add(GLX_BLUE_SIZE, 1);
+        attribs.add(GLX_ALPHA_SIZE, 1);
+        if (doubleBuffer) {
+            attribs.add(GLX_DOUBLEBUFFER);
+        }
+        attribs.add(GLX_DEPTH_SIZE, 1);
+        attribs.add(GLX_STENCIL_SIZE, 1);
+        attribs.end();
+
+        visual->visinfo = glXChooseVisual(display, screen, attribs);
+    }
+
+    return visual;
+}
+
+Drawable *
+createDrawable(const Visual *visual, int width, int height)
+{
+    return new GlxDrawable(visual, width, height);
+}
+
+Context *
+createContext(const Visual *_visual, Context *shareContext, Profile profile, bool debug)
+{
+    const GlxVisual *visual = static_cast<const GlxVisual *>(_visual);
+    GLXContext share_context = NULL;
+    GLXContext context;
+
+    if (shareContext) {
+        share_context = static_cast<GlxContext*>(shareContext)->context;
+    }
+
+    if (glxVersion >= 0x0104 && has_GLX_ARB_create_context) {
+        Attributes<int> attribs;
+        
+        attribs.add(GLX_RENDER_TYPE, GLX_RGBA_TYPE);
+        if (debug) {
+            attribs.add(GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB);
+        }
+
+        switch (profile) {
+        case PROFILE_COMPAT:
+            break;
+        case PROFILE_CORE:
+            // XXX: This will invariable return a 3.2 context, when supported.
+            // We probably should have a PROFILE_CORE_XX per version.
+            attribs.add(GLX_CONTEXT_MAJOR_VERSION_ARB, 3);
+            attribs.add(GLX_CONTEXT_MINOR_VERSION_ARB, 2);
+            attribs.add(GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB);
+            break;
+        default:
+            return NULL;
+        }
+        
+        attribs.end();
+
+        context = glXCreateContextAttribsARB(display, visual->fbconfig, share_context, True, attribs);
+    } else {
+        if (profile != PROFILE_COMPAT) {
+            return NULL;
+        }
+
+        if (glxVersion >= 0x103) {
+            context = glXCreateNewContext(display, visual->fbconfig, GLX_RGBA_TYPE, share_context, True);
+        } else {
+            context = glXCreateContext(display, visual->visinfo, share_context, True);
+        }
+    }
+
+    if (!context) {
+        return NULL;
+    }
+
+    return new GlxContext(visual, profile, context);
+}
+
+bool
+makeCurrent(Drawable *drawable, Context *context)
+{
+    if (!drawable || !context) {
+        return glXMakeCurrent(display, None, NULL);
+    } else {
+        GlxDrawable *glxDrawable = static_cast<GlxDrawable *>(drawable);
+        GlxContext *glxContext = static_cast<GlxContext *>(context);
+
+        return glXMakeCurrent(display, glxDrawable->window, glxContext->context);
+    }
+}
+
+bool
+processEvents(void) {
+    while (XPending(display) > 0) {
+        XEvent event;
+        XNextEvent(display, &event);
+        describeEvent(event);
+    }
+    return true;
+}
+
+
+} /* namespace glws */
diff --git a/retrace/glws_wgl.cpp b/retrace/glws_wgl.cpp
new file mode 100644 (file)
index 0000000..c6e4a3f
--- /dev/null
@@ -0,0 +1,352 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/*
+ * WGL bindings.
+ */
+
+
+#include <iostream>
+
+#include "glproc.hpp"
+#include "glws.hpp"
+
+
+namespace glws {
+
+
+/*
+ * Several WGL functions come in two flavors:
+ * - GDI (ChoosePixelFormat, SetPixelFormat, SwapBuffers, etc)
+ * - WGL (wglChoosePixelFormat, wglSetPixelFormat, wglSwapBuffers, etc)
+ *
+ * The GDI entrypoints will inevitably dispatch to the first module named
+ * "OPENGL32", loading "C:\Windows\System32\opengl32.dll" if none was loaded so
+ * far.
+ *
+ * In order to use a implementation other than the one installed in the system
+ * (when specified via the TRACE_LIBGL environment variable), we need to use
+ * WGL entrypoints.
+ *
+ * See also:
+ * - http://www.opengl.org/archives/resources/faq/technical/mswindows.htm
+ */
+static PFN_WGLCHOOSEPIXELFORMAT pfnChoosePixelFormat = &ChoosePixelFormat;
+static PFN_WGLSETPIXELFORMAT pfnSetPixelFormat = &SetPixelFormat;
+static PFN_WGLSWAPBUFFERS pfnSwapBuffers = &SwapBuffers;
+
+
+static LRESULT CALLBACK
+WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    MINMAXINFO *pMMI;
+    switch (uMsg) {
+    case WM_KEYDOWN:
+        switch (wParam) {
+        case VK_ESCAPE:
+            PostMessage(hWnd, WM_CLOSE, 0, 0);
+            break;
+        }
+        break;
+    case WM_GETMINMAXINFO:
+        // Allow to create a window bigger than the desktop
+        pMMI = (MINMAXINFO *)lParam;
+        pMMI->ptMaxSize.x = 60000;
+        pMMI->ptMaxSize.y = 60000;
+        pMMI->ptMaxTrackSize.x = 60000;
+        pMMI->ptMaxTrackSize.y = 60000;
+        break;
+    case WM_CLOSE:
+        exit(0);
+        break;
+    default:
+        break;
+    }
+
+    return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+
+class WglDrawable : public Drawable
+{
+public:
+    DWORD dwExStyle;
+    DWORD dwStyle;
+    HWND hWnd;
+    HDC hDC;
+    PIXELFORMATDESCRIPTOR pfd;
+    int iPixelFormat;
+
+    WglDrawable(const Visual *vis, int width, int height) :
+        Drawable(vis, width, height)
+    {
+        static bool first = TRUE;
+        RECT rect;
+        BOOL bRet;
+
+        if (first) {
+            WNDCLASS wc;
+            memset(&wc, 0, sizeof wc);
+            wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
+            wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+            wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+            wc.lpfnWndProc = WndProc;
+            wc.lpszClassName = "glretrace";
+            wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
+            RegisterClass(&wc);
+            first = FALSE;
+        }
+
+        dwExStyle = 0;
+        dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW;
+
+        int x = 0, y = 0;
+
+        rect.left = x;
+        rect.top = y;
+        rect.right = rect.left + width;
+        rect.bottom = rect.top + height;
+
+        AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle);
+
+        hWnd = CreateWindowEx(dwExStyle,
+                              "glretrace", /* wc.lpszClassName */
+                              NULL,
+                              dwStyle,
+                              0, /* x */
+                              0, /* y */
+                              rect.right - rect.left, /* width */
+                              rect.bottom - rect.top, /* height */
+                              NULL,
+                              NULL,
+                              NULL,
+                              NULL);
+        hDC = GetDC(hWnd);
+   
+        memset(&pfd, 0, sizeof pfd);
+        pfd.cColorBits = 4;
+        pfd.cRedBits = 1;
+        pfd.cGreenBits = 1;
+        pfd.cBlueBits = 1;
+        pfd.cAlphaBits = 1;
+        pfd.cDepthBits = 1;
+        pfd.cStencilBits = 1;
+        pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
+        pfd.iLayerType = PFD_MAIN_PLANE;
+        pfd.iPixelType = PFD_TYPE_RGBA;
+        pfd.nSize = sizeof(pfd);
+        pfd.nVersion = 1;
+
+        if (visual->doubleBuffer) {
+           pfd.dwFlags |= PFD_DOUBLEBUFFER;
+        }
+
+        iPixelFormat = pfnChoosePixelFormat(hDC, &pfd);
+        if (iPixelFormat <= 0) {
+            std::cerr << "error: ChoosePixelFormat failed\n";
+            exit(1);
+        }
+
+        bRet = pfnSetPixelFormat(hDC, iPixelFormat, &pfd);
+        if (!bRet) {
+            std::cerr << "error: SetPixelFormat failed\n";
+            exit(1);
+        }
+    }
+
+    ~WglDrawable() {
+        ReleaseDC(hWnd, hDC);
+        DestroyWindow(hWnd);
+    }
+    
+    void
+    resize(int w, int h) {
+        if (w == width && h == height) {
+            return;
+        }
+
+        RECT rClient, rWindow;
+        GetClientRect(hWnd, &rClient);
+        GetWindowRect(hWnd, &rWindow);
+        w += (rWindow.right  - rWindow.left) - rClient.right;
+        h += (rWindow.bottom - rWindow.top)  - rClient.bottom;
+        SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, w, h, SWP_NOMOVE);
+
+        Drawable::resize(w, h);
+    }
+
+    void show(void) {
+        if (visible) {
+            return;
+        }
+
+        ShowWindow(hWnd, SW_SHOW);
+
+        Drawable::show();
+    }
+
+    void swapBuffers(void) {
+        BOOL bRet;
+        bRet = pfnSwapBuffers(hDC);
+        if (!bRet) {
+            std::cerr << "warning: SwapBuffers failed\n";
+        }
+
+        // Drain message queue to prevent window from being considered
+        // non-responsive
+        MSG msg;
+        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+            TranslateMessage(&msg);
+            DispatchMessage(&msg);
+        }
+    }
+};
+
+
+class WglContext : public Context
+{
+public:
+    HGLRC hglrc;
+    WglContext *shareContext;
+
+    WglContext(const Visual *vis, Profile prof, WglContext *share) :
+        Context(vis, prof),
+        hglrc(0),
+        shareContext(share)
+    {}
+
+    ~WglContext() {
+        if (hglrc) {
+            wglDeleteContext(hglrc);
+        }
+    }
+};
+
+
+void
+init(void) {
+    /*
+     * OpenGL library must be loaded by the time we call GDI.
+     */
+
+    const char * libgl_filename = getenv("TRACE_LIBGL");
+
+    if (libgl_filename) {
+        pfnChoosePixelFormat = &wglChoosePixelFormat;
+        pfnSetPixelFormat = &wglSetPixelFormat;
+        pfnSwapBuffers = &wglSwapBuffers;
+    } else {
+        libgl_filename = "OPENGL32";
+    }
+
+    _libGlHandle = LoadLibraryA(libgl_filename);
+    if (!_libGlHandle) {
+        std::cerr << "error: unable to open " << libgl_filename << "\n";
+        exit(1);
+    }
+}
+
+void
+cleanup(void) {
+}
+
+Visual *
+createVisual(bool doubleBuffer, Profile profile) {
+    if (profile != PROFILE_COMPAT) {
+        return NULL;
+    }
+
+    Visual *visual = new Visual();
+
+    visual->doubleBuffer = doubleBuffer;
+
+    return visual;
+}
+
+Drawable *
+createDrawable(const Visual *visual, int width, int height)
+{
+    return new WglDrawable(visual, width, height);
+}
+
+Context *
+createContext(const Visual *visual, Context *shareContext, Profile profile, bool debug)
+{
+    if (profile != PROFILE_COMPAT) {
+        return NULL;
+    }
+
+    return new WglContext(visual, profile, static_cast<WglContext *>(shareContext));
+}
+
+bool
+makeCurrent(Drawable *drawable, Context *context)
+{
+    if (!drawable || !context) {
+        return wglMakeCurrent(NULL, NULL);
+    } else {
+        WglDrawable *wglDrawable = static_cast<WglDrawable *>(drawable);
+        WglContext *wglContext = static_cast<WglContext *>(context);
+
+        if (!wglContext->hglrc) {
+            wglContext->hglrc = wglCreateContext(wglDrawable->hDC);
+            if (!wglContext->hglrc) {
+                std::cerr << "error: wglCreateContext failed\n";
+                exit(1);
+                return false;
+            }
+            if (wglContext->shareContext) {
+                BOOL bRet;
+                bRet = wglShareLists(wglContext->shareContext->hglrc,
+                                     wglContext->hglrc);
+                if (!bRet) {
+                    std::cerr << "warning: wglShareLists failed\n";
+                }
+            }
+        }
+
+        return wglMakeCurrent(wglDrawable->hDC, wglContext->hglrc);
+    }
+}
+
+bool
+processEvents(void) {
+    MSG uMsg;
+    while (PeekMessage(&uMsg, NULL, 0, 0, PM_REMOVE)) {
+        if (uMsg.message == WM_QUIT) {
+            return false;
+        }
+
+        if (!TranslateAccelerator(uMsg.hwnd, NULL, &uMsg)) {
+            TranslateMessage(&uMsg);
+            DispatchMessage(&uMsg);
+        }
+    }
+    return true;
+}
+
+
+} /* namespace glws */
diff --git a/retrace/json.hpp b/retrace/json.hpp
new file mode 100644 (file)
index 0000000..2f50a8c
--- /dev/null
@@ -0,0 +1,369 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/*
+ * Trace writing functions.
+ */
+
+#ifndef _JSON_HPP_
+#define _JSON_HPP_
+
+#include <assert.h>
+#include <stddef.h>
+#include <wchar.h>
+
+#ifdef _MSC_VER
+#  include <float.h>
+#  define isfinite _finite
+#else
+#  include <math.h> // isfinite
+#endif
+
+#include <iomanip>
+#include <limits>
+#include <ostream>
+#include <string>
+
+
+class JSONWriter
+{
+private:
+    std::ostream &os;
+
+    int level;
+    bool value;
+    char space;
+
+    void newline(void) {
+        os << "\n";
+        for (int i = 0; i < level; ++i) 
+            os << "  ";
+    }
+
+    void separator(void) {
+        if (value) {
+            os << ",";
+            switch (space) {
+            case '\0':
+                break;
+            case '\n':
+                newline();
+                break;
+            default:
+                os << space;
+                break;
+            }
+        } else {
+            if (space == '\n') {
+                newline();
+            }
+        }
+    }
+
+    void escapeAsciiString(const char *str) {
+        os << "\"";
+
+        const unsigned char *src = (const unsigned char *)str;
+        unsigned char c;
+        while ((c = *src++)) {
+            if ((c == '\"') ||
+                (c == '\\')) {
+                // escape character
+                os << '\\' << (unsigned char)c;
+            } else if ((c >= 0x20 && c <= 0x7e) ||
+                        c == '\t' ||
+                        c == '\r' ||
+                        c == '\n') {
+                // pass-through character
+                os << (unsigned char)c;
+            } else {
+                assert(0);
+                os << "?";
+            }
+        }
+
+        os << "\"";
+    }
+
+    void escapeUnicodeString(const char *str) {
+        os << "\"";
+
+        const char *locale = setlocale(LC_CTYPE, "");
+        const char *src = str;
+        mbstate_t state;
+
+        memset(&state, 0, sizeof state);
+
+        do {
+            // Convert characters one at a time in order to recover from
+            // conversion errors
+            wchar_t c;
+            size_t written = mbsrtowcs(&c, &src, 1, &state);
+            if (written == 0) {
+                // completed
+                break;
+            } if (written == (size_t)-1) {
+                // conversion error -- skip 
+                os << "?";
+                do {
+                    ++src;
+                } while (*src & 0x80);
+            } else if ((c == '\"') ||
+                       (c == '\\')) {
+                // escape character
+                os << '\\' << (unsigned char)c;
+            } else if ((c >= 0x20 && c <= 0x7e) ||
+                        c == '\t' ||
+                        c == '\r' ||
+                        c == '\n') {
+                // pass-through character
+                os << (unsigned char)c;
+            } else {
+                // unicode
+                os << "\\u" << std::setfill('0') << std::hex << std::setw(4) << (unsigned)c;
+                os << std::dec;
+            }
+        } while (src);
+
+        setlocale(LC_CTYPE, locale);
+
+        os << "\"";
+    }
+
+    void encodeBase64String(const unsigned char *bytes, size_t size) {
+        const char *table64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+        unsigned char c0, c1, c2, c3;
+        char buf[4];
+        unsigned written;
+
+        os << "\"";
+
+        written = 0;
+        while (size >= 3) {
+            c0 = bytes[0] >> 2;
+            c1 = ((bytes[0] & 0x03) << 4) | ((bytes[1] & 0xf0) >> 4);
+            c2 = ((bytes[1] & 0x0f) << 2) | ((bytes[2] & 0xc0) >> 6);
+            c3 = bytes[2] & 0x3f;
+
+            buf[0] = table64[c0];
+            buf[1] = table64[c1];
+            buf[2] = table64[c2];
+            buf[3] = table64[c3];
+
+            os.write(buf, 4);
+
+            bytes += 3;
+            size -= 3;
+            ++written;
+
+            if (written >= 76/4 && size) {
+                os << "\n";
+                written = 0;
+            }
+        }
+
+        if (size > 0) {
+            c0 = bytes[0] >> 2;
+            c1 = ((bytes[0] & 0x03) << 4);
+            buf[2] = '=';
+            buf[3] = '=';
+            
+            if (size > 1) {
+                c1 |= ((bytes[1] & 0xf0) >> 4);
+                c2 = ((bytes[1] & 0x0f) << 2);
+                if (size > 2) {
+                    c2 |= ((bytes[2] & 0xc0) >> 6);
+                    c3 = bytes[2] & 0x3f;
+                    buf[3] = table64[c3];
+                }
+                buf[2] = table64[c2];
+            }
+            buf[1] = table64[c1];
+            buf[0] = table64[c0];
+
+            os.write(buf, 4);
+        }
+
+        os << "\"";
+    }
+
+public:
+    JSONWriter(std::ostream &_os) : 
+        os(_os), 
+        level(0),
+        value(false),
+        space(0)
+    {
+        beginObject();
+    }
+
+    ~JSONWriter() {
+        endObject();
+        newline();
+    }
+
+    inline void beginObject() {
+        separator();
+        os << "{";
+        ++level;
+        value = false;
+    }
+
+    inline void endObject() {
+        --level;
+        if (value)
+            newline();
+        os << "}";
+        value = true;
+        space = '\n';
+    }
+
+    inline void beginMember(const char * name) {
+        space = 0;
+        separator();
+        newline();
+        escapeAsciiString(name);
+        os << ": ";
+        value = false;
+    }
+
+    inline void beginMember(const std::string &name) {
+        beginMember(name.c_str());
+    }
+
+    inline void endMember(void) {
+        assert(value);
+        value = true;
+        space = 0;
+    }
+
+    inline void beginArray() {
+        separator();
+        os << "[";
+        ++level;
+        value = false;
+        space = 0;
+    }
+
+    inline void endArray(void) {
+        --level;
+        if (space == '\n') {
+            newline();
+        }
+        os << "]";
+        value = true;
+        space = '\n';
+    }
+
+    inline void writeString(const char *s) {
+        if (!s) {
+            writeNull();
+            return;
+        }
+
+        separator();
+        escapeUnicodeString(s);
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeString(const std::string &s) {
+        writeString(s.c_str());
+    }
+
+    inline void writeBase64(const void *bytes, size_t size) {
+        separator();
+        encodeBase64String((const unsigned char *)bytes, size);
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeNull(void) {
+        separator();
+        os << "null";
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeBool(bool b) {
+        separator();
+        os << (b ? "true" : "false");
+        value = true;
+        space = ' ';
+    }
+
+
+    /**
+     * Special case for char to prevent it to be written as a literal
+     * character.
+     */
+    inline void writeNumber(char n) {
+        separator();
+        os << std::dec << static_cast<int>(n);
+        value = true;
+        space = ' ';
+    }
+
+    inline void writeNumber(unsigned char n) {
+        separator();
+        os << std::dec << static_cast<unsigned>(n);
+        value = true;
+        space = ' ';
+    }
+
+    template<class T>
+    inline void writeNumber(T n) {
+        if (!isfinite(n)) {
+            // NaN/Inf
+            writeNull();
+        } else {
+            separator();
+            os << std::dec << std::setprecision(std::numeric_limits<T>::digits10 + 1) << n;
+            value = true;
+            space = ' ';
+        }
+    }
+    
+    inline void writeStringMember(const char *name, const char *s) {
+        beginMember(name);
+        writeString(s);
+        endMember();
+    }
+
+    inline void writeBoolMember(const char *name, bool b) {
+        beginMember(name);
+        writeBool(b);
+        endMember();
+    }
+
+    template<class T>
+    inline void writeNumberMember(const char *name, T n) {
+        beginMember(name);
+        writeNumber(n);
+        endMember();
+    }
+};
+
+#endif /* _JSON_HPP_ */
diff --git a/retrace/retrace.cpp b/retrace/retrace.cpp
new file mode 100644 (file)
index 0000000..182d118
--- /dev/null
@@ -0,0 +1,119 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+#include <iostream>
+
+#include "os_time.hpp"
+#include "trace_dump.hpp"
+#include "retrace.hpp"
+
+
+namespace retrace {
+
+
+static bool call_dumped = false;
+
+
+static void dumpCall(trace::Call &call) {
+    if (verbosity >= 0 && !call_dumped) {
+        std::cout << call;
+        std::cout.flush();
+        call_dumped = true;
+    }
+}
+
+
+std::ostream &warning(trace::Call &call) {
+    dumpCall(call);
+
+    std::cerr << call.no << ": ";
+    std::cerr << "warning: ";
+
+    return std::cerr;
+}
+
+
+void ignore(trace::Call &call) {
+    (void)call;
+}
+
+void unsupported(trace::Call &call) {
+    warning(call) << "unsupported " << call.name() << " call\n";
+}
+
+inline void Retracer::addCallback(const Entry *entry) {
+    assert(entry->name);
+    assert(entry->callback);
+    map[entry->name] = entry->callback;
+}
+
+
+void Retracer::addCallbacks(const Entry *entries) {
+    while (entries->name && entries->callback) {
+        addCallback(entries++);
+    }
+}
+
+
+void Retracer::retrace(trace::Call &call) {
+    call_dumped = false;
+
+    if (verbosity >= 1) {
+        if (verbosity >= 2 ||
+            !(call.flags & trace::CALL_FLAG_VERBOSE)) {
+            dumpCall(call);
+        }
+    }
+
+    Callback callback = 0;
+
+    trace::Id id = call.sig->id;
+    if (id >= callbacks.size()) {
+        callbacks.resize(id + 1);
+        callback = 0;
+    } else {
+        callback = callbacks[id];
+    }
+
+    if (!callback) {
+        Map::const_iterator it = map.find(call.name());
+        if (it == map.end()) {
+            callback = &unsupported;
+        } else {
+            callback = it->second;
+        }
+        callbacks[id] = callback;
+    }
+
+    assert(callback);
+    assert(callbacks[id] == callback);
+
+    callback(call);
+}
+
+
+} /* namespace retrace */
diff --git a/retrace/retrace.hpp b/retrace/retrace.hpp
new file mode 100644 (file)
index 0000000..56cebc6
--- /dev/null
@@ -0,0 +1,241 @@
+/**************************************************************************
+ *
+ * Copyright 2011-2012 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _RETRACE_HPP_
+#define _RETRACE_HPP_
+
+#include <assert.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <list>
+#include <map>
+#include <ostream>
+
+#include "trace_model.hpp"
+#include "trace_parser.hpp"
+#include "trace_profiler.hpp"
+
+
+namespace image {
+    class Image;
+}
+
+
+namespace retrace {
+
+
+extern trace::Parser parser;
+extern trace::Profiler profiler;
+
+
+/**
+ * Similar to alloca(), but implemented with malloc.
+ */
+class ScopedAllocator
+{
+private:
+    uintptr_t next;
+
+public:
+    ScopedAllocator() :
+        next(0) {
+    }
+
+    inline void *
+    alloc(size_t size) {
+        /* Always return valid address, even when size is zero */
+        size = std::max(size, sizeof(uintptr_t));
+
+        uintptr_t * buf = static_cast<uintptr_t *>(malloc(sizeof(uintptr_t) + size));
+        if (!buf) {
+            return NULL;
+        }
+
+        *buf = next;
+        next = reinterpret_cast<uintptr_t>(buf);
+        assert((next & 1) == 0);
+
+        return static_cast<void *>(&buf[1]);
+    }
+
+    template< class T >
+    inline T *
+    alloc(size_t n = 1) {
+        return static_cast<T *>(alloc(sizeof(T) * n));
+    }
+
+    /**
+     * Allocate an array with the same dimensions as the specified value.
+     */
+    template< class T >
+    inline T *
+    alloc(const trace::Value *value) {
+        const trace::Array *array = dynamic_cast<const trace::Array *>(value);
+        if (array) {
+            return alloc<T>(array->size());
+        }
+        const trace::Null *null = dynamic_cast<const trace::Null *>(value);
+        if (null) {
+            return NULL;
+        }
+        assert(0);
+        return NULL;
+    }
+
+    /**
+     * Prevent this pointer from being automatically freed.
+     */
+    template< class T >
+    inline void
+    bind(T *ptr) {
+        if (ptr) {
+            reinterpret_cast<uintptr_t *>(ptr)[-1] |= 1;
+        }
+    }
+
+    inline
+    ~ScopedAllocator() {
+        while (next) {
+            uintptr_t temp = *reinterpret_cast<uintptr_t *>(next);
+
+            bool bind = temp & 1;
+            temp &= ~1;
+
+            if (!bind) {
+                free(reinterpret_cast<void *>(next));
+            }
+
+            next = temp;
+        }
+    }
+};
+
+
+/**
+ * Output verbosity when retracing files.
+ */
+extern int verbosity;
+
+/**
+ * Debugging checks.
+ */
+extern bool debug;
+
+/**
+ * Add profiling data to the dump when retracing.
+ */
+extern bool profiling;
+extern bool profilingCpuTimes;
+extern bool profilingGpuTimes;
+extern bool profilingPixelsDrawn;
+
+/**
+ * State dumping.
+ */
+extern bool dumpingState;
+
+
+extern bool doubleBuffer;
+extern bool coreProfile;
+
+extern unsigned frameNo;
+extern unsigned callNo;
+
+
+std::ostream &warning(trace::Call &call);
+
+
+void ignore(trace::Call &call);
+void unsupported(trace::Call &call);
+
+
+typedef void (*Callback)(trace::Call &call);
+
+struct Entry {
+    const char *name;
+    Callback callback;
+};
+
+
+struct stringComparer {
+  bool operator() (const char *a, const  char *b) const {
+    return strcmp(a, b) < 0;
+  }
+};
+
+
+extern const Entry stdc_callbacks[];
+
+
+class Retracer
+{
+    typedef std::map<const char *, Callback, stringComparer> Map;
+    Map map;
+
+    std::vector<Callback> callbacks;
+
+public:
+    Retracer() {
+        addCallbacks(stdc_callbacks);
+    }
+
+    virtual ~Retracer() {}
+
+    void addCallback(const Entry *entry);
+    void addCallbacks(const Entry *entries);
+
+    void retrace(trace::Call &call);
+};
+
+
+void
+setUp(void);
+
+void
+addCallbacks(retrace::Retracer &retracer);
+
+void
+frameComplete(trace::Call &call);
+
+image::Image *
+getSnapshot(void);
+
+bool
+dumpState(std::ostream &os);
+
+void
+flushRendering(void);
+
+void
+waitForInput(void);
+
+void
+cleanUp(void);
+
+
+} /* namespace retrace */
+
+#endif /* _RETRACE_HPP_ */
diff --git a/retrace/retrace.py b/retrace/retrace.py
new file mode 100644 (file)
index 0000000..f9b800c
--- /dev/null
@@ -0,0 +1,510 @@
+##########################################################################
+#
+# Copyright 2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""Generic retracing code generator."""
+
+
+# Adjust path
+import os.path
+import sys
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
+
+
+import specs.stdapi as stdapi
+import specs.glapi as glapi
+
+
+class UnsupportedType(Exception):
+    pass
+
+
+def lookupHandle(handle, value):
+    if handle.key is None:
+        return "_%s_map[%s]" % (handle.name, value)
+    else:
+        key_name, key_type = handle.key
+        return "_%s_map[%s][%s]" % (handle.name, key_name, value)
+
+
+class ValueAllocator(stdapi.Visitor):
+
+    def visitLiteral(self, literal, lvalue, rvalue):
+        pass
+
+    def visitConst(self, const, lvalue, rvalue):
+        self.visit(const.type, lvalue, rvalue)
+
+    def visitAlias(self, alias, lvalue, rvalue):
+        self.visit(alias.type, lvalue, rvalue)
+
+    def visitEnum(self, enum, lvalue, rvalue):
+        pass
+
+    def visitBitmask(self, bitmask, lvalue, rvalue):
+        pass
+
+    def visitArray(self, array, lvalue, rvalue):
+        print '    %s = _allocator.alloc<%s>(&%s);' % (lvalue, array.type, rvalue)
+
+    def visitPointer(self, pointer, lvalue, rvalue):
+        print '    %s = _allocator.alloc<%s>(&%s);' % (lvalue, pointer.type, rvalue)
+
+    def visitIntPointer(self, pointer, lvalue, rvalue):
+        pass
+
+    def visitObjPointer(self, pointer, lvalue, rvalue):
+        pass
+
+    def visitLinearPointer(self, pointer, lvalue, rvalue):
+        pass
+
+    def visitReference(self, reference, lvalue, rvalue):
+        self.visit(reference.type, lvalue, rvalue);
+
+    def visitHandle(self, handle, lvalue, rvalue):
+        pass
+
+    def visitBlob(self, blob, lvalue, rvalue):
+        pass
+
+    def visitString(self, string, lvalue, rvalue):
+        pass
+
+    def visitStruct(self, struct, lvalue, rvalue):
+        pass
+
+    def visitPolymorphic(self, polymorphic, lvalue, rvalue):
+        self.visit(polymorphic.defaultType, lvalue, rvalue)
+
+    def visitOpaque(self, opaque, lvalue, rvalue):
+        pass
+
+
+class ValueDeserializer(stdapi.Visitor):
+
+    def visitLiteral(self, literal, lvalue, rvalue):
+        print '    %s = (%s).to%s();' % (lvalue, rvalue, literal.kind)
+
+    def visitConst(self, const, lvalue, rvalue):
+        self.visit(const.type, lvalue, rvalue)
+
+    def visitAlias(self, alias, lvalue, rvalue):
+        self.visit(alias.type, lvalue, rvalue)
+    
+    def visitEnum(self, enum, lvalue, rvalue):
+        print '    %s = static_cast<%s>((%s).toSInt());' % (lvalue, enum, rvalue)
+
+    def visitBitmask(self, bitmask, lvalue, rvalue):
+        self.visit(bitmask.type, lvalue, rvalue)
+
+    def visitArray(self, array, lvalue, rvalue):
+
+        tmp = '_a_' + array.tag + '_' + str(self.seq)
+        self.seq += 1
+
+        print '    if (%s) {' % (lvalue,)
+        print '        const trace::Array *%s = dynamic_cast<const trace::Array *>(&%s);' % (tmp, rvalue)
+        length = '%s->values.size()' % (tmp,)
+        index = '_j' + array.tag
+        print '        for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)
+        try:
+            self.visit(array.type, '%s[%s]' % (lvalue, index), '*%s->values[%s]' % (tmp, index))
+        finally:
+            print '        }'
+            print '    }'
+    
+    def visitPointer(self, pointer, lvalue, rvalue):
+        tmp = '_a_' + pointer.tag + '_' + str(self.seq)
+        self.seq += 1
+
+        print '    if (%s) {' % (lvalue,)
+        print '        const trace::Array *%s = dynamic_cast<const trace::Array *>(&%s);' % (tmp, rvalue)
+        try:
+            self.visit(pointer.type, '%s[0]' % (lvalue,), '*%s->values[0]' % (tmp,))
+        finally:
+            print '    }'
+
+    def visitIntPointer(self, pointer, lvalue, rvalue):
+        print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, pointer, rvalue)
+
+    def visitObjPointer(self, pointer, lvalue, rvalue):
+        print '    %s = static_cast<%s>(retrace::toObjPointer(%s));' % (lvalue, pointer, rvalue)
+
+    def visitLinearPointer(self, pointer, lvalue, rvalue):
+        print '    %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, pointer, rvalue)
+
+    def visitReference(self, reference, lvalue, rvalue):
+        self.visit(reference.type, lvalue, rvalue);
+
+    def visitHandle(self, handle, lvalue, rvalue):
+        #OpaqueValueDeserializer().visit(handle.type, lvalue, rvalue);
+        self.visit(handle.type, lvalue, rvalue);
+        new_lvalue = lookupHandle(handle, lvalue)
+        print '    if (retrace::verbosity >= 2) {'
+        print '        std::cout << "%s " << size_t(%s) << " <- " << size_t(%s) << "\\n";' % (handle.name, lvalue, new_lvalue)
+        print '    }'
+        print '    %s = %s;' % (lvalue, new_lvalue)
+    
+    def visitBlob(self, blob, lvalue, rvalue):
+        print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, blob, rvalue)
+    
+    def visitString(self, string, lvalue, rvalue):
+        print '    %s = (%s)((%s).toString());' % (lvalue, string.expr, rvalue)
+
+    seq = 0
+
+    def visitStruct(self, struct, lvalue, rvalue):
+        tmp = '_s_' + struct.tag + '_' + str(self.seq)
+        self.seq += 1
+
+        print '    const trace::Struct *%s = dynamic_cast<const trace::Struct *>(&%s);' % (tmp, rvalue)
+        print '    assert(%s);' % (tmp)
+        for i in range(len(struct.members)):
+            member_type, member_name = struct.members[i]
+            self.visit(member_type, '%s.%s' % (lvalue, member_name), '*%s->members[%s]' % (tmp, i))
+
+    def visitPolymorphic(self, polymorphic, lvalue, rvalue):
+        self.visit(polymorphic.defaultType, lvalue, rvalue)
+    
+    def visitOpaque(self, opaque, lvalue, rvalue):
+        raise UnsupportedType
+
+
+class OpaqueValueDeserializer(ValueDeserializer):
+    '''Value extractor that also understands opaque values.
+
+    Normally opaque values can't be retraced, unless they are being extracted
+    in the context of handles.'''
+
+    def visitOpaque(self, opaque, lvalue, rvalue):
+        print '    %s = static_cast<%s>(retrace::toPointer(%s));' % (lvalue, opaque, rvalue)
+
+
+class SwizzledValueRegistrator(stdapi.Visitor):
+    '''Type visitor which will register (un)swizzled value pairs, to later be
+    swizzled.'''
+
+    def visitLiteral(self, literal, lvalue, rvalue):
+        pass
+
+    def visitAlias(self, alias, lvalue, rvalue):
+        self.visit(alias.type, lvalue, rvalue)
+    
+    def visitEnum(self, enum, lvalue, rvalue):
+        pass
+
+    def visitBitmask(self, bitmask, lvalue, rvalue):
+        pass
+
+    def visitArray(self, array, lvalue, rvalue):
+        print '    const trace::Array *_a%s = dynamic_cast<const trace::Array *>(&%s);' % (array.tag, rvalue)
+        print '    if (_a%s) {' % (array.tag)
+        length = '_a%s->values.size()' % array.tag
+        index = '_j' + array.tag
+        print '        for (size_t {i} = 0; {i} < {length}; ++{i}) {{'.format(i = index, length = length)
+        try:
+            self.visit(array.type, '%s[%s]' % (lvalue, index), '*_a%s->values[%s]' % (array.tag, index))
+        finally:
+            print '        }'
+            print '    }'
+    
+    def visitPointer(self, pointer, lvalue, rvalue):
+        print '    const trace::Array *_a%s = dynamic_cast<const trace::Array *>(&%s);' % (pointer.tag, rvalue)
+        print '    if (_a%s) {' % (pointer.tag)
+        try:
+            self.visit(pointer.type, '%s[0]' % (lvalue,), '*_a%s->values[0]' % (pointer.tag,))
+        finally:
+            print '    }'
+    
+    def visitIntPointer(self, pointer, lvalue, rvalue):
+        pass
+    
+    def visitObjPointer(self, pointer, lvalue, rvalue):
+        print r'    retrace::addObj(%s, %s);' % (rvalue, lvalue)
+    
+    def visitLinearPointer(self, pointer, lvalue, rvalue):
+        assert pointer.size is not None
+        if pointer.size is not None:
+            print r'    retrace::addRegion((%s).toUIntPtr(), %s, %s);' % (rvalue, lvalue, pointer.size)
+
+    def visitReference(self, reference, lvalue, rvalue):
+        pass
+    
+    def visitHandle(self, handle, lvalue, rvalue):
+        print '    %s _origResult;' % handle.type
+        OpaqueValueDeserializer().visit(handle.type, '_origResult', rvalue);
+        if handle.range is None:
+            rvalue = "_origResult"
+            entry = lookupHandle(handle, rvalue) 
+            print "    %s = %s;" % (entry, lvalue)
+            print '    if (retrace::verbosity >= 2) {'
+            print '        std::cout << "{handle.name} " << {rvalue} << " -> " << {lvalue} << "\\n";'.format(**locals())
+            print '    }'
+        else:
+            i = '_h' + handle.tag
+            lvalue = "%s + %s" % (lvalue, i)
+            rvalue = "_origResult + %s" % (i,)
+            entry = lookupHandle(handle, rvalue) 
+            print '    for ({handle.type} {i} = 0; {i} < {handle.range}; ++{i}) {{'.format(**locals())
+            print '        {entry} = {lvalue};'.format(**locals())
+            print '        if (retrace::verbosity >= 2) {'
+            print '            std::cout << "{handle.name} " << ({rvalue}) << " -> " << ({lvalue}) << "\\n";'.format(**locals())
+            print '        }'
+            print '    }'
+    
+    def visitBlob(self, blob, lvalue, rvalue):
+        pass
+    
+    def visitString(self, string, lvalue, rvalue):
+        pass
+
+    seq = 0
+
+    def visitStruct(self, struct, lvalue, rvalue):
+        tmp = '_s_' + struct.tag + '_' + str(self.seq)
+        self.seq += 1
+
+        print '    const trace::Struct *%s = dynamic_cast<const trace::Struct *>(&%s);' % (tmp, rvalue)
+        print '    assert(%s);' % (tmp,)
+        print '    (void)%s;' % (tmp,)
+        for i in range(len(struct.members)):
+            member_type, member_name = struct.members[i]
+            self.visit(member_type, '%s.%s' % (lvalue, member_name), '*%s->members[%s]' % (tmp, i))
+    
+    def visitPolymorphic(self, polymorphic, lvalue, rvalue):
+        self.visit(polymorphic.defaultType, lvalue, rvalue)
+    
+    def visitOpaque(self, opaque, lvalue, rvalue):
+        pass
+
+
+class Retracer:
+
+    def retraceFunction(self, function):
+        print 'static void retrace_%s(trace::Call &call) {' % function.name
+        self.retraceFunctionBody(function)
+        print '}'
+        print
+
+    def retraceInterfaceMethod(self, interface, method):
+        print 'static void retrace_%s__%s(trace::Call &call) {' % (interface.name, method.name)
+        self.retraceInterfaceMethodBody(interface, method)
+        print '}'
+        print
+
+    def retraceFunctionBody(self, function):
+        assert function.sideeffects
+
+        if function.type is not stdapi.Void:
+            self.checkOrigResult(function)
+
+        self.deserializeArgs(function)
+        
+        self.declareRet(function)
+        self.invokeFunction(function)
+
+        self.swizzleValues(function)
+
+    def retraceInterfaceMethodBody(self, interface, method):
+        assert method.sideeffects
+
+        if method.type is not stdapi.Void:
+            self.checkOrigResult(method)
+
+        self.deserializeThisPointer(interface)
+
+        self.deserializeArgs(method)
+        
+        self.declareRet(method)
+        self.invokeInterfaceMethod(interface, method)
+
+        self.swizzleValues(method)
+
+    def checkOrigResult(self, function):
+        '''Hook for checking the original result, to prevent succeeding now
+        where the original did not, which would cause diversion and potentially
+        unpredictable results.'''
+
+        assert function.type is not stdapi.Void
+
+        if str(function.type) == 'HRESULT':
+            print r'    if (call.ret && FAILED(call.ret->toSInt())) {'
+            print r'        return;'
+            print r'    }'
+
+    def deserializeThisPointer(self, interface):
+        print r'    %s *_this;' % (interface.name,)
+        print r'    _this = static_cast<%s *>(retrace::toObjPointer(call.arg(0)));' % (interface.name,)
+        print r'    if (!_this) {'
+        print r'        retrace::warning(call) << "NULL this pointer\n";'
+        print r'        return;'
+        print r'    }'
+
+    def deserializeArgs(self, function):
+        print '    retrace::ScopedAllocator _allocator;'
+        print '    (void)_allocator;'
+        success = True
+        for arg in function.args:
+            arg_type = arg.type.mutable()
+            print '    %s %s;' % (arg_type, arg.name)
+            rvalue = 'call.arg(%u)' % (arg.index,)
+            lvalue = arg.name
+            try:
+                self.extractArg(function, arg, arg_type, lvalue, rvalue)
+            except UnsupportedType:
+                success =  False
+                print '    memset(&%s, 0, sizeof %s); // FIXME' % (arg.name, arg.name)
+            print
+
+        if not success:
+            print '    if (1) {'
+            self.failFunction(function)
+            if function.name[-1].islower():
+                sys.stderr.write('warning: unsupported %s call\n' % function.name)
+            print '    }'
+
+    def swizzleValues(self, function):
+        for arg in function.args:
+            if arg.output:
+                arg_type = arg.type.mutable()
+                rvalue = 'call.arg(%u)' % (arg.index,)
+                lvalue = arg.name
+                try:
+                    self.regiterSwizzledValue(arg_type, lvalue, rvalue)
+                except UnsupportedType:
+                    print '    // XXX: %s' % arg.name
+        if function.type is not stdapi.Void:
+            rvalue = '*call.ret'
+            lvalue = '_result'
+            try:
+                self.regiterSwizzledValue(function.type, lvalue, rvalue)
+            except UnsupportedType:
+                raise
+                print '    // XXX: result'
+
+    def failFunction(self, function):
+        print '    if (retrace::verbosity >= 0) {'
+        print '        retrace::unsupported(call);'
+        print '    }'
+        print '    return;'
+
+    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
+        ValueAllocator().visit(arg_type, lvalue, rvalue)
+        if arg.input:
+            ValueDeserializer().visit(arg_type, lvalue, rvalue)
+    
+    def extractOpaqueArg(self, function, arg, arg_type, lvalue, rvalue):
+        try:
+            ValueAllocator().visit(arg_type, lvalue, rvalue)
+        except UnsupportedType:
+            pass
+        OpaqueValueDeserializer().visit(arg_type, lvalue, rvalue)
+
+    def regiterSwizzledValue(self, type, lvalue, rvalue):
+        visitor = SwizzledValueRegistrator()
+        visitor.visit(type, lvalue, rvalue)
+
+    def declareRet(self, function):
+        if function.type is not stdapi.Void:
+            print '    %s _result;' % (function.type)
+
+    def invokeFunction(self, function):
+        arg_names = ", ".join(function.argNames())
+        if function.type is not stdapi.Void:
+            print '    _result = %s(%s);' % (function.name, arg_names)
+            print '    (void)_result;'
+        else:
+            print '    %s(%s);' % (function.name, arg_names)
+
+    def invokeInterfaceMethod(self, interface, method):
+        # On release our reference when we reach Release() == 0 call in the
+        # trace.
+        if method.name == 'Release':
+            print '    if (call.ret->toUInt()) {'
+            print '        return;'
+            print '    }'
+            print '    retrace::delObj(call.arg(0));'
+
+        arg_names = ", ".join(method.argNames())
+        if method.type is not stdapi.Void:
+            print '    _result = _this->%s(%s);' % (method.name, arg_names)
+            print '    (void)_result;'
+        else:
+            print '    _this->%s(%s);' % (method.name, arg_names)
+
+    def filterFunction(self, function):
+        return True
+
+    table_name = 'retrace::callbacks'
+
+    def retraceApi(self, api):
+
+        print '#include "os_time.hpp"'
+        print '#include "trace_parser.hpp"'
+        print '#include "retrace.hpp"'
+        print '#include "retrace_swizzle.hpp"'
+        print
+
+        types = api.getAllTypes()
+        handles = [type for type in types if isinstance(type, stdapi.Handle)]
+        handle_names = set()
+        for handle in handles:
+            if handle.name not in handle_names:
+                if handle.key is None:
+                    print 'static retrace::map<%s> _%s_map;' % (handle.type, handle.name)
+                else:
+                    key_name, key_type = handle.key
+                    print 'static std::map<%s, retrace::map<%s> > _%s_map;' % (key_type, handle.type, handle.name)
+                handle_names.add(handle.name)
+        print
+
+        functions = filter(self.filterFunction, api.functions)
+        for function in functions:
+            if function.sideeffects and not function.internal:
+                self.retraceFunction(function)
+        interfaces = api.getAllInterfaces()
+        for interface in interfaces:
+            for method in interface.iterMethods():
+                if method.sideeffects and not method.internal:
+                    self.retraceInterfaceMethod(interface, method)
+
+        print 'const retrace::Entry %s[] = {' % self.table_name
+        for function in functions:
+            if not function.internal:
+                if function.sideeffects:
+                    print '    {"%s", &retrace_%s},' % (function.name, function.name)
+                else:
+                    print '    {"%s", &retrace::ignore},' % (function.name,)
+        for interface in interfaces:
+            for method in interface.iterMethods():                
+                if method.sideeffects:
+                    print '    {"%s::%s", &retrace_%s__%s},' % (interface.name, method.name, interface.name, method.name)
+                else:
+                    print '    {"%s::%s", &retrace::ignore},' % (interface.name, method.name)
+        print '    {NULL, NULL}'
+        print '};'
+        print
+
diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp
new file mode 100644 (file)
index 0000000..9386a61
--- /dev/null
@@ -0,0 +1,320 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <string.h>
+#include <iostream>
+
+#include "os_binary.hpp"
+#include "os_time.hpp"
+#include "image.hpp"
+#include "trace_callset.hpp"
+#include "trace_dump.hpp"
+#include "retrace.hpp"
+
+
+static bool waitOnFinish = false;
+
+static const char *comparePrefix = NULL;
+static const char *snapshotPrefix = NULL;
+static trace::CallSet snapshotFrequency;
+static trace::CallSet compareFrequency;
+
+static unsigned dumpStateCallNo = ~0;
+
+
+namespace retrace {
+
+
+trace::Parser parser;
+trace::Profiler profiler;
+
+
+int verbosity = 0;
+bool debug = true;
+bool dumpingState = false;
+
+bool doubleBuffer = true;
+bool coreProfile = false;
+
+bool profiling = false;
+bool profilingGpuTimes = false;
+bool profilingCpuTimes = false;
+bool profilingPixelsDrawn = false;
+
+unsigned frameNo = 0;
+unsigned callNo = 0;
+
+
+void
+frameComplete(trace::Call &call) {
+    ++frameNo;
+}
+
+
+static void
+takeSnapshot(unsigned call_no) {
+    assert(snapshotPrefix || comparePrefix);
+
+    image::Image *ref = NULL;
+
+    if (comparePrefix) {
+        os::String filename = os::String::format("%s%010u.png", comparePrefix, call_no);
+        ref = image::readPNG(filename);
+        if (!ref) {
+            return;
+        }
+        if (retrace::verbosity >= 0) {
+            std::cout << "Read " << filename << "\n";
+        }
+    }
+
+    image::Image *src = getSnapshot();
+    if (!src) {
+        return;
+    }
+
+    if (snapshotPrefix) {
+        if (snapshotPrefix[0] == '-' && snapshotPrefix[1] == 0) {
+            char comment[21];
+            snprintf(comment, sizeof comment, "%u", call_no);
+            src->writePNM(std::cout, comment);
+        } else {
+            os::String filename = os::String::format("%s%010u.png", snapshotPrefix, call_no);
+            if (src->writePNG(filename) && retrace::verbosity >= 0) {
+                std::cout << "Wrote " << filename << "\n";
+            }
+        }
+    }
+
+    if (ref) {
+        std::cout << "Snapshot " << call_no << " average precision of " << src->compare(*ref) << " bits\n";
+        delete ref;
+    }
+
+    delete src;
+
+    return;
+}
+
+
+static void
+mainLoop() {
+    retrace::Retracer retracer;
+
+    addCallbacks(retracer);
+
+    long long startTime = 0; 
+    frameNo = 0;
+
+    startTime = os::getTime();
+    trace::Call *call;
+
+    while ((call = retrace::parser.parse_call())) {
+        bool swapRenderTarget = call->flags & trace::CALL_FLAG_SWAP_RENDERTARGET;
+        bool doSnapshot =
+            snapshotFrequency.contains(*call) ||
+            compareFrequency.contains(*call)
+        ;
+
+        // For calls which cause rendertargets to be swaped, we take the
+        // snapshot _before_ swapping the rendertargets.
+        if (doSnapshot && swapRenderTarget) {
+            if (call->flags & trace::CALL_FLAG_END_FRAME) {
+                // For swapbuffers/presents we still use this call number,
+                // spite not have been executed yet.
+                takeSnapshot(call->no);
+            } else {
+                // Whereas for ordinate fbo/rendertarget changes we use the
+                // previous call's number.
+                takeSnapshot(call->no - 1);
+            }
+        }
+
+        callNo = call->no;
+        retracer.retrace(*call);
+
+        if (doSnapshot && !swapRenderTarget) {
+            takeSnapshot(call->no);
+        }
+
+        if (call->no >= dumpStateCallNo &&
+            dumpState(std::cout)) {
+            exit(0);
+        }
+
+        delete call;
+    }
+
+    // Reached the end of trace
+    flushRendering();
+
+    long long endTime = os::getTime();
+    float timeInterval = (endTime - startTime) * (1.0 / os::timeFrequency);
+
+    if ((retrace::verbosity >= -1) || (retrace::profiling)) {
+        std::cout << 
+            "Rendered " << frameNo << " frames"
+            " in " <<  timeInterval << " secs,"
+            " average of " << (frameNo/timeInterval) << " fps\n";
+    }
+
+    if (waitOnFinish) {
+        waitForInput();
+    } else {
+        return;
+    }
+}
+
+
+} /* namespace retrace */
+
+
+static void
+usage(const char *argv0) {
+    std::cout << 
+        "Usage: " << argv0 << " [OPTION] TRACE [...]\n"
+        "Replay TRACE.\n"
+        "\n"
+        "  -b           benchmark mode (no error checking or warning messages)\n"
+        "  -pcpu        cpu profiling (cpu times per call)\n"
+        "  -pgpu        gpu profiling (gpu times per draw call)\n"
+        "  -ppd         pixels drawn profiling (pixels drawn per draw call)\n"
+        "  -c PREFIX    compare against snapshots\n"
+        "  -C CALLSET   calls to compare (default is every frame)\n"
+        "  -core        use core profile\n"
+        "  -db          use a double buffer visual (default)\n"
+        "  -sb          use a single buffer visual\n"
+        "  -s PREFIX    take snapshots; `-` for PNM stdout output\n"
+        "  -S CALLSET   calls to snapshot (default is every frame)\n"
+        "  -v           increase output verbosity\n"
+        "  -D CALLNO    dump state at specific call no\n"
+        "  -w           waitOnFinish on final frame\n";
+}
+
+
+extern "C"
+int main(int argc, char **argv)
+{
+    using namespace retrace;
+
+    assert(compareFrequency.empty());
+    assert(snapshotFrequency.empty());
+
+    int i;
+    for (i = 1; i < argc; ++i) {
+        const char *arg = argv[i];
+
+        if (arg[0] != '-') {
+            break;
+        }
+
+        if (!strcmp(arg, "--")) {
+            break;
+        } else if (!strcmp(arg, "-b")) {
+            retrace::debug = false;
+            retrace::verbosity = -1;
+        } else if (!strcmp(arg, "-c")) {
+            comparePrefix = argv[++i];
+            if (compareFrequency.empty()) {
+                compareFrequency = trace::CallSet(trace::FREQUENCY_FRAME);
+            }
+        } else if (!strcmp(arg, "-C")) {
+            compareFrequency = trace::CallSet(argv[++i]);
+            if (comparePrefix == NULL) {
+                comparePrefix = "";
+            }
+        } else if (!strcmp(arg, "-D")) {
+            dumpStateCallNo = atoi(argv[++i]);
+            dumpingState = true;
+            retrace::verbosity = -2;
+        } else if (!strcmp(arg, "-core")) {
+            retrace::coreProfile = true;
+        } else if (!strcmp(arg, "-db")) {
+            retrace::doubleBuffer = true;
+        } else if (!strcmp(arg, "-sb")) {
+            retrace::doubleBuffer = false;
+        } else if (!strcmp(arg, "--help")) {
+            usage(argv[0]);
+            return 0;
+        } else if (!strcmp(arg, "-s")) {
+            snapshotPrefix = argv[++i];
+            if (snapshotFrequency.empty()) {
+                snapshotFrequency = trace::CallSet(trace::FREQUENCY_FRAME);
+            }
+            if (snapshotPrefix[0] == '-' && snapshotPrefix[1] == 0) {
+                os::setBinaryMode(stdout);
+                retrace::verbosity = -2;
+            }
+        } else if (!strcmp(arg, "-S")) {
+            snapshotFrequency = trace::CallSet(argv[++i]);
+            if (snapshotPrefix == NULL) {
+                snapshotPrefix = "";
+            }
+        } else if (!strcmp(arg, "-v")) {
+            ++retrace::verbosity;
+        } else if (!strcmp(arg, "-w")) {
+            waitOnFinish = true;
+        } else if (arg[1] == 'p') {
+            retrace::debug = false;
+            retrace::profiling = true;
+            retrace::verbosity = -1;
+
+            if (!strcmp(arg, "-pcpu")) {
+                retrace::profilingCpuTimes = true;
+            } else if (!strcmp(arg, "-pgpu")) {
+                retrace::profilingGpuTimes = true;
+            } else if (!strcmp(arg, "-ppd")) {
+                retrace::profilingPixelsDrawn = true;
+            }
+        } else {
+            std::cerr << "error: unknown option " << arg << "\n";
+            usage(argv[0]);
+            return 1;
+        }
+    }
+
+    retrace::setUp();
+    if (retrace::profiling) {
+        retrace::profiler.setup(retrace::profilingCpuTimes, retrace::profilingGpuTimes, retrace::profilingPixelsDrawn);
+    }
+
+    for ( ; i < argc; ++i) {
+        if (!retrace::parser.open(argv[i])) {
+            std::cerr << "error: failed to open " << argv[i] << "\n";
+            return 1;
+        }
+
+        retrace::mainLoop();
+
+        retrace::parser.close();
+    }
+
+    // XXX: X often hangs on XCloseDisplay
+    //retrace::cleanUp();
+
+    return 0;
+}
+
diff --git a/retrace/retrace_stdc.cpp b/retrace/retrace_stdc.cpp
new file mode 100644 (file)
index 0000000..dd4d0f4
--- /dev/null
@@ -0,0 +1,71 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <assert.h>
+#include <string.h>
+
+#include <iostream>
+
+#include "retrace.hpp"
+#include "retrace_swizzle.hpp"
+
+
+static void retrace_malloc(trace::Call &call) {
+    size_t size = call.arg(0).toUInt();
+    unsigned long long address = call.ret->toUIntPtr();
+
+    if (!address) {
+        return;
+    }
+
+    void *buffer = malloc(size);
+    if (!buffer) {
+        std::cerr << "error: failed to allocate " << size << " bytes.";
+        return;
+    }
+
+    retrace::addRegion(address, buffer, size);
+}
+
+
+static void retrace_memcpy(trace::Call &call) {
+    void * dest = retrace::toPointer(call.arg(0));
+    void * src  = retrace::toPointer(call.arg(1));
+    size_t n    = call.arg(2).toUInt();
+
+    if (!dest || !src || !n) {
+        return;
+    }
+
+    memcpy(dest, src, n);
+}
+
+
+const retrace::Entry retrace::stdc_callbacks[] = {
+    {"malloc", &retrace_malloc},
+    {"memcpy", &retrace_memcpy},
+    {NULL, NULL}
+};
diff --git a/retrace/retrace_swizzle.cpp b/retrace/retrace_swizzle.cpp
new file mode 100644 (file)
index 0000000..52d1d74
--- /dev/null
@@ -0,0 +1,274 @@
+/**************************************************************************
+ *
+ * Copyright 2011-2012 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <assert.h>
+
+#include <string.h>
+
+#include "retrace.hpp"
+#include "retrace_swizzle.hpp"
+
+
+namespace retrace {
+
+
+struct Region
+{
+    void *buffer;
+    unsigned long long size;
+};
+
+typedef std::map<unsigned long long, Region> RegionMap;
+static RegionMap regionMap;
+
+
+static inline bool
+contains(RegionMap::iterator &it, unsigned long long address) {
+    return it->first <= address && (it->first + it->second.size) > address;
+}
+
+
+static inline bool
+intersects(RegionMap::iterator &it, unsigned long long start, unsigned long long size) {
+    unsigned long it_start = it->first;
+    unsigned long it_stop  = it->first + it->second.size;
+    unsigned long stop = start + size;
+    return it_start < stop && start < it_stop;
+}
+
+
+// Iterator to the first region that contains the address, or the first after
+static RegionMap::iterator
+lowerBound(unsigned long long address) {
+    RegionMap::iterator it = regionMap.lower_bound(address);
+
+    while (it != regionMap.begin()) {
+        RegionMap::iterator pred = it;
+        --pred;
+        if (contains(pred, address)) {
+            it = pred;
+        } else {
+            break;
+        }
+    }
+
+    return it;
+}
+
+// Iterator to the first region that starts after the address
+static RegionMap::iterator
+upperBound(unsigned long long address) {
+    RegionMap::iterator it = regionMap.upper_bound(address);
+
+    return it;
+}
+
+void
+addRegion(unsigned long long address, void *buffer, unsigned long long size)
+{
+    if (retrace::verbosity >= 2) {
+        std::cout
+            << "region "
+            << std::hex
+            << "0x" << address << "-0x" << (address + size)
+            << " -> "
+            << "0x" << (uintptr_t)buffer << "-0x" << ((uintptr_t)buffer + size)
+            << std::dec
+            << "\n";
+    }
+
+    if (!address) {
+        // Ignore NULL pointer
+        assert(!buffer);
+        return;
+    }
+
+#ifndef NDEBUG
+    RegionMap::iterator start = lowerBound(address);
+    RegionMap::iterator stop = upperBound(address + size);
+    if (0) {
+        // Forget all regions that intersect this new one.
+        regionMap.erase(start, stop);
+    } else {
+        for (RegionMap::iterator it = start; it != stop; ++it) {
+            std::cerr << std::hex << "warning: "
+                "region 0x" << address << "-0x" << (address + size) << " "
+                "intersects existing region 0x" << it->first << "-0x" << (it->first + it->second.size) << "\n" << std::dec;
+            assert(intersects(it, address, size));
+        }
+    }
+#endif
+
+    assert(buffer);
+
+    Region region;
+    region.buffer = buffer;
+    region.size = size;
+
+    regionMap[address] = region;
+}
+
+static RegionMap::iterator
+lookupRegion(unsigned long long address) {
+    RegionMap::iterator it = regionMap.lower_bound(address);
+
+    if (it == regionMap.end() ||
+        it->first > address) {
+        if (it == regionMap.begin()) {
+            return regionMap.end();
+        } else {
+            --it;
+        }
+    }
+
+    assert(contains(it, address));
+    return it;
+}
+
+void
+delRegion(unsigned long long address) {
+    RegionMap::iterator it = lookupRegion(address);
+    if (it != regionMap.end()) {
+        regionMap.erase(it);
+    } else {
+        assert(0);
+    }
+}
+
+
+void
+delRegionByPointer(void *ptr) {
+    for (RegionMap::iterator it = regionMap.begin(); it != regionMap.end(); ++it) {
+        if (it->second.buffer == ptr) {
+            regionMap.erase(it);
+            return;
+        }
+    }
+    assert(0);
+}
+
+void *
+lookupAddress(unsigned long long address) {
+    RegionMap::iterator it = lookupRegion(address);
+    if (it != regionMap.end()) {
+        unsigned long long offset = address - it->first;
+        assert(offset < it->second.size);
+        void *addr = (char *)it->second.buffer + offset;
+
+        if (retrace::verbosity >= 2) {
+            std::cout
+                << "region "
+                << std::hex
+                << "0x" << address
+                << " <- "
+                << "0x" << (uintptr_t)addr
+                << std::dec
+                << "\n";
+        }
+
+        return addr;
+    }
+
+    if (retrace::debug && address >= 64 * 1024 * 1024) {
+        /* Likely not an offset, but an address that should had been swizzled */
+        std::cerr << "warning: passing high address 0x" << std::hex << address << std::dec << " as uintptr_t\n";
+    }
+
+    return (void *)(uintptr_t)address;
+}
+
+
+class Translator : protected trace::Visitor
+{
+protected:
+    bool bind;
+
+    void *result;
+
+    void visit(trace::Null *) {
+        result = NULL;
+    }
+
+    void visit(trace::Blob *blob) {
+        result = blob->toPointer(bind);
+    }
+
+    void visit(trace::Pointer *p) {
+        result = lookupAddress(p->value);
+    }
+
+public:
+    Translator(bool _bind) :
+        bind(_bind),
+        result(NULL)
+    {}
+
+    void * operator() (trace::Value *node) {
+        _visit(node);
+        return result;
+    }
+};
+
+
+void *
+toPointer(trace::Value &value, bool bind) {
+    return Translator(bind) (&value);
+}
+
+
+
+static std::map<unsigned long long, void *> _obj_map;
+
+void
+addObj(trace::Value &value, void *obj) {
+    unsigned long long address = value.toUIntPtr();
+    _obj_map[address] = obj;
+    
+    if (retrace::verbosity >= 2) {
+        std::cout << std::hex << "obj 0x" << address << " -> 0x" << size_t(obj) << std::dec << "\n";
+    }
+}
+
+void
+delObj(trace::Value &value) {
+    unsigned long long address = value.toUIntPtr();
+    _obj_map.erase(address);
+}
+
+void *
+toObjPointer(trace::Value &value) {
+    unsigned long long address = value.toUIntPtr();
+    void *obj = address ? _obj_map[address] : NULL;
+
+    if (retrace::verbosity >= 2) {
+        std::cout << std::hex << "obj 0x" << address << " <- 0x" << size_t(obj) << std::dec << "\n";
+    }
+
+    return obj;
+}
+
+
+} /* retrace */
diff --git a/retrace/retrace_swizzle.hpp b/retrace/retrace_swizzle.hpp
new file mode 100644 (file)
index 0000000..66c2962
--- /dev/null
@@ -0,0 +1,102 @@
+/**************************************************************************
+ *
+ * Copyright 2011-2012 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _RETRACE_SWIZZLE_HPP_
+#define _RETRACE_SWIZZLE_HPP_
+
+
+#include <map>
+
+#include "trace_model.hpp"
+
+
+namespace retrace {
+
+
+/**
+ * Handle map.
+ *
+ * It is just like a regular std::map<T, T> container, but lookups of missing
+ * keys return the key instead of default constructor.
+ *
+ * This is necessary for several GL named objects, where one can either request
+ * the implementation to generate an unique name, or pick a value never used
+ * before.
+ *
+ * XXX: In some cases, instead of returning the key, it would make more sense
+ * to return an unused data value (e.g., container count).
+ */
+template <class T>
+class map
+{
+private:
+    typedef std::map<T, T> base_type;
+    base_type base;
+
+public:
+
+    T & operator[] (const T &key) {
+        typename base_type::iterator it;
+        it = base.find(key);
+        if (it == base.end()) {
+            return (base[key] = key);
+        }
+        return it->second;
+    }
+    
+    const T & operator[] (const T &key) const {
+        typename base_type::const_iterator it;
+        it = base.find(key);
+        if (it == base.end()) {
+            return (base[key] = key);
+        }
+        return it->second;
+    }
+};
+
+
+void
+addRegion(unsigned long long address, void *buffer, unsigned long long size);
+
+void
+delRegionByPointer(void *ptr);
+
+void *
+toPointer(trace::Value &value, bool bind = false);
+
+
+void
+addObj(trace::Value &value, void *obj);
+
+void
+delObj(trace::Value &value);
+
+void *
+toObjPointer(trace::Value &value);
+
+
+} /* namespace retrace */
+
+#endif /* _RETRACE_SWIZZLE_HPP_ */
diff --git a/retrace_stdc.cpp b/retrace_stdc.cpp
deleted file mode 100644 (file)
index 03c3865..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2011 Jose Fonseca
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <assert.h>
-
-#include <string.h>
-
-#include "glproc.hpp"
-
-
-
-#include "trace_parser.hpp"
-#include "retrace.hpp"
-
-
-namespace retrace {
-
-struct Region
-{
-    void *buffer;
-    unsigned long long size;
-};
-
-typedef std::map<unsigned long long, Region> RegionMap;
-static RegionMap regionMap;
-
-// Iterator to the first region that contains the address
-static RegionMap::iterator
-lowerBound(unsigned long long address) {
-    RegionMap::iterator it = regionMap.lower_bound(address);
-
-    while (it != regionMap.begin() &&
-           it != regionMap.end() &&
-           it->first + it->second. size > address) {
-        --it;
-    }
-
-    return it;
-}
-
-// Iterator to the first region that not contains the address
-static RegionMap::iterator
-upperBound(unsigned long long address) {
-    RegionMap::iterator it = regionMap.upper_bound(address);
-
-    while (it != regionMap.end() &&
-           it->first + it->second.size > address) {
-        ++it;
-    }
-
-    return it;
-}
-
-void
-addRegion(unsigned long long address, void *buffer, unsigned long long size)
-{
-    if (!address) {
-        // Ignore NULL pointer
-        assert(!buffer);
-        return;
-    }
-
-    // Forget all regions that intersect this new one.
-    if (0) {
-        RegionMap::iterator start = lowerBound(address);
-        if (start != regionMap.end()) {
-            RegionMap::iterator stop = upperBound(address + size);
-            regionMap.erase(start, stop);
-        }
-    }
-
-    assert(buffer);
-
-    Region region;
-    region.buffer = buffer;
-    region.size = size;
-
-    regionMap[address] = region;
-}
-
-static RegionMap::iterator
-lookupRegion(unsigned long long address) {
-    RegionMap::iterator it = regionMap.lower_bound(address);
-
-    if (it == regionMap.end() ||
-        it->first > address) {
-        if (it == regionMap.begin()) {
-            return regionMap.end();
-        } else {
-            --it;
-        }
-    }
-
-    assert(it->first <= address);
-    assert(it->first + it->second.size >= address);
-    return it;
-}
-
-void
-delRegion(unsigned long long address) {
-    RegionMap::iterator it = lookupRegion(address);
-    if (it != regionMap.end()) {
-        regionMap.erase(it);
-    } else {
-        assert(0);
-    }
-}
-
-
-void
-delRegionByPointer(void *ptr) {
-    RegionMap::iterator it = regionMap.begin();
-    while (it != regionMap.end()) {
-        if (it->second.buffer == ptr) {
-            regionMap.erase(it);
-            return;
-        }
-    }
-    assert(0);
-}
-
-void *
-lookupAddress(unsigned long long address) {
-    RegionMap::iterator it = lookupRegion(address);
-    if (it != regionMap.end()) {
-        unsigned long long offset = address - it->first;
-        assert(offset < it->second.size);
-        return (char *)it->second.buffer + offset;
-    }
-
-    if (address >= 0x00400000) {
-        std::cerr << "warning: could not translate address 0x" << std::hex << address << std::dec << "\n";
-    }
-
-    return (void *)(uintptr_t)address;
-}
-
-
-class Translator : protected trace::Visitor
-{
-protected:
-    bool bind;
-
-    void *result;
-
-    void visit(trace::Null *) {
-        result = NULL;
-    }
-
-    void visit(trace::Blob *blob) {
-        result = blob->toPointer(bind);
-    }
-
-    void visit(trace::Pointer *p) {
-        result = lookupAddress(p->value);
-    }
-
-public:
-    Translator(bool _bind) :
-        bind(_bind),
-        result(NULL)
-    {}
-
-    void * operator() (trace::Value *node) {
-        _visit(node);
-        return result;
-    }
-};
-
-
-void *
-toPointer(trace::Value &value, bool bind) {
-    return Translator(bind) (&value);
-}
-
-
-static void retrace_malloc(trace::Call &call) {
-    size_t size = call.arg(0).toUInt();
-    unsigned long long address = call.ret->toUIntPtr();
-
-    if (!address) {
-        return;
-    }
-
-    void *buffer = malloc(size);
-    if (!buffer) {
-        std::cerr << "error: failed to allocated " << size << " bytes.";
-        return;
-    }
-
-    addRegion(address, buffer, size);
-}
-
-
-static void retrace_memcpy(trace::Call &call) {
-    void * dest = toPointer(call.arg(0));
-    void * src  = toPointer(call.arg(1));
-    size_t n    = call.arg(2).toUInt();
-
-    if (!dest || !src || !n) {
-        return;
-    }
-
-    memcpy(dest, src, n);
-}
-
-
-const retrace::Entry stdc_callbacks[] = {
-    {"malloc", &retrace_malloc},
-    {"memcpy", &retrace_memcpy},
-    {NULL, NULL}
-};
-
-
-} /* retrace */
index 986bd1dede68f87fa1f8798d02c96294e2b0139e..9c12e821e77cc62bd823dd3e16e47f1617da7912 100644 (file)
@@ -1,6 +1,6 @@
 ##########################################################################
 #
-# Copyright 2011 Jose Fonseca
+# Copyright 2011-2012 Jose Fonseca
 # Copyright 2008-2009 VMware, Inc.
 # All Rights Reserved.
 #
@@ -25,8 +25,9 @@
 ##########################################################################/
 
 
-import sys
 import platform
+import subprocess
+import sys
 
 
 class PlainHighlighter:
@@ -41,7 +42,7 @@ class PlainHighlighter:
     cyan = None
     white = None
 
-    def __init__(self, stream):
+    def __init__(self, stream = sys.stdout):
         self.stream = stream
 
     def write(self, text):
@@ -56,7 +57,10 @@ class PlainHighlighter:
     def color(self, color):
         pass
 
-    def bold(self):
+    def bold(self, enable = True):
+        pass
+
+    def strike(self):
         pass
 
     def italic(self):
@@ -72,7 +76,6 @@ class AnsiHighlighter(PlainHighlighter):
     _csi = '\33['
 
     _normal = '0m'
-    _bold = '1m'
     _italic = '3m'
 
     black = 0
@@ -84,13 +87,11 @@ class AnsiHighlighter(PlainHighlighter):
     cyan = 6
     white = 7
 
-    def __init__(self, stream):
+    def __init__(self, stream = sys.stdout):
         PlainHighlighter.__init__(self, stream)
-        self.isatty = stream.isatty()
 
     def _escape(self, code):
-        if self.isatty:
-            self.stream.write(self._csi + code)
+        self.stream.write(self._csi + code)
 
     def normal(self):
         self._escape(self._normal)
@@ -98,8 +99,14 @@ class AnsiHighlighter(PlainHighlighter):
     def color(self, color):
         self._escape(str(30 + color) + 'm')
 
-    def bold(self):
-        self._escape(self._bold)
+    def bold(self, enable = True):
+        if enable:
+            self._escape('1m')
+        else:
+            self._escape('21m')
+
+    def strike(self):
+        self._escape('9m')
 
     def italic(self):
         self._escape(self._italic)
@@ -133,7 +140,6 @@ class WindowsConsoleHighlighter(PlainHighlighter):
     COMMON_LVB_UNDERSCORE = 0x8000
 
     _normal = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED
-    _bold   = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY
     _italic = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED
 
     black   = 0
@@ -142,7 +148,7 @@ class WindowsConsoleHighlighter(PlainHighlighter):
     blue    = FOREGROUND_BLUE                                    
     white   = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED
 
-    def __init__(self, stream):
+    def __init__(self, stream = sys.stdout):
         PlainHighlighter.__init__(self, stream)
 
         if stream is sys.stdin:
@@ -158,12 +164,12 @@ class WindowsConsoleHighlighter(PlainHighlighter):
             import ctypes
             self._handle = ctypes.windll.kernel32.GetStdHandle(nStdHandle)
         else:
-            self._handle = INVALID_HANDLE_VALUE
+            self._handle = self.INVALID_HANDLE_VALUE
 
         self._attribute = self.white
 
     def _setAttribute(self, attr):
-        if self._handle != INVALID_HANDLE_VALUE:
+        if self._handle != self.INVALID_HANDLE_VALUE:
             import ctypes
             ctypes.windll.kernel32.SetConsoleTextAttribute(self._handle, attr)
         self._attribute = attr
@@ -172,23 +178,54 @@ class WindowsConsoleHighlighter(PlainHighlighter):
         self._setAttribute(self._normal)
 
     def color(self, color):
-        intensity = self._attribute & FOREGROUND_INTENSITY
+        intensity = self._attribute & self.FOREGROUND_INTENSITY
         self._setAttribute(color | intensity)
 
-    def bold(self):
-        self._setAttribute(self._attribute | FOREGROUND_INTENSITY)
+    def bold(self, enable = True):
+        if enable:
+            attribute = self._attribute | self.FOREGROUND_INTENSITY
+        else:
+            attribute = self._attribute & ~self.FOREGROUND_INTENSITY
+        self._setAttribute(attribute)
 
     def italic(self):
         pass
 
 
-def Highlighter(stream = sys.stdout):
-    if platform.system() == 'Windows':
-        return WindowsConsoleHighlighter(stream)
+if platform.system() == 'Windows':
+    ColorHighlighter = WindowsConsoleHighlighter
+else:
+    ColorHighlighter = AnsiHighlighter
+
+
+def AutoHighlighter(stream = sys.stdout):
+    if stream.isatty():
+        return ColorHighlighter(stream)
     else:
-        return AnsiHighlighter(stream)
+        return PlainHighlighter(stream)
+
+
+class _LessHighlighter(AnsiHighlighter):
+
+    def __init__(self, less):
+        AnsiHighlighter.__init__(self, less.stdin)
+        self.less = less
 
+    def __del__(self):
+        self.less.stdin.close()
+        self.less.wait()
+
+
+def LessHighlighter():
+    if sys.stdout.isatty():
+        try:
+            less = subprocess.Popen(
+                args = ['less', '-FRXn'],
+                stdin = subprocess.PIPE
+            )
+        except OSError:
+            return ColorHighlighter()
+        else:
+            return _LessHighlighter(less)
+    return PlainHighlighter(sys.stdout)
 
-__all__ = [
-    'Highlighter',
-]
diff --git a/scripts/profileshader.py b/scripts/profileshader.py
new file mode 100755 (executable)
index 0000000..d31130e
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+##########################################################################
+#
+# Copyright 2012 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+import sys
+
+
+def process(stream):
+    times = {}
+
+    # call no gpu_start gpu_dura cpu_start cpu_dura pixels program name
+
+    for line in stream:
+        words = line.split(' ')
+
+        if line.startswith('#'):
+            continue
+
+        if words[0] == 'call':
+            id = long(words[1])
+            duration = long(words[3])
+            shader = long(words[7])
+            func = words[8]
+
+            if times.has_key(shader):
+                times[shader]['draws'] += 1
+                times[shader]['duration'] += duration
+
+                if duration > times[shader]['longestDuration']:
+                    times[shader]['longest'] = id
+                    times[shader]['longestDuration'] = duration
+            else:
+                times[shader] = {'draws': 1, 'duration': duration, 'longest': id, 'longestDuration': duration}
+
+    times = sorted(times.items(), key=lambda x: x[1]['duration'], reverse=True)
+
+    print '+------------+--------------+--------------------+--------------+-------------+'
+    print '| Shader[id] |   Draws [#]  |   Duration [ns]  v | Per Call[ns] | Longest[id] |'
+    print '+------------+--------------+--------------------+--------------+-------------+'
+
+    for shader in times:
+        id = str(shader[0]).rjust(10)
+        draw = str(shader[1]['draws']).rjust(12)
+        dura = str(shader[1]['duration']).rjust(18)
+        perCall = str(shader[1]['duration'] / shader[1]['draws']).rjust(12)
+        longest = str(shader[1]['longest']).rjust(11)
+        print "| %s | %s | %s | %s | %s |" % (id, draw, dura, perCall, longest)
+
+    print '+------------+--------------+--------------------+--------------+-------------+'
+
+
+def main():
+    if len(sys.argv) > 1:
+        for arg in sys.argv[1:]:
+            process(open(arg, 'rt'))
+    else:
+        process(sys.stdin)
+
+
+if __name__ == '__main__':
+    main()
index 34959753fc0acf9b137e07394a6e60e621028e9d..8a0837a82bf6a17d9e973c62db70cdbaf6b9860c 100755 (executable)
@@ -37,7 +37,7 @@ import sys
 from PIL import Image
 
 from snapdiff import Comparer
-from highlight import Highlighter
+from highlight import AutoHighlighter
 import jsondiff
 
 
@@ -80,16 +80,16 @@ class Setup:
         p.wait()
         return state.get('parameters', {})
 
-    def diff_state(self, ref_call_no, src_call_no):
+    def diff_state(self, ref_call_no, src_call_no, stream):
         '''Compare the state between two calls.'''
 
         ref_state = self.dump_state(ref_call_no)
         src_state = self.dump_state(src_call_no)
 
-        sys.stdout.flush()
-        differ = jsondiff.Differ(sys.stdout)
+        stream.flush()
+        differ = jsondiff.Differ(stream)
         differ.visit(ref_state, src_state)
-        sys.stdout.write('\n')
+        stream.write('\n')
 
 
 def read_pnm(stream):
@@ -159,6 +159,10 @@ def main():
         '-S', '--snapshot-frequency', metavar='CALLSET',
         type="string", dest="snapshot_frequency", default='draw',
         help="calls to compare [default: %default]")
+    optparser.add_option(
+        '-o', '--output', metavar='FILE',
+        type="string", dest="output",
+        help="output file [default: stdout]")
 
     (options, args) = optparser.parse_args(sys.argv[1:])
     ref_env = parse_env(optparser, options.ref_env)
@@ -169,7 +173,12 @@ def main():
     ref_setup = Setup(args, ref_env)
     src_setup = Setup(args, src_env)
 
-    highligher = Highlighter(sys.stdout)
+    if options.output:
+        output = open(options.output, 'wt')
+    else:
+        output = sys.stdout
+
+    highligher = AutoHighlighter(output)
 
     highligher.write('call\tprecision\n')
 
@@ -217,7 +226,7 @@ def main():
                         src_image.save(prefix + '.src.png')
                         comparer.write_diff(prefix + '.diff.png')
                     if last_bad < last_good:
-                        src_setup.diff_state(last_good, call_no)
+                        src_setup.diff_state(last_good, call_no, output)
                     last_bad = call_no
                 else:
                     last_good = call_no
index bf3768646acfceb1e296ebb431e5ab97346ad8cf..689898512acd75ff1e23b06ce2af2f5b09352d24 100755 (executable)
@@ -130,12 +130,10 @@ def is_image(path):
     name = os.path.basename(path)
     name, ext1 = os.path.splitext(name)
     name, ext2 = os.path.splitext(name)
-    print name, ext1, ext2
     return ext1 in ('.png', '.bmp') and ext2 not in ('.diff', '.thumb')
 
 
 def find_images(prefix):
-    prefix = os.path.abspath(prefix)
     if os.path.isdir(prefix):
         prefix_dir = prefix
     else:
@@ -156,6 +154,10 @@ def main():
 
     optparser = optparse.OptionParser(
         usage="\n\t%prog [options] <ref_prefix> <src_prefix>")
+    optparser.add_option(
+        '-v', '--verbose',
+        action="store_true", dest="verbose", default=False,
+        help="verbose output")
     optparser.add_option(
         '-o', '--output', metavar='FILE',
         type="string", dest="output", default='index.html',
@@ -172,6 +174,10 @@ def main():
         '--overwrite',
         action="store_true", dest="overwrite", default=False,
         help="overwrite images")
+    optparser.add_option(
+        '--show-all',
+        action="store_true", dest="show_all", default=False,
+        help="show all images, including similar ones")
 
     (options, args) = optparser.parse_args(sys.argv[1:])
 
@@ -193,31 +199,46 @@ def main():
     html.write('<html>\n')
     html.write('  <body>\n')
     html.write('    <table border="1">\n')
-    html.write('      <tr><th>%s</th><th>%s</th><th>&Delta;</th></tr>\n' % (ref_prefix, src_prefix))
+    html.write('      <tr><th>File</th><th>%s</th><th>%s</th><th>&Delta;</th></tr>\n' % (ref_prefix, src_prefix))
+    failures = 0
     for image in images:
         ref_image = ref_prefix + image
         src_image = src_prefix + image
         root, ext = os.path.splitext(src_image)
         delta_image = "%s.diff.png" % (root, )
         if os.path.exists(ref_image) and os.path.exists(src_image):
-            if options.overwrite \
-               or not os.path.exists(delta_image) \
-               or (os.path.getmtime(delta_image) < os.path.getmtime(ref_image) \
-                   and os.path.getmtime(delta_image) < os.path.getmtime(src_image)):
-
-                comparer = Comparer(ref_image, src_image, options.alpha)
-                comparer.write_diff(delta_image, fuzz=options.fuzz)
-
+            if options.verbose:
+                sys.stdout.write('Comparing %s and %s ...' % (ref_image, src_image))
+            comparer = Comparer(ref_image, src_image, options.alpha)
+            match = comparer.ae(fuzz=options.fuzz) == 0
+            if match:
+                result = 'MATCH'
+                bgcolor = '#20ff20'
+            else:
+                result = 'MISMATCH'
+                failures += 1
+                bgcolor = '#ff2020'
+            if options.verbose:
+                sys.stdout.write(' %s\n' % (result,))
             html.write('      <tr>\n')
-            surface(html, ref_image)
-            surface(html, src_image)
-            surface(html, delta_image)
+            html.write('        <td bgcolor="%s"><a href="%s">%s<a/></td>\n' % (bgcolor, ref_image, image))
+            if not match or options.show_all:
+                if options.overwrite \
+                   or not os.path.exists(delta_image) \
+                   or (os.path.getmtime(delta_image) < os.path.getmtime(ref_image) \
+                       and os.path.getmtime(delta_image) < os.path.getmtime(src_image)):
+                    comparer.write_diff(delta_image, fuzz=options.fuzz)
+                surface(html, ref_image)
+                surface(html, src_image)
+                surface(html, delta_image)
             html.write('      </tr>\n')
             html.flush()
     html.write('    </table>\n')
     html.write('  </body>\n')
     html.write('</html>\n')
 
+    if failures:
+        sys.exit(1)
 
 if __name__ == '__main__':
     main()
diff --git a/scripts/tracediff.py b/scripts/tracediff.py
new file mode 100755 (executable)
index 0000000..86d1e00
--- /dev/null
@@ -0,0 +1,215 @@
+#!/usr/bin/env python
+##########################################################################
+#
+# Copyright 2011 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+import platform
+import optparse
+import os.path
+import shutil
+import subprocess
+import sys
+import tempfile
+
+
+class Dumper:
+
+    def __init__(self, trace, calls):
+        self.output = tempfile.NamedTemporaryFile()
+
+        dump_args = [
+            options.apitrace,
+            'dump',
+            '--color=never',
+            '--call-nos=no',
+            '--arg-names=no',
+            '--calls=' + calls,
+            trace
+        ]
+
+        self.dump = subprocess.Popen(
+            args = dump_args,
+            stdout = self.output,
+            universal_newlines = True,
+        )
+
+
+if platform.system() == 'Windows':
+    start_delete = ''
+    end_delete   = ''
+    start_insert = ''
+    end_insert   = ''
+else:
+    start_delete = '\33[9m\33[31m'
+    end_delete   = '\33[0m'
+    start_insert = '\33[32m'
+    end_insert   = '\33[0m'
+
+
+def diff(ref_trace, src_trace):
+
+    ref_dumper = Dumper(ref_trace, options.ref_calls)
+    src_dumper = Dumper(src_trace, options.src_calls)
+
+    # TODO use difflib instead
+    if options.diff == 'diff':
+        diff_args = [
+                'diff',
+                '--speed-large-files',
+                '--old-line-format=' + start_delete + '%l' + end_delete + '\n',
+                '--new-line-format=' + start_insert + '%l' + end_insert + '\n',
+            ]
+    elif options.diff == 'sdiff':
+        diff_args = [
+                'sdiff',
+                '--width=%u' % options.width,
+                '--speed-large-files',
+            ]
+    elif options.diff == 'wdiff':
+        diff_args = [
+                'wdiff',
+                #'--terminal',
+                '--avoid-wraps',
+                '--start-delete=' + start_delete,
+                '--end-delete=' + end_delete,
+                '--start-insert=' + start_insert,
+                '--end-insert=' + end_insert,
+            ]
+    else:
+        assert False
+    diff_args += [ref_dumper.output.name, src_dumper.output.name]
+
+    ref_dumper.dump.wait()
+    src_dumper.dump.wait()
+
+    less = None
+    if sys.stdout.isatty():
+        less = subprocess.Popen(
+            args = ['less', '-FRXn'],
+            stdin = subprocess.PIPE
+        )
+
+        diff_stdout = less.stdin
+    else:
+        diff_stdout = None
+
+    diff = subprocess.Popen(
+        args = diff_args,
+        stdout = diff_stdout,
+        universal_newlines = True,
+    )
+
+    diff.wait()
+
+    if less is not None:
+        less.stdin.close()
+        less.wait()
+
+
+def which(executable):
+    '''Search for the executable on the PATH.'''
+
+    if platform.system() == 'Windows':
+        exts = ['.exe']
+    else:
+        exts = ['']
+    dirs = os.environ['PATH'].split(os.path.pathsep)
+    for dir in dirs:
+        path = os.path.join(dir, executable)
+        for ext in exts:
+            if os.path.exists(path + ext):
+                return True
+    return False
+
+
+def columns():
+    import curses
+    curses.setupterm()
+    return curses.tigetnum('cols')
+
+
+def main():
+    '''Main program.
+    '''
+
+    # Determine default options
+    default_width = columns()
+
+    # Parse command line options
+    optparser = optparse.OptionParser(
+        usage='\n\t%prog [options] -- TRACE_FILE TRACE_FILE',
+        version='%%prog')
+    optparser.add_option(
+        '-a', '--apitrace', metavar='PROGRAM',
+        type='string', dest='apitrace', default='apitrace',
+        help='apitrace command [default: %default]')
+    optparser.add_option(
+        '-d', '--diff',
+        type="choice", choices=('diff', 'sdiff', 'wdiff'),
+        dest="diff", default=None,
+        help="diff program: wdiff, sdiff, or diff [default: auto]")
+    optparser.add_option(
+        '-c', '--calls', metavar='CALLSET',
+        type="string", dest="calls", default='1-10000',
+        help="calls to compare [default: %default]")
+    optparser.add_option(
+        '--ref-calls', metavar='CALLSET',
+        type="string", dest="ref_calls", default=None,
+        help="calls to compare from reference trace")
+    optparser.add_option(
+        '--src-calls', metavar='CALLSET',
+        type="string", dest="src_calls", default=None,
+        help="calls to compare from source trace")
+    optparser.add_option(
+        '-w', '--width', metavar='NUM',
+        type="int", dest="width", default=default_width,
+        help="columns [default: %default]")
+
+    global options
+    (options, args) = optparser.parse_args(sys.argv[1:])
+    if len(args) != 2:
+        optparser.error("incorrect number of arguments")
+
+    if options.diff is None:
+        if which('wdiff'):
+            options.diff = 'wdiff'
+        else:
+            sys.stderr.write('warning: wdiff not found\n')
+            if which('sdiff'):
+                options.diff = 'sdiff'
+            else:
+                sys.stderr.write('warning: sdiff not found\n')
+                options.diff = 'diff'
+
+    if options.ref_calls is None:
+        options.ref_calls = options.calls
+    if options.src_calls is None:
+        options.src_calls = options.calls
+
+    diff(*args)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/scripts/tracediff.sh b/scripts/tracediff.sh
deleted file mode 100755 (executable)
index 819a251..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-##########################################################################
-#
-# Copyright 2011 Jose Fonseca
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-set -e
-
-APITRACE=${APITRACE:-apitrace}
-
-$APITRACE dump
-
-stripdump () {
-    $APITRACE dump --color=never --arg-names=no "$1" \
-    | sed \
-        -e 's/\r$//g' \
-        -e 's/^[0-9]\+ //' \
-        -e 's/hdc = \w\+/hdc/g' \
-    | head -1000 \
-    > "$2"
-}
-
-FIFODIR=`mktemp -d`
-FIFO1="$FIFODIR/1"
-FIFO2="$FIFODIR/2"
-
-mkfifo "$FIFO1"
-mkfifo "$FIFO2"
-
-stripdump "$1" "$FIFO1" &
-stripdump "$2" "$FIFO2" &
-
-sdiff \
-    --width=`tput cols` \
-    --speed-large-files \
-    "$FIFO1" "$FIFO2" \
-| less -R
-
-rm -rf "$FIFODIR"
diff --git a/scripts/tracediff2.py b/scripts/tracediff2.py
new file mode 100755 (executable)
index 0000000..0f59d87
--- /dev/null
@@ -0,0 +1,341 @@
+#!/usr/bin/env python
+##########################################################################
+#
+# Copyright 2011-2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+import difflib
+import itertools
+import optparse
+import os.path
+import subprocess
+import sys
+
+from unpickle import Unpickler, Dumper, Rebuilder
+from highlight import ColorHighlighter, LessHighlighter
+
+
+ignoredFunctionNames = set([
+    'glGetString',
+    'glXGetClientString',
+    'glXGetCurrentDisplay',
+    'glXGetCurrentContext',
+    'glXGetProcAddress',
+    'glXGetProcAddressARB',
+    'wglGetProcAddress',
+])
+
+
+class Blob:
+    '''Data-less proxy for bytearrays, to save memory.'''
+
+    def __init__(self, size, hash):
+        self.size = size
+        self.hash = hash
+
+    def __repr__(self):
+        return 'blob(%u)' % self.size
+
+    def __eq__(self, other):
+        return self.size == other.size and self.hash == other.hash
+
+    def __hash__(self):
+        return self.hash
+
+
+class BlobReplacer(Rebuilder):
+    '''Replace blobs with proxys.'''
+
+    def visitByteArray(self, obj):
+        return Blob(len(obj), hash(str(obj)))
+
+    def visitCall(self, call):
+        call.args = map(self.visit, call.args)
+        call.ret = self.visit(call.ret)
+
+
+class Loader(Unpickler):
+
+    def __init__(self, stream):
+        Unpickler.__init__(self, stream)
+        self.calls = []
+        self.rebuilder = BlobReplacer()
+
+    def handleCall(self, call):
+        if call.functionName not in ignoredFunctionNames:
+            self.rebuilder.visitCall(call)
+            self.calls.append(call)
+
+
+def readtrace(trace, calls):
+    p = subprocess.Popen(
+        args = [
+            options.apitrace,
+            'pickle',
+            '--symbolic',
+            '--calls=' + calls,
+            trace
+        ],
+        stdout = subprocess.PIPE,
+    )
+
+    parser = Loader(p.stdout)
+    parser.parse()
+    return parser.calls
+
+
+class SDiffer:
+
+    def __init__(self, a, b, highlighter, callNos = False):
+        self.a = a
+        self.b = b
+        self.highlighter = highlighter
+        self.delete_color = highlighter.red
+        self.insert_color = highlighter.green
+        self.callNos = callNos
+        self.aSpace = 0
+        self.bSpace = 0
+        self.dumper = Dumper()
+
+    def diff(self):
+        matcher = difflib.SequenceMatcher(self.isjunk, self.a, self.b)
+        for tag, alo, ahi, blo, bhi in matcher.get_opcodes():
+            if tag == 'replace':
+                self.replace(alo, ahi, blo, bhi)
+            elif tag == 'delete':
+                self.delete(alo, ahi, blo, bhi)
+            elif tag == 'insert':
+                self.insert(alo, ahi, blo, bhi)
+            elif tag == 'equal':
+                self.equal(alo, ahi, blo, bhi)
+            else:
+                raise ValueError, 'unknown tag %s' % (tag,)
+
+    def isjunk(self, call):
+        return call.functionName == 'glGetError' and call.ret in ('GL_NO_ERROR', 0)
+
+    def replace(self, alo, ahi, blo, bhi):
+        assert alo < ahi and blo < bhi
+        
+        a_names = [call.functionName for call in self.a[alo:ahi]]
+        b_names = [call.functionName for call in self.b[blo:bhi]]
+
+        matcher = difflib.SequenceMatcher(None, a_names, b_names)
+        for tag, _alo, _ahi, _blo, _bhi in matcher.get_opcodes():
+            _alo += alo
+            _ahi += alo
+            _blo += blo
+            _bhi += blo
+            if tag == 'replace':
+                self.replace_dissimilar(_alo, _ahi, _blo, _bhi)
+            elif tag == 'delete':
+                self.delete(_alo, _ahi, _blo, _bhi)
+            elif tag == 'insert':
+                self.insert(_alo, _ahi, _blo, _bhi)
+            elif tag == 'equal':
+                self.replace_similar(_alo, _ahi, _blo, _bhi)
+            else:
+                raise ValueError, 'unknown tag %s' % (tag,)
+
+    def replace_similar(self, alo, ahi, blo, bhi):
+        assert alo < ahi and blo < bhi
+        assert ahi - alo == bhi - blo
+        for i in xrange(0, bhi - blo):
+            self.highlighter.write('| ')
+            a_call = self.a[alo + i]
+            b_call = self.b[blo + i]
+            assert a_call.functionName == b_call.functionName
+            self.dumpCallNos(a_call.no, b_call.no)
+            self.highlighter.bold(True)
+            self.highlighter.write(b_call.functionName)
+            self.highlighter.bold(False)
+            self.highlighter.write('(')
+            sep = ''
+            numArgs = max(len(a_call.args), len(b_call.args))
+            for j in xrange(numArgs):
+                self.highlighter.write(sep)
+                try:
+                    a_arg = a_call.args[j]
+                except IndexError:
+                    pass
+                try:
+                    b_arg = b_call.args[j]
+                except IndexError:
+                    pass
+                self.replace_value(a_arg, b_arg)
+                sep = ', '
+            self.highlighter.write(')')
+            if a_call.ret is not None or b_call.ret is not None:
+                self.highlighter.write(' = ')
+                self.replace_value(a_call.ret, b_call.ret)
+            self.highlighter.write('\n')
+
+    def replace_dissimilar(self, alo, ahi, blo, bhi):
+        assert alo < ahi and blo < bhi
+        if bhi - blo < ahi - alo:
+            self.insert(alo, alo, blo, bhi)
+            self.delete(alo, ahi, bhi, bhi)
+        else:
+            self.delete(alo, ahi, blo, blo)
+            self.insert(ahi, ahi, blo, bhi)
+
+    def replace_value(self, a, b):
+        if b == a:
+            self.highlighter.write(self.dumper.visit(b))
+        else:
+            self.highlighter.strike()
+            self.highlighter.color(self.delete_color)
+            self.highlighter.write(self.dumper.visit(a))
+            self.highlighter.normal()
+            self.highlighter.write(" ")
+            self.highlighter.color(self.insert_color)
+            self.highlighter.write(self.dumper.visit(b))
+            self.highlighter.normal()
+
+    escape = "\33["
+
+    def delete(self, alo, ahi, blo, bhi):
+        assert alo < ahi
+        assert blo == bhi
+        for i in xrange(alo, ahi):
+            call = self.a[i]
+            self.highlighter.write('- ')
+            self.dumpCallNos(call.no, None)
+            self.highlighter.strike()
+            self.highlighter.color(self.delete_color)
+            self.dumpCall(call)
+
+    def insert(self, alo, ahi, blo, bhi):
+        assert alo == ahi
+        assert blo < bhi
+        for i in xrange(blo, bhi):
+            call = self.b[i]
+            self.highlighter.write('+ ')
+            self.dumpCallNos(None, call.no)
+            self.highlighter.color(self.insert_color)
+            self.dumpCall(call)
+
+    def equal(self, alo, ahi, blo, bhi):
+        assert alo < ahi and blo < bhi
+        assert ahi - alo == bhi - blo
+        for i in xrange(0, bhi - blo):
+            self.highlighter.write('  ')
+            a_call = self.a[alo + i]
+            b_call = self.b[blo + i]
+            assert a_call.functionName == b_call.functionName
+            assert len(a_call.args) == len(b_call.args)
+            self.dumpCallNos(a_call.no, b_call.no)
+            self.dumpCall(b_call)
+
+    def dumpCallNos(self, aNo, bNo):
+        if not self.callNos:
+            return
+
+        if aNo is None:
+            self.highlighter.write(' '*self.aSpace)
+        else:
+            aNoStr = str(aNo)
+            self.highlighter.strike()
+            self.highlighter.color(self.delete_color)
+            self.highlighter.write(aNoStr)
+            self.highlighter.normal()
+            self.aSpace = len(aNoStr)
+        self.highlighter.write(' ')
+        if bNo is None:
+            self.highlighter.write(' '*self.bSpace)
+        else:
+            bNoStr = str(bNo)
+            self.highlighter.color(self.insert_color)
+            self.highlighter.write(bNoStr)
+            self.highlighter.normal()
+            self.bSpace = len(bNoStr)
+        self.highlighter.write(' ')
+
+    def dumpCall(self, call):
+        self.highlighter.bold(True)
+        self.highlighter.write(call.functionName)
+        self.highlighter.bold(False)
+        self.highlighter.write('(' + ', '.join(itertools.imap(self.dumper.visit, call.args)) + ')')
+        if call.ret is not None:
+            self.highlighter.write(' = ' + self.dumper.visit(call.ret))
+        self.highlighter.normal()
+        self.highlighter.write('\n')
+
+
+def main():
+    '''Main program.
+    '''
+
+    # Parse command line options
+    optparser = optparse.OptionParser(
+        usage='\n\t%prog <trace> <trace>',
+        version='%%prog')
+    optparser.add_option(
+        '-a', '--apitrace', metavar='PROGRAM',
+        type='string', dest='apitrace', default='apitrace',
+        help='apitrace command [default: %default]')
+    optparser.add_option(
+        '-c', '--calls', metavar='CALLSET',
+        type="string", dest="calls", default='*',
+        help="calls to compare [default: %default]")
+    optparser.add_option(
+        '--ref-calls', metavar='CALLSET',
+        type="string", dest="ref_calls", default=None,
+        help="calls to compare from reference trace")
+    optparser.add_option(
+        '--src-calls', metavar='CALLSET',
+        type="string", dest="src_calls", default=None,
+        help="calls to compare from source trace")
+    optparser.add_option(
+        '--call-nos',
+        action="store_true",
+        dest="call_nos", default=False,
+        help="dump call numbers")
+    global options
+    (options, args) = optparser.parse_args(sys.argv[1:])
+    if len(args) != 2:
+        optparser.error("incorrect number of arguments")
+
+    if options.ref_calls is None:
+        options.ref_calls = options.calls
+    if options.src_calls is None:
+        options.src_calls = options.calls
+
+    ref_calls = readtrace(args[0], options.ref_calls)
+    src_calls = readtrace(args[1], options.src_calls)
+
+    if sys.stdout.isatty():
+        highlighter = LessHighlighter()
+    else:
+        highlighter = ColorHighlighter()
+
+    differ = SDiffer(ref_calls, src_calls, highlighter, options.call_nos)
+    try:
+        differ.diff()
+    except IOError:
+        pass
+
+
+if __name__ == '__main__':
+    main()
index a3c274c8f593e34750be07905031bc6628fba7f9..d2db44df2b9cf577fd68c0145e3bc3436b52152a 100755 (executable)
@@ -33,19 +33,227 @@ Run as:
 '''
 
 
+import itertools
 import optparse
-import cPickle as pickle
 import sys
 import time
+import re
+import cPickle as pickle
+
+
+class Visitor:
+
+    def __init__(self):
+        self.dispatch = {}
+        self.dispatch[type(None)] = self.visitNone
+        self.dispatch[bool] = self.visitBool
+        self.dispatch[int] = self.visitInt
+        self.dispatch[long] = self.visitInt
+        self.dispatch[float] = self.visitFloat
+        self.dispatch[str] = self.visitStr
+        self.dispatch[tuple] = self.visitTuple
+        self.dispatch[list] = self.visitList
+        self.dispatch[dict] = self.visitDict
+        self.dispatch[bytearray] = self.visitByteArray
+
+    def visit(self, obj):
+        method = self.dispatch.get(type(obj), self.visitObj)
+        return method(obj)
+
+    def visitObj(self, obj):
+        raise NotImplementedError
+
+    def visitAtom(self, obj):
+        return self.visitObj(obj)
+
+    def visitNone(self, obj):
+        return self.visitAtom(obj)
+
+    def visitBool(self, obj):
+        return self.visitAtom(obj)
+
+    def visitInt(self, obj):
+        return self.visitAtom(obj)
+
+    def visitFloat(self, obj):
+        return self.visitAtom(obj)
+
+    def visitStr(self, obj):
+        return self.visitAtom(obj)
+
+    def visitIterable(self, obj):
+        return self.visitObj(obj)
+
+    def visitTuple(self, obj):
+        return self.visitIterable(obj)
+
+    def visitList(self, obj):
+        return self.visitIterable(obj)
+
+    def visitDict(self, obj):
+        raise NotImplementedError
+
+    def visitByteArray(self, obj):
+        raise NotImplementedError
+
+
+class Dumper(Visitor):
+
+    id_re = re.compile('^[_A-Za-z][_A-Za-z0-9]*$')
+
+    def visitObj(self, obj):
+        return repr(obj)
+
+    def visitStr(self, obj):
+        if self.id_re.match(obj):
+            return obj
+        else:
+            return repr(obj)
+
+    def visitTuple(self, obj):
+        return '[' + ', '.join(itertools.imap(self.visit, obj)) + ']'
+
+    def visitList(self, obj):
+        return '(' + ', '.join(itertools.imap(self.visit, obj)) + ')'
+
+    def visitByteArray(self, obj):
+        return 'blob(%u)' % len(obj)
+
+
+class Hasher(Visitor):
+    '''Returns a hashable version of the objtree.'''
+
+    def visitObj(self, obj):
+        return obj
+
+    def visitAtom(self, obj):
+        return obj
+
+    def visitIterable(self, obj):
+        return tuple(itertools.imap(self.visit, obj))
+
+    def visitByteArray(self, obj):
+        return str(obj)
+
+
+class Rebuilder(Visitor):
+    '''Returns a hashable version of the objtree.'''
+
+    def visitAtom(self, obj):
+        return obj
+
+    def visitIterable(self, obj):
+        changed = False
+        newItems = []
+        for oldItem in obj:
+            newItem = self.visit(oldItem)
+            if newItem is not oldItem:
+                changed = True
+            newItems.append(newItem)
+        if changed:
+            klass = type(obj)
+            return klass(newItems)
+        else:
+            return obj
+
+    def visitByteArray(self, obj):
+        return obj
+
+
+class Call:
+
+    def __init__(self, callTuple):
+        self.no, self.functionName, self.args, self.ret = callTuple
+        self._hash = None
+
+    def __str__(self):
+        s = self.functionName
+        if self.no is not None:
+            s = str(self.no) + ' ' + s
+        dumper = Dumper()
+        s += '(' + ', '.join(itertools.imap(dumper.visit, self.args)) + ')'
+        if self.ret is not None:
+            s += ' = '
+            s += dumper.visit(self.ret)
+        return s
+
+    def __eq__(self, other):
+        return \
+            self.functionName == other.functionName and \
+            self.args == other.args and \
+            self.ret == other.ret
+
+    def __hash__(self):
+        if self._hash is None:
+            hasher = Hasher()
+            hashable = hasher.visit(self.functionName), hasher.visit(self.args), hasher.visit(self.ret)
+            self._hash = hash(hashable)
+        return self._hash
+
+
+class Unpickler:
+
+    callFactory = Call
+
+    def __init__(self, stream):
+        self.stream = stream
+
+    def parse(self):
+        while self.parseCall():
+            pass
+
+    def parseCall(self):
+        try:
+            callTuple = pickle.load(self.stream)
+        except EOFError:
+            return False
+        else:
+            call = self.callFactory(callTuple)
+            self.handleCall(call)
+            return True
+
+    def handleCall(self, call):
+        pass
+
+
+class Counter(Unpickler):
+
+    def __init__(self, stream, verbose = False):
+        Unpickler.__init__(self, stream)
+        self.verbose = verbose
+        self.numCalls = 0
+        self.functionFrequencies = {}
+
+    def parse(self):
+        Unpickler.parse(self)
+
+        functionFrequencies = self.functionFrequencies.items()
+        functionFrequencies.sort(lambda (name1, freq1), (name2, freq2): cmp(freq1, freq2))
+        for name, frequency in functionFrequencies:
+            sys.stdout.write('%8u %s\n' % (frequency, name))
+
+    def handleCall(self, call):
+        if self.verbose:
+            sys.stdout.write(str(call))
+            sys.stdout.write('\n')
+        self.numCalls += 1
+        try:
+            self.functionFrequencies[call.functionName] += 1
+        except KeyError:
+            self.functionFrequencies[call.functionName] = 1
 
 
 def main():
     optparser = optparse.OptionParser(
         usage="\n\tapitrace pickle trace. %prog [options]")
     optparser.add_option(
-        '--quiet',
-        action="store_true", dest="quiet", default=False,
-        help="don't dump calls to stdout")
+        '-p', '--profile',
+        action="store_true", dest="profile", default=False,
+        help="profile call parsing")
+    optparser.add_option(
+        '-v', '--verbose',
+        action="store_true", dest="verbose", default=False,
+        help="dump calls to stdout")
 
     (options, args) = optparser.parse_args(sys.argv[1:])
 
@@ -61,27 +269,14 @@ def main():
         import os
         msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
 
-    calls = 0
     startTime = time.time()
-    while True:
-        try:
-            call = pickle.load(sys.stdin)
-        except EOFError:
-            break
-        else:
-            callNo, functionName, args, ret = call
-            if not options.quiet:
-                sys.stdout.write('%u ' % callNo)
-                sys.stdout.write(functionName)
-                sys.stdout.write('(' + ', '.join(map(repr, args)) + ')')
-                if ret is not None:
-                    sys.stdout.write(' = ')
-                    sys.stdout.write(repr(ret))
-                sys.stdout.write('\n')
-            calls += 1
+    parser = Counter(sys.stdin, options.verbose)
+    parser.parse()
     stopTime = time.time()
     duration = stopTime - startTime
-    sys.stderr.write('%u calls, %.03f secs, %u calls/sec\n' % (calls, duration, calls/duration))
+
+    if options.profile:
+        sys.stderr.write('Processed %u calls in %.03f secs, at %u calls/sec\n' % (parser.numCalls, duration, parser.numCalls/duration))
 
 
 if __name__ == '__main__':
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0f089c773ce4c0d7cfaafb3424f72d42f7bee77d 100644 (file)
@@ -0,0 +1,28 @@
+##########################################################################
+#
+# Copyright 2012 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+'''Package with the specs for all supported APIs.'''
+
index 5eadbfb00daf5d2a6090cc43044f114b16dbda2e..fbae1b149eecd539d171845a9aac963f868940b6 100644 (file)
@@ -188,7 +188,7 @@ cglapi.addFunctions([
     Function(CGLContextObj, "CGLGetCurrentContext", []),
 
     # OpenGL.h, OpenGL framework
-    Function(CGLError, "CGLChoosePixelFormat", [(Array(Const(CGLPixelFormatAttribute), "__AttribList_size(attribs)"), "attribs"), Out(Pointer(CGLPixelFormatObj), "pix"), Out(Pointer(GLint), "npix")]),
+    Function(CGLError, "CGLChoosePixelFormat", [(Array(Const(CGLPixelFormatAttribute), "_AttribList_size(attribs)"), "attribs"), Out(Pointer(CGLPixelFormatObj), "pix"), Out(Pointer(GLint), "npix")]),
     Function(CGLError, "CGLDestroyPixelFormat", [(CGLPixelFormatObj, "pix")]),
     Function(CGLError, "CGLDescribePixelFormat", [(CGLPixelFormatObj, "pix"), (GLint, "pix_num"), (CGLPixelFormatAttribute, "attrib"), Out(Pointer(GLint), "value")]),
     Function(Void, "CGLReleasePixelFormat", [(CGLPixelFormatObj, "pix")]),
@@ -233,7 +233,7 @@ cglapi.addFunctions([
     Function(CGLError, "CGLLockContext", [(CGLContextObj, "ctx")]),
     Function(CGLError, "CGLUnlockContext", [(CGLContextObj, "ctx")]),
     Function(Void, "CGLGetVersion", [Out(Pointer(GLint), "majorvers"), Out(Pointer(GLint), "minorvers")]),
-    Function(Const(CString), "CGLErrorString", [(CGLError, "error")]),
+    Function(ConstCString, "CGLErrorString", [(CGLError, "error")]),
 
     # CGLIOSurface.h, OpenGL framework
     Function(CGLError, "CGLTexImageIOSurface2D", [(CGLContextObj, "ctx"), (GLenum, "target"), (GLenum, "internal_format"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (IOSurfaceRef, "ioSurface"), (GLuint, "plane")]),
diff --git a/specs/d2d1.def b/specs/d2d1.def
deleted file mode 100644 (file)
index 58c897b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-LIBRARY "d2d1"
-
-EXPORTS
-       D2D1CreateFactory
-       D2D1InvertMatrix
-       D2D1IsMatrixInvertible
-       D2D1MakeRotateMatrix
-       D2D1MakeSkewMatrix
index e7ac8df308556420628744ffe813042f86b3f26a..73e390c743729f399874c514a90cf2c3d06637d1 100644 (file)
@@ -284,11 +284,11 @@ D2D1_LAYER_OPTIONS = EnumFlag("D2D1_LAYER_OPTIONS", [
 
 D2D1_LAYER_PARAMETERS = Struct("D2D1_LAYER_PARAMETERS", [
     (D2D1_RECT_F, "contentBounds"),
-    (Pointer(ID2D1Geometry), "geometricMask"),
+    (ObjPointer(ID2D1Geometry), "geometricMask"),
     (D2D1_ANTIALIAS_MODE, "maskAntialiasMode"),
     (D2D1_MATRIX_3X2_F, "maskTransform"),
     (FLOAT, "opacity"),
-    (Pointer(ID2D1Brush), "opacityBrush"),
+    (ObjPointer(ID2D1Brush), "opacityBrush"),
     (D2D1_LAYER_OPTIONS, "layerOptions"),
 ])
 
@@ -371,7 +371,7 @@ D2D1_FACTORY_OPTIONS = Struct("D2D1_FACTORY_OPTIONS", [
 ])
 
 ID2D1Resource.methods += [
-    Method(Void, "GetFactory", [Out(Pointer(Pointer(ID2D1Factory)), "factory")], const=True),
+    Method(Void, "GetFactory", [Out(Pointer(ObjPointer(ID2D1Factory)), "factory")], const=True),
 ]
 
 ID2D1Bitmap.methods += [
@@ -379,8 +379,8 @@ ID2D1Bitmap.methods += [
     Method(D2D1_SIZE_U, "GetPixelSize", [], const=True),
     Method(D2D1_PIXEL_FORMAT, "GetPixelFormat", [], const=True),
     Method(Void, "GetDpi", [Out(Pointer(FLOAT), "dpiX"), Out(Pointer(FLOAT), "dpiY")], const=True),
-    Method(HRESULT, "CopyFromBitmap", [(Pointer(Const(D2D1_POINT_2U)), "destPoint"), (Pointer(ID2D1Bitmap), "bitmap"), (Pointer(Const(D2D1_RECT_U)), "srcRect")]),
-    Method(HRESULT, "CopyFromRenderTarget", [(Pointer(Const(D2D1_POINT_2U)), "destPoint"), (Pointer(ID2D1RenderTarget), "renderTarget"), (Pointer(Const(D2D1_RECT_U)), "srcRect")]),
+    Method(HRESULT, "CopyFromBitmap", [(Pointer(Const(D2D1_POINT_2U)), "destPoint"), (ObjPointer(ID2D1Bitmap), "bitmap"), (Pointer(Const(D2D1_RECT_U)), "srcRect")]),
+    Method(HRESULT, "CopyFromRenderTarget", [(Pointer(Const(D2D1_POINT_2U)), "destPoint"), (ObjPointer(ID2D1RenderTarget), "renderTarget"), (Pointer(Const(D2D1_RECT_U)), "srcRect")]),
     Method(HRESULT, "CopyFromMemory", [(Pointer(Const(D2D1_RECT_U)), "dstRect"), (OpaquePointer(Const(Void)), "srcData"), (UINT32, "pitch")]),
 ]
 
@@ -402,11 +402,11 @@ ID2D1BitmapBrush.methods += [
     Method(Void, "SetExtendModeX", [(D2D1_EXTEND_MODE, "extendModeX")]),
     Method(Void, "SetExtendModeY", [(D2D1_EXTEND_MODE, "extendModeY")]),
     Method(Void, "SetInterpolationMode", [(D2D1_BITMAP_INTERPOLATION_MODE, "interpolationMode")]),
-    Method(Void, "SetBitmap", [(Pointer(ID2D1Bitmap), "bitmap")]),
+    Method(Void, "SetBitmap", [(ObjPointer(ID2D1Bitmap), "bitmap")]),
     Method(D2D1_EXTEND_MODE, "GetExtendModeX", [], const=True),
     Method(D2D1_EXTEND_MODE, "GetExtendModeY", [], const=True),
     Method(D2D1_BITMAP_INTERPOLATION_MODE, "GetInterpolationMode", [], const=True),
-    Method(Void, "GetBitmap", [Out(Pointer(Pointer(ID2D1Bitmap)), "bitmap")], const=True),
+    Method(Void, "GetBitmap", [Out(Pointer(ObjPointer(ID2D1Bitmap)), "bitmap")], const=True),
 ]
 
 ID2D1SolidColorBrush.methods += [
@@ -419,7 +419,7 @@ ID2D1LinearGradientBrush.methods += [
     Method(Void, "SetEndPoint", [(D2D1_POINT_2F, "endPoint")]),
     Method(D2D1_POINT_2F, "GetStartPoint", [], const=True),
     Method(D2D1_POINT_2F, "GetEndPoint", [], const=True),
-    Method(Void, "GetGradientStopCollection", [Out(Pointer(Pointer(ID2D1GradientStopCollection)), "gradientStopCollection")], const=True),
+    Method(Void, "GetGradientStopCollection", [Out(Pointer(ObjPointer(ID2D1GradientStopCollection)), "gradientStopCollection")], const=True),
 ]
 
 ID2D1RadialGradientBrush.methods += [
@@ -431,7 +431,7 @@ ID2D1RadialGradientBrush.methods += [
     Method(D2D1_POINT_2F, "GetGradientOriginOffset", [], const=True),
     Method(FLOAT, "GetRadiusX", [], const=True),
     Method(FLOAT, "GetRadiusY", [], const=True),
-    Method(Void, "GetGradientStopCollection", [Out(Pointer(Pointer(ID2D1GradientStopCollection)), "gradientStopCollection")], const=True),
+    Method(Void, "GetGradientStopCollection", [Out(Pointer(ObjPointer(ID2D1GradientStopCollection)), "gradientStopCollection")], const=True),
 ]
 
 ID2D1StrokeStyle.methods += [
@@ -448,18 +448,18 @@ ID2D1StrokeStyle.methods += [
 
 ID2D1Geometry.methods += [
     Method(HRESULT, "GetBounds", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), Out(Pointer(D2D1_RECT_F), "bounds")], const=True),
-    Method(HRESULT, "GetWidenedBounds", [(FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(D2D1_RECT_F), "bounds")], const=True),
-    Method(HRESULT, "StrokeContainsPoint", [(D2D1_POINT_2F, "point"), (FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(BOOL), "contains")], const=True),
+    Method(HRESULT, "GetWidenedBounds", [(FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(D2D1_RECT_F), "bounds")], const=True),
+    Method(HRESULT, "StrokeContainsPoint", [(D2D1_POINT_2F, "point"), (FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(BOOL), "contains")], const=True),
     Method(HRESULT, "FillContainsPoint", [(D2D1_POINT_2F, "point"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(BOOL), "contains")], const=True),
-    Method(HRESULT, "CompareWithGeometry", [(Pointer(ID2D1Geometry), "inputGeometry"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "inputGeometryTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(D2D1_GEOMETRY_RELATION), "relation")], const=True),
-    Method(HRESULT, "Simplify", [(D2D1_GEOMETRY_SIMPLIFICATION_OPTION, "simplificationOption"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (Pointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
-    Method(HRESULT, "Tessellate", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (Pointer(ID2D1TessellationSink), "tessellationSink")], const=True),
-    Method(HRESULT, "CombineWithGeometry", [(Pointer(ID2D1Geometry), "inputGeometry"), (D2D1_COMBINE_MODE, "combineMode"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "inputGeometryTransform"), (FLOAT, "flatteningTolerance"), (Pointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
-    Method(HRESULT, "Outline", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (Pointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
+    Method(HRESULT, "CompareWithGeometry", [(ObjPointer(ID2D1Geometry), "inputGeometry"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "inputGeometryTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(D2D1_GEOMETRY_RELATION), "relation")], const=True),
+    Method(HRESULT, "Simplify", [(D2D1_GEOMETRY_SIMPLIFICATION_OPTION, "simplificationOption"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (ObjPointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
+    Method(HRESULT, "Tessellate", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (ObjPointer(ID2D1TessellationSink), "tessellationSink")], const=True),
+    Method(HRESULT, "CombineWithGeometry", [(ObjPointer(ID2D1Geometry), "inputGeometry"), (D2D1_COMBINE_MODE, "combineMode"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "inputGeometryTransform"), (FLOAT, "flatteningTolerance"), (ObjPointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
+    Method(HRESULT, "Outline", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (ObjPointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
     Method(HRESULT, "ComputeArea", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(FLOAT), "area")], const=True),
     Method(HRESULT, "ComputeLength", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(FLOAT), "length")], const=True),
     Method(HRESULT, "ComputePointAtLength", [(FLOAT, "length"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), Out(Pointer(D2D1_POINT_2F), "point"), Out(Pointer(D2D1_POINT_2F), "unitTangentVector")], const=True),
-    Method(HRESULT, "Widen", [(FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (Pointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
+    Method(HRESULT, "Widen", [(FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "worldTransform"), (FLOAT, "flatteningTolerance"), (ObjPointer(ID2D1SimplifiedGeometrySink), "geometrySink")], const=True),
 ]
 
 ID2D1RectangleGeometry.methods += [
@@ -477,11 +477,11 @@ ID2D1EllipseGeometry.methods += [
 ID2D1GeometryGroup.methods += [
     Method(D2D1_FILL_MODE, "GetFillMode", [], const=True),
     Method(UINT32, "GetSourceGeometryCount", [], const=True),
-    Method(Void, "GetSourceGeometries", [Out(Array(Pointer(ID2D1Geometry), "geometriesCount"), "geometries"), (UINT, "geometriesCount")], const=True),
+    Method(Void, "GetSourceGeometries", [Out(Array(ObjPointer(ID2D1Geometry), "geometriesCount"), "geometries"), (UINT, "geometriesCount")], const=True),
 ]
 
 ID2D1TransformedGeometry.methods += [
-    Method(Void, "GetSourceGeometry", [Out(Pointer(Pointer(ID2D1Geometry)), "sourceGeometry")], const=True),
+    Method(Void, "GetSourceGeometry", [Out(Pointer(ObjPointer(ID2D1Geometry)), "sourceGeometry")], const=True),
     Method(Void, "GetTransform", [Out(Pointer(D2D1_MATRIX_3X2_F), "transform")], const=True),
 ]
 
@@ -509,14 +509,14 @@ ID2D1TessellationSink.methods += [
 ]
 
 ID2D1PathGeometry.methods += [
-    Method(HRESULT, "Open", [Out(Pointer(Pointer(ID2D1GeometrySink)), "geometrySink")]),
-    Method(HRESULT, "Stream", [(Pointer(ID2D1GeometrySink), "geometrySink")], const=True),
+    Method(HRESULT, "Open", [Out(Pointer(ObjPointer(ID2D1GeometrySink)), "geometrySink")]),
+    Method(HRESULT, "Stream", [(ObjPointer(ID2D1GeometrySink), "geometrySink")], const=True),
     Method(HRESULT, "GetSegmentCount", [Out(Pointer(UINT32), "count")], const=True),
     Method(HRESULT, "GetFigureCount", [Out(Pointer(UINT32), "count")], const=True),
 ]
 
 ID2D1Mesh.methods += [
-    Method(HRESULT, "Open", [Out(Pointer(Pointer(ID2D1TessellationSink)), "tessellationSink")]),
+    Method(HRESULT, "Open", [Out(Pointer(ObjPointer(ID2D1TessellationSink)), "tessellationSink")]),
 ]
 
 ID2D1Layer.methods += [
@@ -526,52 +526,52 @@ ID2D1Layer.methods += [
 ID2D1DrawingStateBlock.methods += [
     Method(Void, "GetDescription", [Out(Pointer(D2D1_DRAWING_STATE_DESCRIPTION), "stateDescription")], const=True),
     Method(Void, "SetDescription", [(Pointer(Const(D2D1_DRAWING_STATE_DESCRIPTION)), "stateDescription")]),
-    Method(Void, "SetTextRenderingParams", [(Pointer(IDWriteRenderingParams), "textRenderingParams")]),
-    Method(Void, "GetTextRenderingParams", [Out(Pointer(Pointer(IDWriteRenderingParams)), "textRenderingParams")], const=True),
+    Method(Void, "SetTextRenderingParams", [(ObjPointer(IDWriteRenderingParams), "textRenderingParams")]),
+    Method(Void, "GetTextRenderingParams", [Out(Pointer(ObjPointer(IDWriteRenderingParams)), "textRenderingParams")], const=True),
 ]
 
 ID2D1RenderTarget.methods += [
-    Method(HRESULT, "CreateBitmap", [(D2D1_SIZE_U, "size"), (OpaquePointer(Const(Void)), "srcData"), (UINT32, "pitch"), (Pointer(Const(D2D1_BITMAP_PROPERTIES)), "bitmapProperties"), Out(Pointer(Pointer(ID2D1Bitmap)), "bitmap")]),
-    Method(HRESULT, "CreateBitmapFromWicBitmap", [(Opaque("IWICBitmapSource *"), "wicBitmapSource"), (Pointer(Const(D2D1_BITMAP_PROPERTIES)), "bitmapProperties"), Out(Pointer(Pointer(ID2D1Bitmap)), "bitmap")]),
-    Method(HRESULT, "CreateSharedBitmap", [(REFIID, "riid"), Out(OpaquePointer(Void), "data"), (Pointer(Const(D2D1_BITMAP_PROPERTIES)), "bitmapProperties"), Out(Pointer(Pointer(ID2D1Bitmap)), "bitmap")]),
-    Method(HRESULT, "CreateBitmapBrush", [(Pointer(ID2D1Bitmap), "bitmap"), (Pointer(Const(D2D1_BITMAP_BRUSH_PROPERTIES)), "bitmapBrushProperties"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), Out(Pointer(Pointer(ID2D1BitmapBrush)), "bitmapBrush")]),
-    Method(HRESULT, "CreateSolidColorBrush", [(Pointer(Const(D2D1_COLOR_F)), "color"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), Out(Pointer(Pointer(ID2D1SolidColorBrush)), "solidColorBrush")]),
-    Method(HRESULT, "CreateGradientStopCollection", [(Array(Const(D2D1_GRADIENT_STOP), "gradientStopsCount"), "gradientStops"), (UINT, "gradientStopsCount"), (D2D1_GAMMA, "colorInterpolationGamma"), (D2D1_EXTEND_MODE, "extendMode"), Out(Pointer(Pointer(ID2D1GradientStopCollection)), "gradientStopCollection")]),
-    Method(HRESULT, "CreateLinearGradientBrush", [(Pointer(Const(D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES)), "linearGradientBrushProperties"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), (Pointer(ID2D1GradientStopCollection), "gradientStopCollection"), Out(Pointer(Pointer(ID2D1LinearGradientBrush)), "linearGradientBrush")]),
-    Method(HRESULT, "CreateRadialGradientBrush", [(Pointer(Const(D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES)), "radialGradientBrushProperties"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), (Pointer(ID2D1GradientStopCollection), "gradientStopCollection"), Out(Pointer(Pointer(ID2D1RadialGradientBrush)), "radialGradientBrush")]),
-    Method(HRESULT, "CreateCompatibleRenderTarget", [(Pointer(Const(D2D1_SIZE_F)), "desiredSize"), (Pointer(Const(D2D1_SIZE_U)), "desiredPixelSize"), (Pointer(Const(D2D1_PIXEL_FORMAT)), "desiredFormat"), (D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS, "options"), Out(Pointer(Pointer(ID2D1BitmapRenderTarget)), "bitmapRenderTarget")]),
-    Method(HRESULT, "CreateLayer", [(Pointer(Const(D2D1_SIZE_F)), "size"), Out(Pointer(Pointer(ID2D1Layer)), "layer")]),
-    Method(HRESULT, "CreateMesh", [Out(Pointer(Pointer(ID2D1Mesh)), "mesh")]),
-    Method(Void, "DrawLine", [(D2D1_POINT_2F, "point0"), (D2D1_POINT_2F, "point1"), (Pointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle")]),
-    Method(Void, "DrawRectangle", [(Pointer(Const(D2D1_RECT_F)), "rect"), (Pointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle")]),
-    Method(Void, "FillRectangle", [(Pointer(Const(D2D1_RECT_F)), "rect"), (Pointer(ID2D1Brush), "brush")]),
-    Method(Void, "DrawRoundedRectangle", [(Pointer(Const(D2D1_ROUNDED_RECT)), "roundedRect"), (Pointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle")]),
-    Method(Void, "FillRoundedRectangle", [(Pointer(Const(D2D1_ROUNDED_RECT)), "roundedRect"), (Pointer(ID2D1Brush), "brush")]),
-    Method(Void, "DrawEllipse", [(Pointer(Const(D2D1_ELLIPSE)), "ellipse"), (Pointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle")]),
-    Method(Void, "FillEllipse", [(Pointer(Const(D2D1_ELLIPSE)), "ellipse"), (Pointer(ID2D1Brush), "brush")]),
-    Method(Void, "DrawGeometry", [(Pointer(ID2D1Geometry), "geometry"), (Pointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (Pointer(ID2D1StrokeStyle), "strokeStyle")]),
-    Method(Void, "FillGeometry", [(Pointer(ID2D1Geometry), "geometry"), (Pointer(ID2D1Brush), "brush"), (Pointer(ID2D1Brush), "opacityBrush")]),
-    Method(Void, "FillMesh", [(Pointer(ID2D1Mesh), "mesh"), (Pointer(ID2D1Brush), "brush")]),
-    Method(Void, "FillOpacityMask", [(Pointer(ID2D1Bitmap), "opacityMask"), (Pointer(ID2D1Brush), "brush"), (D2D1_OPACITY_MASK_CONTENT, "content"), (Pointer(Const(D2D1_RECT_F)), "destinationRectangle"), (Pointer(Const(D2D1_RECT_F)), "sourceRectangle")]),
-    Method(Void, "DrawBitmap", [(Pointer(ID2D1Bitmap), "bitmap"), (Pointer(Const(D2D1_RECT_F)), "destinationRectangle"), (FLOAT, "opacity"), (D2D1_BITMAP_INTERPOLATION_MODE, "interpolationMode"), (Pointer(Const(D2D1_RECT_F)), "sourceRectangle")]),
-    Method(Void, "DrawText", [(Pointer(Const(WCHAR)), "string"), (UINT, "stringLength"), (Pointer(IDWriteTextFormat), "textFormat"), (Pointer(Const(D2D1_RECT_F)), "layoutRect"), (Pointer(ID2D1Brush), "defaultForegroundBrush"), (D2D1_DRAW_TEXT_OPTIONS, "options"), (DWRITE_MEASURING_MODE, "measuringMode")]),
-    Method(Void, "DrawTextLayout", [(D2D1_POINT_2F, "origin"), (Pointer(IDWriteTextLayout), "textLayout"), (Pointer(ID2D1Brush), "defaultForegroundBrush"), (D2D1_DRAW_TEXT_OPTIONS, "options")]),
-    Method(Void, "DrawGlyphRun", [(D2D1_POINT_2F, "baselineOrigin"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (Pointer(ID2D1Brush), "foregroundBrush"), (DWRITE_MEASURING_MODE, "measuringMode")]),
+    Method(HRESULT, "CreateBitmap", [(D2D1_SIZE_U, "size"), (OpaquePointer(Const(Void)), "srcData"), (UINT32, "pitch"), (Pointer(Const(D2D1_BITMAP_PROPERTIES)), "bitmapProperties"), Out(Pointer(ObjPointer(ID2D1Bitmap)), "bitmap")]),
+    Method(HRESULT, "CreateBitmapFromWicBitmap", [(Opaque("IWICBitmapSource *"), "wicBitmapSource"), (Pointer(Const(D2D1_BITMAP_PROPERTIES)), "bitmapProperties"), Out(Pointer(ObjPointer(ID2D1Bitmap)), "bitmap")]),
+    Method(HRESULT, "CreateSharedBitmap", [(REFIID, "riid"), Out(OpaquePointer(Void), "data"), (Pointer(Const(D2D1_BITMAP_PROPERTIES)), "bitmapProperties"), Out(Pointer(ObjPointer(ID2D1Bitmap)), "bitmap")]),
+    Method(HRESULT, "CreateBitmapBrush", [(ObjPointer(ID2D1Bitmap), "bitmap"), (Pointer(Const(D2D1_BITMAP_BRUSH_PROPERTIES)), "bitmapBrushProperties"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), Out(Pointer(ObjPointer(ID2D1BitmapBrush)), "bitmapBrush")]),
+    Method(HRESULT, "CreateSolidColorBrush", [(Pointer(Const(D2D1_COLOR_F)), "color"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), Out(Pointer(ObjPointer(ID2D1SolidColorBrush)), "solidColorBrush")]),
+    Method(HRESULT, "CreateGradientStopCollection", [(Array(Const(D2D1_GRADIENT_STOP), "gradientStopsCount"), "gradientStops"), (UINT, "gradientStopsCount"), (D2D1_GAMMA, "colorInterpolationGamma"), (D2D1_EXTEND_MODE, "extendMode"), Out(Pointer(ObjPointer(ID2D1GradientStopCollection)), "gradientStopCollection")]),
+    Method(HRESULT, "CreateLinearGradientBrush", [(Pointer(Const(D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES)), "linearGradientBrushProperties"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), (ObjPointer(ID2D1GradientStopCollection), "gradientStopCollection"), Out(Pointer(ObjPointer(ID2D1LinearGradientBrush)), "linearGradientBrush")]),
+    Method(HRESULT, "CreateRadialGradientBrush", [(Pointer(Const(D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES)), "radialGradientBrushProperties"), (Pointer(Const(D2D1_BRUSH_PROPERTIES)), "brushProperties"), (ObjPointer(ID2D1GradientStopCollection), "gradientStopCollection"), Out(Pointer(ObjPointer(ID2D1RadialGradientBrush)), "radialGradientBrush")]),
+    Method(HRESULT, "CreateCompatibleRenderTarget", [(Pointer(Const(D2D1_SIZE_F)), "desiredSize"), (Pointer(Const(D2D1_SIZE_U)), "desiredPixelSize"), (Pointer(Const(D2D1_PIXEL_FORMAT)), "desiredFormat"), (D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS, "options"), Out(Pointer(ObjPointer(ID2D1BitmapRenderTarget)), "bitmapRenderTarget")]),
+    Method(HRESULT, "CreateLayer", [(Pointer(Const(D2D1_SIZE_F)), "size"), Out(Pointer(ObjPointer(ID2D1Layer)), "layer")]),
+    Method(HRESULT, "CreateMesh", [Out(Pointer(ObjPointer(ID2D1Mesh)), "mesh")]),
+    Method(Void, "DrawLine", [(D2D1_POINT_2F, "point0"), (D2D1_POINT_2F, "point1"), (ObjPointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle")]),
+    Method(Void, "DrawRectangle", [(Pointer(Const(D2D1_RECT_F)), "rect"), (ObjPointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle")]),
+    Method(Void, "FillRectangle", [(Pointer(Const(D2D1_RECT_F)), "rect"), (ObjPointer(ID2D1Brush), "brush")]),
+    Method(Void, "DrawRoundedRectangle", [(Pointer(Const(D2D1_ROUNDED_RECT)), "roundedRect"), (ObjPointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle")]),
+    Method(Void, "FillRoundedRectangle", [(Pointer(Const(D2D1_ROUNDED_RECT)), "roundedRect"), (ObjPointer(ID2D1Brush), "brush")]),
+    Method(Void, "DrawEllipse", [(Pointer(Const(D2D1_ELLIPSE)), "ellipse"), (ObjPointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle")]),
+    Method(Void, "FillEllipse", [(Pointer(Const(D2D1_ELLIPSE)), "ellipse"), (ObjPointer(ID2D1Brush), "brush")]),
+    Method(Void, "DrawGeometry", [(ObjPointer(ID2D1Geometry), "geometry"), (ObjPointer(ID2D1Brush), "brush"), (FLOAT, "strokeWidth"), (ObjPointer(ID2D1StrokeStyle), "strokeStyle")]),
+    Method(Void, "FillGeometry", [(ObjPointer(ID2D1Geometry), "geometry"), (ObjPointer(ID2D1Brush), "brush"), (ObjPointer(ID2D1Brush), "opacityBrush")]),
+    Method(Void, "FillMesh", [(ObjPointer(ID2D1Mesh), "mesh"), (ObjPointer(ID2D1Brush), "brush")]),
+    Method(Void, "FillOpacityMask", [(ObjPointer(ID2D1Bitmap), "opacityMask"), (ObjPointer(ID2D1Brush), "brush"), (D2D1_OPACITY_MASK_CONTENT, "content"), (Pointer(Const(D2D1_RECT_F)), "destinationRectangle"), (Pointer(Const(D2D1_RECT_F)), "sourceRectangle")]),
+    Method(Void, "DrawBitmap", [(ObjPointer(ID2D1Bitmap), "bitmap"), (Pointer(Const(D2D1_RECT_F)), "destinationRectangle"), (FLOAT, "opacity"), (D2D1_BITMAP_INTERPOLATION_MODE, "interpolationMode"), (Pointer(Const(D2D1_RECT_F)), "sourceRectangle")]),
+    Method(Void, "DrawText", [(Pointer(Const(WCHAR)), "string"), (UINT, "stringLength"), (ObjPointer(IDWriteTextFormat), "textFormat"), (Pointer(Const(D2D1_RECT_F)), "layoutRect"), (ObjPointer(ID2D1Brush), "defaultForegroundBrush"), (D2D1_DRAW_TEXT_OPTIONS, "options"), (DWRITE_MEASURING_MODE, "measuringMode")]),
+    Method(Void, "DrawTextLayout", [(D2D1_POINT_2F, "origin"), (ObjPointer(IDWriteTextLayout), "textLayout"), (ObjPointer(ID2D1Brush), "defaultForegroundBrush"), (D2D1_DRAW_TEXT_OPTIONS, "options")]),
+    Method(Void, "DrawGlyphRun", [(D2D1_POINT_2F, "baselineOrigin"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (ObjPointer(ID2D1Brush), "foregroundBrush"), (DWRITE_MEASURING_MODE, "measuringMode")]),
     Method(Void, "SetTransform", [(Pointer(Const(D2D1_MATRIX_3X2_F)), "transform")]),
     Method(Void, "GetTransform", [Out(Pointer(D2D1_MATRIX_3X2_F), "transform")], const=True),
     Method(Void, "SetAntialiasMode", [(D2D1_ANTIALIAS_MODE, "antialiasMode")]),
     Method(D2D1_ANTIALIAS_MODE, "GetAntialiasMode", [], const=True),
     Method(Void, "SetTextAntialiasMode", [(D2D1_TEXT_ANTIALIAS_MODE, "textAntialiasMode")]),
     Method(D2D1_TEXT_ANTIALIAS_MODE, "GetTextAntialiasMode", [], const=True),
-    Method(Void, "SetTextRenderingParams", [(Pointer(IDWriteRenderingParams), "textRenderingParams")]),
-    Method(Void, "GetTextRenderingParams", [Out(Pointer(Pointer(IDWriteRenderingParams)), "textRenderingParams")], const=True),
+    Method(Void, "SetTextRenderingParams", [(ObjPointer(IDWriteRenderingParams), "textRenderingParams")]),
+    Method(Void, "GetTextRenderingParams", [Out(Pointer(ObjPointer(IDWriteRenderingParams)), "textRenderingParams")], const=True),
     Method(Void, "SetTags", [(D2D1_TAG, "tag1"), (D2D1_TAG, "tag2")]),
     Method(Void, "GetTags", [Out(Pointer(D2D1_TAG), "tag1"), Out(Pointer(D2D1_TAG), "tag2")], const=True),
-    Method(Void, "PushLayer", [(Pointer(Const(D2D1_LAYER_PARAMETERS)), "layerParameters"), (Pointer(ID2D1Layer), "layer")]),
+    Method(Void, "PushLayer", [(Pointer(Const(D2D1_LAYER_PARAMETERS)), "layerParameters"), (ObjPointer(ID2D1Layer), "layer")]),
     Method(Void, "PopLayer", []),
     Method(HRESULT, "Flush", [Out(Pointer(D2D1_TAG), "tag1"), Out(Pointer(D2D1_TAG), "tag2")]),
-    Method(Void, "SaveDrawingState", [Out(Pointer(ID2D1DrawingStateBlock), "drawingStateBlock")], const=True),
-    Method(Void, "RestoreDrawingState", [(Pointer(ID2D1DrawingStateBlock), "drawingStateBlock")]),
+    Method(Void, "SaveDrawingState", [(ObjPointer(ID2D1DrawingStateBlock), "drawingStateBlock")], const=True),
+    Method(Void, "RestoreDrawingState", [(ObjPointer(ID2D1DrawingStateBlock), "drawingStateBlock")]),
     Method(Void, "PushAxisAlignedClip", [(Pointer(Const(D2D1_RECT_F)), "clipRect"), (D2D1_ANTIALIAS_MODE, "antialiasMode")]),
     Method(Void, "PopAxisAlignedClip", []),
     Method(Void, "Clear", [(Pointer(Const(D2D1_COLOR_F)), "clearColor")]),
@@ -587,7 +587,7 @@ ID2D1RenderTarget.methods += [
 ]
 
 ID2D1BitmapRenderTarget.methods += [
-    Method(HRESULT, "GetBitmap", [Out(Pointer(Pointer(ID2D1Bitmap)), "bitmap")]),
+    Method(HRESULT, "GetBitmap", [Out(Pointer(ObjPointer(ID2D1Bitmap)), "bitmap")]),
 ]
 
 ID2D1HwndRenderTarget.methods += [
@@ -608,18 +608,18 @@ ID2D1DCRenderTarget.methods += [
 ID2D1Factory.methods += [
     Method(HRESULT, "ReloadSystemMetrics", []),
     Method(Void, "GetDesktopDpi", [Out(Pointer(FLOAT), "dpiX"), Out(Pointer(FLOAT), "dpiY")]),
-    Method(HRESULT, "CreateRectangleGeometry", [(Pointer(Const(D2D1_RECT_F)), "rectangle"), Out(Pointer(Pointer(ID2D1RectangleGeometry)), "rectangleGeometry")]),
-    Method(HRESULT, "CreateRoundedRectangleGeometry", [(Pointer(Const(D2D1_ROUNDED_RECT)), "roundedRectangle"), Out(Pointer(Pointer(ID2D1RoundedRectangleGeometry)), "roundedRectangleGeometry")]),
-    Method(HRESULT, "CreateEllipseGeometry", [(Pointer(Const(D2D1_ELLIPSE)), "ellipse"), Out(Pointer(Pointer(ID2D1EllipseGeometry)), "ellipseGeometry")]),
-    Method(HRESULT, "CreateGeometryGroup", [(D2D1_FILL_MODE, "fillMode"), (Pointer(Pointer(ID2D1Geometry)), "geometries"), (UINT, "geometriesCount"), Out(Pointer(Pointer(ID2D1GeometryGroup)), "geometryGroup")]),
-    Method(HRESULT, "CreateTransformedGeometry", [(Pointer(ID2D1Geometry), "sourceGeometry"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "transform"), Out(Pointer(Pointer(ID2D1TransformedGeometry)), "transformedGeometry")]),
-    Method(HRESULT, "CreatePathGeometry", [Out(Pointer(Pointer(ID2D1PathGeometry)), "pathGeometry")]),
-    Method(HRESULT, "CreateStrokeStyle", [(Pointer(Const(D2D1_STROKE_STYLE_PROPERTIES)), "strokeStyleProperties"), (Pointer(Const(FLOAT)), "dashes"), (UINT, "dashesCount"), Out(Pointer(Pointer(ID2D1StrokeStyle)), "strokeStyle")]),
-    Method(HRESULT, "CreateDrawingStateBlock", [(Pointer(Const(D2D1_DRAWING_STATE_DESCRIPTION)), "drawingStateDescription"), (Pointer(IDWriteRenderingParams), "textRenderingParams"), Out(Pointer(Pointer(ID2D1DrawingStateBlock)), "drawingStateBlock")]),
-    Method(HRESULT, "CreateWicBitmapRenderTarget", [(Opaque("IWICBitmap *"), "target"), (Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), Out(Pointer(Pointer(ID2D1RenderTarget)), "renderTarget")]),
-    Method(HRESULT, "CreateHwndRenderTarget", [(Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), (Pointer(Const(D2D1_HWND_RENDER_TARGET_PROPERTIES)), "hwndRenderTargetProperties"), Out(Pointer(Pointer(ID2D1HwndRenderTarget)), "hwndRenderTarget")]),
-    Method(HRESULT, "CreateDxgiSurfaceRenderTarget", [(Pointer(IDXGISurface), "dxgiSurface"), (Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), Out(Pointer(Pointer(ID2D1RenderTarget)), "renderTarget")]),
-    Method(HRESULT, "CreateDCRenderTarget", [(Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), Out(Pointer(Pointer(ID2D1DCRenderTarget)), "dcRenderTarget")]),
+    Method(HRESULT, "CreateRectangleGeometry", [(Pointer(Const(D2D1_RECT_F)), "rectangle"), Out(Pointer(ObjPointer(ID2D1RectangleGeometry)), "rectangleGeometry")]),
+    Method(HRESULT, "CreateRoundedRectangleGeometry", [(Pointer(Const(D2D1_ROUNDED_RECT)), "roundedRectangle"), Out(Pointer(ObjPointer(ID2D1RoundedRectangleGeometry)), "roundedRectangleGeometry")]),
+    Method(HRESULT, "CreateEllipseGeometry", [(Pointer(Const(D2D1_ELLIPSE)), "ellipse"), Out(Pointer(ObjPointer(ID2D1EllipseGeometry)), "ellipseGeometry")]),
+    Method(HRESULT, "CreateGeometryGroup", [(D2D1_FILL_MODE, "fillMode"), (Pointer(ObjPointer(ID2D1Geometry)), "geometries"), (UINT, "geometriesCount"), Out(Pointer(ObjPointer(ID2D1GeometryGroup)), "geometryGroup")]),
+    Method(HRESULT, "CreateTransformedGeometry", [(ObjPointer(ID2D1Geometry), "sourceGeometry"), (Pointer(Const(D2D1_MATRIX_3X2_F)), "transform"), Out(Pointer(ObjPointer(ID2D1TransformedGeometry)), "transformedGeometry")]),
+    Method(HRESULT, "CreatePathGeometry", [Out(Pointer(ObjPointer(ID2D1PathGeometry)), "pathGeometry")]),
+    Method(HRESULT, "CreateStrokeStyle", [(Pointer(Const(D2D1_STROKE_STYLE_PROPERTIES)), "strokeStyleProperties"), (Pointer(Const(FLOAT)), "dashes"), (UINT, "dashesCount"), Out(Pointer(ObjPointer(ID2D1StrokeStyle)), "strokeStyle")]),
+    Method(HRESULT, "CreateDrawingStateBlock", [(Pointer(Const(D2D1_DRAWING_STATE_DESCRIPTION)), "drawingStateDescription"), (ObjPointer(IDWriteRenderingParams), "textRenderingParams"), Out(Pointer(ObjPointer(ID2D1DrawingStateBlock)), "drawingStateBlock")]),
+    Method(HRESULT, "CreateWicBitmapRenderTarget", [(Opaque("IWICBitmap *"), "target"), (Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), Out(Pointer(ObjPointer(ID2D1RenderTarget)), "renderTarget")]),
+    Method(HRESULT, "CreateHwndRenderTarget", [(Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), (Pointer(Const(D2D1_HWND_RENDER_TARGET_PROPERTIES)), "hwndRenderTargetProperties"), Out(Pointer(ObjPointer(ID2D1HwndRenderTarget)), "hwndRenderTarget")]),
+    Method(HRESULT, "CreateDxgiSurfaceRenderTarget", [(ObjPointer(IDXGISurface), "dxgiSurface"), (Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), Out(Pointer(ObjPointer(ID2D1RenderTarget)), "renderTarget")]),
+    Method(HRESULT, "CreateDCRenderTarget", [(Pointer(Const(D2D1_RENDER_TARGET_PROPERTIES)), "renderTargetProperties"), Out(Pointer(ObjPointer(ID2D1DCRenderTarget)), "dcRenderTarget")]),
 ]
 
 d2d1 = API("d2d1")
index 2684e6b65cb92317ccabde7c3e5ad45c3401d205..ca1155167418a62b51b37b464f98130b9511bcd1 100644 (file)
@@ -30,9 +30,6 @@ from ddraw import *
 from d3dtypes import *
 from d3dcaps import *
 
-def OutPointer(type):
-    return Out(Pointer(type), "out")
-
 d3dnextFlags = Flags(DWORD, [
     "D3DNEXT_NEXT",
     "D3DNEXT_HEAD",
@@ -51,8 +48,7 @@ d3ddpFlags = Flags(DWORD, [
     "D3DDP_DONOTLIGHT",
 ])
 
-HRESULT = Enum("HRESULT", [
-    "D3D_OK",
+HRESULT = MAKE_HRESULT(ok = "D3D_OK", errors = [
     "D3DERR_BADMAJORVERSION",
     "D3DERR_BADMINORVERSION",
     "D3DERR_INVALID_DEVICE",
@@ -155,31 +151,31 @@ IDirect3DViewport3 = Interface("IDirect3DViewport3", IDirect3DViewport2)
 IDirect3DVertexBuffer = Interface("IDirect3DVertexBuffer", IUnknown)
 IDirect3DVertexBuffer7 = Interface("IDirect3DVertexBuffer7", IUnknown)
 
-LPUNKNOWN = Pointer(IUnknown)
-
-LPDIRECT3D = Pointer(IDirect3D)
-LPDIRECT3DDEVICE = Pointer(IDirect3DDevice)
-LPDIRECT3DEXECUTEBUFFER = Pointer(IDirect3DExecuteBuffer)
-LPDIRECT3DLIGHT = Pointer(IDirect3DLight)
-LPDIRECT3DMATERIAL = Pointer(IDirect3DMaterial)
-LPDIRECT3DTEXTURE = Pointer(IDirect3DTexture)
-LPDIRECT3DVIEWPORT = Pointer(IDirect3DViewport)
-
-LPDIRECT3D2 = Pointer(IDirect3D2)
-LPDIRECT3DDEVICE2 = Pointer(IDirect3DDevice2)
-LPDIRECT3DMATERIAL2 = Pointer(IDirect3DMaterial2)
-LPDIRECT3DTEXTURE2 = Pointer(IDirect3DTexture2)
-LPDIRECT3DVIEWPORT2 = Pointer(IDirect3DViewport2)
-
-LPDIRECT3D3 = Pointer(IDirect3D3)
-LPDIRECT3DDEVICE3 = Pointer(IDirect3DDevice3)
-LPDIRECT3DMATERIAL3 = Pointer(IDirect3DMaterial3)
-LPDIRECT3DVIEWPORT3 = Pointer(IDirect3DViewport3)
-LPDIRECT3DVERTEXBUFFER = Pointer(IDirect3DVertexBuffer)
-
-LPDIRECT3D7 = Pointer(IDirect3D7)
-LPDIRECT3DDEVICE7 = Pointer(IDirect3DDevice7)
-LPDIRECT3DVERTEXBUFFER7 = Pointer(IDirect3DVertexBuffer7)
+LPUNKNOWN = ObjPointer(IUnknown)
+
+LPDIRECT3D = ObjPointer(IDirect3D)
+LPDIRECT3DDEVICE = ObjPointer(IDirect3DDevice)
+LPDIRECT3DEXECUTEBUFFER = ObjPointer(IDirect3DExecuteBuffer)
+LPDIRECT3DLIGHT = ObjPointer(IDirect3DLight)
+LPDIRECT3DMATERIAL = ObjPointer(IDirect3DMaterial)
+LPDIRECT3DTEXTURE = ObjPointer(IDirect3DTexture)
+LPDIRECT3DVIEWPORT = ObjPointer(IDirect3DViewport)
+
+LPDIRECT3D2 = ObjPointer(IDirect3D2)
+LPDIRECT3DDEVICE2 = ObjPointer(IDirect3DDevice2)
+LPDIRECT3DMATERIAL2 = ObjPointer(IDirect3DMaterial2)
+LPDIRECT3DTEXTURE2 = ObjPointer(IDirect3DTexture2)
+LPDIRECT3DVIEWPORT2 = ObjPointer(IDirect3DViewport2)
+
+LPDIRECT3D3 = ObjPointer(IDirect3D3)
+LPDIRECT3DDEVICE3 = ObjPointer(IDirect3DDevice3)
+LPDIRECT3DMATERIAL3 = ObjPointer(IDirect3DMaterial3)
+LPDIRECT3DVIEWPORT3 = ObjPointer(IDirect3DViewport3)
+LPDIRECT3DVERTEXBUFFER = ObjPointer(IDirect3DVertexBuffer)
+
+LPDIRECT3D7 = ObjPointer(IDirect3D7)
+LPDIRECT3DDEVICE7 = ObjPointer(IDirect3DDevice7)
+LPDIRECT3DVERTEXBUFFER7 = ObjPointer(IDirect3DVertexBuffer7)
 
 IDirect3D.methods += [
     Method(HRESULT, "Initialize", [(REFCLSID, "riid")]),
diff --git a/specs/d3d10.def b/specs/d3d10.def
deleted file mode 100644 (file)
index 5482ab5..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-LIBRARY        "d3d10"
-
-EXPORTS
-        D3D10CreateDevice
-        D3D10CreateDeviceAndSwapChain
-        D3D10CreateBlob
index 5e8d1805b865a285ed6206124455330cbfaeead1..b7c3e653af5a2b7f1447545216da7436daf70461 100644 (file)
 #
 ##########################################################################/
 
+
 from dxgi import *
+from d3dcommon import *
+
+
+HRESULT = MAKE_HRESULT([
+    "D3D10_ERROR_FILE_NOT_FOUND",
+    "D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS",
+    "D3DERR_INVALIDCALL",
+    "D3DERR_WASSTILLDRAWING",
+])
 
 D3D10_BLEND = Enum("D3D10_BLEND", [
     "D3D10_BLEND_ZERO",
@@ -177,6 +187,33 @@ D3D10_SAMPLER_DESC = Struct("D3D10_SAMPLER_DESC", [
     (FLOAT, "MaxLOD"),
 ])
 
+D3D10_FORMAT_SUPPORT = Flags(UINT, [
+    "D3D10_FORMAT_SUPPORT_BUFFER",
+    "D3D10_FORMAT_SUPPORT_IA_VERTEX_BUFFER",
+    "D3D10_FORMAT_SUPPORT_IA_INDEX_BUFFER",
+    "D3D10_FORMAT_SUPPORT_SO_BUFFER",
+    "D3D10_FORMAT_SUPPORT_TEXTURE1D",
+    "D3D10_FORMAT_SUPPORT_TEXTURE2D",
+    "D3D10_FORMAT_SUPPORT_TEXTURE3D",
+    "D3D10_FORMAT_SUPPORT_TEXTURECUBE",
+    "D3D10_FORMAT_SUPPORT_SHADER_LOAD",
+    "D3D10_FORMAT_SUPPORT_SHADER_SAMPLE",
+    "D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON",
+    "D3D10_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT",
+    "D3D10_FORMAT_SUPPORT_MIP",
+    "D3D10_FORMAT_SUPPORT_MIP_AUTOGEN",
+    "D3D10_FORMAT_SUPPORT_RENDER_TARGET",
+    "D3D10_FORMAT_SUPPORT_BLENDABLE",
+    "D3D10_FORMAT_SUPPORT_DEPTH_STENCIL",
+    "D3D10_FORMAT_SUPPORT_CPU_LOCKABLE",
+    "D3D10_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE",
+    "D3D10_FORMAT_SUPPORT_DISPLAY",
+    "D3D10_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT",
+    "D3D10_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET",
+    "D3D10_FORMAT_SUPPORT_MULTISAMPLE_LOAD",
+    "D3D10_FORMAT_SUPPORT_SHADER_GATHER",
+])
+
 D3D10_COUNTER = Enum("D3D10_COUNTER", [
     "D3D10_COUNTER_GPU_IDLE",
     "D3D10_COUNTER_VERTEX_PROCESSING",
@@ -232,7 +269,7 @@ D3D10_USAGE = Enum("D3D10_USAGE", [
     "D3D10_USAGE_STAGING",
 ])
 
-D3D10_BIND_FLAG = Enum("D3D10_BIND_FLAG", [
+D3D10_BIND_FLAG = Flags(UINT, [
     "D3D10_BIND_VERTEX_BUFFER",
     "D3D10_BIND_INDEX_BUFFER",
     "D3D10_BIND_CONSTANT_BUFFER",
@@ -242,12 +279,25 @@ D3D10_BIND_FLAG = Enum("D3D10_BIND_FLAG", [
     "D3D10_BIND_DEPTH_STENCIL",
 ])
 
+D3D10_CPU_ACCESS_FLAG = Flags(UINT, [
+    "D3D10_CPU_ACCESS_WRITE",
+    "D3D10_CPU_ACCESS_READ",
+])
+
+D3D10_RESOURCE_MISC_FLAG = Flags(UINT, [
+    "D3D10_RESOURCE_MISC_GENERATE_MIPS",
+    "D3D10_RESOURCE_MISC_SHARED",
+    "D3D10_RESOURCE_MISC_TEXTURECUBE",
+    "D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX",
+    "D3D10_RESOURCE_MISC_GDI_COMPATIBLE",
+])
+
 D3D10_BUFFER_DESC = Struct("D3D10_BUFFER_DESC", [
     (UINT, "ByteWidth"),
     (D3D10_USAGE, "Usage"),
-    (UINT, "BindFlags"),
-    (UINT, "CPUAccessFlags"),
-    (UINT, "MiscFlags"),
+    (D3D10_BIND_FLAG, "BindFlags"),
+    (D3D10_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D10_RESOURCE_MISC_FLAG, "MiscFlags"),
 ])
 
 D3D10_MAP = Enum("D3D10_MAP", [
@@ -264,9 +314,9 @@ D3D10_TEXTURE1D_DESC = Struct("D3D10_TEXTURE1D_DESC", [
     (UINT, "ArraySize"),
     (DXGI_FORMAT, "Format"),
     (D3D10_USAGE, "Usage"),
-    (UINT, "BindFlags"),
-    (UINT, "CPUAccessFlags"),
-    (UINT, "MiscFlags"),
+    (D3D10_BIND_FLAG, "BindFlags"),
+    (D3D10_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D10_RESOURCE_MISC_FLAG, "MiscFlags"),
 ])
 
 D3D10_TEXTURE2D_DESC = Struct("D3D10_TEXTURE2D_DESC", [
@@ -277,9 +327,9 @@ D3D10_TEXTURE2D_DESC = Struct("D3D10_TEXTURE2D_DESC", [
     (DXGI_FORMAT, "Format"),
     (DXGI_SAMPLE_DESC, "SampleDesc"),
     (D3D10_USAGE, "Usage"),
-    (UINT, "BindFlags"),
-    (UINT, "CPUAccessFlags"),
-    (UINT, "MiscFlags"),
+    (D3D10_BIND_FLAG, "BindFlags"),
+    (D3D10_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D10_RESOURCE_MISC_FLAG, "MiscFlags"),
 ])
 
 D3D10_TEXTURE3D_DESC = Struct("D3D10_TEXTURE3D_DESC", [
@@ -289,9 +339,9 @@ D3D10_TEXTURE3D_DESC = Struct("D3D10_TEXTURE3D_DESC", [
     (UINT, "MipLevels"),
     (DXGI_FORMAT, "Format"),
     (D3D10_USAGE, "Usage"),
-    (UINT, "BindFlags"),
-    (UINT, "CPUAccessFlags"),
-    (UINT, "MiscFlags"),
+    (D3D10_BIND_FLAG, "BindFlags"),
+    (D3D10_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D10_RESOURCE_MISC_FLAG, "MiscFlags"),
 ])
 
 D3D10_DSV_DIMENSION = Enum("D3D10_DSV_DIMENSION", [
@@ -533,31 +583,13 @@ D3D10_QUERY = Enum("D3D10_QUERY", [
     "D3D10_QUERY_SO_OVERFLOW_PREDICATE",
 ])
 
-D3D10_QUERY_DESC = Struct("D3D10_QUERY_DESC", [
-    (D3D10_QUERY, "Query"),
-    (UINT, "MiscFlags"),
-])
-
-D3D10_PRIMITIVE_TOPOLOGY = Enum("D3D10_PRIMITIVE_TOPOLOGY", [
-       "D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED",
-       "D3D10_PRIMITIVE_TOPOLOGY_POINTLIST",
-       "D3D10_PRIMITIVE_TOPOLOGY_LINELIST",
-       "D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP",
-       "D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST",
-       "D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP",
-       "D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ",
-       "D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ",
-       "D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ",
-       "D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ",
+D3D10_QUERY_MISC_FLAG = Flags(UINT, [
+    "D3D10_QUERY_MISC_PREDICATEHINT",
 ])
 
-D3D10_PRIMITIVE = Enum("D3D10_PRIMITIVE", [
-       "D3D10_PRIMITIVE_UNDEFINED",
-       "D3D10_PRIMITIVE_POINT",
-       "D3D10_PRIMITIVE_LINE",
-       "D3D10_PRIMITIVE_TRIANGLE",
-       "D3D10_PRIMITIVE_LINE_ADJ",
-       "D3D10_PRIMITIVE_TRIANGLE_ADJ",
+D3D10_QUERY_DESC = Struct("D3D10_QUERY_DESC", [
+    (D3D10_QUERY, "Query"),
+    (D3D10_QUERY_MISC_FLAG, "MiscFlags"),
 ])
 
 D3D10_RECT = Alias("D3D10_RECT", RECT)
@@ -581,42 +613,21 @@ D3D10_MAPPED_TEXTURE3D = Struct("D3D10_MAPPED_TEXTURE3D", [
     (UINT, "DepthPitch"),
 ])
 
-D3D10_CPU_ACCESS_FLAG = Enum("D3D10_CPU_ACCESS_FLAG", [
-    "D3D10_CPU_ACCESS_WRITE",
-    "D3D10_CPU_ACCESS_READ",
-])
-
-D3D10_RESOURCE_MISC_FLAG = Enum("D3D10_RESOURCE_MISC_FLAG", [
-    "D3D10_RESOURCE_MISC_GENERATE_MIPS",
-    "D3D10_RESOURCE_MISC_SHARED",
-    "D3D10_RESOURCE_MISC_TEXTURECUBE",
-    "D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX",
-    "D3D10_RESOURCE_MISC_GDI_COMPATIBLE",
-])
-
-D3D10_MAP_FLAG = Enum("D3D10_MAP_FLAG", [
+D3D10_MAP_FLAG = Flags(UINT, [
     "D3D10_MAP_FLAG_DO_NOT_WAIT",
 ])
 
-D3D10_CLEAR_FLAG = Enum("D3D10_CLEAR_FLAG", [
+D3D10_CLEAR_FLAG = Flags(UINT, [
     "D3D10_CLEAR_DEPTH",
     "D3D10_CLEAR_STENCIL",
 ])
 
-D3D10_COLOR_WRITE_ENABLE = Enum("D3D10_COLOR_WRITE_ENABLE", [
-    "D3D10_COLOR_WRITE_ENABLE_RED",
-    "D3D10_COLOR_WRITE_ENABLE_GREEN",
-    "D3D10_COLOR_WRITE_ENABLE_BLUE",
-    "D3D10_COLOR_WRITE_ENABLE_ALPHA",
+D3D10_COLOR_WRITE_ENABLE = Flags(UINT, [
     "D3D10_COLOR_WRITE_ENABLE_ALL",
     "D3D10_COLOR_WRITE_ENABLE_RED",
-    "|",
     "D3D10_COLOR_WRITE_ENABLE_GREEN",
-    "|",
     "D3D10_COLOR_WRITE_ENABLE_BLUE",
-    "|",
     "D3D10_COLOR_WRITE_ENABLE_ALPHA",
-    ")",
 ])
 
 D3D10_TEXTURECUBE_FACE = Enum("D3D10_TEXTURECUBE_FACE", [
@@ -628,7 +639,7 @@ D3D10_TEXTURECUBE_FACE = Enum("D3D10_TEXTURECUBE_FACE", [
     "D3D10_TEXTURECUBE_FACE_NEGATIVE_Z",
 ])
 
-D3D10_ASYNC_GETDATA_FLAG = Enum("D3D10_ASYNC_GETDATA_FLAG", [
+D3D10_ASYNC_GETDATA_FLAG = Flags(UINT, [
     "D3D10_ASYNC_GETDATA_DONOTFLUSH",
 ])
 
@@ -637,10 +648,6 @@ D3D10_FILTER_TYPE = Enum("D3D10_FILTER_TYPE", [
     "D3D10_FILTER_TYPE_LINEAR",
 ])
 
-D3D10_QUERY_MISC_FLAG = Enum("D3D10_QUERY_MISC_FLAG", [
-    "D3D10_QUERY_MISC_PREDICATEHINT",
-])
-
 D3D10_QUERY_DATA_TIMESTAMP_DISJOINT = Struct("D3D10_QUERY_DATA_TIMESTAMP_DISJOINT", [
     (UINT64, "Frequency"),
     (BOOL, "Disjoint"),
@@ -662,7 +669,7 @@ D3D10_QUERY_DATA_SO_STATISTICS = Struct("D3D10_QUERY_DATA_SO_STATISTICS", [
     (UINT64, "PrimitivesStorageNeeded"),
 ])
 
-D3D10_CREATE_DEVICE_FLAG = Enum("D3D10_CREATE_DEVICE_FLAG", [
+D3D10_CREATE_DEVICE_FLAG = Flags(UINT, [
     "D3D10_CREATE_DEVICE_SINGLETHREADED",
     "D3D10_CREATE_DEVICE_DEBUG",
     "D3D10_CREATE_DEVICE_SWITCH_TO_REF",
@@ -672,6 +679,10 @@ D3D10_CREATE_DEVICE_FLAG = Enum("D3D10_CREATE_DEVICE_FLAG", [
     "D3D10_CREATE_DEVICE_STRICT_VALIDATION",
 ])
 
+D3D10_RAISE_FLAG = Flags(UINT, [
+    "D3D10_RAISE_FLAG_DRIVER_INTERNAL_ERROR",
+])
+
 ID3D10DeviceChild = Interface("ID3D10DeviceChild", IUnknown)
 ID3D10Resource = Interface("ID3D10Resource", ID3D10DeviceChild)
 ID3D10Buffer = Interface("ID3D10Buffer", ID3D10Resource)
@@ -698,206 +709,199 @@ ID3D10Device = Interface("ID3D10Device", IUnknown)
 ID3D10Multithread = Interface("ID3D10Multithread", IUnknown)
 
 ID3D10DeviceChild.methods += [
-    Method(Void, "GetDevice", [Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]),
-    Method(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")]),
-    Method(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaquePointer(Const(Void)), "pData")]),
-    Method(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")]),
+    Method(Void, "GetDevice", [Out(Pointer(ObjPointer(ID3D10Device)), "ppDevice")]),
+    Method(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")], sideeffects=False),
+    Method(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")], sideeffects=False),
+    Method(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")], sideeffects=False),
 ]
 
 ID3D10Resource.methods += [
-    Method(Void, "GetType", [Out(Pointer(D3D10_RESOURCE_DIMENSION), "rType")]),
+    Method(Void, "GetType", [Out(Pointer(D3D10_RESOURCE_DIMENSION), "rType")], sideeffects=False),
     Method(Void, "SetEvictionPriority", [(UINT, "EvictionPriority")]),
-    Method(UINT, "GetEvictionPriority", []),
+    Method(UINT, "GetEvictionPriority", [], sideeffects=False),
 ]
 
 ID3D10Buffer.methods += [
-    Method(HRESULT, "Map", [(D3D10_MAP, "MapType"), (UINT, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]),
+    Method(HRESULT, "Map", [(D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]),
     Method(Void, "Unmap", []),
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_BUFFER_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_BUFFER_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10Texture1D.methods += [
-    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (UINT, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]),
+    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(OpaquePointer(Void)), "ppData")]),
     Method(Void, "Unmap", [(UINT, "Subresource")]),
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE1D_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE1D_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10Texture2D.methods += [
-    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (UINT, "MapFlags"), Out(Pointer(D3D10_MAPPED_TEXTURE2D), "pMappedTex2D")]),
+    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(D3D10_MAPPED_TEXTURE2D), "pMappedTex2D")]),
     Method(Void, "Unmap", [(UINT, "Subresource")]),
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE2D_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE2D_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10Texture3D.methods += [
-    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (UINT, "MapFlags"), Out(Pointer(D3D10_MAPPED_TEXTURE3D), "pMappedTex3D")]),
+    Method(HRESULT, "Map", [(UINT, "Subresource"), (D3D10_MAP, "MapType"), (D3D10_MAP_FLAG, "MapFlags"), Out(Pointer(D3D10_MAPPED_TEXTURE3D), "pMappedTex3D")]),
     Method(Void, "Unmap", [(UINT, "Subresource")]),
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE3D_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_TEXTURE3D_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10View.methods += [
-    Method(Void, "GetResource", [Out(Pointer(Pointer(ID3D10Resource)), "ppResource")]),
+    Method(Void, "GetResource", [Out(Pointer(ObjPointer(ID3D10Resource)), "ppResource")]),
 ]
 
 ID3D10DepthStencilView.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_DEPTH_STENCIL_VIEW_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_DEPTH_STENCIL_VIEW_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10RenderTargetView.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_RENDER_TARGET_VIEW_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_RENDER_TARGET_VIEW_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10ShaderResourceView.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_SHADER_RESOURCE_VIEW_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_SHADER_RESOURCE_VIEW_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10BlendState.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_BLEND_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_BLEND_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10DepthStencilState.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_DEPTH_STENCIL_DESC), "pDesc")]),
-]
-
-ID3D10GeometryShader.methods += [
-]
-
-ID3D10InputLayout.methods += [
-]
-
-ID3D10PixelShader.methods += [
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_DEPTH_STENCIL_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10RasterizerState.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_RASTERIZER_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_RASTERIZER_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10SamplerState.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_SAMPLER_DESC), "pDesc")]),
-]
-
-ID3D10VertexShader.methods += [
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_SAMPLER_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10Asynchronous.methods += [
     Method(Void, "Begin", []),
     Method(Void, "End", []),
-    Method(HRESULT, "GetData", [Out(Blob(Void, "DataSize"), "pData"), (UINT, "DataSize"), (UINT, "GetDataFlags")]),
-    Method(UINT, "GetDataSize", []),
+    Method(HRESULT, "GetData", [Out(Blob(Void, "DataSize"), "pData"), (UINT, "DataSize"), (D3D10_ASYNC_GETDATA_FLAG, "GetDataFlags")], sideeffects=False),
+    Method(UINT, "GetDataSize", [], sideeffects=False),
 ]
 
 ID3D10Counter.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_COUNTER_DESC), "pDesc")]),
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_COUNTER_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10Query.methods += [
-    Method(Void, "GetDesc", [Out(Pointer(D3D10_QUERY_DESC), "pDesc")]),
-]
-
-ID3D10Predicate.methods += [
+    Method(Void, "GetDesc", [Out(Pointer(D3D10_QUERY_DESC), "pDesc")], sideeffects=False),
 ]
 
 ID3D10Device.methods += [
-    Method(Void, "VSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(OpaquePointer(ID3D10Buffer)), "NumBuffers"), "ppConstantBuffers")]),
-    Method(Void, "PSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(OpaquePointer(ID3D10ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
-    Method(Void, "PSSetShader", [(Pointer(ID3D10PixelShader), "pPixelShader")]),
-    Method(Void, "PSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(OpaquePointer(ID3D10SamplerState)), "NumSamplers"), "ppSamplers")]),
-    Method(Void, "VSSetShader", [(Pointer(ID3D10VertexShader), "pVertexShader")]),
+    Method(Void, "VSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D10Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    Method(Void, "PSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D10ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    Method(Void, "PSSetShader", [(ObjPointer(ID3D10PixelShader), "pPixelShader")]),
+    Method(Void, "PSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D10SamplerState)), "NumSamplers"), "ppSamplers")]),
+    Method(Void, "VSSetShader", [(ObjPointer(ID3D10VertexShader), "pVertexShader")]),
     Method(Void, "DrawIndexed", [(UINT, "IndexCount"), (UINT, "StartIndexLocation"), (INT, "BaseVertexLocation")]),
     Method(Void, "Draw", [(UINT, "VertexCount"), (UINT, "StartVertexLocation")]),
-    Method(Void, "PSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(OpaquePointer(ID3D10Buffer)), "NumBuffers"), "ppConstantBuffers")]),
-    Method(Void, "IASetInputLayout", [(Pointer(ID3D10InputLayout), "pInputLayout")]),
-    Method(Void, "IASetVertexBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(OpaquePointer(ID3D10Buffer)), "NumBuffers"), "ppVertexBuffers"), (Array(Const(UINT), "NumBuffers"), "pStrides"), (Array(Const(UINT), "NumBuffers"), "pOffsets")]),
-    Method(Void, "IASetIndexBuffer", [(OpaquePointer(ID3D10Buffer), "pIndexBuffer"), (DXGI_FORMAT, "Format"), (UINT, "Offset")]),
+    Method(Void, "PSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D10Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    Method(Void, "IASetInputLayout", [(ObjPointer(ID3D10InputLayout), "pInputLayout")]),
+    Method(Void, "IASetVertexBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D10Buffer)), "NumBuffers"), "ppVertexBuffers"), (Array(Const(UINT), "NumBuffers"), "pStrides"), (Array(Const(UINT), "NumBuffers"), "pOffsets")]),
+    Method(Void, "IASetIndexBuffer", [(ObjPointer(ID3D10Buffer), "pIndexBuffer"), (DXGI_FORMAT, "Format"), (UINT, "Offset")]),
     Method(Void, "DrawIndexedInstanced", [(UINT, "IndexCountPerInstance"), (UINT, "InstanceCount"), (UINT, "StartIndexLocation"), (INT, "BaseVertexLocation"), (UINT, "StartInstanceLocation")]),
     Method(Void, "DrawInstanced", [(UINT, "VertexCountPerInstance"), (UINT, "InstanceCount"), (UINT, "StartVertexLocation"), (UINT, "StartInstanceLocation")]),
-    Method(Void, "GSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(OpaquePointer(ID3D10Buffer)), "NumBuffers"), "ppConstantBuffers")]),
-    Method(Void, "GSSetShader", [(Pointer(ID3D10GeometryShader), "pShader")]),
+    Method(Void, "GSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D10Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    Method(Void, "GSSetShader", [(ObjPointer(ID3D10GeometryShader), "pShader")]),
     Method(Void, "IASetPrimitiveTopology", [(D3D10_PRIMITIVE_TOPOLOGY, "Topology")]),
-    Method(Void, "VSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(OpaquePointer(ID3D10ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
-    Method(Void, "VSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(OpaquePointer(ID3D10SamplerState)), "NumSamplers"), "ppSamplers")]),
-    Method(Void, "SetPredication", [(Pointer(ID3D10Predicate), "pPredicate"), (BOOL, "PredicateValue")]),
-    Method(Void, "GSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(OpaquePointer(ID3D10ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
-    Method(Void, "GSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(OpaquePointer(ID3D10SamplerState)), "NumSamplers"), "ppSamplers")]),
-    Method(Void, "OMSetRenderTargets", [(UINT, "NumViews"), (Array(Const(OpaquePointer(ID3D10RenderTargetView)), "NumViews"), "ppRenderTargetViews"), (Pointer(ID3D10DepthStencilView), "pDepthStencilView")]),
-    Method(Void, "OMSetBlendState", [(Pointer(ID3D10BlendState), "pBlendState"), (Array(Const(FLOAT), 4), "BlendFactor"), (UINT, "SampleMask")]),
-    Method(Void, "OMSetDepthStencilState", [(Pointer(ID3D10DepthStencilState), "pDepthStencilState"), (UINT, "StencilRef")]),
-    Method(Void, "SOSetTargets", [(UINT, "NumBuffers"), (Array(Const(OpaquePointer(ID3D10Buffer)), "NumBuffers"), "ppSOTargets"), (Array(Const(UINT), "NumBuffers"), "pOffsets")]),
+    Method(Void, "VSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D10ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    Method(Void, "VSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D10SamplerState)), "NumSamplers"), "ppSamplers")]),
+    Method(Void, "SetPredication", [(ObjPointer(ID3D10Predicate), "pPredicate"), (BOOL, "PredicateValue")]),
+    Method(Void, "GSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D10ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    Method(Void, "GSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D10SamplerState)), "NumSamplers"), "ppSamplers")]),
+    Method(Void, "OMSetRenderTargets", [(UINT, "NumViews"), (Array(Const(ObjPointer(ID3D10RenderTargetView)), "NumViews"), "ppRenderTargetViews"), (ObjPointer(ID3D10DepthStencilView), "pDepthStencilView")]),
+    Method(Void, "OMSetBlendState", [(ObjPointer(ID3D10BlendState), "pBlendState"), (Array(Const(FLOAT), 4), "BlendFactor"), (UINT, "SampleMask")]),
+    Method(Void, "OMSetDepthStencilState", [(ObjPointer(ID3D10DepthStencilState), "pDepthStencilState"), (UINT, "StencilRef")]),
+    Method(Void, "SOSetTargets", [(UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D10Buffer)), "NumBuffers"), "ppSOTargets"), (Array(Const(UINT), "NumBuffers"), "pOffsets")]),
     Method(Void, "DrawAuto", []),
-    Method(Void, "RSSetState", [(Pointer(ID3D10RasterizerState), "pRasterizerState")]),
+    Method(Void, "RSSetState", [(ObjPointer(ID3D10RasterizerState), "pRasterizerState")]),
     Method(Void, "RSSetViewports", [(UINT, "NumViewports"), (Array(Const(D3D10_VIEWPORT), "NumViewports"), "pViewports")]),
     Method(Void, "RSSetScissorRects", [(UINT, "NumRects"), (Array(Const(D3D10_RECT), "NumRects"), "pRects")]),
-    Method(Void, "CopySubresourceRegion", [(Pointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (UINT, "DstX"), (UINT, "DstY"), (UINT, "DstZ"), (Pointer(ID3D10Resource), "pSrcResource"), (UINT, "SrcSubresource"), (Pointer(Const(D3D10_BOX)), "pSrcBox")]),
-    Method(Void, "CopyResource", [(Pointer(ID3D10Resource), "pDstResource"), (Pointer(ID3D10Resource), "pSrcResource")]),
-    Method(Void, "UpdateSubresource", [(Pointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D10_BOX)), "pDstBox"), (OpaquePointer(Const(Void)), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch")]),
-    Method(Void, "ClearRenderTargetView", [(OpaquePointer(ID3D10RenderTargetView), "pRenderTargetView"), (Array(Const(FLOAT), 4), "ColorRGBA")]),
-    Method(Void, "ClearDepthStencilView", [(Pointer(ID3D10DepthStencilView), "pDepthStencilView"), (UINT, "ClearFlags"), (FLOAT, "Depth"), (UINT8, "Stencil")]),
-    Method(Void, "GenerateMips", [(OpaquePointer(ID3D10ShaderResourceView), "pShaderResourceView")]),
-    Method(Void, "ResolveSubresource", [(Pointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(ID3D10Resource), "pSrcResource"), (UINT, "SrcSubresource"), (DXGI_FORMAT, "Format")]),
-    Method(Void, "VSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(OpaquePointer(ID3D10Buffer), "NumBuffers"), "ppConstantBuffers")]),
-    Method(Void, "PSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), Out(Array(OpaquePointer(ID3D10ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
-    Method(Void, "PSGetShader", [Out(Pointer(Pointer(ID3D10PixelShader)), "ppPixelShader")]),
-    Method(Void, "PSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), Out(Array(OpaquePointer(ID3D10SamplerState), "NumSamplers"), "ppSamplers")]),
-    Method(Void, "VSGetShader", [Out(Pointer(Pointer(ID3D10VertexShader)), "ppVertexShader")]),
-    Method(Void, "PSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(OpaquePointer(ID3D10Buffer), "NumBuffers"), "ppConstantBuffers")]),
-    Method(Void, "IAGetInputLayout", [Out(Pointer(Pointer(ID3D10InputLayout)), "ppInputLayout")]),
-    Method(Void, "IAGetVertexBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(OpaquePointer(ID3D10Buffer), "NumBuffers"), "ppVertexBuffers"), Out(Array(UINT, "NumBuffers"), "pStrides"), Out(Array(UINT, "NumBuffers"), "pOffsets")]),
-    Method(Void, "IAGetIndexBuffer", [Out(Pointer(OpaquePointer(ID3D10Buffer)), "pIndexBuffer"), Out(Pointer(DXGI_FORMAT), "Format"), Out(Pointer(UINT), "Offset")]),
-    Method(Void, "GSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(OpaquePointer(ID3D10Buffer), "NumBuffers"), "ppConstantBuffers")]),
-    Method(Void, "GSGetShader", [Out(Pointer(Pointer(ID3D10GeometryShader)), "ppGeometryShader")]),
-    Method(Void, "IAGetPrimitiveTopology", [Out(Pointer(D3D10_PRIMITIVE_TOPOLOGY), "pTopology")]),
-    Method(Void, "VSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), Out(Array(OpaquePointer(ID3D10ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
-    Method(Void, "VSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), Out(Array(OpaquePointer(ID3D10SamplerState), "NumSamplers"), "ppSamplers")]),
-    Method(Void, "GetPredication", [Out(Pointer(Pointer(ID3D10Predicate)), "ppPredicate"), Out(Pointer(BOOL), "pPredicateValue")]),
-    Method(Void, "GSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), Out(Array(OpaquePointer(ID3D10ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
-    Method(Void, "GSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), Out(Array(OpaquePointer(ID3D10SamplerState), "NumSamplers"), "ppSamplers")]),
-    Method(Void, "OMGetRenderTargets", [(UINT, "NumViews"), Out(Array(OpaquePointer(ID3D10RenderTargetView), "NumViews"), "ppRenderTargetViews"), Out(Pointer(Pointer(ID3D10DepthStencilView)), "ppDepthStencilView")]),
-    Method(Void, "OMGetBlendState", [Out(Pointer(Pointer(ID3D10BlendState)), "ppBlendState"), Out(Array(FLOAT, 4), "BlendFactor"), Out(Pointer(UINT), "pSampleMask")]),
-    Method(Void, "OMGetDepthStencilState", [Out(Pointer(Pointer(ID3D10DepthStencilState)), "ppDepthStencilState"), Out(Pointer(UINT), "pStencilRef")]),
-    Method(Void, "SOGetTargets", [(UINT, "NumBuffers"), Out(Array(OpaquePointer(ID3D10Buffer), "NumBuffers"), "ppSOTargets"), Out(Array(UINT, "NumBuffers"), "pOffsets")]),
-    Method(Void, "RSGetState", [Out(Pointer(Pointer(ID3D10RasterizerState)), "ppRasterizerState")]),
-    Method(Void, "RSGetViewports", [Out(Pointer(UINT), "NumViewports"), Out(Array(D3D10_VIEWPORT, "*NumViewports"), "pViewports")]),
-    Method(Void, "RSGetScissorRects", [Out(Pointer(UINT), "NumRects"), Out(Array(D3D10_RECT, "*NumRects"), "pRects")]),
-    Method(HRESULT, "GetDeviceRemovedReason", []),
-    Method(HRESULT, "SetExceptionMode", [(UINT, "RaiseFlags")]),
-    Method(UINT, "GetExceptionMode", []),
-    Method(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")]),
-    Method(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaquePointer(Const(Void)), "pData")]),
-    Method(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")]),
+    Method(Void, "CopySubresourceRegion", [(ObjPointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (UINT, "DstX"), (UINT, "DstY"), (UINT, "DstZ"), (ObjPointer(ID3D10Resource), "pSrcResource"), (UINT, "SrcSubresource"), (Pointer(Const(D3D10_BOX)), "pSrcBox")]),
+    Method(Void, "CopyResource", [(ObjPointer(ID3D10Resource), "pDstResource"), (ObjPointer(ID3D10Resource), "pSrcResource")]),
+    Method(Void, "UpdateSubresource", [(ObjPointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D10_BOX)), "pDstBox"), (OpaquePointer(Const(Void)), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch")]),
+    Method(Void, "ClearRenderTargetView", [(ObjPointer(ID3D10RenderTargetView), "pRenderTargetView"), (Array(Const(FLOAT), 4), "ColorRGBA")]),
+    Method(Void, "ClearDepthStencilView", [(ObjPointer(ID3D10DepthStencilView), "pDepthStencilView"), (D3D10_CLEAR_FLAG, "ClearFlags"), (FLOAT, "Depth"), (UINT8, "Stencil")]),
+    Method(Void, "GenerateMips", [(ObjPointer(ID3D10ShaderResourceView), "pShaderResourceView")]),
+    Method(Void, "ResolveSubresource", [(ObjPointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (ObjPointer(ID3D10Resource), "pSrcResource"), (UINT, "SrcSubresource"), (DXGI_FORMAT, "Format")]),
+    Method(Void, "VSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D10Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    Method(Void, "PSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), Out(Array(ObjPointer(ID3D10ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    Method(Void, "PSGetShader", [Out(Pointer(ObjPointer(ID3D10PixelShader)), "ppPixelShader")]),
+    Method(Void, "PSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), Out(Array(ObjPointer(ID3D10SamplerState), "NumSamplers"), "ppSamplers")]),
+    Method(Void, "VSGetShader", [Out(Pointer(ObjPointer(ID3D10VertexShader)), "ppVertexShader")]),
+    Method(Void, "PSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D10Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    Method(Void, "IAGetInputLayout", [Out(Pointer(ObjPointer(ID3D10InputLayout)), "ppInputLayout")]),
+    Method(Void, "IAGetVertexBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D10Buffer), "NumBuffers"), "ppVertexBuffers"), Out(Array(UINT, "NumBuffers"), "pStrides"), Out(Array(UINT, "NumBuffers"), "pOffsets")]),
+    Method(Void, "IAGetIndexBuffer", [Out(Pointer(ObjPointer(ID3D10Buffer)), "pIndexBuffer"), Out(Pointer(DXGI_FORMAT), "Format"), Out(Pointer(UINT), "Offset")]),
+    Method(Void, "GSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D10Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    Method(Void, "GSGetShader", [Out(Pointer(ObjPointer(ID3D10GeometryShader)), "ppGeometryShader")]),
+    Method(Void, "IAGetPrimitiveTopology", [Out(Pointer(D3D10_PRIMITIVE_TOPOLOGY), "pTopology")], sideeffects=False),
+    Method(Void, "VSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), Out(Array(ObjPointer(ID3D10ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    Method(Void, "VSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), Out(Array(ObjPointer(ID3D10SamplerState), "NumSamplers"), "ppSamplers")]),
+    Method(Void, "GetPredication", [Out(Pointer(ObjPointer(ID3D10Predicate)), "ppPredicate"), Out(Pointer(BOOL), "pPredicateValue")]),
+    Method(Void, "GSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), Out(Array(ObjPointer(ID3D10ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    Method(Void, "GSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), Out(Array(ObjPointer(ID3D10SamplerState), "NumSamplers"), "ppSamplers")]),
+    Method(Void, "OMGetRenderTargets", [(UINT, "NumViews"), Out(Array(ObjPointer(ID3D10RenderTargetView), "NumViews"), "ppRenderTargetViews"), Out(Pointer(ObjPointer(ID3D10DepthStencilView)), "ppDepthStencilView")]),
+    Method(Void, "OMGetBlendState", [Out(Pointer(ObjPointer(ID3D10BlendState)), "ppBlendState"), Out(Array(FLOAT, 4), "BlendFactor"), Out(Pointer(UINT), "pSampleMask")]),
+    Method(Void, "OMGetDepthStencilState", [Out(Pointer(ObjPointer(ID3D10DepthStencilState)), "ppDepthStencilState"), Out(Pointer(UINT), "pStencilRef")]),
+    Method(Void, "SOGetTargets", [(UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D10Buffer), "NumBuffers"), "ppSOTargets"), Out(Array(UINT, "NumBuffers"), "pOffsets")]),
+    Method(Void, "RSGetState", [Out(Pointer(ObjPointer(ID3D10RasterizerState)), "ppRasterizerState")]),
+    Method(Void, "RSGetViewports", [Out(Pointer(UINT), "NumViewports"), Out(Array(D3D10_VIEWPORT, "*NumViewports"), "pViewports")], sideeffects=False),
+    Method(Void, "RSGetScissorRects", [Out(Pointer(UINT), "NumRects"), Out(Array(D3D10_RECT, "*NumRects"), "pRects")], sideeffects=False),
+    Method(HRESULT, "GetDeviceRemovedReason", [], sideeffects=False),
+    Method(HRESULT, "SetExceptionMode", [(D3D10_RAISE_FLAG, "RaiseFlags")]),
+    Method(D3D10_RAISE_FLAG, "GetExceptionMode", [], sideeffects=False),
+    Method(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")], sideeffects=False),
+    Method(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")], sideeffects=False),
+    Method(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")], sideeffects=False),
     Method(Void, "ClearState", []),
     Method(Void, "Flush", []),
-    Method(HRESULT, "CreateBuffer", [(Pointer(Const(D3D10_BUFFER_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(OpaquePointer(ID3D10Buffer)), "ppBuffer")]),
-    Method(HRESULT, "CreateTexture1D", [(Pointer(Const(D3D10_TEXTURE1D_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(Pointer(ID3D10Texture1D)), "ppTexture1D")]),
-    Method(HRESULT, "CreateTexture2D", [(Pointer(Const(D3D10_TEXTURE2D_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(Pointer(ID3D10Texture2D)), "ppTexture2D")]),
-    Method(HRESULT, "CreateTexture3D", [(Pointer(Const(D3D10_TEXTURE3D_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(Pointer(ID3D10Texture3D)), "ppTexture3D")]),
-    Method(HRESULT, "CreateShaderResourceView", [(Pointer(ID3D10Resource), "pResource"), (Pointer(Const(D3D10_SHADER_RESOURCE_VIEW_DESC)), "pDesc"), Out(Pointer(OpaquePointer(ID3D10ShaderResourceView)), "ppSRView")]),
-    Method(HRESULT, "CreateRenderTargetView", [(Pointer(ID3D10Resource), "pResource"), (Pointer(Const(D3D10_RENDER_TARGET_VIEW_DESC)), "pDesc"), Out(Pointer(OpaquePointer(ID3D10RenderTargetView)), "ppRTView")]),
-    Method(HRESULT, "CreateDepthStencilView", [(Pointer(ID3D10Resource), "pResource"), (Pointer(Const(D3D10_DEPTH_STENCIL_VIEW_DESC)), "pDesc"), Out(Pointer(Pointer(ID3D10DepthStencilView)), "ppDepthStencilView")]),
-    Method(HRESULT, "CreateInputLayout", [(Pointer(Const(D3D10_INPUT_ELEMENT_DESC)), "pInputElementDescs"), (UINT, "NumElements"), (Blob(Const(Void), "BytecodeLength"), "pShaderBytecodeWithInputSignature"), (SIZE_T, "BytecodeLength"), Out(Pointer(Pointer(ID3D10InputLayout)), "ppInputLayout")]),
-    Method(HRESULT, "CreateVertexShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(Pointer(ID3D10VertexShader)), "ppVertexShader")]),
-    Method(HRESULT, "CreateGeometryShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(Pointer(ID3D10GeometryShader)), "ppGeometryShader")]),
-    Method(HRESULT, "CreateGeometryShaderWithStreamOutput", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (Pointer(Const(D3D10_SO_DECLARATION_ENTRY)), "pSODeclaration"), (UINT, "NumEntries"), (UINT, "OutputStreamStride"), Out(Pointer(Pointer(ID3D10GeometryShader)), "ppGeometryShader")]),
-    Method(HRESULT, "CreatePixelShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(Pointer(ID3D10PixelShader)), "ppPixelShader")]),
-    Method(HRESULT, "CreateBlendState", [(Pointer(Const(D3D10_BLEND_DESC)), "pBlendStateDesc"), Out(Pointer(Pointer(ID3D10BlendState)), "ppBlendState")]),
-    Method(HRESULT, "CreateDepthStencilState", [(Pointer(Const(D3D10_DEPTH_STENCIL_DESC)), "pDepthStencilDesc"), Out(Pointer(Pointer(ID3D10DepthStencilState)), "ppDepthStencilState")]),
-    Method(HRESULT, "CreateRasterizerState", [(Pointer(Const(D3D10_RASTERIZER_DESC)), "pRasterizerDesc"), Out(Pointer(Pointer(ID3D10RasterizerState)), "ppRasterizerState")]),
-    Method(HRESULT, "CreateSamplerState", [(Pointer(Const(D3D10_SAMPLER_DESC)), "pSamplerDesc"), Out(Pointer(OpaquePointer(ID3D10SamplerState)), "ppSamplerState")]),
-    Method(HRESULT, "CreateQuery", [(Pointer(Const(D3D10_QUERY_DESC)), "pQueryDesc"), Out(Pointer(Pointer(ID3D10Query)), "ppQuery")]),
-    Method(HRESULT, "CreatePredicate", [(Pointer(Const(D3D10_QUERY_DESC)), "pPredicateDesc"), Out(Pointer(Pointer(ID3D10Predicate)), "ppPredicate")]),
-    Method(HRESULT, "CreateCounter", [(Pointer(Const(D3D10_COUNTER_DESC)), "pCounterDesc"), Out(Pointer(Pointer(ID3D10Counter)), "ppCounter")]),
-    Method(HRESULT, "CheckFormatSupport", [(DXGI_FORMAT, "Format"), Out(Pointer(UINT), "pFormatSupport")]),
-    Method(HRESULT, "CheckMultisampleQualityLevels", [(DXGI_FORMAT, "Format"), (UINT, "SampleCount"), Out(Pointer(UINT), "pNumQualityLevels")]),
+    Method(HRESULT, "CreateBuffer", [(Pointer(Const(D3D10_BUFFER_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Buffer)), "ppBuffer")]),
+    Method(HRESULT, "CreateTexture1D", [(Pointer(Const(D3D10_TEXTURE1D_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Texture1D)), "ppTexture1D")]),
+    Method(HRESULT, "CreateTexture2D", [(Pointer(Const(D3D10_TEXTURE2D_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Texture2D)), "ppTexture2D")]),
+    Method(HRESULT, "CreateTexture3D", [(Pointer(Const(D3D10_TEXTURE3D_DESC)), "pDesc"), (Pointer(Const(D3D10_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D10Texture3D)), "ppTexture3D")]),
+    Method(HRESULT, "CreateShaderResourceView", [(ObjPointer(ID3D10Resource), "pResource"), (Pointer(Const(D3D10_SHADER_RESOURCE_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D10ShaderResourceView)), "ppSRView")]),
+    Method(HRESULT, "CreateRenderTargetView", [(ObjPointer(ID3D10Resource), "pResource"), (Pointer(Const(D3D10_RENDER_TARGET_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D10RenderTargetView)), "ppRTView")]),
+    Method(HRESULT, "CreateDepthStencilView", [(ObjPointer(ID3D10Resource), "pResource"), (Pointer(Const(D3D10_DEPTH_STENCIL_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D10DepthStencilView)), "ppDepthStencilView")]),
+    Method(HRESULT, "CreateInputLayout", [(Array(Const(D3D10_INPUT_ELEMENT_DESC), "NumElements"), "pInputElementDescs"), (UINT, "NumElements"), (Blob(Const(Void), "BytecodeLength"), "pShaderBytecodeWithInputSignature"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10InputLayout)), "ppInputLayout")]),
+    Method(HRESULT, "CreateVertexShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10VertexShader)), "ppVertexShader")]),
+    Method(HRESULT, "CreateGeometryShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10GeometryShader)), "ppGeometryShader")]),
+    Method(HRESULT, "CreateGeometryShaderWithStreamOutput", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (Array(Const(D3D10_SO_DECLARATION_ENTRY), "NumEntries"), "pSODeclaration"), (UINT, "NumEntries"), (UINT, "OutputStreamStride"), Out(Pointer(ObjPointer(ID3D10GeometryShader)), "ppGeometryShader")]),
+    Method(HRESULT, "CreatePixelShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10PixelShader)), "ppPixelShader")]),
+    Method(HRESULT, "CreateBlendState", [(Pointer(Const(D3D10_BLEND_DESC)), "pBlendStateDesc"), Out(Pointer(ObjPointer(ID3D10BlendState)), "ppBlendState")]),
+    Method(HRESULT, "CreateDepthStencilState", [(Pointer(Const(D3D10_DEPTH_STENCIL_DESC)), "pDepthStencilDesc"), Out(Pointer(ObjPointer(ID3D10DepthStencilState)), "ppDepthStencilState")]),
+    Method(HRESULT, "CreateRasterizerState", [(Pointer(Const(D3D10_RASTERIZER_DESC)), "pRasterizerDesc"), Out(Pointer(ObjPointer(ID3D10RasterizerState)), "ppRasterizerState")]),
+    Method(HRESULT, "CreateSamplerState", [(Pointer(Const(D3D10_SAMPLER_DESC)), "pSamplerDesc"), Out(Pointer(ObjPointer(ID3D10SamplerState)), "ppSamplerState")]),
+    Method(HRESULT, "CreateQuery", [(Pointer(Const(D3D10_QUERY_DESC)), "pQueryDesc"), Out(Pointer(ObjPointer(ID3D10Query)), "ppQuery")]),
+    Method(HRESULT, "CreatePredicate", [(Pointer(Const(D3D10_QUERY_DESC)), "pPredicateDesc"), Out(Pointer(ObjPointer(ID3D10Predicate)), "ppPredicate")]),
+    Method(HRESULT, "CreateCounter", [(Pointer(Const(D3D10_COUNTER_DESC)), "pCounterDesc"), Out(Pointer(ObjPointer(ID3D10Counter)), "ppCounter")]),
+    Method(HRESULT, "CheckFormatSupport", [(DXGI_FORMAT, "Format"), Out(Pointer(D3D10_FORMAT_SUPPORT), "pFormatSupport")], sideeffects=False),
+    Method(HRESULT, "CheckMultisampleQualityLevels", [(DXGI_FORMAT, "Format"), (UINT, "SampleCount"), Out(Pointer(UINT), "pNumQualityLevels")], sideeffects=False),
     Method(Void, "CheckCounterInfo", [Out(Pointer(D3D10_COUNTER_INFO), "pCounterInfo")]),
-    Method(HRESULT, "CheckCounter", [(Pointer(Const(D3D10_COUNTER_DESC)), "pDesc"), Out(Pointer(D3D10_COUNTER_TYPE), "pType"), Out(Pointer(UINT), "pActiveCounters"), Out(LPSTR, "szName"), Out(Pointer(UINT), "pNameLength"), Out(LPSTR, "szUnits"), Out(Pointer(UINT), "pUnitsLength"), Out(LPSTR, "szDescription"), Out(Pointer(UINT), "pDescriptionLength")]),
-    Method(UINT, "GetCreationFlags", []),
-    Method(HRESULT, "OpenSharedResource", [(HANDLE, "hResource"), (REFIID, "ReturnedInterface"), Out(Pointer(OpaquePointer(Void)), "ppResource")]),
+    Method(HRESULT, "CheckCounter", [(Pointer(Const(D3D10_COUNTER_DESC)), "pDesc"), Out(Pointer(D3D10_COUNTER_TYPE), "pType"), Out(Pointer(UINT), "pActiveCounters"), Out(LPSTR, "szName"), Out(Pointer(UINT), "pNameLength"), Out(LPSTR, "szUnits"), Out(Pointer(UINT), "pUnitsLength"), Out(LPSTR, "szDescription"), Out(Pointer(UINT), "pDescriptionLength")], sideeffects=False),
+    Method(D3D10_CREATE_DEVICE_FLAG, "GetCreationFlags", [], sideeffects=False),
+    Method(HRESULT, "OpenSharedResource", [(HANDLE, "hResource"), (REFIID, "ReturnedInterface"), Out(Pointer(ObjPointer(Void)), "ppResource")]),
     Method(Void, "SetTextFilterSize", [(UINT, "Width"), (UINT, "Height")]),
-    Method(Void, "GetTextFilterSize", [Out(Pointer(UINT), "pWidth"), Out(Pointer(UINT), "pHeight")]),
+    Method(Void, "GetTextFilterSize", [Out(Pointer(UINT), "pWidth"), Out(Pointer(UINT), "pHeight")], sideeffects=False),
 ]
 
 ID3D10Multithread.methods += [
     Method(Void, "Enter", []),
     Method(Void, "Leave", []),
     Method(BOOL, "SetMultithreadProtected", [(BOOL, "bMTProtect")]),
-    Method(BOOL, "GetMultithreadProtected", []),
+    Method(BOOL, "GetMultithreadProtected", [], sideeffects=False),
 ]
 
+
+d3d10 = API("d3d10")
+
+
+from d3d10sdklayers import *
+import d3d10misc
+import d3d10shader
+import d3d10effect
diff --git a/specs/d3d10_1.def b/specs/d3d10_1.def
deleted file mode 100644 (file)
index 48bfe14..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-LIBRARY        "d3d10_1"
-
-EXPORTS
-        D3D10CreateDevice1
-        D3D10CreateDeviceAndSwapChain1
-        D3D10CreateBlob
index ebf28969ae422b44cb69ac8e37809d036049b4c6..5703a2f1ac2997429cfd6e4c1f42c065c622c4cd 100644 (file)
@@ -1,6 +1,6 @@
 ##########################################################################
 #
-# Copyright 2008-2009 VMware, Inc.
+# Copyright 2008-2012 VMware, Inc.
 # All Rights Reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 """d3d10_1.h"""
 
 from winapi import *
-
-ID3D10Blob = Interface("ID3D10Blob", IUnknown)
-LPD3D10BLOB = Pointer(ID3D10Blob)
-
-ID3D10Blob.methods += [
-    Method(LPVOID, "GetBufferPointer", []),
-    Method(SIZE_T, "GetBufferSize", []),
-]
+from d3d10 import *
 
 D3D10_DRIVER_TYPE = Enum("D3D10_DRIVER_TYPE", [
     "D3D10_DRIVER_TYPE_HARDWARE",
@@ -51,27 +44,75 @@ D3D10_FEATURE_LEVEL1 = Enum("D3D10_FEATURE_LEVEL1", [
        "D3D10_FEATURE_LEVEL_9_3",
 ])
 
-# TODO
-IDXGIAdapter = Alias("IDXGIAdapter", Void)
-ID3D10Device1 = Alias("ID3D10Device1", Void)
-IDXGISwapChain = Alias("IDXGISwapChain", Void)
-DXGI_SWAP_CHAIN_DESC = Alias("DXGI_SWAP_CHAIN_DESC", Void)
+D3D10_RENDER_TARGET_BLEND_DESC1 = Struct("D3D10_RENDER_TARGET_BLEND_DESC1", [
+    (BOOL, "BlendEnable"),
+    (D3D10_BLEND, "SrcBlend"),
+    (D3D10_BLEND, "DestBlend"),
+    (D3D10_BLEND_OP, "BlendOp"),
+    (D3D10_BLEND, "SrcBlendAlpha"),
+    (D3D10_BLEND, "DestBlendAlpha"),
+    (D3D10_BLEND_OP, "BlendOpAlpha"),
+    (UINT8, "RenderTargetWriteMask"),
+])
 
-d3d10_1 = Dll("d3d10")
-d3d10_1.functions += [
-    StdFunction(HRESULT, "D3D10CreateDevice1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]),
-    StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain1", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), (OutPointer(Pointer(IDXGISwapChain)), "ppSwapChain"), (OutPointer(Pointer(ID3D10Device1)), "ppDevice")]),
-    StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), (OutPointer(LPD3D10BLOB), "ppBuffer")]),
+D3D10_BLEND_DESC1 = Struct("D3D10_BLEND_DESC1", [
+    (BOOL, "AlphaToCoverageEnable"),
+    (BOOL, "IndependentBlendEnable"),
+    (Array(D3D10_RENDER_TARGET_BLEND_DESC1, "D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT"), "RenderTarget"),
+])
+
+ID3D10BlendState1 = Interface("ID3D10BlendState1", ID3D10BlendState)
+ID3D10BlendState1.methods += [
+    Method(Void, "GetDesc1", [Out(Pointer(D3D10_BLEND_DESC1), "pDesc")]),
 ]
 
-if __name__ == '__main__':
-    print '#include <windows.h>'
-    print '#include <tchar.h>'
-    print
-    print '#include "compat.h"'
-    print
-    print '#include <d3d10_1.h>'
-    print
-    print '#include "trace_writer.hpp"'
-    print
-    wrap()
+D3D10_TEXCUBE_ARRAY_SRV1 = Struct("D3D10_TEXCUBE_ARRAY_SRV1", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+    (UINT, "First2DArrayFace"),
+    (UINT, "NumCubes"),
+])
+
+D3D10_SHADER_RESOURCE_VIEW_DESC1 = Struct("D3D10_SHADER_RESOURCE_VIEW_DESC1", [
+    (DXGI_FORMAT, "Format"),
+    (D3D10_SRV_DIMENSION1, "ViewDimension"),
+    (D3D10_BUFFER_SRV, "Buffer"),
+    (D3D10_TEX1D_SRV, "Texture1D"),
+    (D3D10_TEX1D_ARRAY_SRV, "Texture1DArray"),
+    (D3D10_TEX2D_SRV, "Texture2D"),
+    (D3D10_TEX2D_ARRAY_SRV, "Texture2DArray"),
+    (D3D10_TEX2DMS_SRV, "Texture2DMS"),
+    (D3D10_TEX2DMS_ARRAY_SRV, "Texture2DMSArray"),
+    (D3D10_TEX3D_SRV, "Texture3D"),
+    (D3D10_TEXCUBE_SRV, "TextureCube"),
+    (D3D10_TEXCUBE_ARRAY_SRV1, "TextureCubeArray"),
+])
+
+ID3D10ShaderResourceView1 = Interface("ID3D10ShaderResourceView1", ID3D10ShaderResourceView)
+ID3D10ShaderResourceView1.methods += [
+    Method(Void, "GetDesc1", [Out(Pointer(D3D10_SHADER_RESOURCE_VIEW_DESC1), "pDesc")]),
+]
+
+ID3D10Device1 = Interface("ID3D10Device1", ID3D10Device)
+ID3D10Device1.methods += [
+    Method(HRESULT, "CreateShaderResourceView1", [(ObjPointer(ID3D10Resource), "pResource"), Out(Pointer(Const(D3D10_SHADER_RESOURCE_VIEW_DESC1)), "pDesc"), Out(Pointer(ObjPointer(ID3D10ShaderResourceView1)), "ppSRView")]),
+    Method(HRESULT, "CreateBlendState1", [(Pointer(Const(D3D10_BLEND_DESC1)), "pBlendStateDesc"), Out(Pointer(ObjPointer(ID3D10BlendState1)), "ppBlendState")]),
+    Method(D3D10_FEATURE_LEVEL1, "GetFeatureLevel", []),
+]
+
+d3d10_1 = API("d3d10_1")
+d3d10_1.addFunctions([
+    StdFunction(HRESULT, "D3D10CreateDevice1", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), Out(Pointer(ObjPointer(ID3D10Device1)), "ppDevice")]),
+    StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain1", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (D3D10_FEATURE_LEVEL1, "HardwareLevel"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(ObjPointer(ID3D10Device1)), "ppDevice")]),
+    StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), Out(Pointer(LPD3D10BLOB), "ppBuffer")]),
+])
+
+d3d10_1.addInterfaces([
+    IDXGIAdapter1,
+    IDXGIDevice1,
+    IDXGIResource,
+    ID3D10Debug,
+    ID3D10InfoQueue,
+    ID3D10Multithread,
+    ID3D10SwitchToRef,
+])
diff --git a/specs/d3d10effect.py b/specs/d3d10effect.py
new file mode 100644 (file)
index 0000000..57746aa
--- /dev/null
@@ -0,0 +1,384 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from d3d10 import *
+
+from d3d10shader import *
+
+
+ID3D10StateBlock = Interface("ID3D10StateBlock", IUnknown)
+ID3D10EffectType = Interface("ID3D10EffectType")
+ID3D10EffectVariable = Interface("ID3D10EffectVariable")
+ID3D10EffectScalarVariable = Interface("ID3D10EffectScalarVariable", ID3D10EffectVariable)
+ID3D10EffectVectorVariable = Interface("ID3D10EffectVectorVariable", ID3D10EffectVariable)
+ID3D10EffectMatrixVariable = Interface("ID3D10EffectMatrixVariable", ID3D10EffectVariable)
+ID3D10EffectStringVariable = Interface("ID3D10EffectStringVariable", ID3D10EffectVariable)
+ID3D10EffectShaderResourceVariable = Interface("ID3D10EffectShaderResourceVariable", ID3D10EffectVariable)
+ID3D10EffectRenderTargetViewVariable = Interface("ID3D10EffectRenderTargetViewVariable", ID3D10EffectVariable)
+ID3D10EffectDepthStencilViewVariable = Interface("ID3D10EffectDepthStencilViewVariable", ID3D10EffectVariable)
+ID3D10EffectConstantBuffer = Interface("ID3D10EffectConstantBuffer", ID3D10EffectVariable)
+ID3D10EffectShaderVariable = Interface("ID3D10EffectShaderVariable", ID3D10EffectVariable)
+ID3D10EffectBlendVariable = Interface("ID3D10EffectBlendVariable", ID3D10EffectVariable)
+ID3D10EffectDepthStencilVariable = Interface("ID3D10EffectDepthStencilVariable", ID3D10EffectVariable)
+ID3D10EffectRasterizerVariable = Interface("ID3D10EffectRasterizerVariable", ID3D10EffectVariable)
+ID3D10EffectSamplerVariable = Interface("ID3D10EffectSamplerVariable", ID3D10EffectVariable)
+ID3D10EffectPass = Interface("ID3D10EffectPass")
+ID3D10EffectTechnique = Interface("ID3D10EffectTechnique")
+ID3D10Effect = Interface("ID3D10Effect", IUnknown)
+ID3D10EffectPool = Interface("ID3D10EffectPool", IUnknown)
+
+
+D3D10_DEVICE_STATE_TYPES = Enum("D3D10_DEVICE_STATE_TYPES", [
+    "D3D10_DST_SO_BUFFERS",
+    "D3D10_DST_OM_RENDER_TARGETS",
+    "D3D10_DST_OM_DEPTH_STENCIL_STATE",
+    "D3D10_DST_OM_BLEND_STATE",
+    "D3D10_DST_VS",
+    "D3D10_DST_VS_SAMPLERS",
+    "D3D10_DST_VS_SHADER_RESOURCES",
+    "D3D10_DST_VS_CONSTANT_BUFFERS",
+    "D3D10_DST_GS",
+    "D3D10_DST_GS_SAMPLERS",
+    "D3D10_DST_GS_SHADER_RESOURCES",
+    "D3D10_DST_GS_CONSTANT_BUFFERS",
+    "D3D10_DST_PS",
+    "D3D10_DST_PS_SAMPLERS",
+    "D3D10_DST_PS_SHADER_RESOURCES",
+    "D3D10_DST_PS_CONSTANT_BUFFERS",
+    "D3D10_DST_IA_VERTEX_BUFFERS",
+    "D3D10_DST_IA_INDEX_BUFFER",
+    "D3D10_DST_IA_INPUT_LAYOUT",
+    "D3D10_DST_IA_PRIMITIVE_TOPOLOGY",
+    "D3D10_DST_RS_VIEWPORTS",
+    "D3D10_DST_RS_SCISSOR_RECTS",
+    "D3D10_DST_RS_RASTERIZER_STATE",
+    "D3D10_DST_PREDICATION",
+])
+
+D3D10_STATE_BLOCK_MASK = Struct("D3D10_STATE_BLOCK_MASK", [
+    (BYTE, "VS"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)"), "VSSamplers"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)"), "VSShaderResources"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)"), "VSConstantBuffers"),
+    (BYTE, "GS"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)"), "GSSamplers"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)"), "GSShaderResources"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)"), "GSConstantBuffers"),
+    (BYTE, "PS"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT)"), "PSSamplers"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT)"), "PSShaderResources"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT)"), "PSConstantBuffers"),
+    (Array(BYTE, "D3D10_BYTES_FROM_BITS(D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT)"), "IAVertexBuffers"),
+    (BYTE, "IAIndexBuffer"),
+    (BYTE, "IAInputLayout"),
+    (BYTE, "IAPrimitiveTopology"),
+    (BYTE, "OMRenderTargets"),
+    (BYTE, "OMDepthStencilState"),
+    (BYTE, "OMBlendState"),
+    (BYTE, "RSViewports"),
+    (BYTE, "RSScissorRects"),
+    (BYTE, "RSRasterizerState"),
+    (BYTE, "SOBuffers"),
+    (BYTE, "Predication"),
+])
+
+ID3D10StateBlock.methods += [
+    StdMethod(HRESULT, "Capture", []),
+    StdMethod(HRESULT, "Apply", []),
+    StdMethod(HRESULT, "ReleaseAllDeviceObjects", []),
+    StdMethod(HRESULT, "GetDevice", [Out(Pointer(ObjPointer(ID3D10Device)), "ppDevice")]),
+]
+
+D3D10_EFFECT = Flags(UINT, [
+    "D3D10_EFFECT_COMPILE_CHILD_EFFECT",
+    "D3D10_EFFECT_COMPILE_ALLOW_SLOW_OPS",
+    "D3D10_EFFECT_SINGLE_THREADED",
+    "D3D10_EFFECT_VARIABLE_POOLED",
+    "D3D10_EFFECT_VARIABLE_ANNOTATION",
+    "D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT",
+])
+
+D3D10_EFFECT_TYPE_DESC = Struct("D3D10_EFFECT_TYPE_DESC", [
+    (LPCSTR, "TypeName"),
+    (D3D10_SHADER_VARIABLE_CLASS, "Class"),
+    (D3D10_SHADER_VARIABLE_TYPE, "Type"),
+    (UINT, "Elements"),
+    (UINT, "Members"),
+    (UINT, "Rows"),
+    (UINT, "Columns"),
+    (UINT, "PackedSize"),
+    (UINT, "UnpackedSize"),
+    (UINT, "Stride"),
+])
+
+ID3D10EffectType.methods += [
+    StdMethod(BOOL, "IsValid", []),
+    StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_EFFECT_TYPE_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10EffectType), "GetMemberTypeByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectType), "GetMemberTypeByName", [(LPCSTR, "Name")]),
+    StdMethod(ObjPointer(ID3D10EffectType), "GetMemberTypeBySemantic", [(LPCSTR, "Semantic")]),
+    StdMethod(LPCSTR, "GetMemberName", [(UINT, "Index")]),
+    StdMethod(LPCSTR, "GetMemberSemantic", [(UINT, "Index")]),
+]
+
+D3D10_EFFECT_VARIABLE_DESC = Struct("D3D10_EFFECT_VARIABLE_DESC", [
+    (LPCSTR, "Name"),
+    (LPCSTR, "Semantic"),
+    (UINT, "Flags"),
+    (UINT, "Annotations"),
+    (UINT, "BufferOffset"),
+    (UINT, "ExplicitBindPoint"),
+])
+
+ID3D10EffectVariable.methods += [
+    StdMethod(BOOL, "IsValid", []),
+    StdMethod(ObjPointer(ID3D10EffectType), "GetType", []),
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_EFFECT_VARIABLE_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByName", [(LPCSTR, "Name")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetMemberByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetMemberByName", [(LPCSTR, "Name")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetMemberBySemantic", [(LPCSTR, "Semantic")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetElement", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectConstantBuffer), "GetParentConstantBuffer", []),
+    StdMethod(ObjPointer(ID3D10EffectScalarVariable), "AsScalar", []),
+    StdMethod(ObjPointer(ID3D10EffectVectorVariable), "AsVector", []),
+    StdMethod(ObjPointer(ID3D10EffectMatrixVariable), "AsMatrix", []),
+    StdMethod(ObjPointer(ID3D10EffectStringVariable), "AsString", []),
+    StdMethod(ObjPointer(ID3D10EffectShaderResourceVariable), "AsShaderResource", []),
+    StdMethod(ObjPointer(ID3D10EffectRenderTargetViewVariable), "AsRenderTargetView", []),
+    StdMethod(ObjPointer(ID3D10EffectDepthStencilViewVariable), "AsDepthStencilView", []),
+    StdMethod(ObjPointer(ID3D10EffectConstantBuffer), "AsConstantBuffer", []),
+    StdMethod(ObjPointer(ID3D10EffectShaderVariable), "AsShader", []),
+    StdMethod(ObjPointer(ID3D10EffectBlendVariable), "AsBlend", []),
+    StdMethod(ObjPointer(ID3D10EffectDepthStencilVariable), "AsDepthStencil", []),
+    StdMethod(ObjPointer(ID3D10EffectRasterizerVariable), "AsRasterizer", []),
+    StdMethod(ObjPointer(ID3D10EffectSamplerVariable), "AsSampler", []),
+    StdMethod(HRESULT, "SetRawValue", [(OpaquePointer(Void), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]),
+    StdMethod(HRESULT, "GetRawValue", [Out(OpaquePointer(Void), "pData"), (UINT, "Offset"), (UINT, "ByteCount")]),
+]
+
+ID3D10EffectScalarVariable.methods += [
+    StdMethod(HRESULT, "SetFloat", [(Float, "Value")]),
+    StdMethod(HRESULT, "GetFloat", [Out(Pointer(Float), "pValue")]),
+    StdMethod(HRESULT, "SetFloatArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetFloatArray", [Out(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "SetInt", [(Int, "Value")]),
+    StdMethod(HRESULT, "GetInt", [Out(Pointer(Int), "pValue")]),
+    StdMethod(HRESULT, "SetIntArray", [(Pointer(Int), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetIntArray", [Out(Pointer(Int), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "SetBool", [(BOOL, "Value")]),
+    StdMethod(HRESULT, "GetBool", [Out(Pointer(BOOL), "pValue")]),
+    StdMethod(HRESULT, "SetBoolArray", [(Pointer(BOOL), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetBoolArray", [Out(Pointer(BOOL), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+]
+
+ID3D10EffectVectorVariable.methods += [
+    StdMethod(HRESULT, "SetBoolVector", [(Pointer(BOOL), "pData")]),
+    StdMethod(HRESULT, "SetIntVector", [(Pointer(Int), "pData")]),
+    StdMethod(HRESULT, "SetFloatVector", [(Pointer(Float), "pData")]),
+    StdMethod(HRESULT, "GetBoolVector", [(Pointer(BOOL), "pData")]),
+    StdMethod(HRESULT, "GetIntVector", [(Pointer(Int), "pData")]),
+    StdMethod(HRESULT, "GetFloatVector", [(Pointer(Float), "pData")]),
+    StdMethod(HRESULT, "SetBoolVectorArray", [(Pointer(BOOL), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "SetIntVectorArray", [(Pointer(Int), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "SetFloatVectorArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetBoolVectorArray", [(Pointer(BOOL), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetIntVectorArray", [(Pointer(Int), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetFloatVectorArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+]
+
+ID3D10EffectMatrixVariable.methods += [
+    StdMethod(HRESULT, "SetMatrix", [(Pointer(Float), "pData")]),
+    StdMethod(HRESULT, "GetMatrix", [(Pointer(Float), "pData")]),
+    StdMethod(HRESULT, "SetMatrixArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetMatrixArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "SetMatrixTranspose", [(Pointer(Float), "pData")]),
+    StdMethod(HRESULT, "GetMatrixTranspose", [(Pointer(Float), "pData")]),
+    StdMethod(HRESULT, "SetMatrixTransposeArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetMatrixTransposeArray", [(Pointer(Float), "pData"), (UINT, "Offset"), (UINT, "Count")]),
+]
+
+ID3D10EffectStringVariable.methods += [
+    StdMethod(HRESULT, "GetString", [Out(Pointer(LPCSTR), "ppString")]),
+    StdMethod(HRESULT, "GetStringArray", [Out(Pointer(LPCSTR), "ppStrings"), (UINT, "Offset"), (UINT, "Count")]),
+]
+
+ID3D10EffectShaderResourceVariable.methods += [
+    StdMethod(HRESULT, "SetResource", [(ObjPointer(ID3D10ShaderResourceView), "pResource")]),
+    StdMethod(HRESULT, "GetResource", [Out(Pointer(ObjPointer(ID3D10ShaderResourceView)), "ppResource")]),
+    StdMethod(HRESULT, "SetResourceArray", [(Pointer(ObjPointer(ID3D10ShaderResourceView)), "ppResources"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetResourceArray", [Out(Pointer(ObjPointer(ID3D10ShaderResourceView)), "ppResources"), (UINT, "Offset"), (UINT, "Count")]),
+]
+
+ID3D10EffectRenderTargetViewVariable.methods += [
+    StdMethod(HRESULT, "SetRenderTarget", [(ObjPointer(ID3D10RenderTargetView), "pResource")]),
+    StdMethod(HRESULT, "GetRenderTarget", [Out(Pointer(ObjPointer(ID3D10RenderTargetView)), "ppResource")]),
+    StdMethod(HRESULT, "SetRenderTargetArray", [(Pointer(ObjPointer(ID3D10RenderTargetView)), "ppResources"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetRenderTargetArray", [Out(Pointer(ObjPointer(ID3D10RenderTargetView)), "ppResources"), (UINT, "Offset"), (UINT, "Count")]),
+]
+
+ID3D10EffectDepthStencilViewVariable.methods += [
+    StdMethod(HRESULT, "SetDepthStencil", [(ObjPointer(ID3D10DepthStencilView), "pResource")]),
+    StdMethod(HRESULT, "GetDepthStencil", [Out(Pointer(ObjPointer(ID3D10DepthStencilView)), "ppResource")]),
+    StdMethod(HRESULT, "SetDepthStencilArray", [(Pointer(ObjPointer(ID3D10DepthStencilView)), "ppResources"), (UINT, "Offset"), (UINT, "Count")]),
+    StdMethod(HRESULT, "GetDepthStencilArray", [Out(Pointer(ObjPointer(ID3D10DepthStencilView)), "ppResources"), (UINT, "Offset"), (UINT, "Count")]),
+]
+
+ID3D10EffectConstantBuffer.methods += [
+    StdMethod(HRESULT, "SetConstantBuffer", [(ObjPointer(ID3D10Buffer), "pConstantBuffer")]),
+    StdMethod(HRESULT, "GetConstantBuffer", [Out(Pointer(ObjPointer(ID3D10Buffer)), "ppConstantBuffer")]),
+    StdMethod(HRESULT, "SetTextureBuffer", [(ObjPointer(ID3D10ShaderResourceView), "pTextureBuffer")]),
+    StdMethod(HRESULT, "GetTextureBuffer", [Out(Pointer(ObjPointer(ID3D10ShaderResourceView)), "ppTextureBuffer")]),
+]
+
+D3D10_EFFECT_SHADER_DESC = Struct("D3D10_EFFECT_SHADER_DESC", [
+    (Pointer(Const(BYTE)), "pInputSignature"),
+    (BOOL, "IsInline"),
+    (Pointer(Const(BYTE)), "pBytecode"),
+    (UINT, "BytecodeLength"),
+    (LPCSTR, "SODecl"),
+    (UINT, "NumInputSignatureEntries"),
+    (UINT, "NumOutputSignatureEntries"),
+])
+
+ID3D10EffectShaderVariable.methods += [
+    StdMethod(HRESULT, "GetShaderDesc", [(UINT, "ShaderIndex"), Out(Pointer(D3D10_EFFECT_SHADER_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetVertexShader", [(UINT, "ShaderIndex"), Out(Pointer(ObjPointer(ID3D10VertexShader)), "ppVS")]),
+    StdMethod(HRESULT, "GetGeometryShader", [(UINT, "ShaderIndex"), Out(Pointer(ObjPointer(ID3D10GeometryShader)), "ppGS")]),
+    StdMethod(HRESULT, "GetPixelShader", [(UINT, "ShaderIndex"), Out(Pointer(ObjPointer(ID3D10PixelShader)), "ppPS")]),
+    StdMethod(HRESULT, "GetInputSignatureElementDesc", [(UINT, "ShaderIndex"), (UINT, "Element"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetOutputSignatureElementDesc", [(UINT, "ShaderIndex"), (UINT, "Element"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+]
+
+ID3D10EffectBlendVariable.methods += [
+    StdMethod(HRESULT, "GetBlendState", [(UINT, "Index"), (Pointer(ObjPointer(ID3D10BlendState)), "ppBlendState")]),
+    StdMethod(HRESULT, "GetBackingStore", [(UINT, "Index"), (Pointer(D3D10_BLEND_DESC), "pBlendDesc")]),
+]
+
+ID3D10EffectDepthStencilVariable.methods += [
+    StdMethod(HRESULT, "GetDepthStencilState", [(UINT, "Index"), Out(Pointer(ObjPointer(ID3D10DepthStencilState)), "ppDepthStencilState")]),
+    StdMethod(HRESULT, "GetBackingStore", [(UINT, "Index"), Out(Pointer(D3D10_DEPTH_STENCIL_DESC), "pDepthStencilDesc")]),
+]
+
+ID3D10EffectRasterizerVariable.methods += [
+    StdMethod(HRESULT, "GetRasterizerState", [(UINT, "Index"), Out(Pointer(ObjPointer(ID3D10RasterizerState)), "ppRasterizerState")]),
+    StdMethod(HRESULT, "GetBackingStore", [(UINT, "Index"), Out(Pointer(D3D10_RASTERIZER_DESC), "pRasterizerDesc")]),
+]
+
+ID3D10EffectSamplerVariable.methods += [
+    StdMethod(HRESULT, "GetSampler", [(UINT, "Index"), Out(Pointer(ObjPointer(ID3D10SamplerState)), "ppSampler")]),
+    StdMethod(HRESULT, "GetBackingStore", [(UINT, "Index"), Out(Pointer(D3D10_SAMPLER_DESC), "pSamplerDesc")]),
+]
+
+D3D10_PASS_DESC = Struct("D3D10_PASS_DESC", [
+    (LPCSTR, "Name"),
+    (UINT, "Annotations"),
+    (Pointer(BYTE), "pIAInputSignature"),
+    (SIZE_T, "IAInputSignatureSize"),
+    (UINT, "StencilRef"),
+    (UINT, "SampleMask"),
+    (Array(FLOAT, 4), "BlendFactor"),
+])
+
+D3D10_PASS_SHADER_DESC = Struct("D3D10_PASS_SHADER_DESC", [
+    (ObjPointer(ID3D10EffectShaderVariable), "pShaderVariable"),
+    (UINT, "ShaderIndex"),
+])
+
+ID3D10EffectPass.methods += [
+    StdMethod(BOOL, "IsValid", []),
+    StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_PASS_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetVertexShaderDesc", [(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetGeometryShaderDesc", [(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetPixelShaderDesc", [(Pointer(D3D10_PASS_SHADER_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByName", [(LPCSTR, "Name")]),
+    StdMethod(HRESULT, "Apply", [(UINT, "Flags")]),
+    StdMethod(HRESULT, "ComputeStateBlockMask", [Out(Pointer(D3D10_STATE_BLOCK_MASK), "pStateBlockMask")]),
+]
+
+D3D10_TECHNIQUE_DESC = Struct("D3D10_TECHNIQUE_DESC", [
+    (LPCSTR, "Name"),
+    (UINT, "Passes"),
+    (UINT, "Annotations"),
+])
+
+ID3D10EffectTechnique.methods += [
+    StdMethod(BOOL, "IsValid", []),
+    StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_TECHNIQUE_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetAnnotationByName", [(LPCSTR, "Name")]),
+    StdMethod(ObjPointer(ID3D10EffectPass), "GetPassByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectPass), "GetPassByName", [(LPCSTR, "Name")]),
+    StdMethod(HRESULT, "ComputeStateBlockMask", [Out(Pointer(D3D10_STATE_BLOCK_MASK), "pStateBlockMask")]),
+]
+
+D3D10_EFFECT_DESC = Struct("D3D10_EFFECT_DESC", [
+    (BOOL, "IsChildEffect"),
+    (UINT, "ConstantBuffers"),
+    (UINT, "SharedConstantBuffers"),
+    (UINT, "GlobalVariables"),
+    (UINT, "SharedGlobalVariables"),
+    (UINT, "Techniques"),
+])
+
+ID3D10Effect.methods += [
+    StdMethod(BOOL, "IsValid", []),
+    StdMethod(BOOL, "IsPool", []),
+    StdMethod(HRESULT, "GetDevice", [Out(Pointer(ObjPointer(ID3D10Device)), "ppDevice")]),
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_EFFECT_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10EffectConstantBuffer), "GetConstantBufferByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectConstantBuffer), "GetConstantBufferByName", [(LPCSTR, "Name")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetVariableByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetVariableByName", [(LPCSTR, "Name")]),
+    StdMethod(ObjPointer(ID3D10EffectVariable), "GetVariableBySemantic", [(LPCSTR, "Semantic")]),
+    StdMethod(ObjPointer(ID3D10EffectTechnique), "GetTechniqueByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10EffectTechnique), "GetTechniqueByName", [(LPCSTR, "Name")]),
+    StdMethod(HRESULT, "Optimize", []),
+    StdMethod(BOOL, "IsOptimized", []),
+]
+
+ID3D10EffectPool.methods += [
+    StdMethod(ObjPointer(ID3D10Effect), "AsEffect", []),
+]
+
+
+d3d10.addFunctions([
+    StdFunction(HRESULT, "D3D10StateBlockMaskUnion", [(Pointer(D3D10_STATE_BLOCK_MASK), "pA"), (Pointer(D3D10_STATE_BLOCK_MASK), "pB"), Out(Pointer(D3D10_STATE_BLOCK_MASK), "pResult")]),
+    StdFunction(HRESULT, "D3D10StateBlockMaskIntersect", [(Pointer(D3D10_STATE_BLOCK_MASK), "pA"), (Pointer(D3D10_STATE_BLOCK_MASK), "pB"), Out(Pointer(D3D10_STATE_BLOCK_MASK), "pResult")]),
+    StdFunction(HRESULT, "D3D10StateBlockMaskDifference", [(Pointer(D3D10_STATE_BLOCK_MASK), "pA"), (Pointer(D3D10_STATE_BLOCK_MASK), "pB"), Out(Pointer(D3D10_STATE_BLOCK_MASK), "pResult")]),
+    StdFunction(HRESULT, "D3D10StateBlockMaskEnableCapture", [Out(Pointer(D3D10_STATE_BLOCK_MASK), "pMask"), (D3D10_DEVICE_STATE_TYPES, "StateType"), (UINT, "RangeStart"), (UINT, "RangeLength")]),
+    StdFunction(HRESULT, "D3D10StateBlockMaskDisableCapture", [Out(Pointer(D3D10_STATE_BLOCK_MASK), "pMask"), (D3D10_DEVICE_STATE_TYPES, "StateType"), (UINT, "RangeStart"), (UINT, "RangeLength")]),
+    StdFunction(HRESULT, "D3D10StateBlockMaskEnableAll", [Out(Pointer(D3D10_STATE_BLOCK_MASK), "pMask")]),
+    StdFunction(HRESULT, "D3D10StateBlockMaskDisableAll", [Out(Pointer(D3D10_STATE_BLOCK_MASK), "pMask")]),
+    StdFunction(BOOL, "D3D10StateBlockMaskGetSetting", [(Pointer(D3D10_STATE_BLOCK_MASK), "pMask"), (D3D10_DEVICE_STATE_TYPES, "StateType"), (UINT, "Entry")]),
+    StdFunction(HRESULT, "D3D10CreateStateBlock", [(ObjPointer(ID3D10Device), "pDevice"), (Pointer(D3D10_STATE_BLOCK_MASK), "pStateBlockMask"), Out(Pointer(ObjPointer(ID3D10StateBlock)), "ppStateBlock")]),
+    StdFunction(HRESULT, "D3D10CompileEffectFromMemory", [(OpaquePointer(Void), "pData"), (SIZE_T, "DataLength"), (LPCSTR, "pSrcFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), (UINT, "HLSLFlags"), (UINT, "FXFlags"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppCompiledEffect"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrors")]),
+    StdFunction(HRESULT, "D3D10CreateEffectFromMemory", [(OpaquePointer(Void), "pData"), (SIZE_T, "DataLength"), (UINT, "FXFlags"), (ObjPointer(ID3D10Device), "pDevice"), (ObjPointer(ID3D10EffectPool), "pEffectPool"), Out(Pointer(ObjPointer(ID3D10Effect)), "ppEffect")]),
+    StdFunction(HRESULT, "D3D10CreateEffectPoolFromMemory", [(OpaquePointer(Void), "pData"), (SIZE_T, "DataLength"), (UINT, "FXFlags"), (ObjPointer(ID3D10Device), "pDevice"), Out(Pointer(ObjPointer(ID3D10EffectPool)), "ppEffectPool")]),
+    StdFunction(HRESULT, "D3D10DisassembleEffect", [(ObjPointer(ID3D10Effect), "pEffect"), (BOOL, "EnableColorCode"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDisassembly")]),
+])
index a129382d6f11e70a26b3a268ae186d63abe9f105..6564cc263afb3df389a5d68023a06128b9774d1f 100644 (file)
@@ -29,14 +29,6 @@ from winapi import *
 from d3d10 import *
 
 
-ID3D10Blob = Interface("ID3D10Blob", IUnknown)
-LPD3D10BLOB = Pointer(ID3D10Blob)
-
-ID3D10Blob.methods += [
-    Method(LPVOID, "GetBufferPointer", []),
-    Method(SIZE_T, "GetBufferSize", []),
-]
-
 D3D10_DRIVER_TYPE = Enum("D3D10_DRIVER_TYPE", [
     "D3D10_DRIVER_TYPE_HARDWARE",
     "D3D10_DRIVER_TYPE_REFERENCE",
@@ -46,37 +38,23 @@ D3D10_DRIVER_TYPE = Enum("D3D10_DRIVER_TYPE", [
 ])
 
 
-d3d10 = API("d3d10")
-
 d3d10.addFunctions([
-    StdFunction(HRESULT, "D3D10CreateDevice", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]),
-    StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain", [(Pointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (UINT, "Flags"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(Pointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(Pointer(ID3D10Device)), "ppDevice")]),
+    StdFunction(HRESULT, "D3D10CreateDevice", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (UINT, "SDKVersion"), Out(Pointer(ObjPointer(ID3D10Device)), "ppDevice")]),
+    StdFunction(HRESULT, "D3D10CreateDeviceAndSwapChain", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D10_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D10_CREATE_DEVICE_FLAG, "Flags"), (UINT, "SDKVersion"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pSwapChainDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(ObjPointer(ID3D10Device)), "ppDevice")]),
     StdFunction(HRESULT, "D3D10CreateBlob", [(SIZE_T, "NumBytes"), Out(Pointer(LPD3D10BLOB), "ppBuffer")]),
+
+    # Undocumented
+    StdFunction(DWORD, "D3D10GetVersion", []),
+    StdFunction(DWORD, "D3D10RegisterLayers", []),
 ])
 
 d3d10.addInterfaces([
-    ID3D10DeviceChild,
-    ID3D10Resource,
-    ID3D10Buffer,
-    ID3D10Texture1D,
-    ID3D10Texture2D,
-    ID3D10Texture3D,
-    ID3D10View,
-    ID3D10DepthStencilView,
-    ID3D10RenderTargetView,
-    ID3D10ShaderResourceView,
-    ID3D10BlendState,
-    ID3D10DepthStencilState,
-    ID3D10GeometryShader,
-    ID3D10InputLayout,
-    ID3D10PixelShader,
-    ID3D10RasterizerState,
-    ID3D10SamplerState,
-    ID3D10VertexShader,
-    ID3D10Asynchronous,
-    ID3D10Counter,
-    ID3D10Query,
-    ID3D10Predicate,
-    ID3D10Device,
+    IDXGIAdapter1,
+    IDXGIDevice1,
+    IDXGIResource,
+    ID3D10Debug,
+    ID3D10InfoQueue,
     ID3D10Multithread,
+    ID3D10SwitchToRef,
 ])
+
diff --git a/specs/d3d10sdklayers.py b/specs/d3d10sdklayers.py
new file mode 100644 (file)
index 0000000..7dd5cc8
--- /dev/null
@@ -0,0 +1,620 @@
+##########################################################################
+#
+# Copyright 2012 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+from dxgi import *
+from d3d10 import HRESULT
+
+D3D10_DEBUG_FEATURE = Flags(UINT, [
+    "D3D10_DEBUG_FEATURE_FLUSH_PER_RENDER_OP",
+    "D3D10_DEBUG_FEATURE_FINISH_PER_RENDER_OP",
+    "D3D10_DEBUG_FEATURE_PRESENT_PER_RENDER_OP",
+])
+
+ID3D10Debug = Interface("ID3D10Debug", IUnknown)
+ID3D10Debug.methods += [
+    Method(HRESULT, "SetFeatureMask", [(D3D10_DEBUG_FEATURE, "Mask")]),
+    Method(UINT, "GetFeatureMask", [], sideeffects=False),
+    Method(HRESULT, "SetPresentPerRenderOpDelay", [(UINT, "Milliseconds")]),
+    Method(UINT, "GetPresentPerRenderOpDelay", [], sideeffects=False),
+    Method(HRESULT, "SetSwapChain", [(ObjPointer(IDXGISwapChain), "pSwapChain")]),
+    Method(HRESULT, "GetSwapChain", [Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain")]),
+    Method(HRESULT, "Validate", []),
+]
+
+ID3D10SwitchToRef = Interface("ID3D10SwitchToRef", IUnknown)
+ID3D10SwitchToRef.methods += [
+    Method(BOOL, "SetUseRef", [(BOOL, "UseRef")]),
+    Method(BOOL, "GetUseRef", [], sideeffects=False),
+]
+
+D3D10_MESSAGE_CATEGORY = Enum("D3D10_MESSAGE_CATEGORY", [
+    "D3D10_MESSAGE_CATEGORY_APPLICATION_DEFINED",
+    "D3D10_MESSAGE_CATEGORY_MISCELLANEOUS",
+    "D3D10_MESSAGE_CATEGORY_INITIALIZATION",
+    "D3D10_MESSAGE_CATEGORY_CLEANUP",
+    "D3D10_MESSAGE_CATEGORY_COMPILATION",
+    "D3D10_MESSAGE_CATEGORY_STATE_CREATION",
+    "D3D10_MESSAGE_CATEGORY_STATE_SETTING",
+    "D3D10_MESSAGE_CATEGORY_STATE_GETTING",
+    "D3D10_MESSAGE_CATEGORY_RESOURCE_MANIPULATION",
+    "D3D10_MESSAGE_CATEGORY_EXECUTION",
+])
+
+D3D10_MESSAGE_SEVERITY = Enum("D3D10_MESSAGE_SEVERITY", [
+    "D3D10_MESSAGE_SEVERITY_CORRUPTION",
+    "D3D10_MESSAGE_SEVERITY_ERROR",
+    "D3D10_MESSAGE_SEVERITY_WARNING",
+    "D3D10_MESSAGE_SEVERITY_INFO",
+])
+
+D3D10_MESSAGE_ID = Enum("D3D10_MESSAGE_ID", [
+    "D3D10_MESSAGE_ID_UNKNOWN",
+    "D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD",
+    "D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD",
+    "D3D10_MESSAGE_ID_STRING_FROM_APPLICATION",
+    "D3D10_MESSAGE_ID_CORRUPTED_THIS",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER1",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER2",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER3",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER4",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER5",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER6",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER7",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER8",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER9",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER10",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER11",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER12",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER13",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER14",
+    "D3D10_MESSAGE_ID_CORRUPTED_PARAMETER15",
+    "D3D10_MESSAGE_ID_CORRUPTED_MULTITHREADING",
+    "D3D10_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY",
+    "D3D10_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT",
+    "D3D10_MESSAGE_ID_GETPRIVATEDATA_MOREDATA",
+    "D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA",
+    "D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN",
+    "D3D10_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS",
+    "D3D10_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS",
+    "D3D10_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_INVALIDCONSTANTBUFFERBINDINGS",
+    "D3D10_MESSAGE_ID_CREATEBUFFER_LARGEALLOCATION",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATETEXTURE1D_LARGEALLOCATION",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATETEXTURE2D_LARGEALLOCATION",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATETEXTURE3D_LARGEALLOCATION",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY",
+    "D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE",
+    "D3D10_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE",
+    "D3D10_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY",
+    "D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE",
+    "D3D10_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC",
+    "D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY",
+    "D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS",
+    "D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG",
+    "D3D10_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC",
+    "D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED",
+    "D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED",
+    "D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER",
+    "D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE",
+    "D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_IASETINDEXBUFFER_INVALIDBUFFER",
+    "D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID",
+    "D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE",
+    "D3D10_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED",
+    "D3D10_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D10_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D10_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D10_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D10_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D10_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER",
+    "D3D10_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED",
+    "D3D10_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D10_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D10_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_INVALIDVIEWPORT",
+    "D3D10_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_INVALIDSCISSOR",
+    "D3D10_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH",
+    "D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH",
+    "D3D10_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALID",
+    "D3D10_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_RSGETSCISSORRECTS_RECTS_EMPTY",
+    "D3D10_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID",
+    "D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE",
+    "D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE",
+    "D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX",
+    "D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE",
+    "D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE",
+    "D3D10_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE",
+    "D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE",
+    "D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE",
+    "D3D10_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE",
+    "D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE",
+    "D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX",
+    "D3D10_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE",
+    "D3D10_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID",
+    "D3D10_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_SUBRESOURCE_INVALID",
+    "D3D10_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_INVALID",
+    "D3D10_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_SUBRESOURCE_INVALID",
+    "D3D10_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_FORMAT_INVALID",
+    "D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE",
+    "D3D10_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS",
+    "D3D10_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED",
+    "D3D10_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN",
+    "D3D10_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED",
+    "D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE",
+    "D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE",
+    "D3D10_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS",
+    "D3D10_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED",
+    "D3D10_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN",
+    "D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE",
+    "D3D10_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED",
+    "D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE",
+    "D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE",
+    "D3D10_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS",
+    "D3D10_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED",
+    "D3D10_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN",
+    "D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE",
+    "D3D10_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED",
+    "D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE",
+    "D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE",
+    "D3D10_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS",
+    "D3D10_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED",
+    "D3D10_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN",
+    "D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE",
+    "D3D10_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED",
+    "D3D10_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_DEPRECATED",
+    "D3D10_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_FORMAT_DEPRECATED",
+    "D3D10_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS",
+    "D3D10_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN",
+    "D3D10_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE",
+    "D3D10_MESSAGE_ID_REF_THREADING_MODE",
+    "D3D10_MESSAGE_ID_REF_UMDRIVER_EXCEPTION",
+    "D3D10_MESSAGE_ID_REF_KMDRIVER_EXCEPTION",
+    "D3D10_MESSAGE_ID_REF_HARDWARE_EXCEPTION",
+    "D3D10_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE",
+    "D3D10_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER",
+    "D3D10_MESSAGE_ID_REF_OUT_OF_MEMORY",
+    "D3D10_MESSAGE_ID_REF_INFO",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW",
+    "D3D10_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW",
+    "D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW",
+    "D3D10_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW",
+    "D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW",
+    "D3D10_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND",
+    "D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX",
+    "D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE",
+    "D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK",
+    "D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE",
+    "D3D10_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VIEW_DIMENSION_MISMATCH",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_SET",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_SO_TARGETS_BOUND_WITHOUT_SOURCE",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_SO_STRIDE_LARGER_THAN_BUFFER",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0",
+    "D3D10_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT",
+    "D3D10_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT",
+    "D3D10_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT",
+    "D3D10_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN",
+    "D3D10_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BADINTERFACE_RETURN",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_VIEWPORT_NOT_SET",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC",
+    "D3D10_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_TRAILING_DIGIT_IN_SEMANTIC",
+    "D3D10_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_DENORMFLUSH",
+    "D3D10_MESSAGE_ID_OMSETRENDERTARGETS_INVALIDVIEW",
+    "D3D10_MESSAGE_ID_DEVICE_SETTEXTFILTERSIZE_INVALIDDIMENSIONS",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH",
+    "D3D10_MESSAGE_ID_BLENDSTATE_GETDESC_LEGACY",
+    "D3D10_MESSAGE_ID_SHADERRESOURCEVIEW_GETDESC_LEGACY",
+    "D3D10_MESSAGE_ID_CREATEQUERY_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATEPREDICATE_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATECOUNTER_OUTOFRANGE_COUNTER",
+    "D3D10_MESSAGE_ID_CREATECOUNTER_SIMULTANEOUS_ACTIVE_COUNTERS_EXHAUSTED",
+    "D3D10_MESSAGE_ID_CREATECOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER",
+    "D3D10_MESSAGE_ID_CREATECOUNTER_OUTOFMEMORY_RETURN",
+    "D3D10_MESSAGE_ID_CREATECOUNTER_NONEXCLUSIVE_RETURN",
+    "D3D10_MESSAGE_ID_CREATECOUNTER_NULLDESC",
+    "D3D10_MESSAGE_ID_CHECKCOUNTER_OUTOFRANGE_COUNTER",
+    "D3D10_MESSAGE_ID_CHECKCOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER",
+    "D3D10_MESSAGE_ID_SETPREDICATION_INVALID_PREDICATE_STATE",
+    "D3D10_MESSAGE_ID_QUERY_BEGIN_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_PREDICATE_BEGIN_DURING_PREDICATION",
+    "D3D10_MESSAGE_ID_QUERY_BEGIN_DUPLICATE",
+    "D3D10_MESSAGE_ID_QUERY_BEGIN_ABANDONING_PREVIOUS_RESULTS",
+    "D3D10_MESSAGE_ID_PREDICATE_END_DURING_PREDICATION",
+    "D3D10_MESSAGE_ID_QUERY_END_ABANDONING_PREVIOUS_RESULTS",
+    "D3D10_MESSAGE_ID_QUERY_END_WITHOUT_BEGIN",
+    "D3D10_MESSAGE_ID_QUERY_GETDATA_INVALID_DATASIZE",
+    "D3D10_MESSAGE_ID_QUERY_GETDATA_INVALID_FLAGS",
+    "D3D10_MESSAGE_ID_QUERY_GETDATA_INVALID_CALL",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_PS_OUTPUT_TYPE_MISMATCH",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_GATHER_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN",
+    "D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_STRIDE_TOO_LARGE",
+    "D3D10_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_INVALIDRANGE",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT",
+    "D3D10_MESSAGE_ID_DEVICE_DRAW_RESOURCE_SAMPLE_COUNT_MISMATCH",
+    "D3D10_MESSAGE_ID_D3D10_MESSAGES_END",
+    "D3D10_MESSAGE_ID_D3D10L9_MESSAGES_START",
+    "D3D10_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_STENCIL_NO_TWO_SIDED",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_DepthBiasClamp_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_NO_COMPARISON_SUPPORT",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_EXCESSIVE_ANISOTROPY",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_OUT_OF_RANGE",
+    "D3D10_MESSAGE_ID_VSSETSAMPLERS_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_VSSETSAMPLERS_TOO_MANY_SAMPLERS",
+    "D3D10_MESSAGE_ID_PSSETSAMPLERS_TOO_MANY_SAMPLERS",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NO_ARRAYS",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NO_VB_AND_IB_BIND",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NO_TEXTURE_1D",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_DIMENSION_OUT_OF_RANGE",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_SHADER_RESOURCE",
+    "D3D10_MESSAGE_ID_OMSETRENDERTARGETS_TOO_MANY_RENDER_TARGETS",
+    "D3D10_MESSAGE_ID_OMSETRENDERTARGETS_NO_DIFFERING_BIT_DEPTHS",
+    "D3D10_MESSAGE_ID_IASETVERTEXBUFFERS_BAD_BUFFER_INDEX",
+    "D3D10_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_TOO_MANY_VIEWPORTS",
+    "D3D10_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_ADJACENCY_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_TOO_MANY_SCISSORS",
+    "D3D10_MESSAGE_ID_COPYRESOURCE_ONLY_TEXTURE_2D_WITHIN_GPU_MEMORY",
+    "D3D10_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_3D_READBACK",
+    "D3D10_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_ONLY_READBACK",
+    "D3D10_MESSAGE_ID_CREATEINPUTLAYOUT_UNSUPPORTED_FORMAT",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_NO_ALPHA_TO_COVERAGE",
+    "D3D10_MESSAGE_ID_CREATERASTERIZERSTATE_DepthClipEnable_MUST_BE_TRUE",
+    "D3D10_MESSAGE_ID_DRAWINDEXED_STARTINDEXLOCATION_MUST_BE_POSITIVE",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_MUST_USE_LOWEST_LOD",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_MINLOD_MUST_NOT_BE_FRACTIONAL",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_MAXLOD_MUST_BE_FLT_MAX",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_FIRSTARRAYSLICE_MUST_BE_ZERO",
+    "D3D10_MESSAGE_ID_CREATESHADERRESOURCEVIEW_CUBES_MUST_HAVE_6_SIDES",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_RENDER_TARGET",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NO_DWORD_INDEX_BUFFER",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_MSAA_PRECLUDES_SHADER_RESOURCE",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_PRESENTATION_PRECLUDES_SHADER_RESOURCE",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_BLEND_ENABLE",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_WRITE_MASKS",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NO_STREAM_OUT",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_ONLY_VB_IB_FOR_BUFFERS",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NO_AUTOGEN_FOR_VOLUMES",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_DXGI_FORMAT_R8G8B8A8_CANNOT_BE_SHARED",
+    "D3D10_MESSAGE_ID_VSSHADERRESOURCES_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_GEOMETRY_SHADER_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_STREAM_OUT_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_TEXT_FILTER_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_NO_SEPARATE_ALPHA_BLEND",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_NO_MRT_BLEND",
+    "D3D10_MESSAGE_ID_CREATEBLENDSTATE_OPERATION_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_NO_MIRRORONCE",
+    "D3D10_MESSAGE_ID_DRAWINSTANCED_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_DRAWINDEXEDINSTANCED_NOT_SUPPORTED_BELOW_9_3",
+    "D3D10_MESSAGE_ID_DRAWINDEXED_POINTLIST_UNSUPPORTED",
+    "D3D10_MESSAGE_ID_SETBLENDSTATE_SAMPLE_MASK_CANNOT_BE_ZERO",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_DIMENSION_EXCEEDS_FEATURE_LEVEL_DEFINITION",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_ONLY_SINGLE_MIP_LEVEL_DEPTH_STENCIL_SUPPORTED",
+    "D3D10_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_NEGATIVESCISSOR",
+    "D3D10_MESSAGE_ID_SLOT_ZERO_MUST_BE_D3D10_INPUT_PER_VERTEX_DATA",
+    "D3D10_MESSAGE_ID_CREATERESOURCE_NON_POW_2_MIPMAP",
+    "D3D10_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_NOT_SUPPORTED",
+    "D3D10_MESSAGE_ID_OMSETRENDERTARGETS_NO_SRGB_MRT",
+    "D3D10_MESSAGE_ID_D3D10L9_MESSAGES_END",
+])
+
+D3D10_MESSAGE = Struct("D3D10_MESSAGE", [
+    (D3D10_MESSAGE_CATEGORY, "Category"),
+    (D3D10_MESSAGE_SEVERITY, "Severity"),
+    (D3D10_MESSAGE_ID, "ID"),
+    (ConstCString, "pDescription"),
+    (SIZE_T, "DescriptionByteLength"),
+])
+
+D3D10_INFO_QUEUE_FILTER_DESC = Struct("D3D10_INFO_QUEUE_FILTER_DESC", [
+    (UINT, "NumCategories"),
+    (Pointer(D3D10_MESSAGE_CATEGORY), "pCategoryList"),
+    (UINT, "NumSeverities"),
+    (Pointer(D3D10_MESSAGE_SEVERITY), "pSeverityList"),
+    (UINT, "NumIDs"),
+    (OpaquePointer(D3D10_MESSAGE_ID), "pIDList"), # TODO: Array
+])
+
+D3D10_INFO_QUEUE_FILTER = Struct("D3D10_INFO_QUEUE_FILTER", [
+    (D3D10_INFO_QUEUE_FILTER_DESC, "AllowList"),
+    (D3D10_INFO_QUEUE_FILTER_DESC, "DenyList"),
+])
+
+ID3D10InfoQueue = Interface("ID3D10InfoQueue", IUnknown)
+ID3D10InfoQueue.methods += [
+    Method(HRESULT, "SetMessageCountLimit", [(UINT64, "MessageCountLimit")], sideeffects=False),
+    Method(Void, "ClearStoredMessages", [], sideeffects=False),
+    Method(HRESULT, "GetMessage", [(UINT64, "MessageIndex"), Out(Pointer(D3D10_MESSAGE), "pMessage"), Out(Pointer(SIZE_T), "pMessageByteLength")], sideeffects=False),
+    Method(UINT64, "GetNumMessagesAllowedByStorageFilter", [], sideeffects=False),
+    Method(UINT64, "GetNumMessagesDeniedByStorageFilter", [], sideeffects=False),
+    Method(UINT64, "GetNumStoredMessages", [], sideeffects=False),
+    Method(UINT64, "GetNumStoredMessagesAllowedByRetrievalFilter", [], sideeffects=False),
+    Method(UINT64, "GetNumMessagesDiscardedByMessageCountLimit", [], sideeffects=False),
+    Method(UINT64, "GetMessageCountLimit", [], sideeffects=False),
+    Method(HRESULT, "AddStorageFilterEntries", [(Pointer(D3D10_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False),
+    Method(HRESULT, "GetStorageFilter", [Out(Pointer(D3D10_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")], sideeffects=False),
+    Method(Void, "ClearStorageFilter", [], sideeffects=False),
+    Method(HRESULT, "PushEmptyStorageFilter", [], sideeffects=False),
+    Method(HRESULT, "PushCopyOfStorageFilter", [], sideeffects=False),
+    Method(HRESULT, "PushStorageFilter", [(Pointer(D3D10_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False),
+    Method(Void, "PopStorageFilter", [], sideeffects=False),
+    Method(UINT, "GetStorageFilterStackSize", [], sideeffects=False),
+    Method(HRESULT, "AddRetrievalFilterEntries", [(Pointer(D3D10_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False),
+    Method(HRESULT, "GetRetrievalFilter", [Out(Pointer(D3D10_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")], sideeffects=False),
+    Method(Void, "ClearRetrievalFilter", [], sideeffects=False),
+    Method(HRESULT, "PushEmptyRetrievalFilter", [], sideeffects=False),
+    Method(HRESULT, "PushCopyOfRetrievalFilter", [], sideeffects=False),
+    Method(HRESULT, "PushRetrievalFilter", [(Pointer(D3D10_INFO_QUEUE_FILTER), "pFilter")], sideeffects=False),
+    Method(Void, "PopRetrievalFilter", [], sideeffects=False),
+    Method(UINT, "GetRetrievalFilterStackSize", [], sideeffects=False),
+    Method(HRESULT, "AddMessage", [(D3D10_MESSAGE_CATEGORY, "Category"), (D3D10_MESSAGE_SEVERITY, "Severity"), (D3D10_MESSAGE_ID, "ID"), (LPCSTR, "pDescription")], sideeffects=False),
+    Method(HRESULT, "AddApplicationMessage", [(D3D10_MESSAGE_SEVERITY, "Severity"), (LPCSTR, "pDescription")], sideeffects=False),
+    Method(HRESULT, "SetBreakOnCategory", [(D3D10_MESSAGE_CATEGORY, "Category"), (BOOL, "bEnable")], sideeffects=False),
+    Method(HRESULT, "SetBreakOnSeverity", [(D3D10_MESSAGE_SEVERITY, "Severity"), (BOOL, "bEnable")], sideeffects=False),
+    Method(HRESULT, "SetBreakOnID", [(D3D10_MESSAGE_ID, "ID"), (BOOL, "bEnable")], sideeffects=False),
+    Method(BOOL, "GetBreakOnCategory", [(D3D10_MESSAGE_CATEGORY, "Category")], sideeffects=False),
+    Method(BOOL, "GetBreakOnSeverity", [(D3D10_MESSAGE_SEVERITY, "Severity")], sideeffects=False),
+    Method(BOOL, "GetBreakOnID", [(D3D10_MESSAGE_ID, "ID")], sideeffects=False),
+    Method(Void, "SetMuteDebugOutput", [(BOOL, "bMute")], sideeffects=False),
+    Method(BOOL, "GetMuteDebugOutput", [], sideeffects=False),
+]
+
diff --git a/specs/d3d10shader.py b/specs/d3d10shader.py
new file mode 100644 (file)
index 0000000..43ea865
--- /dev/null
@@ -0,0 +1,175 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from d3dcommon import *
+from d3d10 import *
+
+
+D3D10_SHADER = Flags(UINT, [
+    "D3D10_SHADER_DEBUG",
+    "D3D10_SHADER_SKIP_VALIDATION",
+    "D3D10_SHADER_SKIP_OPTIMIZATION",
+    "D3D10_SHADER_PACK_MATRIX_ROW_MAJOR",
+    "D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR",
+    "D3D10_SHADER_PARTIAL_PRECISION",
+    "D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT",
+    "D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT",
+    "D3D10_SHADER_NO_PRESHADER",
+    "D3D10_SHADER_AVOID_FLOW_CONTROL",
+    "D3D10_SHADER_PREFER_FLOW_CONTROL",
+    "D3D10_SHADER_ENABLE_STRICTNESS",
+    "D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY",
+    "D3D10_SHADER_IEEE_STRICTNESS",
+    "D3D10_SHADER_WARNINGS_ARE_ERRORS",
+    "D3D10_SHADER_OPTIMIZATION_LEVEL0",
+    "D3D10_SHADER_OPTIMIZATION_LEVEL1",
+    "D3D10_SHADER_OPTIMIZATION_LEVEL2",
+    "D3D10_SHADER_OPTIMIZATION_LEVEL3",
+])
+
+D3D10_SHADER_DESC = Struct("D3D10_SHADER_DESC", [
+    (UINT, "Version"),
+    (LPCSTR, "Creator"),
+    (UINT, "Flags"),
+    (UINT, "ConstantBuffers"),
+    (UINT, "BoundResources"),
+    (UINT, "InputParameters"),
+    (UINT, "OutputParameters"),
+    (UINT, "InstructionCount"),
+    (UINT, "TempRegisterCount"),
+    (UINT, "TempArrayCount"),
+    (UINT, "DefCount"),
+    (UINT, "DclCount"),
+    (UINT, "TextureNormalInstructions"),
+    (UINT, "TextureLoadInstructions"),
+    (UINT, "TextureCompInstructions"),
+    (UINT, "TextureBiasInstructions"),
+    (UINT, "TextureGradientInstructions"),
+    (UINT, "FloatInstructionCount"),
+    (UINT, "IntInstructionCount"),
+    (UINT, "UintInstructionCount"),
+    (UINT, "StaticFlowControlCount"),
+    (UINT, "DynamicFlowControlCount"),
+    (UINT, "MacroInstructionCount"),
+    (UINT, "ArrayInstructionCount"),
+    (UINT, "CutInstructionCount"),
+    (UINT, "EmitInstructionCount"),
+    (D3D10_PRIMITIVE_TOPOLOGY, "GSOutputTopology"),
+    (UINT, "GSMaxOutputVertexCount"),
+])
+
+D3D10_SHADER_BUFFER_DESC = Struct("D3D10_SHADER_BUFFER_DESC", [
+    (LPCSTR, "Name"),
+    (D3D10_CBUFFER_TYPE, "Type"),
+    (UINT, "Variables"),
+    (UINT, "Size"),
+    (UINT, "uFlags"),
+])
+
+D3D10_SHADER_VARIABLE_DESC = Struct("D3D10_SHADER_VARIABLE_DESC", [
+    (LPCSTR, "Name"),
+    (UINT, "StartOffset"),
+    (UINT, "Size"),
+    (UINT, "uFlags"),
+    (LPVOID, "DefaultValue"),
+])
+
+D3D10_SHADER_TYPE_DESC = Struct("D3D10_SHADER_TYPE_DESC", [
+    (D3D10_SHADER_VARIABLE_CLASS, "Class"),
+    (D3D10_SHADER_VARIABLE_TYPE, "Type"),
+    (UINT, "Rows"),
+    (UINT, "Columns"),
+    (UINT, "Elements"),
+    (UINT, "Members"),
+    (UINT, "Offset"),
+])
+
+D3D10_SHADER_INPUT_BIND_DESC = Struct("D3D10_SHADER_INPUT_BIND_DESC", [
+    (LPCSTR, "Name"),
+    (D3D10_SHADER_INPUT_TYPE, "Type"),
+    (UINT, "BindPoint"),
+    (UINT, "BindCount"),
+    (UINT, "uFlags"),
+    (D3D10_RESOURCE_RETURN_TYPE, "ReturnType"),
+    (D3D10_SRV_DIMENSION, "Dimension"),
+    (UINT, "NumSamples"),
+])
+
+D3D10_SIGNATURE_PARAMETER_DESC = Struct("D3D10_SIGNATURE_PARAMETER_DESC", [
+    (LPCSTR, "SemanticName"),
+    (UINT, "SemanticIndex"),
+    (UINT, "Register"),
+    (D3D10_NAME, "SystemValueType"),
+    (D3D10_REGISTER_COMPONENT_TYPE, "ComponentType"),
+    (BYTE, "Mask"),
+    (BYTE, "ReadWriteMask"),
+])
+
+ID3D10ShaderReflectionType = Interface("ID3D10ShaderReflectionType")
+ID3D10ShaderReflectionType.methods += [
+    StdMethod(HRESULT, "GetDesc", [(Pointer(D3D10_SHADER_TYPE_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetMemberTypeByName", [(LPCSTR, "Name")]),
+    StdMethod(LPCSTR, "GetMemberTypeName", [(UINT, "Index")]),
+]
+
+ID3D10ShaderReflectionVariable = Interface("ID3D10ShaderReflectionVariable")
+ID3D10ShaderReflectionVariable.methods += [
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_VARIABLE_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10ShaderReflectionType), "GetType", []),
+]
+
+ID3D10ShaderReflectionConstantBuffer = Interface("ID3D10ShaderReflectionConstantBuffer")
+ID3D10ShaderReflectionConstantBuffer.methods += [
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_BUFFER_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10ShaderReflectionVariable), "GetVariableByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10ShaderReflectionVariable), "GetVariableByName", [(LPCSTR, "Name")]),
+]
+
+ID3D10ShaderReflection = Interface("ID3D10ShaderReflection", IUnknown)
+ID3D10ShaderReflection.methods += [
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D10_SHADER_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D10ShaderReflectionConstantBuffer), "GetConstantBufferByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D10ShaderReflectionConstantBuffer), "GetConstantBufferByName", [(LPCSTR, "Name")]),
+    StdMethod(HRESULT, "GetResourceBindingDesc", [(UINT, "ResourceIndex"), Out(Pointer(D3D10_SHADER_INPUT_BIND_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetInputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetOutputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D10_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+]
+
+
+d3d10.addFunctions([
+    StdFunction(HRESULT, "D3D10CompileShader", [(LPCSTR, "pSrcData"), (SIZE_T, "SrcDataSize"), (LPCSTR, "pFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), (LPCSTR, "pFunctionName"), (LPCSTR, "pProfile"), (UINT, "Flags"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppShader"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrorMsgs")]),
+    StdFunction(HRESULT, "D3D10DisassembleShader", [(OpaquePointer(Const(Void)), "pShader"), (SIZE_T, "BytecodeLength"), (BOOL, "EnableColorCode"), (LPCSTR, "pComments"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDisassembly")]),
+    StdFunction(LPCSTR, "D3D10GetPixelShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
+    StdFunction(LPCSTR, "D3D10GetVertexShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
+    StdFunction(LPCSTR, "D3D10GetGeometryShaderProfile", [(ObjPointer(ID3D10Device), "pDevice")]),
+    StdFunction(HRESULT, "D3D10ReflectShader", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10ShaderReflection)), "ppReflector")]),
+    StdFunction(HRESULT, "D3D10PreprocessShader", [(LPCSTR, "pSrcData"), (SIZE_T, "SrcDataSize"), (LPCSTR, "pFileName"), (Pointer(Const(D3D10_SHADER_MACRO)), "pDefines"), (LPD3D10INCLUDE, "pInclude"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppShaderText"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppErrorMsgs")]),
+    StdFunction(HRESULT, "D3D10GetInputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
+    StdFunction(HRESULT, "D3D10GetOutputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
+    StdFunction(HRESULT, "D3D10GetInputAndOutputSignatureBlob", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppSignatureBlob")]),
+    StdFunction(HRESULT, "D3D10GetShaderDebugInfo", [(OpaquePointer(Const(Void)), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D10Blob)), "ppDebugInfo")]),
+])
diff --git a/specs/d3d11.py b/specs/d3d11.py
new file mode 100644 (file)
index 0000000..8a681bd
--- /dev/null
@@ -0,0 +1,1236 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dxgi import *
+from d3dcommon import *
+from d3d11sdklayers import *
+
+
+HRESULT = MAKE_HRESULT([
+    "D3D11_ERROR_FILE_NOT_FOUND",
+    "D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS",
+    "D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS",
+    "D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD",
+    "D3DERR_INVALIDCALL",
+    "D3DERR_WASSTILLDRAWING",
+])
+
+
+ID3D11DepthStencilState = Interface("ID3D11DepthStencilState", ID3D11DeviceChild)
+ID3D11BlendState = Interface("ID3D11BlendState", ID3D11DeviceChild)
+ID3D11RasterizerState = Interface("ID3D11RasterizerState", ID3D11DeviceChild)
+ID3D11Resource = Interface("ID3D11Resource", ID3D11DeviceChild)
+ID3D11Buffer = Interface("ID3D11Buffer", ID3D11Resource)
+ID3D11Texture1D = Interface("ID3D11Texture1D", ID3D11Resource)
+ID3D11Texture2D = Interface("ID3D11Texture2D", ID3D11Resource)
+ID3D11Texture3D = Interface("ID3D11Texture3D", ID3D11Resource)
+ID3D11View = Interface("ID3D11View", ID3D11DeviceChild)
+ID3D11ShaderResourceView = Interface("ID3D11ShaderResourceView", ID3D11View)
+ID3D11RenderTargetView = Interface("ID3D11RenderTargetView", ID3D11View)
+ID3D11DepthStencilView = Interface("ID3D11DepthStencilView", ID3D11View)
+ID3D11UnorderedAccessView = Interface("ID3D11UnorderedAccessView", ID3D11View)
+ID3D11VertexShader = Interface("ID3D11VertexShader", ID3D11DeviceChild)
+ID3D11HullShader = Interface("ID3D11HullShader", ID3D11DeviceChild)
+ID3D11DomainShader = Interface("ID3D11DomainShader", ID3D11DeviceChild)
+ID3D11GeometryShader = Interface("ID3D11GeometryShader", ID3D11DeviceChild)
+ID3D11PixelShader = Interface("ID3D11PixelShader", ID3D11DeviceChild)
+ID3D11ComputeShader = Interface("ID3D11ComputeShader", ID3D11DeviceChild)
+ID3D11InputLayout = Interface("ID3D11InputLayout", ID3D11DeviceChild)
+ID3D11SamplerState = Interface("ID3D11SamplerState", ID3D11DeviceChild)
+ID3D11Asynchronous = Interface("ID3D11Asynchronous", ID3D11DeviceChild)
+ID3D11Query = Interface("ID3D11Query", ID3D11Asynchronous)
+ID3D11Predicate = Interface("ID3D11Predicate", ID3D11Query)
+ID3D11Counter = Interface("ID3D11Counter", ID3D11Asynchronous)
+ID3D11ClassInstance = Interface("ID3D11ClassInstance", ID3D11DeviceChild)
+ID3D11ClassLinkage = Interface("ID3D11ClassLinkage", ID3D11DeviceChild)
+ID3D11CommandList = Interface("ID3D11CommandList", ID3D11DeviceChild)
+ID3D11Device = Interface("ID3D11Device", IUnknown)
+
+
+D3D11_INPUT_CLASSIFICATION = Enum("D3D11_INPUT_CLASSIFICATION", [
+    "D3D11_INPUT_PER_VERTEX_DATA",
+    "D3D11_INPUT_PER_INSTANCE_DATA",
+])
+
+D3D11_INPUT_ELEMENT_ALIGNED_BYTE_OFFSET = FakeEnum(UINT, [
+    "D3D11_APPEND_ALIGNED_ELEMENT",
+])
+
+D3D11_INPUT_ELEMENT_DESC = Struct("D3D11_INPUT_ELEMENT_DESC", [
+    (LPCSTR, "SemanticName"),
+    (UINT, "SemanticIndex"),
+    (DXGI_FORMAT, "Format"),
+    (UINT, "InputSlot"),
+    (D3D11_INPUT_ELEMENT_ALIGNED_BYTE_OFFSET, "AlignedByteOffset"),
+    (D3D11_INPUT_CLASSIFICATION, "InputSlotClass"),
+    (UINT, "InstanceDataStepRate"),
+])
+
+D3D11_FILL_MODE = Enum("D3D11_FILL_MODE", [
+    "D3D11_FILL_WIREFRAME",
+    "D3D11_FILL_SOLID",
+])
+
+D3D11_PRIMITIVE_TOPOLOGY = Enum("D3D11_PRIMITIVE_TOPOLOGY", [
+    "D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED",
+    "D3D11_PRIMITIVE_TOPOLOGY_POINTLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_LINELIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP",
+    "D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP",
+    "D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ",
+    "D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ",
+    "D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ",
+    "D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ",
+    "D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST",
+    "D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST",
+])
+
+D3D11_PRIMITIVE = Enum("D3D11_PRIMITIVE", [
+    "D3D11_PRIMITIVE_UNDEFINED",
+    "D3D11_PRIMITIVE_POINT",
+    "D3D11_PRIMITIVE_LINE",
+    "D3D11_PRIMITIVE_TRIANGLE",
+    "D3D11_PRIMITIVE_LINE_ADJ",
+    "D3D11_PRIMITIVE_TRIANGLE_ADJ",
+    "D3D11_PRIMITIVE_1_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_2_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_3_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_4_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_5_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_6_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_7_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_8_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_9_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_10_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_11_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_12_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_13_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_14_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_15_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_16_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_17_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_18_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_19_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_20_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_21_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_22_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_23_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_24_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_25_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_26_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_27_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_28_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_29_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_30_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_31_CONTROL_POINT_PATCH",
+    "D3D11_PRIMITIVE_32_CONTROL_POINT_PATCH",
+])
+
+D3D11_CULL_MODE = Enum("D3D11_CULL_MODE", [
+    "D3D11_CULL_NONE",
+    "D3D11_CULL_FRONT",
+    "D3D11_CULL_BACK",
+])
+
+D3D11_SO_DECLARATION_ENTRY = Struct("D3D11_SO_DECLARATION_ENTRY", [
+    (UINT, "Stream"),
+    (LPCSTR, "SemanticName"),
+    (UINT, "SemanticIndex"),
+    (BYTE, "StartComponent"),
+    (BYTE, "ComponentCount"),
+    (BYTE, "OutputSlot"),
+])
+
+D3D11_VIEWPORT = Struct("D3D11_VIEWPORT", [
+    (FLOAT, "TopLeftX"),
+    (FLOAT, "TopLeftY"),
+    (FLOAT, "Width"),
+    (FLOAT, "Height"),
+    (FLOAT, "MinDepth"),
+    (FLOAT, "MaxDepth"),
+])
+
+D3D11_RESOURCE_DIMENSION = Enum("D3D11_RESOURCE_DIMENSION", [
+    "D3D11_RESOURCE_DIMENSION_UNKNOWN",
+    "D3D11_RESOURCE_DIMENSION_BUFFER",
+    "D3D11_RESOURCE_DIMENSION_TEXTURE1D",
+    "D3D11_RESOURCE_DIMENSION_TEXTURE2D",
+    "D3D11_RESOURCE_DIMENSION_TEXTURE3D",
+])
+
+D3D11_SRV_DIMENSION = Enum("D3D11_SRV_DIMENSION", [
+    "D3D11_SRV_DIMENSION_UNKNOWN",
+    "D3D11_SRV_DIMENSION_BUFFER",
+    "D3D11_SRV_DIMENSION_TEXTURE1D",
+    "D3D11_SRV_DIMENSION_TEXTURE1DARRAY",
+    "D3D11_SRV_DIMENSION_TEXTURE2D",
+    "D3D11_SRV_DIMENSION_TEXTURE2DARRAY",
+    "D3D11_SRV_DIMENSION_TEXTURE2DMS",
+    "D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY",
+    "D3D11_SRV_DIMENSION_TEXTURE3D",
+    "D3D11_SRV_DIMENSION_TEXTURECUBE",
+    "D3D11_SRV_DIMENSION_TEXTURECUBEARRAY",
+    "D3D11_SRV_DIMENSION_BUFFEREX",
+])
+
+D3D11_DSV_DIMENSION = Enum("D3D11_DSV_DIMENSION", [
+    "D3D11_DSV_DIMENSION_UNKNOWN",
+    "D3D11_DSV_DIMENSION_TEXTURE1D",
+    "D3D11_DSV_DIMENSION_TEXTURE1DARRAY",
+    "D3D11_DSV_DIMENSION_TEXTURE2D",
+    "D3D11_DSV_DIMENSION_TEXTURE2DARRAY",
+    "D3D11_DSV_DIMENSION_TEXTURE2DMS",
+    "D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY",
+])
+
+D3D11_RTV_DIMENSION = Enum("D3D11_RTV_DIMENSION", [
+    "D3D11_RTV_DIMENSION_UNKNOWN",
+    "D3D11_RTV_DIMENSION_BUFFER",
+    "D3D11_RTV_DIMENSION_TEXTURE1D",
+    "D3D11_RTV_DIMENSION_TEXTURE1DARRAY",
+    "D3D11_RTV_DIMENSION_TEXTURE2D",
+    "D3D11_RTV_DIMENSION_TEXTURE2DARRAY",
+    "D3D11_RTV_DIMENSION_TEXTURE2DMS",
+    "D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY",
+    "D3D11_RTV_DIMENSION_TEXTURE3D",
+])
+
+D3D11_UAV_DIMENSION = Enum("D3D11_UAV_DIMENSION", [
+    "D3D11_UAV_DIMENSION_UNKNOWN",
+    "D3D11_UAV_DIMENSION_BUFFER",
+    "D3D11_UAV_DIMENSION_TEXTURE1D",
+    "D3D11_UAV_DIMENSION_TEXTURE1DARRAY",
+    "D3D11_UAV_DIMENSION_TEXTURE2D",
+    "D3D11_UAV_DIMENSION_TEXTURE2DARRAY",
+    "D3D11_UAV_DIMENSION_TEXTURE3D",
+])
+
+D3D11_USAGE = Enum("D3D11_USAGE", [
+    "D3D11_USAGE_DEFAULT",
+    "D3D11_USAGE_IMMUTABLE",
+    "D3D11_USAGE_DYNAMIC",
+    "D3D11_USAGE_STAGING",
+])
+
+D3D11_BIND_FLAG = Flags(UINT, [
+    "D3D11_BIND_VERTEX_BUFFER",
+    "D3D11_BIND_INDEX_BUFFER",
+    "D3D11_BIND_CONSTANT_BUFFER",
+    "D3D11_BIND_SHADER_RESOURCE",
+    "D3D11_BIND_STREAM_OUTPUT",
+    "D3D11_BIND_RENDER_TARGET",
+    "D3D11_BIND_DEPTH_STENCIL",
+    "D3D11_BIND_UNORDERED_ACCESS",
+])
+
+D3D11_CPU_ACCESS_FLAG = Flags(UINT, [
+    "D3D11_CPU_ACCESS_WRITE",
+    "D3D11_CPU_ACCESS_READ",
+])
+
+D3D11_RESOURCE_MISC_FLAG = Flags(UINT, [
+    "D3D11_RESOURCE_MISC_GENERATE_MIPS",
+    "D3D11_RESOURCE_MISC_SHARED",
+    "D3D11_RESOURCE_MISC_TEXTURECUBE",
+    "D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS",
+    "D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS",
+    "D3D11_RESOURCE_MISC_BUFFER_STRUCTURED",
+    "D3D11_RESOURCE_MISC_RESOURCE_CLAMP",
+    "D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX",
+    "D3D11_RESOURCE_MISC_GDI_COMPATIBLE",
+])
+
+D3D11_MAP = Enum("D3D11_MAP", [
+    "D3D11_MAP_READ",
+    "D3D11_MAP_WRITE",
+    "D3D11_MAP_READ_WRITE",
+    "D3D11_MAP_WRITE_DISCARD",
+    "D3D11_MAP_WRITE_NO_OVERWRITE",
+])
+
+D3D11_MAP_FLAG = Flags(UINT, [
+    "D3D11_MAP_FLAG_DO_NOT_WAIT",
+])
+
+D3D11_RAISE_FLAG = Flags(UINT, [
+    "D3D11_RAISE_FLAG_DRIVER_INTERNAL_ERROR",
+])
+
+D3D11_CLEAR_FLAG = Flags(UINT, [
+    "D3D11_CLEAR_DEPTH",
+    "D3D11_CLEAR_STENCIL",
+])
+
+D3D11_RECT = Alias("D3D11_RECT", RECT)
+D3D11_BOX = Struct("D3D11_BOX", [
+    (UINT, "left"),
+    (UINT, "top"),
+    (UINT, "front"),
+    (UINT, "right"),
+    (UINT, "bottom"),
+    (UINT, "back"),
+])
+
+ID3D11DeviceChild.methods += [
+    StdMethod(Void, "GetDevice", [Out(Pointer(ObjPointer(ID3D11Device)), "ppDevice")]),
+    StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")]),
+    StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")]),
+    StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")]),
+]
+
+D3D11_COMPARISON_FUNC = Enum("D3D11_COMPARISON_FUNC", [
+    "D3D11_COMPARISON_NEVER",
+    "D3D11_COMPARISON_LESS",
+    "D3D11_COMPARISON_EQUAL",
+    "D3D11_COMPARISON_LESS_EQUAL",
+    "D3D11_COMPARISON_GREATER",
+    "D3D11_COMPARISON_NOT_EQUAL",
+    "D3D11_COMPARISON_GREATER_EQUAL",
+    "D3D11_COMPARISON_ALWAYS",
+])
+
+D3D11_DEPTH_WRITE_MASK = Enum("D3D11_DEPTH_WRITE_MASK", [
+    "D3D11_DEPTH_WRITE_MASK_ZERO",
+    "D3D11_DEPTH_WRITE_MASK_ALL",
+])
+
+D3D11_STENCIL_OP = Enum("D3D11_STENCIL_OP", [
+    "D3D11_STENCIL_OP_KEEP",
+    "D3D11_STENCIL_OP_ZERO",
+    "D3D11_STENCIL_OP_REPLACE",
+    "D3D11_STENCIL_OP_INCR_SAT",
+    "D3D11_STENCIL_OP_DECR_SAT",
+    "D3D11_STENCIL_OP_INVERT",
+    "D3D11_STENCIL_OP_INCR",
+    "D3D11_STENCIL_OP_DECR",
+])
+
+D3D11_DEPTH_STENCILOP_DESC = Struct("D3D11_DEPTH_STENCILOP_DESC", [
+    (D3D11_STENCIL_OP, "StencilFailOp"),
+    (D3D11_STENCIL_OP, "StencilDepthFailOp"),
+    (D3D11_STENCIL_OP, "StencilPassOp"),
+    (D3D11_COMPARISON_FUNC, "StencilFunc"),
+])
+
+D3D11_DEPTH_STENCIL_DESC = Struct("D3D11_DEPTH_STENCIL_DESC", [
+    (BOOL, "DepthEnable"),
+    (D3D11_DEPTH_WRITE_MASK, "DepthWriteMask"),
+    (D3D11_COMPARISON_FUNC, "DepthFunc"),
+    (BOOL, "StencilEnable"),
+    (UINT8, "StencilReadMask"),
+    (UINT8, "StencilWriteMask"),
+    (D3D11_DEPTH_STENCILOP_DESC, "FrontFace"),
+    (D3D11_DEPTH_STENCILOP_DESC, "BackFace"),
+])
+
+ID3D11DepthStencilState.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_DEPTH_STENCIL_DESC), "pDesc")]),
+]
+
+D3D11_BLEND = Enum("D3D11_BLEND", [
+    "D3D11_BLEND_ZERO",
+    "D3D11_BLEND_ONE",
+    "D3D11_BLEND_SRC_COLOR",
+    "D3D11_BLEND_INV_SRC_COLOR",
+    "D3D11_BLEND_SRC_ALPHA",
+    "D3D11_BLEND_INV_SRC_ALPHA",
+    "D3D11_BLEND_DEST_ALPHA",
+    "D3D11_BLEND_INV_DEST_ALPHA",
+    "D3D11_BLEND_DEST_COLOR",
+    "D3D11_BLEND_INV_DEST_COLOR",
+    "D3D11_BLEND_SRC_ALPHA_SAT",
+    "D3D11_BLEND_BLEND_FACTOR",
+    "D3D11_BLEND_INV_BLEND_FACTOR",
+    "D3D11_BLEND_SRC1_COLOR",
+    "D3D11_BLEND_INV_SRC1_COLOR",
+    "D3D11_BLEND_SRC1_ALPHA",
+    "D3D11_BLEND_INV_SRC1_ALPHA",
+])
+
+D3D11_BLEND_OP = Enum("D3D11_BLEND_OP", [
+    "D3D11_BLEND_OP_ADD",
+    "D3D11_BLEND_OP_SUBTRACT",
+    "D3D11_BLEND_OP_REV_SUBTRACT",
+    "D3D11_BLEND_OP_MIN",
+    "D3D11_BLEND_OP_MAX",
+])
+
+D3D11_COLOR_WRITE_ENABLE = Enum("D3D11_COLOR_WRITE_ENABLE", [
+    "D3D11_COLOR_WRITE_ENABLE_ALL",
+    "D3D11_COLOR_WRITE_ENABLE_RED",
+    "D3D11_COLOR_WRITE_ENABLE_GREEN",
+    "D3D11_COLOR_WRITE_ENABLE_BLUE",
+    "D3D11_COLOR_WRITE_ENABLE_ALPHA",
+])
+
+D3D11_RENDER_TARGET_BLEND_DESC = Struct("D3D11_RENDER_TARGET_BLEND_DESC", [
+    (BOOL, "BlendEnable"),
+    (D3D11_BLEND, "SrcBlend"),
+    (D3D11_BLEND, "DestBlend"),
+    (D3D11_BLEND_OP, "BlendOp"),
+    (D3D11_BLEND, "SrcBlendAlpha"),
+    (D3D11_BLEND, "DestBlendAlpha"),
+    (D3D11_BLEND_OP, "BlendOpAlpha"),
+    (UINT8, "RenderTargetWriteMask"),
+])
+
+D3D11_BLEND_DESC = Struct("D3D11_BLEND_DESC", [
+    (BOOL, "AlphaToCoverageEnable"),
+    (BOOL, "IndependentBlendEnable"),
+    (Array(D3D11_RENDER_TARGET_BLEND_DESC, 8), "RenderTarget"),
+])
+
+ID3D11BlendState.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_BLEND_DESC), "pDesc")]),
+]
+
+D3D11_RASTERIZER_DESC = Struct("D3D11_RASTERIZER_DESC", [
+    (D3D11_FILL_MODE, "FillMode"),
+    (D3D11_CULL_MODE, "CullMode"),
+    (BOOL, "FrontCounterClockwise"),
+    (INT, "DepthBias"),
+    (FLOAT, "DepthBiasClamp"),
+    (FLOAT, "SlopeScaledDepthBias"),
+    (BOOL, "DepthClipEnable"),
+    (BOOL, "ScissorEnable"),
+    (BOOL, "MultisampleEnable"),
+    (BOOL, "AntialiasedLineEnable"),
+])
+
+ID3D11RasterizerState.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_RASTERIZER_DESC), "pDesc")]),
+]
+
+D3D11_SUBRESOURCE_DATA = Struct("D3D11_SUBRESOURCE_DATA", [
+    (OpaquePointer(Const(Void)), "pSysMem"),
+    (UINT, "SysMemPitch"),
+    (UINT, "SysMemSlicePitch"),
+])
+
+D3D11_MAPPED_SUBRESOURCE = Struct("D3D11_MAPPED_SUBRESOURCE", [
+    (OpaquePointer(Void), "pData"),
+    (UINT, "RowPitch"),
+    (UINT, "DepthPitch"),
+])
+
+ID3D11Resource.methods += [
+    StdMethod(Void, "GetType", [Out(Pointer(D3D11_RESOURCE_DIMENSION), "pResourceDimension")]),
+    StdMethod(Void, "SetEvictionPriority", [(UINT, "EvictionPriority")]),
+    StdMethod(UINT, "GetEvictionPriority", []),
+]
+
+D3D11_BUFFER_DESC = Struct("D3D11_BUFFER_DESC", [
+    (UINT, "ByteWidth"),
+    (D3D11_USAGE, "Usage"),
+    (D3D11_BIND_FLAG, "BindFlags"),
+    (D3D11_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D11_RESOURCE_MISC_FLAG, "MiscFlags"),
+    (UINT, "StructureByteStride"),
+])
+
+ID3D11Buffer.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_BUFFER_DESC), "pDesc")]),
+]
+
+D3D11_TEXTURE1D_DESC = Struct("D3D11_TEXTURE1D_DESC", [
+    (UINT, "Width"),
+    (UINT, "MipLevels"),
+    (UINT, "ArraySize"),
+    (DXGI_FORMAT, "Format"),
+    (D3D11_USAGE, "Usage"),
+    (D3D11_BIND_FLAG, "BindFlags"),
+    (D3D11_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D11_RESOURCE_MISC_FLAG, "MiscFlags"),
+])
+
+ID3D11Texture1D.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_TEXTURE1D_DESC), "pDesc")]),
+]
+
+D3D11_TEXTURE2D_DESC = Struct("D3D11_TEXTURE2D_DESC", [
+    (UINT, "Width"),
+    (UINT, "Height"),
+    (UINT, "MipLevels"),
+    (UINT, "ArraySize"),
+    (DXGI_FORMAT, "Format"),
+    (DXGI_SAMPLE_DESC, "SampleDesc"),
+    (D3D11_USAGE, "Usage"),
+    (D3D11_BIND_FLAG, "BindFlags"),
+    (D3D11_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D11_RESOURCE_MISC_FLAG, "MiscFlags"),
+])
+
+ID3D11Texture2D.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_TEXTURE2D_DESC), "pDesc")]),
+]
+
+D3D11_TEXTURE3D_DESC = Struct("D3D11_TEXTURE3D_DESC", [
+    (UINT, "Width"),
+    (UINT, "Height"),
+    (UINT, "Depth"),
+    (UINT, "MipLevels"),
+    (DXGI_FORMAT, "Format"),
+    (D3D11_USAGE, "Usage"),
+    (D3D11_BIND_FLAG, "BindFlags"),
+    (D3D11_CPU_ACCESS_FLAG, "CPUAccessFlags"),
+    (D3D11_RESOURCE_MISC_FLAG, "MiscFlags"),
+])
+
+ID3D11Texture3D.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_TEXTURE3D_DESC), "pDesc")]),
+]
+
+D3D11_TEXTURECUBE_FACE = Enum("D3D11_TEXTURECUBE_FACE", [
+    "D3D11_TEXTURECUBE_FACE_POSITIVE_X",
+    "D3D11_TEXTURECUBE_FACE_NEGATIVE_X",
+    "D3D11_TEXTURECUBE_FACE_POSITIVE_Y",
+    "D3D11_TEXTURECUBE_FACE_NEGATIVE_Y",
+    "D3D11_TEXTURECUBE_FACE_POSITIVE_Z",
+    "D3D11_TEXTURECUBE_FACE_NEGATIVE_Z",
+])
+
+ID3D11View.methods += [
+    StdMethod(Void, "GetResource", [Out(Pointer(ObjPointer(ID3D11Resource)), "ppResource")]),
+]
+
+D3D11_BUFFER_SRV = Struct("D3D11_BUFFER_SRV", [
+    (Union(None, [(UINT, "FirstElement"), (UINT, "ElementOffset")]), None),
+    (Union(None, [(UINT, "NumElements"), (UINT, "ElementWidth")]), None),
+])
+
+D3D11_BUFFEREX_SRV_FLAG = Flags(UINT, [
+    "D3D11_BUFFEREX_SRV_FLAG_RAW",
+])
+
+D3D11_BUFFEREX_SRV = Struct("D3D11_BUFFEREX_SRV", [
+    (UINT, "FirstElement"),
+    (UINT, "NumElements"),
+    (D3D11_BUFFEREX_SRV_FLAG, "Flags"),
+])
+
+D3D11_TEX1D_SRV = Struct("D3D11_TEX1D_SRV", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+])
+
+D3D11_TEX1D_ARRAY_SRV = Struct("D3D11_TEX1D_ARRAY_SRV", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX2D_SRV = Struct("D3D11_TEX2D_SRV", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+])
+
+D3D11_TEX2D_ARRAY_SRV = Struct("D3D11_TEX2D_ARRAY_SRV", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX3D_SRV = Struct("D3D11_TEX3D_SRV", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+])
+
+D3D11_TEXCUBE_SRV = Struct("D3D11_TEXCUBE_SRV", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+])
+
+D3D11_TEXCUBE_ARRAY_SRV = Struct("D3D11_TEXCUBE_ARRAY_SRV", [
+    (UINT, "MostDetailedMip"),
+    (UINT, "MipLevels"),
+    (UINT, "First2DArrayFace"),
+    (UINT, "NumCubes"),
+])
+
+D3D11_TEX2DMS_SRV = Struct("D3D11_TEX2DMS_SRV", [
+    (UINT, "UnusedField_NothingToDefine"),
+])
+
+D3D11_TEX2DMS_ARRAY_SRV = Struct("D3D11_TEX2DMS_ARRAY_SRV", [
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_SHADER_RESOURCE_VIEW_DESC = Struct("D3D11_SHADER_RESOURCE_VIEW_DESC", [
+    (DXGI_FORMAT, "Format"),
+    (D3D11_SRV_DIMENSION, "ViewDimension"),
+    (Union(None, [
+        (D3D11_BUFFER_SRV, "Buffer"),
+        (D3D11_TEX1D_SRV, "Texture1D"),
+        (D3D11_TEX1D_ARRAY_SRV, "Texture1DArray"),
+        (D3D11_TEX2D_SRV, "Texture2D"), 
+        (D3D11_TEX2D_ARRAY_SRV, "Texture2DArray"),
+        (D3D11_TEX2DMS_SRV, "Texture2DMS"),
+        (D3D11_TEX2DMS_ARRAY_SRV, "Texture2DMSArray"),
+        (D3D11_TEX3D_SRV, "Texture3D"),
+        (D3D11_TEXCUBE_SRV, "TextureCube"),
+        (D3D11_TEXCUBE_ARRAY_SRV, "TextureCubeArray"),
+        (D3D11_BUFFEREX_SRV, "BufferEx"),
+    ]), None),
+])
+
+ID3D11ShaderResourceView.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_SHADER_RESOURCE_VIEW_DESC), "pDesc")]),
+]
+
+D3D11_BUFFER_RTV = Struct("D3D11_BUFFER_RTV", [
+    (Union(None, [(UINT, "FirstElement"), (UINT, "ElementOffset")]), None),
+    (Union(None, [(UINT, "NumElements"), (UINT, "ElementWidth")]), None),
+])
+
+D3D11_TEX1D_RTV = Struct("D3D11_TEX1D_RTV", [
+    (UINT, "MipSlice"),
+])
+
+D3D11_TEX1D_ARRAY_RTV = Struct("D3D11_TEX1D_ARRAY_RTV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX2D_RTV = Struct("D3D11_TEX2D_RTV", [
+    (UINT, "MipSlice"),
+])
+
+D3D11_TEX2DMS_RTV = Struct("D3D11_TEX2DMS_RTV", [
+    (UINT, "UnusedField_NothingToDefine"),
+])
+
+D3D11_TEX2D_ARRAY_RTV = Struct("D3D11_TEX2D_ARRAY_RTV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX2DMS_ARRAY_RTV = Struct("D3D11_TEX2DMS_ARRAY_RTV", [
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX3D_RTV = Struct("D3D11_TEX3D_RTV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstWSlice"),
+    (UINT, "WSize"),
+])
+
+D3D11_RENDER_TARGET_VIEW_DESC = Struct("D3D11_RENDER_TARGET_VIEW_DESC", [
+    (DXGI_FORMAT, "Format"),
+    (D3D11_RTV_DIMENSION, "ViewDimension"),
+    (Union(None, [
+        (D3D11_BUFFER_RTV, "Buffer"),
+        (D3D11_TEX1D_RTV, "Texture1D"),
+        (D3D11_TEX1D_ARRAY_RTV, "Texture1DArray"),
+        (D3D11_TEX2D_RTV, "Texture2D"),
+        (D3D11_TEX2D_ARRAY_RTV, "Texture2DArray"),
+        (D3D11_TEX2DMS_RTV, "Texture2DMS"),
+        (D3D11_TEX2DMS_ARRAY_RTV, "Texture2DMSArray"),
+        (D3D11_TEX3D_RTV, "Texture3D"),
+    ]), None),
+])
+
+ID3D11RenderTargetView.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_RENDER_TARGET_VIEW_DESC), "pDesc")]),
+]
+
+D3D11_TEX1D_DSV = Struct("D3D11_TEX1D_DSV", [
+    (UINT, "MipSlice"),
+])
+
+D3D11_TEX1D_ARRAY_DSV = Struct("D3D11_TEX1D_ARRAY_DSV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX2D_DSV = Struct("D3D11_TEX2D_DSV", [
+    (UINT, "MipSlice"),
+])
+
+D3D11_TEX2D_ARRAY_DSV = Struct("D3D11_TEX2D_ARRAY_DSV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX2DMS_DSV = Struct("D3D11_TEX2DMS_DSV", [
+    (UINT, "UnusedField_NothingToDefine"),
+])
+
+D3D11_TEX2DMS_ARRAY_DSV = Struct("D3D11_TEX2DMS_ARRAY_DSV", [
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_DSV_FLAG = Flags(UINT, [
+    "D3D11_DSV_READ_ONLY_DEPTH",
+    "D3D11_DSV_READ_ONLY_STENCIL",
+])
+
+D3D11_DEPTH_STENCIL_VIEW_DESC = Struct("D3D11_DEPTH_STENCIL_VIEW_DESC", [
+    (DXGI_FORMAT, "Format"),
+    (D3D11_DSV_DIMENSION, "ViewDimension"),
+    (D3D11_DSV_FLAG, "Flags"),
+    (Union(None, [
+        (D3D11_TEX1D_DSV, "Texture1D"),
+        (D3D11_TEX1D_ARRAY_DSV, "Texture1DArray"),
+        (D3D11_TEX2D_DSV, "Texture2D"),
+        (D3D11_TEX2D_ARRAY_DSV, "Texture2DArray"),
+        (D3D11_TEX2DMS_DSV, "Texture2DMS"),
+        (D3D11_TEX2DMS_ARRAY_DSV, "Texture2DMSArray"),
+    ]), None),
+])
+
+ID3D11DepthStencilView.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_DEPTH_STENCIL_VIEW_DESC), "pDesc")]),
+]
+
+D3D11_BUFFER_UAV_FLAG = Flags(UINT, [
+    "D3D11_BUFFER_UAV_FLAG_RAW",
+    "D3D11_BUFFER_UAV_FLAG_APPEND",
+    "D3D11_BUFFER_UAV_FLAG_COUNTER",
+])
+
+D3D11_BUFFER_UAV = Struct("D3D11_BUFFER_UAV", [
+    (UINT, "FirstElement"),
+    (UINT, "NumElements"),
+    (D3D11_BUFFER_UAV_FLAG, "Flags"),
+])
+
+D3D11_TEX1D_UAV = Struct("D3D11_TEX1D_UAV", [
+    (UINT, "MipSlice"),
+])
+
+D3D11_TEX1D_ARRAY_UAV = Struct("D3D11_TEX1D_ARRAY_UAV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX2D_UAV = Struct("D3D11_TEX2D_UAV", [
+    (UINT, "MipSlice"),
+])
+
+D3D11_TEX2D_ARRAY_UAV = Struct("D3D11_TEX2D_ARRAY_UAV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstArraySlice"),
+    (UINT, "ArraySize"),
+])
+
+D3D11_TEX3D_UAV = Struct("D3D11_TEX3D_UAV", [
+    (UINT, "MipSlice"),
+    (UINT, "FirstWSlice"),
+    (UINT, "WSize"),
+])
+
+D3D11_UNORDERED_ACCESS_VIEW_DESC = Struct("D3D11_UNORDERED_ACCESS_VIEW_DESC", [
+    (DXGI_FORMAT, "Format"),
+    (D3D11_UAV_DIMENSION, "ViewDimension"),
+    (Union(None, [
+        (D3D11_BUFFER_UAV, "Buffer"),
+        (D3D11_TEX1D_UAV, "Texture1D"),
+        (D3D11_TEX1D_ARRAY_UAV, "Texture1DArray"),
+        (D3D11_TEX2D_UAV, "Texture2D"),
+        (D3D11_TEX2D_ARRAY_UAV, "Texture2DArray"),
+        (D3D11_TEX3D_UAV, "Texture3D"),
+    ]), None),
+])
+
+ID3D11UnorderedAccessView.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_UNORDERED_ACCESS_VIEW_DESC), "pDesc")]),
+]
+
+D3D11_FILTER = Enum("D3D11_FILTER", [
+    "D3D11_FILTER_MIN_MAG_MIP_POINT",
+    "D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR",
+    "D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT",
+    "D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR",
+    "D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT",
+    "D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR",
+    "D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT",
+    "D3D11_FILTER_MIN_MAG_MIP_LINEAR",
+    "D3D11_FILTER_ANISOTROPIC",
+    "D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT",
+    "D3D11_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR",
+    "D3D11_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT",
+    "D3D11_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR",
+    "D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT",
+    "D3D11_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR",
+    "D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT",
+    "D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR",
+    "D3D11_FILTER_COMPARISON_ANISOTROPIC",
+])
+
+D3D11_FILTER_TYPE = Enum("D3D11_FILTER_TYPE", [
+    "D3D11_FILTER_TYPE_POINT",
+    "D3D11_FILTER_TYPE_LINEAR",
+])
+
+D3D11_TEXTURE_ADDRESS_MODE = Enum("D3D11_TEXTURE_ADDRESS_MODE", [
+    "D3D11_TEXTURE_ADDRESS_WRAP",
+    "D3D11_TEXTURE_ADDRESS_MIRROR",
+    "D3D11_TEXTURE_ADDRESS_CLAMP",
+    "D3D11_TEXTURE_ADDRESS_BORDER",
+    "D3D11_TEXTURE_ADDRESS_MIRROR_ONCE",
+])
+
+D3D11_SAMPLER_DESC = Struct("D3D11_SAMPLER_DESC", [
+    (D3D11_FILTER, "Filter"),
+    (D3D11_TEXTURE_ADDRESS_MODE, "AddressU"),
+    (D3D11_TEXTURE_ADDRESS_MODE, "AddressV"),
+    (D3D11_TEXTURE_ADDRESS_MODE, "AddressW"),
+    (FLOAT, "MipLODBias"),
+    (UINT, "MaxAnisotropy"),
+    (D3D11_COMPARISON_FUNC, "ComparisonFunc"),
+    (Array(FLOAT, 4), "BorderColor"),
+    (FLOAT, "MinLOD"),
+    (FLOAT, "MaxLOD"),
+])
+
+ID3D11SamplerState.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_SAMPLER_DESC), "pDesc")]),
+]
+
+D3D11_FORMAT_SUPPORT = Flags(UINT, [
+    "D3D11_FORMAT_SUPPORT_BUFFER",
+    "D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER",
+    "D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER",
+    "D3D11_FORMAT_SUPPORT_SO_BUFFER",
+    "D3D11_FORMAT_SUPPORT_TEXTURE1D",
+    "D3D11_FORMAT_SUPPORT_TEXTURE2D",
+    "D3D11_FORMAT_SUPPORT_TEXTURE3D",
+    "D3D11_FORMAT_SUPPORT_TEXTURECUBE",
+    "D3D11_FORMAT_SUPPORT_SHADER_LOAD",
+    "D3D11_FORMAT_SUPPORT_SHADER_SAMPLE",
+    "D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON",
+    "D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_MONO_TEXT",
+    "D3D11_FORMAT_SUPPORT_MIP",
+    "D3D11_FORMAT_SUPPORT_MIP_AUTOGEN",
+    "D3D11_FORMAT_SUPPORT_RENDER_TARGET",
+    "D3D11_FORMAT_SUPPORT_BLENDABLE",
+    "D3D11_FORMAT_SUPPORT_DEPTH_STENCIL",
+    "D3D11_FORMAT_SUPPORT_CPU_LOCKABLE",
+    "D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE",
+    "D3D11_FORMAT_SUPPORT_DISPLAY",
+    "D3D11_FORMAT_SUPPORT_CAST_WITHIN_BIT_LAYOUT",
+    "D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET",
+    "D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD",
+    "D3D11_FORMAT_SUPPORT_SHADER_GATHER",
+    "D3D11_FORMAT_SUPPORT_BACK_BUFFER_CAST",
+    "D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW",
+    "D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON",
+])
+
+D3D11_FORMAT_SUPPORT2 = Enum("D3D11_FORMAT_SUPPORT2", [
+    "D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_ADD",
+    "D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS",
+    "D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE",
+    "D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE",
+    "D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX",
+    "D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX",
+    "D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD",
+    "D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE",
+])
+
+ID3D11Asynchronous.methods += [
+    StdMethod(UINT, "GetDataSize", []),
+]
+
+D3D11_ASYNC_GETDATA_FLAG = Flags(UINT, [
+    "D3D11_ASYNC_GETDATA_DONOTFLUSH",
+])
+
+D3D11_QUERY = Enum("D3D11_QUERY", [
+    "D3D11_QUERY_EVENT",
+    "D3D11_QUERY_OCCLUSION",
+    "D3D11_QUERY_TIMESTAMP",
+    "D3D11_QUERY_TIMESTAMP_DISJOINT",
+    "D3D11_QUERY_PIPELINE_STATISTICS",
+    "D3D11_QUERY_OCCLUSION_PREDICATE",
+    "D3D11_QUERY_SO_STATISTICS",
+    "D3D11_QUERY_SO_OVERFLOW_PREDICATE",
+    "D3D11_QUERY_SO_STATISTICS_STREAM0",
+    "D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM0",
+    "D3D11_QUERY_SO_STATISTICS_STREAM1",
+    "D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM1",
+    "D3D11_QUERY_SO_STATISTICS_STREAM2",
+    "D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM2",
+    "D3D11_QUERY_SO_STATISTICS_STREAM3",
+    "D3D11_QUERY_SO_OVERFLOW_PREDICATE_STREAM3",
+])
+
+D3D11_QUERY_MISC_FLAG = Flags(UINT, [
+    "D3D11_QUERY_MISC_PREDICATEHINT",
+])
+
+D3D11_QUERY_DESC = Struct("D3D11_QUERY_DESC", [
+    (D3D11_QUERY, "Query"),
+    (D3D11_QUERY_MISC_FLAG, "MiscFlags"),
+])
+
+ID3D11Query.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_QUERY_DESC), "pDesc")]),
+]
+
+D3D11_QUERY_DATA_TIMESTAMP_DISJOINT = Struct("D3D11_QUERY_DATA_TIMESTAMP_DISJOINT", [
+    (UINT64, "Frequency"),
+    (BOOL, "Disjoint"),
+])
+
+D3D11_QUERY_DATA_PIPELINE_STATISTICS = Struct("D3D11_QUERY_DATA_PIPELINE_STATISTICS", [
+    (UINT64, "IAVertices"),
+    (UINT64, "IAPrimitives"),
+    (UINT64, "VSInvocations"),
+    (UINT64, "GSInvocations"),
+    (UINT64, "GSPrimitives"),
+    (UINT64, "CInvocations"),
+    (UINT64, "CPrimitives"),
+    (UINT64, "PSInvocations"),
+    (UINT64, "HSInvocations"),
+    (UINT64, "DSInvocations"),
+    (UINT64, "CSInvocations"),
+])
+
+D3D11_QUERY_DATA_SO_STATISTICS = Struct("D3D11_QUERY_DATA_SO_STATISTICS", [
+    (UINT64, "NumPrimitivesWritten"),
+    (UINT64, "PrimitivesStorageNeeded"),
+])
+
+D3D11_COUNTER = Enum("D3D11_COUNTER", [
+    "D3D11_COUNTER_DEVICE_DEPENDENT_0",
+])
+
+D3D11_COUNTER_TYPE = Enum("D3D11_COUNTER_TYPE", [
+    "D3D11_COUNTER_TYPE_FLOAT32",
+    "D3D11_COUNTER_TYPE_UINT16",
+    "D3D11_COUNTER_TYPE_UINT32",
+    "D3D11_COUNTER_TYPE_UINT64",
+])
+
+D3D11_COUNTER_DESC = Struct("D3D11_COUNTER_DESC", [
+    (D3D11_COUNTER, "Counter"),
+    (UINT, "MiscFlags"),
+])
+
+D3D11_COUNTER_INFO = Struct("D3D11_COUNTER_INFO", [
+    (D3D11_COUNTER, "LastDeviceDependentCounter"),
+    (UINT, "NumSimultaneousCounters"),
+    (UINT8, "NumDetectableParallelUnits"),
+])
+
+ID3D11Counter.methods += [
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_COUNTER_DESC), "pDesc")]),
+]
+
+D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS = Enum("D3D11_STANDARD_MULTISAMPLE_QUALITY_LEVELS", [
+    "D3D11_STANDARD_MULTISAMPLE_PATTERN",
+    "D3D11_CENTER_MULTISAMPLE_PATTERN",
+])
+
+D3D11_DEVICE_CONTEXT_TYPE = Enum("D3D11_DEVICE_CONTEXT_TYPE", [
+    "D3D11_DEVICE_CONTEXT_IMMEDIATE",
+    "D3D11_DEVICE_CONTEXT_DEFERRED",
+])
+
+D3D11_CLASS_INSTANCE_DESC = Struct("D3D11_CLASS_INSTANCE_DESC", [
+    (UINT, "InstanceId"),
+    (UINT, "InstanceIndex"),
+    (UINT, "TypeId"),
+    (UINT, "ConstantBuffer"),
+    (UINT, "BaseConstantBufferOffset"),
+    (UINT, "BaseTexture"),
+    (UINT, "BaseSampler"),
+    (BOOL, "Created"),
+])
+
+
+ID3D11ClassInstance.methods += [
+    StdMethod(Void, "GetClassLinkage", [Out(Pointer(ObjPointer(ID3D11ClassLinkage)), "ppLinkage")]),
+    StdMethod(Void, "GetDesc", [Out(Pointer(D3D11_CLASS_INSTANCE_DESC), "pDesc")]),
+    StdMethod(Void, "GetInstanceName", [Out(LPSTR, "pInstanceName"), Out(Pointer(SIZE_T), "pBufferLength")]),
+    StdMethod(Void, "GetTypeName", [Out(LPSTR, "pTypeName"), Out(Pointer(SIZE_T), "pBufferLength")]),
+]
+
+ID3D11ClassLinkage.methods += [
+    StdMethod(HRESULT, "GetClassInstance", [(LPCSTR, "pClassInstanceName"), (UINT, "InstanceIndex"), Out(Pointer(ObjPointer(ID3D11ClassInstance)), "ppInstance")]),
+    StdMethod(HRESULT, "CreateClassInstance", [(LPCSTR, "pClassTypeName"), (UINT, "ConstantBufferOffset"), (UINT, "ConstantVectorOffset"), (UINT, "TextureOffset"), (UINT, "SamplerOffset"), Out(Pointer(ObjPointer(ID3D11ClassInstance)), "ppInstance")]),
+]
+
+ID3D11CommandList.methods += [
+    StdMethod(UINT, "GetContextFlags", []),
+]
+
+D3D11_FEATURE_DATA_THREADING = Struct("D3D11_FEATURE_DATA_THREADING", [
+    (BOOL, "DriverConcurrentCreates"),
+    (BOOL, "DriverCommandLists"),
+])
+
+D3D11_FEATURE_DATA_DOUBLES = Struct("D3D11_FEATURE_DATA_DOUBLES", [
+    (BOOL, "DoublePrecisionFloatShaderOps"),
+])
+
+D3D11_FEATURE_DATA_FORMAT_SUPPORT = Struct("D3D11_FEATURE_DATA_FORMAT_SUPPORT", [
+    (DXGI_FORMAT, "InFormat"),
+    (D3D11_FORMAT_SUPPORT, "OutFormatSupport"),
+])
+
+D3D11_FEATURE_DATA_FORMAT_SUPPORT2 = Struct("D3D11_FEATURE_DATA_FORMAT_SUPPORT2", [
+    (DXGI_FORMAT, "InFormat"),
+    (D3D11_FORMAT_SUPPORT2, "OutFormatSupport2"),
+])
+
+D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS = Struct("D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS", [
+    (BOOL, "ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x"),
+])
+
+D3D11_FEATURE, D3D11_FEATURE_DATA = EnumPolymorphic("D3D11_FEATURE", "Feature", [
+    ("D3D11_FEATURE_THREADING", Pointer(D3D11_FEATURE_DATA_THREADING)),
+    ("D3D11_FEATURE_DOUBLES", Pointer(D3D11_FEATURE_DATA_DOUBLES)),
+    ("D3D11_FEATURE_FORMAT_SUPPORT", Pointer(D3D11_FEATURE_DATA_FORMAT_SUPPORT)),
+    ("D3D11_FEATURE_FORMAT_SUPPORT2", Pointer(D3D11_FEATURE_DATA_FORMAT_SUPPORT2)),
+    ("D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS", Pointer(D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS)),
+], Blob(Void, "FeatureSupportDataSize"), False)
+
+ID3D11DeviceContext.methods += [
+    StdMethod(Void, "VSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "PSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "PSSetShader", [(ObjPointer(ID3D11PixelShader), "pPixelShader"), (Array(Const(ObjPointer(ID3D11ClassInstance)), "NumClassInstances"), "ppClassInstances"), (UINT, "NumClassInstances")]),
+    StdMethod(Void, "PSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "VSSetShader", [(ObjPointer(ID3D11VertexShader), "pVertexShader"), (Array(Const(ObjPointer(ID3D11ClassInstance)), "NumClassInstances"), "ppClassInstances"), (UINT, "NumClassInstances")]),
+    StdMethod(Void, "DrawIndexed", [(UINT, "IndexCount"), (UINT, "StartIndexLocation"), (INT, "BaseVertexLocation")]),
+    StdMethod(Void, "Draw", [(UINT, "VertexCount"), (UINT, "StartVertexLocation")]),
+    StdMethod(HRESULT, "Map", [(ObjPointer(ID3D11Resource), "pResource"), (UINT, "Subresource"), (D3D11_MAP, "MapType"), (D3D11_MAP_FLAG, "MapFlags"), Out(Pointer(D3D11_MAPPED_SUBRESOURCE), "pMappedResource")]),
+    StdMethod(Void, "Unmap", [(ObjPointer(ID3D11Resource), "pResource"), (UINT, "Subresource")]),
+    StdMethod(Void, "PSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "IASetInputLayout", [(ObjPointer(ID3D11InputLayout), "pInputLayout")]),
+    StdMethod(Void, "IASetVertexBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppVertexBuffers"), (Pointer(Const(UINT)), "pStrides"), (Pointer(Const(UINT)), "pOffsets")]),
+    StdMethod(Void, "IASetIndexBuffer", [(ObjPointer(ID3D11Buffer), "pIndexBuffer"), (DXGI_FORMAT, "Format"), (UINT, "Offset")]),
+    StdMethod(Void, "DrawIndexedInstanced", [(UINT, "IndexCountPerInstance"), (UINT, "InstanceCount"), (UINT, "StartIndexLocation"), (INT, "BaseVertexLocation"), (UINT, "StartInstanceLocation")]),
+    StdMethod(Void, "DrawInstanced", [(UINT, "VertexCountPerInstance"), (UINT, "InstanceCount"), (UINT, "StartVertexLocation"), (UINT, "StartInstanceLocation")]),
+    StdMethod(Void, "GSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "GSSetShader", [(ObjPointer(ID3D11GeometryShader), "pShader"), (Array(Const(ObjPointer(ID3D11ClassInstance)), "NumClassInstances"), "ppClassInstances"), (UINT, "NumClassInstances")]),
+    StdMethod(Void, "IASetPrimitiveTopology", [(D3D11_PRIMITIVE_TOPOLOGY, "Topology")]),
+    StdMethod(Void, "VSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "VSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "Begin", [(ObjPointer(ID3D11Asynchronous), "pAsync")]),
+    StdMethod(Void, "End", [(ObjPointer(ID3D11Asynchronous), "pAsync")]),
+    StdMethod(HRESULT, "GetData", [(ObjPointer(ID3D11Asynchronous), "pAsync"), Out(OpaqueBlob(Void, "DataSize"), "pData"), (UINT, "DataSize"), (D3D11_ASYNC_GETDATA_FLAG, "GetDataFlags")]),
+    StdMethod(Void, "SetPredication", [(ObjPointer(ID3D11Predicate), "pPredicate"), (BOOL, "PredicateValue")]),
+    StdMethod(Void, "GSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "GSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "OMSetRenderTargets", [(UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11RenderTargetView)), "NumViews"), "ppRenderTargetViews"), (ObjPointer(ID3D11DepthStencilView), "pDepthStencilView")]),
+    StdMethod(Void, "OMSetRenderTargetsAndUnorderedAccessViews", [(UINT, "NumRTVs"), (Array(Const(ObjPointer(ID3D11RenderTargetView)), "NumRTVs"), "ppRenderTargetViews"), (ObjPointer(ID3D11DepthStencilView), "pDepthStencilView"), (UINT, "UAVStartSlot"), (UINT, "NumUAVs"), (Array(Const(ObjPointer(ID3D11UnorderedAccessView)), "NumUAVs"), "ppUnorderedAccessViews"), (Pointer(Const(UINT)), "pUAVInitialCounts")]),
+    StdMethod(Void, "OMSetBlendState", [(ObjPointer(ID3D11BlendState), "pBlendState"), (Array(Const(FLOAT), 4), "BlendFactor"), (UINT, "SampleMask")]),
+    StdMethod(Void, "OMSetDepthStencilState", [(ObjPointer(ID3D11DepthStencilState), "pDepthStencilState"), (UINT, "StencilRef")]),
+    StdMethod(Void, "SOSetTargets", [(UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppSOTargets"), (Pointer(Const(UINT)), "pOffsets")]),
+    StdMethod(Void, "DrawAuto", []),
+    StdMethod(Void, "DrawIndexedInstancedIndirect", [(ObjPointer(ID3D11Buffer), "pBufferForArgs"), (UINT, "AlignedByteOffsetForArgs")]),
+    StdMethod(Void, "DrawInstancedIndirect", [(ObjPointer(ID3D11Buffer), "pBufferForArgs"), (UINT, "AlignedByteOffsetForArgs")]),
+    StdMethod(Void, "Dispatch", [(UINT, "ThreadGroupCountX"), (UINT, "ThreadGroupCountY"), (UINT, "ThreadGroupCountZ")]),
+    StdMethod(Void, "DispatchIndirect", [(ObjPointer(ID3D11Buffer), "pBufferForArgs"), (UINT, "AlignedByteOffsetForArgs")]),
+    StdMethod(Void, "RSSetState", [(ObjPointer(ID3D11RasterizerState), "pRasterizerState")]),
+    StdMethod(Void, "RSSetViewports", [(UINT, "NumViewports"), (Array(Const(D3D11_VIEWPORT), "NumViewports"), "pViewports")]),
+    StdMethod(Void, "RSSetScissorRects", [(UINT, "NumRects"), (Array(Const(D3D11_RECT), "NumRects"), "pRects")]),
+    StdMethod(Void, "CopySubresourceRegion", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (UINT, "DstX"), (UINT, "DstY"), (UINT, "DstZ"), (ObjPointer(ID3D11Resource), "pSrcResource"), (UINT, "SrcSubresource"), (Pointer(Const(D3D11_BOX)), "pSrcBox")]),
+    StdMethod(Void, "CopyResource", [(ObjPointer(ID3D11Resource), "pDstResource"), (ObjPointer(ID3D11Resource), "pSrcResource")]),
+    StdMethod(Void, "UpdateSubresource", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D11_BOX)), "pDstBox"), (OpaquePointer(Const(Void)), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch")]),
+    StdMethod(Void, "CopyStructureCount", [(ObjPointer(ID3D11Buffer), "pDstBuffer"), (UINT, "DstAlignedByteOffset"), (ObjPointer(ID3D11UnorderedAccessView), "pSrcView")]),
+    StdMethod(Void, "ClearRenderTargetView", [(ObjPointer(ID3D11RenderTargetView), "pRenderTargetView"), (Array(Const(FLOAT), 4), "ColorRGBA")]),
+    StdMethod(Void, "ClearUnorderedAccessViewUint", [(ObjPointer(ID3D11UnorderedAccessView), "pUnorderedAccessView"), (Array(Const(UINT), 4), "Values")]),
+    StdMethod(Void, "ClearUnorderedAccessViewFloat", [(ObjPointer(ID3D11UnorderedAccessView), "pUnorderedAccessView"), (Array(Const(FLOAT), 4), "Values")]),
+    StdMethod(Void, "ClearDepthStencilView", [(ObjPointer(ID3D11DepthStencilView), "pDepthStencilView"), (D3D11_CLEAR_FLAG, "ClearFlags"), (FLOAT, "Depth"), (UINT8, "Stencil")]),
+    StdMethod(Void, "GenerateMips", [(ObjPointer(ID3D11ShaderResourceView), "pShaderResourceView")]),
+    StdMethod(Void, "SetResourceMinLOD", [(ObjPointer(ID3D11Resource), "pResource"), (FLOAT, "MinLOD")]),
+    StdMethod(FLOAT, "GetResourceMinLOD", [(ObjPointer(ID3D11Resource), "pResource")]),
+    StdMethod(Void, "ResolveSubresource", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (ObjPointer(ID3D11Resource), "pSrcResource"), (UINT, "SrcSubresource"), (DXGI_FORMAT, "Format")]),
+    StdMethod(Void, "ExecuteCommandList", [(ObjPointer(ID3D11CommandList), "pCommandList"), (BOOL, "RestoreContextState")]),
+    StdMethod(Void, "HSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "HSSetShader", [(ObjPointer(ID3D11HullShader), "pHullShader"), (Array(Const(ObjPointer(ID3D11ClassInstance)), "NumClassInstances"), "ppClassInstances"), (UINT, "NumClassInstances")]),
+    StdMethod(Void, "HSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "HSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "DSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "DSSetShader", [(ObjPointer(ID3D11DomainShader), "pDomainShader"), (Array(Const(ObjPointer(ID3D11ClassInstance)), "NumClassInstances"), "ppClassInstances"), (UINT, "NumClassInstances")]),
+    StdMethod(Void, "DSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "DSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "CSSetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(Const(ObjPointer(ID3D11ShaderResourceView)), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "CSSetUnorderedAccessViews", [(UINT, "StartSlot"), (UINT, "NumUAVs"), (Array(Const(ObjPointer(ID3D11UnorderedAccessView)), "NumUAVs"), "ppUnorderedAccessViews"), (Pointer(Const(UINT)), "pUAVInitialCounts")]),
+    StdMethod(Void, "CSSetShader", [(ObjPointer(ID3D11ComputeShader), "pComputeShader"), (Array(Const(ObjPointer(ID3D11ClassInstance)), "NumClassInstances"), "ppClassInstances"), (UINT, "NumClassInstances")]),
+    StdMethod(Void, "CSSetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(Const(ObjPointer(ID3D11SamplerState)), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "CSSetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "VSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "PSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(ObjPointer(ID3D11ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "PSGetShader", [Out(Pointer(ObjPointer(ID3D11PixelShader)), "ppPixelShader"), Out(Array(ObjPointer(ID3D11ClassInstance), "*pNumClassInstances"), "ppClassInstances"), Out(Pointer(UINT), "pNumClassInstances")]),
+    StdMethod(Void, "PSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(ObjPointer(ID3D11SamplerState), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "VSGetShader", [Out(Pointer(ObjPointer(ID3D11VertexShader)), "ppVertexShader"), Out(Array(ObjPointer(ID3D11ClassInstance), "*pNumClassInstances"), "ppClassInstances"), Out(Pointer(UINT), "pNumClassInstances")]),
+    StdMethod(Void, "PSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "IAGetInputLayout", [Out(Pointer(ObjPointer(ID3D11InputLayout)), "ppInputLayout")]),
+    StdMethod(Void, "IAGetVertexBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppVertexBuffers"), Out(Pointer(UINT), "pStrides"), Out(Pointer(UINT), "pOffsets")]),
+    StdMethod(Void, "IAGetIndexBuffer", [Out(Pointer(ObjPointer(ID3D11Buffer)), "pIndexBuffer"), Out(Pointer(DXGI_FORMAT), "Format"), Out(Pointer(UINT), "Offset")]),
+    StdMethod(Void, "GSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "GSGetShader", [Out(Pointer(ObjPointer(ID3D11GeometryShader)), "ppGeometryShader"), Out(Array(ObjPointer(ID3D11ClassInstance), "*pNumClassInstances"), "ppClassInstances"), Out(Pointer(UINT), "pNumClassInstances")]),
+    StdMethod(Void, "IAGetPrimitiveTopology", [Out(Pointer(D3D11_PRIMITIVE_TOPOLOGY), "pTopology")]),
+    StdMethod(Void, "VSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(ObjPointer(ID3D11ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "VSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(ObjPointer(ID3D11SamplerState), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "GetPredication", [Out(Pointer(ObjPointer(ID3D11Predicate)), "ppPredicate"), Out(Pointer(BOOL), "pPredicateValue")]),
+    StdMethod(Void, "GSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(ObjPointer(ID3D11ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "GSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(ObjPointer(ID3D11SamplerState), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "OMGetRenderTargets", [(UINT, "NumViews"), (Array(ObjPointer(ID3D11RenderTargetView), "NumViews"), "ppRenderTargetViews"), Out(Pointer(ObjPointer(ID3D11DepthStencilView)), "ppDepthStencilView")]),
+    StdMethod(Void, "OMGetRenderTargetsAndUnorderedAccessViews", [(UINT, "NumRTVs"), (Array(ObjPointer(ID3D11RenderTargetView), "NumRTVs"), "ppRenderTargetViews"), Out(Pointer(ObjPointer(ID3D11DepthStencilView)), "ppDepthStencilView"), (UINT, "UAVStartSlot"), (UINT, "NumUAVs"), (Array(ObjPointer(ID3D11UnorderedAccessView), "NumUAVs"), "ppUnorderedAccessViews")]),
+    StdMethod(Void, "OMGetBlendState", [Out(Pointer(ObjPointer(ID3D11BlendState)), "ppBlendState"), Out(Array(FLOAT, 4), "BlendFactor"), Out(Pointer(UINT), "pSampleMask")]),
+    StdMethod(Void, "OMGetDepthStencilState", [Out(Pointer(ObjPointer(ID3D11DepthStencilState)), "ppDepthStencilState"), Out(Pointer(UINT), "pStencilRef")]),
+    StdMethod(Void, "SOGetTargets", [(UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppSOTargets")]),
+    StdMethod(Void, "RSGetState", [Out(Pointer(ObjPointer(ID3D11RasterizerState)), "ppRasterizerState")]),
+    StdMethod(Void, "RSGetViewports", [Out(Pointer(UINT), "pNumViewports"), Out(Array(D3D11_VIEWPORT, "*pNumViewports"), "pViewports")]),
+    StdMethod(Void, "RSGetScissorRects", [Out(Pointer(UINT), "pNumRects"), Out(Array(D3D11_RECT, "*pNumRects"), "pRects")]),
+    StdMethod(Void, "HSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(ObjPointer(ID3D11ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "HSGetShader", [Out(Pointer(ObjPointer(ID3D11HullShader)), "ppHullShader"), Out(Array(ObjPointer(ID3D11ClassInstance), "*pNumClassInstances"), "ppClassInstances"), Out(Pointer(UINT), "pNumClassInstances")]),
+    StdMethod(Void, "HSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(ObjPointer(ID3D11SamplerState), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "HSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "DSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(ObjPointer(ID3D11ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "DSGetShader", [Out(Pointer(ObjPointer(ID3D11DomainShader)), "ppDomainShader"), Out(Array(ObjPointer(ID3D11ClassInstance), "*pNumClassInstances"), "ppClassInstances"), Out(Pointer(UINT), "pNumClassInstances")]),
+    StdMethod(Void, "DSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(ObjPointer(ID3D11SamplerState), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "DSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "CSGetShaderResources", [(UINT, "StartSlot"), (UINT, "NumViews"), (Array(ObjPointer(ID3D11ShaderResourceView), "NumViews"), "ppShaderResourceViews")]),
+    StdMethod(Void, "CSGetUnorderedAccessViews", [(UINT, "StartSlot"), (UINT, "NumUAVs"), (Array(ObjPointer(ID3D11UnorderedAccessView), "NumUAVs"), "ppUnorderedAccessViews")]),
+    StdMethod(Void, "CSGetShader", [Out(Pointer(ObjPointer(ID3D11ComputeShader)), "ppComputeShader"), Out(Array(ObjPointer(ID3D11ClassInstance), "*pNumClassInstances"), "ppClassInstances"), Out(Pointer(UINT), "pNumClassInstances")]),
+    StdMethod(Void, "CSGetSamplers", [(UINT, "StartSlot"), (UINT, "NumSamplers"), (Array(ObjPointer(ID3D11SamplerState), "NumSamplers"), "ppSamplers")]),
+    StdMethod(Void, "CSGetConstantBuffers", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers")]),
+    StdMethod(Void, "ClearState", []),
+    StdMethod(Void, "Flush", []),
+    StdMethod(D3D11_DEVICE_CONTEXT_TYPE, "GetType", []),
+    StdMethod(UINT, "GetContextFlags", []),
+    StdMethod(HRESULT, "FinishCommandList", [(BOOL, "RestoreDeferredContextState"), Out(Pointer(ObjPointer(ID3D11CommandList)), "ppCommandList")]),
+]
+
+D3D11_CREATE_DEVICE_FLAG = Flags(UINT, [
+    "D3D11_CREATE_DEVICE_SINGLETHREADED",
+    "D3D11_CREATE_DEVICE_DEBUG",
+    "D3D11_CREATE_DEVICE_SWITCH_TO_REF",
+    "D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS",
+    "D3D11_CREATE_DEVICE_BGRA_SUPPORT",
+])
+
+ID3D11Device.methods += [
+    StdMethod(HRESULT, "CreateBuffer", [(Pointer(Const(D3D11_BUFFER_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Buffer)), "ppBuffer")]),
+    StdMethod(HRESULT, "CreateTexture1D", [(Pointer(Const(D3D11_TEXTURE1D_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture1D)), "ppTexture1D")]),
+    StdMethod(HRESULT, "CreateTexture2D", [(Pointer(Const(D3D11_TEXTURE2D_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture2D)), "ppTexture2D")]),
+    StdMethod(HRESULT, "CreateTexture3D", [(Pointer(Const(D3D11_TEXTURE3D_DESC)), "pDesc"), (Pointer(Const(D3D11_SUBRESOURCE_DATA)), "pInitialData"), Out(Pointer(ObjPointer(ID3D11Texture3D)), "ppTexture3D")]),
+    StdMethod(HRESULT, "CreateShaderResourceView", [(ObjPointer(ID3D11Resource), "pResource"), (Pointer(Const(D3D11_SHADER_RESOURCE_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D11ShaderResourceView)), "ppSRView")]),
+    StdMethod(HRESULT, "CreateUnorderedAccessView", [(ObjPointer(ID3D11Resource), "pResource"), (Pointer(Const(D3D11_UNORDERED_ACCESS_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D11UnorderedAccessView)), "ppUAView")]),
+    StdMethod(HRESULT, "CreateRenderTargetView", [(ObjPointer(ID3D11Resource), "pResource"), (Pointer(Const(D3D11_RENDER_TARGET_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D11RenderTargetView)), "ppRTView")]),
+    StdMethod(HRESULT, "CreateDepthStencilView", [(ObjPointer(ID3D11Resource), "pResource"), (Pointer(Const(D3D11_DEPTH_STENCIL_VIEW_DESC)), "pDesc"), Out(Pointer(ObjPointer(ID3D11DepthStencilView)), "ppDepthStencilView")]),
+    StdMethod(HRESULT, "CreateInputLayout", [(Array(Const(D3D11_INPUT_ELEMENT_DESC), "NumElements"), "pInputElementDescs"), (UINT, "NumElements"), (Blob(Const(Void), "BytecodeLength"), "pShaderBytecodeWithInputSignature"), (SIZE_T, "BytecodeLength"), Out(Pointer(ObjPointer(ID3D11InputLayout)), "ppInputLayout")]),
+    StdMethod(HRESULT, "CreateVertexShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (ObjPointer(ID3D11ClassLinkage), "pClassLinkage"), Out(Pointer(ObjPointer(ID3D11VertexShader)), "ppVertexShader")]),
+    StdMethod(HRESULT, "CreateGeometryShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (ObjPointer(ID3D11ClassLinkage), "pClassLinkage"), Out(Pointer(ObjPointer(ID3D11GeometryShader)), "ppGeometryShader")]),
+    StdMethod(HRESULT, "CreateGeometryShaderWithStreamOutput", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (Array(Const(D3D11_SO_DECLARATION_ENTRY), "NumEntries"), "pSODeclaration"), (UINT, "NumEntries"), (Array(Const(UINT), "NumStrides"), "pBufferStrides"), (UINT, "NumStrides"), (UINT, "RasterizedStream"), (ObjPointer(ID3D11ClassLinkage), "pClassLinkage"), Out(Pointer(ObjPointer(ID3D11GeometryShader)), "ppGeometryShader")]),
+    StdMethod(HRESULT, "CreatePixelShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (ObjPointer(ID3D11ClassLinkage), "pClassLinkage"), Out(Pointer(ObjPointer(ID3D11PixelShader)), "ppPixelShader")]),
+    StdMethod(HRESULT, "CreateHullShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (ObjPointer(ID3D11ClassLinkage), "pClassLinkage"), Out(Pointer(ObjPointer(ID3D11HullShader)), "ppHullShader")]),
+    StdMethod(HRESULT, "CreateDomainShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (ObjPointer(ID3D11ClassLinkage), "pClassLinkage"), Out(Pointer(ObjPointer(ID3D11DomainShader)), "ppDomainShader")]),
+    StdMethod(HRESULT, "CreateComputeShader", [(Blob(Const(Void), "BytecodeLength"), "pShaderBytecode"), (SIZE_T, "BytecodeLength"), (ObjPointer(ID3D11ClassLinkage), "pClassLinkage"), Out(Pointer(ObjPointer(ID3D11ComputeShader)), "ppComputeShader")]),
+    StdMethod(HRESULT, "CreateClassLinkage", [Out(Pointer(ObjPointer(ID3D11ClassLinkage)), "ppLinkage")]),
+    StdMethod(HRESULT, "CreateBlendState", [(Pointer(Const(D3D11_BLEND_DESC)), "pBlendStateDesc"), Out(Pointer(ObjPointer(ID3D11BlendState)), "ppBlendState")]),
+    StdMethod(HRESULT, "CreateDepthStencilState", [(Pointer(Const(D3D11_DEPTH_STENCIL_DESC)), "pDepthStencilDesc"), Out(Pointer(ObjPointer(ID3D11DepthStencilState)), "ppDepthStencilState")]),
+    StdMethod(HRESULT, "CreateRasterizerState", [(Pointer(Const(D3D11_RASTERIZER_DESC)), "pRasterizerDesc"), Out(Pointer(ObjPointer(ID3D11RasterizerState)), "ppRasterizerState")]),
+    StdMethod(HRESULT, "CreateSamplerState", [(Pointer(Const(D3D11_SAMPLER_DESC)), "pSamplerDesc"), Out(Pointer(ObjPointer(ID3D11SamplerState)), "ppSamplerState")]),
+    StdMethod(HRESULT, "CreateQuery", [(Pointer(Const(D3D11_QUERY_DESC)), "pQueryDesc"), Out(Pointer(ObjPointer(ID3D11Query)), "ppQuery")]),
+    StdMethod(HRESULT, "CreatePredicate", [(Pointer(Const(D3D11_QUERY_DESC)), "pPredicateDesc"), Out(Pointer(ObjPointer(ID3D11Predicate)), "ppPredicate")]),
+    StdMethod(HRESULT, "CreateCounter", [(Pointer(Const(D3D11_COUNTER_DESC)), "pCounterDesc"), Out(Pointer(ObjPointer(ID3D11Counter)), "ppCounter")]),
+    StdMethod(HRESULT, "CreateDeferredContext", [(UINT, "ContextFlags"), Out(Pointer(ObjPointer(ID3D11DeviceContext)), "ppDeferredContext")]),
+    StdMethod(HRESULT, "OpenSharedResource", [(HANDLE, "hResource"), (REFIID, "ReturnedInterface"), Out(Pointer(ObjPointer(Void)), "ppResource")]),
+    StdMethod(HRESULT, "CheckFormatSupport", [(DXGI_FORMAT, "Format"), Out(Pointer(D3D11_FORMAT_SUPPORT), "pFormatSupport")]),
+    StdMethod(HRESULT, "CheckMultisampleQualityLevels", [(DXGI_FORMAT, "Format"), (UINT, "SampleCount"), Out(Pointer(UINT), "pNumQualityLevels")]),
+    StdMethod(Void, "CheckCounterInfo", [Out(Pointer(D3D11_COUNTER_INFO), "pCounterInfo")]),
+    StdMethod(HRESULT, "CheckCounter", [(Pointer(Const(D3D11_COUNTER_DESC)), "pDesc"), Out(Pointer(D3D11_COUNTER_TYPE), "pType"), Out(Pointer(UINT), "pActiveCounters"), Out(LPSTR, "szName"), Out(Pointer(UINT), "pNameLength"), Out(LPSTR, "szUnits"), Out(Pointer(UINT), "pUnitsLength"), Out(LPSTR, "szDescription"), Out(Pointer(UINT), "pDescriptionLength")]),
+    StdMethod(HRESULT, "CheckFeatureSupport", [(D3D11_FEATURE, "Feature"), Out(D3D11_FEATURE_DATA, "pFeatureSupportData"), (UINT, "FeatureSupportDataSize")]),
+    StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")]),
+    StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")]),
+    StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "pData")]),
+    StdMethod(D3D_FEATURE_LEVEL, "GetFeatureLevel", []),
+    StdMethod(D3D11_CREATE_DEVICE_FLAG, "GetCreationFlags", []),
+    StdMethod(HRESULT, "GetDeviceRemovedReason", []),
+    StdMethod(Void, "GetImmediateContext", [Out(Pointer(ObjPointer(ID3D11DeviceContext)), "ppImmediateContext")]),
+    StdMethod(HRESULT, "SetExceptionMode", [(D3D11_RAISE_FLAG, "RaiseFlags")]),
+    StdMethod(UINT, "GetExceptionMode", []),
+]
+
+d3d11 = API("d3d11")
+
+d3d11.addFunctions([
+    StdFunction(HRESULT, "D3D11CreateDevice", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D11_CREATE_DEVICE_FLAG, "Flags"), (Array(Const(D3D_FEATURE_LEVEL), "FeatureLevels"), "pFeatureLevels"), (UINT, "FeatureLevels"), (UINT, "SDKVersion"), Out(Pointer(ObjPointer(ID3D11Device)), "ppDevice"), Out(Pointer(D3D_FEATURE_LEVEL), "pFeatureLevel"), Out(Pointer(ObjPointer(ID3D11DeviceContext)), "ppImmediateContext")]),
+    StdFunction(HRESULT, "D3D11CreateDeviceAndSwapChain", [(ObjPointer(IDXGIAdapter), "pAdapter"), (D3D_DRIVER_TYPE, "DriverType"), (HMODULE, "Software"), (D3D11_CREATE_DEVICE_FLAG, "Flags"), (Array(Const(D3D_FEATURE_LEVEL), "FeatureLevels"), "pFeatureLevels"), (UINT, "FeatureLevels"), (UINT, "SDKVersion"), (Pointer(Const(DXGI_SWAP_CHAIN_DESC)), "pSwapChainDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain"), Out(Pointer(ObjPointer(ID3D11Device)), "ppDevice"), Out(Pointer(D3D_FEATURE_LEVEL), "pFeatureLevel"), Out(Pointer(ObjPointer(ID3D11DeviceContext)), "ppImmediateContext")]),
+
+    # XXX: Undocumented functions, called by d3d11sdklayers.dll when D3D11_CREATE_DEVICE_DEBUG is set
+    StdFunction(HRESULT, "D3D11CoreRegisterLayers", [LPCVOID, DWORD], internal=True),
+    StdFunction(SIZE_T, "D3D11CoreGetLayeredDeviceSize", [LPCVOID, DWORD], internal=True),
+    StdFunction(HRESULT, "D3D11CoreCreateLayeredDevice", [LPCVOID, DWORD, LPCVOID, (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppvObj")], internal=True),
+    StdFunction(HRESULT, "D3D11CoreCreateDevice", [DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD], internal=True),
+])
+
+d3d11.addInterfaces([
+    IDXGIAdapter1,
+    IDXGIDevice1,
+    IDXGIResource,
+    ID3D11Debug,
+    ID3D11InfoQueue,
+    ID3D11SwitchToRef,
+])
diff --git a/specs/d3d11_1.py b/specs/d3d11_1.py
new file mode 100644 (file)
index 0000000..c41e8af
--- /dev/null
@@ -0,0 +1,180 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+"""d3d11_1.h"""
+
+
+from winapi import *
+from d3d11sdklayers import *
+from d3d11 import *
+
+D3D_FEATURE_LEVEL.values += [
+    "D3D_FEATURE_LEVEL_11_1",
+]
+
+D3D11_CREATE_DEVICE_FLAG.values += [
+    "D3D11_CREATE_DEVICE_DEBUGGABLE",
+    "D3D11_CREATE_DEVICE_PREVENT_ALTERING_LAYER_SETTINGS_FROM_REGISTRY",
+    "D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT",
+    "D3D11_CREATE_DEVICE_VIDEO_SUPPORT",
+]
+
+D3D_MIN_PRECISION = Enum("D3D_MIN_PRECISION", [
+    "D3D_MIN_PRECISION_DEFAULT",
+    "D3D_MIN_PRECISION_FLOAT_16",
+    "D3D_MIN_PRECISION_FLOAT_2_8",
+    "D3D_MIN_PRECISION_RESERVED",
+    "D3D_MIN_PRECISION_SINT_16",
+    "D3D_MIN_PRECISION_UINT_16",
+    "D3D_MIN_PRECISION_ANY_16",
+    "D3D_MIN_PRECISION_ANY_10",
+])
+
+ID3D11BlendState1 = Interface("ID3D11BlendState1", ID3D11BlendState)
+ID3D11RasterizerState1 = Interface("ID3D11RasterizerState1", ID3D11RasterizerState)
+ID3DDeviceContextState = Interface("ID3DDeviceContextState", ID3D11DeviceChild)
+ID3D11DeviceContext1 = Interface("ID3D11DeviceContext1", ID3D11DeviceContext)
+ID3D11Device1 = Interface("ID3D11Device1", ID3D11Device)
+ID3DUserDefinedAnnotation = Interface("ID3DUserDefinedAnnotation", IUnknown)
+
+
+D3D11_COPY_FLAGS = Flags(UINT, [
+    "D3D11_COPY_NO_OVERWRITE",
+    "D3D11_COPY_DISCARD",
+])
+
+D3D11_LOGIC_OP = Enum("D3D11_LOGIC_OP", [
+    "D3D11_LOGIC_OP_CLEAR",
+    "D3D11_LOGIC_OP_SET",
+    "D3D11_LOGIC_OP_COPY",
+    "D3D11_LOGIC_OP_COPY_INVERTED",
+    "D3D11_LOGIC_OP_NOOP",
+    "D3D11_LOGIC_OP_INVERT",
+    "D3D11_LOGIC_OP_AND",
+    "D3D11_LOGIC_OP_NAND",
+    "D3D11_LOGIC_OP_OR",
+    "D3D11_LOGIC_OP_NOR",
+    "D3D11_LOGIC_OP_XOR",
+    "D3D11_LOGIC_OP_EQUIV",
+    "D3D11_LOGIC_OP_AND_REVERSE",
+    "D3D11_LOGIC_OP_AND_INVERTED",
+    "D3D11_LOGIC_OP_OR_REVERSE",
+    "D3D11_LOGIC_OP_OR_INVERTED",
+])
+
+D3D11_RENDER_TARGET_BLEND_DESC1 = Struct("D3D11_RENDER_TARGET_BLEND_DESC1", [
+    (BOOL, "BlendEnable"),
+    (BOOL, "LogicOpEnable"),
+    (D3D11_BLEND, "SrcBlend"),
+    (D3D11_BLEND, "DestBlend"),
+    (D3D11_BLEND_OP, "BlendOp"),
+    (D3D11_BLEND, "SrcBlendAlpha"),
+    (D3D11_BLEND, "DestBlendAlpha"),
+    (D3D11_BLEND_OP, "BlendOpAlpha"),
+    (D3D11_LOGIC_OP, "LogicOp"),
+    (UINT8, "RenderTargetWriteMask"),
+])
+
+D3D11_BLEND_DESC1 = Struct("D3D11_BLEND_DESC1", [
+    (BOOL, "AlphaToCoverageEnable"),
+    (BOOL, "IndependentBlendEnable"),
+    (Array(D3D11_RENDER_TARGET_BLEND_DESC1, "D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT"), "RenderTarget"),
+])
+
+ID3D11BlendState1.methods += [
+    Method(Void, "GetDesc1", [Out(Pointer(D3D11_BLEND_DESC1), "pDesc")]),
+]
+
+D3D11_RASTERIZER_DESC1 = Struct("D3D11_RASTERIZER_DESC1", [
+    (D3D11_FILL_MODE, "FillMode"),
+    (D3D11_CULL_MODE, "CullMode"),
+    (BOOL, "FrontCounterClockwise"),
+    (INT, "DepthBias"),
+    (FLOAT, "DepthBiasClamp"),
+    (FLOAT, "SlopeScaledDepthBias"),
+    (BOOL, "DepthClipEnable"),
+    (BOOL, "ScissorEnable"),
+    (BOOL, "MultisampleEnable"),
+    (BOOL, "AntialiasedLineEnable"),
+    (UINT, "ForcedSampleCount"),
+])
+
+ID3D11RasterizerState1.methods += [
+    Method(Void, "GetDesc1", [Out(Pointer(D3D11_RASTERIZER_DESC1), "pDesc")]),
+]
+
+D3D11_1_CREATE_DEVICE_CONTEXT_STATE_FLAG = Flags(UINT, [
+    "D3D11_1_CREATE_DEVICE_CONTEXT_STATE_SINGLETHREADED",
+])
+
+ID3D11DeviceContext1.methods += [
+    Method(Void, "CopySubresourceRegion1", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (UINT, "DstX"), (UINT, "DstY"), (UINT, "DstZ"), (ObjPointer(ID3D11Resource), "pSrcResource"), (UINT, "SrcSubresource"), (Pointer(Const(D3D11_BOX)), "pSrcBox"), (D3D11_COPY_FLAGS, "CopyFlags")]),
+    Method(Void, "UpdateSubresource1", [(ObjPointer(ID3D11Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D11_BOX)), "pDstBox"), (OpaquePointer(Const(Void)), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch"), (D3D11_COPY_FLAGS, "CopyFlags")]),
+    Method(Void, "DiscardResource", [(ObjPointer(ID3D11Resource), "pResource")]),
+    Method(Void, "DiscardView", [(ObjPointer(ID3D11View), "pResourceView")]),
+    Method(Void, "VSSetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers"), (Array(Const(UINT), "NumBuffers"), "pFirstConstant"), (Array(Const(UINT), "NumBuffers"), "pNumConstants")]),
+    Method(Void, "HSSetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers"), (Array(Const(UINT), "NumBuffers"), "pFirstConstant"), (Array(Const(UINT), "NumBuffers"), "pNumConstants")]),
+    Method(Void, "DSSetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers"), (Array(Const(UINT), "NumBuffers"), "pFirstConstant"), (Array(Const(UINT), "NumBuffers"), "pNumConstants")]),
+    Method(Void, "GSSetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers"), (Array(Const(UINT), "NumBuffers"), "pFirstConstant"), (Array(Const(UINT), "NumBuffers"), "pNumConstants")]),
+    Method(Void, "PSSetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers"), (Array(Const(UINT), "NumBuffers"), "pFirstConstant"), (Array(Const(UINT), "NumBuffers"), "pNumConstants")]),
+    Method(Void, "CSSetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), (Array(Const(ObjPointer(ID3D11Buffer)), "NumBuffers"), "ppConstantBuffers"), (Array(Const(UINT), "NumBuffers"), "pFirstConstant"), (Array(Const(UINT), "NumBuffers"), "pNumConstants")]),
+    Method(Void, "VSGetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers"), Out(Array(UINT, "NumBuffers"), "pFirstConstant"), Out(Array(UINT, "NumBuffers"), "pNumConstants")]),
+    Method(Void, "HSGetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers"), Out(Array(UINT, "NumBuffers"), "pFirstConstant"), Out(Array(UINT, "NumBuffers"), "pNumConstants")]),
+    Method(Void, "DSGetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers"), Out(Array(UINT, "NumBuffers"), "pFirstConstant"), Out(Array(UINT, "NumBuffers"), "pNumConstants")]),
+    Method(Void, "GSGetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers"), Out(Array(UINT, "NumBuffers"), "pFirstConstant"), Out(Array(UINT, "NumBuffers"), "pNumConstants")]),
+    Method(Void, "PSGetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers"), Out(Array(UINT, "NumBuffers"), "pFirstConstant"), Out(Array(UINT, "NumBuffers"), "pNumConstants")]),
+    Method(Void, "CSGetConstantBuffers1", [(UINT, "StartSlot"), (UINT, "NumBuffers"), Out(Array(ObjPointer(ID3D11Buffer), "NumBuffers"), "ppConstantBuffers"), Out(Array(UINT, "NumBuffers"), "pFirstConstant"), Out(Array(UINT, "NumBuffers"), "pNumConstants")]),
+    Method(Void, "SwapDeviceContextState", [(ObjPointer(ID3DDeviceContextState), "pState"), Out(Pointer(ObjPointer(ID3DDeviceContextState)), "ppPreviousState")]),
+    Method(Void, "ClearView", [(ObjPointer(ID3D11View), "pView"), (Array(Const(FLOAT), 4), "Color"), (Pointer(Const(D3D11_RECT)), "pRect"), (UINT, "NumRects")]),
+]
+
+
+DXGI_SHARED_RESOURCE_FLAG = Flags(DWORD, [
+    "DXGI_SHARED_RESOURCE_READ",
+    "DXGI_SHARED_RESOURCE_WRITE",
+])
+
+
+ID3D11Device1.methods += [
+    Method(Void, "GetImmediateContext1", [Out(Pointer(ObjPointer(ID3D11DeviceContext1)), "ppImmediateContext")]),
+    Method(HRESULT, "CreateDeferredContext1", [(UINT, "ContextFlags"), Out(Pointer(ObjPointer(ID3D11DeviceContext1)), "ppDeferredContext")]),
+    Method(HRESULT, "CreateBlendState1", [(Pointer(Const(D3D11_BLEND_DESC1)), "pBlendStateDesc"), Out(Pointer(ObjPointer(ID3D11BlendState1)), "ppBlendState")]),
+    Method(HRESULT, "CreateRasterizerState1", [(Pointer(Const(D3D11_RASTERIZER_DESC1)), "pRasterizerDesc"), Out(Pointer(ObjPointer(ID3D11RasterizerState1)), "ppRasterizerState")]),
+    Method(HRESULT, "CreateDeviceContextState", [(D3D11_1_CREATE_DEVICE_CONTEXT_STATE_FLAG, "Flags"), (Array(Const(D3D_FEATURE_LEVEL), "FeatureLevels"), "pFeatureLevels"), (UINT, "FeatureLevels"), (UINT, "SDKVersion"), (REFIID, "EmulatedInterface"), Out(Pointer(D3D_FEATURE_LEVEL), "pChosenFeatureLevel"), Out(Pointer(ObjPointer(ID3DDeviceContextState)), "ppContextState")]),
+    Method(HRESULT, "OpenSharedResource1", [(HANDLE, "hResource"), (REFIID, "returnedInterface"), Out(Pointer(ObjPointer(Void)), "ppResource")]),
+    Method(HRESULT, "OpenSharedResourceByName", [(LPCWSTR, "lpName"), (DXGI_SHARED_RESOURCE_FLAG, "dwDesiredAccess"), (REFIID, "returnedInterface"), Out(Pointer(ObjPointer(Void)), "ppResource")]),
+]
+
+ID3DUserDefinedAnnotation.methods += [
+    Method(INT, "BeginEvent", [(LPCWSTR, "Name")]),
+    Method(INT, "EndEvent", []),
+    Method(Void, "SetMarker", [(LPCWSTR, "Name")]),
+    Method(BOOL, "GetStatus", []),
+]
+
+d3d11.addInterfaces([
+    ID3D11Device1,
+    ID3DUserDefinedAnnotation,
+])
diff --git a/specs/d3d11sdklayers.py b/specs/d3d11sdklayers.py
new file mode 100644 (file)
index 0000000..13d85be
--- /dev/null
@@ -0,0 +1,890 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dxgi import *
+
+
+ID3D11DeviceChild = Interface("ID3D11DeviceChild", IUnknown)
+ID3D11DeviceContext = Interface("ID3D11DeviceContext", ID3D11DeviceChild)
+
+
+D3D11_DEBUG_FEATURE = Flags(UINT, [
+    "D3D11_DEBUG_FEATURE_FLUSH_PER_RENDER_OP",
+    "D3D11_DEBUG_FEATURE_FINISH_PER_RENDER_OP",
+    "D3D11_DEBUG_FEATURE_PRESENT_PER_RENDER_OP",
+])
+
+D3D11_RLDO_FLAGS = Enum("D3D11_RLDO_FLAGS", [
+    "D3D11_RLDO_SUMMARY",
+    "D3D11_RLDO_DETAIL",
+])
+
+ID3D11Debug = Interface("ID3D11Debug", IUnknown)
+ID3D11Debug.methods += [
+    StdMethod(HRESULT, "SetFeatureMask", [(D3D11_DEBUG_FEATURE, "Mask")]),
+    StdMethod(D3D11_DEBUG_FEATURE, "GetFeatureMask", []),
+    StdMethod(HRESULT, "SetPresentPerRenderOpDelay", [(UINT, "Milliseconds")]),
+    StdMethod(UINT, "GetPresentPerRenderOpDelay", []),
+    StdMethod(HRESULT, "SetSwapChain", [(ObjPointer(IDXGISwapChain), "pSwapChain")]),
+    StdMethod(HRESULT, "GetSwapChain", [Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain")]),
+    StdMethod(HRESULT, "ValidateContext", [(ObjPointer(ID3D11DeviceContext), "pContext")]),
+    StdMethod(HRESULT, "ReportLiveDeviceObjects", [(D3D11_RLDO_FLAGS, "Flags")]),
+    StdMethod(HRESULT, "ValidateContextForDispatch", [(ObjPointer(ID3D11DeviceContext), "pContext")]),
+]
+
+ID3D11SwitchToRef = Interface("ID3D11SwitchToRef", IUnknown)
+ID3D11SwitchToRef.methods += [
+    StdMethod(BOOL, "SetUseRef", [(BOOL, "UseRef")]),
+    StdMethod(BOOL, "GetUseRef", []),
+]
+
+D3D11_MESSAGE_CATEGORY = Enum("D3D11_MESSAGE_CATEGORY", [
+    "D3D11_MESSAGE_CATEGORY_APPLICATION_DEFINED",
+    "D3D11_MESSAGE_CATEGORY_MISCELLANEOUS",
+    "D3D11_MESSAGE_CATEGORY_INITIALIZATION",
+    "D3D11_MESSAGE_CATEGORY_CLEANUP",
+    "D3D11_MESSAGE_CATEGORY_COMPILATION",
+    "D3D11_MESSAGE_CATEGORY_STATE_CREATION",
+    "D3D11_MESSAGE_CATEGORY_STATE_SETTING",
+    "D3D11_MESSAGE_CATEGORY_STATE_GETTING",
+    "D3D11_MESSAGE_CATEGORY_RESOURCE_MANIPULATION",
+    "D3D11_MESSAGE_CATEGORY_EXECUTION",
+])
+
+D3D11_MESSAGE_SEVERITY = Enum("D3D11_MESSAGE_SEVERITY", [
+    "D3D11_MESSAGE_SEVERITY_CORRUPTION",
+    "D3D11_MESSAGE_SEVERITY_ERROR",
+    "D3D11_MESSAGE_SEVERITY_WARNING",
+    "D3D11_MESSAGE_SEVERITY_INFO",
+])
+
+D3D11_MESSAGE_ID = Enum("D3D11_MESSAGE_ID", [
+    "D3D11_MESSAGE_ID_UNKNOWN",
+    "D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETS_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_SOSETTARGETS_HAZARD",
+    "D3D11_MESSAGE_ID_STRING_FROM_APPLICATION",
+    "D3D11_MESSAGE_ID_CORRUPTED_THIS",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER1",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER2",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER3",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER4",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER5",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER6",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER7",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER8",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER9",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER10",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER11",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER12",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER13",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER14",
+    "D3D11_MESSAGE_ID_CORRUPTED_PARAMETER15",
+    "D3D11_MESSAGE_ID_CORRUPTED_MULTITHREADING",
+    "D3D11_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_IASETINPUTLAYOUT_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_IASETINDEXBUFFER_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_VSSETSHADER_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_VSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_VSSETSAMPLERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_GSSETSHADER_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_GSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_GSSETSAMPLERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_SOSETTARGETS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_PSSETSHADER_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_PSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_PSSETSAMPLERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_RSSETSTATE_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_OMSETBLENDSTATE_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_OMSETDEPTHSTENCILSTATE_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_OMSETRENDERTARGETS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_SETPREDICATION_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_GETPRIVATEDATA_MOREDATA",
+    "D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA",
+    "D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDIUNKNOWN",
+    "D3D11_MESSAGE_ID_SETPRIVATEDATA_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS",
+    "D3D11_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDSAMPLES",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDUSAGE",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_UNRECOGNIZEDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDINITIALDATA",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDMIPLEVELS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDCONSTANTBUFFERBINDINGS",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_LARGEALLOCATION",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_UNSUPPORTEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDSAMPLES",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDUSAGE",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_UNRECOGNIZEDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDINITIALDATA",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDMIPLEVELS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATETEXTURE1D_LARGEALLOCATION",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_UNSUPPORTEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDSAMPLES",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDUSAGE",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_UNRECOGNIZEDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDINITIALDATA",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDMIPLEVELS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATETEXTURE2D_LARGEALLOCATION",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_UNSUPPORTEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDSAMPLES",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDUSAGE",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_UNRECOGNIZEDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDCPUACCESSFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDBINDFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDINITIALDATA",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDMIPLEVELS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATETEXTURE3D_LARGEALLOCATION",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATERENDERTARGETVIEW_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE",
+    "D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDDECL",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_EXPECTEDDECL",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE",
+    "D3D11_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE",
+    "D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDFILTER",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSU",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSV",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDADDRESSW",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMIPLODBIAS",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXANISOTROPY",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDCOMPARISONFUNC",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMINLOD",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_INVALIDMAXLOD",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NULLDESC",
+    "D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDQUERY",
+    "D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_INVALIDMISCFLAGS",
+    "D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNEXPECTEDMISCFLAG",
+    "D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_NULLDESC",
+    "D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNRECOGNIZED",
+    "D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNDEFINED",
+    "D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_OFFSET_TOO_LARGE",
+    "D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_IASETINDEXBUFFER_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_FORMAT_INVALID",
+    "D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_TOO_LARGE",
+    "D3D11_MESSAGE_ID_DEVICE_IASETINDEXBUFFER_OFFSET_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_VSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_VSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_VSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_VSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_GSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_GSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_GSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_GSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_SOSETTARGETS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_SOSETTARGETS_OFFSET_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_PSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_PSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_PSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_PSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_INVALIDVIEWPORT",
+    "D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_INVALIDSCISSOR",
+    "D3D11_MESSAGE_ID_CLEARRENDERTARGETVIEW_DENORMFLUSH",
+    "D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DENORMFLUSH",
+    "D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALID",
+    "D3D11_MESSAGE_ID_DEVICE_IAGETVERTEXBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_VSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_VSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_VSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_GSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_GSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_GSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_SOGETTARGETS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_PSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_PSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_PSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_RSGETVIEWPORTS_VIEWPORTS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_RSGETSCISSORRECTS_RECTS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_GENERATEMIPS_RESOURCE_INVALID",
+    "D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSUBRESOURCE",
+    "D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESUBRESOURCE",
+    "D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCEBOX",
+    "D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCE",
+    "D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDDESTINATIONSTATE",
+    "D3D11_MESSAGE_ID_COPYSUBRESOURCEREGION_INVALIDSOURCESTATE",
+    "D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCE",
+    "D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDDESTINATIONSTATE",
+    "D3D11_MESSAGE_ID_COPYRESOURCE_INVALIDSOURCESTATE",
+    "D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSUBRESOURCE",
+    "D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONBOX",
+    "D3D11_MESSAGE_ID_UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE",
+    "D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_INVALID",
+    "D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_DESTINATION_SUBRESOURCE_INVALID",
+    "D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_INVALID",
+    "D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_SOURCE_SUBRESOURCE_INVALID",
+    "D3D11_MESSAGE_ID_DEVICE_RESOLVESUBRESOURCE_FORMAT_INVALID",
+    "D3D11_MESSAGE_ID_BUFFER_MAP_INVALIDMAPTYPE",
+    "D3D11_MESSAGE_ID_BUFFER_MAP_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_BUFFER_MAP_ALREADYMAPPED",
+    "D3D11_MESSAGE_ID_BUFFER_MAP_DEVICEREMOVED_RETURN",
+    "D3D11_MESSAGE_ID_BUFFER_UNMAP_NOTMAPPED",
+    "D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDMAPTYPE",
+    "D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_TEXTURE1D_MAP_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_TEXTURE1D_MAP_ALREADYMAPPED",
+    "D3D11_MESSAGE_ID_TEXTURE1D_MAP_DEVICEREMOVED_RETURN",
+    "D3D11_MESSAGE_ID_TEXTURE1D_UNMAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_TEXTURE1D_UNMAP_NOTMAPPED",
+    "D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDMAPTYPE",
+    "D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_TEXTURE2D_MAP_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_TEXTURE2D_MAP_ALREADYMAPPED",
+    "D3D11_MESSAGE_ID_TEXTURE2D_MAP_DEVICEREMOVED_RETURN",
+    "D3D11_MESSAGE_ID_TEXTURE2D_UNMAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_TEXTURE2D_UNMAP_NOTMAPPED",
+    "D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDMAPTYPE",
+    "D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_TEXTURE3D_MAP_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_TEXTURE3D_MAP_ALREADYMAPPED",
+    "D3D11_MESSAGE_ID_TEXTURE3D_MAP_DEVICEREMOVED_RETURN",
+    "D3D11_MESSAGE_ID_TEXTURE3D_UNMAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_TEXTURE3D_UNMAP_NOTMAPPED",
+    "D3D11_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_DEPRECATED",
+    "D3D11_MESSAGE_ID_CHECKMULTISAMPLEQUALITYLEVELS_FORMAT_DEPRECATED",
+    "D3D11_MESSAGE_ID_SETEXCEPTIONMODE_UNRECOGNIZEDFLAGS",
+    "D3D11_MESSAGE_ID_SETEXCEPTIONMODE_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_SETEXCEPTIONMODE_DEVICEREMOVED_RETURN",
+    "D3D11_MESSAGE_ID_REF_SIMULATING_INFINITELY_FAST_HARDWARE",
+    "D3D11_MESSAGE_ID_REF_THREADING_MODE",
+    "D3D11_MESSAGE_ID_REF_UMDRIVER_EXCEPTION",
+    "D3D11_MESSAGE_ID_REF_KMDRIVER_EXCEPTION",
+    "D3D11_MESSAGE_ID_REF_HARDWARE_EXCEPTION",
+    "D3D11_MESSAGE_ID_REF_ACCESSING_INDEXABLE_TEMP_OUT_OF_RANGE",
+    "D3D11_MESSAGE_ID_REF_PROBLEM_PARSING_SHADER",
+    "D3D11_MESSAGE_ID_REF_OUT_OF_MEMORY",
+    "D3D11_MESSAGE_ID_REF_INFO",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEXPOS_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINDEXED_INDEXPOS_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINSTANCED_VERTEXPOS_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINSTANCED_INSTANCEPOS_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INSTANCEPOS_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINDEXEDINSTANCED_INDEXPOS_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_SHADER_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND",
+    "D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERINDEX",
+    "D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_COMPONENTTYPE",
+    "D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_REGISTERMASK",
+    "D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_SYSTEMVALUE",
+    "D3D11_MESSAGE_ID_DEVICE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_INPUTLAYOUT_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VIEW_DIMENSION_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_FORMAT_INVALID",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_GS_INPUT_PRIMITIVE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_RETURN_TYPE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_POSITION_NOT_PRESENT",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_BOUND_RESOURCE_MAPPED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_PRIMITIVETOPOLOGY",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_OFFSET_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_OFFSET_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_OUTPUT_STREAM_OFFSET_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_LD_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_SAMPLE_C_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_MULTISAMPLE_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_SO_TARGETS_BOUND_WITHOUT_SOURCE",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_SO_STRIDE_LARGER_THAN_BUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0",
+    "D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT",
+    "D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT",
+    "D3D11_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT",
+    "D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_DEVICE_OPEN_SHARED_RESOURCE_BADINTERFACE_RETURN",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_VIEWPORT_NOT_SET",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_TRAILING_DIGIT_IN_SEMANTIC",
+    "D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_DENORMFLUSH",
+    "D3D11_MESSAGE_ID_OMSETRENDERTARGETS_INVALIDVIEW",
+    "D3D11_MESSAGE_ID_DEVICE_SETTEXTFILTERSIZE_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH",
+    "D3D11_MESSAGE_ID_BLENDSTATE_GETDESC_LEGACY",
+    "D3D11_MESSAGE_ID_SHADERRESOURCEVIEW_GETDESC_LEGACY",
+    "D3D11_MESSAGE_ID_CREATEQUERY_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATEPREDICATE_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATECOUNTER_OUTOFRANGE_COUNTER",
+    "D3D11_MESSAGE_ID_CREATECOUNTER_SIMULTANEOUS_ACTIVE_COUNTERS_EXHAUSTED",
+    "D3D11_MESSAGE_ID_CREATECOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER",
+    "D3D11_MESSAGE_ID_CREATECOUNTER_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATECOUNTER_NONEXCLUSIVE_RETURN",
+    "D3D11_MESSAGE_ID_CREATECOUNTER_NULLDESC",
+    "D3D11_MESSAGE_ID_CHECKCOUNTER_OUTOFRANGE_COUNTER",
+    "D3D11_MESSAGE_ID_CHECKCOUNTER_UNSUPPORTED_WELLKNOWN_COUNTER",
+    "D3D11_MESSAGE_ID_SETPREDICATION_INVALID_PREDICATE_STATE",
+    "D3D11_MESSAGE_ID_QUERY_BEGIN_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_PREDICATE_BEGIN_DURING_PREDICATION",
+    "D3D11_MESSAGE_ID_QUERY_BEGIN_DUPLICATE",
+    "D3D11_MESSAGE_ID_QUERY_BEGIN_ABANDONING_PREVIOUS_RESULTS",
+    "D3D11_MESSAGE_ID_PREDICATE_END_DURING_PREDICATION",
+    "D3D11_MESSAGE_ID_QUERY_END_ABANDONING_PREVIOUS_RESULTS",
+    "D3D11_MESSAGE_ID_QUERY_END_WITHOUT_BEGIN",
+    "D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_DATASIZE",
+    "D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_FLAGS",
+    "D3D11_MESSAGE_ID_QUERY_GETDATA_INVALID_CALL",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_PS_OUTPUT_TYPE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_FORMAT_GATHER_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN",
+    "D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_STRIDE_TOO_LARGE",
+    "D3D11_MESSAGE_ID_DEVICE_IASETVERTEXBUFFERS_INVALIDRANGE",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RESOURCE_SAMPLE_COUNT_MISMATCH",
+    "D3D11_MESSAGE_ID_D3D10_MESSAGES_END",
+    "D3D11_MESSAGE_ID_D3D10L9_MESSAGES_START",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_STENCIL_NO_TWO_SIDED",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_DepthBiasClamp_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NO_COMPARISON_SUPPORT",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_EXCESSIVE_ANISOTROPY",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_OUT_OF_RANGE",
+    "D3D11_MESSAGE_ID_VSSETSAMPLERS_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_VSSETSAMPLERS_TOO_MANY_SAMPLERS",
+    "D3D11_MESSAGE_ID_PSSETSAMPLERS_TOO_MANY_SAMPLERS",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NO_ARRAYS",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NO_VB_AND_IB_BIND",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NO_TEXTURE_1D",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_DIMENSION_OUT_OF_RANGE",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_SHADER_RESOURCE",
+    "D3D11_MESSAGE_ID_OMSETRENDERTARGETS_TOO_MANY_RENDER_TARGETS",
+    "D3D11_MESSAGE_ID_OMSETRENDERTARGETS_NO_DIFFERING_BIT_DEPTHS",
+    "D3D11_MESSAGE_ID_IASETVERTEXBUFFERS_BAD_BUFFER_INDEX",
+    "D3D11_MESSAGE_ID_DEVICE_RSSETVIEWPORTS_TOO_MANY_VIEWPORTS",
+    "D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_ADJACENCY_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_TOO_MANY_SCISSORS",
+    "D3D11_MESSAGE_ID_COPYRESOURCE_ONLY_TEXTURE_2D_WITHIN_GPU_MEMORY",
+    "D3D11_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_3D_READBACK",
+    "D3D11_MESSAGE_ID_COPYRESOURCE_NO_TEXTURE_ONLY_READBACK",
+    "D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_UNSUPPORTED_FORMAT",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_ALPHA_TO_COVERAGE",
+    "D3D11_MESSAGE_ID_CREATERASTERIZERSTATE_DepthClipEnable_MUST_BE_TRUE",
+    "D3D11_MESSAGE_ID_DRAWINDEXED_STARTINDEXLOCATION_MUST_BE_POSITIVE",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_MUST_USE_LOWEST_LOD",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_MINLOD_MUST_NOT_BE_FRACTIONAL",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_MAXLOD_MUST_BE_FLT_MAX",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_FIRSTARRAYSLICE_MUST_BE_ZERO",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_CUBES_MUST_HAVE_6_SIDES",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NOT_BINDABLE_AS_RENDER_TARGET",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NO_DWORD_INDEX_BUFFER",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_MSAA_PRECLUDES_SHADER_RESOURCE",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_PRESENTATION_PRECLUDES_SHADER_RESOURCE",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_BLEND_ENABLE",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_INDEPENDENT_WRITE_MASKS",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NO_STREAM_OUT",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_ONLY_VB_IB_FOR_BUFFERS",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NO_AUTOGEN_FOR_VOLUMES",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_DXGI_FORMAT_R8G8B8A8_CANNOT_BE_SHARED",
+    "D3D11_MESSAGE_ID_VSSHADERRESOURCES_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_GEOMETRY_SHADER_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_STREAM_OUT_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_TEXT_FILTER_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_SEPARATE_ALPHA_BLEND",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_NO_MRT_BLEND",
+    "D3D11_MESSAGE_ID_CREATEBLENDSTATE_OPERATION_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_NO_MIRRORONCE",
+    "D3D11_MESSAGE_ID_DRAWINSTANCED_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_DRAWINDEXEDINSTANCED_NOT_SUPPORTED_BELOW_9_3",
+    "D3D11_MESSAGE_ID_DRAWINDEXED_POINTLIST_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_SETBLENDSTATE_SAMPLE_MASK_CANNOT_BE_ZERO",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_DIMENSION_EXCEEDS_FEATURE_LEVEL_DEFINITION",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_ONLY_SINGLE_MIP_LEVEL_DEPTH_STENCIL_SUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_RSSETSCISSORRECTS_NEGATIVESCISSOR",
+    "D3D11_MESSAGE_ID_SLOT_ZERO_MUST_BE_D3D10_INPUT_PER_VERTEX_DATA",
+    "D3D11_MESSAGE_ID_CREATERESOURCE_NON_POW_2_MIPMAP",
+    "D3D11_MESSAGE_ID_CREATESAMPLERSTATE_BORDER_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_OMSETRENDERTARGETS_NO_SRGB_MRT",
+    "D3D11_MESSAGE_ID_D3D10L9_MESSAGES_END",
+    "D3D11_MESSAGE_ID_D3D11_MESSAGES_START",
+    "D3D11_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDCLASSLINKAGE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDCLASSLINKAGE",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTREAMS",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAMTORASTERIZER",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTREAMS",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCLASSLINKAGE",
+    "D3D11_MESSAGE_ID_CREATEPIXELSHADER_INVALIDCLASSLINKAGE",
+    "D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALID_COMMANDLISTFLAGS",
+    "D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_SINGLETHREADED",
+    "D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_INVALID_CALL_RETURN",
+    "D3D11_MESSAGE_ID_CREATEDEFERREDCONTEXT_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_FINISHDISPLAYLIST_ONIMMEDIATECONTEXT",
+    "D3D11_MESSAGE_ID_FINISHDISPLAYLIST_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_FINISHDISPLAYLIST_INVALID_CALL_RETURN",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAM",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDENTRIES",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTRIDES",
+    "D3D11_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTRIDES",
+    "D3D11_MESSAGE_ID_DEVICE_HSSETSHADERRESOURCES_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_HSSETCONSTANTBUFFERS_HAZARD",
+    "D3D11_MESSAGE_ID_HSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDCALL",
+    "D3D11_MESSAGE_ID_CREATEHULLSHADER_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERBYTECODE",
+    "D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERTYPE",
+    "D3D11_MESSAGE_ID_CREATEHULLSHADER_INVALIDCLASSLINKAGE",
+    "D3D11_MESSAGE_ID_DEVICE_HSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_HSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_HSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_HSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_HSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_HSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_HSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_DSSETSHADERRESOURCES_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_DSSETCONSTANTBUFFERS_HAZARD",
+    "D3D11_MESSAGE_ID_DSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCALL",
+    "D3D11_MESSAGE_ID_CREATEDOMAINSHADER_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERBYTECODE",
+    "D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERTYPE",
+    "D3D11_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCLASSLINKAGE",
+    "D3D11_MESSAGE_ID_DEVICE_DSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_DSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_DSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_DSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_DSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_DSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_HS_XOR_DS_MISMATCH",
+    "D3D11_MESSAGE_ID_DEFERRED_CONTEXT_REMOVAL_PROCESS_AT_FAULT",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_INVALID_ARG_BUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAWINDIRECT_OFFSET_OVERFLOW",
+    "D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDMAPTYPE",
+    "D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_RESOURCE_MAP_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_RESOURCE_MAP_ALREADYMAPPED",
+    "D3D11_MESSAGE_ID_RESOURCE_MAP_DEVICEREMOVED_RETURN",
+    "D3D11_MESSAGE_ID_RESOURCE_MAP_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_RESOURCE_MAP_WITHOUT_INITIAL_DISCARD",
+    "D3D11_MESSAGE_ID_RESOURCE_UNMAP_INVALIDSUBRESOURCE",
+    "D3D11_MESSAGE_ID_RESOURCE_UNMAP_NOTMAPPED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_RASTERIZING_CONTROL_POINTS",
+    "D3D11_MESSAGE_ID_DEVICE_IASETPRIMITIVETOPOLOGY_TOPOLOGY_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_SIGNATURE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_CONTROL_POINT_COUNT_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_HS_DS_TESSELLATOR_DOMAIN_MISMATCH",
+    "D3D11_MESSAGE_ID_CREATE_CONTEXT",
+    "D3D11_MESSAGE_ID_LIVE_CONTEXT",
+    "D3D11_MESSAGE_ID_DESTROY_CONTEXT",
+    "D3D11_MESSAGE_ID_CREATE_BUFFER",
+    "D3D11_MESSAGE_ID_LIVE_BUFFER",
+    "D3D11_MESSAGE_ID_DESTROY_BUFFER",
+    "D3D11_MESSAGE_ID_CREATE_TEXTURE1D",
+    "D3D11_MESSAGE_ID_LIVE_TEXTURE1D",
+    "D3D11_MESSAGE_ID_DESTROY_TEXTURE1D",
+    "D3D11_MESSAGE_ID_CREATE_TEXTURE2D",
+    "D3D11_MESSAGE_ID_LIVE_TEXTURE2D",
+    "D3D11_MESSAGE_ID_DESTROY_TEXTURE2D",
+    "D3D11_MESSAGE_ID_CREATE_TEXTURE3D",
+    "D3D11_MESSAGE_ID_LIVE_TEXTURE3D",
+    "D3D11_MESSAGE_ID_DESTROY_TEXTURE3D",
+    "D3D11_MESSAGE_ID_CREATE_SHADERRESOURCEVIEW",
+    "D3D11_MESSAGE_ID_LIVE_SHADERRESOURCEVIEW",
+    "D3D11_MESSAGE_ID_DESTROY_SHADERRESOURCEVIEW",
+    "D3D11_MESSAGE_ID_CREATE_RENDERTARGETVIEW",
+    "D3D11_MESSAGE_ID_LIVE_RENDERTARGETVIEW",
+    "D3D11_MESSAGE_ID_DESTROY_RENDERTARGETVIEW",
+    "D3D11_MESSAGE_ID_CREATE_DEPTHSTENCILVIEW",
+    "D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILVIEW",
+    "D3D11_MESSAGE_ID_DESTROY_DEPTHSTENCILVIEW",
+    "D3D11_MESSAGE_ID_CREATE_VERTEXSHADER",
+    "D3D11_MESSAGE_ID_LIVE_VERTEXSHADER",
+    "D3D11_MESSAGE_ID_DESTROY_VERTEXSHADER",
+    "D3D11_MESSAGE_ID_CREATE_HULLSHADER",
+    "D3D11_MESSAGE_ID_LIVE_HULLSHADER",
+    "D3D11_MESSAGE_ID_DESTROY_HULLSHADER",
+    "D3D11_MESSAGE_ID_CREATE_DOMAINSHADER",
+    "D3D11_MESSAGE_ID_LIVE_DOMAINSHADER",
+    "D3D11_MESSAGE_ID_DESTROY_DOMAINSHADER",
+    "D3D11_MESSAGE_ID_CREATE_GEOMETRYSHADER",
+    "D3D11_MESSAGE_ID_LIVE_GEOMETRYSHADER",
+    "D3D11_MESSAGE_ID_DESTROY_GEOMETRYSHADER",
+    "D3D11_MESSAGE_ID_CREATE_PIXELSHADER",
+    "D3D11_MESSAGE_ID_LIVE_PIXELSHADER",
+    "D3D11_MESSAGE_ID_DESTROY_PIXELSHADER",
+    "D3D11_MESSAGE_ID_CREATE_INPUTLAYOUT",
+    "D3D11_MESSAGE_ID_LIVE_INPUTLAYOUT",
+    "D3D11_MESSAGE_ID_DESTROY_INPUTLAYOUT",
+    "D3D11_MESSAGE_ID_CREATE_SAMPLER",
+    "D3D11_MESSAGE_ID_LIVE_SAMPLER",
+    "D3D11_MESSAGE_ID_DESTROY_SAMPLER",
+    "D3D11_MESSAGE_ID_CREATE_BLENDSTATE",
+    "D3D11_MESSAGE_ID_LIVE_BLENDSTATE",
+    "D3D11_MESSAGE_ID_DESTROY_BLENDSTATE",
+    "D3D11_MESSAGE_ID_CREATE_DEPTHSTENCILSTATE",
+    "D3D11_MESSAGE_ID_LIVE_DEPTHSTENCILSTATE",
+    "D3D11_MESSAGE_ID_DESTROY_DEPTHSTENCILSTATE",
+    "D3D11_MESSAGE_ID_CREATE_RASTERIZERSTATE",
+    "D3D11_MESSAGE_ID_LIVE_RASTERIZERSTATE",
+    "D3D11_MESSAGE_ID_DESTROY_RASTERIZERSTATE",
+    "D3D11_MESSAGE_ID_CREATE_QUERY",
+    "D3D11_MESSAGE_ID_LIVE_QUERY",
+    "D3D11_MESSAGE_ID_DESTROY_QUERY",
+    "D3D11_MESSAGE_ID_CREATE_PREDICATE",
+    "D3D11_MESSAGE_ID_LIVE_PREDICATE",
+    "D3D11_MESSAGE_ID_DESTROY_PREDICATE",
+    "D3D11_MESSAGE_ID_CREATE_COUNTER",
+    "D3D11_MESSAGE_ID_LIVE_COUNTER",
+    "D3D11_MESSAGE_ID_DESTROY_COUNTER",
+    "D3D11_MESSAGE_ID_CREATE_COMMANDLIST",
+    "D3D11_MESSAGE_ID_LIVE_COMMANDLIST",
+    "D3D11_MESSAGE_ID_DESTROY_COMMANDLIST",
+    "D3D11_MESSAGE_ID_CREATE_CLASSINSTANCE",
+    "D3D11_MESSAGE_ID_LIVE_CLASSINSTANCE",
+    "D3D11_MESSAGE_ID_DESTROY_CLASSINSTANCE",
+    "D3D11_MESSAGE_ID_CREATE_CLASSLINKAGE",
+    "D3D11_MESSAGE_ID_LIVE_CLASSLINKAGE",
+    "D3D11_MESSAGE_ID_DESTROY_CLASSLINKAGE",
+    "D3D11_MESSAGE_ID_LIVE_DEVICE",
+    "D3D11_MESSAGE_ID_LIVE_OBJECT_SUMMARY",
+    "D3D11_MESSAGE_ID_CREATE_COMPUTESHADER",
+    "D3D11_MESSAGE_ID_LIVE_COMPUTESHADER",
+    "D3D11_MESSAGE_ID_DESTROY_COMPUTESHADER",
+    "D3D11_MESSAGE_ID_CREATE_UNORDEREDACCESSVIEW",
+    "D3D11_MESSAGE_ID_LIVE_UNORDEREDACCESSVIEW",
+    "D3D11_MESSAGE_ID_DESTROY_UNORDEREDACCESSVIEW",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_INTERFACES_FEATURELEVEL",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_INTERFACE_COUNT_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_INDEX",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_TYPE",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_INVALID_INSTANCE_DATA",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_UNBOUND_INSTANCE_DATA",
+    "D3D11_MESSAGE_ID_DEVICE_SETSHADER_INSTANCE_DATA_BINDINGS",
+    "D3D11_MESSAGE_ID_DEVICE_CREATESHADER_CLASSLINKAGE_FULL",
+    "D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_UNRECOGNIZED_FEATURE",
+    "D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_MISMATCHED_DATA_SIZE",
+    "D3D11_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_HAZARD",
+    "D3D11_MESSAGE_ID_CSSETSHADERRESOURCES_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCALL",
+    "D3D11_MESSAGE_ID_CREATECOMPUTESHADER_OUTOFMEMORY",
+    "D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERBYTECODE",
+    "D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERTYPE",
+    "D3D11_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCLASSLINKAGE",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_CSSETCONSTANTBUFFERS_INVALIDBUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_CSGETSHADERRESOURCES_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_CSGETCONSTANTBUFFERS_BUFFERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_CSGETSAMPLERS_SAMPLERS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEFLOATOPSNOTSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEFLOATOPSNOTSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEFLOATOPSNOTSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEFLOATOPSNOTSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEFLOATOPSNOTSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEFLOATOPSNOTSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEFLOATOPSNOTSUPPORTED",
+    "D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDSTRUCTURESTRIDE",
+    "D3D11_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDESC",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDIMENSIONS",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_UNRECOGNIZEDFORMAT",
+    "D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_HAZARD",
+    "D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_OVERLAPPING_OLD_SLOTS",
+    "D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NO_OP",
+    "D3D11_MESSAGE_ID_CSSETUNORDEREDACCESSVIEWS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_PSSETUNORDEREDACCESSVIEWS_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDARG_RETURN",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_OUTOFMEMORY_RETURN",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_HAZARD",
+    "D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEW_DENORMFLUSH",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSS_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_DEVICE_CSGETUNORDEREDACCESSS_VIEWS_EMPTY",
+    "D3D11_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFLAGS",
+    "D3D11_MESSAGE_ID_CREATESHADERRESESOURCEVIEW_TOOMANYOBJECTS",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_INVALID_ARG_BUFFER",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_UNALIGNED",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_OFFSET_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDCONTEXT",
+    "D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDRESOURCE",
+    "D3D11_MESSAGE_ID_DEVICE_SETRESOURCEMINLOD_INVALIDMINLOD",
+    "D3D11_MESSAGE_ID_DEVICE_GETRESOURCEMINLOD_INVALIDCONTEXT",
+    "D3D11_MESSAGE_ID_DEVICE_GETRESOURCEMINLOD_INVALIDRESOURCE",
+    "D3D11_MESSAGE_ID_OMSETDEPTHSTENCIL_UNBINDDELETINGOBJECT",
+    "D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_DEPTH_READONLY",
+    "D3D11_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_STENCIL_READONLY",
+    "D3D11_MESSAGE_ID_CHECKFEATURESUPPORT_FORMAT_DEPRECATED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RETURN_TYPE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_NOT_SET",
+    "D3D11_MESSAGE_ID_DEVICE_DRAW_UNORDEREDACCESSVIEW_RENDERTARGETVIEW_OVERLAP",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_DIMENSION_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_APPEND_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMICS_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_STRUCTURE_STRIDE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_BUFFER_TYPE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_RAW_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_LD_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_FORMAT_STORE_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_ADD_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_BITWISE_OPS_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_CMPSTORE_CMPEXCHANGE_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_EXCHANGE_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_SIGNED_MINMAX_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_ATOMIC_UNSIGNED_MINMAX_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCH_BOUND_RESOURCE_MAPPED",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_OVERFLOW",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCH_THREADGROUPCOUNT_ZERO",
+    "D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_STRUCTURE_STRIDE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_BUFFER_TYPE_MISMATCH",
+    "D3D11_MESSAGE_ID_DEVICE_SHADERRESOURCEVIEW_RAW_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCH_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_DISPATCHINDIRECT_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDOFFSET",
+    "D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_LARGEOFFSET",
+    "D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDDESTINATIONSTATE",
+    "D3D11_MESSAGE_ID_COPYSTRUCTURECOUNT_INVALIDSOURCESTATE",
+    "D3D11_MESSAGE_ID_CHECKFORMATSUPPORT_FORMAT_NOT_SUPPORTED",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_INVALIDVIEW",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_INVALIDOFFSET",
+    "D3D11_MESSAGE_ID_DEVICE_CSSETUNORDEREDACCESSVIEWS_TOOMANYVIEWS",
+    "D3D11_MESSAGE_ID_CLEARUNORDEREDACCESSVIEWFLOAT_INVALIDFORMAT",
+    "D3D11_MESSAGE_ID_DEVICE_UNORDEREDACCESSVIEW_COUNTER_UNSUPPORTED",
+    "D3D11_MESSAGE_ID_REF_WARNING",
+    "D3D11_MESSAGE_ID_D3D11_MESSAGES_END",
+])
+
+D3D11_MESSAGE = Struct("D3D11_MESSAGE", [
+    (D3D11_MESSAGE_CATEGORY, "Category"),
+    (D3D11_MESSAGE_SEVERITY, "Severity"),
+    (D3D11_MESSAGE_ID, "ID"),
+    (Pointer(Const(Int)), "pDescription"),
+    (SIZE_T, "DescriptionByteLength"),
+])
+
+D3D11_INFO_QUEUE_FILTER_DESC = Struct("D3D11_INFO_QUEUE_FILTER_DESC", [
+    (UINT, "NumCategories"),
+    (Pointer(D3D11_MESSAGE_CATEGORY), "pCategoryList"),
+    (UINT, "NumSeverities"),
+    (Pointer(D3D11_MESSAGE_SEVERITY), "pSeverityList"),
+    (UINT, "NumIDs"),
+    (Pointer(D3D11_MESSAGE_ID), "pIDList"),
+])
+
+D3D11_INFO_QUEUE_FILTER = Struct("D3D11_INFO_QUEUE_FILTER", [
+    (D3D11_INFO_QUEUE_FILTER_DESC, "AllowList"),
+    (D3D11_INFO_QUEUE_FILTER_DESC, "DenyList"),
+])
+
+ID3D11InfoQueue = Interface("ID3D11InfoQueue", IUnknown)
+ID3D11InfoQueue.methods += [
+    StdMethod(HRESULT, "SetMessageCountLimit", [(UINT64, "MessageCountLimit")]),
+    StdMethod(Void, "ClearStoredMessages", []),
+    StdMethod(HRESULT, "GetMessage", [(UINT64, "MessageIndex"), Out(Pointer(D3D11_MESSAGE), "pMessage"), Out(Pointer(SIZE_T), "pMessageByteLength")]),
+    StdMethod(UINT64, "GetNumMessagesAllowedByStorageFilter", []),
+    StdMethod(UINT64, "GetNumMessagesDeniedByStorageFilter", []),
+    StdMethod(UINT64, "GetNumStoredMessages", []),
+    StdMethod(UINT64, "GetNumStoredMessagesAllowedByRetrievalFilter", []),
+    StdMethod(UINT64, "GetNumMessagesDiscardedByMessageCountLimit", []),
+    StdMethod(UINT64, "GetMessageCountLimit", []),
+    StdMethod(HRESULT, "AddStorageFilterEntries", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]),
+    StdMethod(HRESULT, "GetStorageFilter", [Out(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")]),
+    StdMethod(Void, "ClearStorageFilter", []),
+    StdMethod(HRESULT, "PushEmptyStorageFilter", []),
+    StdMethod(HRESULT, "PushCopyOfStorageFilter", []),
+    StdMethod(HRESULT, "PushStorageFilter", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]),
+    StdMethod(Void, "PopStorageFilter", []),
+    StdMethod(UINT, "GetStorageFilterStackSize", []),
+    StdMethod(HRESULT, "AddRetrievalFilterEntries", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]),
+    StdMethod(HRESULT, "GetRetrievalFilter", [Out(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter"), Out(Pointer(SIZE_T), "pFilterByteLength")]),
+    StdMethod(Void, "ClearRetrievalFilter", []),
+    StdMethod(HRESULT, "PushEmptyRetrievalFilter", []),
+    StdMethod(HRESULT, "PushCopyOfRetrievalFilter", []),
+    StdMethod(HRESULT, "PushRetrievalFilter", [(Pointer(D3D11_INFO_QUEUE_FILTER), "pFilter")]),
+    StdMethod(Void, "PopRetrievalFilter", []),
+    StdMethod(UINT, "GetRetrievalFilterStackSize", []),
+    StdMethod(HRESULT, "AddMessage", [(D3D11_MESSAGE_CATEGORY, "Category"), (D3D11_MESSAGE_SEVERITY, "Severity"), (D3D11_MESSAGE_ID, "ID"), (LPCSTR, "pDescription")]),
+    StdMethod(HRESULT, "AddApplicationMessage", [(D3D11_MESSAGE_SEVERITY, "Severity"), (LPCSTR, "pDescription")]),
+    StdMethod(HRESULT, "SetBreakOnCategory", [(D3D11_MESSAGE_CATEGORY, "Category"), (BOOL, "bEnable")]),
+    StdMethod(HRESULT, "SetBreakOnSeverity", [(D3D11_MESSAGE_SEVERITY, "Severity"), (BOOL, "bEnable")]),
+    StdMethod(HRESULT, "SetBreakOnID", [(D3D11_MESSAGE_ID, "ID"), (BOOL, "bEnable")]),
+    StdMethod(BOOL, "GetBreakOnCategory", [(D3D11_MESSAGE_CATEGORY, "Category")]),
+    StdMethod(BOOL, "GetBreakOnSeverity", [(D3D11_MESSAGE_SEVERITY, "Severity")]),
+    StdMethod(BOOL, "GetBreakOnID", [(D3D11_MESSAGE_ID, "ID")]),
+    StdMethod(Void, "SetMuteDebugOutput", [(BOOL, "bMute")]),
+    StdMethod(BOOL, "GetMuteDebugOutput", []),
+]
+
diff --git a/specs/d3d11shader.py b/specs/d3d11shader.py
new file mode 100644 (file)
index 0000000..1fe357b
--- /dev/null
@@ -0,0 +1,186 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from d3dcommon import *
+
+
+ID3D11ShaderReflectionType = Interface("ID3D11ShaderReflectionType", IUnknown)
+ID3D11ShaderReflectionVariable = Interface("ID3D11ShaderReflectionVariable", IUnknown)
+ID3D11ShaderReflectionConstantBuffer = Interface("ID3D11ShaderReflectionConstantBuffer", IUnknown)
+ID3D11ShaderReflection = Interface("ID3D11ShaderReflection", IUnknown)
+
+
+D3D11_SHADER_VERSION_TYPE = Enum("D3D11_SHADER_VERSION_TYPE", [
+    "D3D11_SHVER_PIXEL_SHADER",
+    "D3D11_SHVER_VERTEX_SHADER",
+    "D3D11_SHVER_GEOMETRY_SHADER",
+    "D3D11_SHVER_HULL_SHADER",
+    "D3D11_SHVER_DOMAIN_SHADER",
+    "D3D11_SHVER_COMPUTE_SHADER",
+])
+
+D3D11_SIGNATURE_PARAMETER_DESC = Struct("D3D11_SIGNATURE_PARAMETER_DESC", [
+    (LPCSTR, "SemanticName"),
+    (UINT, "SemanticIndex"),
+    (UINT, "Register"),
+    (D3D_NAME, "SystemValueType"),
+    (D3D_REGISTER_COMPONENT_TYPE, "ComponentType"),
+    (BYTE, "Mask"),
+    (BYTE, "ReadWriteMask"),
+    (UINT, "Stream"),
+])
+
+D3D11_SHADER_BUFFER_DESC = Struct("D3D11_SHADER_BUFFER_DESC", [
+    (LPCSTR, "Name"),
+    (D3D_CBUFFER_TYPE, "Type"),
+    (UINT, "Variables"),
+    (UINT, "Size"),
+    (UINT, "uFlags"),
+])
+
+D3D11_SHADER_VARIABLE_DESC = Struct("D3D11_SHADER_VARIABLE_DESC", [
+    (LPCSTR, "Name"),
+    (UINT, "StartOffset"),
+    (UINT, "Size"),
+    (UINT, "uFlags"),
+    (LPVOID, "DefaultValue"),
+    (UINT, "StartTexture"),
+    (UINT, "TextureSize"),
+    (UINT, "StartSampler"),
+    (UINT, "SamplerSize"),
+])
+
+D3D11_SHADER_TYPE_DESC = Struct("D3D11_SHADER_TYPE_DESC", [
+    (D3D_SHADER_VARIABLE_CLASS, "Class"),
+    (D3D_SHADER_VARIABLE_TYPE, "Type"),
+    (UINT, "Rows"),
+    (UINT, "Columns"),
+    (UINT, "Elements"),
+    (UINT, "Members"),
+    (UINT, "Offset"),
+    (LPCSTR, "Name"),
+])
+
+D3D11_SHADER_DESC = Struct("D3D11_SHADER_DESC", [
+    (UINT, "Version"),
+    (LPCSTR, "Creator"),
+    (UINT, "Flags"),
+    (UINT, "ConstantBuffers"),
+    (UINT, "BoundResources"),
+    (UINT, "InputParameters"),
+    (UINT, "OutputParameters"),
+    (UINT, "InstructionCount"),
+    (UINT, "TempRegisterCount"),
+    (UINT, "TempArrayCount"),
+    (UINT, "DefCount"),
+    (UINT, "DclCount"),
+    (UINT, "TextureNormalInstructions"),
+    (UINT, "TextureLoadInstructions"),
+    (UINT, "TextureCompInstructions"),
+    (UINT, "TextureBiasInstructions"),
+    (UINT, "TextureGradientInstructions"),
+    (UINT, "FloatInstructionCount"),
+    (UINT, "IntInstructionCount"),
+    (UINT, "UintInstructionCount"),
+    (UINT, "StaticFlowControlCount"),
+    (UINT, "DynamicFlowControlCount"),
+    (UINT, "MacroInstructionCount"),
+    (UINT, "ArrayInstructionCount"),
+    (UINT, "CutInstructionCount"),
+    (UINT, "EmitInstructionCount"),
+    (D3D_PRIMITIVE_TOPOLOGY, "GSOutputTopology"),
+    (UINT, "GSMaxOutputVertexCount"),
+    (D3D_PRIMITIVE, "InputPrimitive"),
+    (UINT, "PatchConstantParameters"),
+    (UINT, "cGSInstanceCount"),
+    (UINT, "cControlPoints"),
+    (D3D_TESSELLATOR_OUTPUT_PRIMITIVE, "HSOutputPrimitive"),
+    (D3D_TESSELLATOR_PARTITIONING, "HSPartitioning"),
+    (D3D_TESSELLATOR_DOMAIN, "TessellatorDomain"),
+    (UINT, "cBarrierInstructions"),
+    (UINT, "cInterlockedInstructions"),
+    (UINT, "cTextureStoreInstructions"),
+])
+
+D3D11_SHADER_INPUT_BIND_DESC = Struct("D3D11_SHADER_INPUT_BIND_DESC", [
+    (LPCSTR, "Name"),
+    (D3D_SHADER_INPUT_TYPE, "Type"),
+    (UINT, "BindPoint"),
+    (UINT, "BindCount"),
+    (UINT, "uFlags"),
+    (D3D_RESOURCE_RETURN_TYPE, "ReturnType"),
+    (D3D_SRV_DIMENSION, "Dimension"),
+    (UINT, "NumSamples"),
+])
+
+ID3D11ShaderReflectionType.methods += [
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D11_SHADER_TYPE_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionType), "GetMemberTypeByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionType), "GetMemberTypeByName", [(LPCSTR, "Name")]),
+    StdMethod(LPCSTR, "GetMemberTypeName", [(UINT, "Index")]),
+    StdMethod(HRESULT, "IsEqual", [(ObjPointer(ID3D11ShaderReflectionType), "pType")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionType), "GetSubType", []),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionType), "GetBaseClass", []),
+    StdMethod(UINT, "GetNumInterfaces", []),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionType), "GetInterfaceByIndex", [(UINT, "uIndex")]),
+    StdMethod(HRESULT, "IsOfType", [(ObjPointer(ID3D11ShaderReflectionType), "pType")]),
+    StdMethod(HRESULT, "ImplementsInterface", [(ObjPointer(ID3D11ShaderReflectionType), "pBase")]),
+]
+
+ID3D11ShaderReflectionVariable.methods += [
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D11_SHADER_VARIABLE_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionType), "GetType", []),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionConstantBuffer), "GetBuffer", []),
+    StdMethod(UINT, "GetInterfaceSlot", [(UINT, "uArrayIndex")]),
+]
+
+ID3D11ShaderReflectionConstantBuffer.methods += [
+    StdMethod(HRESULT, "GetDesc", [(Pointer(D3D11_SHADER_BUFFER_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionVariable), "GetVariableByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionVariable), "GetVariableByName", [(LPCSTR, "Name")]),
+]
+
+ID3D11ShaderReflection.methods += [
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(D3D11_SHADER_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionConstantBuffer), "GetConstantBufferByIndex", [(UINT, "Index")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionConstantBuffer), "GetConstantBufferByName", [(LPCSTR, "Name")]),
+    StdMethod(HRESULT, "GetResourceBindingDesc", [(UINT, "ResourceIndex"), Out(Pointer(D3D11_SHADER_INPUT_BIND_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetInputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D11_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetOutputParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D11_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+    StdMethod(HRESULT, "GetPatchConstantParameterDesc", [(UINT, "ParameterIndex"), Out(Pointer(D3D11_SIGNATURE_PARAMETER_DESC), "pDesc")]),
+    StdMethod(ObjPointer(ID3D11ShaderReflectionVariable), "GetVariableByName", [(LPCSTR, "Name")]),
+    StdMethod(HRESULT, "GetResourceBindingDescByName", [(LPCSTR, "Name"), Out(Pointer(D3D11_SHADER_INPUT_BIND_DESC), "pDesc")]),
+    StdMethod(UINT, "GetMovInstructionCount", []),
+    StdMethod(UINT, "GetMovcInstructionCount", []),
+    StdMethod(UINT, "GetConversionInstructionCount", []),
+    StdMethod(UINT, "GetBitwiseInstructionCount", []),
+    StdMethod(D3D_PRIMITIVE, "GetGSInputPrimitive", []),
+    StdMethod(BOOL, "IsSampleFrequencyShader", []),
+    StdMethod(UINT, "GetNumInterfaceSlots", []),
+    StdMethod(HRESULT, "GetMinFeatureLevel", [Out(Pointer(D3D_FEATURE_LEVEL), "pLevel")]),
+    StdMethod(UINT, "GetThreadGroupSize", [Out(Pointer(UINT), "pSizeX"), Out(Pointer(UINT), "pSizeY"), Out(Pointer(UINT), "pSizeZ")]),
+]
+
diff --git a/specs/d3d8.def b/specs/d3d8.def
deleted file mode 100644 (file)
index 5134cb8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBRARY        "d3d8"
-
-EXPORTS
-        Direct3DCreate8 @1
index 601c54b88c26cce558624764c6eb65e6f2661541..e4994869d1d9e3a33cee5aeb94ce817df35cfe73 100644 (file)
@@ -29,8 +29,7 @@ from winapi import *
 from d3d8types import *
 from d3d8caps import *
 
-HRESULT = Enum("HRESULT", [
-    "D3D_OK",
+HRESULT = MAKE_HRESULT(ok = "D3D_OK", errors = [
     "D3DERR_WRONGTEXTUREFORMAT",
     "D3DERR_UNSUPPORTEDCOLOROPERATION",
     "D3DERR_UNSUPPORTEDCOLORARG",
@@ -54,6 +53,20 @@ HRESULT = Enum("HRESULT", [
     "D3DERR_DRIVERINVALIDCALL",
 ])
 
+D3DADAPTER = FakeEnum(UINT, [
+    "D3DADAPTER_DEFAULT",
+])
+
+D3DCREATE = Flags(DWORD, [
+   "D3DCREATE_FPU_PRESERVE",
+   "D3DCREATE_MULTITHREADED",
+   "D3DCREATE_PUREDEVICE",
+   "D3DCREATE_SOFTWARE_VERTEXPROCESSING",
+   "D3DCREATE_HARDWARE_VERTEXPROCESSING",
+   "D3DCREATE_MIXED_VERTEXPROCESSING",
+   "D3DCREATE_DISABLE_DRIVER_MANAGEMENT",
+])
+
 IDirect3D8 = Interface("IDirect3D8", IUnknown)
 IDirect3DDevice8 = Interface("IDirect3DDevice8", IUnknown)
 IDirect3DSwapChain8 = Interface("IDirect3DSwapChain8", IUnknown)
@@ -67,33 +80,33 @@ IDirect3DIndexBuffer8 = Interface("IDirect3DIndexBuffer8", IDirect3DResource8)
 IDirect3DSurface8 = Interface("IDirect3DSurface8", IUnknown)
 IDirect3DVolume8 = Interface("IDirect3DVolume8", IUnknown)
 
-PDIRECT3D8 = Pointer(IDirect3D8)
-PDIRECT3DDEVICE8 = Pointer(IDirect3DDevice8)
-PDIRECT3DSWAPCHAIN8 = Pointer(IDirect3DSwapChain8)
-PDIRECT3DRESOURCE8 = Pointer(IDirect3DResource8)
-PDIRECT3DBASETEXTURE8 = Pointer(IDirect3DBaseTexture8)
-PDIRECT3DTEXTURE8 = Pointer(IDirect3DTexture8)
-PDIRECT3DVOLUMETEXTURE8 = Pointer(IDirect3DVolumeTexture8)
-PDIRECT3DCUBETEXTURE8 = Pointer(IDirect3DCubeTexture8)
-PDIRECT3DVERTEXBUFFER8 = Pointer(IDirect3DVertexBuffer8)
-PDIRECT3DINDEXBUFFER8 = Pointer(IDirect3DIndexBuffer8)
-PDIRECT3DSURFACE8 = Pointer(IDirect3DSurface8)
-PDIRECT3DVOLUME8 = Pointer(IDirect3DVolume8)
+PDIRECT3D8 = ObjPointer(IDirect3D8)
+PDIRECT3DDEVICE8 = ObjPointer(IDirect3DDevice8)
+PDIRECT3DSWAPCHAIN8 = ObjPointer(IDirect3DSwapChain8)
+PDIRECT3DRESOURCE8 = ObjPointer(IDirect3DResource8)
+PDIRECT3DBASETEXTURE8 = ObjPointer(IDirect3DBaseTexture8)
+PDIRECT3DTEXTURE8 = ObjPointer(IDirect3DTexture8)
+PDIRECT3DVOLUMETEXTURE8 = ObjPointer(IDirect3DVolumeTexture8)
+PDIRECT3DCUBETEXTURE8 = ObjPointer(IDirect3DCubeTexture8)
+PDIRECT3DVERTEXBUFFER8 = ObjPointer(IDirect3DVertexBuffer8)
+PDIRECT3DINDEXBUFFER8 = ObjPointer(IDirect3DIndexBuffer8)
+PDIRECT3DSURFACE8 = ObjPointer(IDirect3DSurface8)
+PDIRECT3DVOLUME8 = ObjPointer(IDirect3DVolume8)
 
 IDirect3D8.methods += [
     Method(HRESULT, "RegisterSoftwareDevice", [(OpaquePointer(Void), "pInitializeFunction")]),
     Method(UINT, "GetAdapterCount", []),
-    Method(HRESULT, "GetAdapterIdentifier", [(UINT, "Adapter"), (DWORD, "Flags"), Out(Pointer(D3DADAPTER_IDENTIFIER8), "pIdentifier")]),
-    Method(UINT, "GetAdapterModeCount", [(UINT, "Adapter")]),
-    Method(HRESULT, "EnumAdapterModes", [(UINT, "Adapter"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
-    Method(HRESULT, "GetAdapterDisplayMode", [(UINT, "Adapter"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
-    Method(HRESULT, "CheckDeviceType", [(UINT, "Adapter"), (D3DDEVTYPE, "CheckType"), (D3DFORMAT, "DisplayFormat"), (D3DFORMAT, "BackBufferFormat"), (BOOL, "Windowed")]),
-    Method(HRESULT, "CheckDeviceFormat", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (DWORD, "Usage"), (D3DRESOURCETYPE, "RType"), (D3DFORMAT, "CheckFormat")]),
-    Method(HRESULT, "CheckDeviceMultiSampleType", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SurfaceFormat"), (BOOL, "Windowed"), (D3DMULTISAMPLE_TYPE, "MultiSampleType")]),
-    Method(HRESULT, "CheckDepthStencilMatch", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "RenderTargetFormat"), (D3DFORMAT, "DepthStencilFormat")]),
-    Method(HRESULT, "GetDeviceCaps", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), Out(Pointer(D3DCAPS8), "pCaps")]),
-    Method(HMONITOR, "GetAdapterMonitor", [(UINT, "Adapter")]),
-    Method(HRESULT, "CreateDevice", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (DWORD, "BehaviorFlags"), Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DDEVICE8), "ppReturnedDeviceInterface")]),
+    Method(HRESULT, "GetAdapterIdentifier", [(D3DADAPTER, "Adapter"), (DWORD, "Flags"), Out(Pointer(D3DADAPTER_IDENTIFIER8), "pIdentifier")]),
+    Method(UINT, "GetAdapterModeCount", [(D3DADAPTER, "Adapter")]),
+    Method(HRESULT, "EnumAdapterModes", [(D3DADAPTER, "Adapter"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
+    Method(HRESULT, "GetAdapterDisplayMode", [(D3DADAPTER, "Adapter"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
+    Method(HRESULT, "CheckDeviceType", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "CheckType"), (D3DFORMAT, "DisplayFormat"), (D3DFORMAT, "BackBufferFormat"), (BOOL, "Windowed")]),
+    Method(HRESULT, "CheckDeviceFormat", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (DWORD, "Usage"), (D3DRESOURCETYPE, "RType"), (D3DFORMAT, "CheckFormat")]),
+    Method(HRESULT, "CheckDeviceMultiSampleType", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SurfaceFormat"), (BOOL, "Windowed"), (D3DMULTISAMPLE_TYPE, "MultiSampleType")]),
+    Method(HRESULT, "CheckDepthStencilMatch", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "RenderTargetFormat"), (D3DFORMAT, "DepthStencilFormat")]),
+    Method(HRESULT, "GetDeviceCaps", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), Out(Pointer(D3DCAPS8), "pCaps")]),
+    Method(HMONITOR, "GetAdapterMonitor", [(D3DADAPTER, "Adapter")]),
+    Method(HRESULT, "CreateDevice", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (D3DCREATE, "BehaviorFlags"), Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DDEVICE8), "ppReturnedDeviceInterface")]),
 ]
 
 IDirect3DDevice8.methods += [
@@ -259,7 +272,7 @@ IDirect3DSurface8.methods += [
     Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]),
     Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")]),
     Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
-    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppContainer")]),
+    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppContainer")]),
     Method(HRESULT, "GetDesc", [Out(Pointer(D3DSURFACE_DESC), "pDesc")]),
     Method(HRESULT, "LockRect", [Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (DWORD, "Flags")]),
     Method(HRESULT, "UnlockRect", []),
@@ -270,7 +283,7 @@ IDirect3DVolume8.methods += [
     Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (DWORD, "Flags")]),
     Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")]),
     Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
-    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppContainer")]),
+    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppContainer")]),
     Method(HRESULT, "GetDesc", [Out(Pointer(D3DVOLUME_DESC), "pDesc")]),
     Method(HRESULT, "LockBox", [Out(Pointer(D3DLOCKED_BOX), "pLockedVolume"), (ConstPointer(D3DBOX), "pBox"), (DWORD, "Flags")]),
     Method(HRESULT, "UnlockBox", []),
diff --git a/specs/d3d9.def b/specs/d3d9.def
deleted file mode 100644 (file)
index dbbb029..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-LIBRARY        "d3d9"
-
-EXPORTS
-        Direct3DCreate9
-        Direct3DCreate9Ex
-        D3DPERF_BeginEvent
-        D3DPERF_EndEvent
-        D3DPERF_SetMarker
-        D3DPERF_SetRegion
-        D3DPERF_QueryRepeatFrame
-        D3DPERF_SetOptions
-        D3DPERF_GetStatus
index 742c652e2ab6a3244f0fe447bf4e88b4b3d78549..fa71e9a87578a68cebd58700654901e10ecc7e51 100644 (file)
@@ -30,30 +30,13 @@ from d3d9types import *
 from d3d9caps import *
 
 
-D3DSHADER9 = Opaque("const DWORD *")
+D3DSHADER9 = Blob(Const(DWORD), "_shaderSize(pFunction)")
 
 D3DSPD = Flags(DWORD, [
     "D3DSPD_IUNKNOWN",
 ])
 
-D3DCREATE = Flags(DWORD, [
-    "D3DCREATE_FPU_PRESERVE",
-    "D3DCREATE_MULTITHREADED",
-    "D3DCREATE_PUREDEVICE",
-    "D3DCREATE_SOFTWARE_VERTEXPROCESSING",
-    "D3DCREATE_HARDWARE_VERTEXPROCESSING",
-    "D3DCREATE_MIXED_VERTEXPROCESSING",
-    "D3DCREATE_DISABLE_DRIVER_MANAGEMENT",
-    "D3DCREATE_ADAPTERGROUP_DEVICE",
-    "D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX",
-    "D3DCREATE_NOWINDOWCHANGES",
-    "D3DCREATE_DISABLE_PSGP_THREADING",
-    "D3DCREATE_ENABLE_PRESENTSTATS",
-    "D3DCREATE_DISABLE_PRINTSCREEN",
-    "D3DCREATE_SCREENSAVER",
-])
-
-D3DADAPTER = FakeEnum(DWORD, [
+D3DADAPTER = FakeEnum(UINT, [
     "D3DADAPTER_DEFAULT",
 ])
 
@@ -78,8 +61,7 @@ D3DPRESENT = Flags(DWORD, [
     "D3DPRESENT_VIDEO_RESTRICT_TO_MONITOR",
 ])
 
-HRESULT = Enum("HRESULT", [
-    "D3D_OK",
+HRESULT = MAKE_HRESULT(ok = "D3D_OK", errors = [
     "D3DERR_WRONGTEXTUREFORMAT",
     "D3DERR_UNSUPPORTEDCOLOROPERATION",
     "D3DERR_UNSUPPORTEDCOLORARG",
@@ -132,79 +114,79 @@ IDirect3D9Ex = Interface("IDirect3D9Ex", IDirect3D9)
 IDirect3DDevice9Ex = Interface("IDirect3DDevice9Ex", IDirect3DDevice9)
 IDirect3DSwapChain9Ex = Interface("IDirect3DSwapChain9Ex", IDirect3DSwapChain9)
 
-PDIRECT3D9 = Pointer(IDirect3D9)
-PDIRECT3DDEVICE9 = Pointer(IDirect3DDevice9)
-PDIRECT3DSTATEBLOCK9 = Pointer(IDirect3DStateBlock9)
-PDIRECT3DSWAPCHAIN9 = Pointer(IDirect3DSwapChain9)
-PDIRECT3DRESOURCE9 = Pointer(IDirect3DResource9)
-PDIRECT3DVERTEXDECLARATION9 = Pointer(IDirect3DVertexDeclaration9)
-PDIRECT3DVERTEXSHADER9 = Pointer(IDirect3DVertexShader9)
-PDIRECT3DPIXELSHADER9 = Pointer(IDirect3DPixelShader9)
-PDIRECT3DBASETEXTURE9 = Pointer(IDirect3DBaseTexture9)
-PDIRECT3DTEXTURE9 = Pointer(IDirect3DTexture9)
-PDIRECT3DVOLUMETEXTURE9 = Pointer(IDirect3DVolumeTexture9)
-PDIRECT3DCUBETEXTURE9 = Pointer(IDirect3DCubeTexture9)
-PDIRECT3DVERTEXBUFFER9 = Pointer(IDirect3DVertexBuffer9)
-PDIRECT3DINDEXBUFFER9 = Pointer(IDirect3DIndexBuffer9)
-PDIRECT3DSURFACE9 = Pointer(IDirect3DSurface9)
-PDIRECT3DVOLUME9 = Pointer(IDirect3DVolume9)
-PDIRECT3DQUERY9 = Pointer(IDirect3DQuery9)
-PDIRECT3D9EX = Pointer(IDirect3D9Ex)
-PDIRECT3DDEVICE9EX = Pointer(IDirect3DDevice9Ex)
-PDIRECT3DSWAPCHAIN9EX = Pointer(IDirect3DSwapChain9Ex)
+PDIRECT3D9 = ObjPointer(IDirect3D9)
+PDIRECT3DDEVICE9 = ObjPointer(IDirect3DDevice9)
+PDIRECT3DSTATEBLOCK9 = ObjPointer(IDirect3DStateBlock9)
+PDIRECT3DSWAPCHAIN9 = ObjPointer(IDirect3DSwapChain9)
+PDIRECT3DRESOURCE9 = ObjPointer(IDirect3DResource9)
+PDIRECT3DVERTEXDECLARATION9 = ObjPointer(IDirect3DVertexDeclaration9)
+PDIRECT3DVERTEXSHADER9 = ObjPointer(IDirect3DVertexShader9)
+PDIRECT3DPIXELSHADER9 = ObjPointer(IDirect3DPixelShader9)
+PDIRECT3DBASETEXTURE9 = ObjPointer(IDirect3DBaseTexture9)
+PDIRECT3DTEXTURE9 = ObjPointer(IDirect3DTexture9)
+PDIRECT3DVOLUMETEXTURE9 = ObjPointer(IDirect3DVolumeTexture9)
+PDIRECT3DCUBETEXTURE9 = ObjPointer(IDirect3DCubeTexture9)
+PDIRECT3DVERTEXBUFFER9 = ObjPointer(IDirect3DVertexBuffer9)
+PDIRECT3DINDEXBUFFER9 = ObjPointer(IDirect3DIndexBuffer9)
+PDIRECT3DSURFACE9 = ObjPointer(IDirect3DSurface9)
+PDIRECT3DVOLUME9 = ObjPointer(IDirect3DVolume9)
+PDIRECT3DQUERY9 = ObjPointer(IDirect3DQuery9)
+PDIRECT3D9EX = ObjPointer(IDirect3D9Ex)
+PDIRECT3DDEVICE9EX = ObjPointer(IDirect3DDevice9Ex)
+PDIRECT3DSWAPCHAIN9EX = ObjPointer(IDirect3DSwapChain9Ex)
 
 IDirect3D9.methods += [
-    Method(HRESULT, "RegisterSoftwareDevice", [(OpaquePointer(Void), "pInitializeFunction")]),
-    Method(UINT, "GetAdapterCount", []),
-    Method(HRESULT, "GetAdapterIdentifier", [(UINT, "Adapter"), (D3DENUM, "Flags"), Out(Pointer(D3DADAPTER_IDENTIFIER9), "pIdentifier")]),
-    Method(UINT, "GetAdapterModeCount", [(UINT, "Adapter"), (D3DFORMAT, "Format")]),
-    Method(HRESULT, "EnumAdapterModes", [(UINT, "Adapter"), (D3DFORMAT, "Format"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
-    Method(HRESULT, "GetAdapterDisplayMode", [(UINT, "Adapter"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
-    Method(HRESULT, "CheckDeviceType", [(UINT, "Adapter"), (D3DDEVTYPE, "DevType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "BackBufferFormat"), (BOOL, "bWindowed")]),
-    Method(HRESULT, "CheckDeviceFormat", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DUSAGE, "Usage"), (D3DRESOURCETYPE, "RType"), (D3DFORMAT, "CheckFormat")]),
-    Method(HRESULT, "CheckDeviceMultiSampleType", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SurfaceFormat"), (BOOL, "Windowed"), (D3DMULTISAMPLE_TYPE, "MultiSampleType"), Out(Pointer(DWORD), "pQualityLevels")]),
-    Method(HRESULT, "CheckDepthStencilMatch", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "RenderTargetFormat"), (D3DFORMAT, "DepthStencilFormat")]),
-    Method(HRESULT, "CheckDeviceFormatConversion", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SourceFormat"), (D3DFORMAT, "TargetFormat")]),
-    Method(HRESULT, "GetDeviceCaps", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), Out(Pointer(D3DCAPS9), "pCaps")]),
-    Method(HMONITOR, "GetAdapterMonitor", [(UINT, "Adapter")]),
-    Method(HRESULT, "CreateDevice", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (D3DCREATE, "BehaviorFlags"), Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DDEVICE9), "ppReturnedDeviceInterface")]),
+    Method(HRESULT, "RegisterSoftwareDevice", [(OpaquePointer(Void), "pInitializeFunction")], sideeffects=False),
+    Method(UINT, "GetAdapterCount", [], sideeffects=False),
+    Method(HRESULT, "GetAdapterIdentifier", [(D3DADAPTER, "Adapter"), (D3DENUM, "Flags"), Out(Pointer(D3DADAPTER_IDENTIFIER9), "pIdentifier")], sideeffects=False),
+    Method(UINT, "GetAdapterModeCount", [(D3DADAPTER, "Adapter"), (D3DFORMAT, "Format")], sideeffects=False),
+    Method(HRESULT, "EnumAdapterModes", [(D3DADAPTER, "Adapter"), (D3DFORMAT, "Format"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODE), "pMode")], sideeffects=False),
+    Method(HRESULT, "GetAdapterDisplayMode", [(D3DADAPTER, "Adapter"), Out(Pointer(D3DDISPLAYMODE), "pMode")], sideeffects=False),
+    Method(HRESULT, "CheckDeviceType", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DevType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "BackBufferFormat"), (BOOL, "bWindowed")], sideeffects=False),
+    Method(HRESULT, "CheckDeviceFormat", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DUSAGE, "Usage"), (D3DRESOURCETYPE, "RType"), (D3DFORMAT, "CheckFormat")], sideeffects=False),
+    Method(HRESULT, "CheckDeviceMultiSampleType", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SurfaceFormat"), (BOOL, "Windowed"), (D3DMULTISAMPLE_TYPE, "MultiSampleType"), Out(Pointer(DWORD), "pQualityLevels")], sideeffects=False),
+    Method(HRESULT, "CheckDepthStencilMatch", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "AdapterFormat"), (D3DFORMAT, "RenderTargetFormat"), (D3DFORMAT, "DepthStencilFormat")], sideeffects=False),
+    Method(HRESULT, "CheckDeviceFormatConversion", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (D3DFORMAT, "SourceFormat"), (D3DFORMAT, "TargetFormat")], sideeffects=False),
+    Method(HRESULT, "GetDeviceCaps", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), Out(Pointer(D3DCAPS9), "pCaps")], sideeffects=False),
+    Method(HMONITOR, "GetAdapterMonitor", [(D3DADAPTER, "Adapter")], sideeffects=False),
+    Method(HRESULT, "CreateDevice", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (D3DCREATE, "BehaviorFlags"), InOut(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DDEVICE9), "ppReturnedDeviceInterface")]),
 ]
 
 IDirect3DDevice9.methods += [
     Method(HRESULT, "TestCooperativeLevel", []),
-    Method(UINT, "GetAvailableTextureMem", []),
+    Method(UINT, "GetAvailableTextureMem", [], sideeffects=False),
     Method(HRESULT, "EvictManagedResources", []),
     Method(HRESULT, "GetDirect3D", [Out(Pointer(PDIRECT3D9), "ppD3D9")]),
-    Method(HRESULT, "GetDeviceCaps", [Out(Pointer(D3DCAPS9), "pCaps")]),
-    Method(HRESULT, "GetDisplayMode", [(UINT, "iSwapChain"), Out(Pointer(D3DDISPLAYMODE), "pMode")]),
-    Method(HRESULT, "GetCreationParameters", [Out(Pointer(D3DDEVICE_CREATION_PARAMETERS), "pParameters")]),
+    Method(HRESULT, "GetDeviceCaps", [Out(Pointer(D3DCAPS9), "pCaps")], sideeffects=False),
+    Method(HRESULT, "GetDisplayMode", [(UINT, "iSwapChain"), Out(Pointer(D3DDISPLAYMODE), "pMode")], sideeffects=False),
+    Method(HRESULT, "GetCreationParameters", [Out(Pointer(D3DDEVICE_CREATION_PARAMETERS), "pParameters")], sideeffects=False),
     Method(HRESULT, "SetCursorProperties", [(UINT, "XHotSpot"), (UINT, "YHotSpot"), (PDIRECT3DSURFACE9, "pCursorBitmap")]),
     Method(Void, "SetCursorPosition", [(Int, "X"), (Int, "Y"), (D3DCURSOR, "Flags")]),
     Method(BOOL, "ShowCursor", [(BOOL, "bShow")]),
-    Method(HRESULT, "CreateAdditionalSwapChain", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DSWAPCHAIN9), "pSwapChain")]),
+    Method(HRESULT, "CreateAdditionalSwapChain", [InOut(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(PDIRECT3DSWAPCHAIN9), "pSwapChain")]),
     Method(HRESULT, "GetSwapChain", [(UINT, "iSwapChain"), Out(Pointer(PDIRECT3DSWAPCHAIN9), "pSwapChain")]),
-    Method(UINT, "GetNumberOfSwapChains", []),
-    Method(HRESULT, "Reset", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")]),
+    Method(UINT, "GetNumberOfSwapChains", [], sideeffects=False),
+    Method(HRESULT, "Reset", [InOut(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")]),
     Method(HRESULT, "Present", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion")]),
     Method(HRESULT, "GetBackBuffer", [(UINT, "iSwapChain"), (UINT, "iBackBuffer"), (D3DBACKBUFFER_TYPE, "Type"), Out(Pointer(PDIRECT3DSURFACE9), "ppBackBuffer")]),
-    Method(HRESULT, "GetRasterStatus", [(UINT, "iSwapChain"), Out(Pointer(D3DRASTER_STATUS), "pRasterStatus")]),
+    Method(HRESULT, "GetRasterStatus", [(UINT, "iSwapChain"), Out(Pointer(D3DRASTER_STATUS), "pRasterStatus")], sideeffects=False),
     Method(HRESULT, "SetDialogBoxMode", [(BOOL, "bEnableDialogs")]),
     Method(Void, "SetGammaRamp", [(UINT, "iSwapChain"), (D3DSGR, "Flags"), (ConstPointer(D3DGAMMARAMP), "pRamp")]),
-    Method(Void, "GetGammaRamp", [(UINT, "iSwapChain"), Out(Pointer(D3DGAMMARAMP), "pRamp")]),
-    Method(HRESULT, "CreateTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DTEXTURE9), "ppTexture"), Out(Pointer(HANDLE), "pSharedHandle")]),
-    Method(HRESULT, "CreateVolumeTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Depth"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DVOLUMETEXTURE9), "ppVolumeTexture"), Out(Pointer(HANDLE), "pSharedHandle")]),
-    Method(HRESULT, "CreateCubeTexture", [(UINT, "EdgeLength"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DCUBETEXTURE9), "ppCubeTexture"), Out(Pointer(HANDLE), "pSharedHandle")]),
-    Method(HRESULT, "CreateVertexBuffer", [(UINT, "Length"), (D3DUSAGE, "Usage"), (D3DFVF, "FVF"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DVERTEXBUFFER9), "ppVertexBuffer"), Out(Pointer(HANDLE), "pSharedHandle")]),
-    Method(HRESULT, "CreateIndexBuffer", [(UINT, "Length"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DINDEXBUFFER9), "ppIndexBuffer"), Out(Pointer(HANDLE), "pSharedHandle")]),
-    Method(HRESULT, "CreateRenderTarget", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle")]),
-    Method(HRESULT, "CreateDepthStencilSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle")]),
+    Method(Void, "GetGammaRamp", [(UINT, "iSwapChain"), Out(Pointer(D3DGAMMARAMP), "pRamp")], sideeffects=False),
+    Method(HRESULT, "CreateTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DTEXTURE9), "ppTexture"), (Pointer(HANDLE), "pSharedHandle")]),
+    Method(HRESULT, "CreateVolumeTexture", [(UINT, "Width"), (UINT, "Height"), (UINT, "Depth"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DVOLUMETEXTURE9), "ppVolumeTexture"), (Pointer(HANDLE), "pSharedHandle")]),
+    Method(HRESULT, "CreateCubeTexture", [(UINT, "EdgeLength"), (UINT, "Levels"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DCUBETEXTURE9), "ppCubeTexture"), (Pointer(HANDLE), "pSharedHandle")]),
+    Method(HRESULT, "CreateVertexBuffer", [(UINT, "Length"), (D3DUSAGE, "Usage"), (D3DFVF, "FVF"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DVERTEXBUFFER9), "ppVertexBuffer"), (Pointer(HANDLE), "pSharedHandle")]),
+    Method(HRESULT, "CreateIndexBuffer", [(UINT, "Length"), (D3DUSAGE, "Usage"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DINDEXBUFFER9), "ppIndexBuffer"), (Pointer(HANDLE), "pSharedHandle")]),
+    Method(HRESULT, "CreateRenderTarget", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), (Pointer(HANDLE), "pSharedHandle")]),
+    Method(HRESULT, "CreateDepthStencilSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), (Pointer(HANDLE), "pSharedHandle")]),
     Method(HRESULT, "UpdateSurface", [(PDIRECT3DSURFACE9, "pSourceSurface"), (ConstPointer(RECT), "pSourceRect"), (PDIRECT3DSURFACE9, "pDestinationSurface"), (ConstPointer(POINT), "pDestPoint")]),
     Method(HRESULT, "UpdateTexture", [(PDIRECT3DBASETEXTURE9, "pSourceTexture"), (PDIRECT3DBASETEXTURE9, "pDestinationTexture")]),
-    Method(HRESULT, "GetRenderTargetData", [(PDIRECT3DSURFACE9, "pRenderTarget"), (PDIRECT3DSURFACE9, "pDestSurface")]),
-    Method(HRESULT, "GetFrontBufferData", [(UINT, "iSwapChain"), (PDIRECT3DSURFACE9, "pDestSurface")]),
+    Method(HRESULT, "GetRenderTargetData", [(PDIRECT3DSURFACE9, "pRenderTarget"), (PDIRECT3DSURFACE9, "pDestSurface")], sideeffects=False),
+    Method(HRESULT, "GetFrontBufferData", [(UINT, "iSwapChain"), (PDIRECT3DSURFACE9, "pDestSurface")], sideeffects=False),
     Method(HRESULT, "StretchRect", [(PDIRECT3DSURFACE9, "pSourceSurface"), (ConstPointer(RECT), "pSourceRect"), (PDIRECT3DSURFACE9, "pDestSurface"), (ConstPointer(RECT), "pDestRect"), (D3DTEXTUREFILTERTYPE, "Filter")]),
     Method(HRESULT, "ColorFill", [(PDIRECT3DSURFACE9, "pSurface"), (ConstPointer(RECT), "pRect"), (D3DCOLOR, "color")]),
-    Method(HRESULT, "CreateOffscreenPlainSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle")]),
+    Method(HRESULT, "CreateOffscreenPlainSurface", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), (Pointer(HANDLE), "pSharedHandle")]),
     Method(HRESULT, "SetRenderTarget", [(DWORD, "RenderTargetIndex"), (PDIRECT3DSURFACE9, "pRenderTarget")]),
     Method(HRESULT, "GetRenderTarget", [(DWORD, "RenderTargetIndex"), Out(Pointer(PDIRECT3DSURFACE9), "ppRenderTarget")]),
     Method(HRESULT, "SetDepthStencilSurface", [(PDIRECT3DSURFACE9, "pNewZStencil")]),
@@ -213,76 +195,76 @@ IDirect3DDevice9.methods += [
     Method(HRESULT, "EndScene", []),
     Method(HRESULT, "Clear", [(DWORD, "Count"), (ConstPointer(D3DRECT), "pRects"), (D3DCLEAR, "Flags"), (D3DCOLOR, "Color"), (Float, "Z"), (DWORD, "Stencil")]),
     Method(HRESULT, "SetTransform", [(D3DTRANSFORMSTATETYPE, "State"), (ConstPointer(D3DMATRIX), "pMatrix")]),
-    Method(HRESULT, "GetTransform", [(D3DTRANSFORMSTATETYPE, "State"), Out(Pointer(D3DMATRIX), "pMatrix")]),
+    Method(HRESULT, "GetTransform", [(D3DTRANSFORMSTATETYPE, "State"), Out(Pointer(D3DMATRIX), "pMatrix")], sideeffects=False),
     Method(HRESULT, "MultiplyTransform", [(D3DTRANSFORMSTATETYPE, "State"), (ConstPointer(D3DMATRIX), "pMatrix")]),
     Method(HRESULT, "SetViewport", [(ConstPointer(D3DVIEWPORT9), "pViewport")]),
-    Method(HRESULT, "GetViewport", [Out(Pointer(D3DVIEWPORT9), "pViewport")]),
+    Method(HRESULT, "GetViewport", [Out(Pointer(D3DVIEWPORT9), "pViewport")], sideeffects=False),
     Method(HRESULT, "SetMaterial", [(ConstPointer(D3DMATERIAL9), "pMaterial")]),
-    Method(HRESULT, "GetMaterial", [Out(Pointer(D3DMATERIAL9), "pMaterial")]),
+    Method(HRESULT, "GetMaterial", [Out(Pointer(D3DMATERIAL9), "pMaterial")], sideeffects=False),
     Method(HRESULT, "SetLight", [(DWORD, "Index"), (ConstPointer(D3DLIGHT9), "pLight")]),
-    Method(HRESULT, "GetLight", [(DWORD, "Index"), Out(Pointer(D3DLIGHT9), "pLight")]),
+    Method(HRESULT, "GetLight", [(DWORD, "Index"), Out(Pointer(D3DLIGHT9), "pLight")], sideeffects=False),
     Method(HRESULT, "LightEnable", [(DWORD, "Index"), (BOOL, "Enable")]),
-    Method(HRESULT, "GetLightEnable", [(DWORD, "Index"), Out(Pointer(BOOL), "pEnable")]),
+    Method(HRESULT, "GetLightEnable", [(DWORD, "Index"), Out(Pointer(BOOL), "pEnable")], sideeffects=False),
     Method(HRESULT, "SetClipPlane", [(DWORD, "Index"), (ConstPointer(Float), "pPlane")]),
-    Method(HRESULT, "GetClipPlane", [(DWORD, "Index"), Out(Pointer(Float), "pPlane")]),
+    Method(HRESULT, "GetClipPlane", [(DWORD, "Index"), Out(Pointer(Float), "pPlane")], sideeffects=False),
     Method(HRESULT, "SetRenderState", [(D3DRENDERSTATETYPE, "State"), (D3DRENDERSTATEVALUE, "Value")]),
-    Method(HRESULT, "GetRenderState", [(D3DRENDERSTATETYPE, "State"), Out(Pointer(D3DRENDERSTATEVALUE), "pValue")]),
+    Method(HRESULT, "GetRenderState", [(D3DRENDERSTATETYPE, "State"), Out(Pointer(D3DRENDERSTATEVALUE), "pValue")], sideeffects=False),
     Method(HRESULT, "CreateStateBlock", [(D3DSTATEBLOCKTYPE, "Type"), Out(Pointer(PDIRECT3DSTATEBLOCK9), "ppSB")]),
     Method(HRESULT, "BeginStateBlock", []),
     Method(HRESULT, "EndStateBlock", [Out(Pointer(PDIRECT3DSTATEBLOCK9), "ppSB")]),
     Method(HRESULT, "SetClipStatus", [(ConstPointer(D3DCLIPSTATUS9), "pClipStatus")]),
-    Method(HRESULT, "GetClipStatus", [Out(Pointer(D3DCLIPSTATUS9), "pClipStatus")]),
+    Method(HRESULT, "GetClipStatus", [Out(Pointer(D3DCLIPSTATUS9), "pClipStatus")], sideeffects=False),
     Method(HRESULT, "GetTexture", [(DWORD, "Stage"), Out(Pointer(PDIRECT3DBASETEXTURE9), "ppTexture")]),
     Method(HRESULT, "SetTexture", [(DWORD, "Stage"), (PDIRECT3DBASETEXTURE9, "pTexture")]),
-    Method(HRESULT, "GetTextureStageState", [(DWORD, "Stage"), (D3DTEXTURESTAGESTATETYPE, "Type"), Out(Pointer(D3DTEXTURESTAGESTATEVALUE), "pValue")]),
+    Method(HRESULT, "GetTextureStageState", [(DWORD, "Stage"), (D3DTEXTURESTAGESTATETYPE, "Type"), Out(Pointer(D3DTEXTURESTAGESTATEVALUE), "pValue")], sideeffects=False),
     Method(HRESULT, "SetTextureStageState", [(DWORD, "Stage"), (D3DTEXTURESTAGESTATETYPE, "Type"), (D3DTEXTURESTAGESTATEVALUE, "Value")]),
-    Method(HRESULT, "GetSamplerState", [(DWORD, "Sampler"), (D3DSAMPLERSTATETYPE, "Type"), Out(Pointer(D3DSAMPLERSTATEVALUE), "pValue")]),
+    Method(HRESULT, "GetSamplerState", [(DWORD, "Sampler"), (D3DSAMPLERSTATETYPE, "Type"), Out(Pointer(D3DSAMPLERSTATEVALUE), "pValue")], sideeffects=False),
     Method(HRESULT, "SetSamplerState", [(DWORD, "Sampler"), (D3DSAMPLERSTATETYPE, "Type"), (D3DSAMPLERSTATEVALUE, "Value")]),
     Method(HRESULT, "ValidateDevice", [Out(Pointer(DWORD), "pNumPasses")]),
     Method(HRESULT, "SetPaletteEntries", [(UINT, "PaletteNumber"), (ConstPointer(PALETTEENTRY), "pEntries")]),
-    Method(HRESULT, "GetPaletteEntries", [(UINT, "PaletteNumber"), Out(Pointer(PALETTEENTRY), "pEntries")]),
+    Method(HRESULT, "GetPaletteEntries", [(UINT, "PaletteNumber"), Out(Pointer(PALETTEENTRY), "pEntries")], sideeffects=False),
     Method(HRESULT, "SetCurrentTexturePalette", [(UINT, "PaletteNumber")]),
-    Method(HRESULT, "GetCurrentTexturePalette", [Out(Pointer(UINT), "PaletteNumber")]),
+    Method(HRESULT, "GetCurrentTexturePalette", [Out(Pointer(UINT), "PaletteNumber")], sideeffects=False),
     Method(HRESULT, "SetScissorRect", [(ConstPointer(RECT), "pRect")]),
     Method(HRESULT, "GetScissorRect", [Out(Pointer(RECT), "pRect")]),
     Method(HRESULT, "SetSoftwareVertexProcessing", [(BOOL, "bSoftware")]),
-    Method(BOOL, "GetSoftwareVertexProcessing", []),
+    Method(BOOL, "GetSoftwareVertexProcessing", [], sideeffects=False),
     Method(HRESULT, "SetNPatchMode", [(Float, "nSegments")]),
-    Method(Float, "GetNPatchMode", []),
+    Method(Float, "GetNPatchMode", [], sideeffects=False),
     Method(HRESULT, "DrawPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "StartVertex"), (UINT, "PrimitiveCount")]),
     Method(HRESULT, "DrawIndexedPrimitive", [(D3DPRIMITIVETYPE, "PrimitiveType"), (INT, "BaseVertexIndex"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "startIndex"), (UINT, "primCount")]),
-    Method(HRESULT, "DrawPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "PrimitiveCount"), (OpaquePointer(Const(Void)), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
-    Method(HRESULT, "DrawIndexedPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "PrimitiveCount"), (OpaquePointer(Const(Void)), "pIndexData"), (D3DFORMAT, "IndexDataFormat"), (OpaquePointer(Const(Void)), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
+    Method(HRESULT, "DrawPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "PrimitiveCount"), (Blob(Const(Void), "_vertexDataSize(PrimitiveType, PrimitiveCount, VertexStreamZeroStride)"), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
+    Method(HRESULT, "DrawIndexedPrimitiveUP", [(D3DPRIMITIVETYPE, "PrimitiveType"), (UINT, "MinVertexIndex"), (UINT, "NumVertices"), (UINT, "PrimitiveCount"), (Blob(Const(Void), "_indexDataSize(PrimitiveType, PrimitiveCount, IndexDataFormat)"), "pIndexData"), (D3DFORMAT, "IndexDataFormat"), (Blob(Const(Void), "NumVertices*VertexStreamZeroStride"), "pVertexStreamZeroData"), (UINT, "VertexStreamZeroStride")]),
     Method(HRESULT, "ProcessVertices", [(UINT, "SrcStartIndex"), (UINT, "DestIndex"), (UINT, "VertexCount"), (PDIRECT3DVERTEXBUFFER9, "pDestBuffer"), (PDIRECT3DVERTEXDECLARATION9, "pVertexDecl"), (D3DPV, "Flags")]),
     Method(HRESULT, "CreateVertexDeclaration", [(Array(Const(D3DVERTEXELEMENT9), "_declCount(pVertexElements)"), "pVertexElements"), Out(Pointer(PDIRECT3DVERTEXDECLARATION9), "ppDecl")]),
     Method(HRESULT, "SetVertexDeclaration", [(PDIRECT3DVERTEXDECLARATION9, "pDecl")]),
     Method(HRESULT, "GetVertexDeclaration", [Out(Pointer(PDIRECT3DVERTEXDECLARATION9), "ppDecl")]),
     Method(HRESULT, "SetFVF", [(D3DFVF, "FVF")]),
-    Method(HRESULT, "GetFVF", [Out(Pointer(D3DFVF), "pFVF")]),
+    Method(HRESULT, "GetFVF", [Out(Pointer(D3DFVF), "pFVF")], sideeffects=False),
     Method(HRESULT, "CreateVertexShader", [(D3DSHADER9, "pFunction"), Out(Pointer(PDIRECT3DVERTEXSHADER9), "ppShader")]),
     Method(HRESULT, "SetVertexShader", [(PDIRECT3DVERTEXSHADER9, "pShader")]),
     Method(HRESULT, "GetVertexShader", [Out(Pointer(PDIRECT3DVERTEXSHADER9), "ppShader")]),
     Method(HRESULT, "SetVertexShaderConstantF", [(UINT, "StartRegister"), (Array(Const(Float), "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")]),
-    Method(HRESULT, "GetVertexShaderConstantF", [(UINT, "StartRegister"), Out(Array(Float, "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")]),
+    Method(HRESULT, "GetVertexShaderConstantF", [(UINT, "StartRegister"), Out(Array(Float, "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")], sideeffects=False),
     Method(HRESULT, "SetVertexShaderConstantI", [(UINT, "StartRegister"), (Array(Const(Int), "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")]),
-    Method(HRESULT, "GetVertexShaderConstantI", [(UINT, "StartRegister"), Out(Array(Int, "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")]),
+    Method(HRESULT, "GetVertexShaderConstantI", [(UINT, "StartRegister"), Out(Array(Int, "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")], sideeffects=False),
     Method(HRESULT, "SetVertexShaderConstantB", [(UINT, "StartRegister"), (Array(Const(BOOL), "BoolCount"), "pConstantData"), (UINT, "BoolCount")]),
-    Method(HRESULT, "GetVertexShaderConstantB", [(UINT, "StartRegister"), Out(Array(BOOL, "BoolCount"), "pConstantData"), (UINT, "BoolCount")]),
+    Method(HRESULT, "GetVertexShaderConstantB", [(UINT, "StartRegister"), Out(Array(BOOL, "BoolCount"), "pConstantData"), (UINT, "BoolCount")], sideeffects=False),
     Method(HRESULT, "SetStreamSource", [(UINT, "StreamNumber"), (PDIRECT3DVERTEXBUFFER9, "pStreamData"), (UINT, "OffsetInBytes"), (UINT, "Stride")]),
     Method(HRESULT, "GetStreamSource", [(UINT, "StreamNumber"), Out(Pointer(PDIRECT3DVERTEXBUFFER9), "ppStreamData"), Out(Pointer(UINT), "pOffsetInBytes"), Out(Pointer(UINT), "pStride")]),
     Method(HRESULT, "SetStreamSourceFreq", [(UINT, "StreamNumber"), (UINT, "Setting")]),
-    Method(HRESULT, "GetStreamSourceFreq", [(UINT, "StreamNumber"), Out(Pointer(UINT), "pSetting")]),
+    Method(HRESULT, "GetStreamSourceFreq", [(UINT, "StreamNumber"), Out(Pointer(UINT), "pSetting")], sideeffects=False),
     Method(HRESULT, "SetIndices", [(PDIRECT3DINDEXBUFFER9, "pIndexData")]),
     Method(HRESULT, "GetIndices", [Out(Pointer(PDIRECT3DINDEXBUFFER9), "ppIndexData")]),
     Method(HRESULT, "CreatePixelShader", [(D3DSHADER9, "pFunction"), Out(Pointer(PDIRECT3DPIXELSHADER9), "ppShader")]),
     Method(HRESULT, "SetPixelShader", [(PDIRECT3DPIXELSHADER9, "pShader")]),
     Method(HRESULT, "GetPixelShader", [Out(Pointer(PDIRECT3DPIXELSHADER9), "ppShader")]),
     Method(HRESULT, "SetPixelShaderConstantF", [(UINT, "StartRegister"), (Array(Const(Float), "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")]),
-    Method(HRESULT, "GetPixelShaderConstantF", [(UINT, "StartRegister"), Out(Array(Float, "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")]),
+    Method(HRESULT, "GetPixelShaderConstantF", [(UINT, "StartRegister"), Out(Array(Float, "4*Vector4fCount"), "pConstantData"), (UINT, "Vector4fCount")], sideeffects=False),
     Method(HRESULT, "SetPixelShaderConstantI", [(UINT, "StartRegister"), (Array(Const(Int), "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")]),
-    Method(HRESULT, "GetPixelShaderConstantI", [(UINT, "StartRegister"), Out(Array(Int, "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")]),
+    Method(HRESULT, "GetPixelShaderConstantI", [(UINT, "StartRegister"), Out(Array(Int, "4*Vector4iCount"), "pConstantData"), (UINT, "Vector4iCount")], sideeffects=False),
     Method(HRESULT, "SetPixelShaderConstantB", [(UINT, "StartRegister"), (Array(Const(BOOL), "BoolCount"), "pConstantData"), (UINT, "BoolCount")]),
-    Method(HRESULT, "GetPixelShaderConstantB", [(UINT, "StartRegister"), Out(Array(BOOL, "BoolCount"), "pConstantData"), (UINT, "BoolCount")]),
+    Method(HRESULT, "GetPixelShaderConstantB", [(UINT, "StartRegister"), Out(Array(BOOL, "BoolCount"), "pConstantData"), (UINT, "BoolCount")], sideeffects=False),
     Method(HRESULT, "DrawRectPatch", [(UINT, "Handle"), (ConstPointer(Float), "pNumSegs"), (ConstPointer(D3DRECTPATCH_INFO), "pRectPatchInfo")]),
     Method(HRESULT, "DrawTriPatch", [(UINT, "Handle"), (ConstPointer(Float), "pNumSegs"), (ConstPointer(D3DTRIPATCH_INFO), "pTriPatchInfo")]),
     Method(HRESULT, "DeletePatch", [(UINT, "Handle")]),
@@ -297,51 +279,51 @@ IDirect3DStateBlock9.methods += [
 
 IDirect3DSwapChain9.methods += [
     Method(HRESULT, "Present", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion"), (D3DPRESENT, "dwFlags")]),
-    Method(HRESULT, "GetFrontBufferData", [(PDIRECT3DSURFACE9, "pDestSurface")]),
+    Method(HRESULT, "GetFrontBufferData", [(PDIRECT3DSURFACE9, "pDestSurface")], sideeffects=False),
     Method(HRESULT, "GetBackBuffer", [(UINT, "iBackBuffer"), (D3DBACKBUFFER_TYPE, "Type"), Out(Pointer(PDIRECT3DSURFACE9), "ppBackBuffer")]),
-    Method(HRESULT, "GetRasterStatus", [Out(Pointer(D3DRASTER_STATUS), "pRasterStatus")]),
-    Method(HRESULT, "GetDisplayMode", [Out(Pointer(D3DDISPLAYMODE), "pMode")]),
+    Method(HRESULT, "GetRasterStatus", [Out(Pointer(D3DRASTER_STATUS), "pRasterStatus")], sideeffects=False),
+    Method(HRESULT, "GetDisplayMode", [Out(Pointer(D3DDISPLAYMODE), "pMode")], sideeffects=False),
     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
-    Method(HRESULT, "GetPresentParameters", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")]),
+    Method(HRESULT, "GetPresentParameters", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters")], sideeffects=False),
 ]
 
 IDirect3DResource9.methods += [
     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
-    Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")]),
-    Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")]),
-    Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
+    Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaqueBlob(Const(Void), "SizeOfData"), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")], sideeffects=False),
+    Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(DWORD), "pSizeOfData")], sideeffects=False),
+    Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")], sideeffects=False),
     Method(D3D9_RESOURCE_PRIORITY, "SetPriority", [(D3D9_RESOURCE_PRIORITY, "PriorityNew")]),
-    Method(D3D9_RESOURCE_PRIORITY, "GetPriority", []),
+    Method(D3D9_RESOURCE_PRIORITY, "GetPriority", [], sideeffects=False),
     Method(Void, "PreLoad", []),
-    Method(D3DRESOURCETYPE, "GetType", []),
+    Method(D3DRESOURCETYPE, "GetType", [], sideeffects=False),
 ]
 
 IDirect3DVertexDeclaration9.methods += [
     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
-    Method(HRESULT, "GetDeclaration", [Out(Pointer(D3DVERTEXELEMENT9), "pElement"), Out(Pointer(UINT), "pNumElements")]),
+    Method(HRESULT, "GetDeclaration", [Out(Array(D3DVERTEXELEMENT9, "*pNumElements"), "pElement"), Out(Pointer(UINT), "pNumElements")], sideeffects=False),
 ]
 
 IDirect3DVertexShader9.methods += [
     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
-    Method(HRESULT, "GetFunction", [Out(OpaquePointer(Void), "pData"), Out(Pointer(UINT), "pSizeOfData")]),
+    Method(HRESULT, "GetFunction", [Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(UINT), "pSizeOfData")], sideeffects=False),
 ]
 
 IDirect3DPixelShader9.methods += [
     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
-    Method(HRESULT, "GetFunction", [Out(OpaquePointer(Void), "pData"), Out(Pointer(UINT), "pSizeOfData")]),
+    Method(HRESULT, "GetFunction", [Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(UINT), "pSizeOfData")], sideeffects=False),
 ]
 
 IDirect3DBaseTexture9.methods += [
     Method(DWORD, "SetLOD", [(DWORD, "LODNew")]),
-    Method(DWORD, "GetLOD", []),
-    Method(DWORD, "GetLevelCount", []),
+    Method(DWORD, "GetLOD", [], sideeffects=False),
+    Method(DWORD, "GetLevelCount", [], sideeffects=False),
     Method(HRESULT, "SetAutoGenFilterType", [(D3DTEXTUREFILTERTYPE, "FilterType")]),
-    Method(D3DTEXTUREFILTERTYPE, "GetAutoGenFilterType", []),
+    Method(D3DTEXTUREFILTERTYPE, "GetAutoGenFilterType", [], sideeffects=False),
     Method(Void, "GenerateMipSubLevels", []),
 ]
 
 IDirect3DTexture9.methods += [
-    Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DSURFACE_DESC), "pDesc")]),
+    Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DSURFACE_DESC), "pDesc")], sideeffects=False),
     Method(HRESULT, "GetSurfaceLevel", [(UINT, "Level"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurfaceLevel")]),
     Method(HRESULT, "LockRect", [(UINT, "Level"), Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]),
     Method(HRESULT, "UnlockRect", [(UINT, "Level")]),
@@ -349,7 +331,7 @@ IDirect3DTexture9.methods += [
 ]
 
 IDirect3DVolumeTexture9.methods += [
-    Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DVOLUME_DESC), "pDesc")]),
+    Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DVOLUME_DESC), "pDesc")], sideeffects=False),
     Method(HRESULT, "GetVolumeLevel", [(UINT, "Level"), Out(Pointer(PDIRECT3DVOLUME9), "ppVolumeLevel")]),
     Method(HRESULT, "LockBox", [(UINT, "Level"), Out(Pointer(D3DLOCKED_BOX), "pLockedVolume"), (ConstPointer(D3DBOX), "pBox"), (D3DLOCK, "Flags")]),
     Method(HRESULT, "UnlockBox", [(UINT, "Level")]),
@@ -357,7 +339,7 @@ IDirect3DVolumeTexture9.methods += [
 ]
 
 IDirect3DCubeTexture9.methods += [
-    Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DSURFACE_DESC), "pDesc")]),
+    Method(HRESULT, "GetLevelDesc", [(UINT, "Level"), Out(Pointer(D3DSURFACE_DESC), "pDesc")], sideeffects=False),
     Method(HRESULT, "GetCubeMapSurface", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level"), Out(Pointer(PDIRECT3DSURFACE9), "ppCubeMapSurface")]),
     Method(HRESULT, "LockRect", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level"), Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]),
     Method(HRESULT, "UnlockRect", [(D3DCUBEMAP_FACES, "FaceType"), (UINT, "Level")]),
@@ -365,20 +347,20 @@ IDirect3DCubeTexture9.methods += [
 ]
 
 IDirect3DVertexBuffer9.methods += [
-    Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(OpaquePointer(Void)), "ppbData"), (D3DLOCK, "Flags")]),
+    Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(LinearPointer(Void, "_LockedSize")), "ppbData"), (D3DLOCK, "Flags")]),
     Method(HRESULT, "Unlock", []),
-    Method(HRESULT, "GetDesc", [Out(Pointer(D3DVERTEXBUFFER_DESC), "pDesc")]),
+    Method(HRESULT, "GetDesc", [Out(Pointer(D3DVERTEXBUFFER_DESC), "pDesc")], sideeffects=False),
 ]
 
 IDirect3DIndexBuffer9.methods += [
-    Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(OpaquePointer(Void)), "ppbData"), (D3DLOCK, "Flags")]),
+    Method(HRESULT, "Lock", [(UINT, "OffsetToLock"), (UINT, "SizeToLock"), Out(Pointer(LinearPointer(Void, "_LockedSize")), "ppbData"), (D3DLOCK, "Flags")]),
     Method(HRESULT, "Unlock", []),
-    Method(HRESULT, "GetDesc", [Out(Pointer(D3DINDEXBUFFER_DESC), "pDesc")]),
+    Method(HRESULT, "GetDesc", [Out(Pointer(D3DINDEXBUFFER_DESC), "pDesc")], sideeffects=False),
 ]
 
 IDirect3DSurface9.methods += [
-    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppContainer")]),
-    Method(HRESULT, "GetDesc", [Out(Pointer(D3DSURFACE_DESC), "pDesc")]),
+    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppContainer")], sideeffects=False),
+    Method(HRESULT, "GetDesc", [Out(Pointer(D3DSURFACE_DESC), "pDesc")], sideeffects=False),
     Method(HRESULT, "LockRect", [Out(Pointer(D3DLOCKED_RECT), "pLockedRect"), (ConstPointer(RECT), "pRect"), (D3DLOCK, "Flags")]),
     Method(HRESULT, "UnlockRect", []),
     Method(HRESULT, "GetDC", [Out(Pointer(HDC), "phdc")]),
@@ -387,64 +369,67 @@ IDirect3DSurface9.methods += [
 
 IDirect3DVolume9.methods += [
     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
-    Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaquePointer(Const(Void)), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")]),
-    Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaquePointer(Void), "pData"), Out(Pointer(DWORD), "pSizeOfData")]),
-    Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")]),
-    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppContainer")]),
-    Method(HRESULT, "GetDesc", [Out(Pointer(D3DVOLUME_DESC), "pDesc")]),
+    Method(HRESULT, "SetPrivateData", [(REFGUID, "refguid"), (OpaqueBlob(Const(Void), "SizeOfData"), "pData"), (DWORD, "SizeOfData"), (D3DSPD, "Flags")], sideeffects=False),
+    Method(HRESULT, "GetPrivateData", [(REFGUID, "refguid"), Out(OpaqueBlob(Void, "*pSizeOfData"), "pData"), Out(Pointer(DWORD), "pSizeOfData")], sideeffects=False),
+    Method(HRESULT, "FreePrivateData", [(REFGUID, "refguid")], sideeffects=False),
+    Method(HRESULT, "GetContainer", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppContainer")], sideeffects=False),
+    Method(HRESULT, "GetDesc", [Out(Pointer(D3DVOLUME_DESC), "pDesc")], sideeffects=False),
     Method(HRESULT, "LockBox", [Out(Pointer(D3DLOCKED_BOX), "pLockedVolume"), (ConstPointer(D3DBOX), "pBox"), (D3DLOCK, "Flags")]),
     Method(HRESULT, "UnlockBox", []),
 ]
 
 IDirect3DQuery9.methods += [
     Method(HRESULT, "GetDevice", [Out(Pointer(PDIRECT3DDEVICE9), "ppDevice")]),
-    Method(D3DQUERYTYPE, "GetType", []),
-    Method(DWORD, "GetDataSize", []),
+    Method(D3DQUERYTYPE, "GetType", [], sideeffects=False),
+    Method(DWORD, "GetDataSize", [], sideeffects=False),
     Method(HRESULT, "Issue", [(D3DISSUE, "dwIssueFlags")]),
-    Method(HRESULT, "GetData", [Out(Blob(Void, "dwSize"), "pData"), (DWORD, "dwSize"), (D3DGETDATA, "dwGetDataFlags")]),
+    Method(HRESULT, "GetData", [Out(Blob(Void, "dwSize"), "pData"), (DWORD, "dwSize"), (D3DGETDATA, "dwGetDataFlags")], sideeffects=False),
 ]
 
 IDirect3D9Ex.methods += [
-    Method(UINT, "GetAdapterModeCountEx", [(UINT, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter") ]),
-    Method(HRESULT, "EnumAdapterModesEx", [(UINT, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODEEX), "pMode")]),
-    Method(HRESULT, "GetAdapterDisplayModeEx", [(UINT, "Adapter"), Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")]),
-    Method(HRESULT, "CreateDeviceEx", [(UINT, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (D3DCREATE, "BehaviorFlags"), Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode"), Out(Pointer(PDIRECT3DDEVICE9EX), "ppReturnedDeviceInterface")]),
-    Method(HRESULT, "GetAdapterLUID", [(UINT, "Adapter"), Out(Pointer(LUID), "pLUID")]),
+    Method(UINT, "GetAdapterModeCountEx", [(D3DADAPTER, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter") ], sideeffects=False),
+    Method(HRESULT, "EnumAdapterModesEx", [(D3DADAPTER, "Adapter"), (ConstPointer(D3DDISPLAYMODEFILTER), "pFilter"), (UINT, "Mode"), Out(Pointer(D3DDISPLAYMODEEX), "pMode")], sideeffects=False),
+    Method(HRESULT, "GetAdapterDisplayModeEx", [(D3DADAPTER, "Adapter"), Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")], sideeffects=False),
+    Method(HRESULT, "CreateDeviceEx", [(D3DADAPTER, "Adapter"), (D3DDEVTYPE, "DeviceType"), (HWND, "hFocusWindow"), (D3DCREATE, "BehaviorFlags"), InOut(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode"), Out(Pointer(PDIRECT3DDEVICE9EX), "ppReturnedDeviceInterface")]),
+    Method(HRESULT, "GetAdapterLUID", [(D3DADAPTER, "Adapter"), Out(Pointer(LUID), "pLUID")], sideeffects=False),
 ]
 
 IDirect3DDevice9Ex.methods += [
     Method(HRESULT, "SetConvolutionMonoKernel", [(UINT, "width"), (UINT, "height"), (Array(Float, "width"), "rows"), (Array(Float, "height"), "columns")]),
     Method(HRESULT, "ComposeRects", [(PDIRECT3DSURFACE9, "pSrc"), (PDIRECT3DSURFACE9, "pDst"), (PDIRECT3DVERTEXBUFFER9, "pSrcRectDescs"), (UINT, "NumRects"), (PDIRECT3DVERTEXBUFFER9, "pDstRectDescs"), (D3DCOMPOSERECTSOP, "Operation"), (Int, "Xoffset"), (Int, "Yoffset")]),
     Method(HRESULT, "PresentEx", [(ConstPointer(RECT), "pSourceRect"), (ConstPointer(RECT), "pDestRect"), (HWND, "hDestWindowOverride"), (ConstPointer(RGNDATA), "pDirtyRegion"), (D3DPRESENT, "dwFlags")]),
-    Method(HRESULT, "GetGPUThreadPriority", [Out(Pointer(INT), "pPriority")]),
+    Method(HRESULT, "GetGPUThreadPriority", [Out(Pointer(INT), "pPriority")], sideeffects=False),
     Method(HRESULT, "SetGPUThreadPriority", [(INT, "Priority")]),
     Method(HRESULT, "WaitForVBlank", [(UINT, "iSwapChain")]),
     Method(HRESULT, "CheckResourceResidency", [(Array(PDIRECT3DRESOURCE9, "NumResources"), "pResourceArray"), (UINT32, "NumResources")]),
     Method(HRESULT, "SetMaximumFrameLatency", [(UINT, "MaxLatency")]),
-    Method(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")]),
-    Method(HRESULT, "CheckDeviceState", [(HWND, "hDestinationWindow")]),
-    Method(HRESULT, "CreateRenderTargetEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
+    Method(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")], sideeffects=False),
+    Method(HRESULT, "CheckDeviceState", [(HWND, "hDestinationWindow")], sideeffects=False),
+    Method(HRESULT, "CreateRenderTargetEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Lockable"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), (Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
     Method(HRESULT, "CreateOffscreenPlainSurfaceEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
-    Method(HRESULT, "CreateDepthStencilSurfaceEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), Out(Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
-    Method(HRESULT, "ResetEx", [Out(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode")]),
-    Method(HRESULT, "GetDisplayModeEx", [(UINT, "iSwapChain"), Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")]),
+    Method(HRESULT, "CreateDepthStencilSurfaceEx", [(UINT, "Width"), (UINT, "Height"), (D3DFORMAT, "Format"), (D3DMULTISAMPLE_TYPE, "MultiSample"), (DWORD, "MultisampleQuality"), (BOOL, "Discard"), Out(Pointer(PDIRECT3DSURFACE9), "ppSurface"), (Pointer(HANDLE), "pSharedHandle"), (D3DUSAGE, "Usage")]),
+    Method(HRESULT, "ResetEx", [InOut(Pointer(D3DPRESENT_PARAMETERS), "pPresentationParameters"), Out(Pointer(D3DDISPLAYMODEEX), "pFullscreenDisplayMode")]),
+    Method(HRESULT, "GetDisplayModeEx", [(UINT, "iSwapChain"), Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")], sideeffects=False),
 ]
 
 IDirect3DSwapChain9Ex.methods += [
-    Method(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "pLastPresentCount")]),
-    Method(HRESULT, "GetPresentStats", [Out(Pointer(D3DPRESENTSTATS), "pPresentationStatistics")]),
-    Method(HRESULT, "GetDisplayModeEx", [Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")]),
+    Method(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "pLastPresentCount")], sideeffects=False),
+    Method(HRESULT, "GetPresentStats", [Out(Pointer(D3DPRESENTSTATS), "pPresentationStatistics")], sideeffects=False),
+    Method(HRESULT, "GetDisplayModeEx", [Out(Pointer(D3DDISPLAYMODEEX), "pMode"), Out(Pointer(D3DDISPLAYROTATION), "pRotation")], sideeffects=False),
 ]
 
 d3d9 = API("d3d9")
 d3d9.addFunctions([
     StdFunction(PDIRECT3D9, "Direct3DCreate9", [(UINT, "SDKVersion")], fail='NULL'),
     StdFunction(HRESULT, "Direct3DCreate9Ex", [(UINT, "SDKVersion"), Out(Pointer(PDIRECT3D9EX), "ppD3D")], fail='D3DERR_NOTAVAILABLE'),
-    StdFunction(Int, "D3DPERF_BeginEvent", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail='-1'),
-    StdFunction(Int, "D3DPERF_EndEvent", [], fail='-1'),
-    StdFunction(Void, "D3DPERF_SetMarker", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")]),
-    StdFunction(Void, "D3DPERF_SetRegion", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")]),
-    StdFunction(BOOL, "D3DPERF_QueryRepeatFrame", [], fail='FALSE'),
-    StdFunction(Void, "D3DPERF_SetOptions", [(DWORD, "dwOptions")]),
-    StdFunction(DWORD, "D3DPERF_GetStatus", [], fail='0'),
+    StdFunction(Int, "D3DPERF_BeginEvent", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], fail='-1', sideeffects=False),
+    StdFunction(Int, "D3DPERF_EndEvent", [], fail='-1', sideeffects=False),
+    StdFunction(Void, "D3DPERF_SetMarker", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], sideeffects=False),
+    StdFunction(Void, "D3DPERF_SetRegion", [(D3DCOLOR, "col"), (LPCWSTR, "wszName")], sideeffects=False),
+    StdFunction(BOOL, "D3DPERF_QueryRepeatFrame", [], fail='FALSE', sideeffects=False),
+    StdFunction(Void, "D3DPERF_SetOptions", [(DWORD, "dwOptions")], sideeffects=False),
+    StdFunction(DWORD, "D3DPERF_GetStatus", [], fail='0', sideeffects=False),
+])
+d3d9.addInterfaces([
+    IDirect3DSwapChain9Ex,
 ])
index 1c0188f969e63d35026803dbf920b5a12f7d75cf..b3582879a8a47108cae5a9ce8879e6291868addb 100644 (file)
@@ -75,16 +75,7 @@ D3DCAPS3 = Flags(DWORD, [
     "D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION",
     "D3DCAPS3_COPY_TO_VIDMEM",
     "D3DCAPS3_COPY_TO_SYSTEMMEM",
-])
-
-
-D3DPRESENT_INTERVAL = Flags(DWORD, [
-    #"D3DPRESENT_INTERVAL_DEFAULT", # 0
-    "D3DPRESENT_INTERVAL_ONE",
-    "D3DPRESENT_INTERVAL_TWO",
-    "D3DPRESENT_INTERVAL_THREE",
-    "D3DPRESENT_INTERVAL_FOUR",
-    "D3DPRESENT_INTERVAL_IMMEDIATE",
+    "D3DCAPS3_DXVAHD",
 ])
 
 D3DCURSORCAPS = Flags(DWORD, [
index 312eb2aaac63fa84160ddc8f10dfc05ebaea5d3f..279d6d3c08f21bd715643724f49af2b0727a5992 100644 (file)
@@ -296,7 +296,7 @@ D3DDEBUGMONITORTOKENS = Enum("D3DDEBUGMONITORTOKENS", [
 # TODO: Convert these to/from actual floats
 FLOAT_AS_DWORD = DWORD
 
-D3DRENDERSTATEVALUE = Polymorphic(DWORD, "State", [
+D3DRENDERSTATETYPE, D3DRENDERSTATEVALUE = EnumPolymorphic("D3DRENDERSTATETYPE", "State", [
     ("D3DRS_ZENABLE", D3DZBUFFERTYPE),
     ("D3DRS_FILLMODE", D3DFILLMODE),
     ("D3DRS_SHADEMODE", D3DSHADEMODE),
@@ -402,11 +402,7 @@ D3DRENDERSTATEVALUE = Polymorphic(DWORD, "State", [
     ("D3DRS_BLENDOPALPHA", D3DBLENDOP),
 
     # XXX: D3DRENDERSTATE_WRAPBIAS + n
-])
-
-D3DRENDERSTATETYPE = Enum("D3DRENDERSTATETYPE", [
-    expr for expr, types in D3DRENDERSTATEVALUE.switchTypes
-])
+], DWORD)
 
 D3DTSS_TCI = Flags(DWORD, [
     #"D3DTSS_TCI_PASSTHRU", # 0
@@ -468,7 +464,7 @@ D3DTEXTURETRANSFORMFLAGS = Enum("D3DTEXTURETRANSFORMFLAGS", [
 ])
 
 
-D3DTEXTURESTAGESTATEVALUE = Polymorphic(DWORD, "Type", [
+D3DTEXTURESTAGESTATETYPE, D3DTEXTURESTAGESTATEVALUE = EnumPolymorphic("D3DTEXTURESTAGESTATETYPE", "Type", [
     ("D3DTSS_COLOROP", D3DTEXTUREOP),
     ("D3DTSS_COLORARG1", D3DTA),
     ("D3DTSS_COLORARG2", D3DTA),
@@ -487,11 +483,7 @@ D3DTEXTURESTAGESTATEVALUE = Polymorphic(DWORD, "Type", [
     ("D3DTSS_ALPHAARG0", D3DTA,),
     ("D3DTSS_RESULTARG", D3DTA,),
     ("D3DTSS_CONSTANT", D3DCOLOR),
-])
-
-D3DTEXTURESTAGESTATETYPE = Enum("D3DTEXTURESTAGESTATETYPE", [
-    expr for expr, types in D3DTEXTURESTAGESTATEVALUE.switchTypes
-])
+], DWORD)
 
 D3DTEXTUREFILTERTYPE = Enum("D3DTEXTUREFILTERTYPE", [
     "D3DTEXF_NONE",
@@ -503,7 +495,7 @@ D3DTEXTUREFILTERTYPE = Enum("D3DTEXTUREFILTERTYPE", [
     "D3DTEXF_CONVOLUTIONMONO",
 ])
 
-D3DSAMPLERSTATEVALUE = Polymorphic(DWORD, "Type", [
+D3DSAMPLERSTATETYPE, D3DSAMPLERSTATEVALUE = EnumPolymorphic("D3DSAMPLERSTATETYPE", "Type", [
     ("D3DSAMP_ADDRESSU", D3DTEXTUREADDRESS),
     ("D3DSAMP_ADDRESSV", D3DTEXTUREADDRESS),
     ("D3DSAMP_ADDRESSW", D3DTEXTUREADDRESS),
@@ -517,11 +509,7 @@ D3DSAMPLERSTATEVALUE = Polymorphic(DWORD, "Type", [
     ("D3DSAMP_SRGBTEXTURE", BOOL),
     ("D3DSAMP_ELEMENTINDEX", DWORD),
     ("D3DSAMP_DMAPOFFSET", DWORD),
-])
-
-D3DSAMPLERSTATETYPE = Enum("D3DSAMPLERSTATETYPE", [
-    expr for expr, types in D3DSAMPLERSTATEVALUE.switchTypes
-])
+], DWORD)
 
 D3DPV = Flags(DWORD, [
     "D3DPV_DONOTCOPYDATA",
@@ -741,8 +729,8 @@ D3DFORMAT = Enum("D3DFORMAT", [
     "D3DFMT_BINARYBUFFER",
 
     # Unofficial formats
-    "D3DFMT_ATI1",
-    "D3DFMT_ATI2",
+    "D3DFMT_ATI1N",
+    "D3DFMT_ATI2N",
     "D3DFMT_AYUV",
     "D3DFMT_DF16",
     "D3DFMT_DF24",
@@ -759,11 +747,28 @@ D3DDISPLAYMODE = Struct("D3DDISPLAYMODE", [
     (D3DFORMAT, "Format"),
 ])
 
+D3DCREATE = Flags(DWORD, [
+    "D3DCREATE_FPU_PRESERVE",
+    "D3DCREATE_MULTITHREADED",
+    "D3DCREATE_PUREDEVICE",
+    "D3DCREATE_SOFTWARE_VERTEXPROCESSING",
+    "D3DCREATE_HARDWARE_VERTEXPROCESSING",
+    "D3DCREATE_MIXED_VERTEXPROCESSING",
+    "D3DCREATE_DISABLE_DRIVER_MANAGEMENT",
+    "D3DCREATE_ADAPTERGROUP_DEVICE",
+    "D3DCREATE_DISABLE_DRIVER_MANAGEMENT_EX",
+    "D3DCREATE_NOWINDOWCHANGES",
+    "D3DCREATE_DISABLE_PSGP_THREADING",
+    "D3DCREATE_ENABLE_PRESENTSTATS",
+    "D3DCREATE_DISABLE_PRINTSCREEN",
+    "D3DCREATE_SCREENSAVER",
+])
+
 D3DDEVICE_CREATION_PARAMETERS = Struct("D3DDEVICE_CREATION_PARAMETERS", [
     (UINT, "AdapterOrdinal"),
     (D3DDEVTYPE, "DeviceType"),
     (HWND, "hFocusWindow"),
-    (DWORD, "BehaviorFlags"),
+    (D3DCREATE, "BehaviorFlags"),
 ])
 
 D3DSWAPEFFECT = Enum("D3DSWAPEFFECT", [
@@ -783,6 +788,24 @@ D3DPRESENT = FakeEnum(DWORD, [
     "D3DPRESENT_RATE_DEFAULT",
 ])
 
+D3DPRESENTFLAG = Flags(DWORD, [
+    "D3DPRESENTFLAG_LOCKABLE_BACKBUFFER",
+    "D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL",
+    "D3DPRESENTFLAG_DEVICECLIP",
+    "D3DPRESENTFLAG_VIDEO",
+    "D3DPRESENTFLAG_NOAUTOROTATE",
+    "D3DPRESENTFLAG_UNPRUNEDMODE",
+])
+
+D3DPRESENT_INTERVAL = Flags(DWORD, [
+    "D3DPRESENT_INTERVAL_DEFAULT", # 0
+    "D3DPRESENT_INTERVAL_ONE",
+    "D3DPRESENT_INTERVAL_TWO",
+    "D3DPRESENT_INTERVAL_THREE",
+    "D3DPRESENT_INTERVAL_FOUR",
+    "D3DPRESENT_INTERVAL_IMMEDIATE",
+])
+
 D3DPRESENT_PARAMETERS = Struct("D3DPRESENT_PARAMETERS", [
     (UINT, "BackBufferWidth"),
     (UINT, "BackBufferHeight"),
@@ -795,18 +818,9 @@ D3DPRESENT_PARAMETERS = Struct("D3DPRESENT_PARAMETERS", [
     (BOOL, "Windowed"),
     (BOOL, "EnableAutoDepthStencil"),
     (D3DFORMAT, "AutoDepthStencilFormat"),
-    (DWORD, "Flags"),
+    (D3DPRESENTFLAG, "Flags"),
     (UINT, "FullScreen_RefreshRateInHz"),
-    (UINT, "PresentationInterval"),
-])
-
-D3DPRESENTFLAG = Flags(DWORD, [
-    "D3DPRESENTFLAG_LOCKABLE_BACKBUFFER",
-    "D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL",
-    "D3DPRESENTFLAG_DEVICECLIP",
-    "D3DPRESENTFLAG_VIDEO",
-    "D3DPRESENTFLAG_NOAUTOROTATE",
-    "D3DPRESENTFLAG_UNPRUNEDMODE",
+    (D3DPRESENT_INTERVAL, "PresentationInterval"),
 ])
 
 D3DGAMMARAMP = Struct("D3DGAMMARAMP", [
@@ -852,6 +866,9 @@ D3DUSAGE = Flags(DWORD, [
     "D3DUSAGE_RTPATCHES",
     "D3DUSAGE_NPATCHES",
     "D3DUSAGE_TEXTAPI",
+    "D3DUSAGE_RESTRICTED_CONTENT",
+    "D3DUSAGE_RESTRICT_SHARED_RESOURCE",
+    "D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER",
 ])
 
 D3DCUBEMAP_FACES = Enum("D3DCUBEMAP_FACES", [
@@ -912,7 +929,7 @@ D3DVOLUME_DESC = Struct("D3DVOLUME_DESC", [
 
 D3DLOCKED_RECT = Struct("D3DLOCKED_RECT", [
     (INT, "Pitch"),
-    (OpaquePointer(Void), "pBits"),
+    (LinearPointer(Void, "_LockedSize"), "pBits"),
 ])
 
 D3DBOX = Struct("D3DBOX", [
@@ -927,7 +944,7 @@ D3DBOX = Struct("D3DBOX", [
 D3DLOCKED_BOX = Struct("D3DLOCKED_BOX", [
     (INT, "RowPitch"),
     (INT, "SlicePitch"),
-    (OpaquePointer(Void), "pBits"),
+    (LinearPointer(Void, "_LockedSize"), "pBits"),
 ])
 
 D3DRANGE = Struct("D3DRANGE", [
diff --git a/specs/d3dcommon.py b/specs/d3dcommon.py
new file mode 100644 (file)
index 0000000..9486ba8
--- /dev/null
@@ -0,0 +1,701 @@
+##########################################################################
+#
+# Copyright 2012 Jose Fonseca
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from winapi import *
+
+
+D3D_DRIVER_TYPE = Enum('D3D_DRIVER_TYPE', [
+    'D3D_DRIVER_TYPE_UNKNOWN',
+    'D3D_DRIVER_TYPE_HARDWARE',
+    'D3D_DRIVER_TYPE_REFERENCE',
+    'D3D_DRIVER_TYPE_NULL',
+    'D3D_DRIVER_TYPE_SOFTWARE',
+    'D3D_DRIVER_TYPE_WARP',
+])
+
+D3D_FEATURE_LEVEL = Enum('D3D_FEATURE_LEVEL', [
+    'D3D_FEATURE_LEVEL_9_1',
+    'D3D_FEATURE_LEVEL_9_2',
+    'D3D_FEATURE_LEVEL_9_3',
+    'D3D_FEATURE_LEVEL_10_0',
+    'D3D_FEATURE_LEVEL_10_1',
+    'D3D_FEATURE_LEVEL_11_0',
+])
+
+D3D_PRIMITIVE_TOPOLOGY = Enum('D3D_PRIMITIVE_TOPOLOGY', [
+    'D3D_PRIMITIVE_TOPOLOGY_UNDEFINED',
+    'D3D_PRIMITIVE_TOPOLOGY_POINTLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_LINELIST',
+    'D3D_PRIMITIVE_TOPOLOGY_LINESTRIP',
+    'D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST',
+    'D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP',
+    'D3D_PRIMITIVE_TOPOLOGY_LINELIST_ADJ',
+    'D3D_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ',
+    'D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ',
+    'D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ',
+    'D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST',
+    'D3D_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST',
+])
+
+D3D10_PRIMITIVE_TOPOLOGY = Enum('D3D10_PRIMITIVE_TOPOLOGY', [
+    'D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED',
+    'D3D10_PRIMITIVE_TOPOLOGY_POINTLIST',
+    'D3D10_PRIMITIVE_TOPOLOGY_LINELIST',
+    'D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP',
+    'D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST',
+    'D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP',
+    'D3D10_PRIMITIVE_TOPOLOGY_LINELIST_ADJ',
+    'D3D10_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ',
+    'D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ',
+    'D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ',
+])
+
+D3D11_PRIMITIVE_TOPOLOGY = Enum('D3D11_PRIMITIVE_TOPOLOGY', [
+    'D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED',
+    'D3D11_PRIMITIVE_TOPOLOGY_POINTLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_LINELIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP',
+    'D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP',
+    'D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ',
+    'D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ',
+    'D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ',
+    'D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ',
+    'D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_2_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_5_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_6_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_7_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_8_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_9_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_10_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_11_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_13_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_14_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_15_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_16_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_17_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_18_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_19_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_20_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_21_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_22_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_23_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_24_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_25_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_26_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_27_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_28_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_29_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_30_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_31_CONTROL_POINT_PATCHLIST',
+    'D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST',
+])
+
+D3D_PRIMITIVE = Enum('D3D_PRIMITIVE', [
+    'D3D_PRIMITIVE_UNDEFINED',
+    'D3D_PRIMITIVE_POINT',
+    'D3D_PRIMITIVE_LINE',
+    'D3D_PRIMITIVE_TRIANGLE',
+    'D3D_PRIMITIVE_LINE_ADJ',
+    'D3D_PRIMITIVE_TRIANGLE_ADJ',
+    'D3D_PRIMITIVE_1_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_2_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_3_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_4_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_5_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_6_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_7_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_8_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_9_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_10_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_11_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_12_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_13_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_14_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_15_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_16_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_17_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_18_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_19_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_20_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_21_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_22_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_23_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_24_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_25_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_26_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_27_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_28_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_29_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_30_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_31_CONTROL_POINT_PATCH',
+    'D3D_PRIMITIVE_32_CONTROL_POINT_PATCH',
+])
+
+D3D10_PRIMITIVE = Enum('D3D10_PRIMITIVE', [
+    'D3D10_PRIMITIVE_UNDEFINED',
+    'D3D10_PRIMITIVE_POINT',
+    'D3D10_PRIMITIVE_LINE',
+    'D3D10_PRIMITIVE_TRIANGLE',
+    'D3D10_PRIMITIVE_LINE_ADJ',
+    'D3D10_PRIMITIVE_TRIANGLE_ADJ',
+])
+
+D3D11_PRIMITIVE = Enum('D3D11_PRIMITIVE', [
+    'D3D11_PRIMITIVE_UNDEFINED',
+    'D3D11_PRIMITIVE_POINT',
+    'D3D11_PRIMITIVE_LINE',
+    'D3D11_PRIMITIVE_TRIANGLE',
+    'D3D11_PRIMITIVE_LINE_ADJ',
+    'D3D11_PRIMITIVE_TRIANGLE_ADJ',
+    'D3D11_PRIMITIVE_1_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_2_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_3_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_4_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_5_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_6_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_7_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_8_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_9_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_10_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_11_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_12_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_13_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_14_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_15_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_16_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_17_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_18_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_19_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_20_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_21_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_22_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_23_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_24_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_25_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_26_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_27_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_28_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_29_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_30_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_31_CONTROL_POINT_PATCH',
+    'D3D11_PRIMITIVE_32_CONTROL_POINT_PATCH',
+])
+
+D3D_SRV_DIMENSION = Enum('D3D_SRV_DIMENSION', [
+    'D3D_SRV_DIMENSION_UNKNOWN',
+    'D3D_SRV_DIMENSION_BUFFER',
+    'D3D_SRV_DIMENSION_TEXTURE1D',
+    'D3D_SRV_DIMENSION_TEXTURE1DARRAY',
+    'D3D_SRV_DIMENSION_TEXTURE2D',
+    'D3D_SRV_DIMENSION_TEXTURE2DARRAY',
+    'D3D_SRV_DIMENSION_TEXTURE2DMS',
+    'D3D_SRV_DIMENSION_TEXTURE2DMSARRAY',
+    'D3D_SRV_DIMENSION_TEXTURE3D',
+    'D3D_SRV_DIMENSION_TEXTURECUBE',
+    'D3D_SRV_DIMENSION_TEXTURECUBEARRAY',
+    'D3D_SRV_DIMENSION_BUFFEREX',
+])
+
+D3D10_SRV_DIMENSION = Enum('D3D10_SRV_DIMENSION', [
+    'D3D10_SRV_DIMENSION_UNKNOWN',
+    'D3D10_SRV_DIMENSION_BUFFER',
+    'D3D10_SRV_DIMENSION_TEXTURE1D',
+    'D3D10_SRV_DIMENSION_TEXTURE1DARRAY',
+    'D3D10_SRV_DIMENSION_TEXTURE2D',
+    'D3D10_SRV_DIMENSION_TEXTURE2DARRAY',
+    'D3D10_SRV_DIMENSION_TEXTURE2DMS',
+    'D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY',
+    'D3D10_SRV_DIMENSION_TEXTURE3D',
+    'D3D10_SRV_DIMENSION_TEXTURECUBE',
+])
+
+D3D10_SRV_DIMENSION1 = Enum('D3D10_SRV_DIMENSION1', [
+    'D3D10_1_SRV_DIMENSION_UNKNOWN',
+    'D3D10_1_SRV_DIMENSION_BUFFER',
+    'D3D10_1_SRV_DIMENSION_TEXTURE1D',
+    'D3D10_1_SRV_DIMENSION_TEXTURE1DARRAY',
+    'D3D10_1_SRV_DIMENSION_TEXTURE2D',
+    'D3D10_1_SRV_DIMENSION_TEXTURE2DARRAY',
+    'D3D10_1_SRV_DIMENSION_TEXTURE2DMS',
+    'D3D10_1_SRV_DIMENSION_TEXTURE2DMSARRAY',
+    'D3D10_1_SRV_DIMENSION_TEXTURE3D',
+    'D3D10_1_SRV_DIMENSION_TEXTURECUBE',
+    'D3D10_1_SRV_DIMENSION_TEXTURECUBEARRAY',
+])
+
+D3D11_SRV_DIMENSION = Enum('D3D11_SRV_DIMENSION', [
+    'D3D11_SRV_DIMENSION_UNKNOWN',
+    'D3D11_SRV_DIMENSION_BUFFER',
+    'D3D11_SRV_DIMENSION_TEXTURE1D',
+    'D3D11_SRV_DIMENSION_TEXTURE1DARRAY',
+    'D3D11_SRV_DIMENSION_TEXTURE2D',
+    'D3D11_SRV_DIMENSION_TEXTURE2DARRAY',
+    'D3D11_SRV_DIMENSION_TEXTURE2DMS',
+    'D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY',
+    'D3D11_SRV_DIMENSION_TEXTURE3D',
+    'D3D11_SRV_DIMENSION_TEXTURECUBE',
+    'D3D11_SRV_DIMENSION_TEXTURECUBEARRAY',
+    'D3D11_SRV_DIMENSION_BUFFEREX',
+])
+
+D3D10_SHADER_MACRO = Struct('D3D10_SHADER_MACRO', [
+    (LPCSTR, 'Name'),
+    (LPCSTR, 'Definition'),
+])
+
+ID3D10Blob = Interface('ID3D10Blob', IUnknown)
+ID3D10Blob.methods += [
+    StdMethod(LPVOID, 'GetBufferPointer', [], sideeffects=False),
+    StdMethod(SIZE_T, 'GetBufferSize', [], sideeffects=False),
+]
+LPD3D10BLOB = ObjPointer(ID3D10Blob)
+
+D3D_INCLUDE_TYPE = Enum('D3D_INCLUDE_TYPE', [
+    'D3D_INCLUDE_LOCAL',
+    'D3D_INCLUDE_SYSTEM',
+])
+
+D3D10_INCLUDE_TYPE = Enum('D3D10_INCLUDE_TYPE', [
+    'D3D10_INCLUDE_LOCAL',
+    'D3D10_INCLUDE_SYSTEM',
+])
+
+ID3D10Include = Interface("ID3D10Include", IUnknown)
+ID3D10Include.methods += [
+    StdMethod(HRESULT, "Open", [(D3D10_INCLUDE_TYPE, "IncludeType"), (LPCSTR, "pFileName"), (LPCVOID, "pParentData"), Out(Pointer(LPCVOID), "ppData"), Out(Pointer(UINT), "pBytes")]),
+    StdMethod(HRESULT, "Close", [(LPCVOID, "pData")]),
+]
+# It is implemented by applications, not D3D runtime, so treat as opaque for
+# now.
+LPD3D10INCLUDE = OpaquePointer(ID3D10Include)
+
+D3D_SHADER_VARIABLE_CLASS = Enum('D3D_SHADER_VARIABLE_CLASS', [
+    'D3D_SVC_SCALAR',
+    'D3D_SVC_VECTOR',
+    'D3D_SVC_MATRIX_ROWS',
+    'D3D_SVC_MATRIX_COLUMNS',
+    'D3D_SVC_OBJECT',
+    'D3D_SVC_STRUCT',
+    'D3D_SVC_INTERFACE_CLASS',
+    'D3D_SVC_INTERFACE_POINTER',
+])
+
+D3D10_SHADER_VARIABLE_CLASS = Enum('D3D_SHADER_VARIABLE_CLASS', [
+    'D3D10_SVC_SCALAR',
+    'D3D10_SVC_VECTOR',
+    'D3D10_SVC_MATRIX_ROWS',
+    'D3D10_SVC_MATRIX_COLUMNS',
+    'D3D10_SVC_OBJECT',
+    'D3D10_SVC_STRUCT',
+])
+
+D3D11_SHADER_VARIABLE_CLASS = Enum('D3D_SHADER_VARIABLE_CLASS', [
+    'D3D11_SVC_INTERFACE_CLASS',
+    'D3D11_SVC_INTERFACE_POINTER',
+])
+
+D3D10_SHADER_VARIABLE_FLAGS = Enum('D3D10_SHADER_VARIABLE_FLAGS', [
+    'D3D_SVF_USERPACKED',
+    'D3D_SVF_USED',
+    'D3D_SVF_INTERFACE_POINTER',
+    'D3D_SVF_INTERFACE_PARAMETER',
+])
+
+D3D11_SHADER_VARIABLE_FLAGS = Enum('D3D11_SHADER_VARIABLE_FLAGS', [
+    'D3D10_SVF_USERPACKED',
+    'D3D10_SVF_USED',
+    'D3D11_SVF_INTERFACE_POINTER',
+    'D3D11_SVF_INTERFACE_PARAMETER',
+])
+
+D3D_SHADER_VARIABLE_TYPE = Enum('D3D_SHADER_VARIABLE_TYPE', [
+    'D3D_SVT_VOID',
+    'D3D_SVT_BOOL',
+    'D3D_SVT_INT',
+    'D3D_SVT_FLOAT',
+    'D3D_SVT_STRING',
+    'D3D_SVT_TEXTURE',
+    'D3D_SVT_TEXTURE1D',
+    'D3D_SVT_TEXTURE2D',
+    'D3D_SVT_TEXTURE3D',
+    'D3D_SVT_TEXTURECUBE',
+    'D3D_SVT_SAMPLER',
+    'D3D_SVT_SAMPLER1D',
+    'D3D_SVT_SAMPLER2D',
+    'D3D_SVT_SAMPLER3D',
+    'D3D_SVT_SAMPLERCUBE',
+    'D3D_SVT_PIXELSHADER',
+    'D3D_SVT_VERTEXSHADER',
+    'D3D_SVT_PIXELFRAGMENT',
+    'D3D_SVT_VERTEXFRAGMENT',
+    'D3D_SVT_UINT',
+    'D3D_SVT_UINT8',
+    'D3D_SVT_GEOMETRYSHADER',
+    'D3D_SVT_RASTERIZER',
+    'D3D_SVT_DEPTHSTENCIL',
+    'D3D_SVT_BLEND',
+    'D3D_SVT_BUFFER',
+    'D3D_SVT_CBUFFER',
+    'D3D_SVT_TBUFFER',
+    'D3D_SVT_TEXTURE1DARRAY',
+    'D3D_SVT_TEXTURE2DARRAY',
+    'D3D_SVT_RENDERTARGETVIEW',
+    'D3D_SVT_DEPTHSTENCILVIEW',
+    'D3D_SVT_TEXTURE2DMS',
+    'D3D_SVT_TEXTURE2DMSARRAY',
+    'D3D_SVT_TEXTURECUBEARRAY',
+    'D3D_SVT_HULLSHADER',
+    'D3D_SVT_DOMAINSHADER',
+    'D3D_SVT_INTERFACE_POINTER',
+    'D3D_SVT_COMPUTESHADER',
+    'D3D_SVT_DOUBLE',
+    'D3D_SVT_RWTEXTURE1D',
+    'D3D_SVT_RWTEXTURE1DARRAY',
+    'D3D_SVT_RWTEXTURE2D',
+    'D3D_SVT_RWTEXTURE2DARRAY',
+    'D3D_SVT_RWTEXTURE3D',
+    'D3D_SVT_RWBUFFER',
+    'D3D_SVT_BYTEADDRESS_BUFFER',
+    'D3D_SVT_RWBYTEADDRESS_BUFFER',
+    'D3D_SVT_STRUCTURED_BUFFER',
+    'D3D_SVT_RWSTRUCTURED_BUFFER',
+    'D3D_SVT_APPEND_STRUCTURED_BUFFER',
+    'D3D_SVT_CONSUME_STRUCTURED_BUFFER',
+])
+
+D3D10_SHADER_VARIABLE_TYPE = Enum('D3D10_SHADER_VARIABLE_TYPE', [
+    'D3D10_SVT_VOID',
+    'D3D10_SVT_BOOL',
+    'D3D10_SVT_INT',
+    'D3D10_SVT_FLOAT',
+    'D3D10_SVT_STRING',
+    'D3D10_SVT_TEXTURE',
+    'D3D10_SVT_TEXTURE1D',
+    'D3D10_SVT_TEXTURE2D',
+    'D3D10_SVT_TEXTURE3D',
+    'D3D10_SVT_TEXTURECUBE',
+    'D3D10_SVT_SAMPLER',
+    'D3D10_SVT_SAMPLER1D',
+    'D3D10_SVT_SAMPLER2D',
+    'D3D10_SVT_SAMPLER3D',
+    'D3D10_SVT_SAMPLERCUBE',
+    'D3D10_SVT_PIXELSHADER',
+    'D3D10_SVT_VERTEXSHADER',
+    'D3D10_SVT_PIXELFRAGMENT',
+    'D3D10_SVT_VERTEXFRAGMENT',
+    'D3D10_SVT_UINT',
+    'D3D10_SVT_UINT8',
+    'D3D10_SVT_GEOMETRYSHADER',
+    'D3D10_SVT_RASTERIZER',
+    'D3D10_SVT_DEPTHSTENCIL',
+    'D3D10_SVT_BLEND',
+    'D3D10_SVT_BUFFER',
+    'D3D10_SVT_CBUFFER',
+    'D3D10_SVT_TBUFFER',
+    'D3D10_SVT_TEXTURE1DARRAY',
+    'D3D10_SVT_TEXTURE2DARRAY',
+    'D3D10_SVT_RENDERTARGETVIEW',
+    'D3D10_SVT_DEPTHSTENCILVIEW',
+    'D3D10_SVT_TEXTURE2DMS',
+    'D3D10_SVT_TEXTURE2DMSARRAY',
+    'D3D10_SVT_TEXTURECUBEARRAY',
+])
+
+D3D11_SHADER_VARIABLE_TYPE = Enum('D3D11_SHADER_VARIABLE_TYPE', [
+    'D3D11_SVT_HULLSHADER',
+    'D3D11_SVT_DOMAINSHADER',
+    'D3D11_SVT_INTERFACE_POINTER',
+    'D3D11_SVT_COMPUTESHADER',
+    'D3D11_SVT_DOUBLE',
+    'D3D11_SVT_RWTEXTURE1D',
+    'D3D11_SVT_RWTEXTURE1DARRAY',
+    'D3D11_SVT_RWTEXTURE2D',
+    'D3D11_SVT_RWTEXTURE2DARRAY',
+    'D3D11_SVT_RWTEXTURE3D',
+    'D3D11_SVT_RWBUFFER',
+    'D3D11_SVT_BYTEADDRESS_BUFFER',
+    'D3D11_SVT_RWBYTEADDRESS_BUFFER',
+    'D3D11_SVT_STRUCTURED_BUFFER',
+    'D3D11_SVT_RWSTRUCTURED_BUFFER',
+    'D3D11_SVT_APPEND_STRUCTURED_BUFFER',
+    'D3D11_SVT_CONSUME_STRUCTURED_BUFFER',
+])
+
+D3D_SHADER_INPUT_FLAGS = Enum('D3D_SHADER_INPUT_FLAGS', [
+    'D3D_SIF_USERPACKED',
+    'D3D_SIF_COMPARISON_SAMPLER',
+    'D3D_SIF_TEXTURE_COMPONENT_0',
+    'D3D_SIF_TEXTURE_COMPONENT_1',
+    'D3D_SIF_TEXTURE_COMPONENTS',
+])
+
+D3D10_SHADER_INPUT_FLAGS = Enum('D3D10_SHADER_INPUT_FLAGS', [
+    'D3D10_SIF_USERPACKED',
+    'D3D10_SIF_COMPARISON_SAMPLER',
+    'D3D10_SIF_TEXTURE_COMPONENT_0',
+    'D3D10_SIF_TEXTURE_COMPONENT_1',
+    'D3D10_SIF_TEXTURE_COMPONENTS',
+])
+
+D3D_SHADER_INPUT_TYPE = Enum('D3D_SHADER_INPUT_TYPE', [
+    'D3D_SIT_CBUFFER',
+    'D3D_SIT_TBUFFER',
+    'D3D_SIT_TEXTURE',
+    'D3D_SIT_SAMPLER',
+    'D3D_SIT_UAV_RWTYPED',
+    'D3D_SIT_STRUCTURED',
+    'D3D_SIT_UAV_RWSTRUCTURED',
+    'D3D_SIT_BYTEADDRESS',
+    'D3D_SIT_UAV_RWBYTEADDRESS',
+    'D3D_SIT_UAV_APPEND_STRUCTURED',
+    'D3D_SIT_UAV_CONSUME_STRUCTURED',
+    'D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER',
+])
+
+D3D10_SHADER_INPUT_TYPE = Enum('D3D10_SHADER_INPUT_TYPE', [
+    'D3D10_SIT_CBUFFER',
+    'D3D10_SIT_TBUFFER',
+    'D3D10_SIT_TEXTURE',
+    'D3D10_SIT_SAMPLER',
+])
+
+D3D11_SHADER_INPUT_TYPE = Enum('D3D11_SHADER_INPUT_TYPE', [
+    'D3D11_SIT_UAV_RWTYPED',
+    'D3D11_SIT_STRUCTURED',
+    'D3D11_SIT_UAV_RWSTRUCTURED',
+    'D3D11_SIT_BYTEADDRESS',
+    'D3D11_SIT_UAV_RWBYTEADDRESS',
+    'D3D11_SIT_UAV_APPEND_STRUCTURED',
+    'D3D11_SIT_UAV_CONSUME_STRUCTURED',
+    'D3D11_SIT_UAV_RWSTRUCTURED_WITH_COUNTER',
+])
+
+D3D_SHADER_CBUFFER_FLAGS = Enum('D3D_SHADER_CBUFFER_FLAGS', [
+    'D3D_CBF_USERPACKED',
+])
+
+D3D10_SHADER_CBUFFER_FLAGS = Enum('D3D10_SHADER_CBUFFER_FLAGS', [
+    'D3D10_CBF_USERPACKED',
+])
+
+D3D_CBUFFER_TYPE = Enum('D3D_CBUFFER_TYPE', [
+    'D3D_CT_CBUFFER',
+    'D3D_CT_TBUFFER',
+    'D3D_CT_INTERFACE_POINTERS',
+    'D3D_CT_RESOURCE_BIND_INFO',
+])
+
+D3D10_CBUFFER_TYPE = Enum('D3D10_CBUFFER_TYPE', [
+    'D3D10_CT_CBUFFER',
+    'D3D10_CT_TBUFFER',
+])
+
+D3D11_CBUFFER_TYPE = Enum('D3D11_CBUFFER_TYPE', [
+    'D3D11_CT_CBUFFER',
+    'D3D11_CT_TBUFFER',
+    'D3D11_CT_INTERFACE_POINTERS',
+    'D3D11_CT_RESOURCE_BIND_INFO',
+])
+
+D3D_NAME = Enum('D3D_NAME', [
+    'D3D_NAME_UNDEFINED',
+    'D3D_NAME_POSITION',
+    'D3D_NAME_CLIP_DISTANCE',
+    'D3D_NAME_CULL_DISTANCE',
+    'D3D_NAME_RENDER_TARGET_ARRAY_INDEX',
+    'D3D_NAME_VIEWPORT_ARRAY_INDEX',
+    'D3D_NAME_VERTEX_ID',
+    'D3D_NAME_PRIMITIVE_ID',
+    'D3D_NAME_INSTANCE_ID',
+    'D3D_NAME_IS_FRONT_FACE',
+    'D3D_NAME_SAMPLE_INDEX',
+    'D3D_NAME_FINAL_QUAD_EDGE_TESSFACTOR',
+    'D3D_NAME_FINAL_QUAD_INSIDE_TESSFACTOR',
+    'D3D_NAME_FINAL_TRI_EDGE_TESSFACTOR',
+    'D3D_NAME_FINAL_TRI_INSIDE_TESSFACTOR',
+    'D3D_NAME_FINAL_LINE_DETAIL_TESSFACTOR',
+    'D3D_NAME_FINAL_LINE_DENSITY_TESSFACTOR',
+    'D3D_NAME_TARGET',
+    'D3D_NAME_DEPTH',
+    'D3D_NAME_COVERAGE',
+    'D3D_NAME_DEPTH_GREATER_EQUAL',
+    'D3D_NAME_DEPTH_LESS_EQUAL',
+])
+
+D3D10_NAME = Enum('D3D10_NAME', [
+    'D3D10_NAME_UNDEFINED',
+    'D3D10_NAME_POSITION',
+    'D3D10_NAME_CLIP_DISTANCE',
+    'D3D10_NAME_CULL_DISTANCE',
+    'D3D10_NAME_RENDER_TARGET_ARRAY_INDEX',
+    'D3D10_NAME_VIEWPORT_ARRAY_INDEX',
+    'D3D10_NAME_VERTEX_ID',
+    'D3D10_NAME_PRIMITIVE_ID',
+    'D3D10_NAME_INSTANCE_ID',
+    'D3D10_NAME_IS_FRONT_FACE',
+    'D3D10_NAME_SAMPLE_INDEX',
+    'D3D10_NAME_TARGET',
+    'D3D10_NAME_DEPTH',
+    'D3D10_NAME_COVERAGE',
+])
+
+D3D11_NAME = Enum('D3D11_NAME', [
+    'D3D11_NAME_FINAL_QUAD_EDGE_TESSFACTOR',
+    'D3D11_NAME_FINAL_QUAD_INSIDE_TESSFACTOR',
+    'D3D11_NAME_FINAL_TRI_EDGE_TESSFACTOR',
+    'D3D11_NAME_FINAL_TRI_INSIDE_TESSFACTOR',
+    'D3D11_NAME_FINAL_LINE_DETAIL_TESSFACTOR',
+    'D3D11_NAME_FINAL_LINE_DENSITY_TESSFACTOR',
+    'D3D11_NAME_DEPTH_GREATER_EQUAL',
+    'D3D11_NAME_DEPTH_LESS_EQUAL',
+])
+
+D3D_RESOURCE_RETURN_TYPE = Enum('D3D_RESOURCE_RETURN_TYPE', [
+    'D3D_RETURN_TYPE_UNORM',
+    'D3D_RETURN_TYPE_SNORM',
+    'D3D_RETURN_TYPE_SINT',
+    'D3D_RETURN_TYPE_UINT',
+    'D3D_RETURN_TYPE_FLOAT',
+    'D3D_RETURN_TYPE_MIXED',
+    'D3D_RETURN_TYPE_DOUBLE',
+    'D3D_RETURN_TYPE_CONTINUED',
+])
+
+D3D10_RESOURCE_RETURN_TYPE = Enum('D3D10_RESOURCE_RETURN_TYPE', [
+    'D3D10_RETURN_TYPE_UNORM',
+    'D3D10_RETURN_TYPE_SNORM',
+    'D3D10_RETURN_TYPE_SINT',
+    'D3D10_RETURN_TYPE_UINT',
+    'D3D10_RETURN_TYPE_FLOAT',
+    'D3D10_RETURN_TYPE_MIXED',
+])
+
+D3D11_RESOURCE_RETURN_TYPE = Enum('D3D11_RESOURCE_RETURN_TYPE', [
+    'D3D11_RETURN_TYPE_UNORM',
+    'D3D11_RETURN_TYPE_SNORM',
+    'D3D11_RETURN_TYPE_SINT',
+    'D3D11_RETURN_TYPE_UINT',
+    'D3D11_RETURN_TYPE_FLOAT',
+    'D3D11_RETURN_TYPE_MIXED',
+    'D3D11_RETURN_TYPE_DOUBLE',
+    'D3D11_RETURN_TYPE_CONTINUED',
+])
+
+D3D_REGISTER_COMPONENT_TYPE = Enum('D3D_REGISTER_COMPONENT_TYPE', [
+    'D3D_REGISTER_COMPONENT_UNKNOWN',
+    'D3D_REGISTER_COMPONENT_UINT32',
+    'D3D_REGISTER_COMPONENT_SINT32',
+    'D3D_REGISTER_COMPONENT_FLOAT32',
+])
+
+D3D10_REGISTER_COMPONENT_TYPE = Enum('D3D10_REGISTER_COMPONENT_TYPE', [
+    'D3D10_REGISTER_COMPONENT_UNKNOWN',
+    'D3D10_REGISTER_COMPONENT_UINT32',
+    'D3D10_REGISTER_COMPONENT_SINT32',
+    'D3D10_REGISTER_COMPONENT_FLOAT32',
+])
+
+D3D_TESSELLATOR_DOMAIN = Enum('D3D_TESSELLATOR_DOMAIN', [
+    'D3D_TESSELLATOR_DOMAIN_UNDEFINED',
+    'D3D_TESSELLATOR_DOMAIN_ISOLINE',
+    'D3D_TESSELLATOR_DOMAIN_TRI',
+    'D3D_TESSELLATOR_DOMAIN_QUAD',
+])
+
+D3D11_TESSELLATOR_DOMAIN = Enum('D3D11_TESSELLATOR_DOMAIN', [
+    'D3D11_TESSELLATOR_DOMAIN_UNDEFINED',
+    'D3D11_TESSELLATOR_DOMAIN_ISOLINE',
+    'D3D11_TESSELLATOR_DOMAIN_TRI',
+    'D3D11_TESSELLATOR_DOMAIN_QUAD',
+])
+
+D3D_TESSELLATOR_PARTITIONING = Enum('D3D_TESSELLATOR_PARTITIONING', [
+    'D3D_TESSELLATOR_PARTITIONING_UNDEFINED',
+    'D3D_TESSELLATOR_PARTITIONING_INTEGER',
+    'D3D_TESSELLATOR_PARTITIONING_POW2',
+    'D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD',
+    'D3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN',
+])
+
+D3D11_TESSELLATOR_PARTITIONING = Enum('D3D11_TESSELLATOR_PARTITIONING', [
+    'D3D11_TESSELLATOR_PARTITIONING_UNDEFINED',
+    'D3D11_TESSELLATOR_PARTITIONING_INTEGER',
+    'D3D11_TESSELLATOR_PARTITIONING_POW2',
+    'D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD',
+    'D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN',
+])
+
+D3D_TESSELLATOR_OUTPUT_PRIMITIVE = Enum('D3D_TESSELLATOR_OUTPUT_PRIMITIVE', [
+    'D3D_TESSELLATOR_OUTPUT_UNDEFINED',
+    'D3D_TESSELLATOR_OUTPUT_POINT',
+    'D3D_TESSELLATOR_OUTPUT_LINE',
+    'D3D_TESSELLATOR_OUTPUT_TRIANGLE_CW',
+    'D3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW',
+])
+
+D3D11_TESSELLATOR_OUTPUT_PRIMITIVE = Enum('D3D11_TESSELLATOR_OUTPUT_PRIMITIVE', [
+    'D3D11_TESSELLATOR_OUTPUT_UNDEFINED',
+    'D3D11_TESSELLATOR_OUTPUT_POINT',
+    'D3D11_TESSELLATOR_OUTPUT_LINE',
+    'D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CW',
+    'D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CCW',
+])
+
diff --git a/specs/ddraw.def b/specs/ddraw.def
deleted file mode 100644 (file)
index 6186c60..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-EXPORTS
-        AcquireDDThreadLock
-        CompleteCreateSysmemSurface
-        D3DParseUnknownCommand
-        DDGetAttachedSurfaceLcl
-        DDInternalLock
-        DDInternalUnlock
-        DirectDrawCreate
-        DirectDrawCreateClipper
-        DirectDrawCreateEx
-        DirectDrawEnumerateA
-        DirectDrawEnumerateExA
-        DirectDrawEnumerateExW
-        DirectDrawEnumerateW
-        DllCanUnloadNow PRIVATE
-        DllGetClassObject PRIVATE
-        DSoundHelp
-        GetDDSurfaceLocal
-        GetOLEThunkData
-        GetSurfaceFromDC
-        RegisterSpecialCase
-        ReleaseDDThreadLock
-        ;SetAppCompatData
index 37031c4f52d6b24bc967d65e0af0e835e9e526c9..aed2b0d958198cb7c0f0e7c436a418dc0a17a5b4 100644 (file)
@@ -59,19 +59,20 @@ IDirectDrawSurface7 = Interface("IDirectDrawSurface7", IUnknown)
 IDirectDrawColorControl = Interface("IDirectDrawColorControl", IUnknown)
 IDirectDrawGammaControl = Interface("IDirectDrawGammaControl", IUnknown)
 
-LPDIRECTDRAW = Pointer(IDirectDraw)
-LPDIRECTDRAW2 = Pointer(IDirectDraw2)
-LPDIRECTDRAW4 = Pointer(IDirectDraw4)
-LPDIRECTDRAW7 = Pointer(IDirectDraw7)
-LPDIRECTDRAWSURFACE = Pointer(IDirectDrawSurface)
-LPDIRECTDRAWSURFACE2 = Pointer(IDirectDrawSurface2)
-LPDIRECTDRAWSURFACE3 = Pointer(IDirectDrawSurface3)
-LPDIRECTDRAWSURFACE4 = Pointer(IDirectDrawSurface4)
-LPDIRECTDRAWSURFACE7 = Pointer(IDirectDrawSurface7)
-LPDIRECTDRAWPALETTE = Pointer(IDirectDrawPalette)
-LPDIRECTDRAWCLIPPER = Pointer(IDirectDrawClipper)
-LPDIRECTDRAWCOLORCONTROL = Pointer(IDirectDrawColorControl)
-LPDIRECTDRAWGAMMACONTROL = Pointer(IDirectDrawGammaControl)
+LPUNKNOWN = ObjPointer(IUnknown)
+LPDIRECTDRAW = ObjPointer(IDirectDraw)
+LPDIRECTDRAW2 = ObjPointer(IDirectDraw2)
+LPDIRECTDRAW4 = ObjPointer(IDirectDraw4)
+LPDIRECTDRAW7 = ObjPointer(IDirectDraw7)
+LPDIRECTDRAWSURFACE = ObjPointer(IDirectDrawSurface)
+LPDIRECTDRAWSURFACE2 = ObjPointer(IDirectDrawSurface2)
+LPDIRECTDRAWSURFACE3 = ObjPointer(IDirectDrawSurface3)
+LPDIRECTDRAWSURFACE4 = ObjPointer(IDirectDrawSurface4)
+LPDIRECTDRAWSURFACE7 = ObjPointer(IDirectDrawSurface7)
+LPDIRECTDRAWPALETTE = ObjPointer(IDirectDrawPalette)
+LPDIRECTDRAWCLIPPER = ObjPointer(IDirectDrawClipper)
+LPDIRECTDRAWCOLORCONTROL = ObjPointer(IDirectDrawColorControl)
+LPDIRECTDRAWGAMMACONTROL = ObjPointer(IDirectDrawGammaControl)
 
 DDARGB = Struct("DDARGB", [
     (BYTE, "blue"),
@@ -1146,9 +1147,7 @@ DirectDrawEvaluateModeFlags = Flags(DWORD, [
     "DDEM_MODEFAILED",
 ])
 
-DDRESULT = FakeEnum(HRESULT, [
-    "DD_OK",
-    "DD_FALSE",
+DDRESULT = MAKE_HRESULT(ok = "DD_OK", false = "DD_FALSE", errors = [
     "DDERR_ALREADYINITIALIZED",
     "DDERR_CANNOTATTACHSURFACE",
     "DDERR_CANNOTDETACHSURFACE",
@@ -1278,9 +1277,9 @@ LPDDENUMSURFACESCALLBACK7 = FunctionPointer(HRESULT, "LPDDENUMSURFACESCALLBACK7"
 
 IDirectDraw.methods += [
     Method(DDRESULT, "Compact", []),
-    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE), "lplpDDSurface"), (Pointer(IUnknown), "pUnkOuter")]),
+    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (LPUNKNOWN, "pUnkOuter")]),
+    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (ObjPointer(IUnknown), "pUnkOuter")]),
+    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE), "lplpDDSurface"), (LPUNKNOWN, "pUnkOuter")]),
     Method(DDRESULT, "DuplicateSurface", [(LPDIRECTDRAWSURFACE, "lpDDSurface"), Out(Pointer(LPDIRECTDRAWSURFACE), "lplpDupDDSurface")]),
     Method(DDRESULT, "EnumDisplayModes", [(DirectDrawEnumDisplayModesFlags, "dwFlags"), (LPDDSURFACEDESC, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMMODESCALLBACK, "lpEnumModesCallback")]),
     Method(DDRESULT, "EnumSurfaces", [(DirectDrawEnumSurfacesFlags, "dwFlags"), (LPDDSURFACEDESC, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMSURFACESCALLBACK, "lpEnumSurfacesCallback")]),
@@ -1301,9 +1300,9 @@ IDirectDraw.methods += [
 
 IDirectDraw2.methods += [
     Method(DDRESULT, "Compact", []),
-    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE), "lplpDDSurface"), (Pointer(IUnknown), "pUnkOuter")]),
+    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (LPUNKNOWN, "pUnkOuter")]),
+    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (LPUNKNOWN, "pUnkOuter")]),
+    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE), "lplpDDSurface"), (LPUNKNOWN, "pUnkOuter")]),
     Method(DDRESULT, "DuplicateSurface", [(LPDIRECTDRAWSURFACE, "lpDDSurface"), Out(Pointer(LPDIRECTDRAWSURFACE), "lplpDupDDSurface")]),
     Method(DDRESULT, "EnumDisplayModes", [(DirectDrawEnumDisplayModesFlags, "dwFlags"), (LPDDSURFACEDESC, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMMODESCALLBACK, "lpEnumModesCallback")]),
     Method(DDRESULT, "EnumSurfaces", [(DirectDrawEnumSurfacesFlags, "dwFlags"), (LPDDSURFACEDESC, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMSURFACESCALLBACK, "lpEnumSurfacesCallback")]),
@@ -1325,9 +1324,9 @@ IDirectDraw2.methods += [
 
 IDirectDraw4.methods += [
     Method(DDRESULT, "Compact", []),
-    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC2, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE4), "lplpDDSurface"), (Pointer(IUnknown), "pUnkOuter")]),
+    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (LPUNKNOWN, "pUnkOuter")]),
+    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (ObjPointer(IUnknown), "pUnkOuter")]),
+    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC2, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE4), "lplpDDSurface"), (LPUNKNOWN, "pUnkOuter")]),
     Method(DDRESULT, "DuplicateSurface", [(LPDIRECTDRAWSURFACE4, "lpDDSurface"), Out(Pointer(LPDIRECTDRAWSURFACE4), "lplpDupDDSurface")]),
     Method(DDRESULT, "EnumDisplayModes", [(DirectDrawEnumDisplayModesFlags, "dwFlags"), (LPDDSURFACEDESC2, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMMODESCALLBACK2, "lpEnumModesCallback")]),
     Method(DDRESULT, "EnumSurfaces", [(DirectDrawEnumSurfacesFlags, "dwFlags"), (LPDDSURFACEDESC2, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMSURFACESCALLBACK2, "lpEnumSurfacesCallback")]),
@@ -1353,9 +1352,9 @@ IDirectDraw4.methods += [
 
 IDirectDraw7.methods += [
     Method(DDRESULT, "Compact", []),
-    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (Pointer(IUnknown), "pUnkOuter")]),
-    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC2, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE7), "lplpDDSurface"), (Pointer(IUnknown), "pUnkOuter")]),
+    Method(DDRESULT, "CreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (LPUNKNOWN, "pUnkOuter")]),
+    Method(DDRESULT, "CreatePalette", [(DirectDrawPaletteCapsFlags, "dwFlags"), (LPPALETTEENTRY, "lpDDColorArray"), Out(Pointer(LPDIRECTDRAWPALETTE), "lplpDDPalette"), (LPUNKNOWN, "pUnkOuter")]),
+    Method(DDRESULT, "CreateSurface", [(LPDDSURFACEDESC2, "lpDDSurfaceDesc"), Out(Pointer(LPDIRECTDRAWSURFACE7), "lplpDDSurface"), (LPUNKNOWN, "pUnkOuter")]),
     Method(DDRESULT, "DuplicateSurface", [(LPDIRECTDRAWSURFACE7, "lpDDSurface"), Out(Pointer(LPDIRECTDRAWSURFACE7), "lplpDupDDSurface")]),
     Method(DDRESULT, "EnumDisplayModes", [(DirectDrawEnumDisplayModesFlags, "dwFlags"), (LPDDSURFACEDESC2, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMMODESCALLBACK2, "lpEnumModesCallback")]),
     Method(DDRESULT, "EnumSurfaces", [(DirectDrawEnumSurfacesFlags, "dwFlags"), (LPDDSURFACEDESC2, "lpDDSurfaceDesc"), (LPVOID, "lpContext"), (LPDDENUMSURFACESCALLBACK7, "lpEnumSurfacesCallback")]),
@@ -1468,7 +1467,7 @@ IDirectDrawSurface2.methods += [
     Method(DDRESULT, "UpdateOverlay", [(LPRECT, "lpSrcRect"), (LPDIRECTDRAWSURFACE2, "lpDDDestSurface"), (LPRECT, "lpDestRect"), (DirectDrawSurfaceOverlayFlags, "dwFlags"), (LPDDOVERLAYFX, "lpDDOverlayFx")]),
     Method(DDRESULT, "UpdateOverlayDisplay", [(DWORD, "dwFlags")]),
     Method(DDRESULT, "UpdateOverlayZOrder", [(DirectDrawUpdateOverlayZOrderFlags, "dwFlags"), (LPDIRECTDRAWSURFACE2, "lpDDSReference")]),
-    Method(DDRESULT, "GetDDInterface", [Out(Pointer(IUnknown), "lplpDD")]),
+    Method(DDRESULT, "GetDDInterface", [Out(LPUNKNOWN, "lplpDD")]),
     Method(DDRESULT, "PageLock", [(DWORD, "dwFlags")]),
     Method(DDRESULT, "PageUnlock", [(DWORD, "dwFlags")]),
 ]
@@ -1507,7 +1506,7 @@ IDirectDrawSurface3.methods += [
     Method(DDRESULT, "UpdateOverlay", [(LPRECT, "lpSrcRect"), (LPDIRECTDRAWSURFACE3, "lpDDDestSurface"), (LPRECT, "lpDestRect"), (DirectDrawSurfaceOverlayFlags, "dwFlags"), (LPDDOVERLAYFX, "lpDDOverlayFx")]),
     Method(DDRESULT, "UpdateOverlayDisplay", [(DWORD, "dwFlags")]),
     Method(DDRESULT, "UpdateOverlayZOrder", [(DirectDrawUpdateOverlayZOrderFlags, "dwFlags"), (LPDIRECTDRAWSURFACE3, "lpDDSReference")]),
-    Method(DDRESULT, "GetDDInterface", [Out(Pointer(IUnknown), "lplpDD")]),
+    Method(DDRESULT, "GetDDInterface", [Out(LPUNKNOWN, "lplpDD")]),
     Method(DDRESULT, "PageLock", [(DWORD, "dwFlags")]),
     Method(DDRESULT, "PageUnlock", [(DWORD, "dwFlags")]),
     Method(DDRESULT, "SetSurfaceDesc", [(LPDDSURFACEDESC, "lpDDSD"), (DWORD, "dwFlags")]),
@@ -1639,14 +1638,14 @@ ddraw.addFunctions([
     StdFunction(HRESULT, "DirectDrawEnumerateA", [(LPDDENUMCALLBACKA, "lpCallback"), (LPVOID, "lpContext")]),
     StdFunction(HRESULT, "DirectDrawEnumerateExW", [(LPDDENUMCALLBACKEXW, "lpCallback"), (LPVOID, "lpContext"), (DDENUM, "dwFlags")]),
     StdFunction(HRESULT, "DirectDrawEnumerateExA", [(LPDDENUMCALLBACKEXA, "lpCallback"), (LPVOID, "lpContext"), (DDENUM, "dwFlags")]),
-    StdFunction(HRESULT, "DirectDrawCreate", [(Pointer(GUID), "lpGUID"), Out(Pointer(LPDIRECTDRAW), "lplpDD"), (Pointer(IUnknown), "pUnkOuter")]),
-    StdFunction(HRESULT, "DirectDrawCreateEx", [(Pointer(GUID), "lpGuid"), Out(Pointer(LPVOID), "lplpDD"), (REFIID, "iid"), (Pointer(IUnknown), "pUnkOuter")]),
-    StdFunction(HRESULT, "DirectDrawCreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (Pointer(IUnknown), "pUnkOuter")]),
+    StdFunction(HRESULT, "DirectDrawCreate", [(Pointer(GUID), "lpGUID"), Out(Pointer(LPDIRECTDRAW), "lplpDD"), (LPUNKNOWN, "pUnkOuter")]),
+    StdFunction(HRESULT, "DirectDrawCreateEx", [(Pointer(GUID), "lpGuid"), Out(Pointer(ObjPointer(Void)), "lplpDD"), (REFIID, "iid"), (LPUNKNOWN, "pUnkOuter")]),
+    StdFunction(HRESULT, "DirectDrawCreateClipper", [(DWORD, "dwFlags"), Out(Pointer(LPDIRECTDRAWCLIPPER), "lplpDDClipper"), (LPUNKNOWN, "pUnkOuter")]),
     StdFunction(Void, "AcquireDDThreadLock", []),
     StdFunction(Void, "ReleaseDDThreadLock", []),
     StdFunction(DWORD, "D3DParseUnknownCommand", [(LPVOID, "lpCmd"), Out(Pointer(LPVOID), "lpRetCmd")]),
     StdFunction(HRESULT, "DllCanUnloadNow", []),
-    StdFunction(HRESULT, "DllGetClassObject", [(REFCLSID, "rclsid"), (REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppv")]),
+    StdFunction(HRESULT, "DllGetClassObject", [(REFCLSID, "rclsid"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppv")]),
 
     # XXX
     StdFunction(HRESULT, "CompleteCreateSysmemSurface", [Int, Int]),
diff --git a/specs/dwrite.def b/specs/dwrite.def
deleted file mode 100644 (file)
index 4cc6785..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBRARY "d2d1"
-
-EXPORTS
-       DWriteCreateFactory
index dac621100456750a83004be400184ae810d07618..88c6b83878ba7ca701e750f1d66c6332b31cf4fb 100644 (file)
@@ -183,7 +183,7 @@ DWRITE_FACTORY_TYPE = Enum("DWRITE_FACTORY_TYPE", [
 ])
 
 IDWriteFontFileLoader.methods += [
-    Method(HRESULT, "CreateStreamFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(Pointer(IDWriteFontFileStream)), "fontFileStream")]),
+    Method(HRESULT, "CreateStreamFromKey", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), Out(Pointer(ObjPointer(IDWriteFontFileStream)), "fontFileStream")]),
 ]
 
 IDWriteLocalFontFileLoader.methods += [
@@ -201,7 +201,7 @@ IDWriteFontFileStream.methods += [
 
 IDWriteFontFile.methods += [
     Method(HRESULT, "GetReferenceKey", [Out(Pointer(OpaquePointer(Const(Void))), "fontFileReferenceKey"), Out(Pointer(UINT32), "fontFileReferenceKeySize")]),
-    Method(HRESULT, "GetLoader", [Out(Pointer(Pointer(IDWriteFontFileLoader)), "fontFileLoader")]),
+    Method(HRESULT, "GetLoader", [Out(Pointer(ObjPointer(IDWriteFontFileLoader)), "fontFileLoader")]),
     Method(HRESULT, "Analyze", [Out(Pointer(BOOL), "isSupportedFontType"), Out(Pointer(DWRITE_FONT_FILE_TYPE), "fontFileType"), Out(Pointer(DWRITE_FONT_FACE_TYPE), "fontFaceType"), Out(Pointer(UINT32), "numberOfFaces")]),
 ]
 
@@ -240,7 +240,7 @@ IDWriteRenderingParams.methods += [
 
 IDWriteFontFace.methods += [
     Method(DWRITE_FONT_FACE_TYPE, "GetType", []),
-    Method(HRESULT, "GetFiles", [(OpaquePointer(UINT32), "numberOfFiles"), Out(Pointer(Pointer(IDWriteFontFile)), "fontFiles")]),
+    Method(HRESULT, "GetFiles", [(OpaquePointer(UINT32), "numberOfFiles"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFiles")]),
     Method(UINT32, "GetIndex", []),
     Method(DWRITE_FONT_SIMULATIONS, "GetSimulations", []),
     Method(BOOL, "IsSymbolFont", []),
@@ -250,19 +250,19 @@ IDWriteFontFace.methods += [
     Method(HRESULT, "GetGlyphIndices", [(Pointer(Const(UINT32)), "codePoints"), (UINT32, "codePointCount"), Out(Pointer(UINT16), "glyphIndices")]),
     Method(HRESULT, "TryGetFontTable", [(UINT32, "openTypeTableTag"), Out(Pointer(OpaquePointer(Const(Void))), "tableData"), Out(Pointer(UINT32), "tableSize"), Out(Pointer(OpaquePointer(Void)), "tableContext"), Out(Pointer(BOOL), "exists")]),
     Method(Void, "ReleaseFontTable", [(OpaquePointer(Void), "tableContext")]),
-    Method(HRESULT, "GetGlyphRunOutline", [(FLOAT, "emSize"), (Pointer(Const(UINT16)), "glyphIndices"), (Pointer(Const(FLOAT)), "glyphAdvances"), (Pointer(Const(DWRITE_GLYPH_OFFSET)), "glyphOffsets"), (UINT32, "glyphCount"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(IDWriteGeometrySink), "geometrySink")]),
-    Method(HRESULT, "GetRecommendedRenderingMode", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (DWRITE_MEASURING_MODE, "measuringMode"), (Pointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(DWRITE_RENDERING_MODE), "renderingMode")]),
+    Method(HRESULT, "GetGlyphRunOutline", [(FLOAT, "emSize"), (Pointer(Const(UINT16)), "glyphIndices"), (Pointer(Const(FLOAT)), "glyphAdvances"), (Pointer(Const(DWRITE_GLYPH_OFFSET)), "glyphOffsets"), (UINT32, "glyphCount"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (ObjPointer(IDWriteGeometrySink), "geometrySink")]),
+    Method(HRESULT, "GetRecommendedRenderingMode", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (DWRITE_MEASURING_MODE, "measuringMode"), (ObjPointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(DWRITE_RENDERING_MODE), "renderingMode")]),
     Method(HRESULT, "GetGdiCompatibleMetrics", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), Out(Pointer(DWRITE_FONT_METRICS), "fontFaceMetrics")]),
     Method(HRESULT, "GetGdiCompatibleGlyphMetrics", [(FLOAT, "emSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (UINT32, "glyphCount"), Out(Array(DWRITE_GLYPH_METRICS, "glyphCount"), "glyphMetrics"), (BOOL, "isSideways")]),
 ]
 
 IDWriteFontCollectionLoader.methods += [
-    Method(HRESULT, "CreateEnumeratorFromKey", [(Pointer(IDWriteFactory), "factory"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(Pointer(IDWriteFontFileEnumerator)), "fontFileEnumerator")]),
+    Method(HRESULT, "CreateEnumeratorFromKey", [(ObjPointer(IDWriteFactory), "factory"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(ObjPointer(IDWriteFontFileEnumerator)), "fontFileEnumerator")]),
 ]
 
 IDWriteFontFileEnumerator.methods += [
     Method(HRESULT, "MoveNext", [Out(Pointer(BOOL), "hasCurrentFile")]),
-    Method(HRESULT, "GetCurrentFontFile", [Out(Pointer(Pointer(IDWriteFontFile)), "fontFile")]),
+    Method(HRESULT, "GetCurrentFontFile", [Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
 ]
 
 IDWriteLocalizedStrings.methods += [
@@ -276,35 +276,35 @@ IDWriteLocalizedStrings.methods += [
 
 IDWriteFontCollection.methods += [
     Method(UINT32, "GetFontFamilyCount", []),
-    Method(HRESULT, "GetFontFamily", [(UINT32, "index"), Out(Pointer(Pointer(IDWriteFontFamily)), "fontFamily")]),
+    Method(HRESULT, "GetFontFamily", [(UINT32, "index"), Out(Pointer(ObjPointer(IDWriteFontFamily)), "fontFamily")]),
     Method(HRESULT, "FindFamilyName", [(Pointer(Const(WCHAR)), "familyName"), Out(Pointer(UINT32), "index"), Out(Pointer(BOOL), "exists")]),
-    Method(HRESULT, "GetFontFromFontFace", [(Pointer(IDWriteFontFace), "fontFace"), Out(Pointer(Pointer(IDWriteFont)), "font")]),
+    Method(HRESULT, "GetFontFromFontFace", [(ObjPointer(IDWriteFontFace), "fontFace"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
 ]
 
 IDWriteFontList.methods += [
-    Method(HRESULT, "GetFontCollection", [Out(Pointer(Pointer(IDWriteFontCollection)), "fontCollection")]),
+    Method(HRESULT, "GetFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
     Method(UINT32, "GetFontCount", []),
-    Method(HRESULT, "GetFont", [(UINT32, "index"), Out(Pointer(Pointer(IDWriteFont)), "font")]),
+    Method(HRESULT, "GetFont", [(UINT32, "index"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
 ]
 
 IDWriteFontFamily.methods += [
-    Method(HRESULT, "GetFamilyNames", [Out(Pointer(Pointer(IDWriteLocalizedStrings)), "names")]),
-    Method(HRESULT, "GetFirstMatchingFont", [(DWRITE_FONT_WEIGHT, "weight"), (DWRITE_FONT_STRETCH, "stretch"), (DWRITE_FONT_STYLE, "style"), Out(Pointer(Pointer(IDWriteFont)), "matchingFont")]),
-    Method(HRESULT, "GetMatchingFonts", [(DWRITE_FONT_WEIGHT, "weight"), (DWRITE_FONT_STRETCH, "stretch"), (DWRITE_FONT_STYLE, "style"), Out(Pointer(Pointer(IDWriteFontList)), "matchingFonts")]),
+    Method(HRESULT, "GetFamilyNames", [Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "names")]),
+    Method(HRESULT, "GetFirstMatchingFont", [(DWRITE_FONT_WEIGHT, "weight"), (DWRITE_FONT_STRETCH, "stretch"), (DWRITE_FONT_STYLE, "style"), Out(Pointer(ObjPointer(IDWriteFont)), "matchingFont")]),
+    Method(HRESULT, "GetMatchingFonts", [(DWRITE_FONT_WEIGHT, "weight"), (DWRITE_FONT_STRETCH, "stretch"), (DWRITE_FONT_STYLE, "style"), Out(Pointer(ObjPointer(IDWriteFontList)), "matchingFonts")]),
 ]
 
 IDWriteFont.methods += [
-    Method(HRESULT, "GetFontFamily", [Out(Pointer(Pointer(IDWriteFontFamily)), "fontFamily")]),
+    Method(HRESULT, "GetFontFamily", [Out(Pointer(ObjPointer(IDWriteFontFamily)), "fontFamily")]),
     Method(DWRITE_FONT_WEIGHT, "GetWeight", []),
     Method(DWRITE_FONT_STRETCH, "GetStretch", []),
     Method(DWRITE_FONT_STYLE, "GetStyle", []),
     Method(BOOL, "IsSymbolFont", []),
-    Method(HRESULT, "GetFaceNames", [Out(Pointer(Pointer(IDWriteLocalizedStrings)), "names")]),
-    Method(HRESULT, "GetInformationalStrings", [(DWRITE_INFORMATIONAL_STRING_ID, "informationalStringID"), Out(Pointer(Pointer(IDWriteLocalizedStrings)), "informationalStrings"), Out(Pointer(BOOL), "exists")]),
+    Method(HRESULT, "GetFaceNames", [Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "names")]),
+    Method(HRESULT, "GetInformationalStrings", [(DWRITE_INFORMATIONAL_STRING_ID, "informationalStringID"), Out(Pointer(ObjPointer(IDWriteLocalizedStrings)), "informationalStrings"), Out(Pointer(BOOL), "exists")]),
     Method(DWRITE_FONT_SIMULATIONS, "GetSimulations", []),
     Method(Void, "GetMetrics", [Out(Pointer(DWRITE_FONT_METRICS), "fontMetrics")]),
     Method(HRESULT, "HasCharacter", [(UINT32, "unicodeValue"), Out(Pointer(BOOL), "exists")]),
-    Method(HRESULT, "CreateFontFace", [Out(Pointer(Pointer(IDWriteFontFace)), "fontFace")]),
+    Method(HRESULT, "CreateFontFace", [Out(Pointer(ObjPointer(IDWriteFontFace)), "fontFace")]),
 ]
 
 DWRITE_READING_DIRECTION = Enum("DWRITE_READING_DIRECTION", [
@@ -454,7 +454,7 @@ IDWriteTextFormat.methods += [
     Method(HRESULT, "SetReadingDirection", [(DWRITE_READING_DIRECTION, "readingDirection")]),
     Method(HRESULT, "SetFlowDirection", [(DWRITE_FLOW_DIRECTION, "flowDirection")]),
     Method(HRESULT, "SetIncrementalTabStop", [(FLOAT, "incrementalTabStop")]),
-    Method(HRESULT, "SetTrimming", [(Pointer(Const(DWRITE_TRIMMING)), "trimmingOptions"), (Pointer(IDWriteInlineObject), "trimmingSign")]),
+    Method(HRESULT, "SetTrimming", [(Pointer(Const(DWRITE_TRIMMING)), "trimmingOptions"), (ObjPointer(IDWriteInlineObject), "trimmingSign")]),
     Method(HRESULT, "SetLineSpacing", [(DWRITE_LINE_SPACING_METHOD, "lineSpacingMethod"), (FLOAT, "lineSpacing"), (FLOAT, "baseline")]),
     Method(DWRITE_TEXT_ALIGNMENT, "GetTextAlignment", []),
     Method(DWRITE_PARAGRAPH_ALIGNMENT, "GetParagraphAlignment", []),
@@ -462,9 +462,9 @@ IDWriteTextFormat.methods += [
     Method(DWRITE_READING_DIRECTION, "GetReadingDirection", []),
     Method(DWRITE_FLOW_DIRECTION, "GetFlowDirection", []),
     Method(FLOAT, "GetIncrementalTabStop", []),
-    Method(HRESULT, "GetTrimming", [Out(Pointer(DWRITE_TRIMMING), "trimmingOptions"), Out(Pointer(Pointer(IDWriteInlineObject)), "trimmingSign")]),
+    Method(HRESULT, "GetTrimming", [Out(Pointer(DWRITE_TRIMMING), "trimmingOptions"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "trimmingSign")]),
     Method(HRESULT, "GetLineSpacing", [Out(Pointer(DWRITE_LINE_SPACING_METHOD), "lineSpacingMethod"), Out(Pointer(FLOAT), "lineSpacing"), Out(Pointer(FLOAT), "baseline")]),
-    Method(HRESULT, "GetFontCollection", [Out(Pointer(Pointer(IDWriteFontCollection)), "fontCollection")]),
+    Method(HRESULT, "GetFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
     Method(UINT32, "GetFontFamilyNameLength", []),
     Method(HRESULT, "GetFontFamilyName", [Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize")]),
     Method(DWRITE_FONT_WEIGHT, "GetFontWeight", []),
@@ -535,28 +535,28 @@ IDWriteTextAnalysisSource.methods += [
     Method(HRESULT, "GetTextBeforePosition", [(UINT32, "textPosition"), Out(Pointer(Pointer(Const(WCHAR))), "textString"), Out(Pointer(UINT32), "textLength")]),
     Method(DWRITE_READING_DIRECTION, "GetParagraphReadingDirection", []),
     Method(HRESULT, "GetLocaleName", [(UINT32, "textPosition"), Out(Pointer(UINT32), "textLength"), Out(Pointer(Pointer(Const(WCHAR))), "localeName")]),
-    Method(HRESULT, "GetNumberSubstitution", [(UINT32, "textPosition"), Out(Pointer(UINT32), "textLength"), Out(Pointer(Pointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
+    Method(HRESULT, "GetNumberSubstitution", [(UINT32, "textPosition"), Out(Pointer(UINT32), "textLength"), Out(Pointer(ObjPointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
 ]
 
 IDWriteTextAnalysisSink.methods += [
     Method(HRESULT, "SetScriptAnalysis", [(UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis")]),
     Method(HRESULT, "SetLineBreakpoints", [(UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(Const(DWRITE_LINE_BREAKPOINT)), "lineBreakpoints")]),
     Method(HRESULT, "SetBidiLevel", [(UINT32, "textPosition"), (UINT32, "textLength"), (UINT8, "explicitLevel"), (UINT8, "resolvedLevel")]),
-    Method(HRESULT, "SetNumberSubstitution", [(UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(IDWriteNumberSubstitution), "numberSubstitution")]),
+    Method(HRESULT, "SetNumberSubstitution", [(UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteNumberSubstitution), "numberSubstitution")]),
 ]
 
 IDWriteTextAnalyzer.methods += [
-    Method(HRESULT, "AnalyzeScript", [(Pointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(IDWriteTextAnalysisSink), "analysisSink")]),
-    Method(HRESULT, "AnalyzeBidi", [(Pointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(IDWriteTextAnalysisSink), "analysisSink")]),
-    Method(HRESULT, "AnalyzeNumberSubstitution", [(Pointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(IDWriteTextAnalysisSink), "analysisSink")]),
-    Method(HRESULT, "AnalyzeLineBreakpoints", [(Pointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (Pointer(IDWriteTextAnalysisSink), "analysisSink")]),
-    Method(HRESULT, "GetGlyphs", [(Pointer(Const(WCHAR)), "textString"), (UINT32, "textLength"), (Pointer(IDWriteFontFace), "fontFace"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (Pointer(Const(WCHAR)), "localeName"), (Pointer(IDWriteNumberSubstitution), "numberSubstitution"), (OpaquePointer(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES))), "features"), (Pointer(Const(UINT32)), "featureRangeLengths"), (UINT32, "featureRanges"), (UINT32, "maxGlyphCount"), Out(Pointer(UINT16), "clusterMap"), Out(Pointer(DWRITE_SHAPING_TEXT_PROPERTIES), "textProps"), Out(Pointer(UINT16), "glyphIndices"), Out(Pointer(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphProps"), Out(Pointer(UINT32), "actualGlyphCount")]),
-    Method(HRESULT, "GetGlyphPlacements", [(Array(Const(WCHAR), "textLength"), "textString"), (Array(Const(UINT16), "textLength"), "clusterMap"), (Array(DWRITE_SHAPING_TEXT_PROPERTIES, "textLength"), "textProps"), (UINT32, "textLength"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (Array(Const(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphCount"), "glyphProps"), (UINT32, "glyphCount"), (Pointer(IDWriteFontFace), "fontFace"), (FLOAT, "fontEmSize"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (LPCWSTR, "localeName"), (Array(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES)), "featureRanges"), "features"), (Array(Const(UINT32), "featureRanges"), "featureRangeLengths"), (UINT32, "featureRanges"), Out(Array(FLOAT, "glyphCount"), "glyphAdvances"), Out(Array(DWRITE_GLYPH_OFFSET, "glyphCount"), "glyphOffsets")]), 
-    Method(HRESULT, "GetGdiCompatibleGlyphPlacements", [(Array(Const(WCHAR), "textLength"), "textString"), (Array(Const(UINT16), "textLength"), "clusterMap"), (Array(DWRITE_SHAPING_TEXT_PROPERTIES, "textLength"), "textProps"), (UINT32, "textLength"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (Array(Const(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphCount"), "glyphProps"), (UINT32, "glyphCount"), (Pointer(IDWriteFontFace), "fontFace"), (FLOAT, "fontEmSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (LPCWSTR, "localeName"), (Array(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES)), "featureRanges"), "features"), (Array(Const(UINT32), "featureRanges"), "featureRangeLengths"), (UINT32, "featureRanges"), Out(Array(FLOAT, "glyphCount"), "glyphAdvances"), Out(Array(DWRITE_GLYPH_OFFSET, "glyphCount"), "glyphOffsets")]),
+    Method(HRESULT, "AnalyzeScript", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
+    Method(HRESULT, "AnalyzeBidi", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
+    Method(HRESULT, "AnalyzeNumberSubstitution", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
+    Method(HRESULT, "AnalyzeLineBreakpoints", [(ObjPointer(IDWriteTextAnalysisSource), "analysisSource"), (UINT32, "textPosition"), (UINT32, "textLength"), (ObjPointer(IDWriteTextAnalysisSink), "analysisSink")]),
+    Method(HRESULT, "GetGlyphs", [(Pointer(Const(WCHAR)), "textString"), (UINT32, "textLength"), (ObjPointer(IDWriteFontFace), "fontFace"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (Pointer(Const(WCHAR)), "localeName"), (ObjPointer(IDWriteNumberSubstitution), "numberSubstitution"), (OpaquePointer(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES))), "features"), (Pointer(Const(UINT32)), "featureRangeLengths"), (UINT32, "featureRanges"), (UINT32, "maxGlyphCount"), Out(Pointer(UINT16), "clusterMap"), Out(Pointer(DWRITE_SHAPING_TEXT_PROPERTIES), "textProps"), Out(Pointer(UINT16), "glyphIndices"), Out(Pointer(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphProps"), Out(Pointer(UINT32), "actualGlyphCount")]),
+    Method(HRESULT, "GetGlyphPlacements", [(Array(Const(WCHAR), "textLength"), "textString"), (Array(Const(UINT16), "textLength"), "clusterMap"), (Array(DWRITE_SHAPING_TEXT_PROPERTIES, "textLength"), "textProps"), (UINT32, "textLength"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (Array(Const(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphCount"), "glyphProps"), (UINT32, "glyphCount"), (ObjPointer(IDWriteFontFace), "fontFace"), (FLOAT, "fontEmSize"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (LPCWSTR, "localeName"), (Array(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES)), "featureRanges"), "features"), (Array(Const(UINT32), "featureRanges"), "featureRangeLengths"), (UINT32, "featureRanges"), Out(Array(FLOAT, "glyphCount"), "glyphAdvances"), Out(Array(DWRITE_GLYPH_OFFSET, "glyphCount"), "glyphOffsets")]), 
+    Method(HRESULT, "GetGdiCompatibleGlyphPlacements", [(Array(Const(WCHAR), "textLength"), "textString"), (Array(Const(UINT16), "textLength"), "clusterMap"), (Array(DWRITE_SHAPING_TEXT_PROPERTIES, "textLength"), "textProps"), (UINT32, "textLength"), (Array(Const(UINT16), "glyphCount"), "glyphIndices"), (Array(Const(DWRITE_SHAPING_GLYPH_PROPERTIES), "glyphCount"), "glyphProps"), (UINT32, "glyphCount"), (ObjPointer(IDWriteFontFace), "fontFace"), (FLOAT, "fontEmSize"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(Const(DWRITE_SCRIPT_ANALYSIS)), "scriptAnalysis"), (LPCWSTR, "localeName"), (Array(Pointer(Const(DWRITE_TYPOGRAPHIC_FEATURES)), "featureRanges"), "features"), (Array(Const(UINT32), "featureRanges"), "featureRangeLengths"), (UINT32, "featureRanges"), Out(Array(FLOAT, "glyphCount"), "glyphAdvances"), Out(Array(DWRITE_GLYPH_OFFSET, "glyphCount"), "glyphOffsets")]),
 ]
 
 DWRITE_GLYPH_RUN = Struct("DWRITE_GLYPH_RUN", [
-    (Pointer(IDWriteFontFace), "fontFace"),
+    (ObjPointer(IDWriteFontFace), "fontFace"),
     (FLOAT, "fontEmSize"),
     (UINT32, "glyphCount"),
     (Pointer(Const(UINT16)), "glyphIndices"),
@@ -654,7 +654,7 @@ DWRITE_HIT_TEST_METRICS = Struct("DWRITE_HIT_TEST_METRICS", [
 ])
 
 IDWriteInlineObject.methods += [
-    Method(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (Pointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(IUnknown), "clientDrawingEffect")]),
+    Method(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (ObjPointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
     Method(HRESULT, "GetMetrics", [Out(Pointer(DWRITE_INLINE_OBJECT_METRICS), "metrics")]),
     Method(HRESULT, "GetOverhangMetrics", [Out(Pointer(DWRITE_OVERHANG_METRICS), "overhangs")]),
     Method(HRESULT, "GetBreakConditions", [Out(Pointer(DWRITE_BREAK_CONDITION), "breakConditionBefore"), Out(Pointer(DWRITE_BREAK_CONDITION), "breakConditionAfter")]),
@@ -667,16 +667,16 @@ IDWritePixelSnapping.methods += [
 ]
 
 IDWriteTextRenderer.methods += [
-    Method(HRESULT, "DrawGlyphRun", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (DWRITE_MEASURING_MODE, "measuringMode"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (Pointer(Const(DWRITE_GLYPH_RUN_DESCRIPTION)), "glyphRunDescription"), (Pointer(IUnknown), "clientDrawingEffect")]),
-    Method(HRESULT, "DrawUnderline", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_UNDERLINE)), "underline"), (Pointer(IUnknown), "clientDrawingEffect")]),
-    Method(HRESULT, "DrawStrikethrough", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_STRIKETHROUGH)), "strikethrough"), (Pointer(IUnknown), "clientDrawingEffect")]),
-    Method(HRESULT, "DrawInlineObject", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "originX"), (FLOAT, "originY"), (Pointer(IDWriteInlineObject), "inlineObject"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (Pointer(IUnknown), "clientDrawingEffect")]),
+    Method(HRESULT, "DrawGlyphRun", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (DWRITE_MEASURING_MODE, "measuringMode"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (Pointer(Const(DWRITE_GLYPH_RUN_DESCRIPTION)), "glyphRunDescription"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
+    Method(HRESULT, "DrawUnderline", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_UNDERLINE)), "underline"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
+    Method(HRESULT, "DrawStrikethrough", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (Pointer(Const(DWRITE_STRIKETHROUGH)), "strikethrough"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
+    Method(HRESULT, "DrawInlineObject", [(OpaquePointer(Void), "clientDrawingContext"), (FLOAT, "originX"), (FLOAT, "originY"), (ObjPointer(IDWriteInlineObject), "inlineObject"), (BOOL, "isSideways"), (BOOL, "isRightToLeft"), (ObjPointer(IUnknown), "clientDrawingEffect")]),
 ]
 
 IDWriteTextLayout.methods += [
     Method(HRESULT, "SetMaxWidth", [(FLOAT, "maxWidth")]),
     Method(HRESULT, "SetMaxHeight", [(FLOAT, "maxHeight")]),
-    Method(HRESULT, "SetFontCollection", [(Pointer(IDWriteFontCollection), "fontCollection"), (DWRITE_TEXT_RANGE, "textRange")]),
+    Method(HRESULT, "SetFontCollection", [(ObjPointer(IDWriteFontCollection), "fontCollection"), (DWRITE_TEXT_RANGE, "textRange")]),
     Method(HRESULT, "SetFontFamilyName", [(Pointer(Const(WCHAR)), "fontFamilyName"), (DWRITE_TEXT_RANGE, "textRange")]),
     Method(HRESULT, "SetFontWeight", [(DWRITE_FONT_WEIGHT, "fontWeight"), (DWRITE_TEXT_RANGE, "textRange")]),
     Method(HRESULT, "SetFontStyle", [(DWRITE_FONT_STYLE, "fontStyle"), (DWRITE_TEXT_RANGE, "textRange")]),
@@ -684,13 +684,13 @@ IDWriteTextLayout.methods += [
     Method(HRESULT, "SetFontSize", [(FLOAT, "fontSize"), (DWRITE_TEXT_RANGE, "textRange")]),
     Method(HRESULT, "SetUnderline", [(BOOL, "hasUnderline"), (DWRITE_TEXT_RANGE, "textRange")]),
     Method(HRESULT, "SetStrikethrough", [(BOOL, "hasStrikethrough"), (DWRITE_TEXT_RANGE, "textRange")]),
-    Method(HRESULT, "SetDrawingEffect", [(Pointer(IUnknown), "drawingEffect"), (DWRITE_TEXT_RANGE, "textRange")]),
-    Method(HRESULT, "SetInlineObject", [(Pointer(IDWriteInlineObject), "inlineObject"), (DWRITE_TEXT_RANGE, "textRange")]),
-    Method(HRESULT, "SetTypography", [(Pointer(IDWriteTypography), "typography"), (DWRITE_TEXT_RANGE, "textRange")]),
+    Method(HRESULT, "SetDrawingEffect", [(ObjPointer(IUnknown), "drawingEffect"), (DWRITE_TEXT_RANGE, "textRange")]),
+    Method(HRESULT, "SetInlineObject", [(ObjPointer(IDWriteInlineObject), "inlineObject"), (DWRITE_TEXT_RANGE, "textRange")]),
+    Method(HRESULT, "SetTypography", [(ObjPointer(IDWriteTypography), "typography"), (DWRITE_TEXT_RANGE, "textRange")]),
     Method(HRESULT, "SetLocaleName", [(Pointer(Const(WCHAR)), "localeName"), (DWRITE_TEXT_RANGE, "textRange")]),
     Method(FLOAT, "GetMaxWidth", []),
     Method(FLOAT, "GetMaxHeight", []),
-    Method(HRESULT, "GetFontCollection", [(UINT32, "currentPosition"), Out(Pointer(Pointer(IDWriteFontCollection)), "fontCollection"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
+    Method(HRESULT, "GetFontCollection", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
     Method(HRESULT, "GetFontFamilyNameLength", [(UINT32, "currentPosition"), Out(Pointer(UINT32), "nameLength"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
     Method(HRESULT, "GetFontFamilyName", [(UINT32, "currentPosition"), Out(Pointer(WCHAR), "fontFamilyName"), (UINT32, "nameSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
     Method(HRESULT, "GetFontWeight", [(UINT32, "currentPosition"), Out(Pointer(DWRITE_FONT_WEIGHT), "fontWeight"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
@@ -699,12 +699,12 @@ IDWriteTextLayout.methods += [
     Method(HRESULT, "GetFontSize", [(UINT32, "currentPosition"), Out(Pointer(FLOAT), "fontSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
     Method(HRESULT, "GetUnderline", [(UINT32, "currentPosition"), Out(Pointer(BOOL), "hasUnderline"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
     Method(HRESULT, "GetStrikethrough", [(UINT32, "currentPosition"), Out(Pointer(BOOL), "hasStrikethrough"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
-    Method(HRESULT, "GetDrawingEffect", [(UINT32, "currentPosition"), Out(Pointer(Pointer(IUnknown)), "drawingEffect"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
-    Method(HRESULT, "GetInlineObject", [(UINT32, "currentPosition"), Out(Pointer(Pointer(IDWriteInlineObject)), "inlineObject"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
-    Method(HRESULT, "GetTypography", [(UINT32, "currentPosition"), Out(Pointer(Pointer(IDWriteTypography)), "typography"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
+    Method(HRESULT, "GetDrawingEffect", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IUnknown)), "drawingEffect"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
+    Method(HRESULT, "GetInlineObject", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "inlineObject"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
+    Method(HRESULT, "GetTypography", [(UINT32, "currentPosition"), Out(Pointer(ObjPointer(IDWriteTypography)), "typography"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
     Method(HRESULT, "GetLocaleNameLength", [(UINT32, "currentPosition"), Out(Pointer(UINT32), "nameLength"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
     Method(HRESULT, "GetLocaleName", [(UINT32, "currentPosition"), Out(Pointer(WCHAR), "localeName"), (UINT32, "nameSize"), Out(Pointer(DWRITE_TEXT_RANGE), "textRange")]),
-    Method(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (Pointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY")]),
+    Method(HRESULT, "Draw", [(OpaquePointer(Void), "clientDrawingContext"), (ObjPointer(IDWriteTextRenderer), "renderer"), (FLOAT, "originX"), (FLOAT, "originY")]),
     Method(HRESULT, "GetLineMetrics", [Out(Pointer(DWRITE_LINE_METRICS), "lineMetrics"), (UINT32, "maxLineCount"), Out(Pointer(UINT32), "actualLineCount")]),
     Method(HRESULT, "GetMetrics", [Out(Pointer(DWRITE_TEXT_METRICS), "textMetrics")]),
     Method(HRESULT, "GetOverhangMetrics", [Out(Pointer(DWRITE_OVERHANG_METRICS), "overhangs")]),
@@ -716,7 +716,7 @@ IDWriteTextLayout.methods += [
 ]
 
 IDWriteBitmapRenderTarget.methods += [
-    Method(HRESULT, "DrawGlyphRun", [(FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (DWRITE_MEASURING_MODE, "measuringMode"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (Pointer(IDWriteRenderingParams), "renderingParams"), (COLORREF, "textColor"), Out(Pointer(RECT), "blackBoxRect")]),
+    Method(HRESULT, "DrawGlyphRun", [(FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), (DWRITE_MEASURING_MODE, "measuringMode"), (Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (ObjPointer(IDWriteRenderingParams), "renderingParams"), (COLORREF, "textColor"), Out(Pointer(RECT), "blackBoxRect")]),
     Method(HDC, "GetMemoryDC", []),
     Method(FLOAT, "GetPixelsPerDip", []),
     Method(HRESULT, "SetPixelsPerDip", [(FLOAT, "pixelsPerDip")]),
@@ -727,11 +727,11 @@ IDWriteBitmapRenderTarget.methods += [
 ]
 
 IDWriteGdiInterop.methods += [
-    Method(HRESULT, "CreateFontFromLOGFONT", [(Pointer(Const(LOGFONTW)), "logFont"), Out(Pointer(Pointer(IDWriteFont)), "font")]),
-    Method(HRESULT, "ConvertFontToLOGFONT", [(Pointer(IDWriteFont), "font"), Out(Pointer(LOGFONTW), "logFont"), Out(Pointer(BOOL), "isSystemFont")]),
-    Method(HRESULT, "ConvertFontFaceToLOGFONT", [(Pointer(IDWriteFontFace), "font"), Out(Pointer(LOGFONTW), "logFont")]),
-    Method(HRESULT, "CreateFontFaceFromHdc", [(HDC, "hdc"), Out(Pointer(Pointer(IDWriteFontFace)), "fontFace")]),
-    Method(HRESULT, "CreateBitmapRenderTarget", [(HDC, "hdc"), (UINT32, "width"), (UINT32, "height"), Out(Pointer(Pointer(IDWriteBitmapRenderTarget)), "renderTarget")]),
+    Method(HRESULT, "CreateFontFromLOGFONT", [(Pointer(Const(LOGFONTW)), "logFont"), Out(Pointer(ObjPointer(IDWriteFont)), "font")]),
+    Method(HRESULT, "ConvertFontToLOGFONT", [(ObjPointer(IDWriteFont), "font"), Out(Pointer(LOGFONTW), "logFont"), Out(Pointer(BOOL), "isSystemFont")]),
+    Method(HRESULT, "ConvertFontFaceToLOGFONT", [(ObjPointer(IDWriteFontFace), "font"), Out(Pointer(LOGFONTW), "logFont")]),
+    Method(HRESULT, "CreateFontFaceFromHdc", [(HDC, "hdc"), Out(Pointer(ObjPointer(IDWriteFontFace)), "fontFace")]),
+    Method(HRESULT, "CreateBitmapRenderTarget", [(HDC, "hdc"), (UINT32, "width"), (UINT32, "height"), Out(Pointer(ObjPointer(IDWriteBitmapRenderTarget)), "renderTarget")]),
 ]
 
 DWRITE_TEXTURE_TYPE = Enum("DWRITE_TEXTURE_TYPE", [
@@ -742,35 +742,35 @@ DWRITE_TEXTURE_TYPE = Enum("DWRITE_TEXTURE_TYPE", [
 IDWriteGlyphRunAnalysis.methods += [
     Method(HRESULT, "GetAlphaTextureBounds", [(DWRITE_TEXTURE_TYPE, "textureType"), Out(Pointer(RECT), "textureBounds")]),
     Method(HRESULT, "CreateAlphaTexture", [(DWRITE_TEXTURE_TYPE, "textureType"), (Pointer(Const(RECT)), "textureBounds"), Out(Pointer(BYTE), "alphaValues"), (UINT32, "bufferSize")]),
-    Method(HRESULT, "GetAlphaBlendParams", [(Pointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(FLOAT), "blendGamma"), Out(Pointer(FLOAT), "blendEnhancedContrast"), Out(Pointer(FLOAT), "blendClearTypeLevel")]),
+    Method(HRESULT, "GetAlphaBlendParams", [(ObjPointer(IDWriteRenderingParams), "renderingParams"), Out(Pointer(FLOAT), "blendGamma"), Out(Pointer(FLOAT), "blendEnhancedContrast"), Out(Pointer(FLOAT), "blendClearTypeLevel")]),
 ]
 
 IDWriteFactory.methods += [
-    Method(HRESULT, "GetSystemFontCollection", [Out(Pointer(Pointer(IDWriteFontCollection)), "fontCollection"), (BOOL, "checkForUpdates")]),
-    Method(HRESULT, "CreateCustomFontCollection", [(Pointer(IDWriteFontCollectionLoader), "collectionLoader"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(Pointer(IDWriteFontCollection)), "fontCollection")]),
-    Method(HRESULT, "RegisterFontCollectionLoader", [(Pointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
-    Method(HRESULT, "UnregisterFontCollectionLoader", [(Pointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
-    Method(HRESULT, "CreateFontFileReference", [(Pointer(Const(WCHAR)), "filePath"), (Pointer(Const(FILETIME)), "lastWriteTime"), Out(Pointer(Pointer(IDWriteFontFile)), "fontFile")]),
-    Method(HRESULT, "CreateCustomFontFileReference", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), (Pointer(IDWriteFontFileLoader), "fontFileLoader"), Out(Pointer(Pointer(IDWriteFontFile)), "fontFile")]),
-    Method(HRESULT, "CreateFontFace", [(DWRITE_FONT_FACE_TYPE, "fontFaceType"), (UINT32, "numberOfFiles"), (Pointer(Const(Pointer(IDWriteFontFile))), "fontFiles"), (UINT32, "faceIndex"), (DWRITE_FONT_SIMULATIONS, "fontFaceSimulationFlags"), Out(Pointer(Pointer(IDWriteFontFace)), "fontFace")]),
-    Method(HRESULT, "CreateRenderingParams", [Out(Pointer(Pointer(IDWriteRenderingParams)), "renderingParams")]),
-    Method(HRESULT, "CreateMonitorRenderingParams", [(HMONITOR, "monitor"), Out(Pointer(Pointer(IDWriteRenderingParams)), "renderingParams")]),
-    Method(HRESULT, "CreateCustomRenderingParams", [(FLOAT, "gamma"), (FLOAT, "enhancedContrast"), (FLOAT, "clearTypeLevel"), (DWRITE_PIXEL_GEOMETRY, "pixelGeometry"), (DWRITE_RENDERING_MODE, "renderingMode"), Out(Pointer(Pointer(IDWriteRenderingParams)), "renderingParams")]),
-    Method(HRESULT, "RegisterFontFileLoader", [(Pointer(IDWriteFontFileLoader), "fontFileLoader")]),
-    Method(HRESULT, "UnregisterFontFileLoader", [(Pointer(IDWriteFontFileLoader), "fontFileLoader")]),
-    Method(HRESULT, "CreateTextFormat", [(Pointer(Const(WCHAR)), "fontFamilyName"), (Pointer(IDWriteFontCollection), "fontCollection"), (DWRITE_FONT_WEIGHT, "fontWeight"), (DWRITE_FONT_STYLE, "fontStyle"), (DWRITE_FONT_STRETCH, "fontStretch"), (FLOAT, "fontSize"), (Pointer(Const(WCHAR)), "localeName"), Out(Pointer(Pointer(IDWriteTextFormat)), "textFormat")]),
-    Method(HRESULT, "CreateTypography", [Out(Pointer(Pointer(IDWriteTypography)), "typography")]),
-    Method(HRESULT, "GetGdiInterop", [Out(Pointer(Pointer(IDWriteGdiInterop)), "gdiInterop")]),
-    Method(HRESULT, "CreateTextLayout", [(Pointer(Const(WCHAR)), "string"), (UINT32, "stringLength"), (Pointer(IDWriteTextFormat), "textFormat"), (FLOAT, "maxWidth"), (FLOAT, "maxHeight"), Out(Pointer(Pointer(IDWriteTextLayout)), "textLayout")]),
-    Method(HRESULT, "CreateGdiCompatibleTextLayout", [(Pointer(Const(WCHAR)), "string"), (UINT32, "stringLength"), (Pointer(IDWriteTextFormat), "textFormat"), (FLOAT, "layoutWidth"), (FLOAT, "layoutHeight"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), Out(Pointer(Pointer(IDWriteTextLayout)), "textLayout")]),
-    Method(HRESULT, "CreateEllipsisTrimmingSign", [(Pointer(IDWriteTextFormat), "textFormat"), Out(Pointer(Pointer(IDWriteInlineObject)), "trimmingSign")]),
-    Method(HRESULT, "CreateTextAnalyzer", [Out(Pointer(Pointer(IDWriteTextAnalyzer)), "textAnalyzer")]),
-    Method(HRESULT, "CreateNumberSubstitution", [(DWRITE_NUMBER_SUBSTITUTION_METHOD, "substitutionMethod"), (Pointer(Const(WCHAR)), "localeName"), (BOOL, "ignoreUserOverride"), Out(Pointer(Pointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
-    Method(HRESULT, "CreateGlyphRunAnalysis", [(Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (DWRITE_RENDERING_MODE, "renderingMode"), (DWRITE_MEASURING_MODE, "measuringMode"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), Out(Pointer(Pointer(IDWriteGlyphRunAnalysis)), "glyphRunAnalysis")]),
+    Method(HRESULT, "GetSystemFontCollection", [Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection"), (BOOL, "checkForUpdates")]),
+    Method(HRESULT, "CreateCustomFontCollection", [(ObjPointer(IDWriteFontCollectionLoader), "collectionLoader"), (OpaquePointer(Const(Void)), "collectionKey"), (UINT32, "collectionKeySize"), Out(Pointer(ObjPointer(IDWriteFontCollection)), "fontCollection")]),
+    Method(HRESULT, "RegisterFontCollectionLoader", [(ObjPointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
+    Method(HRESULT, "UnregisterFontCollectionLoader", [(ObjPointer(IDWriteFontCollectionLoader), "fontCollectionLoader")]),
+    Method(HRESULT, "CreateFontFileReference", [(Pointer(Const(WCHAR)), "filePath"), (Pointer(Const(FILETIME)), "lastWriteTime"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
+    Method(HRESULT, "CreateCustomFontFileReference", [(OpaquePointer(Const(Void)), "fontFileReferenceKey"), (UINT32, "fontFileReferenceKeySize"), (ObjPointer(IDWriteFontFileLoader), "fontFileLoader"), Out(Pointer(ObjPointer(IDWriteFontFile)), "fontFile")]),
+    Method(HRESULT, "CreateFontFace", [(DWRITE_FONT_FACE_TYPE, "fontFaceType"), (UINT32, "numberOfFiles"), (Array(Const(ObjPointer(IDWriteFontFile)), "numberOfFiles"), "fontFiles"), (UINT32, "faceIndex"), (DWRITE_FONT_SIMULATIONS, "fontFaceSimulationFlags"), Out(Pointer(ObjPointer(IDWriteFontFace)), "fontFace")]),
+    Method(HRESULT, "CreateRenderingParams", [Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
+    Method(HRESULT, "CreateMonitorRenderingParams", [(HMONITOR, "monitor"), Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
+    Method(HRESULT, "CreateCustomRenderingParams", [(FLOAT, "gamma"), (FLOAT, "enhancedContrast"), (FLOAT, "clearTypeLevel"), (DWRITE_PIXEL_GEOMETRY, "pixelGeometry"), (DWRITE_RENDERING_MODE, "renderingMode"), Out(Pointer(ObjPointer(IDWriteRenderingParams)), "renderingParams")]),
+    Method(HRESULT, "RegisterFontFileLoader", [(ObjPointer(IDWriteFontFileLoader), "fontFileLoader")]),
+    Method(HRESULT, "UnregisterFontFileLoader", [(ObjPointer(IDWriteFontFileLoader), "fontFileLoader")]),
+    Method(HRESULT, "CreateTextFormat", [(Pointer(Const(WCHAR)), "fontFamilyName"), (ObjPointer(IDWriteFontCollection), "fontCollection"), (DWRITE_FONT_WEIGHT, "fontWeight"), (DWRITE_FONT_STYLE, "fontStyle"), (DWRITE_FONT_STRETCH, "fontStretch"), (FLOAT, "fontSize"), (Pointer(Const(WCHAR)), "localeName"), Out(Pointer(ObjPointer(IDWriteTextFormat)), "textFormat")]),
+    Method(HRESULT, "CreateTypography", [Out(Pointer(ObjPointer(IDWriteTypography)), "typography")]),
+    Method(HRESULT, "GetGdiInterop", [Out(Pointer(ObjPointer(IDWriteGdiInterop)), "gdiInterop")]),
+    Method(HRESULT, "CreateTextLayout", [(Pointer(Const(WCHAR)), "string"), (UINT32, "stringLength"), (ObjPointer(IDWriteTextFormat), "textFormat"), (FLOAT, "maxWidth"), (FLOAT, "maxHeight"), Out(Pointer(ObjPointer(IDWriteTextLayout)), "textLayout")]),
+    Method(HRESULT, "CreateGdiCompatibleTextLayout", [(Pointer(Const(WCHAR)), "string"), (UINT32, "stringLength"), (ObjPointer(IDWriteTextFormat), "textFormat"), (FLOAT, "layoutWidth"), (FLOAT, "layoutHeight"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (BOOL, "useGdiNatural"), Out(Pointer(ObjPointer(IDWriteTextLayout)), "textLayout")]),
+    Method(HRESULT, "CreateEllipsisTrimmingSign", [(ObjPointer(IDWriteTextFormat), "textFormat"), Out(Pointer(ObjPointer(IDWriteInlineObject)), "trimmingSign")]),
+    Method(HRESULT, "CreateTextAnalyzer", [Out(Pointer(ObjPointer(IDWriteTextAnalyzer)), "textAnalyzer")]),
+    Method(HRESULT, "CreateNumberSubstitution", [(DWRITE_NUMBER_SUBSTITUTION_METHOD, "substitutionMethod"), (Pointer(Const(WCHAR)), "localeName"), (BOOL, "ignoreUserOverride"), Out(Pointer(ObjPointer(IDWriteNumberSubstitution)), "numberSubstitution")]),
+    Method(HRESULT, "CreateGlyphRunAnalysis", [(Pointer(Const(DWRITE_GLYPH_RUN)), "glyphRun"), (FLOAT, "pixelsPerDip"), (Pointer(Const(DWRITE_MATRIX)), "transform"), (DWRITE_RENDERING_MODE, "renderingMode"), (DWRITE_MEASURING_MODE, "measuringMode"), (FLOAT, "baselineOriginX"), (FLOAT, "baselineOriginY"), Out(Pointer(ObjPointer(IDWriteGlyphRunAnalysis)), "glyphRunAnalysis")]),
 ]
 
 dwrite = API("dwrite")
 dwrite.addInterface(IDWriteFactory)
 dwrite.addFunctions([
-    StdFunction(HRESULT, "DWriteCreateFactory", [(DWRITE_FACTORY_TYPE, "factoryType"), (REFIID, "iid"), Out(Pointer(Pointer(IUnknown)), "factory")]),
+    StdFunction(HRESULT, "DWriteCreateFactory", [(DWRITE_FACTORY_TYPE, "factoryType"), (REFIID, "iid"), Out(Pointer(ObjPointer(IUnknown)), "factory")]),
 ])
index 8fef9bd532f9827ec543935e771ac5146a5f390a..5c7925e4427d62eec7a6a54f35e4453bfe9cbaff 100644 (file)
 #
 ##########################################################################/
 
-from dxgitype import *
-
-HMONITOR = Alias("HMONITOR", HANDLE)
-_LUID = Struct("_LUID", [
-    (DWORD, "LowPart"),
-    (LONG, "HighPart"),
-])
 
-DXGI_USAGE = Alias("DXGI_USAGE", UINT)
-DXGI_SWAP_EFFECT = Enum("DXGI_SWAP_EFFECT", [
-    "DXGI_SWAP_EFFECT_DISCARD",
-    "DXGI_SWAP_EFFECT_SEQUENTIAL",
-])
+from dxgitype import *
 
-DXGI_RESIDENCY = Enum("DXGI_RESIDENCY", [
-    "DXGI_RESIDENCY_FULLY_RESIDENT",
-    "DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY",
-    "DXGI_RESIDENCY_EVICTED_TO_DISK",
-])
 
-DXGI_SURFACE_DESC = Struct("DXGI_SURFACE_DESC", [
-    (UINT, "Width"),
-    (UINT, "Height"),
-    (DXGI_FORMAT, "Format"),
-    (DXGI_SAMPLE_DESC, "SampleDesc"),
-])
+IDXGIObject = Interface("IDXGIObject", IUnknown)
+IDXGIDeviceSubObject = Interface("IDXGIDeviceSubObject", IDXGIObject)
+IDXGIResource = Interface("IDXGIResource", IDXGIDeviceSubObject)
+IDXGIKeyedMutex = Interface("IDXGIKeyedMutex", IDXGIDeviceSubObject)
+IDXGISurface = Interface("IDXGISurface", IDXGIDeviceSubObject)
+IDXGISurface1 = Interface("IDXGISurface1", IDXGISurface)
+IDXGIAdapter = Interface("IDXGIAdapter", IDXGIObject)
+IDXGIOutput = Interface("IDXGIOutput", IDXGIObject)
+IDXGISwapChain = Interface("IDXGISwapChain", IDXGIDeviceSubObject)
+IDXGIFactory = Interface("IDXGIFactory", IDXGIObject)
+IDXGIDevice = Interface("IDXGIDevice", IDXGIObject)
+IDXGIFactory1 = Interface("IDXGIFactory1", IDXGIFactory)
+IDXGIAdapter1 = Interface("IDXGIAdapter1", IDXGIAdapter)
+IDXGIDevice1 = Interface("IDXGIDevice1", IDXGIDevice)
 
-DXGI_MAPPED_RECT = Struct("DXGI_MAPPED_RECT", [
-    (INT, "Pitch"),
-    (OpaquePointer(BYTE), "pBits"),
-])
 
-DXGI_OUTPUT_DESC = Struct("DXGI_OUTPUT_DESC", [
-    (WString, "DeviceName"),
-    (RECT, "DesktopCoordinates"),
-    (BOOL, "AttachedToDesktop"),
-    (DXGI_MODE_ROTATION, "Rotation"),
-    (HMONITOR, "Monitor"),
+DXGI_USAGE = Flags(UINT, [
+    "DXGI_CPU_ACCESS_NONE", # 0
+    "DXGI_CPU_ACCESS_SCRATCH", # 3
+    "DXGI_CPU_ACCESS_DYNAMIC", # 1
+    "DXGI_CPU_ACCESS_READ_WRITE", # 2
+    "DXGI_USAGE_SHADER_INPUT",
+    "DXGI_USAGE_RENDER_TARGET_OUTPUT",
+    "DXGI_USAGE_BACK_BUFFER",
+    "DXGI_USAGE_SHARED",
+    "DXGI_USAGE_READ_ONLY",
+    "DXGI_USAGE_DISCARD_ON_PRESENT",
+    "DXGI_USAGE_UNORDERED_ACCESS",
 ])
 
 DXGI_FRAME_STATISTICS = Struct("DXGI_FRAME_STATISTICS", [
@@ -71,6 +65,11 @@ DXGI_FRAME_STATISTICS = Struct("DXGI_FRAME_STATISTICS", [
     (LARGE_INTEGER, "SyncGPUTime"),
 ])
 
+DXGI_MAPPED_RECT = Struct("DXGI_MAPPED_RECT", [
+    (INT, "Pitch"),
+    (OpaquePointer(BYTE), "pBits"),
+])
+
 DXGI_ADAPTER_DESC = Struct("DXGI_ADAPTER_DESC", [
     (WString, "Description"),
     (UINT, "VendorId"),
@@ -83,7 +82,45 @@ DXGI_ADAPTER_DESC = Struct("DXGI_ADAPTER_DESC", [
     (LUID, "AdapterLuid"),
 ])
 
-DXGI_SWAP_CHAIN_FLAG = Enum("DXGI_SWAP_CHAIN_FLAG", [
+DXGI_OUTPUT_DESC = Struct("DXGI_OUTPUT_DESC", [
+    (WString, "DeviceName"),
+    (RECT, "DesktopCoordinates"),
+    (BOOL, "AttachedToDesktop"),
+    (DXGI_MODE_ROTATION, "Rotation"),
+    (HMONITOR, "Monitor"),
+])
+
+DXGI_SHARED_RESOURCE = Struct("DXGI_SHARED_RESOURCE", [
+    (HANDLE, "Handle"),
+])
+
+DXGI_RESOURCE_PRIORITY = FakeEnum(UINT, [
+    "DXGI_RESOURCE_PRIORITY_MINIMUM",
+    "DXGI_RESOURCE_PRIORITY_LOW",
+    "DXGI_RESOURCE_PRIORITY_NORMAL",
+    "DXGI_RESOURCE_PRIORITY_HIGH",
+    "DXGI_RESOURCE_PRIORITY_MAXIMUM",
+])
+
+DXGI_RESIDENCY = Enum("DXGI_RESIDENCY", [
+    "DXGI_RESIDENCY_FULLY_RESIDENT",
+    "DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY",
+    "DXGI_RESIDENCY_EVICTED_TO_DISK",
+])
+
+DXGI_SURFACE_DESC = Struct("DXGI_SURFACE_DESC", [
+    (UINT, "Width"),
+    (UINT, "Height"),
+    (DXGI_FORMAT, "Format"),
+    (DXGI_SAMPLE_DESC, "SampleDesc"),
+])
+
+DXGI_SWAP_EFFECT = Enum("DXGI_SWAP_EFFECT", [
+    "DXGI_SWAP_EFFECT_DISCARD",
+    "DXGI_SWAP_EFFECT_SEQUENTIAL",
+])
+
+DXGI_SWAP_CHAIN_FLAG = Flags(UINT, [
     "DXGI_SWAP_CHAIN_FLAG_NONPREROTATED",
     "DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH",
     "DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE",
@@ -97,87 +134,156 @@ DXGI_SWAP_CHAIN_DESC = Struct("DXGI_SWAP_CHAIN_DESC", [
     (HWND, "OutputWindow"),
     (BOOL, "Windowed"),
     (DXGI_SWAP_EFFECT, "SwapEffect"),
-    (UINT, "Flags"),
-])
-
-DXGI_SHARED_RESOURCE = Struct("DXGI_SHARED_RESOURCE", [
-    (HANDLE, "Handle"),
+    (DXGI_SWAP_CHAIN_FLAG, "Flags"),
 ])
 
-IDXGIObject = Interface("IDXGIObject", IUnknown)
 IDXGIObject.methods += [
-    Method(HRESULT, "SetPrivateData", [(REFGUID, "guid"), (UINT, "data_size"), (OpaquePointer(Const(Void)), "data")]),
-    Method(HRESULT, "SetPrivateDataInterface", [(REFGUID, "guid"), (OpaquePointer(Const(IUnknown)), "object")]),
-    Method(HRESULT, "GetPrivateData", [(REFGUID, "guid"), Out(Pointer(UINT), "data_size"), Out(OpaquePointer(Void), "data")]),
-    Method(HRESULT, "GetParent", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "parent")]),
+    StdMethod(HRESULT, "SetPrivateData", [(REFGUID, "Name"), (UINT, "DataSize"), (OpaqueBlob(Const(Void), "DataSize"), "pData")], sideeffects=False),
+    StdMethod(HRESULT, "SetPrivateDataInterface", [(REFGUID, "Name"), (OpaquePointer(Const(IUnknown)), "pUnknown")], sideeffects=False),
+    StdMethod(HRESULT, "GetPrivateData", [(REFGUID, "Name"), Out(Pointer(UINT), "pDataSize"), Out(OpaquePointer(Void), "pData")], sideeffects=False),
+    StdMethod(HRESULT, "GetParent", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppParent")]),
 ]
 
-IDXGIDeviceSubObject = Interface("IDXGIDeviceSubObject", IDXGIObject)
 IDXGIDeviceSubObject.methods += [
-    Method(HRESULT, "GetDevice", [(REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "device")]),
+    StdMethod(HRESULT, "GetDevice", [(REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppDevice")]),
 ]
 
-IDXGISurface = Interface("IDXGISurface", IDXGIDeviceSubObject)
+IDXGIResource.methods += [
+    StdMethod(HRESULT, "GetSharedHandle", [Out(Pointer(HANDLE), "pSharedHandle")]),
+    StdMethod(HRESULT, "GetUsage", [Out(Pointer(DXGI_USAGE), "pUsage")], sideeffects=False),
+    StdMethod(HRESULT, "SetEvictionPriority", [(DXGI_RESOURCE_PRIORITY, "EvictionPriority")]),
+    StdMethod(HRESULT, "GetEvictionPriority", [Out(Pointer(DXGI_RESOURCE_PRIORITY), "pEvictionPriority")], sideeffects=False),
+]
+
+IDXGIKeyedMutex.methods += [
+    StdMethod(HRESULT, "AcquireSync", [(UINT64, "Key"), (DWORD, "dwMilliseconds")]),
+    StdMethod(HRESULT, "ReleaseSync", [(UINT64, "Key")]),
+]
+
+DXGI_MAP = Flags(UINT, [
+    "DXGI_MAP_READ",
+    "DXGI_MAP_WRITE",
+    "DXGI_MAP_DISCARD",
+])
+
 IDXGISurface.methods += [
-    Method(HRESULT, "GetDesc", [Out(Pointer(DXGI_SURFACE_DESC), "desc")]),
-    Method(HRESULT, "Map", [Out(Pointer(DXGI_MAPPED_RECT), "mapped_rect"), (UINT, "flags")]),
-    Method(HRESULT, "Unmap", []),
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SURFACE_DESC), "pDesc")], sideeffects=False),
+    StdMethod(HRESULT, "Map", [Out(Pointer(DXGI_MAPPED_RECT), "pLockedRect"), (DXGI_MAP, "MapFlags")]),
+    StdMethod(HRESULT, "Unmap", []),
 ]
 
-IDXGIOutput = Interface("IDXGIOutput", IDXGIObject)
-IDXGIOutput.methods += [
-    Method(HRESULT, "GetDesc", [Out(Pointer(DXGI_OUTPUT_DESC), "desc")]),
-    Method(HRESULT, "GetDisplayModeList", [(DXGI_FORMAT, "format"), (UINT, "flags"), Out(Pointer(UINT), "mode_count"), Out(Array(DXGI_MODE_DESC, "*mode_count"), "desc")]),
-    Method(HRESULT, "FindClosestMatchingMode", [(Pointer(Const(DXGI_MODE_DESC)), "mode"), Out(Pointer(DXGI_MODE_DESC), "closest_match"), (Pointer(IUnknown), "device")]),
-    Method(HRESULT, "WaitForVBlank", []),
-    Method(HRESULT, "TakeOwnership", [(Pointer(IUnknown), "device"), (BOOL, "exclusive")]),
-    Method(Void, "ReleaseOwnership", []),
-    Method(HRESULT, "GetGammaControlCapabilities", [Out(Pointer(DXGI_GAMMA_CONTROL_CAPABILITIES), "gamma_caps")]),
-    Method(HRESULT, "SetGammaControl", [(Pointer(Const(DXGI_GAMMA_CONTROL)), "gamma_control")]),
-    Method(HRESULT, "GetGammaControl", [Out(Pointer(DXGI_GAMMA_CONTROL), "gamma_control")]),
-    Method(HRESULT, "SetDisplaySurface", [(Pointer(IDXGISurface), "surface")]),
-    Method(HRESULT, "GetDisplaySurfaceData", [(Pointer(IDXGISurface), "surface")]),
-    Method(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "stats")]),
+IDXGISurface1.methods += [
+    StdMethod(HRESULT, "GetDC", [(BOOL, "Discard"), Out(Pointer(HDC), "phdc")]),
+    StdMethod(HRESULT, "ReleaseDC", [(Pointer(RECT), "pDirtyRect")]),
 ]
 
-IDXGIAdapter = Interface("IDXGIAdapter", IDXGIObject)
 IDXGIAdapter.methods += [
-    Method(HRESULT, "EnumOutputs", [(UINT, "output_idx"), Out(Pointer(Pointer(IDXGIOutput)), "output")]),
-    Method(HRESULT, "GetDesc", [Out(Pointer(DXGI_ADAPTER_DESC), "desc")]),
-    Method(HRESULT, "CheckInterfaceSupport", [(REFGUID, "guid"), Out(Pointer(LARGE_INTEGER), "umd_version")]),
+    StdMethod(HRESULT, "EnumOutputs", [(UINT, "Output"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_ADAPTER_DESC), "pDesc")], sideeffects=False),
+    StdMethod(HRESULT, "CheckInterfaceSupport", [(REFGUID, "InterfaceName"), Out(Pointer(LARGE_INTEGER), "pUMDVersion")], sideeffects=False),
 ]
 
-IDXGISwapChain = Interface("IDXGISwapChain", IDXGIDeviceSubObject)
+DXGI_ENUM_MODES = Flags(UINT, [
+    "DXGI_ENUM_MODES_INTERLACED",
+    "DXGI_ENUM_MODES_SCALING",
+])
+
+IDXGIOutput.methods += [
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_OUTPUT_DESC), "pDesc")], sideeffects=False),
+    StdMethod(HRESULT, "GetDisplayModeList", [(DXGI_FORMAT, "EnumFormat"), (DXGI_ENUM_MODES, "Flags"), Out(Pointer(UINT), "pNumModes"), Out(Array(DXGI_MODE_DESC, "*pNumModes"), "pDesc")], sideeffects=False),
+    StdMethod(HRESULT, "FindClosestMatchingMode", [(Pointer(Const(DXGI_MODE_DESC)), "pModeToMatch"), Out(Pointer(DXGI_MODE_DESC), "pClosestMatch"), (ObjPointer(IUnknown), "pConcernedDevice")]),
+    StdMethod(HRESULT, "WaitForVBlank", []),
+    StdMethod(HRESULT, "TakeOwnership", [(ObjPointer(IUnknown), "pDevice"), (BOOL, "Exclusive")]),
+    StdMethod(Void, "ReleaseOwnership", []),
+    StdMethod(HRESULT, "GetGammaControlCapabilities", [Out(Pointer(DXGI_GAMMA_CONTROL_CAPABILITIES), "pGammaCaps")]),
+    StdMethod(HRESULT, "SetGammaControl", [(Pointer(Const(DXGI_GAMMA_CONTROL)), "pArray")]),
+    StdMethod(HRESULT, "GetGammaControl", [Out(Pointer(DXGI_GAMMA_CONTROL), "pArray")], sideeffects=False),
+    StdMethod(HRESULT, "SetDisplaySurface", [(ObjPointer(IDXGISurface), "pScanoutSurface")]),
+    StdMethod(HRESULT, "GetDisplaySurfaceData", [(ObjPointer(IDXGISurface), "pDestination")]),
+    StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
+]
+
+DXGI_PRESENT = Flags(UINT, [
+    "DXGI_PRESENT_TEST",
+    "DXGI_PRESENT_DO_NOT_SEQUENCE",
+    "DXGI_PRESENT_RESTART",
+])
+
 IDXGISwapChain.methods += [
-    Method(HRESULT, "Present", [(UINT, "sync_interval"), (UINT, "flags")]),
-    Method(HRESULT, "GetBuffer", [(UINT, "buffer_idx"), (REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "surface")]),
-    Method(HRESULT, "SetFullscreenState", [(BOOL, "fullscreen"), (Pointer(IDXGIOutput), "target")]),
-    Method(HRESULT, "GetFullscreenState", [Out(Pointer(BOOL), "fullscreen"), Out(Pointer(Pointer(IDXGIOutput)), "target")]),
-    Method(HRESULT, "GetDesc", [Out(Pointer(DXGI_SWAP_CHAIN_DESC), "desc")]),
-    Method(HRESULT, "ResizeBuffers", [(UINT, "buffer_count"), (UINT, "width"), (UINT, "height"), (DXGI_FORMAT, "format"), (UINT, "flags")]),
-    Method(HRESULT, "ResizeTarget", [(Pointer(Const(DXGI_MODE_DESC)), "target_mode_desc")]),
-    Method(HRESULT, "GetContainingOutput", [Out(Pointer(Pointer(IDXGIOutput)), "output")]),
-    Method(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "stats")]),
-    Method(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "last_present_count")]),
+    StdMethod(HRESULT, "Present", [(UINT, "SyncInterval"), (DXGI_PRESENT, "Flags")]),
+    StdMethod(HRESULT, "GetBuffer", [(UINT, "Buffer"), (REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppSurface")]),
+    StdMethod(HRESULT, "SetFullscreenState", [(BOOL, "Fullscreen"), (ObjPointer(IDXGIOutput), "pTarget")]),
+    StdMethod(HRESULT, "GetFullscreenState", [Out(Pointer(BOOL), "pFullscreen"), Out(Pointer(ObjPointer(IDXGIOutput)), "ppTarget")]),
+    StdMethod(HRESULT, "GetDesc", [Out(Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc")], sideeffects=False),
+    StdMethod(HRESULT, "ResizeBuffers", [(UINT, "BufferCount"), (UINT, "Width"), (UINT, "Height"), (DXGI_FORMAT, "NewFormat"), (UINT, "SwapChainFlags")]),
+    StdMethod(HRESULT, "ResizeTarget", [(Pointer(Const(DXGI_MODE_DESC)), "pNewTargetParameters")]),
+    StdMethod(HRESULT, "GetContainingOutput", [Out(Pointer(ObjPointer(IDXGIOutput)), "ppOutput")]),
+    StdMethod(HRESULT, "GetFrameStatistics", [Out(Pointer(DXGI_FRAME_STATISTICS), "pStats")], sideeffects=False),
+    StdMethod(HRESULT, "GetLastPresentCount", [Out(Pointer(UINT), "pLastPresentCount")], sideeffects=False),
 ]
 
-IDXGIFactory = Interface("IDXGIFactory", IDXGIObject)
+DXGI_MWA = Flags(UINT, [
+    "DXGI_MWA_NO_WINDOW_CHANGES",
+    "DXGI_MWA_NO_ALT_ENTER",
+    "DXGI_MWA_NO_PRINT_SCREEN",
+    "DXGI_MWA_VALID",
+])
+
 IDXGIFactory.methods += [
-    Method(HRESULT, "EnumAdapters", [(UINT, "adapter_idx"), Out(Pointer(Pointer(IDXGIAdapter)), "adapter")]),
-    Method(HRESULT, "MakeWindowAssociation", [(HWND, "window"), (UINT, "flags")]),
-    Method(HRESULT, "GetWindowAssociation", [Out(Pointer(HWND), "window")]),
-    Method(HRESULT, "CreateSwapChain", [(Pointer(IUnknown), "device"), (Pointer(DXGI_SWAP_CHAIN_DESC), "desc"), Out(Pointer(Pointer(IDXGISwapChain)), "swapchain")]),
-    Method(HRESULT, "CreateSoftwareAdapter", [(HMODULE, "swrast"), Out(Pointer(Pointer(IDXGIAdapter)), "adapter")]),
+    StdMethod(HRESULT, "EnumAdapters", [(UINT, "Adapter"), Out(Pointer(ObjPointer(IDXGIAdapter)), "ppAdapter")]),
+    StdMethod(HRESULT, "MakeWindowAssociation", [(HWND, "WindowHandle"), (DXGI_MWA, "Flags")]),
+    StdMethod(HRESULT, "GetWindowAssociation", [Out(Pointer(HWND), "pWindowHandle")], sideeffects=False),
+    StdMethod(HRESULT, "CreateSwapChain", [(ObjPointer(IUnknown), "pDevice"), (Pointer(DXGI_SWAP_CHAIN_DESC), "pDesc"), Out(Pointer(ObjPointer(IDXGISwapChain)), "ppSwapChain")]),
+    StdMethod(HRESULT, "CreateSoftwareAdapter", [(HMODULE, "Module"), Out(Pointer(ObjPointer(IDXGIAdapter)), "ppAdapter")]),
 ]
 
-#StdFunction(HRESULT, "CreateDXGIFactory", [(REFIID, "riid"), (Pointer(OpaquePointer(Void)), "factory")]),
-
-IDXGIDevice = Interface("IDXGIDevice", IDXGIObject)
 IDXGIDevice.methods += [
-    Method(HRESULT, "GetAdapter", [Out(Pointer(Pointer(IDXGIAdapter)), "adapter")]),
-    Method(HRESULT, "CreateSurface", [(Pointer(Const(DXGI_SURFACE_DESC)), "desc"), (UINT, "surface_count"), (DXGI_USAGE, "usage"), (Pointer(Const(DXGI_SHARED_RESOURCE)), "shared_resource"), Out(Pointer(Pointer(IDXGISurface)), "surface")]),
-    Method(HRESULT, "QueryResourceResidency", [(Array(Const(OpaquePointer(IUnknown)), "resource_count"), "resources"), Out(Array(DXGI_RESIDENCY, "resource_count"), "residency"), (UINT, "resource_count")]),
-    Method(HRESULT, "SetGPUThreadPriority", [(INT, "priority")]),
-    Method(HRESULT, "GetGPUThreadPriority", [Out(Pointer(INT), "priority")]),
+    StdMethod(HRESULT, "GetAdapter", [Out(Pointer(ObjPointer(IDXGIAdapter)), "pAdapter")]),
+    StdMethod(HRESULT, "CreateSurface", [(Pointer(Const(DXGI_SURFACE_DESC)), "pDesc"), (UINT, "NumSurfaces"), (DXGI_USAGE, "Usage"), (Pointer(Const(DXGI_SHARED_RESOURCE)), "pSharedResource"), Out(Pointer(ObjPointer(IDXGISurface)), "ppSurface")]),
+    StdMethod(HRESULT, "QueryResourceResidency", [(Array(Const(ObjPointer(IUnknown)), "NumResources"), "ppResources"), Out(Array(DXGI_RESIDENCY, "NumResources"), "pResidencyStatus"), (UINT, "NumResources")], sideeffects=False),
+    StdMethod(HRESULT, "SetGPUThreadPriority", [(INT, "Priority")]),
+    StdMethod(HRESULT, "GetGPUThreadPriority", [Out(Pointer(INT), "pPriority")], sideeffects=False),
 ]
 
+DXGI_ADAPTER_FLAG = Enum("DXGI_ADAPTER_FLAG", [
+    "DXGI_ADAPTER_FLAG_NONE",
+    "DXGI_ADAPTER_FLAG_REMOTE",
+])
+
+DXGI_ADAPTER_DESC1 = Struct("DXGI_ADAPTER_DESC1", [
+    (WString, "Description"),
+    (UINT, "VendorId"),
+    (UINT, "DeviceId"),
+    (UINT, "SubSysId"),
+    (UINT, "Revision"),
+    (SIZE_T, "DedicatedVideoMemory"),
+    (SIZE_T, "DedicatedSystemMemory"),
+    (SIZE_T, "SharedSystemMemory"),
+    (LUID, "AdapterLuid"),
+    (UINT, "Flags"),
+])
+
+DXGI_DISPLAY_COLOR_SPACE = Struct("DXGI_DISPLAY_COLOR_SPACE", [
+    (Array(Array(FLOAT, 8), 2), "PrimaryCoordinates"),
+    (Array(Array(FLOAT, 16), 2), "WhitePoints"),
+])
+
+IDXGIFactory1.methods += [
+    StdMethod(HRESULT, "EnumAdapters1", [(UINT, "Adapter"), Out(Pointer(ObjPointer(IDXGIAdapter1)), "ppAdapter")]),
+    StdMethod(BOOL, "IsCurrent", []),
+]
+
+IDXGIAdapter1.methods += [
+    StdMethod(HRESULT, "GetDesc1", [Out(Pointer(DXGI_ADAPTER_DESC1), "pDesc")], sideeffects=False),
+]
+
+IDXGIDevice1.methods += [
+    StdMethod(HRESULT, "SetMaximumFrameLatency", [(UINT, "MaxLatency")]),
+    StdMethod(HRESULT, "GetMaximumFrameLatency", [Out(Pointer(UINT), "pMaxLatency")], sideeffects=False),
+]
+
+dxgi = API('dxgi')
+dxgi.addFunctions([
+    StdFunction(HRESULT, "CreateDXGIFactory", [(REFIID, "riid"), (Pointer(ObjPointer(Void)), "ppFactory")]),
+    StdFunction(HRESULT, "CreateDXGIFactory1", [(REFIID, "riid"), (Pointer(ObjPointer(Void)), "ppFactory")]),
+])
index 9b1326e996687e0cd19f6acdf6201f42ce3e37d2..b2d2a75e4ac9d511c484dc56aae74f8ebd75ddfd 100644 (file)
 #
 ##########################################################################/
 
+
 from winapi import *
 
+
 DXGI_FORMAT = Enum("DXGI_FORMAT", [
     "DXGI_FORMAT_UNKNOWN",
     "DXGI_FORMAT_R32G32B32A32_TYPELESS",
index f5237c9e8038c68ace806f44156855137ecfb26a..c6202b58588d1ac9a088bf5f390e67d2d613c4a9 100644 (file)
 #
 ##########################################################################/
 
+
 from dxgiformat import *
 
+
+HRESULT = MAKE_HRESULT([
+    "DXGI_STATUS_OCCLUDED",
+    "DXGI_STATUS_CLIPPED",
+    "DXGI_STATUS_NO_REDIRECTION",
+    "DXGI_STATUS_NO_DESKTOP_ACCESS",
+    "DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE",
+    "DXGI_STATUS_MODE_CHANGED",
+    "DXGI_STATUS_MODE_CHANGE_IN_PROGRESS",
+    "DXGI_ERROR_INVALID_CALL",
+    "DXGI_ERROR_NOT_FOUND",
+    "DXGI_ERROR_MORE_DATA",
+    "DXGI_ERROR_UNSUPPORTED",
+    "DXGI_ERROR_DEVICE_REMOVED",
+    "DXGI_ERROR_DEVICE_HUNG",
+    "DXGI_ERROR_DEVICE_RESET",
+    "DXGI_ERROR_WAS_STILL_DRAWING",
+    "DXGI_ERROR_FRAME_STATISTICS_DISJOINT",
+    "DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE",
+    "DXGI_ERROR_DRIVER_INTERNAL_ERROR",
+    "DXGI_ERROR_NONEXCLUSIVE",
+    "DXGI_ERROR_NOT_CURRENTLY_AVAILABLE",
+    "DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED",
+    "DXGI_ERROR_REMOTE_OUTOFMEMORY",
+])
+
+
 DXGI_RGB = Struct("DXGI_RGB", [
     (Float, "Red"),
     (Float, "Green"),
index fabe5bd2e5190925420882429c07910fb0a66347..74584784fac766cd5c3770e1d3326d304564a63a 100644 (file)
@@ -291,9 +291,9 @@ EGLuint64NV = Alias("EGLuint64NV", UInt64)
 
 eglapi = API("EGL")
 
-EGLAttribList = Array(Const(EGLattrib), "__AttribPairList_size(attrib_list, EGL_NONE)")
+EGLAttribList = Array(Const(EGLattrib), "_AttribPairList_size(attrib_list, EGL_NONE)")
 
-PROC = Opaque("__eglMustCastToProperFunctionPointerType")
+EGLProc = Opaque("__eglMustCastToProperFunctionPointerType")
 
 def GlFunction(*args, **kwargs):
     kwargs.setdefault('call', 'GL_APIENTRY')
@@ -307,7 +307,7 @@ eglapi.addFunctions([
     Function(EGLBoolean, "eglInitialize", [(EGLDisplay, "dpy"), Out(Pointer(EGLint), "major"), Out(Pointer(EGLint), "minor")]),
     Function(EGLBoolean, "eglTerminate", [(EGLDisplay, "dpy")]),
 
-    Function(Const(String("char *")), "eglQueryString", [(EGLDisplay, "dpy"), (EGLName, "name")], sideeffects=False),
+    Function(ConstCString, "eglQueryString", [(EGLDisplay, "dpy"), (EGLName, "name")], sideeffects=False),
 
     Function(EGLBoolean, "eglGetConfigs", [(EGLDisplay, "dpy"), (Array(EGLConfig, "config_size"), "configs"), (EGLint, "config_size"), Out(Pointer(EGLint), "num_config")]),
     Function(EGLBoolean, "eglChooseConfig", [(EGLDisplay, "dpy"), (EGLAttribList, "attrib_list"), (Array(EGLConfig, "config_size"), "configs"), (EGLint, "config_size"), Out(Pointer(EGLint), "num_config")]),
@@ -349,7 +349,7 @@ eglapi.addFunctions([
     Function(EGLBoolean, "eglSwapBuffers", [(EGLDisplay, "dpy"), (EGLSurface, "surface")]),
     Function(EGLBoolean, "eglCopyBuffers", [(EGLDisplay, "dpy"), (EGLSurface, "surface"), (EGLNativePixmapType, "target")]),
 
-    Function(PROC, "eglGetProcAddress", [(Const(CString), "procname")]),
+    Function(EGLProc, "eglGetProcAddress", [(ConstCString, "procname")]),
 
     # EGL_KHR_lock_surface
     Function(EGLBoolean, "eglLockSurfaceKHR", [(EGLDisplay, "display"), (EGLSurface, "surface"), (EGLAttribList, "attrib_list")]),
index 886da1cd84f693a62dc688db5ea1947c46b55b52..fa7e91e9900bb50bfcc134217da1ab5602e3098d 100644 (file)
@@ -57,16 +57,16 @@ glapi.addFunctions([
     GlFunction(Void, "glPolygonMode", [(GLenum, "face"), (GLenum, "mode")]),
     GlFunction(Void, "glScissor", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glTexParameterf", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glTexParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexParameteri", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glTexParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glTexImage1D", [(GLenum, "target"), (GLint, "level"), (GLenum_int, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexImage1D_size(format, type, width)"), "pixels")]),
-    GlFunction(Void, "glTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLenum_int, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexImage2D_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glTexParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexImage1D", [(GLenum, "target"), (GLint, "level"), (GLenum_int, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexImage1D_size(format, type, width)"), "pixels")]),
+    GlFunction(Void, "glTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLenum_int, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexImage2D_size(format, type, width, height)"), "pixels")]),
     GlFunction(Void, "glDrawBuffer", [(GLenum, "mode")]),
     GlFunction(Void, "glClear", [(GLbitfield_attrib, "mask")]),
-    GlFunction(Void, "glClearColor", [(GLclampf, "red"), (GLclampf, "green"), (GLclampf, "blue"), (GLclampf, "alpha")]),
+    GlFunction(Void, "glClearColor", [(GLfloat, "red"), (GLfloat, "green"), (GLfloat, "blue"), (GLfloat, "alpha")]),
     GlFunction(Void, "glClearStencil", [(GLint, "s")]),
-    GlFunction(Void, "glClearDepth", [(GLclampd, "depth")]),
+    GlFunction(Void, "glClearDepth", [(GLdouble, "depth")]),
     GlFunction(Void, "glStencilMask", [(GLuint, "mask")]),
     GlFunction(Void, "glColorMask", [(GLboolean, "red"), (GLboolean, "green"), (GLboolean, "blue"), (GLboolean, "alpha")]),
     GlFunction(Void, "glDepthMask", [(GLboolean, "flag")]),
@@ -83,31 +83,31 @@ glapi.addFunctions([
     GlFunction(Void, "glPixelStorei", [(GLenum, "pname"), (GLint, "param")]),
     GlFunction(Void, "glReadBuffer", [(GLenum, "mode")]),
     GlFunction(Void, "glReadPixels", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), Out(GLpointer, "pixels")]),
-    GlFunction(Void, "glGetBooleanv", [(GLenum, "pname"), Out(Array(GLboolean, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetDoublev", [(GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetBooleanv", [(GLenum, "pname"), Out(Array(GLboolean, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetDoublev", [(GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLenum_error, "glGetError", [], sideeffects=False),
-    GlFunction(Void, "glGetFloatv", [(GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetIntegerv", [(GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(String("const GLubyte *"), "glGetString", [(GLenum, "name")], sideeffects=False),
+    GlFunction(Void, "glGetFloatv", [(GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetIntegerv", [(GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(String(Const(GLubyte)), "glGetString", [(GLenum, "name")], sideeffects=False),
     GlFunction(Void, "glGetTexImage", [(GLenum, "target"), (GLint, "level"), (GLenum, "format"), (GLenum, "type"), Out(GLpointer, "pixels")]),
-    GlFunction(Void, "glGetTexParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexLevelParameterfv", [(GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexLevelParameteriv", [(GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexLevelParameterfv", [(GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexLevelParameteriv", [(GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLboolean, "glIsEnabled", [(GLenum, "cap")], sideeffects=False),
-    GlFunction(Void, "glDepthRange", [(GLclampd, "zNear"), (GLclampd, "zFar")]),
+    GlFunction(Void, "glDepthRange", [(GLdouble, "zNear"), (GLdouble, "zFar")]),
     GlFunction(Void, "glViewport", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
 
     # GL_VERSION_1_0_DEPRECATED
     GlFunction(Void, "glNewList", [(GLlist, "list"), (GLenum, "mode")]),
     GlFunction(Void, "glEndList", []),
     GlFunction(Void, "glCallList", [(GLlist, "list")]),
-    GlFunction(Void, "glCallLists", [(GLsizei, "n"), (GLenum, "type"), (Blob(Const(GLvoid), "__glCallLists_size(n, type)"), "lists")]),
+    GlFunction(Void, "glCallLists", [(GLsizei, "n"), (GLenum, "type"), (Blob(Const(GLvoid), "_glCallLists_size(n, type)"), "lists")]),
     GlFunction(Void, "glDeleteLists", [(GLlist, "list"), (GLsizei, "range")]),
     GlFunction(Handle("list", GLuint, "range"), "glGenLists", [(GLsizei, "range")]),
     GlFunction(Void, "glListBase", [(GLuint, "base")]),
     GlFunction(Void, "glBegin", [(GLenum_mode, "mode")]),
-    GlFunction(Void, "glBitmap", [(GLsizei, "width"), (GLsizei, "height"), (GLfloat, "xorig"), (GLfloat, "yorig"), (GLfloat, "xmove"), (GLfloat, "ymove"), (Blob(Const(GLubyte), "__glBitmap_size(width, height)"), "bitmap")]),
+    GlFunction(Void, "glBitmap", [(GLsizei, "width"), (GLsizei, "height"), (GLfloat, "xorig"), (GLfloat, "yorig"), (GLfloat, "xmove"), (GLfloat, "ymove"), (Blob(Const(GLubyte), "_glBitmap_size(width, height)"), "bitmap")]),
     GlFunction(Void, "glColor3b", [(GLbyte, "red"), (GLbyte, "green"), (GLbyte, "blue")]),
     GlFunction(Void, "glColor3bv", [(Array(Const(GLbyte), 3), "v")]),
     GlFunction(Void, "glColor3d", [(GLdouble, "red"), (GLdouble, "green"), (GLdouble, "blue")]),
@@ -252,34 +252,34 @@ glapi.addFunctions([
     GlFunction(Void, "glClipPlane", [(GLenum, "plane"), (Array(Const(GLdouble), 4), "equation")]),
     GlFunction(Void, "glColorMaterial", [(GLenum, "face"), (GLenum, "mode")]),
     GlFunction(Void, "glFogf", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glFogfv", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFogfv", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFogi", [(GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glFogiv", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFogiv", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glLightf", [(GLenum, "light"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glLightfv", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glLightfv", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glLighti", [(GLenum, "light"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glLightiv", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glLightiv", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glLightModelf", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glLightModelfv", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glLightModelfv", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glLightModeli", [(GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glLightModeliv", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glLightModeliv", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glLineStipple", [(GLint, "factor"), (GLushort, "pattern")]),
     GlFunction(Void, "glMaterialf", [(GLenum, "face"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glMaterialfv", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMaterialfv", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glMateriali", [(GLenum, "face"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glMaterialiv", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glPolygonStipple", [(Array(Const(GLubyte), "__glPolygonStipple_size()"), "mask")]),
+    GlFunction(Void, "glMaterialiv", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPolygonStipple", [(Array(Const(GLubyte), "_glPolygonStipple_size()"), "mask")]),
     GlFunction(Void, "glShadeModel", [(GLenum, "mode")]),
     GlFunction(Void, "glTexEnvf", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glTexEnvfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexEnvfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexEnvi", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glTexEnviv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexEnviv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexGend", [(GLenum, "coord"), (GLenum, "pname"), (GLdouble, "param")]),
-    GlFunction(Void, "glTexGendv", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLdouble), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexGendv", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLdouble), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexGenf", [(GLenum, "coord"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glTexGenfv", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexGenfv", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexGeni", [(GLenum, "coord"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glTexGeniv", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexGeniv", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFeedbackBuffer", [(GLsizei, "size"), (GLenum, "type"), Out(Array(GLfloat, "size"), "buffer")]),
     GlFunction(Void, "glSelectBuffer", [(GLsizei, "size"), Out(Array(GLuint, "size"), "buffer")]),
     GlFunction(Alias("GLint", GLenum), "glRenderMode", [(GLenum, "mode")]),
@@ -294,10 +294,10 @@ glapi.addFunctions([
     GlFunction(Void, "glAccum", [(GLenum, "op"), (GLfloat, "value")]),
     GlFunction(Void, "glPopAttrib", []),
     GlFunction(Void, "glPushAttrib", [(GLbitfield_attrib, "mask")]),
-    GlFunction(Void, "glMap1d", [(GLenum, "target"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "stride"), (GLint, "order"), (Array(Const(GLdouble), "__glMap1d_size(target, stride, order)"), "points")]),
-    GlFunction(Void, "glMap1f", [(GLenum, "target"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "stride"), (GLint, "order"), (Array(Const(GLfloat), "__glMap1f_size(target, stride, order)"), "points")]),
-    GlFunction(Void, "glMap2d", [(GLenum, "target"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLdouble, "v1"), (GLdouble, "v2"), (GLint, "vstride"), (GLint, "vorder"), (Array(Const(GLdouble), "__glMap2d_size(target, ustride, uorder, vstride, vorder)"), "points")]),
-    GlFunction(Void, "glMap2f", [(GLenum, "target"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLfloat, "v1"), (GLfloat, "v2"), (GLint, "vstride"), (GLint, "vorder"), (Array(Const(GLfloat), "__glMap2f_size(target, ustride, uorder, vstride, vorder)"), "points")]),
+    GlFunction(Void, "glMap1d", [(GLenum, "target"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "stride"), (GLint, "order"), (Array(Const(GLdouble), "_glMap1d_size(target, stride, order)"), "points")]),
+    GlFunction(Void, "glMap1f", [(GLenum, "target"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "stride"), (GLint, "order"), (Array(Const(GLfloat), "_glMap1f_size(target, stride, order)"), "points")]),
+    GlFunction(Void, "glMap2d", [(GLenum, "target"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLdouble, "v1"), (GLdouble, "v2"), (GLint, "vstride"), (GLint, "vorder"), (Array(Const(GLdouble), "_glMap2d_size(target, ustride, uorder, vstride, vorder)"), "points")]),
+    GlFunction(Void, "glMap2f", [(GLenum, "target"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLfloat, "v1"), (GLfloat, "v2"), (GLint, "vstride"), (GLint, "vorder"), (Array(Const(GLfloat), "_glMap2f_size(target, ustride, uorder, vstride, vorder)"), "points")]),
     GlFunction(Void, "glMapGrid1d", [(GLint, "un"), (GLdouble, "u1"), (GLdouble, "u2")]),
     GlFunction(Void, "glMapGrid1f", [(GLint, "un"), (GLfloat, "u1"), (GLfloat, "u2")]),
     GlFunction(Void, "glMapGrid2d", [(GLint, "un"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "vn"), (GLdouble, "v1"), (GLdouble, "v2")]),
@@ -314,7 +314,7 @@ glapi.addFunctions([
     GlFunction(Void, "glEvalPoint1", [(GLint, "i")]),
     GlFunction(Void, "glEvalMesh2", [(GLenum, "mode"), (GLint, "i1"), (GLint, "i2"), (GLint, "j1"), (GLint, "j2")]),
     GlFunction(Void, "glEvalPoint2", [(GLint, "i"), (GLint, "j")]),
-    GlFunction(Void, "glAlphaFunc", [(GLenum, "func"), (GLclampf, "ref")]),
+    GlFunction(Void, "glAlphaFunc", [(GLenum, "func"), (GLfloat, "ref")]),
     GlFunction(Void, "glPixelZoom", [(GLfloat, "xfactor"), (GLfloat, "yfactor")]),
     GlFunction(Void, "glPixelTransferf", [(GLenum, "pname"), (GLfloat, "param")]),
     GlFunction(Void, "glPixelTransferi", [(GLenum, "pname"), (GLint, "param")]),
@@ -322,24 +322,24 @@ glapi.addFunctions([
     GlFunction(Void, "glPixelMapuiv", [(GLenum, "map"), (GLsizei, "mapsize"), (Array(Const(GLuint), "mapsize"), "values")]),
     GlFunction(Void, "glPixelMapusv", [(GLenum, "map"), (GLsizei, "mapsize"), (Array(Const(GLushort), "mapsize"), "values")]),
     GlFunction(Void, "glCopyPixels", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "type")]),
-    GlFunction(Void, "glDrawPixels", [(GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glDrawPixels_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glDrawPixels", [(GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glDrawPixels_size(format, type, width, height)"), "pixels")]),
     GlFunction(Void, "glGetClipPlane", [(GLenum, "plane"), Out(Array(GLdouble, 4), "equation")], sideeffects=False),
-    GlFunction(Void, "glGetLightfv", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetLightiv", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetLightfv", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetLightiv", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetMapdv", [(GLenum, "target"), (GLenum, "query"), Out(Pointer(GLdouble), "v")], sideeffects=False),
     GlFunction(Void, "glGetMapfv", [(GLenum, "target"), (GLenum, "query"), Out(Pointer(GLfloat), "v")], sideeffects=False),
     GlFunction(Void, "glGetMapiv", [(GLenum, "target"), (GLenum, "query"), Out(Pointer(GLint), "v")], sideeffects=False),
-    GlFunction(Void, "glGetMaterialfv", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMaterialiv", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMaterialfv", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMaterialiv", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetPixelMapfv", [(GLenum, "map"), Out(Pointer(GLfloat), "values")]),
     GlFunction(Void, "glGetPixelMapuiv", [(GLenum, "map"), Out(Pointer(GLuint), "values")]),
     GlFunction(Void, "glGetPixelMapusv", [(GLenum, "map"), Out(Pointer(GLushort), "values")]),
     GlFunction(Void, "glGetPolygonStipple", [Out(OpaquePointer(GLubyte), "mask")]),
-    GlFunction(Void, "glGetTexEnvfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexEnviv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexGendv", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexGenfv", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexGeniv", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexEnvfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexEnviv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexGendv", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexGenfv", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexGeniv", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLboolean, "glIsList", [(GLuint, "list")], sideeffects=False),
     GlFunction(Void, "glFrustum", [(GLdouble, "left"), (GLdouble, "right"), (GLdouble, "bottom"), (GLdouble, "top"), (GLdouble, "zNear"), (GLdouble, "zFar")]),
     GlFunction(Void, "glLoadIdentity", []),
@@ -367,8 +367,8 @@ glapi.addFunctions([
     GlFunction(Void, "glCopyTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border")]),
     GlFunction(Void, "glCopyTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
     GlFunction(Void, "glCopyTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexSubImage1D_size(format, type, width)"), "pixels")]),
-    GlFunction(Void, "glTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexSubImage2D_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexSubImage1D_size(format, type, width)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexSubImage2D_size(format, type, width, height)"), "pixels")]),
     GlFunction(Void, "glBindTexture", [(GLenum, "target"), (GLtexture, "texture")]),
     GlFunction(Void, "glDeleteTextures", [(GLsizei, "n"), (Array(Const(GLtexture), "n"), "textures")]),
     GlFunction(Void, "glGenTextures", [(GLsizei, "n"), Out(Array(GLtexture, "n"), "textures")]),
@@ -393,42 +393,42 @@ glapi.addFunctions([
     GlFunction(Void, "glPushClientAttrib", [(GLbitfield_client_attrib, "mask")]),
 
     # GL_VERSION_1_2
-    GlFunction(Void, "glBlendColor", [(GLclampf, "red"), (GLclampf, "green"), (GLclampf, "blue"), (GLclampf, "alpha")]),
+    GlFunction(Void, "glBlendColor", [(GLfloat, "red"), (GLfloat, "green"), (GLfloat, "blue"), (GLfloat, "alpha")]),
     GlFunction(Void, "glBlendEquation", [(GLenum, "mode")]),
     GlFunction(Void, "glDrawRangeElements", [(GLenum_mode, "mode"), (GLuint, "start"), (GLuint, "end"), (GLsizei, "count"), (GLenum, "type"), (GLpointerConst, "indices")]),
-    GlFunction(Void, "glTexImage3D", [(GLenum, "target"), (GLint, "level"), (GLenum_int, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexImage3D_size(format, type, width, height, depth)"), "pixels")]),
-    GlFunction(Void, "glTexSubImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexSubImage3D_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glTexImage3D", [(GLenum, "target"), (GLint, "level"), (GLenum_int, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexImage3D_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexSubImage3D_size(format, type, width, height, depth)"), "pixels")]),
     GlFunction(Void, "glCopyTexSubImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
 
     # GL_VERSION_1_2_DEPRECATED
-    GlFunction(Void, "glColorTable", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glColorTable_size(format, type, width)"), "table")]),
-    GlFunction(Void, "glColorTableParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glColorTableParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glColorTable", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glColorTable_size(format, type, width)"), "table")]),
+    GlFunction(Void, "glColorTableParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glColorTableParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glCopyColorTable", [(GLenum, "target"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
-    GlFunction(Void, "glGetColorTable", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetColorTable_size(target, format, type)"), "table")], sideeffects=False),
-    GlFunction(Void, "glGetColorTableParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetColorTableParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glColorSubTable", [(GLenum, "target"), (GLsizei, "start"), (GLsizei, "count"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glColorSubTable_size(format, type, count)"), "data")]),
+    GlFunction(Void, "glGetColorTable", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetColorTable_size(target, format, type)"), "table")], sideeffects=False),
+    GlFunction(Void, "glGetColorTableParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetColorTableParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glColorSubTable", [(GLenum, "target"), (GLsizei, "start"), (GLsizei, "count"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glColorSubTable_size(format, type, count)"), "data")]),
     GlFunction(Void, "glCopyColorSubTable", [(GLenum, "target"), (GLsizei, "start"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
-    GlFunction(Void, "glConvolutionFilter1D", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glConvolutionFilter1D_size(format, type, width)"), "image")]),
-    GlFunction(Void, "glConvolutionFilter2D", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glConvolutionFilter2D_size(format, type, width, height)"), "image")]),
+    GlFunction(Void, "glConvolutionFilter1D", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glConvolutionFilter1D_size(format, type, width)"), "image")]),
+    GlFunction(Void, "glConvolutionFilter2D", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glConvolutionFilter2D_size(format, type, width, height)"), "image")]),
     GlFunction(Void, "glConvolutionParameterf", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "params")]),
-    GlFunction(Void, "glConvolutionParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glConvolutionParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glConvolutionParameteri", [(GLenum, "target"), (GLenum, "pname"), (GLint, "params")]),
-    GlFunction(Void, "glConvolutionParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glConvolutionParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glCopyConvolutionFilter1D", [(GLenum, "target"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
     GlFunction(Void, "glCopyConvolutionFilter2D", [(GLenum, "target"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetConvolutionFilter", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetConvolutionFilter_size(target, format, type)"), "image")]),
-    GlFunction(Void, "glGetConvolutionParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetConvolutionParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetSeparableFilter", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetSeparableFilter_size(target, format, type)"), "row"), Out(OpaqueBlob(GLvoid, "__glGetSeparableFilter_size(target, format, type)"), "column"), Out(GLpointer, "span")]),
-    GlFunction(Void, "glSeparableFilter2D", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glConvolutionFilter1D_size(format, type, width)"), "row"), (Blob(Const(GLvoid), "__glConvolutionFilter1D_size(format, type, height)"), "column")]),
-    GlFunction(Void, "glGetHistogram", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetHistogram_size(target, format, type)"), "values")]),
-    GlFunction(Void, "glGetHistogramParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetHistogramParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMinmax", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetMinmax_size(target, format, type)"), "values")]),
-    GlFunction(Void, "glGetMinmaxParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMinmaxParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetConvolutionFilter", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetConvolutionFilter_size(target, format, type)"), "image")]),
+    GlFunction(Void, "glGetConvolutionParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetConvolutionParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetSeparableFilter", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetSeparableFilter_size(target, format, type)"), "row"), Out(OpaqueBlob(GLvoid, "_glGetSeparableFilter_size(target, format, type)"), "column"), Out(GLpointer, "span")]),
+    GlFunction(Void, "glSeparableFilter2D", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glConvolutionFilter1D_size(format, type, width)"), "row"), (Blob(Const(GLvoid), "_glConvolutionFilter1D_size(format, type, height)"), "column")]),
+    GlFunction(Void, "glGetHistogram", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetHistogram_size(target, format, type)"), "values")]),
+    GlFunction(Void, "glGetHistogramParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetHistogramParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMinmax", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetMinmax_size(target, format, type)"), "values")]),
+    GlFunction(Void, "glGetMinmaxParameterfv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMinmaxParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glHistogram", [(GLenum, "target"), (GLsizei, "width"), (GLenum, "internalformat"), (GLboolean, "sink")]),
     GlFunction(Void, "glMinmax", [(GLenum, "target"), (GLenum, "internalformat"), (GLboolean, "sink")]),
     GlFunction(Void, "glResetHistogram", [(GLenum, "target")]),
@@ -436,14 +436,14 @@ glapi.addFunctions([
 
     # GL_VERSION_1_3
     GlFunction(Void, "glActiveTexture", [(GLenum, "texture")]),
-    GlFunction(Void, "glSampleCoverage", [(GLclampf, "value"), (GLboolean, "invert")]),
+    GlFunction(Void, "glSampleCoverage", [(GLfloat, "value"), (GLboolean, "invert")]),
     GlFunction(Void, "glCompressedTexImage3D", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
     GlFunction(Void, "glCompressedTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
     GlFunction(Void, "glCompressedTexImage1D", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
     GlFunction(Void, "glCompressedTexSubImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
     GlFunction(Void, "glCompressedTexSubImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
     GlFunction(Void, "glCompressedTexSubImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
-    GlFunction(Void, "glGetCompressedTexImage", [(GLenum, "target"), (GLint, "level"), Out(OpaqueBlob(GLvoid, "__glGetCompressedTexImage_size(target, level)"), "img")]),
+    GlFunction(Void, "glGetCompressedTexImage", [(GLenum, "target"), (GLint, "level"), Out(OpaqueBlob(GLvoid, "_glGetCompressedTexImage_size(target, level)"), "img")]),
 
     # GL_VERSION_1_3_DEPRECATED
     GlFunction(Void, "glClientActiveTexture", [(GLenum, "texture")]),
@@ -486,12 +486,12 @@ glapi.addFunctions([
 
     # GL_VERSION_1_4
     GlFunction(Void, "glBlendFuncSeparate", [(GLenum, "sfactorRGB"), (GLenum, "dfactorRGB"), (GLenum, "sfactorAlpha"), (GLenum, "dfactorAlpha")]),
-    GlFunction(Void, "glMultiDrawArrays", [(GLenum_mode, "mode"), (Array(Const(GLint), "primcount"), "first"), (Array(Const(GLsizei), "primcount"), "count"), (GLsizei, "primcount")]),
-    GlFunction(Void, "glMultiDrawElements", [(GLenum_mode, "mode"), (Array(Const(GLsizei), "primcount"), "count"), (GLenum, "type"), (Array(GLpointerConst, "primcount"), "indices"), (GLsizei, "primcount")]),
+    GlFunction(Void, "glMultiDrawArrays", [(GLenum_mode, "mode"), (Array(Const(GLint), "drawcount"), "first"), (Array(Const(GLsizei), "drawcount"), "count"), (GLsizei, "drawcount")]),
+    GlFunction(Void, "glMultiDrawElements", [(GLenum_mode, "mode"), (Array(Const(GLsizei), "drawcount"), "count"), (GLenum, "type"), (Array(Const(GLpointerConst), "drawcount"), "indices"), (GLsizei, "drawcount")]),
     GlFunction(Void, "glPointParameterf", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glPointParameterfv", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPointParameterfv", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glPointParameteri", [(GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glPointParameteriv", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPointParameteriv", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
 
     # GL_VERSION_1_4_DEPRECATED
     GlFunction(Void, "glFogCoordf", [(GLfloat, "coord")]),
@@ -539,19 +539,19 @@ glapi.addFunctions([
     GlFunction(GLboolean, "glIsQuery", [(GLquery, "id")], sideeffects=False),
     GlFunction(Void, "glBeginQuery", [(GLenum, "target"), (GLquery, "id")]),
     GlFunction(Void, "glEndQuery", [(GLenum, "target")]),
-    GlFunction(Void, "glGetQueryiv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetQueryObjectiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetQueryObjectuiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryiv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjectiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjectuiv", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glBindBuffer", [(GLenum, "target"), (GLbuffer, "buffer")]),
     GlFunction(Void, "glDeleteBuffers", [(GLsizei, "n"), (Array(Const(GLbuffer), "n"), "buffer")]),
     GlFunction(Void, "glGenBuffers", [(GLsizei, "n"), Out(Array(GLbuffer, "n"), "buffer")]),
     GlFunction(GLboolean, "glIsBuffer", [(GLbuffer, "buffer")], sideeffects=False),
     GlFunction(Void, "glBufferData", [(GLenum, "target"), (GLsizeiptr, "size"), (Blob(Const(GLvoid), "size"), "data"), (GLenum, "usage")]),
     GlFunction(Void, "glBufferSubData", [(GLenum, "target"), (GLintptr, "offset"), (GLsizeiptr, "size"), (Blob(Const(GLvoid), "size"), "data")]),
-    GlFunction(Void, "glGetBufferSubData", [(GLenum, "target"), (GLintptr, "offset"), (GLsizeiptr, "size"), Out(Blob(GLvoid, "size"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetBufferSubData", [(GLenum, "target"), (GLintptr, "offset"), (GLsizeiptr, "size"), Out(OpaqueBlob(GLvoid, "size"), "data")], sideeffects=False),
     GlFunction(GLmap, "glMapBuffer", [(GLenum, "target"), (GLenum, "access")]),
     GlFunction(GLboolean, "glUnmapBuffer", [(GLenum, "target")]),
-    GlFunction(Void, "glGetBufferParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetBufferParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetBufferPointerv", [(GLenum, "target"), (GLenum, "pname"), Out(Pointer(GLpointer), "params")], sideeffects=False),
 
     # GL_VERSION_2_0
@@ -561,7 +561,7 @@ glapi.addFunctions([
     GlFunction(Void, "glStencilFuncSeparate", [(GLenum, "face"), (GLenum, "func"), (GLint, "ref"), (GLuint, "mask")]),
     GlFunction(Void, "glStencilMaskSeparate", [(GLenum, "face"), (GLuint, "mask")]),
     GlFunction(Void, "glAttachShader", [(GLprogram, "program"), (GLshader, "shader")]),
-    GlFunction(Void, "glBindAttribLocation", [(GLprogram, "program"), (GLuint, "index"), (Const(GLstring), "name")]),
+    GlFunction(Void, "glBindAttribLocation", [(GLprogram, "program"), (GLuint, "index"), (GLstringConst, "name")]),
     GlFunction(Void, "glCompileShader", [(GLshader, "shader")]),
     GlFunction(GLprogram, "glCreateProgram", []),
     GlFunction(GLshader, "glCreateShader", [(GLenum, "type")]),
@@ -573,23 +573,23 @@ glapi.addFunctions([
     GlFunction(Void, "glGetActiveAttrib", [(GLprogram, "program"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLint), "size"), Out(Pointer(GLenum), "type"), Out(GLstring, "name")], sideeffects=False),
     GlFunction(Void, "glGetActiveUniform", [(GLprogram, "program"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLint), "size"), Out(Pointer(GLenum), "type"), Out(GLstring, "name")], sideeffects=False),
     GlFunction(Void, "glGetAttachedShaders", [(GLprogram, "program"), (GLsizei, "maxCount"), Out(Pointer(GLsizei), "count"), Out(Array(GLuint, "(count ? *count : maxCount)"), "obj")], sideeffects=False),
-    GlFunction(GLint, "glGetAttribLocation", [(GLprogram, "program"), (Const(GLstring), "name")]),
-    GlFunction(Void, "glGetProgramiv", [(GLprogram, "program"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(GLint, "glGetAttribLocation", [(GLprogram, "program"), (GLstringConst, "name")]),
+    GlFunction(Void, "glGetProgramiv", [(GLprogram, "program"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetProgramInfoLog", [(GLprogram, "program"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(GLstring, "infoLog")], sideeffects=False),
-    GlFunction(Void, "glGetShaderiv", [(GLshader, "shader"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetShaderiv", [(GLshader, "shader"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetShaderInfoLog", [(GLshader, "shader"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(GLstring, "infoLog")], sideeffects=False),
-    GlFunction(Void, "glGetShaderSource", [(GLshader, "shader"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(String("GLchar *", "*length"), "source")], sideeffects=False),
-    GlFunction(GLlocation, "glGetUniformLocation", [(GLprogram, "program"), (Const(GLstring), "name")]),
+    GlFunction(Void, "glGetShaderSource", [(GLshader, "shader"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(String(GLchar, "*length"), "source")], sideeffects=False),
+    GlFunction(GLlocation, "glGetUniformLocation", [(GLprogram, "program"), (GLstringConst, "name")]),
     GlFunction(Void, "glGetUniformfv", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaquePointer(GLfloat), "params")], sideeffects=False),
     GlFunction(Void, "glGetUniformiv", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaquePointer(GLint), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribdv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribfv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribiv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribdv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribfv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribiv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetVertexAttribPointerv", [(GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLpointer), "pointer")], sideeffects=False),
     GlFunction(GLboolean, "glIsProgram", [(GLprogram, "program")], sideeffects=False),
     GlFunction(GLboolean, "glIsShader", [(GLshader, "shader")], sideeffects=False),
     GlFunction(Void, "glLinkProgram", [(GLprogram, "program")]),
-    GlFunction(Void, "glShaderSource", [(GLshader, "shader"), (GLsizei, "count"), (Const(Array(Const(GLstringARB), "count")), "string"), (Array(Const(GLint), "count"), "length")]),
+    GlFunction(Void, "glShaderSource", [(GLshader, "shader"), (GLsizei, "count"), (Array(Const(GLstringConstARB), "count"), "string"), (Array(Const(GLint), "count"), "length")]),
     GlFunction(Void, "glUseProgram", [(GLprogram, "program")]),
     GlFunction(Void, "glUniform1f", [(GLlocation, "location"), (GLfloat, "v0")]),
     GlFunction(Void, "glUniform2f", [(GLlocation, "location"), (GLfloat, "v0"), (GLfloat, "v1")]),
@@ -659,8 +659,8 @@ glapi.addFunctions([
 
     # GL_VERSION_3_0
     GlFunction(Void, "glColorMaski", [(GLuint, "index"), (GLboolean, "r"), (GLboolean, "g"), (GLboolean, "b"), (GLboolean, "a")]),
-    GlFunction(Void, "glGetBooleani_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLboolean, "__gl_param_size(target)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetIntegeri_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLint, "__gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetBooleani_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLboolean, "_gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetIntegeri_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLint, "_gl_param_size(target)"), "data")], sideeffects=False),
     GlFunction(Void, "glEnablei", [(GLenum, "target"), (GLuint, "index")]),
     GlFunction(Void, "glDisablei", [(GLenum, "target"), (GLuint, "index")]),
     GlFunction(GLboolean, "glIsEnabledi", [(GLenum, "target"), (GLuint, "index")], sideeffects=False),
@@ -668,14 +668,14 @@ glapi.addFunctions([
     GlFunction(Void, "glEndTransformFeedback", []),
     GlFunction(Void, "glBindBufferRange", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "size")]),
     GlFunction(Void, "glBindBufferBase", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer")]),
-    GlFunction(Void, "glTransformFeedbackVaryings", [(GLprogram, "program"), (GLsizei, "count"), (Const(Array(Const(GLstring), "count")), "varyings"), (GLenum, "bufferMode")]),
+    GlFunction(Void, "glTransformFeedbackVaryings", [(GLprogram, "program"), (GLsizei, "count"), (Array(Const(GLstringConst), "count"), "varyings"), (GLenum, "bufferMode")]),
     GlFunction(Void, "glGetTransformFeedbackVarying", [(GLprogram, "program"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLsizei), "size"), Out(Pointer(GLenum), "type"), Out(GLstring, "name")], sideeffects=False),
     GlFunction(Void, "glClampColor", [(GLenum, "target"), (GLenum, "clamp")]),
     GlFunction(Void, "glBeginConditionalRender", [(GLuint, "id"), (GLenum, "mode")]),
     GlFunction(Void, "glEndConditionalRender", []),
     GlFunction(Void, "glVertexAttribIPointer", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (GLpointerConst, "pointer")]),
-    GlFunction(Void, "glGetVertexAttribIiv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribIuiv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribIiv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribIuiv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glVertexAttribI1i", [(GLuint, "index"), (GLint, "x")]),
     GlFunction(Void, "glVertexAttribI2i", [(GLuint, "index"), (GLint, "x"), (GLint, "y")]),
     GlFunction(Void, "glVertexAttribI3i", [(GLuint, "index"), (GLint, "x"), (GLint, "y"), (GLint, "z")]),
@@ -696,9 +696,9 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexAttribI4sv", [(GLuint, "index"), (Array(Const(GLshort), 4), "v")]),
     GlFunction(Void, "glVertexAttribI4ubv", [(GLuint, "index"), (Array(Const(GLubyte), 4), "v")]),
     GlFunction(Void, "glVertexAttribI4usv", [(GLuint, "index"), (Array(Const(GLushort), 4), "v")]),
-    GlFunction(Void, "glGetUniformuiv", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaqueArray(GLuint, "__glGetUniformuiv_size(program, location)"), "params")], sideeffects=False),
-    GlFunction(Void, "glBindFragDataLocation", [(GLprogram, "program"), (GLuint, "color"), (Const(GLstring), "name")]),
-    GlFunction(GLlocation, "glGetFragDataLocation", [(GLprogram, "program"), (Const(GLstring), "name")]),
+    GlFunction(Void, "glGetUniformuiv", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaqueArray(GLuint, "_glGetUniformuiv_size(program, location)"), "params")], sideeffects=False),
+    GlFunction(Void, "glBindFragDataLocation", [(GLprogram, "program"), (GLuint, "color"), (GLstringConst, "name")]),
+    GlFunction(GLlocation, "glGetFragDataLocation", [(GLprogram, "program"), (GLstringConst, "name")]),
     GlFunction(Void, "glUniform1ui", [(GLlocation, "location"), (GLuint, "v0")]),
     GlFunction(Void, "glUniform2ui", [(GLlocation, "location"), (GLuint, "v0"), (GLuint, "v1")]),
     GlFunction(Void, "glUniform3ui", [(GLlocation, "location"), (GLuint, "v0"), (GLuint, "v1"), (GLuint, "v2")]),
@@ -707,15 +707,15 @@ glapi.addFunctions([
     GlFunction(Void, "glUniform2uiv", [(GLlocation, "location"), (GLsizei, "count"), (Array(Const(GLuint), "count*2"), "value")]),
     GlFunction(Void, "glUniform3uiv", [(GLlocation, "location"), (GLsizei, "count"), (Array(Const(GLuint), "count*3"), "value")]),
     GlFunction(Void, "glUniform4uiv", [(GLlocation, "location"), (GLsizei, "count"), (Array(Const(GLuint), "count*4"), "value")]),
-    GlFunction(Void, "glTexParameterIiv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glTexParameterIuiv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetTexParameterIiv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexParameterIuiv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glClearBufferiv", [(GLenum, "buffer"), (GLint, "drawbuffer"), (Array(Const(GLint), "__glClearBuffer_size(buffer)"), "value")]),
-    GlFunction(Void, "glClearBufferuiv", [(GLenum, "buffer"), (GLint, "drawbuffer"), (Array(Const(GLuint), "__glClearBuffer_size(buffer)"), "value")]),
-    GlFunction(Void, "glClearBufferfv", [(GLenum, "buffer"), (GLint, "drawbuffer"), (Array(Const(GLfloat), "__glClearBuffer_size(buffer)"), "value")]),
+    GlFunction(Void, "glTexParameterIiv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexParameterIuiv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetTexParameterIiv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexParameterIuiv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glClearBufferiv", [(GLenum, "buffer"), (GLint, "drawbuffer"), (Array(Const(GLint), "_glClearBuffer_size(buffer)"), "value")]),
+    GlFunction(Void, "glClearBufferuiv", [(GLenum, "buffer"), (GLint, "drawbuffer"), (Array(Const(GLuint), "_glClearBuffer_size(buffer)"), "value")]),
+    GlFunction(Void, "glClearBufferfv", [(GLenum, "buffer"), (GLint, "drawbuffer"), (Array(Const(GLfloat), "_glClearBuffer_size(buffer)"), "value")]),
     GlFunction(Void, "glClearBufferfi", [(GLenum, "buffer"), (GLint, "drawbuffer"), (GLfloat, "depth"), (GLint, "stencil")]),
-    GlFunction(String("const GLubyte *"), "glGetStringi", [(GLenum, "name"), (GLuint, "index")], sideeffects=False),
+    GlFunction(String(Const(GLubyte)), "glGetStringi", [(GLenum, "name"), (GLuint, "index")], sideeffects=False),
 
     # GL_VERSION_3_1
     GlFunction(Void, "glDrawArraysInstanced", [(GLenum_mode, "mode"), (GLint, "first"), (GLsizei, "count"), (GLsizei, "primcount")]),
@@ -724,15 +724,15 @@ glapi.addFunctions([
     GlFunction(Void, "glPrimitiveRestartIndex", [(GLuint, "index")]),
 
     # GL_VERSION_3_2
-    GlFunction(Void, "glGetInteger64i_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLint64, "__gl_param_size(target)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetBufferParameteri64v", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint64, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetInteger64i_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLint64, "_gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetBufferParameteri64v", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glFramebufferTexture", [(GLenum, "target"), (GLenum, "attachment"), (GLtexture, "texture"), (GLint, "level")]),
 
     # GL_VERSION_3_3
     GlFunction(Void, "glVertexAttribDivisor", [(GLuint, "index"), (GLuint, "divisor")]),
 
     # GL_VERSION_4_0
-    GlFunction(Void, "glMinSampleShading", [(GLclampf, "value")]),
+    GlFunction(Void, "glMinSampleShading", [(GLfloat, "value")]),
     GlFunction(Void, "glBlendEquationi", [(GLuint, "buf"), (GLenum, "mode")]),
     GlFunction(Void, "glBlendEquationSeparatei", [(GLuint, "buf"), (GLenum, "modeRGB"), (GLenum, "modeAlpha")]),
     GlFunction(Void, "glBlendFunci", [(GLuint, "buf"), (GLenum, "src"), (GLenum, "dst")]),
@@ -781,7 +781,7 @@ glapi.addFunctions([
     GlFunction(Void, "glMultTransposeMatrixdARB", [(Array(Const(GLdouble), 16), "m")]),
 
     # GL_ARB_multisample
-    GlFunction(Void, "glSampleCoverageARB", [(GLclampf, "value"), (GLboolean, "invert")]),
+    GlFunction(Void, "glSampleCoverageARB", [(GLfloat, "value"), (GLboolean, "invert")]),
 
     # GL_ARB_texture_compression
     GlFunction(Void, "glCompressedTexImage3DARB", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
@@ -794,7 +794,7 @@ glapi.addFunctions([
 
     # GL_ARB_point_parameters
     GlFunction(Void, "glPointParameterfARB", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glPointParameterfvARB", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPointParameterfvARB", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
 
     # GL_ARB_vertex_blend
     GlFunction(Void, "glWeightbvARB", [(GLint, "size"), (Array(Const(GLbyte), "size"), "weights")]),
@@ -873,7 +873,7 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexAttribPointerARB", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLboolean, "normalized"), (GLsizei, "stride"), (GLpointerConst, "pointer")]),
     GlFunction(Void, "glEnableVertexAttribArrayARB", [(GLuint, "index")]),
     GlFunction(Void, "glDisableVertexAttribArrayARB", [(GLuint, "index")]),
-    GlFunction(Void, "glProgramStringARB", [(GLenum, "target"), (GLenum, "format"), (GLsizei, "len"), (String("const void *", "len"), "string")]),
+    GlFunction(Void, "glProgramStringARB", [(GLenum, "target"), (GLenum, "format"), (GLsizei, "len"), (String(Const(Void), "len"), "string")]),
     GlFunction(Void, "glBindProgramARB", [(GLenum, "target"), (GLprogramARB, "program")]),
     GlFunction(Void, "glDeleteProgramsARB", [(GLsizei, "n"), (Array(Const(GLprogramARB), "n"), "programs")]),
     GlFunction(Void, "glGenProgramsARB", [(GLsizei, "n"), Out(Array(GLprogramARB, "n"), "programs")]),
@@ -889,11 +889,11 @@ glapi.addFunctions([
     GlFunction(Void, "glGetProgramEnvParameterfvARB", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLfloat, 4), "params")], sideeffects=False),
     GlFunction(Void, "glGetProgramLocalParameterdvARB", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLdouble, 4), "params")], sideeffects=False),
     GlFunction(Void, "glGetProgramLocalParameterfvARB", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLfloat, 4), "params")], sideeffects=False),
-    GlFunction(Void, "glGetProgramivARB", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetProgramivARB", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetProgramStringARB", [(GLenum, "target"), (GLenum, "pname"), Out(GLpointer, "string")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribdvARB", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribfvARB", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribivARB", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribdvARB", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribfvARB", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribivARB", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetVertexAttribPointervARB", [(GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLpointer), "pointer")], sideeffects=False),
     GlFunction(GLboolean, "glIsProgramARB", [(GLprogramARB, "program")], sideeffects=False),
 
@@ -904,10 +904,10 @@ glapi.addFunctions([
     GlFunction(GLboolean, "glIsBufferARB", [(GLbuffer, "buffer")], sideeffects=False),
     GlFunction(Void, "glBufferDataARB", [(GLenum, "target"), (GLsizeiptrARB, "size"), (Blob(Const(GLvoid), "size"), "data"), (GLenum, "usage")]),
     GlFunction(Void, "glBufferSubDataARB", [(GLenum, "target"), (GLintptrARB, "offset"), (GLsizeiptrARB, "size"), (Blob(Const(GLvoid), "size"), "data")]),
-    GlFunction(Void, "glGetBufferSubDataARB", [(GLenum, "target"), (GLintptrARB, "offset"), (GLsizeiptrARB, "size"), Out(Blob(GLvoid, "size"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetBufferSubDataARB", [(GLenum, "target"), (GLintptrARB, "offset"), (GLsizeiptrARB, "size"), Out(OpaqueBlob(GLvoid, "size"), "data")], sideeffects=False),
     GlFunction(GLmap, "glMapBufferARB", [(GLenum, "target"), (GLenum, "access")]),
     GlFunction(GLboolean, "glUnmapBufferARB", [(GLenum, "target")]),
-    GlFunction(Void, "glGetBufferParameterivARB", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetBufferParameterivARB", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetBufferPointervARB", [(GLenum, "target"), (GLenum, "pname"), Out(Pointer(GLpointer), "params")], sideeffects=False),
 
     # GL_ARB_occlusion_query
@@ -916,16 +916,16 @@ glapi.addFunctions([
     GlFunction(GLboolean, "glIsQueryARB", [(GLquery, "id")], sideeffects=False),
     GlFunction(Void, "glBeginQueryARB", [(GLenum, "target"), (GLquery, "id")]),
     GlFunction(Void, "glEndQueryARB", [(GLenum, "target")]),
-    GlFunction(Void, "glGetQueryivARB", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetQueryObjectivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetQueryObjectuivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryivARB", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjectivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjectuivARB", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_ARB_shader_objects
     GlFunction(Void, "glDeleteObjectARB", [(GLhandleARB, "obj")]),
     GlFunction(GLhandleARB, "glGetHandleARB", [(GLenum, "pname")], sideeffects=False),
     GlFunction(Void, "glDetachObjectARB", [(GLhandleARB, "containerObj"), (GLhandleARB, "attachedObj")]),
     GlFunction(GLhandleARB, "glCreateShaderObjectARB", [(GLenum, "shaderType")]),
-    GlFunction(Void, "glShaderSourceARB", [(GLhandleARB, "shaderObj"), (GLsizei, "count"), (Const(Array(Const(GLstringARB), "count")), "string"), (Array(Const(GLint), "count"), "length")]),
+    GlFunction(Void, "glShaderSourceARB", [(GLhandleARB, "shaderObj"), (GLsizei, "count"), (Const(Array(GLstringConstARB, "count")), "string"), (Array(Const(GLint), "count"), "length")]),
     GlFunction(Void, "glCompileShaderARB", [(GLhandleARB, "shaderObj")]),
     GlFunction(GLhandleARB, "glCreateProgramObjectARB", []),
     GlFunction(Void, "glAttachObjectARB", [(GLhandleARB, "containerObj"), (GLhandleARB, "obj")]),
@@ -951,20 +951,20 @@ glapi.addFunctions([
     GlFunction(Void, "glUniformMatrix2fvARB", [(GLlocationARB, "location"), (GLsizei, "count"), (GLboolean, "transpose"), (Array(Const(GLfloat), "count*2*2"), "value")]),
     GlFunction(Void, "glUniformMatrix3fvARB", [(GLlocationARB, "location"), (GLsizei, "count"), (GLboolean, "transpose"), (Array(Const(GLfloat), "count*3*3"), "value")]),
     GlFunction(Void, "glUniformMatrix4fvARB", [(GLlocationARB, "location"), (GLsizei, "count"), (GLboolean, "transpose"), (Array(Const(GLfloat), "count*4*4"), "value")]),
-    GlFunction(Void, "glGetObjectParameterfvARB", [(GLhandleARB, "obj"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetObjectParameterivARB", [(GLhandleARB, "obj"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetObjectParameterfvARB", [(GLhandleARB, "obj"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetObjectParameterivARB", [(GLhandleARB, "obj"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetInfoLogARB", [(GLhandleARB, "obj"), (GLsizei, "maxLength"), Out(Pointer(GLsizei), "length"), Out(GLstringARB, "infoLog")], sideeffects=False),
     GlFunction(Void, "glGetAttachedObjectsARB", [(GLhandleARB, "containerObj"), (GLsizei, "maxCount"), Out(Pointer(GLsizei), "count"), Out(Array(GLhandleARB, "(count ? *count : maxCount)"), "obj")], sideeffects=False),
-    GlFunction(GLlocationARB, "glGetUniformLocationARB", [(GLhandleARB, "programObj"), (Const(GLstringARB), "name")]),
+    GlFunction(GLlocationARB, "glGetUniformLocationARB", [(GLhandleARB, "programObj"), (GLstringConstARB, "name")]),
     GlFunction(Void, "glGetActiveUniformARB", [(GLhandleARB, "programObj"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLint), "size"), Out(Pointer(GLenum), "type"), Out(GLstringARB, "name")], sideeffects=False),
     GlFunction(Void, "glGetUniformfvARB", [(GLhandleARB, "programObj"), (GLlocationARB, "location"), Out(OpaquePointer(GLfloat), "params")], sideeffects=False),
     GlFunction(Void, "glGetUniformivARB", [(GLhandleARB, "programObj"), (GLlocationARB, "location"), Out(OpaquePointer(GLint), "params")], sideeffects=False),
     GlFunction(Void, "glGetShaderSourceARB", [(GLhandleARB, "obj"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(GLstringARB, "source")], sideeffects=False),
 
     # GL_ARB_vertex_shader
-    GlFunction(Void, "glBindAttribLocationARB", [(GLhandleARB, "programObj"), (GLuint, "index"), (Const(GLstringARB), "name")]),
+    GlFunction(Void, "glBindAttribLocationARB", [(GLhandleARB, "programObj"), (GLuint, "index"), (GLstringConstARB, "name")]),
     GlFunction(Void, "glGetActiveAttribARB", [(GLhandleARB, "programObj"), (GLuint, "index"), (GLsizei, "maxLength"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLint), "size"), Out(Pointer(GLenum), "type"), Out(GLstringARB, "name")], sideeffects=False),
-    GlFunction(GLint, "glGetAttribLocationARB", [(GLhandleARB, "programObj"), (Const(GLstringARB), "name")]),
+    GlFunction(GLint, "glGetAttribLocationARB", [(GLhandleARB, "programObj"), (GLstringConstARB, "name")]),
 
     # GL_ARB_draw_buffers
     GlFunction(Void, "glDrawBuffersARB", [(GLsizei, "n"), (Array(Const(GLenum), "n"), "bufs")]),
@@ -982,7 +982,7 @@ glapi.addFunctions([
     GlFunction(Void, "glDeleteRenderbuffers", [(GLsizei, "n"), (Array(Const(GLrenderbuffer), "n"), "renderbuffers")]),
     GlFunction(Void, "glGenRenderbuffers", [(GLsizei, "n"), Out(Array(GLrenderbuffer, "n"), "renderbuffers")]),
     GlFunction(Void, "glRenderbufferStorage", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetRenderbufferParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetRenderbufferParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLboolean, "glIsFramebuffer", [(GLframebuffer, "framebuffer")], sideeffects=False),
     GlFunction(Void, "glBindFramebuffer", [(GLenum, "target"), (GLframebuffer, "framebuffer")]),
     GlFunction(Void, "glDeleteFramebuffers", [(GLsizei, "n"), (Array(Const(GLframebuffer), "n"), "framebuffers")]),
@@ -992,7 +992,7 @@ glapi.addFunctions([
     GlFunction(Void, "glFramebufferTexture2D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
     GlFunction(Void, "glFramebufferTexture3D", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level"), (GLint, "zoffset")]),
     GlFunction(Void, "glFramebufferRenderbuffer", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "renderbuffertarget"), (GLuint, "renderbuffer")]),
-    GlFunction(Void, "glGetFramebufferAttachmentParameteriv", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFramebufferAttachmentParameteriv", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGenerateMipmap", [(GLenum, "target")]),
     GlFunction(Void, "glBlitFramebuffer", [(GLint, "srcX0"), (GLint, "srcY0"), (GLint, "srcX1"), (GLint, "srcY1"), (GLint, "dstX0"), (GLint, "dstY0"), (GLint, "dstX1"), (GLint, "dstY1"), (GLbitfield_attrib, "mask"), (GLenum, "filter")]),
     GlFunction(Void, "glRenderbufferStorageMultisample", [(GLenum, "target"), (GLsizei, "samples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
@@ -1021,11 +1021,11 @@ glapi.addFunctions([
     GlFunction(GLboolean, "glIsVertexArray", [(GLarray, "array")], sideeffects=False),
 
     # GL_ARB_uniform_buffer_object
-    GlFunction(Void, "glGetUniformIndices", [(GLprogram, "program"), (GLsizei, "uniformCount"), (Array(Const(GLstring), "uniformCount"), "uniformNames"), Out(Array(GLuint, "uniformCount"), "uniformIndices")], sideeffects=False),
-    GlFunction(Void, "glGetActiveUniformsiv", [(GLprogram, "program"), (GLsizei, "uniformCount"), (Array(Const(GLuint), "uniformCount"), "uniformIndices"), (GLenum, "pname"), Out(OpaqueArray(GLint, "__glGetActiveUniformsiv_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetUniformIndices", [(GLprogram, "program"), (GLsizei, "uniformCount"), (Array(Const(GLstringConst), "uniformCount"), "uniformNames"), Out(Array(GLuint, "uniformCount"), "uniformIndices")], sideeffects=False),
+    GlFunction(Void, "glGetActiveUniformsiv", [(GLprogram, "program"), (GLsizei, "uniformCount"), (Array(Const(GLuint), "uniformCount"), "uniformIndices"), (GLenum, "pname"), Out(OpaqueArray(GLint, "_glGetActiveUniformsiv_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetActiveUniformName", [(GLprogram, "program"), (GLuint, "uniformIndex"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "uniformName")], sideeffects=False),
-    GlFunction(GLuint, "glGetUniformBlockIndex", [(GLprogram, "program"), (Const(GLstring), "uniformBlockName")]),
-    GlFunction(Void, "glGetActiveUniformBlockiv", [(GLprogram, "program"), (GLuint, "uniformBlockIndex"), (GLenum, "pname"), Out(OpaqueArray(GLint, "__glGetActiveUniformBlockiv_size(pname)"), "params")], sideeffects=False),
+    GlFunction(GLuint, "glGetUniformBlockIndex", [(GLprogram, "program"), (GLstringConst, "uniformBlockName")]),
+    GlFunction(Void, "glGetActiveUniformBlockiv", [(GLprogram, "program"), (GLuint, "uniformBlockIndex"), (GLenum, "pname"), Out(OpaqueArray(GLint, "_glGetActiveUniformBlockiv_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetActiveUniformBlockName", [(GLprogram, "program"), (GLuint, "uniformBlockIndex"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "uniformBlockName")], sideeffects=False),
     GlFunction(Void, "glUniformBlockBinding", [(GLprogram, "program"), (GLuint, "uniformBlockIndex"), (GLuint, "uniformBlockBinding")]),
 
@@ -1036,7 +1036,7 @@ glapi.addFunctions([
     GlFunction(Void, "glDrawElementsBaseVertex", [(GLenum_mode, "mode"), (GLsizei, "count"), (GLenum, "type"), (GLpointerConst, "indices"), (GLint, "basevertex")]),
     GlFunction(Void, "glDrawRangeElementsBaseVertex", [(GLenum_mode, "mode"), (GLuint, "start"), (GLuint, "end"), (GLsizei, "count"), (GLenum, "type"), (GLpointerConst, "indices"), (GLint, "basevertex")]),
     GlFunction(Void, "glDrawElementsInstancedBaseVertex", [(GLenum_mode, "mode"), (GLsizei, "count"), (GLenum, "type"), (GLpointerConst, "indices"), (GLsizei, "primcount"), (GLint, "basevertex")]),
-    GlFunction(Void, "glMultiDrawElementsBaseVertex", [(GLenum_mode, "mode"), (Array(Const(GLsizei), "primcount"), "count"), (GLenum, "type"), (Array(GLpointerConst, "primcount"), "indices"), (GLsizei, "primcount"), (Array(Const(GLint), "primcount"), "basevertex")]),
+    GlFunction(Void, "glMultiDrawElementsBaseVertex", [(GLenum_mode, "mode"), (Array(Const(GLsizei), "drawcount"), "count"), (GLenum, "type"), (Array(Const(GLpointerConst), "drawcount"), "indices"), (GLsizei, "drawcount"), (Array(Const(GLint), "drawcount"), "basevertex")]),
 
     # GL_ARB_provoking_vertex
     GlFunction(Void, "glProvokingVertex", [(GLenum, "mode")]),
@@ -1047,13 +1047,13 @@ glapi.addFunctions([
     GlFunction(Void, "glDeleteSync", [(GLsync, "sync")]),
     GlFunction(GLenum, "glClientWaitSync", [(GLsync, "sync"), (GLbitfield_sync_flush, "flags"), (GLuint64, "timeout")]),
     GlFunction(Void, "glWaitSync", [(GLsync, "sync"), (GLbitfield, "flags"), (GLuint64, "timeout")]),
-    GlFunction(Void, "glGetInteger64v", [(GLenum, "pname"), Out(Array(GLint64, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetInteger64v", [(GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetSynciv", [(GLsync, "sync"), (GLenum, "pname"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLint, "(length ? *length : bufSize)"), "values")], sideeffects=False),
 
     # GL_ARB_texture_multisample
     GlFunction(Void, "glTexImage2DMultisample", [(GLenum, "target"), (GLsizei, "samples"), (GLint, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLboolean, "fixedsamplelocations")]),
     GlFunction(Void, "glTexImage3DMultisample", [(GLenum, "target"), (GLsizei, "samples"), (GLint, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLboolean, "fixedsamplelocations")]),
-    GlFunction(Void, "glGetMultisamplefv", [(GLenum, "pname"), (GLuint, "index"), Out(Array(GLfloat, "__gl_param_size(pname)"), "val")], sideeffects=False),
+    GlFunction(Void, "glGetMultisamplefv", [(GLenum, "pname"), (GLuint, "index"), Out(Array(GLfloat, "_gl_param_size(pname)"), "val")], sideeffects=False),
     GlFunction(Void, "glSampleMaski", [(GLuint, "index"), (GLbitfield, "mask")]),
 
     # GL_ARB_draw_buffers_blend
@@ -1063,19 +1063,19 @@ glapi.addFunctions([
     GlFunction(Void, "glBlendFuncSeparateiARB", [(GLuint, "buf"), (GLenum, "srcRGB"), (GLenum, "dstRGB"), (GLenum, "srcAlpha"), (GLenum, "dstAlpha")]),
 
     # GL_ARB_sample_shading
-    GlFunction(Void, "glMinSampleShadingARB", [(GLclampf, "value")]),
+    GlFunction(Void, "glMinSampleShadingARB", [(GLfloat, "value")]),
 
     # GL_ARB_shading_language_include
-    GlFunction(Void, "glNamedStringARB", [(GLenum, "type"), (GLint, "namelen"), (Const(String('GLchar *', "namelen")), "name"), (GLint, "stringlen"), (Const(String('GLchar *', "stringlen")), "string")]),
-    GlFunction(Void, "glDeleteNamedStringARB", [(GLint, "namelen"), (Const(String('GLchar *', "namelen")), "name")]),
-    GlFunction(Void, "glCompileShaderIncludeARB", [(GLshader, "shader"), (GLsizei, "count"), (Array(String("const GLchar *"), "count"), "path"), (Array(Const(GLint), "count"), "length")]),
-    GlFunction(GLboolean, "glIsNamedStringARB", [(GLint, "namelen"), (Const(String('GLchar *', "namelen")), "name")], sideeffects=False),
-    GlFunction(Void, "glGetNamedStringARB", [(GLint, "namelen"), (Const(String('GLchar *', "namelen")), "name"), (GLsizei, "bufSize"), Out(Pointer(GLint), "stringlen"), Out(Array(GLchar, "bufSize"), "string")], sideeffects=False),
-    GlFunction(Void, "glGetNamedStringivARB", [(GLint, "namelen"), (Const(String('GLchar *', "namelen")), "name"), (GLenum, "pname"), Out(OpaqueArray(GLint, "__glGetNamedStringivARB_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glNamedStringARB", [(GLenum, "type"), (GLint, "namelen"), (String(Const(GLchar), "namelen"), "name"), (GLint, "stringlen"), (String(Const(GLchar), "stringlen"), "string")]),
+    GlFunction(Void, "glDeleteNamedStringARB", [(GLint, "namelen"), (String(Const(GLchar), "namelen"), "name")]),
+    GlFunction(Void, "glCompileShaderIncludeARB", [(GLshader, "shader"), (GLsizei, "count"), (Array(String(Const(GLchar)), "count"), "path"), (Array(Const(GLint), "count"), "length")]),
+    GlFunction(GLboolean, "glIsNamedStringARB", [(GLint, "namelen"), (String(Const(GLchar), "namelen"), "name")], sideeffects=False),
+    GlFunction(Void, "glGetNamedStringARB", [(GLint, "namelen"), (String(Const(GLchar), "namelen"), "name"), (GLsizei, "bufSize"), Out(Pointer(GLint), "stringlen"), Out(Array(GLchar, "bufSize"), "string")], sideeffects=False),
+    GlFunction(Void, "glGetNamedStringivARB", [(GLint, "namelen"), (String(Const(GLchar), "namelen"), "name"), (GLenum, "pname"), Out(OpaqueArray(GLint, "_glGetNamedStringivARB_size(pname)"), "params")], sideeffects=False),
 
     # GL_ARB_blend_func_extended
-    GlFunction(Void, "glBindFragDataLocationIndexed", [(GLprogram, "program"), (GLuint, "colorNumber"), (GLuint, "index"), (Const(GLstring), "name")]),
-    GlFunction(GLint, "glGetFragDataIndex", [(GLprogram, "program"), (Const(GLstring), "name")], sideeffects=False),
+    GlFunction(Void, "glBindFragDataLocationIndexed", [(GLprogram, "program"), (GLuint, "colorNumber"), (GLuint, "index"), (GLstringConst, "name")]),
+    GlFunction(GLint, "glGetFragDataIndex", [(GLprogram, "program"), (GLstringConst, "name")], sideeffects=False),
 
     # GL_ARB_sampler_objects
     GlFunction(Void, "glGenSamplers", [(GLsizei, "count"), Out(Array(GLsampler, "count"), "samplers")]),
@@ -1083,20 +1083,20 @@ glapi.addFunctions([
     GlFunction(GLboolean, "glIsSampler", [(GLsampler, "sampler")], sideeffects=False),
     GlFunction(Void, "glBindSampler", [(GLuint, "unit"), (GLsampler, "sampler")]),
     GlFunction(Void, "glSamplerParameteri", [(GLsampler, "sampler"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glSamplerParameteriv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "param")]),
+    GlFunction(Void, "glSamplerParameteriv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "param")]),
     GlFunction(Void, "glSamplerParameterf", [(GLsampler, "sampler"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glSamplerParameterfv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "param")]),
-    GlFunction(Void, "glSamplerParameterIiv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "param")]),
-    GlFunction(Void, "glSamplerParameterIuiv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLuint), "__gl_param_size(pname)"), "param")]),
-    GlFunction(Void, "glGetSamplerParameteriv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetSamplerParameterIiv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetSamplerParameterfv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetSamplerParameterIuiv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glSamplerParameterfv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "param")]),
+    GlFunction(Void, "glSamplerParameterIiv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "param")]),
+    GlFunction(Void, "glSamplerParameterIuiv", [(GLsampler, "sampler"), (GLenum, "pname"), (Array(Const(GLuint), "_gl_param_size(pname)"), "param")]),
+    GlFunction(Void, "glGetSamplerParameteriv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetSamplerParameterIiv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetSamplerParameterfv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetSamplerParameterIuiv", [(GLsampler, "sampler"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_ARB_timer_query
     GlFunction(Void, "glQueryCounter", [(GLuint, "id"), (GLenum, "target")]),
-    GlFunction(Void, "glGetQueryObjecti64v", [(GLuint, "id"), (GLenum, "pname"), Out(Array(GLint64, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetQueryObjectui64v", [(GLuint, "id"), (GLenum, "pname"), Out(Array(GLuint64, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjecti64v", [(GLuint, "id"), (GLenum, "pname"), Out(Array(GLint64, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjectui64v", [(GLuint, "id"), (GLenum, "pname"), Out(Array(GLuint64, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_ARB_vertex_type_2_10_10_10_rev
     GlFunction(Void, "glVertexP2ui", [(GLenum, "type"), (GLuint, "value")]),
@@ -1160,12 +1160,12 @@ glapi.addFunctions([
     GlFunction(Void, "glUniformMatrix3x4dv", [(GLlocation, "location"), (GLsizei, "count"), (GLboolean, "transpose"), (Array(Const(GLdouble), "count*3*4"), "value")]),
     GlFunction(Void, "glUniformMatrix4x2dv", [(GLlocation, "location"), (GLsizei, "count"), (GLboolean, "transpose"), (Array(Const(GLdouble), "count*4*2"), "value")]),
     GlFunction(Void, "glUniformMatrix4x3dv", [(GLlocation, "location"), (GLsizei, "count"), (GLboolean, "transpose"), (Array(Const(GLdouble), "count*4*3"), "value")]),
-    GlFunction(Void, "glGetUniformdv", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaqueArray(GLdouble, "__glGetUniformdv_size(location)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetUniformdv", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaqueArray(GLdouble, "_glGetUniformdv_size(location)"), "params")], sideeffects=False),
 
     # GL_ARB_shader_subroutine
-    GlFunction(GLlocation, "glGetSubroutineUniformLocation", [(GLprogram, "program"), (GLenum, "shadertype"), (Const(GLstring), "name")]),
-    GlFunction(GLuint, "glGetSubroutineIndex", [(GLprogram, "program"), (GLenum, "shadertype"), (Const(GLstring), "name")]),
-    GlFunction(Void, "glGetActiveSubroutineUniformiv", [(GLprogram, "program"), (GLenum, "shadertype"), (GLuint, "index"), (GLenum, "pname"), Out(OpaqueArray(GLint, "__glGetActiveSubroutineUniformiv_size(pname)"), "values")], sideeffects=False),
+    GlFunction(GLlocation, "glGetSubroutineUniformLocation", [(GLprogram, "program"), (GLenum, "shadertype"), (GLstringConst, "name")]),
+    GlFunction(GLuint, "glGetSubroutineIndex", [(GLprogram, "program"), (GLenum, "shadertype"), (GLstringConst, "name")]),
+    GlFunction(Void, "glGetActiveSubroutineUniformiv", [(GLprogram, "program"), (GLenum, "shadertype"), (GLuint, "index"), (GLenum, "pname"), Out(OpaqueArray(GLint, "_glGetActiveSubroutineUniformiv_size(pname)"), "values")], sideeffects=False),
     GlFunction(Void, "glGetActiveSubroutineUniformName", [(GLprogram, "program"), (GLenum, "shadertype"), (GLuint, "index"), (GLsizei, "bufsize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufsize"), "name")], sideeffects=False),
     GlFunction(Void, "glGetActiveSubroutineName", [(GLprogram, "program"), (GLenum, "shadertype"), (GLuint, "index"), (GLsizei, "bufsize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufsize"), "name")], sideeffects=False),
     GlFunction(Void, "glUniformSubroutinesuiv", [(GLenum, "shadertype"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "indices")]),
@@ -1174,7 +1174,7 @@ glapi.addFunctions([
 
     # GL_ARB_tessellation_shader
     GlFunction(Void, "glPatchParameteri", [(GLenum, "pname"), (GLint, "value")]),
-    GlFunction(Void, "glPatchParameterfv", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "values")]),
+    GlFunction(Void, "glPatchParameterfv", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "values")]),
 
     # GL_ARB_transform_feedback2
     GlFunction(Void, "glBindTransformFeedback", [(GLenum, "target"), (GLfeedback, "id")]),
@@ -1189,29 +1189,29 @@ glapi.addFunctions([
     GlFunction(Void, "glDrawTransformFeedbackStream", [(GLenum_mode, "mode"), (GLfeedback, "id"), (GLuint, "stream")]),
     GlFunction(Void, "glBeginQueryIndexed", [(GLenum, "target"), (GLuint, "index"), (GLfeedback, "id")]),
     GlFunction(Void, "glEndQueryIndexed", [(GLenum, "target"), (GLuint, "index")]),
-    GlFunction(Void, "glGetQueryIndexediv", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryIndexediv", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_ARB_ES2_compatibility
     GlFunction(Void, "glReleaseShaderCompiler", []),
     GlFunction(Void, "glShaderBinary", [(GLsizei, "count"), (Array(Const(GLuint), "count"), "shaders"), (GLenum, "binaryformat"), (Blob(Const(GLvoid), "length"), "binary"), (GLsizei, "length")]),
     GlFunction(Void, "glGetShaderPrecisionFormat", [(GLenum, "shadertype"), (GLenum, "precisiontype"), Out(Array(GLint, 2), "range"), Out(Array(GLint, 2), "precision")], sideeffects=False),
-    GlFunction(Void, "glDepthRangef", [(GLclampf, "n"), (GLclampf, "f")]),
-    GlFunction(Void, "glClearDepthf", [(GLclampf, "d")]),
+    GlFunction(Void, "glDepthRangef", [(GLfloat, "n"), (GLfloat, "f")]),
+    GlFunction(Void, "glClearDepthf", [(GLfloat, "d")]),
 
     # GL_ARB_get_program_binary
-    GlFunction(Void, "glGetProgramBinary", [(GLprogram, "program"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLenum), "binaryFormat"), Out(OpaqueArray(GLvoid, "__glGetProgramBinary_size(length)"), "binary")], sideeffects=False),
+    GlFunction(Void, "glGetProgramBinary", [(GLprogram, "program"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLenum), "binaryFormat"), Out(OpaqueArray(GLvoid, "_glGetProgramBinary_size(length)"), "binary")], sideeffects=False),
     GlFunction(Void, "glProgramBinary", [(GLprogram, "program"), (GLenum, "binaryFormat"), (Blob(Const(GLvoid), "length"), "binary"), (GLsizei, "length")]),
     GlFunction(Void, "glProgramParameteri", [(GLprogram, "program"), (GLenum, "pname"), (GLint, "value")]),
 
     # GL_ARB_separate_shader_objects
     GlFunction(Void, "glUseProgramStages", [(GLpipeline, "pipeline"), (GLbitfield_shader, "stages"), (GLprogram, "program")]),
     GlFunction(Void, "glActiveShaderProgram", [(GLpipeline, "pipeline"), (GLprogram, "program")]),
-    GlFunction(GLprogram, "glCreateShaderProgramv", [(GLenum, "type"), (GLsizei, "count"), (Const(Array(Const(GLstring), "count")), "strings")]),
+    GlFunction(GLprogram, "glCreateShaderProgramv", [(GLenum, "type"), (GLsizei, "count"), (Array(Const(GLstringConst), "count"), "strings")]),
     GlFunction(Void, "glBindProgramPipeline", [(GLpipeline, "pipeline")]),
     GlFunction(Void, "glDeleteProgramPipelines", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "pipelines")]),
     GlFunction(Void, "glGenProgramPipelines", [(GLsizei, "n"), Out(Array(GLpipeline, "n"), "pipelines")]),
     GlFunction(GLboolean, "glIsProgramPipeline", [(GLpipeline, "pipeline")], sideeffects=False),
-    GlFunction(Void, "glGetProgramPipelineiv", [(GLpipeline, "pipeline"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetProgramPipelineiv", [(GLpipeline, "pipeline"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glProgramUniform1i", [(GLprogram, "program"), (GLlocation, "location"), (GLint, "v0")]),
     GlFunction(Void, "glProgramUniform1iv", [(GLprogram, "program"), (GLlocation, "location"), (GLsizei, "count"), (Array(Const(GLint), "count"), "value")]),
     GlFunction(Void, "glProgramUniform1f", [(GLprogram, "program"), (GLlocation, "location"), (GLfloat, "v0")]),
@@ -1275,7 +1275,7 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexAttribL3dv", [(GLuint, "index"), (Array(Const(GLdouble), 3), "v")]),
     GlFunction(Void, "glVertexAttribL4dv", [(GLuint, "index"), (Array(Const(GLdouble), 4), "v")]),
     GlFunction(Void, "glVertexAttribLPointer", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (GLpointerConst, "pointer")]),
-    GlFunction(Void, "glGetVertexAttribLdv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribLdv", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_ARB_viewport_array
     GlFunction(Void, "glViewportArrayv", [(GLuint, "first"), (GLsizei, "count"), (Array(Const(GLfloat), "count*4"), "v")]),
@@ -1284,14 +1284,14 @@ glapi.addFunctions([
     GlFunction(Void, "glScissorArrayv", [(GLuint, "first"), (GLsizei, "count"), (Array(Const(GLint), "count*4"), "v")]),
     GlFunction(Void, "glScissorIndexed", [(GLuint, "index"), (GLint, "left"), (GLint, "bottom"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glScissorIndexedv", [(GLuint, "index"), (Array(Const(GLint), 4), "v")]),
-    GlFunction(Void, "glDepthRangeArrayv", [(GLuint, "first"), (GLsizei, "count"), (Array(Const(GLclampd), "count*2"), "v")]),
-    GlFunction(Void, "glDepthRangeIndexed", [(GLuint, "index"), (GLclampd, "n"), (GLclampd, "f")]),
-    GlFunction(Void, "glGetFloati_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLfloat, "__gl_param_size(target)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetDoublei_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLdouble, "__gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glDepthRangeArrayv", [(GLuint, "first"), (GLsizei, "count"), (Array(Const(GLdouble), "count*2"), "v")]),
+    GlFunction(Void, "glDepthRangeIndexed", [(GLuint, "index"), (GLdouble, "n"), (GLdouble, "f")]),
+    GlFunction(Void, "glGetFloati_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLfloat, "_gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetDoublei_v", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLdouble, "_gl_param_size(target)"), "data")], sideeffects=False),
 
     # GL_ARB_debug_output
     GlFunction(Void, "glDebugMessageControlARB", [(GLenum, "source"), (GLenum, "type"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=False),
-    GlFunction(Void, "glDebugMessageInsertARB", [(GLenum, "source"), (GLenum, "type"), (GLuint, "id"), (GLenum, "severity"), (GLsizei, "length"), (Const(String("GLchar *", "length")), "buf")], sideeffects=False),
+    GlFunction(Void, "glDebugMessageInsertARB", [(GLenum, "source"), (GLenum, "type"), (GLuint, "id"), (GLenum, "severity"), (GLsizei, "length"), (String(Const(GLchar), "length"), "buf")], sideeffects=False),
     GlFunction(Void, "glDebugMessageCallbackARB", [(GLDEBUGPROCARB, "callback"), (GLpointerConst, "userParam")], sideeffects=False),
     GlFunction(GLuint, "glGetDebugMessageLogARB", [(GLuint, "count"), (GLsizei, "bufsize"), Out(Array(GLenum, "count"), "sources"), Out(Array(GLenum, "count"), "types"), Out(Array(GLuint, "count"), "ids"), Out(Array(GLenum, "count"), "severities"), Out(Array(GLsizei, "count"), "lengths"), Out(GLstring, "messageLog")], sideeffects=False),
 
@@ -1303,15 +1303,15 @@ glapi.addFunctions([
     GlFunction(Void, "glGetnPixelMapfvARB", [(GLenum, "map"), (GLsizei, "bufSize"), Out(Array(GLfloat, "bufSize"), "values")]),
     GlFunction(Void, "glGetnPixelMapuivARB", [(GLenum, "map"), (GLsizei, "bufSize"), Out(Array(GLuint, "bufSize"), "values")]),
     GlFunction(Void, "glGetnPixelMapusvARB", [(GLenum, "map"), (GLsizei, "bufSize"), Out(Array(GLushort, "bufSize"), "values")]),
-    GlFunction(Void, "glGetnPolygonStippleARB", [(GLsizei, "bufSize"), Out(Blob(GLubyte, "bufSize"), "pattern")]),
-    GlFunction(Void, "glGetnColorTableARB", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(Blob(GLvoid, "bufSize"), "table")], sideeffects=False),
-    GlFunction(Void, "glGetnConvolutionFilterARB", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(Blob(GLvoid, "bufSize"), "image")]),
-    GlFunction(Void, "glGetnSeparableFilterARB", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "rowBufSize"), Out(Blob(GLvoid, "rowBufSize"), "row"), (GLsizei, "columnBufSize"), Out(Blob(GLvoid, "columnBufSize"), "column"), Out(GLpointer, "span")]),
-    GlFunction(Void, "glGetnHistogramARB", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(Blob(GLvoid, "bufSize"), "values")]),
-    GlFunction(Void, "glGetnMinmaxARB", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(Blob(GLvoid, "bufSize"), "values")]),
-    GlFunction(Void, "glGetnTexImageARB", [(GLenum, "target"), (GLint, "level"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(Blob(GLvoid, "bufSize"), "img")]),
-    GlFunction(Void, "glReadnPixelsARB", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(Blob(GLvoid, "bufSize"), "data")]),
-    GlFunction(Void, "glGetnCompressedTexImageARB", [(GLenum, "target"), (GLint, "lod"), (GLsizei, "bufSize"), Out(Blob(GLvoid, "bufSize"), "img")], sideeffects=False),
+    GlFunction(Void, "glGetnPolygonStippleARB", [(GLsizei, "bufSize"), Out(OpaqueBlob(GLubyte, "bufSize"), "pattern")]),
+    GlFunction(Void, "glGetnColorTableARB", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(OpaqueBlob(GLvoid, "bufSize"), "table")], sideeffects=False),
+    GlFunction(Void, "glGetnConvolutionFilterARB", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(OpaqueBlob(GLvoid, "bufSize"), "image")]),
+    GlFunction(Void, "glGetnSeparableFilterARB", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "rowBufSize"), Out(OpaqueBlob(GLvoid, "rowBufSize"), "row"), (GLsizei, "columnBufSize"), Out(OpaqueBlob(GLvoid, "columnBufSize"), "column"), Out(GLpointer, "span")]),
+    GlFunction(Void, "glGetnHistogramARB", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(OpaqueBlob(GLvoid, "bufSize"), "values")]),
+    GlFunction(Void, "glGetnMinmaxARB", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(OpaqueBlob(GLvoid, "bufSize"), "values")]),
+    GlFunction(Void, "glGetnTexImageARB", [(GLenum, "target"), (GLint, "level"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(OpaqueBlob(GLvoid, "bufSize"), "img")]),
+    GlFunction(Void, "glReadnPixelsARB", [(GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (GLsizei, "bufSize"), Out(OpaqueBlob(GLvoid, "bufSize"), "data")]),
+    GlFunction(Void, "glGetnCompressedTexImageARB", [(GLenum, "target"), (GLint, "lod"), (GLsizei, "bufSize"), Out(OpaqueBlob(GLvoid, "bufSize"), "img")], sideeffects=False),
     GlFunction(Void, "glGetnUniformfvARB", [(GLprogram, "program"), (GLlocation, "location"), (GLsizei, "bufSize"), Out(Array(GLfloat, "bufSize"), "params")], sideeffects=False),
     GlFunction(Void, "glGetnUniformivARB", [(GLprogram, "program"), (GLlocation, "location"), (GLsizei, "bufSize"), Out(Array(GLint, "bufSize"), "params")], sideeffects=False),
     GlFunction(Void, "glGetnUniformuivARB", [(GLprogram, "program"), (GLlocation, "location"), (GLsizei, "bufSize"), Out(Array(GLuint, "bufSize"), "params")], sideeffects=False),
@@ -1330,7 +1330,7 @@ glapi.addFunctions([
     GlFunction(Void, "glGetInternalformativ", [(GLenum, "target"), (GLenum, "internalformat"), (GLenum, "pname"), (GLsizei, "bufSize"), Out(Array(GLint, "bufSize"), "params")], sideeffects=False),
 
     # GL_ARB_shader_atomic_counters
-    GlFunction(Void, "glGetActiveAtomicCounterBufferiv", [(GLprogram, "program"), (GLuint, "bufferIndex"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetActiveAtomicCounterBufferiv", [(GLprogram, "program"), (GLuint, "bufferIndex"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_ARB_shader_image_load_store
     GlFunction(Void, "glBindImageTexture", [(GLuint, "unit"), (GLtexture, "texture"), (GLint, "level"), (GLboolean, "layered"), (GLint, "layer"), (GLenum, "access"), (GLenum, "format")]),
@@ -1344,23 +1344,107 @@ glapi.addFunctions([
     GlFunction(Void, "glTextureStorage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLsizei, "levels"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glTextureStorage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLsizei, "levels"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth")]),
 
+    # GL_KHR_debug
+    GlFunction(Void, "glDebugMessageControl", [(GLenum, "source"), (GLenum, "type"), (GLenum, "severity"), (GLsizei, "count"), (Array(Const(GLuint), "count"), "ids"), (GLboolean, "enabled")], sideeffects=False),
+    GlFunction(Void, "glDebugMessageInsert", [(GLenum, "source"), (GLenum, "type"), (GLuint, "id"), (GLenum, "severity"), (GLsizei, "length"), (OpaqueArray(Const(GLchar), "_glDebugMessageInsert_size(buf, length)"), "buf")], sideeffects=False),
+    GlFunction(Void, "glDebugMessageCallback", [(GLDEBUGPROC, "callback"), (OpaquePointer(Const(Void)), "userParam")], sideeffects=False),
+    GlFunction(GLuint, "glGetDebugMessageLog", [(GLuint, "count"), (GLsizei, "bufsize"), Out(OpaqueArray(GLenum, "_glGetDebugMessageLog_size(count)"), "sources"), Out(OpaqueArray(GLenum, "_glGetDebugMessageLog_size(count)"), "types"), Out(OpaqueArray(GLuint, "_glGetDebugMessageLog_size(count)"), "ids"), Out(OpaqueArray(GLenum, "_glGetDebugMessageLog_size(count)"), "severities"), Out(OpaqueArray(GLsizei, "_glGetDebugMessageLog_size(count)"), "lengths"), Out(OpaqueArray(GLchar, "_glGetDebugMessageLog_size(bufsize)"), "messageLog")], sideeffects=False),
+    GlFunction(Void, "glPushDebugGroup", [(GLenum, "source"), (GLuint, "id"), (GLsizei, "length"), (OpaqueArray(Const(GLchar), "_glPushDebugGroup_size(message, length)"), "message")], sideeffects=False),
+    GlFunction(Void, "glPopDebugGroup", [], sideeffects=False),
+    GlFunction(Void, "glObjectLabel", [(GLenum, "identifier"), (GLuint, "name"), (GLsizei, "length"), (OpaqueArray(Const(GLchar), "_glObjectLabel_size(label, length)"), "label")], sideeffects=False),
+    GlFunction(Void, "glGetObjectLabel", [(GLenum, "identifier"), (GLuint, "name"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "label")], sideeffects=False),
+    GlFunction(Void, "glObjectPtrLabel", [(OpaquePointer(Const(Void)), "ptr"), (GLsizei, "length"), (OpaqueArray(Const(GLchar), "_glObjectPtrLabel_size(label, length)"), "label")], sideeffects=False),
+    GlFunction(Void, "glGetObjectPtrLabel", [(OpaquePointer(Const(Void)), "ptr"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "label")], sideeffects=False),
+
+    # GL_ARB_clear_buffer_object
+    GlFunction(Void, "glClearBufferData", [(GLenum, "target"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (OpaqueArray(Const(Void), "_glClearBufferData_size(format, type)"), "data")]),
+    GlFunction(Void, "glClearBufferSubData", [(GLenum, "target"), (GLenum, "internalformat"), (GLintptr, "offset"), (GLsizeiptr, "size"), (GLenum, "format"), (GLenum, "type"), (OpaqueArray(Const(Void), "_glClearBufferSubData_size(format, type)"), "data")]),
+    GlFunction(Void, "glClearNamedBufferDataEXT", [(GLbuffer, "buffer"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (OpaqueArray(Const(Void), "_glClearNamedBufferDataEXT_size(format, type)"), "data")]),
+    GlFunction(Void, "glClearNamedBufferSubDataEXT", [(GLbuffer, "buffer"), (GLenum, "internalformat"), (GLenum, "format"), (GLenum, "type"), (GLsizeiptr, "offset"), (GLsizeiptr, "size"), (OpaqueArray(Const(Void), "_glClearNamedBufferSubDataEXT_size(format, type)"), "data")]),
+
+    # GL_ARB_compute_shader
+    GlFunction(Void, "glDispatchCompute", [(GLuint, "num_groups_x"), (GLuint, "num_groups_y"), (GLuint, "num_groups_z")]),
+    GlFunction(Void, "glDispatchComputeIndirect", [(GLintptr, "indirect")]),
+
+    # GL_ARB_copy_image
+    GlFunction(Void, "glCopyImageSubData", [(GLuint, "srcName"), (GLenum, "srcTarget"), (GLint, "srcLevel"), (GLint, "srcX"), (GLint, "srcY"), (GLint, "srcZ"), (GLuint, "dstName"), (GLenum, "dstTarget"), (GLint, "dstLevel"), (GLint, "dstX"), (GLint, "dstY"), (GLint, "dstZ"), (GLsizei, "srcWidth"), (GLsizei, "srcHeight"), (GLsizei, "srcDepth")]),
+
+    # GL_ARB_framebuffer_no_attachments
+    GlFunction(Void, "glFramebufferParameteri", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
+    GlFunction(Void, "glGetFramebufferParameteriv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glNamedFramebufferParameteriEXT", [(GLuint, "framebuffer"), (GLenum, "pname"), (GLint, "param")]),
+    GlFunction(Void, "glGetNamedFramebufferParameterivEXT", [(GLuint, "framebuffer"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+
+    # GL_ARB_internalformat_query2
+    GlFunction(Void, "glGetInternalformati64v", [(GLenum, "target"), (GLenum, "internalformat"), (GLenum, "pname"), (GLsizei, "bufSize"), Out(Array(GLint64, "bufSize"), "params")], sideeffects=False),
+
+    # GL_ARB_invalidate_subdata
+    GlFunction(Void, "glInvalidateTexSubImage", [(GLtexture, "texture"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth")]),
+    GlFunction(Void, "glInvalidateTexImage", [(GLtexture, "texture"), (GLint, "level")]),
+    GlFunction(Void, "glInvalidateBufferSubData", [(GLuint, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "length")]),
+    GlFunction(Void, "glInvalidateBufferData", [(GLbuffer, "buffer")]),
+    GlFunction(Void, "glInvalidateFramebuffer", [(GLenum, "target"), (GLsizei, "numAttachments"), (Array(Const(GLenum), "numAttachments"), "attachments")]),
+    GlFunction(Void, "glInvalidateSubFramebuffer", [(GLenum, "target"), (GLsizei, "numAttachments"), (Array(Const(GLenum), "numAttachments"), "attachments"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
+
+    # GL_ARB_multi_draw_indirect
+    GlFunction(Void, "glMultiDrawArraysIndirect", [(GLenum, "mode"), (OpaqueArray(Const(Void), "_glMultiDrawArraysIndirect_size(drawcount, stride)"), "indirect"), (GLsizei, "drawcount"), (GLsizei, "stride")]),
+    GlFunction(Void, "glMultiDrawElementsIndirect", [(GLenum, "mode"), (GLenum, "type"), (OpaqueArray(Const(Void), "_glMultiDrawElementsIndirect_size(drawcount, stride)"), "indirect"), (GLsizei, "drawcount"), (GLsizei, "stride")]),
+
+    # GL_ARB_program_interface_query
+    GlFunction(Void, "glGetProgramInterfaceiv", [(GLprogram, "program"), (GLenum, "programInterface"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(GLuint, "glGetProgramResourceIndex", [(GLprogram, "program"), (GLenum, "programInterface"), (OpaqueArray(Const(GLchar), "_glGetProgramResourceIndex_size(name)"), "name")], sideeffects=False),
+    GlFunction(Void, "glGetProgramResourceName", [(GLprogram, "program"), (GLenum, "programInterface"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "name")], sideeffects=False),
+    GlFunction(Void, "glGetProgramResourceiv", [(GLprogram, "program"), (GLenum, "programInterface"), (GLuint, "index"), (GLsizei, "propCount"), (Array(Const(GLenum), "propCount"), "props"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLint, "bufSize"), "params")], sideeffects=False),
+    GlFunction(GLlocation, "glGetProgramResourceLocation", [(GLprogram, "program"), (GLenum, "programInterface"), (GLstringConst, "name")], sideeffects=False),
+    GlFunction(GLlocation, "glGetProgramResourceLocationIndex", [(GLprogram, "program"), (GLenum, "programInterface"), (GLstringConst, "name")], sideeffects=False),
+
+    # GL_ARB_shader_storage_buffer_object
+    GlFunction(Void, "glShaderStorageBlockBinding", [(GLprogram, "program"), (GLuint, "storageBlockIndex"), (GLuint, "storageBlockBinding")]),
+
+    # GL_ARB_texture_buffer_range
+    GlFunction(Void, "glTexBufferRange", [(GLenum, "target"), (GLenum, "internalformat"), (GLuint, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "size")]),
+    GlFunction(Void, "glTextureBufferRangeEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "internalformat"), (GLuint, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "size")]),
+
+    # GL_ARB_texture_storage_multisample
+    GlFunction(Void, "glTexStorage2DMultisample", [(GLenum, "target"), (GLsizei, "samples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLboolean, "fixedsamplelocations")]),
+    GlFunction(Void, "glTexStorage3DMultisample", [(GLenum, "target"), (GLsizei, "samples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLboolean, "fixedsamplelocations")]),
+    GlFunction(Void, "glTextureStorage2DMultisampleEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLsizei, "samples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLboolean, "fixedsamplelocations")]),
+    GlFunction(Void, "glTextureStorage3DMultisampleEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLsizei, "samples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLboolean, "fixedsamplelocations")]),
+
+    # GL_ARB_texture_view
+    GlFunction(Void, "glTextureView", [(GLtexture, "texture"), (GLenum, "target"), (GLtexture, "origtexture"), (GLenum, "internalformat"), (GLuint, "minlevel"), (GLuint, "numlevels"), (GLuint, "minlayer"), (GLuint, "numlayers")]),
+
+    # GL_ARB_vertex_attrib_binding
+    GlFunction(Void, "glBindVertexBuffer", [(GLuint, "bindingindex"), (GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizei, "stride")]),
+    GlFunction(Void, "glVertexAttribFormat", [(GLuint, "attribindex"), (GLint, "size"), (GLenum, "type"), (GLboolean, "normalized"), (GLuint, "relativeoffset")]),
+    GlFunction(Void, "glVertexAttribIFormat", [(GLuint, "attribindex"), (GLint, "size"), (GLenum, "type"), (GLuint, "relativeoffset")]),
+    GlFunction(Void, "glVertexAttribLFormat", [(GLuint, "attribindex"), (GLint, "size"), (GLenum, "type"), (GLuint, "relativeoffset")]),
+    GlFunction(Void, "glVertexAttribBinding", [(GLuint, "attribindex"), (GLuint, "bindingindex")]),
+    GlFunction(Void, "glVertexBindingDivisor", [(GLuint, "bindingindex"), (GLuint, "divisor")]),
+    GlFunction(Void, "glVertexArrayBindVertexBufferEXT", [(GLarray, "vaobj"), (GLuint, "bindingindex"), (GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizei, "stride")]),
+    GlFunction(Void, "glVertexArrayVertexAttribFormatEXT", [(GLarray, "vaobj"), (GLuint, "attribindex"), (GLint, "size"), (GLenum, "type"), (GLboolean, "normalized"), (GLuint, "relativeoffset")]),
+    GlFunction(Void, "glVertexArrayVertexAttribIFormatEXT", [(GLarray, "vaobj"), (GLuint, "attribindex"), (GLint, "size"), (GLenum, "type"), (GLuint, "relativeoffset")]),
+    GlFunction(Void, "glVertexArrayVertexAttribLFormatEXT", [(GLarray, "vaobj"), (GLuint, "attribindex"), (GLint, "size"), (GLenum, "type"), (GLuint, "relativeoffset")]),
+    GlFunction(Void, "glVertexArrayVertexAttribBindingEXT", [(GLarray, "vaobj"), (GLuint, "attribindex"), (GLuint, "bindingindex")]),
+    GlFunction(Void, "glVertexArrayVertexBindingDivisorEXT", [(GLarray, "vaobj"), (GLuint, "bindingindex"), (GLuint, "divisor")]),
+
     # GL_EXT_blend_color
-    GlFunction(Void, "glBlendColorEXT", [(GLclampf, "red"), (GLclampf, "green"), (GLclampf, "blue"), (GLclampf, "alpha")]),
+    GlFunction(Void, "glBlendColorEXT", [(GLfloat, "red"), (GLfloat, "green"), (GLfloat, "blue"), (GLfloat, "alpha")]),
 
     # GL_EXT_polygon_offset
     GlFunction(Void, "glPolygonOffsetEXT", [(GLfloat, "factor"), (GLfloat, "bias")]),
 
     # GL_EXT_texture3D
-    GlFunction(Void, "glTexImage3DEXT", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexImage3D_size(format, type, width, height, depth)"), "pixels")]),
-    GlFunction(Void, "glTexSubImage3DEXT", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexSubImage3D_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glTexImage3DEXT", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexImage3D_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage3DEXT", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexSubImage3D_size(format, type, width, height, depth)"), "pixels")]),
 
     # GL_SGIS_texture_filter4
-    GlFunction(Void, "glGetTexFilterFuncSGIS", [(GLenum, "target"), (GLenum, "filter"), Out(OpaqueArray(GLfloat, "__glGetTexFilterFuncSGIS_size(target, filter)"), "weights")], sideeffects=False),
+    GlFunction(Void, "glGetTexFilterFuncSGIS", [(GLenum, "target"), (GLenum, "filter"), Out(OpaqueArray(GLfloat, "_glGetTexFilterFuncSGIS_size(target, filter)"), "weights")], sideeffects=False),
     GlFunction(Void, "glTexFilterFuncSGIS", [(GLenum, "target"), (GLenum, "filter"), (GLsizei, "n"), (Array(Const(GLfloat), "n"), "weights")]),
 
     # GL_EXT_subtexture
-    GlFunction(Void, "glTexSubImage1DEXT", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexSubImage1D_size(format, type, width)"), "pixels")]),
-    GlFunction(Void, "glTexSubImage2DEXT", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexSubImage2D_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage1DEXT", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexSubImage1D_size(format, type, width)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage2DEXT", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexSubImage2D_size(format, type, width, height)"), "pixels")]),
 
     # GL_EXT_copy_texture
     GlFunction(Void, "glCopyTexImage1DEXT", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLint, "border")]),
@@ -1370,58 +1454,58 @@ glapi.addFunctions([
     GlFunction(Void, "glCopyTexSubImage3DEXT", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
 
     # GL_EXT_histogram
-    GlFunction(Void, "glGetHistogramEXT", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetHistogramEXT_size(target, format, type)"), "values")], sideeffects=False),
-    GlFunction(Void, "glGetHistogramParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetHistogramParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMinmaxEXT", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetMinmaxEXT_size(target, format, type)"), "values")], sideeffects=False),
-    GlFunction(Void, "glGetMinmaxParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMinmaxParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetHistogramEXT", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetHistogramEXT_size(target, format, type)"), "values")], sideeffects=False),
+    GlFunction(Void, "glGetHistogramParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetHistogramParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMinmaxEXT", [(GLenum, "target"), (GLboolean, "reset"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetMinmaxEXT_size(target, format, type)"), "values")], sideeffects=False),
+    GlFunction(Void, "glGetMinmaxParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMinmaxParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glHistogramEXT", [(GLenum, "target"), (GLsizei, "width"), (GLenum, "internalformat"), (GLboolean, "sink")]),
     GlFunction(Void, "glMinmaxEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLboolean, "sink")]),
     GlFunction(Void, "glResetHistogramEXT", [(GLenum, "target")]),
     GlFunction(Void, "glResetMinmaxEXT", [(GLenum, "target")]),
 
     # GL_EXT_convolution
-    GlFunction(Void, "glConvolutionFilter1DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glConvolutionFilter1D_size(format, type, width)"), "image")]),
-    GlFunction(Void, "glConvolutionFilter2DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glConvolutionFilter2D_size(format, type, width, height)"), "image")]),
+    GlFunction(Void, "glConvolutionFilter1DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glConvolutionFilter1D_size(format, type, width)"), "image")]),
+    GlFunction(Void, "glConvolutionFilter2DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glConvolutionFilter2D_size(format, type, width, height)"), "image")]),
     GlFunction(Void, "glConvolutionParameterfEXT", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "params")]),
-    GlFunction(Void, "glConvolutionParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glConvolutionParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glConvolutionParameteriEXT", [(GLenum, "target"), (GLenum, "pname"), (GLint, "params")]),
-    GlFunction(Void, "glConvolutionParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glConvolutionParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glCopyConvolutionFilter1DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
     GlFunction(Void, "glCopyConvolutionFilter2DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetConvolutionFilterEXT", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetConvolutionFilterEXT_size(target, format, type)"), "image")], sideeffects=False),
-    GlFunction(Void, "glGetConvolutionParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetConvolutionParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetSeparableFilterEXT", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetSeparableFilterEXT_size(target, format, type)"), "row"), Out(OpaqueBlob(GLvoid, "__glGetSeparableFilterEXT_size(target, format, type)"), "column"), Out(OpaqueBlob(GLvoid, "__glGetSeparableFilterEXT_size(target, format, type)"), "span")], sideeffects=False),
-    GlFunction(Void, "glSeparableFilter2DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glConvolutionFilter1D_size(format, type, width)"), "row"), (Blob(Const(GLvoid), "__glConvolutionFilter1D_size(format, type, height)"), "column")]),
+    GlFunction(Void, "glGetConvolutionFilterEXT", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetConvolutionFilterEXT_size(target, format, type)"), "image")], sideeffects=False),
+    GlFunction(Void, "glGetConvolutionParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetConvolutionParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetSeparableFilterEXT", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetSeparableFilterEXT_size(target, format, type)"), "row"), Out(OpaqueBlob(GLvoid, "_glGetSeparableFilterEXT_size(target, format, type)"), "column"), Out(OpaqueBlob(GLvoid, "_glGetSeparableFilterEXT_size(target, format, type)"), "span")], sideeffects=False),
+    GlFunction(Void, "glSeparableFilter2DEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glConvolutionFilter1D_size(format, type, width)"), "row"), (Blob(Const(GLvoid), "_glConvolutionFilter1D_size(format, type, height)"), "column")]),
 
     # GL_SGI_color_table
-    GlFunction(Void, "glColorTableSGI", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glColorTable_size(format, type, width)"), "table")]),
-    GlFunction(Void, "glColorTableParameterfvSGI", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glColorTableParameterivSGI", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glColorTableSGI", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glColorTable_size(format, type, width)"), "table")]),
+    GlFunction(Void, "glColorTableParameterfvSGI", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glColorTableParameterivSGI", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glCopyColorTableSGI", [(GLenum, "target"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
-    GlFunction(Void, "glGetColorTableSGI", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetColorTableSGI_size(target, format, type)"), "table")], sideeffects=False),
-    GlFunction(Void, "glGetColorTableParameterfvSGI", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetColorTableParameterivSGI", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetColorTableSGI", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetColorTableSGI_size(target, format, type)"), "table")], sideeffects=False),
+    GlFunction(Void, "glGetColorTableParameterfvSGI", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetColorTableParameterivSGI", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_SGIX_pixel_texture
     GlFunction(Void, "glPixelTexGenSGIX", [(GLenum, "mode")]),
 
     # GL_SGIS_pixel_texture
     GlFunction(Void, "glPixelTexGenParameteriSGIS", [(GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glPixelTexGenParameterivSGIS", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPixelTexGenParameterivSGIS", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glPixelTexGenParameterfSGIS", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glPixelTexGenParameterfvSGIS", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetPixelTexGenParameterivSGIS", [(GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetPixelTexGenParameterfvSGIS", [(GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glPixelTexGenParameterfvSGIS", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetPixelTexGenParameterivSGIS", [(GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetPixelTexGenParameterfvSGIS", [(GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_SGIS_texture4D
-    GlFunction(Void, "glTexImage4DSGIS", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLsizei, "size4d"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "__glTexImage4DSGIS_size(format, type, width, height, depth, size4d)"), "pixels")]),
-    GlFunction(Void, "glTexSubImage4DSGIS", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "woffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLsizei, "size4d"), (GLenum, "format"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "__glTexSubImage4DSGIS_size(format, type, width, height, depth, size4d)"), "pixels")]),
+    GlFunction(Void, "glTexImage4DSGIS", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLsizei, "size4d"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "_glTexImage4DSGIS_size(format, type, width, height, depth, size4d)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage4DSGIS", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "woffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLsizei, "size4d"), (GLenum, "format"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "_glTexSubImage4DSGIS_size(format, type, width, height, depth, size4d)"), "pixels")]),
 
     # GL_EXT_texture_object
-    GlFunction(GLboolean, "glAreTexturesResidentEXT", [(GLsizei, "n"), (Array(Const(GLtexture), "n"), "textures"), Out(Array(GLboolean, "n"), "residences")]),
+    GlFunction(GLboolean, "glAreTexturesResidentEXT", [(GLsizei, "n"), (Array(Const(GLtexture), "n"), "textures"), Out(Array(GLboolean, "n"), "residences")], sideeffects=False),
     GlFunction(Void, "glBindTextureEXT", [(GLenum, "target"), (GLtexture, "texture")]),
     GlFunction(Void, "glDeleteTexturesEXT", [(GLsizei, "n"), (Array(Const(GLtexture), "n"), "textures")]),
     GlFunction(Void, "glGenTexturesEXT", [(GLsizei, "n"), Out(Array(GLtexture, "n"), "textures")]),
@@ -1430,11 +1514,11 @@ glapi.addFunctions([
 
     # GL_SGIS_detail_texture
     GlFunction(Void, "glDetailTexFuncSGIS", [(GLenum, "target"), (GLsizei, "n"), (Array(Const(GLfloat), "n*2"), "points")]),
-    GlFunction(Void, "glGetDetailTexFuncSGIS", [(GLenum, "target"), Out(OpaqueArray(GLfloat, "__glGetDetailTexFuncSGIS_size(target)"), "points")], sideeffects=False),
+    GlFunction(Void, "glGetDetailTexFuncSGIS", [(GLenum, "target"), Out(OpaqueArray(GLfloat, "_glGetDetailTexFuncSGIS_size(target)"), "points")], sideeffects=False),
 
     # GL_SGIS_sharpen_texture
     GlFunction(Void, "glSharpenTexFuncSGIS", [(GLenum, "target"), (GLsizei, "n"), (Array(Const(GLfloat), "n*2"), "points")]),
-    GlFunction(Void, "glGetSharpenTexFuncSGIS", [(GLenum, "target"), Out(OpaqueArray(GLfloat, "__glGetSharpenTexFuncSGIS_size(target)"), "points")], sideeffects=False),
+    GlFunction(Void, "glGetSharpenTexFuncSGIS", [(GLenum, "target"), Out(OpaqueArray(GLfloat, "_glGetSharpenTexFuncSGIS_size(target)"), "points")], sideeffects=False),
 
     # GL_SGIS_multisample
     GlFunction(Void, "glSampleMaskSGIS", [(GLclampf, "value"), (GLboolean, "invert")]),
@@ -1456,17 +1540,17 @@ glapi.addFunctions([
 
     # GL_SGIX_sprite
     GlFunction(Void, "glSpriteParameterfSGIX", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glSpriteParameterfvSGIX", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glSpriteParameterfvSGIX", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glSpriteParameteriSGIX", [(GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glSpriteParameterivSGIX", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glSpriteParameterivSGIX", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
 
     # GL_EXT_point_parameters
     GlFunction(Void, "glPointParameterfEXT", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glPointParameterfvEXT", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPointParameterfvEXT", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
 
     # GL_SGIS_point_parameters
     GlFunction(Void, "glPointParameterfSGIS", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glPointParameterfvSGIS", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPointParameterfvSGIS", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
 
     # GL_SGIX_instruments
     GlFunction(GLint, "glGetInstrumentsSGIX", [], sideeffects=False),
@@ -1483,8 +1567,8 @@ glapi.addFunctions([
     GlFunction(Void, "glTagSampleBufferSGIX", []),
 
     # GL_SGIX_polynomial_ffd
-    GlFunction(Void, "glDeformationMap3dSGIX", [(GLenum, "target"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLdouble, "v1"), (GLdouble, "v2"), (GLint, "vstride"), (GLint, "vorder"), (GLdouble, "w1"), (GLdouble, "w2"), (GLint, "wstride"), (GLint, "worder"), (OpaqueArray(Const(GLdouble), "__glDeformationMap3dSGIX_size(target, ustride, uorder, vstride, vorder, wstride, worder)"), "points")]),
-    GlFunction(Void, "glDeformationMap3fSGIX", [(GLenum, "target"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLfloat, "v1"), (GLfloat, "v2"), (GLint, "vstride"), (GLint, "vorder"), (GLfloat, "w1"), (GLfloat, "w2"), (GLint, "wstride"), (GLint, "worder"), (OpaqueArray(Const(GLfloat), "__glDeformationMap3fSGIX_size(target, ustride, uorder, vstride, vorder, wstride, worder)"), "points")]),
+    GlFunction(Void, "glDeformationMap3dSGIX", [(GLenum, "target"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLdouble, "v1"), (GLdouble, "v2"), (GLint, "vstride"), (GLint, "vorder"), (GLdouble, "w1"), (GLdouble, "w2"), (GLint, "wstride"), (GLint, "worder"), (OpaqueArray(Const(GLdouble), "_glDeformationMap3dSGIX_size(target, ustride, uorder, vstride, vorder, wstride, worder)"), "points")]),
+    GlFunction(Void, "glDeformationMap3fSGIX", [(GLenum, "target"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLfloat, "v1"), (GLfloat, "v2"), (GLint, "vstride"), (GLint, "vorder"), (GLfloat, "w1"), (GLfloat, "w2"), (GLint, "wstride"), (GLint, "worder"), (OpaqueArray(Const(GLfloat), "_glDeformationMap3fSGIX_size(target, ustride, uorder, vstride, vorder, wstride, worder)"), "points")]),
     GlFunction(Void, "glDeformSGIX", [(GLbitfield, "mask")]),
     GlFunction(Void, "glLoadIdentityDeformationMapSGIX", [(GLbitfield, "mask")]),
 
@@ -1496,36 +1580,36 @@ glapi.addFunctions([
 
     # GL_SGIS_fog_function
     GlFunction(Void, "glFogFuncSGIS", [(GLsizei, "n"), (Array(Const(GLfloat), "n*2"), "points")]),
-    GlFunction(Void, "glGetFogFuncSGIS", [Out(OpaqueArray(GLfloat, "__glGetFogFuncSGIS_size()"), "points")], sideeffects=False),
+    GlFunction(Void, "glGetFogFuncSGIS", [Out(OpaqueArray(GLfloat, "_glGetFogFuncSGIS_size()"), "points")], sideeffects=False),
 
     # GL_HP_image_transform
     GlFunction(Void, "glImageTransformParameteriHP", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
     GlFunction(Void, "glImageTransformParameterfHP", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glImageTransformParameterivHP", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glImageTransformParameterfvHP", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetImageTransformParameterivHP", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetImageTransformParameterfvHP", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glImageTransformParameterivHP", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glImageTransformParameterfvHP", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetImageTransformParameterivHP", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetImageTransformParameterfvHP", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_EXT_color_subtable
-    GlFunction(Void, "glColorSubTableEXT", [(GLenum, "target"), (GLsizei, "start"), (GLsizei, "count"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glColorSubTable_size(format, type, count)"), "data")]),
+    GlFunction(Void, "glColorSubTableEXT", [(GLenum, "target"), (GLsizei, "start"), (GLsizei, "count"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glColorSubTable_size(format, type, count)"), "data")]),
     GlFunction(Void, "glCopyColorSubTableEXT", [(GLenum, "target"), (GLsizei, "start"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
 
     # GL_PGI_misc_hints
     GlFunction(Void, "glHintPGI", [(GLenum, "target"), (GLint, "mode")]),
 
     # GL_EXT_paletted_texture
-    GlFunction(Void, "glColorTableEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glColorTable_size(format, type, width)"), "table")]),
-    GlFunction(Void, "glGetColorTableEXT", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetColorTableEXT_size(target, format, type)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetColorTableParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetColorTableParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glColorTableEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glColorTable_size(format, type, width)"), "table")]),
+    GlFunction(Void, "glGetColorTableEXT", [(GLenum, "target"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetColorTableEXT_size(target, format, type)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetColorTableParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetColorTableParameterfvEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_SGIX_list_priority
-    GlFunction(Void, "glGetListParameterfvSGIX", [(GLuint, "list"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetListParameterivSGIX", [(GLuint, "list"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetListParameterfvSGIX", [(GLuint, "list"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetListParameterivSGIX", [(GLuint, "list"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glListParameterfSGIX", [(GLuint, "list"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glListParameterfvSGIX", [(GLuint, "list"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glListParameterfvSGIX", [(GLuint, "list"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glListParameteriSGIX", [(GLuint, "list"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glListParameterivSGIX", [(GLuint, "list"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glListParameterivSGIX", [(GLuint, "list"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
 
     # GL_EXT_index_material
     GlFunction(Void, "glIndexMaterialEXT", [(GLenum, "face"), (GLenum, "mode")]),
@@ -1538,27 +1622,27 @@ glapi.addFunctions([
     GlFunction(Void, "glUnlockArraysEXT", []),
 
     # GL_EXT_cull_vertex
-    GlFunction(Void, "glCullParameterdvEXT", [(GLenum, "pname"), Out(Array(GLdouble, 4), "params")]),
-    GlFunction(Void, "glCullParameterfvEXT", [(GLenum, "pname"), Out(Array(GLfloat, 4), "params")]),
+    GlFunction(Void, "glCullParameterdvEXT", [(GLenum, "pname"), (Array(GLdouble, 4), "params")]),
+    GlFunction(Void, "glCullParameterfvEXT", [(GLenum, "pname"), (Array(GLfloat, 4), "params")]),
 
     # GL_SGIX_fragment_lighting
     GlFunction(Void, "glFragmentColorMaterialSGIX", [(GLenum, "face"), (GLenum, "mode")]),
     GlFunction(Void, "glFragmentLightfSGIX", [(GLenum, "light"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glFragmentLightfvSGIX", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFragmentLightfvSGIX", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFragmentLightiSGIX", [(GLenum, "light"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glFragmentLightivSGIX", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFragmentLightivSGIX", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFragmentLightModelfSGIX", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glFragmentLightModelfvSGIX", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFragmentLightModelfvSGIX", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFragmentLightModeliSGIX", [(GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glFragmentLightModelivSGIX", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFragmentLightModelivSGIX", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFragmentMaterialfSGIX", [(GLenum, "face"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glFragmentMaterialfvSGIX", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFragmentMaterialfvSGIX", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFragmentMaterialiSGIX", [(GLenum, "face"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glFragmentMaterialivSGIX", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetFragmentLightfvSGIX", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetFragmentLightivSGIX", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetFragmentMaterialfvSGIX", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetFragmentMaterialivSGIX", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glFragmentMaterialivSGIX", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetFragmentLightfvSGIX", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFragmentLightivSGIX", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFragmentMaterialfvSGIX", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFragmentMaterialivSGIX", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glLightEnviSGIX", [(GLenum, "pname"), (GLint, "param")]),
 
     # GL_EXT_draw_range_elements
@@ -1663,9 +1747,9 @@ glapi.addFunctions([
     GlFunction(Void, "glReplacementCodeuiSUN", [(GLuint, "code")]),
     GlFunction(Void, "glReplacementCodeusSUN", [(GLushort, "code")]),
     GlFunction(Void, "glReplacementCodeubSUN", [(GLubyte, "code")]),
-    GlFunction(Void, "glReplacementCodeuivSUN", [(OpaqueArray(Const(GLuint), "__glReplacementCodeuivSUN_size()"), "code")]),
-    GlFunction(Void, "glReplacementCodeusvSUN", [(OpaqueArray(Const(GLushort), "__glReplacementCodeusvSUN_size()"), "code")]),
-    GlFunction(Void, "glReplacementCodeubvSUN", [(OpaqueArray(Const(GLubyte), "__glReplacementCodeubvSUN_size()"), "code")]),
+    GlFunction(Void, "glReplacementCodeuivSUN", [(OpaqueArray(Const(GLuint), "_glReplacementCodeuivSUN_size()"), "code")]),
+    GlFunction(Void, "glReplacementCodeusvSUN", [(OpaqueArray(Const(GLushort), "_glReplacementCodeusvSUN_size()"), "code")]),
+    GlFunction(Void, "glReplacementCodeubvSUN", [(OpaqueArray(Const(GLubyte), "_glReplacementCodeubvSUN_size()"), "code")]),
     GlFunction(Void, "glReplacementCodePointerSUN", [(GLenum, "type"), (GLsizei, "stride"), (OpaquePointer(GLpointerConst), "pointer")]),
 
     # GL_SUN_vertex
@@ -1726,19 +1810,19 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexArrayRangeNV", [(GLsizei, "length"), (GLpointerConst, "pointer")]),
 
     # GL_NV_register_combiners
-    GlFunction(Void, "glCombinerParameterfvNV", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glCombinerParameterfvNV", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glCombinerParameterfNV", [(GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glCombinerParameterivNV", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glCombinerParameterivNV", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glCombinerParameteriNV", [(GLenum, "pname"), (GLint, "param")]),
     GlFunction(Void, "glCombinerInputNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "variable"), (GLenum, "input"), (GLenum, "mapping"), (GLenum, "componentUsage")]),
     GlFunction(Void, "glCombinerOutputNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "abOutput"), (GLenum, "cdOutput"), (GLenum, "sumOutput"), (GLenum, "scale"), (GLenum, "bias"), (GLboolean, "abDotProduct"), (GLboolean, "cdDotProduct"), (GLboolean, "muxSum")]),
     GlFunction(Void, "glFinalCombinerInputNV", [(GLenum, "variable"), (GLenum, "input"), (GLenum, "mapping"), (GLenum, "componentUsage")]),
-    GlFunction(Void, "glGetCombinerInputParameterfvNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "variable"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetCombinerInputParameterivNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "variable"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetCombinerOutputParameterfvNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetCombinerOutputParameterivNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetFinalCombinerInputParameterfvNV", [(GLenum, "variable"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetFinalCombinerInputParameterivNV", [(GLenum, "variable"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetCombinerInputParameterfvNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "variable"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetCombinerInputParameterivNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "variable"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetCombinerOutputParameterfvNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetCombinerOutputParameterivNV", [(GLenum, "stage"), (GLenum, "portion"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFinalCombinerInputParameterfvNV", [(GLenum, "variable"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFinalCombinerInputParameterivNV", [(GLenum, "variable"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_MESA_resize_buffers
     GlFunction(Void, "glResizeBuffersMESA", []),
@@ -1794,49 +1878,49 @@ glapi.addFunctions([
     GlFunction(Void, "glTextureColorMaskSGIS", [(GLboolean, "red"), (GLboolean, "green"), (GLboolean, "blue"), (GLboolean, "alpha")]),
 
     # GL_SGIX_igloo_interface
-    GlFunction(Void, "glIglooInterfaceSGIX", [(GLenum, "pname"), (OpaqueBlob(Const(GLvoid), "__glIglooInterfaceSGIX_size(pname)"), "params")]),
+    GlFunction(Void, "glIglooInterfaceSGIX", [(GLenum, "pname"), (OpaqueBlob(Const(GLvoid), "_glIglooInterfaceSGIX_size(pname)"), "params")]),
 
     # GL_NV_fence
     GlFunction(Void, "glDeleteFencesNV", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "fences")]),
     GlFunction(Void, "glGenFencesNV", [(GLsizei, "n"), Out(Array(GLuint, "n"), "fences")]),
     GlFunction(GLboolean, "glIsFenceNV", [(GLuint, "fence")], sideeffects=False),
     GlFunction(GLboolean, "glTestFenceNV", [(GLuint, "fence")]),
-    GlFunction(Void, "glGetFenceivNV", [(GLuint, "fence"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFenceivNV", [(GLuint, "fence"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glFinishFenceNV", [(GLuint, "fence")]),
     GlFunction(Void, "glSetFenceNV", [(GLuint, "fence"), (GLenum, "condition")]),
 
     # GL_NV_evaluators
-    GlFunction(Void, "glMapControlPointsNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "type"), (GLsizei, "ustride"), (GLsizei, "vstride"), (GLint, "uorder"), (GLint, "vorder"), (GLboolean, "packed"), (OpaqueBlob(Const(GLvoid), "__glMapControlPointsNV_size(target, uorder, vorder)"), "points")]),
-    GlFunction(Void, "glMapParameterivNV", [(GLenum, "target"), (GLenum, "pname"), (OpaqueArray(Const(GLint), "__glMapParameterivNV_size(target, pname)"), "params")]),
-    GlFunction(Void, "glMapParameterfvNV", [(GLenum, "target"), (GLenum, "pname"), (OpaqueArray(Const(GLfloat), "__glMapParameterfvNV_size(target, pname)"), "params")]),
-    GlFunction(Void, "glGetMapControlPointsNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "type"), (GLsizei, "ustride"), (GLsizei, "vstride"), (GLboolean, "packed"), Out(OpaqueBlob(GLvoid, "__glGetMapControlPointsNV_size(target)"), "points")], sideeffects=False),
-    GlFunction(Void, "glGetMapParameterivNV", [(GLenum, "target"), (GLenum, "pname"), Out(OpaqueArray(GLint, "__glGetMapParameterivNV_size(target, pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMapParameterfvNV", [(GLenum, "target"), (GLenum, "pname"), Out(OpaqueArray(GLfloat, "__glGetMapParameterfvNV_size(target, pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMapAttribParameterivNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMapAttribParameterfvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glMapControlPointsNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "type"), (GLsizei, "ustride"), (GLsizei, "vstride"), (GLint, "uorder"), (GLint, "vorder"), (GLboolean, "packed"), (OpaqueBlob(Const(GLvoid), "_glMapControlPointsNV_size(target, uorder, vorder)"), "points")]),
+    GlFunction(Void, "glMapParameterivNV", [(GLenum, "target"), (GLenum, "pname"), (OpaqueArray(Const(GLint), "_glMapParameterivNV_size(target, pname)"), "params")]),
+    GlFunction(Void, "glMapParameterfvNV", [(GLenum, "target"), (GLenum, "pname"), (OpaqueArray(Const(GLfloat), "_glMapParameterfvNV_size(target, pname)"), "params")]),
+    GlFunction(Void, "glGetMapControlPointsNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "type"), (GLsizei, "ustride"), (GLsizei, "vstride"), (GLboolean, "packed"), Out(OpaqueBlob(GLvoid, "_glGetMapControlPointsNV_size(target)"), "points")], sideeffects=False),
+    GlFunction(Void, "glGetMapParameterivNV", [(GLenum, "target"), (GLenum, "pname"), Out(OpaqueArray(GLint, "_glGetMapParameterivNV_size(target, pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMapParameterfvNV", [(GLenum, "target"), (GLenum, "pname"), Out(OpaqueArray(GLfloat, "_glGetMapParameterfvNV_size(target, pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMapAttribParameterivNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMapAttribParameterfvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glEvalMapsNV", [(GLenum, "target"), (GLenum, "mode")]),
 
     # GL_NV_register_combiners2
-    GlFunction(Void, "glCombinerStageParameterfvNV", [(GLenum, "stage"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetCombinerStageParameterfvNV", [(GLenum, "stage"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glCombinerStageParameterfvNV", [(GLenum, "stage"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetCombinerStageParameterfvNV", [(GLenum, "stage"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_NV_vertex_program
-    GlFunction(GLboolean, "glAreProgramsResidentNV", [(GLsizei, "n"), (Array(Const(GLprogramARB), "n"), "ids"), Out(Array(GLboolean, "n"), "residences")]),
+    GlFunction(GLboolean, "glAreProgramsResidentNV", [(GLsizei, "n"), (Array(Const(GLprogramARB), "n"), "ids"), Out(Array(GLboolean, "n"), "residences")], sideeffects=False),
     GlFunction(Void, "glBindProgramNV", [(GLenum, "target"), (GLprogramARB, "program")]),
     GlFunction(Void, "glDeleteProgramsNV", [(GLsizei, "n"), (Array(Const(GLprogramARB), "n"), "programs")]),
     GlFunction(Void, "glExecuteProgramNV", [(GLenum, "target"), (GLprogramARB, "id"), (Array(Const(GLfloat), 4), "params")]),
     GlFunction(Void, "glGenProgramsNV", [(GLsizei, "n"), Out(Array(GLprogramARB, "n"), "programs")]),
-    GlFunction(Void, "glGetProgramParameterdvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetProgramParameterfvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetProgramParameterdvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetProgramParameterfvNV", [(GLenum, "target"), (GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetProgramivNV", [(GLprogramARB, "id"), (GLenum, "pname"), Out(Pointer(GLint), "params")], sideeffects=False),
-    GlFunction(Void, "glGetProgramStringNV", [(GLprogramARB, "id"), (GLenum, "pname"), Out(Array(GLubyte, "__gl_param_size(pname)"), "program")], sideeffects=False),
-    GlFunction(Void, "glGetTrackMatrixivNV", [(GLenum, "target"), (GLuint, "address"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribdvNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribfvNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribivNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetProgramStringNV", [(GLprogramARB, "id"), (GLenum, "pname"), Out(Array(GLubyte, "_gl_param_size(pname)"), "program")], sideeffects=False),
+    GlFunction(Void, "glGetTrackMatrixivNV", [(GLenum, "target"), (GLuint, "address"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribdvNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribfvNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribivNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetVertexAttribPointervNV", [(GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLpointer), "pointer")], sideeffects=False),
     GlFunction(GLboolean, "glIsProgramNV", [(GLprogramARB, "program")], sideeffects=False),
-    GlFunction(Void, "glLoadProgramNV", [(GLenum, "target"), (GLprogramARB, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "program")]),
+    GlFunction(Void, "glLoadProgramNV", [(GLenum, "target"), (GLprogramARB, "id"), (GLsizei, "len"), (String(Const(GLubyte), "len"), "program")]),
     GlFunction(Void, "glProgramParameter4dNV", [(GLenum, "target"), (GLuint, "index"), (GLdouble, "x"), (GLdouble, "y"), (GLdouble, "z"), (GLdouble, "w")]),
     GlFunction(Void, "glProgramParameter4dvNV", [(GLenum, "target"), (GLuint, "index"), (Array(Const(GLdouble), 4), "v")]),
     GlFunction(Void, "glProgramParameter4fNV", [(GLenum, "target"), (GLuint, "index"), (GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "w")]),
@@ -1887,10 +1971,10 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexAttribs4ubvNV", [(GLuint, "index"), (GLsizei, "count"), (Array(Const(GLubyte), "count*4"), "v")]),
 
     # GL_ATI_envmap_bumpmap
-    GlFunction(Void, "glTexBumpParameterivATI", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "param")]),
-    GlFunction(Void, "glTexBumpParameterfvATI", [(GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "param")]),
-    GlFunction(Void, "glGetTexBumpParameterivATI", [(GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "param")], sideeffects=False),
-    GlFunction(Void, "glGetTexBumpParameterfvATI", [(GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "param")], sideeffects=False),
+    GlFunction(Void, "glTexBumpParameterivATI", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "param")]),
+    GlFunction(Void, "glTexBumpParameterfvATI", [(GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "param")]),
+    GlFunction(Void, "glGetTexBumpParameterivATI", [(GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "param")], sideeffects=False),
+    GlFunction(Void, "glGetTexBumpParameterfvATI", [(GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "param")], sideeffects=False),
 
     # GL_ATI_fragment_shader
     GlFunction(Handle("fragmentShaderATI", GLuint, "range"), "glGenFragmentShadersATI", [(GLuint, "range")]),
@@ -1940,17 +2024,17 @@ glapi.addFunctions([
     GlFunction(Void, "glInsertComponentEXT", [(GLuint, "res"), (GLuint, "src"), (GLuint, "num")]),
     GlFunction(Void, "glExtractComponentEXT", [(GLuint, "res"), (GLuint, "src"), (GLuint, "num")]),
     GlFunction(GLuint, "glGenSymbolsEXT", [(GLenum, "datatype"), (GLenum, "storagetype"), (GLenum, "range"), (GLuint, "components")]),
-    GlFunction(Void, "glSetInvariantEXT", [(GLuint, "id"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "__glSetInvariantEXT_size(id, type)"), "addr")]),
-    GlFunction(Void, "glSetLocalConstantEXT", [(GLuint, "id"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "__glSetLocalConstantEXT_size(id, type)"), "addr")]),
-    GlFunction(Void, "glVariantbvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLbyte), "__glVariantbvEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantsvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLshort), "__glVariantsvEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantivEXT", [(GLuint, "id"), (OpaqueArray(Const(GLint), "__glVariantivEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantfvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLfloat), "__glVariantfvEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantdvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLdouble), "__glVariantdvEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantubvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLubyte), "__glVariantubvEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantusvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLushort), "__glVariantusvEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantuivEXT", [(GLuint, "id"), (OpaqueArray(Const(GLuint), "__glVariantuivEXT_size(id)"), "addr")]),
-    GlFunction(Void, "glVariantPointerEXT", [(GLuint, "id"), (GLenum, "type"), (GLuint, "stride"), (OpaqueBlob(Const(GLvoid), "__glVariantPointerEXT_size(id, type, stride)"), "addr")]),
+    GlFunction(Void, "glSetInvariantEXT", [(GLuint, "id"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "_glSetInvariantEXT_size(id, type)"), "addr")]),
+    GlFunction(Void, "glSetLocalConstantEXT", [(GLuint, "id"), (GLenum, "type"), (OpaqueBlob(Const(GLvoid), "_glSetLocalConstantEXT_size(id, type)"), "addr")]),
+    GlFunction(Void, "glVariantbvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLbyte), "_glVariantbvEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantsvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLshort), "_glVariantsvEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantivEXT", [(GLuint, "id"), (OpaqueArray(Const(GLint), "_glVariantivEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantfvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLfloat), "_glVariantfvEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantdvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLdouble), "_glVariantdvEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantubvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLubyte), "_glVariantubvEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantusvEXT", [(GLuint, "id"), (OpaqueArray(Const(GLushort), "_glVariantusvEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantuivEXT", [(GLuint, "id"), (OpaqueArray(Const(GLuint), "_glVariantuivEXT_size(id)"), "addr")]),
+    GlFunction(Void, "glVariantPointerEXT", [(GLuint, "id"), (GLenum, "type"), (GLuint, "stride"), (OpaqueBlob(Const(GLvoid), "_glVariantPointerEXT_size(id, type, stride)"), "addr")]),
     GlFunction(Void, "glEnableVariantClientStateEXT", [(GLuint, "id")]),
     GlFunction(Void, "glDisableVariantClientStateEXT", [(GLuint, "id")]),
     GlFunction(GLuint, "glBindLightParameterEXT", [(GLenum, "light"), (GLenum, "value")]),
@@ -1959,16 +2043,16 @@ glapi.addFunctions([
     GlFunction(GLuint, "glBindTextureUnitParameterEXT", [(GLenum, "unit"), (GLenum, "value")]),
     GlFunction(GLuint, "glBindParameterEXT", [(GLenum, "value")]),
     GlFunction(GLboolean, "glIsVariantEnabledEXT", [(GLuint, "id"), (GLenum, "cap")], sideeffects=False),
-    GlFunction(Void, "glGetVariantBooleanvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLboolean, "__glGetVariantBooleanvEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetVariantIntegervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLint, "__glGetVariantIntegervEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetVariantFloatvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLfloat, "__glGetVariantFloatvEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetVariantPointervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLpointer, "__glGetVariantPointervEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetInvariantBooleanvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLboolean, "__glGetInvariantBooleanvEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetInvariantIntegervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLint, "__glGetInvariantIntegervEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetInvariantFloatvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLfloat, "__glGetInvariantFloatvEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetLocalConstantBooleanvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLboolean, "__glGetLocalConstantBooleanvEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetLocalConstantIntegervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLint, "__glGetLocalConstantIntegervEXT_size(id)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetLocalConstantFloatvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLfloat, "__glGetLocalConstantFloatvEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetVariantBooleanvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLboolean, "_glGetVariantBooleanvEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetVariantIntegervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLint, "_glGetVariantIntegervEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetVariantFloatvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLfloat, "_glGetVariantFloatvEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetVariantPointervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLpointer, "_glGetVariantPointervEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetInvariantBooleanvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLboolean, "_glGetInvariantBooleanvEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetInvariantIntegervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLint, "_glGetInvariantIntegervEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetInvariantFloatvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLfloat, "_glGetInvariantFloatvEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetLocalConstantBooleanvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLboolean, "_glGetLocalConstantBooleanvEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetLocalConstantIntegervEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLint, "_glGetLocalConstantIntegervEXT_size(id)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetLocalConstantFloatvEXT", [(GLuint, "id"), (GLenum, "value"), Out(OpaqueArray(GLfloat, "_glGetLocalConstantFloatvEXT_size(id)"), "data")], sideeffects=False),
 
     # GL_ATI_vertex_streams
     GlFunction(Void, "glVertexStream1sATI", [(GLenum, "stream"), (GLshort, "x")]),
@@ -2031,12 +2115,12 @@ glapi.addFunctions([
     GlFunction(GLboolean, "glIsOcclusionQueryNV", [(GLquery, "id")], sideeffects=False),
     GlFunction(Void, "glBeginOcclusionQueryNV", [(GLquery, "id")]),
     GlFunction(Void, "glEndOcclusionQueryNV", []),
-    GlFunction(Void, "glGetOcclusionQueryivNV", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetOcclusionQueryuivNV", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetOcclusionQueryivNV", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetOcclusionQueryuivNV", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_NV_point_sprite
     GlFunction(Void, "glPointParameteriNV", [(GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glPointParameterivNV", [(GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPointParameterivNV", [(GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
 
     # GL_EXT_stencil_two_side
     GlFunction(Void, "glActiveStencilFaceEXT", [(GLenum, "face")]),
@@ -2065,8 +2149,8 @@ glapi.addFunctions([
     GlFunction(GLboolean, "glIsVertexArrayAPPLE", [(GLuint, "array")], sideeffects=False),
 
     # GL_APPLE_vertex_array_range
-    GlFunction(Void, "glVertexArrayRangeAPPLE", [(GLsizei, "length"), Out(Blob(GLvoid, "length"), "pointer")]),
-    GlFunction(Void, "glFlushVertexArrayRangeAPPLE", [(GLsizei, "length"), Out(Blob(GLvoid, "length"), "pointer")]),
+    GlFunction(Void, "glVertexArrayRangeAPPLE", [(GLsizei, "length"), (GLpointer, "pointer")]),
+    GlFunction(Void, "glFlushVertexArrayRangeAPPLE", [(GLsizei, "length"), (GLpointer, "pointer")]),
     GlFunction(Void, "glVertexArrayParameteriAPPLE", [(GLenum, "pname"), (GLint, "param")]),
 
     # GL_APPLE_flush_render
@@ -2078,12 +2162,12 @@ glapi.addFunctions([
     GlFunction(Void, "glDrawBuffersATI", [(GLsizei, "n"), (Array(Const(GLenum), "n"), "bufs")]),
 
     # GL_NV_fragment_program
-    GlFunction(Void, "glProgramNamedParameter4fNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "name"), (GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "w")]),
-    GlFunction(Void, "glProgramNamedParameter4dNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "name"), (GLdouble, "x"), (GLdouble, "y"), (GLdouble, "z"), (GLdouble, "w")]),
-    GlFunction(Void, "glProgramNamedParameter4fvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "name"), (Array(Const(GLfloat), 4), "v")]),
-    GlFunction(Void, "glProgramNamedParameter4dvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "name"), (Array(Const(GLdouble), 4), "v")]),
-    GlFunction(Void, "glGetProgramNamedParameterdvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "name"), Out(Array(GLdouble, 4), "params")], sideeffects=False),
-    GlFunction(Void, "glGetProgramNamedParameterfvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String("const GLubyte *", "len"), "name"), Out(Array(GLfloat, 4), "params")], sideeffects=False),
+    GlFunction(Void, "glProgramNamedParameter4fNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String(Const(GLubyte), "len"), "name"), (GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "w")]),
+    GlFunction(Void, "glProgramNamedParameter4dNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String(Const(GLubyte), "len"), "name"), (GLdouble, "x"), (GLdouble, "y"), (GLdouble, "z"), (GLdouble, "w")]),
+    GlFunction(Void, "glProgramNamedParameter4fvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String(Const(GLubyte), "len"), "name"), (Array(Const(GLfloat), 4), "v")]),
+    GlFunction(Void, "glProgramNamedParameter4dvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String(Const(GLubyte), "len"), "name"), (Array(Const(GLdouble), 4), "v")]),
+    GlFunction(Void, "glGetProgramNamedParameterdvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String(Const(GLubyte), "len"), "name"), Out(Array(GLdouble, 4), "params")], sideeffects=False),
+    GlFunction(Void, "glGetProgramNamedParameterfvNV", [(GLprogramARB, "id"), (GLsizei, "len"), (String(Const(GLubyte), "len"), "name"), Out(Array(GLfloat, 4), "params")], sideeffects=False),
 
     # GL_NV_half_float
     GlFunction(Void, "glVertex2hNV", [(GLhalfNV, "x"), (GLhalfNV, "y")]),
@@ -2134,7 +2218,7 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexAttribs4hvNV", [(GLuint, "index"), (GLsizei, "n"), (Array(Const(GLhalfNV), "n"), "v")]),
 
     # GL_NV_pixel_data_range
-    GlFunction(Void, "glPixelDataRangeNV", [(GLenum, "target"), (GLsizei, "length"), Out(Blob(GLvoid, "length"), "pointer")]),
+    GlFunction(Void, "glPixelDataRangeNV", [(GLenum, "target"), (GLsizei, "length"), (OpaqueBlob(Const(GLvoid), "length"), "pointer")]),
     GlFunction(Void, "glFlushPixelDataRangeNV", [(GLenum, "target")]),
 
     # GL_NV_primitive_restart
@@ -2142,7 +2226,7 @@ glapi.addFunctions([
     GlFunction(Void, "glPrimitiveRestartIndexNV", [(GLuint, "index")]),
 
     # GL_ATI_map_object_buffer
-    GlFunction(GLpointer, "glMapObjectBufferATI", [(GLbuffer, "buffer")]),
+    GlFunction(GLmap, "glMapObjectBufferATI", [(GLbuffer, "buffer")]),
     GlFunction(Void, "glUnmapObjectBufferATI", [(GLbuffer, "buffer")]),
 
     # GL_ATI_separate_stencil
@@ -2166,7 +2250,7 @@ glapi.addFunctions([
     GlFunction(Void, "glDeleteRenderbuffersEXT", [(GLsizei, "n"), (Array(Const(GLrenderbuffer), "n"), "renderbuffers")]),
     GlFunction(Void, "glGenRenderbuffersEXT", [(GLsizei, "n"), Out(Array(GLrenderbuffer, "n"), "renderbuffers")]),
     GlFunction(Void, "glRenderbufferStorageEXT", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetRenderbufferParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetRenderbufferParameterivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLboolean, "glIsFramebufferEXT", [(GLframebuffer, "framebuffer")], sideeffects=False),
     GlFunction(Void, "glBindFramebufferEXT", [(GLenum, "target"), (GLframebuffer, "framebuffer")]),
     GlFunction(Void, "glDeleteFramebuffersEXT", [(GLsizei, "n"), (Array(Const(GLframebuffer), "n"), "framebuffers")]),
@@ -2176,11 +2260,11 @@ glapi.addFunctions([
     GlFunction(Void, "glFramebufferTexture2DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
     GlFunction(Void, "glFramebufferTexture3DEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level"), (GLint, "zoffset")]),
     GlFunction(Void, "glFramebufferRenderbufferEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "renderbuffertarget"), (GLuint, "renderbuffer")]),
-    GlFunction(Void, "glGetFramebufferAttachmentParameterivEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFramebufferAttachmentParameterivEXT", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGenerateMipmapEXT", [(GLenum, "target")]),
 
     # GL_GREMEDY_string_marker
-    GlFunction(Void, "glStringMarkerGREMEDY", [(GLsizei, "len"), (Const(String("GLvoid *", "len ? len : strlen((const char *)string)")), "string")], sideeffects=False),
+    GlFunction(Void, "glStringMarkerGREMEDY", [(GLsizei, "len"), (String(Const(GLvoid), "len ? len : strlen((const char *)string)"), "string")], sideeffects=False),
 
     # GL_EXT_stencil_clear_tag
     GlFunction(Void, "glStencilClearTagEXT", [(GLsizei, "stencilTagBits"), (GLuint, "stencilClearTag")]),
@@ -2192,8 +2276,8 @@ glapi.addFunctions([
     GlFunction(Void, "glRenderbufferStorageMultisampleEXT", [(GLenum, "target"), (GLsizei, "samples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
 
     # GL_EXT_timer_query
-    GlFunction(Void, "glGetQueryObjecti64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetQueryObjectui64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjecti64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjectui64vEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_EXT_gpu_program_parameters
     GlFunction(Void, "glProgramEnvParameters4fvEXT", [(GLenum, "target"), (GLuint, "index"), (GLsizei, "count"), (Array(Const(GLfloat), "count*4"), "params")]),
@@ -2256,9 +2340,9 @@ glapi.addFunctions([
     GlFunction(Void, "glGetVertexAttribIuivEXT", [(GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLuint), "params")], sideeffects=False),
 
     # GL_EXT_gpu_shader4
-    GlFunction(Void, "glGetUniformuivEXT", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaqueArray(GLuint, "__glGetUniformuivEXT_size(program, location)"), "params")], sideeffects=False),
-    GlFunction(Void, "glBindFragDataLocationEXT", [(GLprogram, "program"), (GLuint, "color"), (Const(GLstring), "name")]),
-    GlFunction(GLlocation, "glGetFragDataLocationEXT", [(GLprogram, "program"), (Const(GLstring), "name")]),
+    GlFunction(Void, "glGetUniformuivEXT", [(GLprogram, "program"), (GLlocation, "location"), Out(OpaqueArray(GLuint, "_glGetUniformuivEXT_size(program, location)"), "params")], sideeffects=False),
+    GlFunction(Void, "glBindFragDataLocationEXT", [(GLprogram, "program"), (GLuint, "color"), (GLstringConst, "name")]),
+    GlFunction(GLlocation, "glGetFragDataLocationEXT", [(GLprogram, "program"), (GLstringConst, "name")]),
     GlFunction(Void, "glUniform1uiEXT", [(GLlocation, "location"), (GLuint, "v0")]),
     GlFunction(Void, "glUniform2uiEXT", [(GLlocation, "location"), (GLuint, "v0"), (GLuint, "v1")]),
     GlFunction(Void, "glUniform3uiEXT", [(GLlocation, "location"), (GLuint, "v0"), (GLuint, "v1"), (GLuint, "v2")]),
@@ -2290,8 +2374,8 @@ glapi.addFunctions([
 
     # GL_EXT_draw_buffers2
     GlFunction(Void, "glColorMaskIndexedEXT", [(GLuint, "index"), (GLboolean, "r"), (GLboolean, "g"), (GLboolean, "b"), (GLboolean, "a")]),
-    GlFunction(Void, "glGetBooleanIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLboolean, "__gl_param_size(target)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetIntegerIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLint, "__gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetBooleanIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLboolean, "_gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetIntegerIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLint, "_gl_param_size(target)"), "data")], sideeffects=False),
     GlFunction(Void, "glEnableIndexedEXT", [(GLenum, "target"), (GLuint, "index")]),
     GlFunction(Void, "glDisableIndexedEXT", [(GLenum, "target"), (GLuint, "index")]),
     GlFunction(GLboolean, "glIsEnabledIndexedEXT", [(GLenum, "target"), (GLuint, "index")], sideeffects=False),
@@ -2299,13 +2383,13 @@ glapi.addFunctions([
     # GL_NV_transform_feedback
     GlFunction(Void, "glBeginTransformFeedbackNV", [(GLenum_mode, "primitiveMode")]),
     GlFunction(Void, "glEndTransformFeedbackNV", []),
-    GlFunction(Void, "glTransformFeedbackAttribsNV", [(GLuint, "count"), (OpaqueArray(Const(GLint), "__glTransformFeedbackAttribsNV_size(count)"), "attribs"), (GLenum, "bufferMode")]),
+    GlFunction(Void, "glTransformFeedbackAttribsNV", [(GLuint, "count"), (OpaqueArray(Const(GLint), "_glTransformFeedbackAttribsNV_size(count)"), "attribs"), (GLenum, "bufferMode")]),
     GlFunction(Void, "glBindBufferRangeNV", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "size")]),
     GlFunction(Void, "glBindBufferOffsetNV", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer"), (GLintptr, "offset")]),
     GlFunction(Void, "glBindBufferBaseNV", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer")]),
     GlFunction(Void, "glTransformFeedbackVaryingsNV", [(GLprogram, "program"), (GLsizei, "count"), (Array(Const(GLint), "count"), "locations"), (GLenum, "bufferMode")]),
-    GlFunction(Void, "glActiveVaryingNV", [(GLprogram, "program"), (Const(GLstring), "name")]),
-    GlFunction(GLlocation, "glGetVaryingLocationNV", [(GLprogram, "program"), (Const(GLstring), "name")]),
+    GlFunction(Void, "glActiveVaryingNV", [(GLprogram, "program"), (GLstringConst, "name")]),
+    GlFunction(GLlocation, "glGetVaryingLocationNV", [(GLprogram, "program"), (GLstringConst, "name")]),
     GlFunction(Void, "glGetActiveVaryingNV", [(GLprogram, "program"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLsizei), "size"), Out(Pointer(GLenum), "type"), Out(GLstring, "name")], sideeffects=False),
     GlFunction(Void, "glGetTransformFeedbackVaryingNV", [(GLprogram, "program"), (GLuint, "index"), Out(Pointer(GLlocation), "location")], sideeffects=False),
     GlFunction(Void, "glTransformFeedbackStreamAttribsNV", [(GLsizei, "count"), (Array(Const(GLint), "count"), "attribs"), (GLsizei, "nbuffers"), (Array(Const(GLint), "nbuffers"), "bufstreams"), (GLenum, "bufferMode")]),
@@ -2316,10 +2400,10 @@ glapi.addFunctions([
     GlFunction(GLintptr, "glGetUniformOffsetEXT", [(GLprogram, "program"), (GLlocation, "location")]),
 
     # GL_EXT_texture_integer
-    GlFunction(Void, "glTexParameterIivEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glTexParameterIuivEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetTexParameterIivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexParameterIuivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glTexParameterIivEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexParameterIuivEXT", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetTexParameterIivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexParameterIuivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glClearColorIiEXT", [(GLint, "red"), (GLint, "green"), (GLint, "blue"), (GLint, "alpha")]),
     GlFunction(Void, "glClearColorIuiEXT", [(GLuint, "red"), (GLuint, "green"), (GLuint, "blue"), (GLuint, "alpha")]),
 
@@ -2333,10 +2417,10 @@ glapi.addFunctions([
     # GL_NV_present_video
     GlFunction(Void, "glPresentFrameKeyedNV", [(GLuint, "video_slot"), (GLuint64EXT, "minPresentTime"), (GLuint, "beginPresentTimeId"), (GLuint, "presentDurationId"), (GLenum, "type"), (GLenum, "target0"), (GLuint, "fill0"), (GLuint, "key0"), (GLenum, "target1"), (GLuint, "fill1"), (GLuint, "key1")]),
     GlFunction(Void, "glPresentFrameDualFillNV", [(GLuint, "video_slot"), (GLuint64EXT, "minPresentTime"), (GLuint, "beginPresentTimeId"), (GLuint, "presentDurationId"), (GLenum, "type"), (GLenum, "target0"), (GLuint, "fill0"), (GLenum, "target1"), (GLuint, "fill1"), (GLenum, "target2"), (GLuint, "fill2"), (GLenum, "target3"), (GLuint, "fill3")]),
-    GlFunction(Void, "glGetVideoivNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVideouivNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVideoi64vNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVideoui64vNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLuint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideoivNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideouivNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideoi64vNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideoui64vNV", [(GLuint, "video_slot"), (GLenum, "pname"), Out(Array(GLuint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_EXT_transform_feedback
     GlFunction(Void, "glBeginTransformFeedbackEXT", [(GLenum_mode, "primitiveMode")]),
@@ -2344,7 +2428,7 @@ glapi.addFunctions([
     GlFunction(Void, "glBindBufferRangeEXT", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "size")]),
     GlFunction(Void, "glBindBufferOffsetEXT", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer"), (GLintptr, "offset")]),
     GlFunction(Void, "glBindBufferBaseEXT", [(GLenum, "target"), (GLuint, "index"), (GLbuffer, "buffer")]),
-    GlFunction(Void, "glTransformFeedbackVaryingsEXT", [(GLprogram, "program"), (GLsizei, "count"), (Const(Array(Const(GLstring), "count")), "varyings"), (GLenum, "bufferMode")]),
+    GlFunction(Void, "glTransformFeedbackVaryingsEXT", [(GLprogram, "program"), (GLsizei, "count"), (Const(Array(GLstringConst, "count")), "varyings"), (GLenum, "bufferMode")]),
     GlFunction(Void, "glGetTransformFeedbackVaryingEXT", [(GLprogram, "program"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLsizei), "size"), Out(Pointer(GLenum), "type"), Out(GLstring, "name")], sideeffects=False),
 
     # GL_EXT_direct_state_access
@@ -2370,82 +2454,82 @@ glapi.addFunctions([
     GlFunction(Void, "glMatrixMultTransposefEXT", [(GLenum, "mode"), (Array(Const(GLfloat), 16), "m")]),
     GlFunction(Void, "glMatrixMultTransposedEXT", [(GLenum, "mode"), (Array(Const(GLdouble), 16), "m")]),
     GlFunction(Void, "glTextureParameterfEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glTextureParameterfvEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTextureParameterfvEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTextureParameteriEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glTextureParameterivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glTextureImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTextureImage1DEXT_size(format, type, width)"), "pixels")]),
-    GlFunction(Void, "glTextureImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTextureImage2DEXT_size(format, type, width, height)"), "pixels")]),
-    GlFunction(Void, "glTextureSubImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTextureSubImage1DEXT_size(format, type, width)"), "pixels")]),
-    GlFunction(Void, "glTextureSubImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTextureSubImage2DEXT_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glTextureParameterivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTextureImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTextureImage1DEXT_size(format, type, width)"), "pixels")]),
+    GlFunction(Void, "glTextureImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTextureImage2DEXT_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glTextureSubImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTextureSubImage1DEXT_size(format, type, width)"), "pixels")]),
+    GlFunction(Void, "glTextureSubImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTextureSubImage2DEXT_size(format, type, width, height)"), "pixels")]),
     GlFunction(Void, "glCopyTextureImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLint, "border")]),
     GlFunction(Void, "glCopyTextureImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border")]),
     GlFunction(Void, "glCopyTextureSubImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
     GlFunction(Void, "glCopyTextureSubImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetTextureImageEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetTextureImageEXT_size(target, level, format, type)"), "pixels")], sideeffects=False),
-    GlFunction(Void, "glGetTextureParameterfvEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTextureParameterivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTextureLevelParameterfvEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTextureLevelParameterivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glTextureImage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTextureImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
-    GlFunction(Void, "glTextureSubImage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTextureSubImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glGetTextureImageEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetTextureImageEXT_size(target, level, format, type)"), "pixels")], sideeffects=False),
+    GlFunction(Void, "glGetTextureParameterfvEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTextureParameterivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTextureLevelParameterfvEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTextureLevelParameterivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glTextureImage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTextureImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glTextureSubImage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTextureSubImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
     GlFunction(Void, "glCopyTextureSubImage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glMultiTexParameterfEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glMultiTexParameterfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMultiTexParameterfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glMultiTexParameteriEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glMultiTexParameterivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glMultiTexImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glMultiTexImage1DEXT_size(format, type, width)"), "pixels")]),
-    GlFunction(Void, "glMultiTexImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glMultiTexImage2DEXT_size(format, type, width, height)"), "pixels")]),
-    GlFunction(Void, "glMultiTexSubImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glMultiTexSubImage1DEXT_size(format, type, width)"), "pixels")]),
-    GlFunction(Void, "glMultiTexSubImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glMultiTexSubImage2DEXT_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glMultiTexParameterivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMultiTexImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glMultiTexImage1DEXT_size(format, type, width)"), "pixels")]),
+    GlFunction(Void, "glMultiTexImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glMultiTexImage2DEXT_size(format, type, width, height)"), "pixels")]),
+    GlFunction(Void, "glMultiTexSubImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glMultiTexSubImage1DEXT_size(format, type, width)"), "pixels")]),
+    GlFunction(Void, "glMultiTexSubImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glMultiTexSubImage2DEXT_size(format, type, width, height)"), "pixels")]),
     GlFunction(Void, "glCopyMultiTexImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLint, "border")]),
     GlFunction(Void, "glCopyMultiTexImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border")]),
     GlFunction(Void, "glCopyMultiTexSubImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width")]),
     GlFunction(Void, "glCopyMultiTexSubImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetMultiTexImageEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "__glGetMultiTexImageEXT_size(target, level, format, type)"), "pixels")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexParameterfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexParameterivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexLevelParameterfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexLevelParameterivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glMultiTexImage3DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glMultiTexImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
-    GlFunction(Void, "glMultiTexSubImage3DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glMultiTexSubImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glGetMultiTexImageEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "format"), (GLenum, "type"), Out(OpaqueBlob(GLvoid, "_glGetMultiTexImageEXT_size(target, level, format, type)"), "pixels")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexParameterfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexParameterivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexLevelParameterfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexLevelParameterivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glMultiTexImage3DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glMultiTexImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glMultiTexSubImage3DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glMultiTexSubImage3DEXT_size(format, type, width, height, depth)"), "pixels")]),
     GlFunction(Void, "glCopyMultiTexSubImage3DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glBindMultiTextureEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLtexture, "texture")]),
     GlFunction(Void, "glEnableClientStateIndexedEXT", [(GLenum, "array"), (GLuint, "index")]),
     GlFunction(Void, "glDisableClientStateIndexedEXT", [(GLenum, "array"), (GLuint, "index")]),
     GlFunction(Void, "glMultiTexCoordPointerEXT", [(GLenum, "texunit"), (GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (GLpointerConst, "pointer")]),
     GlFunction(Void, "glMultiTexEnvfEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glMultiTexEnvfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMultiTexEnvfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glMultiTexEnviEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glMultiTexEnvivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMultiTexEnvivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glMultiTexGendEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (GLdouble, "param")]),
-    GlFunction(Void, "glMultiTexGendvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLdouble), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMultiTexGendvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLdouble), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glMultiTexGenfEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glMultiTexGenfvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMultiTexGenfvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glMultiTexGeniEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glMultiTexGenivEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetMultiTexEnvfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexEnvivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexGendvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexGenfvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexGenivEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetFloatIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLfloat, "__gl_param_size(target)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetDoubleIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLdouble, "__gl_param_size(target)"), "data")], sideeffects=False),
-    GlFunction(Void, "glGetPointerIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLpointer, "__gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glMultiTexGenivEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetMultiTexEnvfvEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexEnvivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexGendvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexGenfvEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexGenivEXT", [(GLenum, "texunit"), (GLenum, "coord"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFloatIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLfloat, "_gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetDoubleIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLdouble, "_gl_param_size(target)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetPointerIndexedvEXT", [(GLenum, "target"), (GLuint, "index"), Out(Array(GLpointer, "_gl_param_size(target)"), "data")], sideeffects=False),
     GlFunction(Void, "glCompressedTextureImage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedTextureImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedTextureImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedTextureSubImage3DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedTextureSubImage2DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedTextureSubImage1DEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
-    GlFunction(Void, "glGetCompressedTextureImageEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "lod"), Out(OpaqueBlob(GLvoid, "__glGetCompressedTextureImageEXT_size(target, lod)"), "img")], sideeffects=False),
+    GlFunction(Void, "glGetCompressedTextureImageEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLint, "lod"), Out(OpaqueBlob(GLvoid, "_glGetCompressedTextureImageEXT_size(target, lod)"), "img")], sideeffects=False),
     GlFunction(Void, "glCompressedMultiTexImage3DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedMultiTexImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedMultiTexImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedMultiTexSubImage3DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedMultiTexSubImage2DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
     GlFunction(Void, "glCompressedMultiTexSubImage1DEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLsizei, "width"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "bits")]),
-    GlFunction(Void, "glGetCompressedMultiTexImageEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "lod"), Out(OpaqueBlob(GLvoid, "__glGetCompressedMultiTexImageEXT_size(target, lod)"), "img")], sideeffects=False),
-    GlFunction(Void, "glNamedProgramStringEXT", [(GLprogram, "program"), (GLenum, "target"), (GLenum, "format"), (GLsizei, "len"), (Const(String("GLvoid *", "len")), "string")]),
+    GlFunction(Void, "glGetCompressedMultiTexImageEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLint, "lod"), Out(OpaqueBlob(GLvoid, "_glGetCompressedMultiTexImageEXT_size(target, lod)"), "img")], sideeffects=False),
+    GlFunction(Void, "glNamedProgramStringEXT", [(GLprogram, "program"), (GLenum, "target"), (GLenum, "format"), (GLsizei, "len"), (String(Const(GLvoid), "len"), "string")]),
     GlFunction(Void, "glNamedProgramLocalParameter4dEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), (GLdouble, "x"), (GLdouble, "y"), (GLdouble, "z"), (GLdouble, "w")]),
     GlFunction(Void, "glNamedProgramLocalParameter4dvEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), (Array(Const(GLdouble), 4), "params")]),
     GlFunction(Void, "glNamedProgramLocalParameter4fEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), (GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "w")]),
@@ -2453,7 +2537,7 @@ glapi.addFunctions([
     GlFunction(Void, "glGetNamedProgramLocalParameterdvEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), Out(Array(GLdouble, 4), "params")], sideeffects=False),
     GlFunction(Void, "glGetNamedProgramLocalParameterfvEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), Out(Array(GLfloat, 4), "params")], sideeffects=False),
     GlFunction(Void, "glGetNamedProgramivEXT", [(GLprogram, "program"), (GLenum, "target"), (GLenum, "pname"), Out(Pointer(GLint), "params")], sideeffects=False),
-    GlFunction(Void, "glGetNamedProgramStringEXT", [(GLprogram, "program"), (GLenum, "target"), (GLenum, "pname"), Out(OpaqueBlob(GLvoid, "__glGetNamedProgramStringEXT_size(program,pname)"), "string")], sideeffects=False),
+    GlFunction(Void, "glGetNamedProgramStringEXT", [(GLprogram, "program"), (GLenum, "target"), (GLenum, "pname"), Out(OpaqueBlob(GLvoid, "_glGetNamedProgramStringEXT_size(program,pname)"), "string")], sideeffects=False),
     GlFunction(Void, "glNamedProgramLocalParameters4fvEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), (GLsizei, "count"), (Array(Const(GLfloat), "count*4"), "params")]),
     GlFunction(Void, "glNamedProgramLocalParameterI4iEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), (GLint, "x"), (GLint, "y"), (GLint, "z"), (GLint, "w")]),
     GlFunction(Void, "glNamedProgramLocalParameterI4ivEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), (Array(Const(GLint), 4), "params")]),
@@ -2463,14 +2547,14 @@ glapi.addFunctions([
     GlFunction(Void, "glNamedProgramLocalParametersI4uivEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), (GLsizei, "count"), (Array(Const(GLuint), "count*4"), "params")]),
     GlFunction(Void, "glGetNamedProgramLocalParameterIivEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), Out(Array(GLint, 4), "params")], sideeffects=False),
     GlFunction(Void, "glGetNamedProgramLocalParameterIuivEXT", [(GLprogram, "program"), (GLenum, "target"), (GLuint, "index"), Out(Array(GLuint, 4), "params")], sideeffects=False),
-    GlFunction(Void, "glTextureParameterIivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glTextureParameterIuivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetTextureParameterIivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTextureParameterIuivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glMultiTexParameterIivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glMultiTexParameterIuivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetMultiTexParameterIivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMultiTexParameterIuivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glTextureParameterIivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTextureParameterIuivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetTextureParameterIivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTextureParameterIuivEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glMultiTexParameterIivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMultiTexParameterIuivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), (Array(Const(GLuint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetMultiTexParameterIivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMultiTexParameterIuivEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glProgramUniform1fEXT", [(GLprogram, "program"), (GLlocation, "location"), (GLfloat, "v0")]),
     GlFunction(Void, "glProgramUniform2fEXT", [(GLprogram, "program"), (GLlocation, "location"), (GLfloat, "v0"), (GLfloat, "v1")]),
     GlFunction(Void, "glProgramUniform3fEXT", [(GLprogram, "program"), (GLlocation, "location"), (GLfloat, "v0"), (GLfloat, "v1"), (GLfloat, "v2")]),
@@ -2511,25 +2595,25 @@ glapi.addFunctions([
     GlFunction(GLmap, "glMapNamedBufferRangeEXT", [(GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "length"), (GLbitfield_access, "access")]),
     GlFunction(Void, "glFlushMappedNamedBufferRangeEXT", [(GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "length")]),
     GlFunction(Void, "glNamedCopyBufferSubDataEXT", [(GLbuffer, "readBuffer"), (GLbuffer, "writeBuffer"), (GLintptr, "readOffset"), (GLintptr, "writeOffset"), (GLsizeiptr, "size")]),
-    GlFunction(Void, "glGetNamedBufferParameterivEXT", [(GLbuffer, "buffer"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetNamedBufferParameterivEXT", [(GLbuffer, "buffer"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGetNamedBufferPointervEXT", [(GLbuffer, "buffer"), (GLenum, "pname"), Out(Pointer(GLpointer), "params")], sideeffects=False),
     GlFunction(Void, "glGetNamedBufferSubDataEXT", [(GLbuffer, "buffer"), (GLintptr, "offset"), (GLsizeiptr, "size"), Out(OpaqueBlob(GLvoid, "size"), "data")], sideeffects=False),
     GlFunction(Void, "glTextureBufferEXT", [(GLtexture, "texture"), (GLenum, "target"), (GLenum, "internalformat"), (GLbuffer, "buffer")]),
     GlFunction(Void, "glMultiTexBufferEXT", [(GLenum, "texunit"), (GLenum, "target"), (GLenum, "internalformat"), (GLbuffer, "buffer")]),
     GlFunction(Void, "glNamedRenderbufferStorageEXT", [(GLrenderbuffer, "renderbuffer"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetNamedRenderbufferParameterivEXT", [(GLrenderbuffer, "renderbuffer"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetNamedRenderbufferParameterivEXT", [(GLrenderbuffer, "renderbuffer"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLenum, "glCheckNamedFramebufferStatusEXT", [(GLframebuffer, "framebuffer"), (GLenum, "target")]),
     GlFunction(Void, "glNamedFramebufferTexture1DEXT", [(GLframebuffer, "framebuffer"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
     GlFunction(Void, "glNamedFramebufferTexture2DEXT", [(GLframebuffer, "framebuffer"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
     GlFunction(Void, "glNamedFramebufferTexture3DEXT", [(GLframebuffer, "framebuffer"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level"), (GLint, "zoffset")]),
     GlFunction(Void, "glNamedFramebufferRenderbufferEXT", [(GLframebuffer, "framebuffer"), (GLenum, "attachment"), (GLenum, "renderbuffertarget"), (GLuint, "renderbuffer")]),
-    GlFunction(Void, "glGetNamedFramebufferAttachmentParameterivEXT", [(GLframebuffer, "framebuffer"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetNamedFramebufferAttachmentParameterivEXT", [(GLframebuffer, "framebuffer"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGenerateTextureMipmapEXT", [(GLtexture, "texture"), (GLenum, "target")]),
     GlFunction(Void, "glGenerateMultiTexMipmapEXT", [(GLenum, "texunit"), (GLenum, "target")]),
     GlFunction(Void, "glFramebufferDrawBufferEXT", [(GLframebuffer, "framebuffer"), (GLenum, "mode")]),
     GlFunction(Void, "glFramebufferDrawBuffersEXT", [(GLframebuffer, "framebuffer"), (GLsizei, "n"), (Array(Const(GLenum), "n"), "bufs")]),
     GlFunction(Void, "glFramebufferReadBufferEXT", [(GLframebuffer, "framebuffer"), (GLenum, "mode")]),
-    GlFunction(Void, "glGetFramebufferParameterivEXT", [(GLframebuffer, "framebuffer"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFramebufferParameterivEXT", [(GLframebuffer, "framebuffer"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glNamedRenderbufferStorageMultisampleEXT", [(GLrenderbuffer, "renderbuffer"), (GLsizei, "samples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glNamedRenderbufferStorageMultisampleCoverageEXT", [(GLrenderbuffer, "renderbuffer"), (GLsizei, "coverageSamples"), (GLsizei, "colorSamples"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glNamedFramebufferTextureEXT", [(GLframebuffer, "framebuffer"), (GLenum, "attachment"), (GLtexture, "texture"), (GLint, "level")]),
@@ -2569,10 +2653,10 @@ glapi.addFunctions([
     GlFunction(Void, "glDisableVertexArrayEXT", [(GLarray, "vaobj"), (GLenum, "array")]),
     GlFunction(Void, "glEnableVertexArrayAttribEXT", [(GLarray, "vaobj"), (GLuint, "index")]),
     GlFunction(Void, "glDisableVertexArrayAttribEXT", [(GLarray, "vaobj"), (GLuint, "index")]),
-    GlFunction(Void, "glGetVertexArrayIntegervEXT", [(GLarray, "vaobj"), (GLenum, "pname"), Out(Pointer(GLint), "param")]),
-    GlFunction(Void, "glGetVertexArrayPointervEXT", [(GLarray, "vaobj"), (GLenum, "pname"), Out(Pointer(GLpointer), "param")]),
-    GlFunction(Void, "glGetVertexArrayIntegeri_vEXT", [(GLarray, "vaobj"), (GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLint), "param")]),
-    GlFunction(Void, "glGetVertexArrayPointeri_vEXT", [(GLarray, "vaobj"), (GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLpointer), "param")]),
+    GlFunction(Void, "glGetVertexArrayIntegervEXT", [(GLarray, "vaobj"), (GLenum, "pname"), Out(Pointer(GLint), "param")], sideeffects=False),
+    GlFunction(Void, "glGetVertexArrayPointervEXT", [(GLarray, "vaobj"), (GLenum, "pname"), Out(Pointer(GLpointer), "param")], sideeffects=False),
+    GlFunction(Void, "glGetVertexArrayIntegeri_vEXT", [(GLarray, "vaobj"), (GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLint), "param")], sideeffects=False),
+    GlFunction(Void, "glGetVertexArrayPointeri_vEXT", [(GLarray, "vaobj"), (GLuint, "index"), (GLenum, "pname"), Out(Pointer(GLpointer), "param")], sideeffects=False),
 
     # GL_NV_explicit_multisample
     GlFunction(Void, "glGetMultisamplefvNV", [(GLenum, "pname"), (GLuint, "index"), Out(Array(GLfloat, 2), "val")], sideeffects=False),
@@ -2593,10 +2677,10 @@ glapi.addFunctions([
     GlFunction(Void, "glGetPerfMonitorCountersAMD", [(GLuint, "group"), Out(Pointer(GLint), "numCounters"), Out(Pointer(GLint), "maxActiveCounters"), (GLsizei, "counterSize"), Out(Array(GLuint, "counterSize"), "counters")], sideeffects=False),
     GlFunction(Void, "glGetPerfMonitorGroupStringAMD", [(GLuint, "group"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "groupString")], sideeffects=False),
     GlFunction(Void, "glGetPerfMonitorCounterStringAMD", [(GLuint, "group"), (GLuint, "counter"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLchar, "bufSize"), "counterString")], sideeffects=False),
-    GlFunction(Void, "glGetPerfMonitorCounterInfoAMD", [(GLuint, "group"), (GLuint, "counter"), (GLenum, "pname"), Out(OpaqueBlob(GLvoid, "__glGetPerfMonitorCounterInfoAMD_size(pname)"), "data")], sideeffects=False),
+    GlFunction(Void, "glGetPerfMonitorCounterInfoAMD", [(GLuint, "group"), (GLuint, "counter"), (GLenum, "pname"), Out(OpaqueBlob(GLvoid, "_glGetPerfMonitorCounterInfoAMD_size(pname)"), "data")], sideeffects=False),
     GlFunction(Void, "glGenPerfMonitorsAMD", [(GLsizei, "n"), Out(Array(GLuint, "n"), "monitors")]),
-    GlFunction(Void, "glDeletePerfMonitorsAMD", [(GLsizei, "n"), Out(Array(GLuint, "n"), "monitors")]),
-    GlFunction(Void, "glSelectPerfMonitorCountersAMD", [(GLuint, "monitor"), (GLboolean, "enable"), (GLuint, "group"), (GLint, "numCounters"), Out(Array(GLuint, "numCounters"), "counterList")]),
+    GlFunction(Void, "glDeletePerfMonitorsAMD", [(GLsizei, "n"), (Array(GLuint, "n"), "monitors")]),
+    GlFunction(Void, "glSelectPerfMonitorCountersAMD", [(GLuint, "monitor"), (GLboolean, "enable"), (GLuint, "group"), (GLint, "numCounters"), (Array(GLuint, "numCounters"), "counterList")]),
     GlFunction(Void, "glBeginPerfMonitorAMD", [(GLuint, "monitor")]),
     GlFunction(Void, "glEndPerfMonitorAMD", [(GLuint, "monitor")]),
     GlFunction(Void, "glGetPerfMonitorCounterDataAMD", [(GLuint, "monitor"), (GLenum, "pname"), (GLsizei, "dataSize"), Out(Array(GLuint, "dataSize"), "data"), Out(Pointer(GLint), "bytesWritten")], sideeffects=False),
@@ -2622,29 +2706,29 @@ glapi.addFunctions([
     GlFunction(Void, "glEnableVertexAttribAPPLE", [(GLuint, "index"), (GLenum, "pname")]),
     GlFunction(Void, "glDisableVertexAttribAPPLE", [(GLuint, "index"), (GLenum, "pname")]),
     GlFunction(GLboolean, "glIsVertexAttribEnabledAPPLE", [(GLuint, "index"), (GLenum, "pname")], sideeffects=False),
-    GlFunction(Void, "glMapVertexAttrib1dAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "stride"), (GLint, "order"), (OpaqueArray(Const(GLdouble), "__glMapVertexAttrib1dAPPLE_size(size, stride, order)"), "points")]),
-    GlFunction(Void, "glMapVertexAttrib1fAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "stride"), (GLint, "order"), (OpaqueArray(Const(GLfloat), "__glMapVertexAttrib1fAPPLE_size(size, stride, order)"), "points")]),
-    GlFunction(Void, "glMapVertexAttrib2dAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLdouble, "v1"), (GLdouble, "v2"), (GLint, "vstride"), (GLint, "vorder"), (OpaqueArray(Const(GLdouble), "__glMapVertexAttrib2dAPPLE_size(size, ustride, uorder, vstride, vorder)"), "points")]),
-    GlFunction(Void, "glMapVertexAttrib2fAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLfloat, "v1"), (GLfloat, "v2"), (GLint, "vstride"), (GLint, "vorder"), (OpaqueArray(Const(GLfloat), "__glMapVertexAttrib2fAPPLE_size(size, ustride, uorder, vstride, vorder)"), "points")]),
+    GlFunction(Void, "glMapVertexAttrib1dAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "stride"), (GLint, "order"), (OpaqueArray(Const(GLdouble), "_glMapVertexAttrib1dAPPLE_size(size, stride, order)"), "points")]),
+    GlFunction(Void, "glMapVertexAttrib1fAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "stride"), (GLint, "order"), (OpaqueArray(Const(GLfloat), "_glMapVertexAttrib1fAPPLE_size(size, stride, order)"), "points")]),
+    GlFunction(Void, "glMapVertexAttrib2dAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLdouble, "u1"), (GLdouble, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLdouble, "v1"), (GLdouble, "v2"), (GLint, "vstride"), (GLint, "vorder"), (OpaqueArray(Const(GLdouble), "_glMapVertexAttrib2dAPPLE_size(size, ustride, uorder, vstride, vorder)"), "points")]),
+    GlFunction(Void, "glMapVertexAttrib2fAPPLE", [(GLuint, "index"), (GLuint, "size"), (GLfloat, "u1"), (GLfloat, "u2"), (GLint, "ustride"), (GLint, "uorder"), (GLfloat, "v1"), (GLfloat, "v2"), (GLint, "vstride"), (GLint, "vorder"), (OpaqueArray(Const(GLfloat), "_glMapVertexAttrib2fAPPLE_size(size, ustride, uorder, vstride, vorder)"), "points")]),
 
     # GL_APPLE_object_purgeable
     GlFunction(GLenum, "glObjectPurgeableAPPLE", [(GLenum, "objectType"), (GLuint, "name"), (GLenum, "option")]),
     GlFunction(GLenum, "glObjectUnpurgeableAPPLE", [(GLenum, "objectType"), (GLuint, "name"), (GLenum, "option")]),
-    GlFunction(Void, "glGetObjectParameterivAPPLE", [(GLenum, "objectType"), (GLuint, "name"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetObjectParameterivAPPLE", [(GLenum, "objectType"), (GLuint, "name"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_NV_video_capture
     GlFunction(Void, "glBeginVideoCaptureNV", [(GLuint, "video_capture_slot")]),
     GlFunction(Void, "glBindVideoCaptureStreamBufferNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "frame_region"), (GLintptrARB, "offset")]),
     GlFunction(Void, "glBindVideoCaptureStreamTextureNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "frame_region"), (GLenum, "target"), (GLuint, "texture")]),
     GlFunction(Void, "glEndVideoCaptureNV", [(GLuint, "video_capture_slot")]),
-    GlFunction(Void, "glGetVideoCaptureivNV", [(GLuint, "video_capture_slot"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVideoCaptureStreamivNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVideoCaptureStreamfvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVideoCaptureStreamdvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideoCaptureivNV", [(GLuint, "video_capture_slot"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideoCaptureStreamivNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideoCaptureStreamfvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVideoCaptureStreamdvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLenum, "glVideoCaptureNV", [(GLuint, "video_capture_slot"), Out(Pointer(GLuint), "sequence_num"), Out(Pointer(GLuint64EXT), "capture_time")]),
-    GlFunction(Void, "glVideoCaptureStreamParameterivNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glVideoCaptureStreamParameterfvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glVideoCaptureStreamParameterdvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), (Array(Const(GLdouble), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glVideoCaptureStreamParameterivNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glVideoCaptureStreamParameterfvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glVideoCaptureStreamParameterdvNV", [(GLuint, "video_capture_slot"), (GLuint, "stream"), (GLenum, "pname"), (Array(Const(GLdouble), "_gl_param_size(pname)"), "params")]),
 
     # GL_NV_copy_image
     GlFunction(Void, "glCopyImageSubDataNV", [(GLuint, "srcName"), (GLenum, "srcTarget"), (GLint, "srcLevel"), (GLint, "srcX"), (GLint, "srcY"), (GLint, "srcZ"), (GLuint, "dstName"), (GLenum, "dstTarget"), (GLint, "dstLevel"), (GLint, "dstX"), (GLint, "dstY"), (GLint, "dstZ"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth")]),
@@ -2652,7 +2736,7 @@ glapi.addFunctions([
     # GL_EXT_separate_shader_objects
     GlFunction(Void, "glUseShaderProgramEXT", [(GLenum, "type"), (GLprogram, "program")]),
     GlFunction(Void, "glActiveProgramEXT", [(GLprogram, "program")]),
-    GlFunction(GLprogram, "glCreateShaderProgramEXT", [(GLenum, "type"), (Const(GLstring), "string")]),
+    GlFunction(GLprogram, "glCreateShaderProgramEXT", [(GLenum, "type"), (GLstringConst, "string")]),
 
     # GL_NV_shader_buffer_load
     GlFunction(Void, "glMakeBufferResidentNV", [(GLenum, "target"), (GLenum, "access")]),
@@ -2661,12 +2745,12 @@ glapi.addFunctions([
     GlFunction(Void, "glMakeNamedBufferResidentNV", [(GLuint, "buffer"), (GLenum, "access")]),
     GlFunction(Void, "glMakeNamedBufferNonResidentNV", [(GLuint, "buffer")]),
     GlFunction(GLboolean, "glIsNamedBufferResidentNV", [(GLuint, "buffer")], sideeffects=False),
-    GlFunction(Void, "glGetBufferParameterui64vNV", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetNamedBufferParameterui64vNV", [(GLuint, "buffer"), (GLenum, "pname"), Out(Array(GLuint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetIntegerui64vNV", [(GLenum, "value"), Out(Array(GLuint64EXT, "__gl_param_size(value)"), "result")], sideeffects=False),
+    GlFunction(Void, "glGetBufferParameterui64vNV", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLuint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetNamedBufferParameterui64vNV", [(GLuint, "buffer"), (GLenum, "pname"), Out(Array(GLuint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetIntegerui64vNV", [(GLenum, "value"), Out(Array(GLuint64EXT, "_gl_param_size(value)"), "result")], sideeffects=False),
     GlFunction(Void, "glUniformui64NV", [(GLint, "location"), (GLuint64EXT, "value")]),
     GlFunction(Void, "glUniformui64vNV", [(GLint, "location"), (GLsizei, "count"), (Array(Const(GLuint64EXT), "count"), "value")]),
-    GlFunction(Void, "glGetUniformui64vNV", [(GLuint, "program"), (GLint, "location"), Out(OpaqueArray(GLuint64EXT, "__glGetUniformui64vNV_size(program, location)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetUniformui64vNV", [(GLuint, "program"), (GLint, "location"), Out(OpaqueArray(GLuint64EXT, "_glGetUniformui64vNV_size(program, location)"), "params")], sideeffects=False),
     GlFunction(Void, "glProgramUniformui64NV", [(GLuint, "program"), (GLint, "location"), (GLuint64EXT, "value")]),
     GlFunction(Void, "glProgramUniformui64vNV", [(GLuint, "program"), (GLint, "location"), (GLsizei, "count"), (Array(Const(GLuint64EXT), "count"), "value")]),
 
@@ -2682,7 +2766,7 @@ glapi.addFunctions([
     GlFunction(Void, "glFogCoordFormatNV", [(GLenum, "type"), (GLsizei, "stride")]),
     GlFunction(Void, "glVertexAttribFormatNV", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLboolean, "normalized"), (GLsizei, "stride")]),
     GlFunction(Void, "glVertexAttribIFormatNV", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLsizei, "stride")]),
-    GlFunction(Void, "glGetIntegerui64i_vNV", [(GLenum, "value"), (GLuint, "index"), Out(Array(GLuint64EXT, "__gl_param_size(value)"), "result")], sideeffects=False),
+    GlFunction(Void, "glGetIntegerui64i_vNV", [(GLenum, "value"), (GLuint, "index"), Out(Array(GLuint64EXT, "_gl_param_size(value)"), "result")], sideeffects=False),
 
     # GL_NV_texture_barrier
     GlFunction(Void, "glTextureBarrierNV", []),
@@ -2701,7 +2785,7 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexAttribL3dvEXT", [(GLuint, "index"), (Array(Const(GLdouble), 3), "v")]),
     GlFunction(Void, "glVertexAttribL4dvEXT", [(GLuint, "index"), (Array(Const(GLdouble), 4), "v")]),
     GlFunction(Void, "glVertexAttribLPointerEXT", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (Blob(Const(GLvoid), "size"), "pointer")]),
-    GlFunction(Void, "glGetVertexAttribLdvEXT", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribLdvEXT", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLdouble, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glVertexArrayVertexAttribLOffsetEXT", [(GLarray, "vaobj"), (GLuint, "buffer"), (GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLsizei, "stride"), (GLintptr, "offset")]),
 
     # GL_NV_gpu_program5
@@ -2725,7 +2809,7 @@ glapi.addFunctions([
     GlFunction(Void, "glUniform2ui64vNV", [(GLint, "location"), (GLsizei, "count"), (Array(Const(GLuint64EXT), "count*2"), "value")]),
     GlFunction(Void, "glUniform3ui64vNV", [(GLint, "location"), (GLsizei, "count"), (Array(Const(GLuint64EXT), "count*3"), "value")]),
     GlFunction(Void, "glUniform4ui64vNV", [(GLint, "location"), (GLsizei, "count"), (Array(Const(GLuint64EXT), "count*4"), "value")]),
-    GlFunction(Void, "glGetUniformi64vNV", [(GLuint, "program"), (GLint, "location"), Out(OpaqueArray(GLint64EXT, "__glGetUniformi64vNV_size(location)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetUniformi64vNV", [(GLuint, "program"), (GLint, "location"), Out(OpaqueArray(GLint64EXT, "_glGetUniformi64vNV_size(location)"), "params")], sideeffects=False),
     GlFunction(Void, "glProgramUniform1i64NV", [(GLuint, "program"), (GLint, "location"), (GLint64EXT, "x")]),
     GlFunction(Void, "glProgramUniform2i64NV", [(GLuint, "program"), (GLint, "location"), (GLint64EXT, "x"), (GLint64EXT, "y")]),
     GlFunction(Void, "glProgramUniform3i64NV", [(GLuint, "program"), (GLint, "location"), (GLint64EXT, "x"), (GLint64EXT, "y"), (GLint64EXT, "z")]),
@@ -2760,8 +2844,8 @@ glapi.addFunctions([
     GlFunction(Void, "glVertexAttribL2ui64vNV", [(GLuint, "index"), (Array(Const(GLuint64EXT), 2), "v")]),
     GlFunction(Void, "glVertexAttribL3ui64vNV", [(GLuint, "index"), (Array(Const(GLuint64EXT), 3), "v")]),
     GlFunction(Void, "glVertexAttribL4ui64vNV", [(GLuint, "index"), (Array(Const(GLuint64EXT), 4), "v")]),
-    GlFunction(Void, "glGetVertexAttribLi64vNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetVertexAttribLui64vNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLuint64EXT, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribLi64vNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetVertexAttribLui64vNV", [(GLuint, "index"), (GLenum, "pname"), Out(Array(GLuint64EXT, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glVertexAttribLFormatNV", [(GLuint, "index"), (GLint, "size"), (GLenum, "type"), (GLsizei, "stride")]),
 
     # GL_AMD_name_gen_delete
index 9d1679847b02b9d032c52dd5d04092ecd03a2ebf..46c6ef02888e363f5b93aa4633e26c9ed1be9cb8 100644 (file)
@@ -59,16 +59,16 @@ glesapi.addFunctions([
     GlFunction(Void, "glColor4x", [(GLfixed, "red"), (GLfixed, "green"), (GLfixed, "blue"), (GLfixed, "alpha")]),
     GlFunction(Void, "glDepthRangex", [(GLclampx, "zNear"), (GLclampx, "zFar")]),
     GlFunction(Void, "glFogx", [(GLenum, "pname"), (GLfixed, "param")]),
-    GlFunction(Void, "glFogxv", [(GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glFogxv", [(GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glFrustumx", [(GLfixed, "left"), (GLfixed, "right"), (GLfixed, "bottom"), (GLfixed, "top"), (GLfixed, "zNear"), (GLfixed, "zFar")]),
     GlFunction(Void, "glLightModelx", [(GLenum, "pname"), (GLfixed, "param")]),
-    GlFunction(Void, "glLightModelxv", [(GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glLightModelxv", [(GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glLightx", [(GLenum, "light"), (GLenum, "pname"), (GLfixed, "param")]),
-    GlFunction(Void, "glLightxv", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glLightxv", [(GLenum, "light"), (GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glLineWidthx", [(GLfixed, "width")]),
     GlFunction(Void, "glLoadMatrixx", [(Array(Const(GLfixed), 16), "m")]),
     GlFunction(Void, "glMaterialx", [(GLenum, "face"), (GLenum, "pname"), (GLfixed, "param")]),
-    GlFunction(Void, "glMaterialxv", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glMaterialxv", [(GLenum, "face"), (GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glMultMatrixx", [(Array(Const(GLfixed), 16), "m")]),
     GlFunction(Void, "glMultiTexCoord4x", [(GLenum, "target"), (GLfixed, "s"), (GLfixed, "t"), (GLfixed, "r"), (GLfixed, "q")]),
     GlFunction(Void, "glNormal3x", [(GLfixed, "nx"), (GLfixed, "ny"), (GLfixed, "nz")]),
@@ -79,20 +79,20 @@ glesapi.addFunctions([
     GlFunction(Void, "glSampleCoveragex", [(GLclampx, "value"), (GLboolean, "invert")]),
     GlFunction(Void, "glScalex", [(GLfixed, "x"), (GLfixed, "y"), (GLfixed, "z")]),
     GlFunction(Void, "glTexEnvx", [(GLenum, "target"), (GLenum, "pname"), (GLfixed, "param")]),
-    GlFunction(Void, "glTexEnvxv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexEnvxv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexParameterx", [(GLenum, "target"), (GLenum, "pname"), (GLfixed, "param")]),
     GlFunction(Void, "glTranslatex", [(GLfixed, "x"), (GLfixed, "y"), (GLfixed, "z")]),
 
     GlFunction(Void, "glClipPlanex", [(GLenum, "plane"), (Array(Const(GLfixed), 4), "equation")]),
     GlFunction(Void, "glGetClipPlanex", [(GLenum, "plane"), Out(Array(GLfixed, 4), "equation")], sideeffects=False),
-    GlFunction(Void, "glGetFixedv", [(GLenum, "pname"), Out(Array(GLfixed, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetLightxv", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLfixed, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetMaterialxv", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLfixed, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexEnvxv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfixed, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexParameterxv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfixed, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFixedv", [(GLenum, "pname"), Out(Array(GLfixed, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetLightxv", [(GLenum, "light"), (GLenum, "pname"), Out(Array(GLfixed, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetMaterialxv", [(GLenum, "face"), (GLenum, "pname"), Out(Array(GLfixed, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexEnvxv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfixed, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexParameterxv", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLfixed, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glPointParameterx", [(GLenum, "pname"), (GLfixed, "param")]),
-    GlFunction(Void, "glPointParameterxv", [(GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glTexParameterxv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glPointParameterxv", [(GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexParameterxv", [(GLenum, "target"), (GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
 
     # GL_ES_VERSION_2_0
 
@@ -114,7 +114,7 @@ glesapi.addFunctions([
     GlFunction(Void, "glDeleteRenderbuffersOES", [(GLsizei, "n"), (Array(Const(GLrenderbuffer), "n"), "renderbuffers")]),
     GlFunction(Void, "glGenRenderbuffersOES", [(GLsizei, "n"), Out(Array(GLrenderbuffer, "n"), "renderbuffers")]),
     GlFunction(Void, "glRenderbufferStorageOES", [(GLenum, "target"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height")]),
-    GlFunction(Void, "glGetRenderbufferParameterivOES", [(GLenum, "target"), (GLenum, "pname"), (Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetRenderbufferParameterivOES", [(GLenum, "target"), (GLenum, "pname"), (Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(GLboolean, "glIsFramebufferOES", [(GLframebuffer, "framebuffer")], sideeffects=False),
     GlFunction(Void, "glBindFramebufferOES", [(GLenum, "target"), (GLframebuffer, "framebuffer")]),
     GlFunction(Void, "glDeleteFramebuffersOES", [(GLsizei, "n"), (Array(Const(GLframebuffer), "n"), "framebuffers")]),
@@ -122,7 +122,7 @@ glesapi.addFunctions([
     GlFunction(GLenum, "glCheckFramebufferStatusOES", [(GLenum, "target")]),
     GlFunction(Void, "glFramebufferTexture2DOES", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "textarget"), (GLtexture, "texture"), (GLint, "level")]),
     GlFunction(Void, "glFramebufferRenderbufferOES", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "renderbuffertarget"), (GLuint, "renderbuffer")]),
-    GlFunction(Void, "glGetFramebufferAttachmentParameterivOES", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetFramebufferAttachmentParameterivOES", [(GLenum, "target"), (GLenum, "attachment"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     GlFunction(Void, "glGenerateMipmapOES", [(GLenum, "target")]),
 
     # GL_OES_matrix_palette
@@ -139,14 +139,14 @@ glesapi.addFunctions([
 
     # GL_OES_texture_cube_map
     GlFunction(Void, "glTexGenfOES", [(GLenum, "coord"), (GLenum, "pname"), (GLfloat, "param")]),
-    GlFunction(Void, "glTexGenfvOES", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfloat), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexGenfvOES", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfloat), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexGeniOES", [(GLenum, "coord"), (GLenum, "pname"), (GLint, "param")]),
-    GlFunction(Void, "glTexGenivOES", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLint), "__gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glTexGenivOES", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLint), "_gl_param_size(pname)"), "params")]),
     GlFunction(Void, "glTexGenxOES", [(GLenum, "coord"), (GLenum, "pname"), (GLfixed, "param")]),
-    GlFunction(Void, "glTexGenxvOES", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfixed), "__gl_param_size(pname)"), "params")]),
-    GlFunction(Void, "glGetTexGenfvOES", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfloat, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexGenivOES", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetTexGenxvOES", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfixed, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glTexGenxvOES", [(GLenum, "coord"), (GLenum, "pname"), (Array(Const(GLfixed), "_gl_param_size(pname)"), "params")]),
+    GlFunction(Void, "glGetTexGenfvOES", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfloat, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexGenivOES", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetTexGenxvOES", [(GLenum, "coord"), (GLenum, "pname"), Out(Array(GLfixed, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_OES_mapbuffer
     GlFunction(Void, "glGetBufferPointervOES", [(GLenum, "target"), (GLenum, "pname"), Out(Pointer(GLpointer), "params")], sideeffects=False),
@@ -154,8 +154,8 @@ glesapi.addFunctions([
     GlFunction(GLboolean, "glUnmapBufferOES", [(GLenum, "target")]),
 
     # GL_OES_texture_3D
-    GlFunction(Void, "glTexImage3DOES", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexImage3D_size(format, type, width, height, depth)"), "pixels")]),
-    GlFunction(Void, "glTexSubImage3DOES", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__glTexSubImage3D_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glTexImage3DOES", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexImage3D_size(format, type, width, height, depth)"), "pixels")]),
+    GlFunction(Void, "glTexSubImage3DOES", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "_glTexSubImage3D_size(format, type, width, height, depth)"), "pixels")]),
     GlFunction(Void, "glCopyTexSubImage3DOES", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
     GlFunction(Void, "glCompressedTexImage3DOES", [(GLenum, "target"), (GLint, "level"), (GLenum, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
     GlFunction(Void, "glCompressedTexSubImage3DOES", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLsizei, "imageSize"), (Blob(Const(GLvoid), "imageSize"), "data")]),
@@ -165,6 +165,14 @@ glesapi.addFunctions([
     GlFunction(Void, "glGetProgramBinaryOES", [(GLprogram, "program"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Pointer(GLenum), "binaryFormat"), Out(OpaqueBlob(GLvoid, "length ? *length : bufSize"), "binary")], sideeffects=False),
     GlFunction(Void, "glProgramBinaryOES", [(GLprogram, "program"), (GLenum, "binaryFormat"), (Blob(Const(GLvoid), "length"), "binary"), (GLsizei, "length")]),
 
+    # GL_OES_draw_texture
+    GlFunction(Void, "glDrawTexfOES", [(GLfloat, "x"), (GLfloat, "y"), (GLfloat, "z"), (GLfloat, "width"), (GLfloat, "height")]),
+    GlFunction(Void, "glDrawTexfvOES", [(Array(Const(GLfloat), 4), "coords")]),
+    GlFunction(Void, "glDrawTexiOES", [(GLint, "x"), (GLint, "y"), (GLint, "z"), (GLint, "width"), (GLint, "height")]),
+    GlFunction(Void, "glDrawTexivOES", [(Array(Const(GLint), 4), "coords")]),
+    GlFunction(Void, "glDrawTexsOES", [(GLshort, "x"), (GLshort, "y"), (GLshort, "z"), (GLshort, "width"), (GLshort, "height")]),
+    GlFunction(Void, "glDrawTexsvOES", [(Array(Const(GLshort), 4), "coords")]),
+
     # GL_EXT_discard_framebuffer
     GlFunction(Void, "glDiscardFramebufferEXT", [(GLenum, "target"), (GLsizei, "numAttachments"), (Array(Const(GLenum), "numAttachments"), "attachments")]),
 
@@ -199,12 +207,12 @@ glesapi.addFunctions([
     GlFunction(Void, "glReadBufferNV", [(GLenum, "mode")]),
 
     # GL_EXT_debug_label
-    GlFunction(Void, "glLabelObjectEXT", [(GLenum, "type"), (GLuint, "object"), (GLsizei, "length"), (Const(GLstring), "label")]),
+    GlFunction(Void, "glLabelObjectEXT", [(GLenum, "type"), (GLuint, "object"), (GLsizei, "length"), (GLstringConst, "label")]),
     GlFunction(Void, "glGetObjectLabelEXT", [(GLenum, "type"), (GLuint, "object"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(GLstring, "label")], sideeffects=False),
 
     # GL_EXT_debug_marker
-    GlFunction(Void, "glInsertEventMarkerEXT", [(GLsizei, "length"), (Const(String("GLchar *", "length ? length : strlen(marker)")), "marker")], sideeffects=False),
-    GlFunction(Void, "glPushGroupMarkerEXT", [(GLsizei, "length"), (Const(String("GLchar *", "length ? length : strlen(marker)")), "marker")], sideeffects=False),
+    GlFunction(Void, "glInsertEventMarkerEXT", [(GLsizei, "length"), (String(Const(GLchar), "length ? length : strlen(marker)"), "marker")], sideeffects=False),
+    GlFunction(Void, "glPushGroupMarkerEXT", [(GLsizei, "length"), (String(Const(GLchar), "length ? length : strlen(marker)"), "marker")], sideeffects=False),
     GlFunction(Void, "glPopGroupMarkerEXT", [], sideeffects=False),
 
     # GL_EXT_occlusion_query_boolean
@@ -213,19 +221,19 @@ glesapi.addFunctions([
     GlFunction(GLboolean, "glIsQueryEXT", [(GLquery, "id")], sideeffects=False),
     GlFunction(Void, "glBeginQueryEXT", [(GLenum, "target"), (GLquery, "id")]),
     GlFunction(Void, "glEndQueryEXT", [(GLenum, "target")]),
-    GlFunction(Void, "glGetQueryivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
-    GlFunction(Void, "glGetQueryObjectuivEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryivEXT", [(GLenum, "target"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetQueryObjectuivEXT", [(GLquery, "id"), (GLenum, "pname"), Out(Array(GLuint, "_gl_param_size(pname)"), "params")], sideeffects=False),
 
     # GL_EXT_separate_shader_objects
     GlFunction(Void, "glUseProgramStagesEXT", [(GLpipeline, "pipeline"), (GLbitfield_shader, "stages"), (GLprogram, "program")]),
     GlFunction(Void, "glActiveShaderProgramEXT", [(GLpipeline, "pipeline"), (GLprogram, "program")]),
-    GlFunction(GLprogram, "glCreateShaderProgramvEXT", [(GLenum, "type"), (GLsizei, "count"), (Const(Array(Const(GLstring), "count")), "strings")]),
+    GlFunction(GLprogram, "glCreateShaderProgramvEXT", [(GLenum, "type"), (GLsizei, "count"), (Const(Array(GLstringConst, "count")), "strings")]),
     GlFunction(Void, "glBindProgramPipelineEXT", [(GLpipeline, "pipeline")]),
     GlFunction(Void, "glDeleteProgramPipelinesEXT", [(GLsizei, "n"), (Array(Const(GLuint), "n"), "pipelines")]),
     GlFunction(Void, "glGenProgramPipelinesEXT", [(GLsizei, "n"), Out(Array(GLpipeline, "n"), "pipelines")]),
     GlFunction(GLboolean, "glIsProgramPipelineEXT", [(GLpipeline, "pipeline")], sideeffects=False),
     #GlFunction(Void, "glProgramParameteriEXT", [(GLprogram, "program"), (GLenum, "pname"), (GLint, "value")]),
-    GlFunction(Void, "glGetProgramPipelineivEXT", [(GLpipeline, "pipeline"), (GLenum, "pname"), Out(Array(GLint, "__gl_param_size(pname)"), "params")], sideeffects=False),
+    GlFunction(Void, "glGetProgramPipelineivEXT", [(GLpipeline, "pipeline"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
     #GlFunction(Void, "glProgramUniform1iEXT", [(GLprogram, "program"), (GLlocation, "location"), (GLint, "x")]),
     #GlFunction(Void, "glProgramUniform2iEXT", [(GLprogram, "program"), (GLlocation, "location"), (GLint, "x"), (GLint, "y")]),
     #GlFunction(Void, "glProgramUniform3iEXT", [(GLprogram, "program"), (GLlocation, "location"), (GLint, "x"), (GLint, "y"), (GLint, "z")]),
index acd8a22d6cbbe3c5d200cb03eefd29f04c5ff6e7..98d4ee6f392a4f04d7615f7e95eb6faedeb7aba6 100644 (file)
@@ -744,7 +744,7 @@ parameters = [
     ("",       X,      1,      "GL_PHONG_WIN"),        # 0x80EA
     ("",       X,      1,      "GL_PHONG_HINT_WIN"),   # 0x80EB
     ("",       X,      1,      "GL_FOG_SPECULAR_TEXTURE_WIN"), # 0x80EC
-    ("",       X,      1,      "GL_TEXTURE_INDEX_SIZE_EXT"),   # 0x80ED
+    ("_glGetTexLevelParameter",        I,      1,      "GL_TEXTURE_INDEX_SIZE_EXT"),   # 0x80ED
     ("glGet",  E,      1,      "GL_CLIP_VOLUME_CLIPPING_HINT_EXT"),    # 0x80F0
     ("",       X,      1,      "GL_DUAL_ALPHA4_SGIS"), # 0x8110
     ("",       X,      1,      "GL_DUAL_ALPHA8_SGIS"), # 0x8111
@@ -840,7 +840,7 @@ parameters = [
     ("glGetTexParameter",      I,      2,      "GL_TEXTURE_CLIPMAP_OFFSET_SGIX"),      # 0x8173
     ("glGetTexParameter",      I,      3,      "GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX"),       # 0x8174
     ("",       X,      1,      "GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX"),  # 0x8175
-    ("",       X,      1,      "GL_TEXTURE_CLIPMAP_DEPTH_SGIX"),       # 0x8176
+    ("",       I,      1,      "GL_TEXTURE_CLIPMAP_DEPTH_SGIX"),       # 0x8176
     ("glGet",  I,      1,      "GL_MAX_CLIPMAP_DEPTH_SGIX"),   # 0x8177
     ("glGet",  I,      1,      "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX"),   # 0x8178
     ("glGetTexParameter",      F,      1,      "GL_POST_TEXTURE_FILTER_BIAS_SGIX"),    # 0x8179
@@ -882,11 +882,11 @@ parameters = [
     ("",       X,      1,      "GL_DEPTH_COMPONENT16"),        # 0x81A5
     ("",       X,      1,      "GL_DEPTH_COMPONENT24"),        # 0x81A6
     ("",       X,      1,      "GL_DEPTH_COMPONENT32"),        # 0x81A7
-    ("",       X,      1,      "GL_ARRAY_ELEMENT_LOCK_FIRST_EXT"),     # 0x81A8
-    ("",       X,      1,      "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT"),     # 0x81A9
-    ("",       X,      1,      "GL_CULL_VERTEX_EXT"),  # 0x81AA
-    ("",       X,      1,      "GL_CULL_VERTEX_EYE_POSITION_EXT"),     # 0x81AB
-    ("",       X,      1,      "GL_CULL_VERTEX_OBJECT_POSITION_EXT"),  # 0x81AC
+    ("glGet",  I,      1,      "GL_ARRAY_ELEMENT_LOCK_FIRST_EXT"),     # 0x81A8
+    ("glGet",  I,      1,      "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT"),     # 0x81A9
+    ("glGet",  B,      1,      "GL_CULL_VERTEX_EXT"),  # 0x81AA
+    ("glGet",  F,      4,      "GL_CULL_VERTEX_EYE_POSITION_EXT"),     # 0x81AB
+    ("glGet",  F,      4,      "GL_CULL_VERTEX_OBJECT_POSITION_EXT"),  # 0x81AC
     ("",       X,      1,      "GL_IUI_V2F_EXT"),      # 0x81AD
     ("",       X,      1,      "GL_IUI_V3F_EXT"),      # 0x81AE
     ("",       X,      1,      "GL_IUI_N3F_V2F_EXT"),  # 0x81AF
@@ -910,7 +910,7 @@ parameters = [
     ("",       X,      1,      "GL_REPLACEMENT_CODE_SUN"),     # 0x81D8
     ("",       X,      1,      "GL_GLOBAL_ALPHA_SUN"), # 0x81D9
     ("",       X,      1,      "GL_GLOBAL_ALPHA_FACTOR_SUN"),  # 0x81DA
-    ("",       X,      1,      "GL_TEXTURE_COLOR_WRITEMASK_SGIS"),     # 0x81EF
+    ("glGet",  B,      4,      "GL_TEXTURE_COLOR_WRITEMASK_SGIS"),     # 0x81EF
     ("",       X,      1,      "GL_EYE_DISTANCE_TO_POINT_SGIS"),       # 0x81F0
     ("",       X,      1,      "GL_OBJECT_DISTANCE_TO_POINT_SGIS"),    # 0x81F1
     ("",       X,      1,      "GL_EYE_DISTANCE_TO_LINE_SGIS"),        # 0x81F2
@@ -968,22 +968,22 @@ parameters = [
     ("",       X,      1,      "GL_RG32UI"),   # 0x823C
     ("",       X,      1,      "GL_SYNC_CL_EVENT_ARB"),        # 0x8240
     ("",       X,      1,      "GL_SYNC_CL_EVENT_COMPLETE_ARB"),       # 0x8241
-    ("",       X,      1,      "GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB"),     # 0x8242
-    ("",       X,      1,      "GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB"),     # 0x8243
-    ("",       X,      1,      "GL_DEBUG_CALLBACK_FUNCTION_ARB"),      # 0x8244
-    ("",       X,      1,      "GL_DEBUG_CALLBACK_USER_PARAM_ARB"),    # 0x8245
-    ("",       X,      1,      "GL_DEBUG_SOURCE_API_ARB"),     # 0x8246
-    ("",       X,      1,      "GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB"),   # 0x8247
-    ("",       X,      1,      "GL_DEBUG_SOURCE_SHADER_COMPILER_ARB"), # 0x8248
-    ("",       X,      1,      "GL_DEBUG_SOURCE_THIRD_PARTY_ARB"),     # 0x8249
-    ("",       X,      1,      "GL_DEBUG_SOURCE_APPLICATION_ARB"),     # 0x824A
-    ("",       X,      1,      "GL_DEBUG_SOURCE_OTHER_ARB"),   # 0x824B
-    ("",       X,      1,      "GL_DEBUG_TYPE_ERROR_ARB"),     # 0x824C
-    ("",       X,      1,      "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB"),       # 0x824D
-    ("",       X,      1,      "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB"),        # 0x824E
-    ("",       X,      1,      "GL_DEBUG_TYPE_PORTABILITY_ARB"),       # 0x824F
-    ("",       X,      1,      "GL_DEBUG_TYPE_PERFORMANCE_ARB"),       # 0x8250
-    ("",       X,      1,      "GL_DEBUG_TYPE_OTHER_ARB"),     # 0x8251
+    ("glGet",  B,      1,      "GL_DEBUG_OUTPUT_SYNCHRONOUS"), # 0x8242
+    ("glGet",  I,      1,      "GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH"), # 0x8243
+    ("glGet",  P,      1,      "GL_DEBUG_CALLBACK_FUNCTION"),  # 0x8244
+    ("glGet",  P,      1,      "GL_DEBUG_CALLBACK_USER_PARAM"),        # 0x8245
+    ("",       X,      1,      "GL_DEBUG_SOURCE_API"), # 0x8246
+    ("",       X,      1,      "GL_DEBUG_SOURCE_WINDOW_SYSTEM"),       # 0x8247
+    ("",       X,      1,      "GL_DEBUG_SOURCE_SHADER_COMPILER"),     # 0x8248
+    ("",       X,      1,      "GL_DEBUG_SOURCE_THIRD_PARTY"), # 0x8249
+    ("",       X,      1,      "GL_DEBUG_SOURCE_APPLICATION"), # 0x824A
+    ("",       X,      1,      "GL_DEBUG_SOURCE_OTHER"),       # 0x824B
+    ("",       X,      1,      "GL_DEBUG_TYPE_ERROR"), # 0x824C
+    ("",       X,      1,      "GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR"),   # 0x824D
+    ("",       X,      1,      "GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR"),    # 0x824E
+    ("",       X,      1,      "GL_DEBUG_TYPE_PORTABILITY"),   # 0x824F
+    ("",       X,      1,      "GL_DEBUG_TYPE_PERFORMANCE"),   # 0x8250
+    ("",       X,      1,      "GL_DEBUG_TYPE_OTHER"), # 0x8251
     ("",       X,      1,      "GL_LOSE_CONTEXT_ON_RESET_ARB"),        # 0x8252
     ("",       X,      1,      "GL_GUILTY_CONTEXT_RESET_ARB"), # 0x8253
     ("",       X,      1,      "GL_INNOCENT_CONTEXT_RESET_ARB"),       # 0x8254
@@ -1000,6 +1000,139 @@ parameters = [
     ("glGet",  E,      1,      "GL_VIEWPORT_INDEX_PROVOKING_VERTEX"),  # 0x825F
     ("",       X,      1,      "GL_UNDEFINED_VERTEX"), # 0x8260
     ("",       X,      1,      "GL_NO_RESET_NOTIFICATION_ARB"),        # 0x8261
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_SHARED_MEMORY_SIZE"),   # 0x8262
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_UNIFORM_COMPONENTS"),   # 0x8263
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS"),       # 0x8264
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_ATOMIC_COUNTERS"),      # 0x8265
+    ("glGet",  I,      1,      "GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS"),  # 0x8266
+    ("",       X,      1,      "GL_COMPUTE_LOCAL_WORK_SIZE"),  # 0x8267
+    ("",       X,      1,      "GL_DEBUG_TYPE_MARKER"),        # 0x8268
+    ("",       X,      1,      "GL_DEBUG_TYPE_PUSH_GROUP"),    # 0x8269
+    ("",       X,      1,      "GL_DEBUG_TYPE_POP_GROUP"),     # 0x826A
+    ("",       X,      1,      "GL_DEBUG_SEVERITY_NOTIFICATION"),      # 0x826B
+    ("",       X,      1,      "GL_MAX_DEBUG_GROUP_STACK_DEPTH"),      # 0x826C
+    ("",       X,      1,      "GL_DEBUG_GROUP_STACK_DEPTH"),  # 0x826D
+    ("glGet",  I,      1,      "GL_MAX_UNIFORM_LOCATIONS"),    # 0x826E
+    ("",       X,      1,      "GL_INTERNALFORMAT_SUPPORTED"), # 0x826F
+    ("",       X,      1,      "GL_INTERNALFORMAT_PREFERRED"), # 0x8270
+    ("",       X,      1,      "GL_INTERNALFORMAT_RED_SIZE"),  # 0x8271
+    ("",       X,      1,      "GL_INTERNALFORMAT_GREEN_SIZE"),        # 0x8272
+    ("",       X,      1,      "GL_INTERNALFORMAT_BLUE_SIZE"), # 0x8273
+    ("",       X,      1,      "GL_INTERNALFORMAT_ALPHA_SIZE"),        # 0x8274
+    ("",       X,      1,      "GL_INTERNALFORMAT_DEPTH_SIZE"),        # 0x8275
+    ("",       X,      1,      "GL_INTERNALFORMAT_STENCIL_SIZE"),      # 0x8276
+    ("",       X,      1,      "GL_INTERNALFORMAT_SHARED_SIZE"),       # 0x8277
+    ("",       X,      1,      "GL_INTERNALFORMAT_RED_TYPE"),  # 0x8278
+    ("",       X,      1,      "GL_INTERNALFORMAT_GREEN_TYPE"),        # 0x8279
+    ("",       X,      1,      "GL_INTERNALFORMAT_BLUE_TYPE"), # 0x827A
+    ("",       X,      1,      "GL_INTERNALFORMAT_ALPHA_TYPE"),        # 0x827B
+    ("",       X,      1,      "GL_INTERNALFORMAT_DEPTH_TYPE"),        # 0x827C
+    ("",       X,      1,      "GL_INTERNALFORMAT_STENCIL_TYPE"),      # 0x827D
+    ("",       X,      1,      "GL_MAX_WIDTH"),        # 0x827E
+    ("",       X,      1,      "GL_MAX_HEIGHT"),       # 0x827F
+    ("",       X,      1,      "GL_MAX_DEPTH"),        # 0x8280
+    ("",       X,      1,      "GL_MAX_LAYERS"),       # 0x8281
+    ("",       X,      1,      "GL_MAX_COMBINED_DIMENSIONS"),  # 0x8282
+    ("",       X,      1,      "GL_COLOR_COMPONENTS"), # 0x8283
+    ("",       X,      1,      "GL_DEPTH_COMPONENTS"), # 0x8284
+    ("",       X,      1,      "GL_STENCIL_COMPONENTS"),       # 0x8285
+    ("",       X,      1,      "GL_COLOR_RENDERABLE"), # 0x8286
+    ("",       X,      1,      "GL_DEPTH_RENDERABLE"), # 0x8287
+    ("",       X,      1,      "GL_STENCIL_RENDERABLE"),       # 0x8288
+    ("",       X,      1,      "GL_FRAMEBUFFER_RENDERABLE"),   # 0x8289
+    ("",       X,      1,      "GL_FRAMEBUFFER_RENDERABLE_LAYERED"),   # 0x828A
+    ("",       X,      1,      "GL_FRAMEBUFFER_BLEND"),        # 0x828B
+    ("",       X,      1,      "GL_READ_PIXELS"),      # 0x828C
+    ("",       X,      1,      "GL_READ_PIXELS_FORMAT"),       # 0x828D
+    ("",       X,      1,      "GL_READ_PIXELS_TYPE"), # 0x828E
+    ("",       X,      1,      "GL_TEXTURE_IMAGE_FORMAT"),     # 0x828F
+    ("",       X,      1,      "GL_TEXTURE_IMAGE_TYPE"),       # 0x8290
+    ("",       X,      1,      "GL_GET_TEXTURE_IMAGE_FORMAT"), # 0x8291
+    ("",       X,      1,      "GL_GET_TEXTURE_IMAGE_TYPE"),   # 0x8292
+    ("",       X,      1,      "GL_MIPMAP"),   # 0x8293
+    ("",       X,      1,      "GL_MANUAL_GENERATE_MIPMAP"),   # 0x8294
+    ("",       X,      1,      "GL_AUTO_GENERATE_MIPMAP"),     # 0x8295
+    ("",       X,      1,      "GL_COLOR_ENCODING"),   # 0x8296
+    ("",       X,      1,      "GL_SRGB_READ"),        # 0x8297
+    ("",       X,      1,      "GL_SRGB_WRITE"),       # 0x8298
+    ("",       X,      1,      "GL_SRGB_DECODE_ARB"),  # 0x8299
+    ("",       X,      1,      "GL_FILTER"),   # 0x829A
+    ("",       X,      1,      "GL_VERTEX_TEXTURE"),   # 0x829B
+    ("",       X,      1,      "GL_TESS_CONTROL_TEXTURE"),     # 0x829C
+    ("",       X,      1,      "GL_TESS_EVALUATION_TEXTURE"),  # 0x829D
+    ("",       X,      1,      "GL_GEOMETRY_TEXTURE"), # 0x829E
+    ("",       X,      1,      "GL_FRAGMENT_TEXTURE"), # 0x829F
+    ("",       X,      1,      "GL_COMPUTE_TEXTURE"),  # 0x82A0
+    ("",       X,      1,      "GL_TEXTURE_SHADOW"),   # 0x82A1
+    ("",       X,      1,      "GL_TEXTURE_GATHER"),   # 0x82A2
+    ("",       X,      1,      "GL_TEXTURE_GATHER_SHADOW"),    # 0x82A3
+    ("",       X,      1,      "GL_SHADER_IMAGE_LOAD"),        # 0x82A4
+    ("",       X,      1,      "GL_SHADER_IMAGE_STORE"),       # 0x82A5
+    ("",       X,      1,      "GL_SHADER_IMAGE_ATOMIC"),      # 0x82A6
+    ("",       X,      1,      "GL_IMAGE_TEXEL_SIZE"), # 0x82A7
+    ("",       X,      1,      "GL_IMAGE_COMPATIBILITY_CLASS"),        # 0x82A8
+    ("",       X,      1,      "GL_IMAGE_PIXEL_FORMAT"),       # 0x82A9
+    ("",       X,      1,      "GL_IMAGE_PIXEL_TYPE"), # 0x82AA
+    ("",       X,      1,      "GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST"),      # 0x82AC
+    ("",       X,      1,      "GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST"),    # 0x82AD
+    ("",       X,      1,      "GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE"),     # 0x82AE
+    ("",       X,      1,      "GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE"),   # 0x82AF
+    ("",       X,      1,      "GL_TEXTURE_COMPRESSED_BLOCK_WIDTH"),   # 0x82B1
+    ("",       X,      1,      "GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT"),  # 0x82B2
+    ("",       X,      1,      "GL_TEXTURE_COMPRESSED_BLOCK_SIZE"),    # 0x82B3
+    ("",       X,      1,      "GL_CLEAR_BUFFER"),     # 0x82B4
+    ("",       X,      1,      "GL_TEXTURE_VIEW"),     # 0x82B5
+    ("",       X,      1,      "GL_VIEW_COMPATIBILITY_CLASS"), # 0x82B6
+    ("",       X,      1,      "GL_FULL_SUPPORT"),     # 0x82B7
+    ("",       X,      1,      "GL_CAVEAT_SUPPORT"),   # 0x82B8
+    ("",       X,      1,      "GL_IMAGE_CLASS_4_X_32"),       # 0x82B9
+    ("",       X,      1,      "GL_IMAGE_CLASS_2_X_32"),       # 0x82BA
+    ("",       X,      1,      "GL_IMAGE_CLASS_1_X_32"),       # 0x82BB
+    ("",       X,      1,      "GL_IMAGE_CLASS_4_X_16"),       # 0x82BC
+    ("",       X,      1,      "GL_IMAGE_CLASS_2_X_16"),       # 0x82BD
+    ("",       X,      1,      "GL_IMAGE_CLASS_1_X_16"),       # 0x82BE
+    ("",       X,      1,      "GL_IMAGE_CLASS_4_X_8"),        # 0x82BF
+    ("",       X,      1,      "GL_IMAGE_CLASS_2_X_8"),        # 0x82C0
+    ("",       X,      1,      "GL_IMAGE_CLASS_1_X_8"),        # 0x82C1
+    ("",       X,      1,      "GL_IMAGE_CLASS_11_11_10"),     # 0x82C2
+    ("",       X,      1,      "GL_IMAGE_CLASS_10_10_10_2"),   # 0x82C3
+    ("",       X,      1,      "GL_VIEW_CLASS_128_BITS"),      # 0x82C4
+    ("",       X,      1,      "GL_VIEW_CLASS_96_BITS"),       # 0x82C5
+    ("",       X,      1,      "GL_VIEW_CLASS_64_BITS"),       # 0x82C6
+    ("",       X,      1,      "GL_VIEW_CLASS_48_BITS"),       # 0x82C7
+    ("",       X,      1,      "GL_VIEW_CLASS_32_BITS"),       # 0x82C8
+    ("",       X,      1,      "GL_VIEW_CLASS_24_BITS"),       # 0x82C9
+    ("",       X,      1,      "GL_VIEW_CLASS_16_BITS"),       # 0x82CA
+    ("",       X,      1,      "GL_VIEW_CLASS_8_BITS"),        # 0x82CB
+    ("",       X,      1,      "GL_VIEW_CLASS_S3TC_DXT1_RGB"), # 0x82CC
+    ("",       X,      1,      "GL_VIEW_CLASS_S3TC_DXT1_RGBA"),        # 0x82CD
+    ("",       X,      1,      "GL_VIEW_CLASS_S3TC_DXT3_RGBA"),        # 0x82CE
+    ("",       X,      1,      "GL_VIEW_CLASS_S3TC_DXT5_RGBA"),        # 0x82CF
+    ("",       X,      1,      "GL_VIEW_CLASS_RGTC1_RED"),     # 0x82D0
+    ("",       X,      1,      "GL_VIEW_CLASS_RGTC2_RG"),      # 0x82D1
+    ("",       X,      1,      "GL_VIEW_CLASS_BPTC_UNORM"),    # 0x82D2
+    ("",       X,      1,      "GL_VIEW_CLASS_BPTC_FLOAT"),    # 0x82D3
+    ("",       I,      1,      "GL_VERTEX_ATTRIB_BINDING"),    # 0x82D4
+    ("",       I,      1,      "GL_VERTEX_ATTRIB_RELATIVE_OFFSET"),    # 0x82D5
+    ("",       I,      1,      "GL_VERTEX_BINDING_DIVISOR"),   # 0x82D6
+    ("",       I,      1,      "GL_VERTEX_BINDING_OFFSET"),    # 0x82D7
+    ("",       I,      1,      "GL_VERTEX_BINDING_STRIDE"),    # 0x82D8
+    ("",       I,      1,      "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET"),        # 0x82D9
+    ("",       I,      1,      "GL_MAX_VERTEX_ATTRIB_BINDINGS"),       # 0x82DA
+    ("glGetTexParameter",      I,      1,      "GL_TEXTURE_VIEW_MIN_LEVEL"),   # 0x82DB
+    ("glGetTexParameter",      I,      1,      "GL_TEXTURE_VIEW_NUM_LEVELS"),  # 0x82DC
+    ("glGetTexParameter",      I,      1,      "GL_TEXTURE_VIEW_MIN_LAYER"),   # 0x82DD
+    ("glGetTexParameter",      I,      1,      "GL_TEXTURE_VIEW_NUM_LAYERS"),  # 0x82DE
+    ("glGetTexParameter",      I,      1,      "GL_TEXTURE_IMMUTABLE_LEVELS"), # 0x82DF
+    ("",       X,      1,      "GL_BUFFER"),   # 0x82E0
+    ("",       X,      1,      "GL_SHADER"),   # 0x82E1
+    ("",       X,      1,      "GL_PROGRAM"),  # 0x82E2
+    ("",       X,      1,      "GL_QUERY"),    # 0x82E3
+    ("",       X,      1,      "GL_PROGRAM_PIPELINE"), # 0x82E4
+    ("",       X,      1,      "GL_SAMPLER"),  # 0x82E6
+    ("",       X,      1,      "GL_DISPLAY_LIST"),     # 0x82E7
+    ("",       X,      1,      "GL_MAX_LABEL_LENGTH"), # 0x82E8
+    ("",       X,      1,      "GL_NUM_SHADING_LANGUAGE_VERSIONS"),    # 0x82E9
     ("",       X,      1,      "GL_DEPTH_PASS_INSTRUMENT_SGIX"),       # 0x8310
     ("",       X,      1,      "GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX"),      # 0x8311
     ("",       X,      1,      "GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX"),   # 0x8312
@@ -1177,8 +1310,8 @@ parameters = [
     ("",       X,      1,      "GL_COMPRESSED_RGB"),   # 0x84ED
     ("",       X,      1,      "GL_COMPRESSED_RGBA"),  # 0x84EE
     ("glGet",  E,      1,      "GL_TEXTURE_COMPRESSION_HINT"), # 0x84EF
-    ("",       X,      1,      "GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER"),  # 0x84F0
-    ("",       X,      1,      "GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER"),       # 0x84F1
+    ("glGetActiveUniformBlock",        B,      1,      "GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER"),  # 0x84F0
+    ("glGetActiveUniformBlock",        B,      1,      "GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER"),       # 0x84F1
     ("",       X,      1,      "GL_ALL_COMPLETED_NV"), # 0x84F2
     ("",       X,      1,      "GL_FENCE_STATUS_NV"),  # 0x84F3
     ("",       X,      1,      "GL_FENCE_CONDITION_NV"),       # 0x84F4
@@ -1791,7 +1924,7 @@ parameters = [
     ("",       X,      1,      "GL_INTENSITY16F_ARB"), # 0x881D
     ("",       X,      1,      "GL_LUMINANCE16F_ARB"), # 0x881E
     ("",       X,      1,      "GL_LUMINANCE_ALPHA16F_ARB"),   # 0x881F
-    ("",       X,      1,      "GL_RGBA_FLOAT_MODE_ARB"),      # 0x8820
+    ("glGet",  B,      1,      "GL_RGBA_FLOAT_MODE_ARB"),      # 0x8820
     ("glGet",  I,      1,      "GL_MAX_DRAW_BUFFERS"), # 0x8824
     ("glGet",  E,      1,      "GL_DRAW_BUFFER0"),     # 0x8825
     ("glGet",  E,      1,      "GL_DRAW_BUFFER1"),     # 0x8826
@@ -1993,7 +2126,7 @@ parameters = [
     ("",       X,      1,      "GL_SRC1_COLOR"),       # 0x88F9
     ("",       X,      1,      "GL_ONE_MINUS_SRC1_COLOR"),     # 0x88FA
     ("",       X,      1,      "GL_ONE_MINUS_SRC1_ALPHA"),     # 0x88FB
-    ("",       X,      1,      "GL_MAX_DUAL_SOURCE_DRAW_BUFFERS"),     # 0x88FC
+    ("glGet",  I,      1,      "GL_MAX_DUAL_SOURCE_DRAW_BUFFERS"),     # 0x88FC
     ("glGetVertexAttrib",      I,      1,      "GL_VERTEX_ATTRIB_ARRAY_INTEGER"),      # 0x88FD
     ("glGetVertexAttrib",      I,      1,      "GL_VERTEX_ATTRIB_ARRAY_DIVISOR"),      # 0x88FE
     ("glGet",  I,      1,      "GL_MAX_ARRAY_TEXTURE_LAYERS"), # 0x88FF
@@ -2011,9 +2144,9 @@ parameters = [
     ("",       X,      1,      "GL_GEOMETRY_INPUT_TYPE"),      # 0x8917
     ("",       X,      1,      "GL_GEOMETRY_OUTPUT_TYPE"),     # 0x8918
     ("glGet",  I,      1,      "GL_SAMPLER_BINDING"),  # 0x8919
-    ("",       X,      1,      "GL_CLAMP_VERTEX_COLOR"),       # 0x891A
-    ("",       X,      1,      "GL_CLAMP_FRAGMENT_COLOR"),     # 0x891B
-    ("",       X,      1,      "GL_CLAMP_READ_COLOR"), # 0x891C
+    ("glGet",  B,      1,      "GL_CLAMP_VERTEX_COLOR"),       # 0x891A
+    ("glGet",  B,      1,      "GL_CLAMP_FRAGMENT_COLOR"),     # 0x891B
+    ("glGet",  B,      1,      "GL_CLAMP_READ_COLOR"), # 0x891C
     ("",       X,      1,      "GL_FIXED_ONLY"),       # 0x891D
     ("",       X,      1,      "GL_TESS_CONTROL_PROGRAM_NV"),  # 0x891E
     ("",       X,      1,      "GL_TESS_EVALUATION_PROGRAM_NV"),       # 0x891F
@@ -2186,8 +2319,8 @@ parameters = [
     ("glGetTexParameter",      E,      1,      "GL_TEXTURE_SRGB_DECODE_EXT"),  # 0x8A48
     ("",       X,      1,      "GL_DECODE_EXT"),       # 0x8A49
     ("",       X,      1,      "GL_SKIP_DECODE_EXT"),  # 0x8A4A
-    ("",       X,      1,      "GL_FRAGMENT_SHADER"),  # 0x8B30
-    ("",       X,      1,      "GL_VERTEX_SHADER"),    # 0x8B31
+    ("glGetProgramPipeline",   I,      1,      "GL_FRAGMENT_SHADER"),  # 0x8B30
+    ("glGetProgramPipeline",   I,      1,      "GL_VERTEX_SHADER"),    # 0x8B31
     ("",       H,      1,      "GL_PROGRAM_OBJECT_ARB"),       # 0x8B40
     ("",       X,      1,      "GL_SHADER_OBJECT_ARB"),        # 0x8B48
     ("glGet",  I,      1,      "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS"),  # 0x8B49
@@ -2195,7 +2328,7 @@ parameters = [
     ("glGet",  I,      1,      "GL_MAX_VARYING_COMPONENTS"),   # 0x8B4B
     ("glGet",  I,      1,      "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS"),   # 0x8B4C
     ("glGet",  I,      1,      "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS"), # 0x8B4D
-    ("glGet",  E,      1,      "GL_OBJECT_TYPE_ARB"),  # 0x8B4E
+    ("",       E,      1,      "GL_OBJECT_TYPE_ARB"),  # 0x8B4E
     ("glGetShader",    E,      1,      "GL_SHADER_TYPE"),      # 0x8B4F
     ("",       X,      1,      "GL_FLOAT_VEC2"),       # 0x8B50
     ("",       X,      1,      "GL_FLOAT_VEC3"),       # 0x8B51
@@ -2236,7 +2369,7 @@ parameters = [
     ("glGetProgram",   I,      1,      "GL_ACTIVE_ATTRIBUTES"),        # 0x8B89
     ("glGetProgram",   I,      1,      "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"),      # 0x8B8A
     ("",       X,      1,      "GL_FRAGMENT_SHADER_DERIVATIVE_HINT"),  # 0x8B8B
-    ("",       X,      1,      "GL_SHADING_LANGUAGE_VERSION"), # 0x8B8C
+    ("glGet",  S,      1,      "GL_SHADING_LANGUAGE_VERSION"), # 0x8B8C
     ("glGet",  I,      1,      "GL_CURRENT_PROGRAM"),  # 0x8B8D
     #("",      X,      1,      "GL_PALETTE4_RGB8_OES"),        # 0x8B90
     #("",      X,      1,      "GL_PALETTE4_RGBA8_OES"),       # 0x8B91
@@ -2248,10 +2381,10 @@ parameters = [
     #("",      X,      1,      "GL_PALETTE8_R5_G6_B5_OES"),    # 0x8B97
     #("",      X,      1,      "GL_PALETTE8_RGBA4_OES"),       # 0x8B98
     #("",      X,      1,      "GL_PALETTE8_RGB5_A1_OES"),     # 0x8B99
-    ("glGet",  I,      1,      "GL_IMPLEMENTATION_COLOR_READ_TYPE"),   # 0x8B9A
-    ("glGet",  I,      1,      "GL_IMPLEMENTATION_COLOR_READ_FORMAT"), # 0x8B9B
+    ("glGet",  E,      1,      "GL_IMPLEMENTATION_COLOR_READ_TYPE"),   # 0x8B9A
+    ("glGet",  E,      1,      "GL_IMPLEMENTATION_COLOR_READ_FORMAT"), # 0x8B9B
     #("",      X,      1,      "GL_POINT_SIZE_ARRAY_OES"),     # 0x8B9C
-    #("",      X,      1,      "GL_TEXTURE_CROP_RECT_OES"),    # 0x8B9D
+    ("glGetTexParameter",      I,      4,      "GL_TEXTURE_CROP_RECT_OES"),    # 0x8B9D
     #("",      X,      1,      "GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES"),    # 0x8B9E
     #("",      X,      1,      "GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES"),      # 0x8B9F
     #("",      X,      1,      "GL_FRAGMENT_PROGRAM_POSITION_MESA"),   # 0x8BB0
@@ -2291,13 +2424,13 @@ parameters = [
     #("",      X,      1,      "GL_FRAGMENT_ALPHA_MODULATE_IMG"),      # 0x8C08
     #("",      X,      1,      "GL_ADD_BLEND_IMG"),    # 0x8C09
     #("",      X,      1,      "GL_SGX_BINARY_IMG"),   # 0x8C0A
-    ("",       X,      1,      "GL_TEXTURE_RED_TYPE"), # 0x8C10
-    ("",       X,      1,      "GL_TEXTURE_GREEN_TYPE"),       # 0x8C11
-    ("",       X,      1,      "GL_TEXTURE_BLUE_TYPE"),        # 0x8C12
-    ("",       X,      1,      "GL_TEXTURE_ALPHA_TYPE"),       # 0x8C13
-    ("",       X,      1,      "GL_TEXTURE_LUMINANCE_TYPE"),   # 0x8C14
-    ("",       X,      1,      "GL_TEXTURE_INTENSITY_TYPE"),   # 0x8C15
-    ("",       X,      1,      "GL_TEXTURE_DEPTH_TYPE"),       # 0x8C16
+    ("glGetTexLevelParameter", E,      1,      "GL_TEXTURE_RED_TYPE"), # 0x8C10
+    ("glGetTexLevelParameter", E,      1,      "GL_TEXTURE_GREEN_TYPE"),       # 0x8C11
+    ("glGetTexLevelParameter", E,      1,      "GL_TEXTURE_BLUE_TYPE"),        # 0x8C12
+    ("glGetTexLevelParameter", E,      1,      "GL_TEXTURE_ALPHA_TYPE"),       # 0x8C13
+    ("glGetTexLevelParameter", E,      1,      "GL_TEXTURE_LUMINANCE_TYPE"),   # 0x8C14
+    ("glGetTexLevelParameter", E,      1,      "GL_TEXTURE_INTENSITY_TYPE"),   # 0x8C15
+    ("glGetTexLevelParameter", E,      1,      "GL_TEXTURE_DEPTH_TYPE"),       # 0x8C16
     ("",       X,      1,      "GL_UNSIGNED_NORMALIZED"),      # 0x8C17
     ("",       X,      1,      "GL_TEXTURE_1D_ARRAY"), # 0x8C18
     ("",       X,      1,      "GL_PROXY_TEXTURE_1D_ARRAY"),   # 0x8C19
@@ -2309,11 +2442,11 @@ parameters = [
     ("",       X,      1,      "GL_MAX_PROGRAM_OUTPUT_VERTICES_NV"),   # 0x8C27
     ("",       X,      1,      "GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV"),   # 0x8C28
     ("glGet",  I,      1,      "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS"), # 0x8C29
-    ("",       X,      1,      "GL_TEXTURE_BUFFER"),   # 0x8C2A
-    ("",       X,      1,      "GL_MAX_TEXTURE_BUFFER_SIZE"),  # 0x8C2B
-    ("",       X,      1,      "GL_TEXTURE_BINDING_BUFFER"),   # 0x8C2C
+    ("glGet",  I,      1,      "GL_TEXTURE_BUFFER"),   # 0x8C2A
+    ("glGet",  I,      1,      "GL_MAX_TEXTURE_BUFFER_SIZE"),  # 0x8C2B
+    ("glGet",  I,      1,      "GL_TEXTURE_BINDING_BUFFER"),   # 0x8C2C
     ("glGet",  I,      1,      "GL_TEXTURE_BUFFER_DATA_STORE_BINDING"),        # 0x8C2D
-    ("",       X,      1,      "GL_TEXTURE_BUFFER_FORMAT"),    # 0x8C2E
+    ("glGet",  E,      1,      "GL_TEXTURE_BUFFER_FORMAT"),    # 0x8C2E
     ("",       X,      1,      "GL_ANY_SAMPLES_PASSED"),       # 0x8C2F
     ("",       X,      1,      "GL_SAMPLE_SHADING"),   # 0x8C36
     ("",       X,      1,      "GL_MIN_SAMPLE_SHADING_VALUE"), # 0x8C37
@@ -2359,12 +2492,12 @@ parameters = [
     ("",       X,      1,      "GL_ACTIVE_VARYINGS_NV"),       # 0x8C81
     ("",       X,      1,      "GL_ACTIVE_VARYING_MAX_LENGTH_NV"),     # 0x8C82
     ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_VARYINGS"),      # 0x8C83
-    ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_START"),  # 0x8C84
-    ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE"),   # 0x8C85
+    ("",       I,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_START"),  # 0x8C84
+    ("",       I,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE"),   # 0x8C85
     ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_RECORD_NV"),     # 0x8C86
     ("",       X,      1,      "GL_PRIMITIVES_GENERATED"),     # 0x8C87
     ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN"),    # 0x8C88
-    ("",       X,      1,      "GL_RASTERIZER_DISCARD"),       # 0x8C89
+    ("glGet",  B,      1,      "GL_RASTERIZER_DISCARD"),       # 0x8C89
     ("",       X,      1,      "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS"),    # 0x8C8A
     ("",       X,      1,      "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS"),  # 0x8C8B
     ("",       X,      1,      "GL_INTERLEAVED_ATTRIBS"),      # 0x8C8C
@@ -2444,6 +2577,10 @@ parameters = [
     #("",      X,      1,      "GL_SAMPLER_EXTERNAL_OES"),     # 0x8D66
     #("",      X,      1,      "GL_TEXTURE_BINDING_EXTERNAL_OES"),     # 0x8D67
     #("",      X,      1,      "GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES"), # 0x8D68
+    ("",       B,      1,      "GL_PRIMITIVE_RESTART_FIXED_INDEX"),    # 0x8D69
+    ("",       X,      1,      "GL_ANY_SAMPLES_PASSED_CONSERVATIVE"),  # 0x8D6A
+    ("glGet",  I,      1,      "GL_MAX_ELEMENT_INDEX"),        # 0x8D6B
+    #("",      X,      1,      "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT"),       # 0x8D6C
     ("",       X,      1,      "GL_RGBA32UI"), # 0x8D70
     ("",       X,      1,      "GL_RGB32UI"),  # 0x8D71
     ("",       X,      1,      "GL_ALPHA32UI_EXT"),    # 0x8D72
@@ -2539,10 +2676,10 @@ parameters = [
     ("",       X,      1,      "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY"),    # 0x8DD6
     ("",       X,      1,      "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY"),    # 0x8DD7
     ("",       X,      1,      "GL_UNSIGNED_INT_SAMPLER_BUFFER"),      # 0x8DD8
-    ("",       X,      1,      "GL_GEOMETRY_SHADER"),  # 0x8DD9
-    ("",       X,      1,      "GL_GEOMETRY_VERTICES_OUT_ARB"),        # 0x8DDA
-    ("",       X,      1,      "GL_GEOMETRY_INPUT_TYPE_ARB"),  # 0x8DDB
-    ("",       X,      1,      "GL_GEOMETRY_OUTPUT_TYPE_ARB"), # 0x8DDC
+    ("glGetProgramPipeline",   I,      1,      "GL_GEOMETRY_SHADER"),  # 0x8DD9
+    ("glGetProgram",   I,      1,      "GL_GEOMETRY_VERTICES_OUT_ARB"),        # 0x8DDA
+    ("glGetProgram",   E,      1,      "GL_GEOMETRY_INPUT_TYPE_ARB"),  # 0x8DDB
+    ("glGetProgram",   E,      1,      "GL_GEOMETRY_OUTPUT_TYPE_ARB"), # 0x8DDC
     ("glGet",  I,      1,      "GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB"),      # 0x8DDD
     ("glGet",  I,      1,      "GL_MAX_VERTEX_VARYING_COMPONENTS_ARB"),        # 0x8DDE
     ("glGet",  I,      1,      "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS"),  # 0x8DDF
@@ -2553,11 +2690,11 @@ parameters = [
     ("",       X,      1,      "GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT"),       # 0x8DE4
     ("",       X,      1,      "GL_ACTIVE_SUBROUTINES"),       # 0x8DE5
     ("",       X,      1,      "GL_ACTIVE_SUBROUTINE_UNIFORMS"),       # 0x8DE6
-    ("",       X,      1,      "GL_MAX_SUBROUTINES"),  # 0x8DE7
-    ("",       X,      1,      "GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS"), # 0x8DE8
-    ("",       X,      1,      "GL_NAMED_STRING_LENGTH_ARB"),  # 0x8DE9
-    ("",       X,      1,      "GL_NAMED_STRING_TYPE_ARB"),    # 0x8DEA
-    ("",       X,      1,      "GL_MAX_BINDABLE_UNIFORM_SIZE_EXT"),    # 0x8DED
+    ("glGet",  I,      1,      "GL_MAX_SUBROUTINES"),  # 0x8DE7
+    ("glGet",  I,      1,      "GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS"), # 0x8DE8
+    ("glGetNamedString",       X,      1,      "GL_NAMED_STRING_LENGTH_ARB"),  # 0x8DE9
+    ("glGetNamedString",       E,      1,      "GL_NAMED_STRING_TYPE_ARB"),    # 0x8DEA
+    ("glGet",  I,      1,      "GL_MAX_BINDABLE_UNIFORM_SIZE_EXT"),    # 0x8DED
     ("",       X,      1,      "GL_UNIFORM_BUFFER_EXT"),       # 0x8DEE
     ("glGet",  I,      1,      "GL_UNIFORM_BUFFER_BINDING_EXT"),       # 0x8DEF
     ("",       X,      1,      "GL_LOW_FLOAT"),        # 0x8DF0
@@ -2578,12 +2715,12 @@ parameters = [
     ("",       X,      1,      "GL_QUERY_NO_WAIT"),    # 0x8E14
     ("",       X,      1,      "GL_QUERY_BY_REGION_WAIT"),     # 0x8E15
     ("",       X,      1,      "GL_QUERY_BY_REGION_NO_WAIT"),  # 0x8E16
-    ("",       X,      1,      "GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS"),     # 0x8E1E
-    ("",       X,      1,      "GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS"),  # 0x8E1F
+    ("glGet",  I,      1,      "GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS"),     # 0x8E1E
+    ("glGet",  I,      1,      "GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS"),  # 0x8E1F
     ("",       X,      1,      "GL_COLOR_SAMPLES_NV"), # 0x8E20
     ("",       X,      1,      "GL_TRANSFORM_FEEDBACK"),       # 0x8E22
-    ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED"), # 0x8E23
-    ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE"), # 0x8E24
+    ("glGet",  B,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED"), # 0x8E23
+    ("glGet",  B,      1,      "GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE"), # 0x8E24
     ("glGet",  I,      1,      "GL_TRANSFORM_FEEDBACK_BINDING"),       # 0x8E25
     ("",       X,      1,      "GL_FRAME_NV"), # 0x8E26
     ("",       X,      1,      "GL_FIELDS_NV"),        # 0x8E27
@@ -2608,49 +2745,49 @@ parameters = [
     ("",       X,      1,      "GL_FIRST_VERTEX_CONVENTION"),  # 0x8E4D
     ("",       X,      1,      "GL_LAST_VERTEX_CONVENTION"),   # 0x8E4E
     ("glGet",  E,      1,      "GL_PROVOKING_VERTEX"), # 0x8E4F
-    ("",       X,      1,      "GL_SAMPLE_POSITION"),  # 0x8E50
-    ("",       X,      1,      "GL_SAMPLE_MASK"),      # 0x8E51
-    ("",       X,      1,      "GL_SAMPLE_MASK_VALUE"),        # 0x8E52
+    ("glGetMultisample",       I,      1,      "GL_SAMPLE_POSITION"),  # 0x8E50
+    ("glGet",  B,      1,      "GL_SAMPLE_MASK"),      # 0x8E51
+    ("glGet",  I,      1,      "GL_SAMPLE_MASK_VALUE"),        # 0x8E52
     ("",       X,      1,      "GL_TEXTURE_BINDING_RENDERBUFFER_NV"),  # 0x8E53
     ("glGet",  I,      1,      "GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV"),       # 0x8E54
     ("",       X,      1,      "GL_TEXTURE_RENDERBUFFER_NV"),  # 0x8E55
     ("",       X,      1,      "GL_SAMPLER_RENDERBUFFER_NV"),  # 0x8E56
     ("",       X,      1,      "GL_INT_SAMPLER_RENDERBUFFER_NV"),      # 0x8E57
     ("",       X,      1,      "GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV"),     # 0x8E58
-    ("",       X,      1,      "GL_MAX_SAMPLE_MASK_WORDS"),    # 0x8E59
+    ("glGet",  I,      1,      "GL_MAX_SAMPLE_MASK_WORDS"),    # 0x8E59
     ("",       X,      1,      "GL_MAX_GEOMETRY_SHADER_INVOCATIONS"),  # 0x8E5A
     ("",       X,      1,      "GL_MIN_FRAGMENT_INTERPOLATION_OFFSET"),        # 0x8E5B
     ("",       X,      1,      "GL_MAX_FRAGMENT_INTERPOLATION_OFFSET"),        # 0x8E5C
     ("",       X,      1,      "GL_FRAGMENT_INTERPOLATION_OFFSET_BITS"),       # 0x8E5D
     ("",       X,      1,      "GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET"),        # 0x8E5E
     ("",       X,      1,      "GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET"),        # 0x8E5F
-    ("",       X,      1,      "GL_MAX_TRANSFORM_FEEDBACK_BUFFERS"),   # 0x8E70
-    ("",       X,      1,      "GL_MAX_VERTEX_STREAMS"),       # 0x8E71
-    ("",       X,      1,      "GL_PATCH_VERTICES"),   # 0x8E72
-    ("",       F,      2,      "GL_PATCH_DEFAULT_INNER_LEVEL"),        # 0x8E73
-    ("glGetPatchParameter",    F,      4,      "GL_PATCH_DEFAULT_OUTER_LEVEL"),        # 0x8E74
-    ("glGetPatchParameter",    X,      1,      "GL_TESS_CONTROL_OUTPUT_VERTICES"),     # 0x8E75
-    ("",       X,      1,      "GL_TESS_GEN_MODE"),    # 0x8E76
-    ("",       X,      1,      "GL_TESS_GEN_SPACING"), # 0x8E77
-    ("",       X,      1,      "GL_TESS_GEN_VERTEX_ORDER"),    # 0x8E78
-    ("",       X,      1,      "GL_TESS_GEN_POINT_MODE"),      # 0x8E79
+    ("glGet",  I,      1,      "GL_MAX_TRANSFORM_FEEDBACK_BUFFERS"),   # 0x8E70
+    ("glGet",  I,      1,      "GL_MAX_VERTEX_STREAMS"),       # 0x8E71
+    ("glGet",  I,      1,      "GL_PATCH_VERTICES"),   # 0x8E72
+    ("glGet",  F,      2,      "GL_PATCH_DEFAULT_INNER_LEVEL"),        # 0x8E73
+    ("glGet",  F,      4,      "GL_PATCH_DEFAULT_OUTER_LEVEL"),        # 0x8E74
+    ("glGet",  X,      1,      "GL_TESS_CONTROL_OUTPUT_VERTICES"),     # 0x8E75
+    ("glGet",  E,      1,      "GL_TESS_GEN_MODE"),    # 0x8E76
+    ("glGet",  E,      1,      "GL_TESS_GEN_SPACING"), # 0x8E77
+    ("glGet",  E,      1,      "GL_TESS_GEN_VERTEX_ORDER"),    # 0x8E78
+    ("glGet",  E,      1,      "GL_TESS_GEN_POINT_MODE"),      # 0x8E79
     ("",       X,      1,      "GL_ISOLINES"), # 0x8E7A
     ("",       X,      1,      "GL_FRACTIONAL_ODD"),   # 0x8E7B
     ("",       X,      1,      "GL_FRACTIONAL_EVEN"),  # 0x8E7C
-    ("",       X,      1,      "GL_MAX_PATCH_VERTICES"),       # 0x8E7D
-    ("",       X,      1,      "GL_MAX_TESS_GEN_LEVEL"),       # 0x8E7E
-    ("",       X,      1,      "GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS"),      # 0x8E7F
-    ("",       X,      1,      "GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS"),   # 0x8E80
-    ("",       X,      1,      "GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS"),     # 0x8E81
-    ("",       X,      1,      "GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS"),  # 0x8E82
-    ("",       X,      1,      "GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS"),       # 0x8E83
-    ("",       X,      1,      "GL_MAX_TESS_PATCH_COMPONENTS"),        # 0x8E84
-    ("",       X,      1,      "GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS"), # 0x8E85
-    ("",       X,      1,      "GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS"),    # 0x8E86
-    ("",       X,      1,      "GL_TESS_EVALUATION_SHADER"),   # 0x8E87
-    ("",       X,      1,      "GL_TESS_CONTROL_SHADER"),      # 0x8E88
-    ("",       X,      1,      "GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS"),  # 0x8E89
-    ("",       X,      1,      "GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS"),       # 0x8E8A
+    ("glGet",  I,      1,      "GL_MAX_PATCH_VERTICES"),       # 0x8E7D
+    ("glGet",  I,      1,      "GL_MAX_TESS_GEN_LEVEL"),       # 0x8E7E
+    ("glGet",  I,      1,      "GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS"),      # 0x8E7F
+    ("glGet",  I,      1,      "GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS"),   # 0x8E80
+    ("glGet",  I,      1,      "GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS"),     # 0x8E81
+    ("glGet",  I,      1,      "GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS"),  # 0x8E82
+    ("glGet",  I,      1,      "GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS"),       # 0x8E83
+    ("glGet",  I,      1,      "GL_MAX_TESS_PATCH_COMPONENTS"),        # 0x8E84
+    ("glGet",  I,      1,      "GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS"), # 0x8E85
+    ("glGet",  I,      1,      "GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS"),    # 0x8E86
+    ("glGetProgramPipeline",   I,      1,      "GL_TESS_EVALUATION_SHADER"),   # 0x8E87
+    ("glGetProgramPipeline",   I,      1,      "GL_TESS_CONTROL_SHADER"),      # 0x8E88
+    ("glGet",  I,      1,      "GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS"),  # 0x8E89
+    ("glGet",  I,      1,      "GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS"),       # 0x8E8A
     ("",       X,      1,      "GL_COMPRESSED_RGBA_BPTC_UNORM_ARB"),   # 0x8E8C
     ("",       X,      1,      "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB"),     # 0x8E8D
     ("",       X,      1,      "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB"),     # 0x8E8E
@@ -2688,8 +2825,8 @@ parameters = [
     ("",       X,      1,      "GL_ELEMENT_ARRAY_LENGTH_NV"),  # 0x8F33
     ("",       X,      1,      "GL_GPU_ADDRESS_NV"),   # 0x8F34
     ("",       X,      1,      "GL_MAX_SHADER_BUFFER_ADDRESS_NV"),     # 0x8F35
-    ("",       X,      1,      "GL_COPY_READ_BUFFER"), # 0x8F36
-    ("",       X,      1,      "GL_COPY_WRITE_BUFFER"),        # 0x8F37
+    ("glGet",  I,      1,      "GL_COPY_READ_BUFFER"), # 0x8F36
+    ("glGet",  I,      1,      "GL_COPY_WRITE_BUFFER"),        # 0x8F37
     ("",       X,      1,      "GL_MAX_IMAGE_UNITS"),  # 0x8F38
     ("",       X,      1,      "GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS"),    # 0x8F39
     ("",       X,      1,      "GL_IMAGE_BINDING_NAME"),       # 0x8F3A
@@ -2768,7 +2905,7 @@ parameters = [
     ("",       X,      1,      "GL_TESSELLATION_FACTOR_AMD"),  # 0x9005
     ("",       X,      1,      "GL_DISCRETE_AMD"),     # 0x9006
     ("",       X,      1,      "GL_CONTINUOUS_AMD"),   # 0x9007
-    ("",       X,      1,      "GL_TEXTURE_CUBE_MAP_ARRAY"),   # 0x9009
+    ("_glGet", B,      1,      "GL_TEXTURE_CUBE_MAP_ARRAY"),   # 0x9009
     ("_glGet", I,      1,      "GL_TEXTURE_BINDING_CUBE_MAP_ARRAY"),   # 0x900A
     ("",       X,      1,      "GL_PROXY_TEXTURE_CUBE_MAP_ARRAY"),     # 0x900B
     ("",       X,      1,      "GL_SAMPLER_CUBE_MAP_ARRAY"),   # 0x900C
@@ -2863,9 +3000,86 @@ parameters = [
     ("",       X,      1,      "GL_MAX_IMAGE_SAMPLES"),        # 0x906D
     ("",       X,      1,      "GL_IMAGE_BINDING_FORMAT"),     # 0x906E
     ("",       X,      1,      "GL_RGB10_A2UI"),       # 0x906F
+    ("",       X,      1,      "GL_PATH_FORMAT_SVG_NV"),       # 0x9070
+    ("",       X,      1,      "GL_PATH_FORMAT_PS_NV"),        # 0x9071
+    ("",       X,      1,      "GL_STANDARD_FONT_NAME_NV"),    # 0x9072
+    ("",       X,      1,      "GL_SYSTEM_FONT_NAME_NV"),      # 0x9073
+    ("",       X,      1,      "GL_FILE_NAME_NV"),     # 0x9074
+    ("",       X,      1,      "GL_PATH_STROKE_WIDTH_NV"),     # 0x9075
+    ("",       X,      1,      "GL_PATH_END_CAPS_NV"), # 0x9076
+    ("",       X,      1,      "GL_PATH_INITIAL_END_CAP_NV"),  # 0x9077
+    ("",       X,      1,      "GL_PATH_TERMINAL_END_CAP_NV"), # 0x9078
+    ("",       X,      1,      "GL_PATH_JOIN_STYLE_NV"),       # 0x9079
+    ("",       X,      1,      "GL_PATH_MITER_LIMIT_NV"),      # 0x907A
+    ("",       X,      1,      "GL_PATH_DASH_CAPS_NV"),        # 0x907B
+    ("",       X,      1,      "GL_PATH_INITIAL_DASH_CAP_NV"), # 0x907C
+    ("",       X,      1,      "GL_PATH_TERMINAL_DASH_CAP_NV"),        # 0x907D
+    ("",       X,      1,      "GL_PATH_DASH_OFFSET_NV"),      # 0x907E
+    ("",       X,      1,      "GL_PATH_CLIENT_LENGTH_NV"),    # 0x907F
+    ("",       X,      1,      "GL_PATH_FILL_MODE_NV"),        # 0x9080
+    ("",       X,      1,      "GL_PATH_FILL_MASK_NV"),        # 0x9081
+    ("",       X,      1,      "GL_PATH_FILL_COVER_MODE_NV"),  # 0x9082
+    ("",       X,      1,      "GL_PATH_STROKE_COVER_MODE_NV"),        # 0x9083
+    ("",       X,      1,      "GL_PATH_STROKE_MASK_NV"),      # 0x9084
+    ("",       X,      1,      "GL_PATH_SAMPLE_QUALITY_NV"),   # 0x9085
+    ("",       X,      1,      "GL_PATH_STROKE_BOUND_NV"),     # 0x9086
+    ("",       X,      1,      "GL_PATH_STROKE_OVERSAMPLE_COUNT_NV"),  # 0x9087
+    ("",       X,      1,      "GL_COUNT_UP_NV"),      # 0x9088
+    ("",       X,      1,      "GL_COUNT_DOWN_NV"),    # 0x9089
+    ("",       X,      1,      "GL_PATH_OBJECT_BOUNDING_BOX_NV"),      # 0x908A
+    ("",       X,      1,      "GL_CONVEX_HULL_NV"),   # 0x908B
+    ("",       X,      1,      "GL_MULTI_HULLS_NV"),   # 0x908C
+    ("",       X,      1,      "GL_BOUNDING_BOX_NV"),  # 0x908D
+    ("",       X,      1,      "GL_TRANSLATE_X_NV"),   # 0x908E
+    ("",       X,      1,      "GL_TRANSLATE_Y_NV"),   # 0x908F
+    ("",       X,      1,      "GL_TRANSLATE_2D_NV"),  # 0x9090
+    ("",       X,      1,      "GL_TRANSLATE_3D_NV"),  # 0x9091
+    ("",       X,      1,      "GL_AFFINE_2D_NV"),     # 0x9092
+    ("",       X,      1,      "GL_PROJECTIVE_2D_NV"), # 0x9093
+    ("",       X,      1,      "GL_AFFINE_3D_NV"),     # 0x9094
+    ("",       X,      1,      "GL_PROJECTIVE_3D_NV"), # 0x9095
+    ("",       X,      1,      "GL_TRANSPOSE_AFFINE_2D_NV"),   # 0x9096
+    ("",       X,      1,      "GL_TRANSPOSE_PROJECTIVE_2D_NV"),       # 0x9097
+    ("",       X,      1,      "GL_TRANSPOSE_AFFINE_3D_NV"),   # 0x9098
+    ("",       X,      1,      "GL_TRANSPOSE_PROJECTIVE_3D_NV"),       # 0x9099
+    ("",       X,      1,      "GL_UTF8_NV"),  # 0x909A
+    ("",       X,      1,      "GL_UTF16_NV"), # 0x909B
+    ("",       X,      1,      "GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV"),        # 0x909C
+    ("",       X,      1,      "GL_PATH_COMMAND_COUNT_NV"),    # 0x909D
+    ("",       X,      1,      "GL_PATH_COORD_COUNT_NV"),      # 0x909E
+    ("",       X,      1,      "GL_PATH_DASH_ARRAY_COUNT_NV"), # 0x909F
+    ("",       X,      1,      "GL_PATH_COMPUTED_LENGTH_NV"),  # 0x90A0
+    ("",       X,      1,      "GL_PATH_FILL_BOUNDING_BOX_NV"),        # 0x90A1
+    ("",       X,      1,      "GL_PATH_STROKE_BOUNDING_BOX_NV"),      # 0x90A2
+    ("",       X,      1,      "GL_SQUARE_NV"),        # 0x90A3
+    ("",       X,      1,      "GL_ROUND_NV"), # 0x90A4
+    ("",       X,      1,      "GL_TRIANGULAR_NV"),    # 0x90A5
+    ("",       X,      1,      "GL_BEVEL_NV"), # 0x90A6
+    ("",       X,      1,      "GL_MITER_REVERT_NV"),  # 0x90A7
+    ("",       X,      1,      "GL_MITER_TRUNCATE_NV"),        # 0x90A8
+    ("",       X,      1,      "GL_SKIP_MISSING_GLYPH_NV"),    # 0x90A9
+    ("",       X,      1,      "GL_USE_MISSING_GLYPH_NV"),     # 0x90AA
+    ("",       X,      1,      "GL_PATH_ERROR_POSITION_NV"),   # 0x90AB
+    ("",       X,      1,      "GL_PATH_FOG_GEN_MODE_NV"),     # 0x90AC
+    ("",       X,      1,      "GL_ACCUM_ADJACENT_PAIRS_NV"),  # 0x90AD
+    ("",       X,      1,      "GL_ADJACENT_PAIRS_NV"),        # 0x90AE
+    ("",       X,      1,      "GL_FIRST_TO_REST_NV"), # 0x90AF
+    ("",       X,      1,      "GL_PATH_GEN_MODE_NV"), # 0x90B0
+    ("",       X,      1,      "GL_PATH_GEN_COEFF_NV"),        # 0x90B1
+    ("",       X,      1,      "GL_PATH_GEN_COLOR_FORMAT_NV"), # 0x90B2
+    ("",       X,      1,      "GL_PATH_GEN_COMPONENTS_NV"),   # 0x90B3
+    ("",       X,      1,      "GL_PATH_DASH_OFFSET_RESET_NV"),        # 0x90B4
+    ("",       X,      1,      "GL_MOVE_TO_RESETS_NV"),        # 0x90B5
+    ("",       X,      1,      "GL_MOVE_TO_CONTINUES_NV"),     # 0x90B6
+    ("",       X,      1,      "GL_PATH_STENCIL_FUNC_NV"),     # 0x90B7
+    ("",       X,      1,      "GL_PATH_STENCIL_REF_NV"),      # 0x90B8
+    ("",       X,      1,      "GL_PATH_STENCIL_VALUE_MASK_NV"),       # 0x90B9
     ("",       X,      1,      "GL_SCALED_RESOLVE_FASTEST_EXT"),       # 0x90BA
     ("",       X,      1,      "GL_SCALED_RESOLVE_NICEST_EXT"),        # 0x90BB
     ("",       X,      1,      "GL_MIN_MAP_BUFFER_ALIGNMENT"), # 0x90BC
+    ("",       X,      1,      "GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV"),      # 0x90BD
+    ("",       X,      1,      "GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV"),       # 0x90BE
+    ("",       X,      1,      "GL_PATH_COVER_DEPTH_FUNC_NV"), # 0x90BF
     ("",       X,      1,      "GL_IMAGE_FORMAT_COMPATIBILITY_TYPE"),  # 0x90C7
     ("",       X,      1,      "GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE"),       # 0x90C8
     ("",       X,      1,      "GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS"),      # 0x90C9
@@ -2875,24 +3089,44 @@ parameters = [
     ("",       X,      1,      "GL_MAX_GEOMETRY_IMAGE_UNIFORMS"),      # 0x90CD
     ("",       X,      1,      "GL_MAX_FRAGMENT_IMAGE_UNIFORMS"),      # 0x90CE
     ("",       X,      1,      "GL_MAX_COMBINED_IMAGE_UNIFORMS"),      # 0x90CF
+    ("",       I,      1,      "GL_SHADER_STORAGE_BUFFER"),    # 0x90D2
+    ("",       I,      1,      "GL_SHADER_STORAGE_BUFFER_BINDING"),    # 0x90D3
+    ("",       I,      1,      "GL_SHADER_STORAGE_BUFFER_START"),      # 0x90D4
+    ("",       I,      1,      "GL_SHADER_STORAGE_BUFFER_SIZE"),       # 0x90D5
+    ("",       I,      1,      "GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS"), # 0x90D6
+    ("",       I,      1,      "GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS"),       # 0x90D7
+    ("",       I,      1,      "GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS"),   # 0x90D8
+    ("",       I,      1,      "GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS"),        # 0x90D9
+    ("",       I,      1,      "GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS"),       # 0x90DA
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS"),        # 0x90DB
+    ("",       I,      1,      "GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS"),       # 0x90DC
+    ("",       I,      1,      "GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS"),       # 0x90DD
+    ("",       I,      1,      "GL_MAX_SHADER_STORAGE_BLOCK_SIZE"),    # 0x90DE
+    ("",       X,      1,      "GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT"),   # 0x90DF
     ("",       X,      1,      "GL_SYNC_X11_FENCE_EXT"),       # 0x90E1
+    ("glGetTexParameter",      E,      1,      "GL_DEPTH_STENCIL_TEXTURE_MODE"),       # 0x90EA
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_LOCAL_INVOCATIONS"),    # 0x90EB
+    ("",       X,      1,      "GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER"),       # 0x90EC
+    ("",       X,      1,      "GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER"),       # 0x90ED
+    ("",       X,      1,      "GL_DISPATCH_INDIRECT_BUFFER"), # 0x90EE
+    ("glGet",  I,      1,      "GL_DISPATCH_INDIRECT_BUFFER_BINDING"), # 0x90EF
     ("",       X,      1,      "GL_TEXTURE_2D_MULTISAMPLE"),   # 0x9100
     ("",       X,      1,      "GL_PROXY_TEXTURE_2D_MULTISAMPLE"),     # 0x9101
     ("",       X,      1,      "GL_TEXTURE_2D_MULTISAMPLE_ARRAY"),     # 0x9102
     ("",       X,      1,      "GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY"),       # 0x9103
-    ("",       X,      1,      "GL_TEXTURE_BINDING_2D_MULTISAMPLE"),   # 0x9104
-    ("",       X,      1,      "GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY"),     # 0x9105
-    ("",       X,      1,      "GL_TEXTURE_SAMPLES"),  # 0x9106
-    ("",       X,      1,      "GL_TEXTURE_FIXED_SAMPLE_LOCATIONS"),   # 0x9107
+    ("_glGet", B,      1,      "GL_TEXTURE_BINDING_2D_MULTISAMPLE"),   # 0x9104
+    ("_glGet", I,      1,      "GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY"),     # 0x9105
+    ("glGetTexLevelParameter", I,      1,      "GL_TEXTURE_SAMPLES"),  # 0x9106
+    ("glGetTexLevelParameter", B,      1,      "GL_TEXTURE_FIXED_SAMPLE_LOCATIONS"),   # 0x9107
     ("",       X,      1,      "GL_SAMPLER_2D_MULTISAMPLE"),   # 0x9108
     ("",       X,      1,      "GL_INT_SAMPLER_2D_MULTISAMPLE"),       # 0x9109
     ("",       X,      1,      "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE"),      # 0x910A
     ("",       X,      1,      "GL_SAMPLER_2D_MULTISAMPLE_ARRAY"),     # 0x910B
     ("",       X,      1,      "GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"), # 0x910C
     ("",       X,      1,      "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY"),        # 0x910D
-    ("",       X,      1,      "GL_MAX_COLOR_TEXTURE_SAMPLES"),        # 0x910E
-    ("",       X,      1,      "GL_MAX_DEPTH_TEXTURE_SAMPLES"),        # 0x910F
-    ("",       X,      1,      "GL_MAX_INTEGER_SAMPLES"),      # 0x9110
+    ("glGet",  I,      1,      "GL_MAX_COLOR_TEXTURE_SAMPLES"),        # 0x910E
+    ("glGet",  I,      1,      "GL_MAX_DEPTH_TEXTURE_SAMPLES"),        # 0x910F
+    ("glGet",  I,      1,      "GL_MAX_INTEGER_SAMPLES"),      # 0x9110
     ("_glGet", I64,    1,      "GL_MAX_SERVER_WAIT_TIMEOUT"),  # 0x9111
     ("",       X,      1,      "GL_OBJECT_TYPE"),      # 0x9112
     ("",       X,      1,      "GL_SYNC_CONDITION"),   # 0x9113
@@ -2928,12 +3162,12 @@ parameters = [
     #("",      X,      1,      "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG"),   # 0x9134
     #("",      X,      1,      "GL_MAX_SAMPLES_IMG"),  # 0x9135
     #("",      X,      1,      "GL_TEXTURE_SAMPLES_IMG"),      # 0x9136
-    ("",       X,      1,      "GL_MAX_DEBUG_MESSAGE_LENGTH_ARB"),     # 0x9143
-    ("",       X,      1,      "GL_MAX_DEBUG_LOGGED_MESSAGES_ARB"),    # 0x9144
-    ("",       X,      1,      "GL_DEBUG_LOGGED_MESSAGES_ARB"),        # 0x9145
-    ("",       X,      1,      "GL_DEBUG_SEVERITY_HIGH_ARB"),  # 0x9146
-    ("",       X,      1,      "GL_DEBUG_SEVERITY_MEDIUM_ARB"),        # 0x9147
-    ("",       X,      1,      "GL_DEBUG_SEVERITY_LOW_ARB"),   # 0x9148
+    ("glGet",  I,      1,      "GL_MAX_DEBUG_MESSAGE_LENGTH"), # 0x9143
+    ("glGet",  I,      1,      "GL_MAX_DEBUG_LOGGED_MESSAGES"),        # 0x9144
+    ("glGet",  I,      1,      "GL_DEBUG_LOGGED_MESSAGES"),    # 0x9145
+    ("",       X,      1,      "GL_DEBUG_SEVERITY_HIGH"),      # 0x9146
+    ("",       X,      1,      "GL_DEBUG_SEVERITY_MEDIUM"),    # 0x9147
+    ("",       X,      1,      "GL_DEBUG_SEVERITY_LOW"),       # 0x9148
     ("",       X,      1,      "GL_DEBUG_CATEGORY_API_ERROR_AMD"),     # 0x9149
     ("",       X,      1,      "GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD"), # 0x914A
     ("",       X,      1,      "GL_DEBUG_CATEGORY_DEPRECATION_AMD"),   # 0x914B
@@ -2942,12 +3176,36 @@ parameters = [
     ("",       X,      1,      "GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD"),       # 0x914E
     ("",       X,      1,      "GL_DEBUG_CATEGORY_APPLICATION_AMD"),   # 0x914F
     ("",       X,      1,      "GL_DEBUG_CATEGORY_OTHER_AMD"), # 0x9150
-    ("",       X,      1,      "GL_DATA_BUFFER_AMD"),  # 0x9151
+    ("",       X,      1,      "GL_BUFFER_OBJECT_EXT"),        # 0x9151
     ("",       X,      1,      "GL_PERFORMANCE_MONITOR_AMD"),  # 0x9152
-    ("",       X,      1,      "GL_QUERY_OBJECT_AMD"), # 0x9153
-    ("",       X,      1,      "GL_VERTEX_ARRAY_OBJECT_AMD"),  # 0x9154
+    ("",       X,      1,      "GL_QUERY_OBJECT_EXT"), # 0x9153
+    ("",       X,      1,      "GL_VERTEX_ARRAY_OBJECT_EXT"),  # 0x9154
     ("",       X,      1,      "GL_SAMPLER_OBJECT_AMD"),       # 0x9155
-    #("",      X,      1,      "GL_SHADER_BINARY_DMP"),        # 0x9250
+    ("",       X,      1,      "GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD"),       # 0x9160
+    ("",       X,      1,      "GL_QUERY_BUFFER_AMD"), # 0x9192
+    ("",       X,      1,      "GL_QUERY_BUFFER_BINDING_AMD"), # 0x9193
+    ("",       X,      1,      "GL_QUERY_RESULT_NO_WAIT_AMD"), # 0x9194
+    ("glGetTexLevelParameter", I,      1,      "GL_TEXTURE_BUFFER_OFFSET"),    # 0x919D
+    ("glGetTexLevelParameter", I,      1,      "GL_TEXTURE_BUFFER_SIZE"),      # 0x919E
+    ("glGet",  I,      1,      "GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT"),  # 0x919F
+    ("",       X,      1,      "GL_COMPUTE_SHADER"),   # 0x91B9
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_UNIFORM_BLOCKS"),       # 0x91BB
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS"),  # 0x91BC
+    ("glGet",  I,      1,      "GL_MAX_COMPUTE_IMAGE_UNIFORMS"),       # 0x91BD
+    ("glGet",  I,      3,      "GL_MAX_COMPUTE_WORK_GROUP_COUNT"),     # 0x91BE
+    ("glGet",  I,      3,      "GL_MAX_COMPUTE_WORK_GROUP_SIZE"),      # 0x91BF
+    ("",       X,      1,      "GL_SHADER_BINARY_DMP"),        # 0x9250
+    #("",      X,      1,      "GL_GCCSO_SHADER_BINARY_FJ"),   # 0x9260
+    ("",       X,      1,      "GL_COMPRESSED_R11_EAC"),       # 0x9270
+    ("",       X,      1,      "GL_COMPRESSED_SIGNED_R11_EAC"),        # 0x9271
+    ("",       X,      1,      "GL_COMPRESSED_RG11_EAC"),      # 0x9272
+    ("",       X,      1,      "GL_COMPRESSED_SIGNED_RG11_EAC"),       # 0x9273
+    ("",       X,      1,      "GL_COMPRESSED_RGB8_ETC2"),     # 0x9274
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ETC2"),    # 0x9275
+    ("",       X,      1,      "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"), # 0x9276
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"),        # 0x9277
+    ("",       X,      1,      "GL_COMPRESSED_RGBA8_ETC2_EAC"),        # 0x9278
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"), # 0x9279
     ("",       X,      1,      "GL_ATOMIC_COUNTER_BUFFER"),    # 0x92C0
     ("",       X,      1,      "GL_ATOMIC_COUNTER_BUFFER_BINDING"),    # 0x92C1
     ("",       X,      1,      "GL_ATOMIC_COUNTER_BUFFER_START"),      # 0x92C2
@@ -2977,7 +3235,105 @@ parameters = [
     ("",       X,      1,      "GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX"),      # 0x92DA
     ("",       X,      1,      "GL_UNSIGNED_INT_ATOMIC_COUNTER"),      # 0x92DB
     ("",       X,      1,      "GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS"),       # 0x92DC
+    ("glGet",  B,      1,      "GL_DEBUG_OUTPUT"),     # 0x92E0
+    ("",       X,      1,      "GL_UNIFORM"),  # 0x92E1
+    ("",       X,      1,      "GL_UNIFORM_BLOCK"),    # 0x92E2
+    ("",       X,      1,      "GL_PROGRAM_INPUT"),    # 0x92E3
+    ("",       X,      1,      "GL_PROGRAM_OUTPUT"),   # 0x92E4
+    ("",       X,      1,      "GL_BUFFER_VARIABLE"),  # 0x92E5
+    ("",       X,      1,      "GL_SHADER_STORAGE_BLOCK"),     # 0x92E6
+    ("",       X,      1,      "GL_IS_PER_PATCH"),     # 0x92E7
+    ("",       X,      1,      "GL_VERTEX_SUBROUTINE"),        # 0x92E8
+    ("",       X,      1,      "GL_TESS_CONTROL_SUBROUTINE"),  # 0x92E9
+    ("",       X,      1,      "GL_TESS_EVALUATION_SUBROUTINE"),       # 0x92EA
+    ("",       X,      1,      "GL_GEOMETRY_SUBROUTINE"),      # 0x92EB
+    ("",       X,      1,      "GL_FRAGMENT_SUBROUTINE"),      # 0x92EC
+    ("",       X,      1,      "GL_COMPUTE_SUBROUTINE"),       # 0x92ED
+    ("",       X,      1,      "GL_VERTEX_SUBROUTINE_UNIFORM"),        # 0x92EE
+    ("",       X,      1,      "GL_TESS_CONTROL_SUBROUTINE_UNIFORM"),  # 0x92EF
+    ("",       X,      1,      "GL_TESS_EVALUATION_SUBROUTINE_UNIFORM"),       # 0x92F0
+    ("",       X,      1,      "GL_GEOMETRY_SUBROUTINE_UNIFORM"),      # 0x92F1
+    ("",       X,      1,      "GL_FRAGMENT_SUBROUTINE_UNIFORM"),      # 0x92F2
+    ("",       X,      1,      "GL_COMPUTE_SUBROUTINE_UNIFORM"),       # 0x92F3
+    ("",       X,      1,      "GL_TRANSFORM_FEEDBACK_VARYING"),       # 0x92F4
+    ("",       X,      1,      "GL_ACTIVE_RESOURCES"), # 0x92F5
+    ("",       X,      1,      "GL_MAX_NAME_LENGTH"),  # 0x92F6
+    ("",       X,      1,      "GL_MAX_NUM_ACTIVE_VARIABLES"), # 0x92F7
+    ("",       X,      1,      "GL_MAX_NUM_COMPATIBLE_SUBROUTINES"),   # 0x92F8
+    ("",       X,      1,      "GL_NAME_LENGTH"),      # 0x92F9
+    ("",       X,      1,      "GL_TYPE"),     # 0x92FA
+    ("",       X,      1,      "GL_ARRAY_SIZE"),       # 0x92FB
+    ("",       X,      1,      "GL_OFFSET"),   # 0x92FC
+    ("",       X,      1,      "GL_BLOCK_INDEX"),      # 0x92FD
+    ("",       X,      1,      "GL_ARRAY_STRIDE"),     # 0x92FE
+    ("",       X,      1,      "GL_MATRIX_STRIDE"),    # 0x92FF
+    ("",       X,      1,      "GL_IS_ROW_MAJOR"),     # 0x9300
+    ("",       X,      1,      "GL_ATOMIC_COUNTER_BUFFER_INDEX"),      # 0x9301
+    ("",       X,      1,      "GL_BUFFER_BINDING"),   # 0x9302
+    ("",       X,      1,      "GL_BUFFER_DATA_SIZE"), # 0x9303
+    ("",       X,      1,      "GL_NUM_ACTIVE_VARIABLES"),     # 0x9304
+    ("",       X,      1,      "GL_ACTIVE_VARIABLES"), # 0x9305
+    ("",       X,      1,      "GL_REFERENCED_BY_VERTEX_SHADER"),      # 0x9306
+    ("",       X,      1,      "GL_REFERENCED_BY_TESS_CONTROL_SHADER"),        # 0x9307
+    ("",       X,      1,      "GL_REFERENCED_BY_TESS_EVALUATION_SHADER"),     # 0x9308
+    ("",       X,      1,      "GL_REFERENCED_BY_GEOMETRY_SHADER"),    # 0x9309
+    ("",       X,      1,      "GL_REFERENCED_BY_FRAGMENT_SHADER"),    # 0x930A
+    ("",       X,      1,      "GL_REFERENCED_BY_COMPUTE_SHADER"),     # 0x930B
+    ("",       X,      1,      "GL_TOP_LEVEL_ARRAY_SIZE"),     # 0x930C
+    ("",       X,      1,      "GL_TOP_LEVEL_ARRAY_STRIDE"),   # 0x930D
+    ("",       X,      1,      "GL_LOCATION"), # 0x930E
+    ("",       X,      1,      "GL_LOCATION_INDEX"),   # 0x930F
+    ("",       I,      1,      "GL_FRAMEBUFFER_DEFAULT_WIDTH"),        # 0x9310
+    ("",       I,      1,      "GL_FRAMEBUFFER_DEFAULT_HEIGHT"),       # 0x9311
+    ("",       I,      1,      "GL_FRAMEBUFFER_DEFAULT_LAYERS"),       # 0x9312
+    ("",       I,      1,      "GL_FRAMEBUFFER_DEFAULT_SAMPLES"),      # 0x9313
+    ("",       B,      1,      "GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS"),       # 0x9314
+    ("glGet",  I,      1,      "GL_MAX_FRAMEBUFFER_WIDTH"),    # 0x9315
+    ("glGet",  I,      1,      "GL_MAX_FRAMEBUFFER_HEIGHT"),   # 0x9316
+    ("glGet",  I,      1,      "GL_MAX_FRAMEBUFFER_LAYERS"),   # 0x9317
+    ("glGet",  I,      1,      "GL_MAX_FRAMEBUFFER_SAMPLES"),  # 0x9318
     ("",       X,      1,      "GL_NUM_SAMPLE_COUNTS"),        # 0x9380
+    ("",       X,      1,      "GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE"),    # 0x93A0
+    ("",       X,      1,      "GL_TEXTURE_USAGE_ANGLE"),      # 0x93A2
+    ("",       X,      1,      "GL_FRAMEBUFFER_ATTACHMENT_ANGLE"),     # 0x93A3
+    ("",       X,      1,      "GL_PACK_REVERSE_ROW_ORDER_ANGLE"),     # 0x93A4
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_4x4_KHR"),     # 0x93B0
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_5x4_KHR"),     # 0x93B1
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_5x5_KHR"),     # 0x93B2
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_6x5_KHR"),     # 0x93B3
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_6x6_KHR"),     # 0x93B4
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_8x5_KHR"),     # 0x93B5
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_8x6_KHR"),     # 0x93B6
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_8x8_KHR"),     # 0x93B7
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_10x5_KHR"),    # 0x93B8
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_10x6_KHR"),    # 0x93B9
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_10x8_KHR"),    # 0x93BA
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_10x10_KHR"),   # 0x93BB
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_12x10_KHR"),   # 0x93BC
+    ("",       X,      1,      "GL_COMPRESSED_RGBA_ASTC_12x12_KHR"),   # 0x93BD
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"),     # 0x93D0
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"),     # 0x93D1
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"),     # 0x93D2
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"),     # 0x93D3
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"),     # 0x93D4
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"),     # 0x93D5
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"),     # 0x93D6
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"),     # 0x93D7
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"),    # 0x93D8
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"),    # 0x93D9
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"),    # 0x93DA
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"),   # 0x93DB
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"),   # 0x93DC
+    ("",       X,      1,      "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"),   # 0x93DD
+    #("",      X,      1,      "GL_RESTART_PATH_NV"),  # 0xF0
+    #("",      X,      1,      "GL_DUP_FIRST_CUBIC_CURVE_TO_NV"),      # 0xF2
+    #("",      X,      1,      "GL_DUP_LAST_CUBIC_CURVE_TO_NV"),       # 0xF4
+    #("",      X,      1,      "GL_RECT_NV"),  # 0xF6
+    #("",      X,      1,      "GL_CIRCULAR_CCW_ARC_TO_NV"),   # 0xF8
+    #("",      X,      1,      "GL_CIRCULAR_CW_ARC_TO_NV"),    # 0xFA
+    #("",      X,      1,      "GL_CIRCULAR_TANGENT_ARC_TO_NV"),       # 0xFC
+    #("",      X,      1,      "GL_ARC_TO_NV"),        # 0xFE
+    #("",      X,      1,      "GL_TIMEOUT_IGNORED"),  # 0xFFFFFFFFFFFFFFFFull
     ("",       X,      1,      "GL_INVALID_INDEX"),    # 0xFFFFFFFFu
 ]
 
index 5ea201a06584228c8af0dde5d55790ced3d62ebf..45231b244cf29304bbf4592413af93b3f6e91be0 100644 (file)
@@ -32,7 +32,11 @@ import platform
 from stdapi import *
 
 
-GLboolean = Alias("GLboolean", Bool)
+GLboolean = Enum("GLboolean", [
+    "GL_TRUE",
+    "GL_FALSE",
+])
+
 GLvoid = Alias("GLvoid", Void)
 GLbyte = Alias("GLbyte", SChar)
 GLshort = Alias("GLshort", Short)
@@ -49,11 +53,9 @@ GLfloat = Alias("GLfloat", Float)
 GLclampf = Alias("GLclampf", Float)
 GLdouble = Alias("GLdouble", Double)
 GLclampd = Alias("GLclampd", Double)
-GLchar = Alias("GLchar", SChar)
-GLstring = String("GLchar *")
+GLchar = Alias("GLchar", Char)
 
 GLcharARB = Alias("GLcharARB", SChar)
-GLstringARB = String("GLcharARB *")
 GLintptrARB = Alias("GLintptrARB", Int)
 GLsizeiptrARB = Alias("GLsizeiptrARB", Int)
 GLhandleARB = Handle("handleARB", Alias("GLhandleARB", UInt))
@@ -61,9 +63,15 @@ GLhalfARB = Alias("GLhalfARB", UShort)
 GLhalfNV = Alias("GLhalfNV", UShort)
 GLint64EXT = Alias("GLint64EXT", Int64)
 GLuint64EXT = Alias("GLuint64EXT", UInt64)
+GLDEBUGPROC = Opaque("GLDEBUGPROC")
 GLDEBUGPROCARB = Opaque("GLDEBUGPROCARB")
 GLDEBUGPROCAMD = Opaque("GLDEBUGPROCAMD")
 
+GLstring = String(GLchar)
+GLstringConst = String(Const(GLchar))
+GLstringARB = String(GLcharARB)
+GLstringConstARB = String(Const(GLcharARB))
+
 GLpointer = OpaquePointer(GLvoid)
 GLpointerConst = OpaquePointer(Const(GLvoid))
 
@@ -108,19 +116,15 @@ GLfeedback = Handle("feedback", GLuint)
 # reconstructed from other state.
 GLmap = LinearPointer(GLvoid, "length")
 
-GLsync_ = IntPointer("GLsync")
-GLsync = Handle("sync", GLsync_)
+GLsync = Handle("sync", IntPointer("GLsync"))
 
 GLenum = Enum("GLenum", [
     # Parameters are added later from glparams.py's parameter table
 ])
 
 # Some functions take GLenum disguised as GLint, and need special treatment so
-# that symbolic names are traced correctly.  Apple noticed and fixed it in the
-# gl.h header, which further complicates things.  C++ typechecking rules force
-# the wrappers to match the prototype precisely, so the precise type is defined
-# in glimports.hpp
-GLenum_int = Alias("GLenum_int", GLenum)
+# that symbolic names are traced correctly.
+GLenum_int = Alias("GLint", GLenum)
 
 GLenum_mode = FakeEnum(GLenum, [
     "GL_POINTS",                         # 0x0000
@@ -192,6 +196,7 @@ GLbitfield_shader = Flags(GLbitfield, [
     "GL_GEOMETRY_SHADER_BIT",                    # 0x00000004
     "GL_TESS_CONTROL_SHADER_BIT",                # 0x00000008
     "GL_TESS_EVALUATION_SHADER_BIT",             # 0x00000010
+    "GL_COMPUTE_SHADER_BIT",                     # 0x00000020
 ])
 
 GLbitfield_access = Flags(GLbitfield, [
index e57b82a7f1d6c42ec2e4cd54e4e8b256290abf4a..85699ead83c0b1a74904c2f8b240800f40149d38 100644 (file)
@@ -248,7 +248,7 @@ PROC = Opaque("__GLXextFuncPtr")
 
 glxapi.addFunctions([
     # GLX
-    Function(Pointer(XVisualInfo), "glXChooseVisual", [(Display, "dpy"), (Int, "screen"), (Array(GLXAttrib, "__AttribList_size(attribList)"), "attribList")]),
+    Function(Pointer(XVisualInfo), "glXChooseVisual", [(Display, "dpy"), (Int, "screen"), (Array(GLXAttrib, "_AttribList_size(attribList)"), "attribList")]),
     Function(GLXContext, "glXCreateContext", [(Display, "dpy"), (Pointer(XVisualInfo), "vis"), (GLXContext, "shareList"), (Bool, "direct")]),
     Function(Void, "glXDestroyContext",  [(Display, "dpy"), (GLXContext, "ctx")]),
     Function(Bool, "glXMakeCurrent", [(Display, "dpy"), (GLXDrawable, "drawable"), (GLXContext, "ctx")]),
@@ -270,28 +270,28 @@ glxapi.addFunctions([
     Function(Void, "glXUseXFont", [(Font, "font"), (Int, "first"), (Int, "count"), (Int, "list")]),
 
     # GLX 1.1 and later
-    Function((Const(String("char *"))), "glXQueryExtensionsString", [(Display, "dpy"), (Int, "screen")]),
-    Function((Const(String("char *"))), "glXQueryServerString",  [(Display, "dpy"), (Int, "screen"), (GLXname, "name")]),
-    Function((Const(String("char *"))), "glXGetClientString", [(Display, "dpy"), (GLXname, "name")]),
+    Function((ConstCString), "glXQueryExtensionsString", [(Display, "dpy"), (Int, "screen")]),
+    Function((ConstCString), "glXQueryServerString",  [(Display, "dpy"), (Int, "screen"), (GLXname, "name")]),
+    Function((ConstCString), "glXGetClientString", [(Display, "dpy"), (GLXname, "name")]),
 
     # GLX 1.2 and later
     Function(Display, "glXGetCurrentDisplay", [], sideeffects=False),
 
     # GLX 1.3 and later
-    Function(Array(GLXFBConfig, "*nitems"), "glXChooseFBConfig", [(Display, "dpy"), (Int, "screen"), (Array(Const(GLXAttrib), "__AttribPairList_size(attribList)"), "attribList"), Out(Pointer(Int), "nitems")]),
+    Function(Array(GLXFBConfig, "*nitems"), "glXChooseFBConfig", [(Display, "dpy"), (Int, "screen"), (Array(Const(GLXAttrib), "_AttribPairList_size(attribList)"), "attribList"), Out(Pointer(Int), "nitems")]),
     Function(Int, "glXGetFBConfigAttrib", [(Display, "dpy"), (GLXFBConfig, "config"), (GLXAttrib, "attribute"), Out(Pointer(Int), "value")]),
     Function(Array(GLXFBConfig, "*nelements"), "glXGetFBConfigs", [(Display, "dpy"), (Int, "screen"), 
                                                                    Out(Pointer(Int), "nelements")]),
     Function(Pointer(XVisualInfo), "glXGetVisualFromFBConfig", [(Display, "dpy"),
                                                                 (GLXFBConfig, "config")]),
     Function(GLXWindow, "glXCreateWindow", [(Display, "dpy"), (GLXFBConfig, "config"),
-                                            (Window, "win"), (Array(Const(Int), "__AttribPairList_size(attribList)"), "attribList")]),
+                                            (Window, "win"), (Array(Const(Int), "_AttribPairList_size(attribList)"), "attribList")]),
     Function(Void, "glXDestroyWindow", [(Display, "dpy"), (GLXWindow, "window")]),
     Function(GLXPixmap, "glXCreatePixmap", [(Display, "dpy"), (GLXFBConfig, "config"),
-                                            (Pixmap, "pixmap"), (Array(Const(Int), "__AttribPairList_size(attribList)"), "attribList")]),
+                                            (Pixmap, "pixmap"), (Array(Const(Int), "_AttribPairList_size(attribList)"), "attribList")]),
     Function(Void, "glXDestroyPixmap", [(Display, "dpy"), (GLXPixmap, "pixmap")]),
     Function(GLXPbuffer, "glXCreatePbuffer", [(Display, "dpy"), (GLXFBConfig, "config"),
-                                              (Array(Const(GLXEnum), "__AttribPairList_size(attribList)"), "attribList")]),
+                                              (Array(Const(GLXEnum), "_AttribPairList_size(attribList)"), "attribList")]),
     Function(Void, "glXDestroyPbuffer", [(Display, "dpy"), (GLXPbuffer, "pbuf")]),
     Function(Void, "glXQueryDrawable", [(Display, "dpy"), (GLXDrawable, "draw"), (GLXEnum, "attribute"),
                                         Out(Pointer(UInt), "value")]),
@@ -309,7 +309,7 @@ glxapi.addFunctions([
                                            Out(Pointer(ULong), "mask")]),
 
     # GLX_ARB_create_context
-    Function(GLXContext, "glXCreateContextAttribsARB", [(Display, "dpy"), (GLXFBConfig, "config"), (GLXContext, "share_context"), (Bool, "direct"), (Array(Const(GLXAttrib), "__AttribPairList_size(attrib_list)"), "attrib_list")]),
+    Function(GLXContext, "glXCreateContextAttribsARB", [(Display, "dpy"), (GLXFBConfig, "config"), (GLXContext, "share_context"), (Bool, "direct"), (Array(Const(GLXAttrib), "_AttribPairList_size(attrib_list)"), "attrib_list")]),
 
     # GLX_SGI_swap_control
     Function(Int, "glXSwapIntervalSGI", [(Int, "interval")]),
@@ -335,14 +335,14 @@ glxapi.addFunctions([
 
     # GLX_SGIX_fbconfig
     Function(Int, "glXGetFBConfigAttribSGIX", [(Display, "dpy"), (GLXFBConfigSGIX, "config"), (Int, "attribute"), Out(Pointer(Int), "value")]),
-    Function(OpaquePointer(GLXFBConfigSGIX), "glXChooseFBConfigSGIX", [(Display, "dpy"), (Int, "screen"), (Array(Int, "__AttribPairList_size(attrib_list)"), "attrib_list"), Out(Pointer(Int), "nelements")]),
+    Function(OpaquePointer(GLXFBConfigSGIX), "glXChooseFBConfigSGIX", [(Display, "dpy"), (Int, "screen"), (Array(Int, "_AttribPairList_size(attrib_list)"), "attrib_list"), Out(Pointer(Int), "nelements")]),
     Function(GLXPixmap, "glXCreateGLXPixmapWithConfigSGIX", [(Display, "dpy"), (GLXFBConfigSGIX, "config"), (Pixmap, "pixmap")]),
     Function(GLXContext, "glXCreateContextWithConfigSGIX", [(Display, "dpy"), (GLXFBConfigSGIX, "config"), (Int, "render_type"), (GLXContext, "share_list"), (Bool, "direct")]),
     Function(Pointer(XVisualInfo), "glXGetVisualFromFBConfigSGIX", [(Display, "dpy"), (GLXFBConfigSGIX, "config")]),
     Function(GLXFBConfigSGIX, "glXGetFBConfigFromVisualSGIX", [(Display, "dpy"), Out(Pointer(XVisualInfo), "vis")]),
 
     # GLX_SGIX_pbuffer
-    Function(GLXPbufferSGIX, "glXCreateGLXPbufferSGIX", [(Display, "dpy"), (GLXFBConfigSGIX, "config"), (UInt, "width"), (UInt, "height"), (Array(Int, "__AttribPairList_size(attrib_list)"), "attrib_list")]),
+    Function(GLXPbufferSGIX, "glXCreateGLXPbufferSGIX", [(Display, "dpy"), (GLXFBConfigSGIX, "config"), (UInt, "width"), (UInt, "height"), (Array(Int, "_AttribPairList_size(attrib_list)"), "attrib_list")]),
     Function(Void, "glXDestroyGLXPbufferSGIX", [(Display, "dpy"), (GLXPbufferSGIX, "pbuf")]),
     Function(Int, "glXQueryGLXPbufferSGIX", [(Display, "dpy"), (GLXPbufferSGIX, "pbuf"), (Int, "attribute"), Out(Pointer(UInt), "value")]),
     Function(Void, "glXSelectEventSGIX", [(Display, "dpy"), (GLXDrawable, "drawable"), (ULong, "mask")]),
@@ -408,12 +408,12 @@ glxapi.addFunctions([
     Function(UInt, "glXGetAGPOffsetMESA", [(OpaquePointer(Const(Void)), "pointer")]),
     
     # EXT_texture_from_pixmap
-    Function(Void, "glXBindTexImageEXT", [(Display, "display"), (GLXDrawable, "drawable"), (Int, "buffer"), (Array(Const(Int), "__AttribPairList_size(attrib_list)"), "attrib_list")]),
+    Function(Void, "glXBindTexImageEXT", [(Display, "display"), (GLXDrawable, "drawable"), (Int, "buffer"), (Array(Const(Int), "_AttribPairList_size(attrib_list)"), "attrib_list")]),
     Function(Void, "glXReleaseTexImageEXT", [(Display, "display"), (GLXDrawable, "drawable"), (Int, "buffer")]),
 
     # GLX_NV_present_video
     #Function(OpaquePointer(UInt), "glXEnumerateVideoDevicesNV", [(Display, "dpy"), (Int, "screen"), (OpaquePointer(Int), "nelements")]),
-    #Function(Int, "glXBindVideoDeviceNV", [(Display, "dpy"), (UInt, "video_slot"), (UInt, "video_device"), (Array(Const(Int), "__AttribPairList_size(attrib_list)"), "attrib_list")]),
+    #Function(Int, "glXBindVideoDeviceNV", [(Display, "dpy"), (UInt, "video_slot"), (UInt, "video_device"), (Array(Const(Int), "_AttribPairList_size(attrib_list)"), "attrib_list")]),
 
     # GLX_NV_video_output
     #Function(Int, "glXGetVideoDeviceNV", [(Display, "dpy"), (Int, "screen"), (Int, "numVideoDevices"), (OpaquePointer(GLXVideoDeviceNV), "pVideoDevice")]),
@@ -439,7 +439,7 @@ glxapi.addFunctions([
     #Function(Void, "glXReleaseVideoCaptureDeviceNV", [(Display, "dpy"), (GLXVideoCaptureDeviceNV, "device")]),
 
     # GLX_EXT_swap_control
-    Function(Int, "glXSwapIntervalEXT", [(Display, "dpy"), (GLXDrawable, "drawable"), (Int, "interval")]),
+    Function(Void, "glXSwapIntervalEXT", [(Display, "dpy"), (GLXDrawable, "drawable"), (Int, "interval")]),
 
     # GLX_NV_copy_image
     Function(Void, "glXCopyImageSubDataNV", [(Display, "dpy"), (GLXContext, "srcCtx"), (GLuint, "srcName"), (GLenum, "srcTarget"), (GLint, "srcLevel"), (GLint, "srcX"), (GLint, "srcY"), (GLint, "srcZ"), (GLXContext, "dstCtx"), (GLuint, "dstName"), (GLenum, "dstTarget"), (GLint, "dstLevel"), (GLint, "dstX"), (GLint, "dstY"), (GLint, "dstZ"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth")]),
@@ -449,8 +449,10 @@ glxapi.addFunctions([
     Function(Void, "glXFreeMemoryNV", [(OpaquePointer(Void), "pointer")]),
 
     # Must be last
-    Function(PROC, "glXGetProcAddressARB", [(Alias("const GLubyte *", CString), "procName")]),
-    Function(PROC, "glXGetProcAddress", [(Alias("const GLubyte *", CString), "procName")]),
+    Function(PROC, "glXGetProcAddressARB", [(String(Const(GLubyte)), "procName")]),
+    Function(PROC, "glXGetProcAddress", [(String(Const(GLubyte)), "procName")]),
 ])
 
 
+# To prevent collision with stdapi.Bool
+del Bool
diff --git a/specs/opengl32.def b/specs/opengl32.def
deleted file mode 100644 (file)
index 9e717a7..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-LIBRARY opengl32
-
-EXPORTS
-;      GlmfBeginGlsBlock
-;      GlmfCloseMetaFile
-;      GlmfEndGlsBlock
-;      GlmfEndPlayback
-;      GlmfInitPlayback
-;      GlmfPlayGlsRecord
-       glAccum
-       glAlphaFunc
-       glAreTexturesResident
-       glArrayElement
-       glBegin
-       glBindTexture
-       glBitmap
-       glBlendFunc
-       glCallList
-       glCallLists
-       glClear
-       glClearAccum
-       glClearColor
-       glClearDepth
-       glClearIndex
-       glClearStencil
-       glClipPlane
-       glColor3b
-       glColor3bv
-       glColor3d
-       glColor3dv
-       glColor3f
-       glColor3fv
-       glColor3i
-       glColor3iv
-       glColor3s
-       glColor3sv
-       glColor3ub
-       glColor3ubv
-       glColor3ui
-       glColor3uiv
-       glColor3us
-       glColor3usv
-       glColor4b
-       glColor4bv
-       glColor4d
-       glColor4dv
-       glColor4f
-       glColor4fv
-       glColor4i
-       glColor4iv
-       glColor4s
-       glColor4sv
-       glColor4ub
-       glColor4ubv
-       glColor4ui
-       glColor4uiv
-       glColor4us
-       glColor4usv
-       glColorMask
-       glColorMaterial
-       glColorPointer
-       glCopyPixels
-       glCopyTexImage1D
-       glCopyTexImage2D
-       glCopyTexSubImage1D
-       glCopyTexSubImage2D
-       glCullFace
-;      glDebugEntry
-       glDeleteLists
-       glDeleteTextures
-       glDepthFunc
-       glDepthMask
-       glDepthRange
-       glDisable
-       glDisableClientState
-       glDrawArrays
-       glDrawBuffer
-       glDrawElements
-       glDrawPixels
-       glEdgeFlag
-       glEdgeFlagPointer
-       glEdgeFlagv
-       glEnable
-       glEnableClientState
-       glEnd
-       glEndList
-       glEvalCoord1d
-       glEvalCoord1dv
-       glEvalCoord1f
-       glEvalCoord1fv
-       glEvalCoord2d
-       glEvalCoord2dv
-       glEvalCoord2f
-       glEvalCoord2fv
-       glEvalMesh1
-       glEvalMesh2
-       glEvalPoint1
-       glEvalPoint2
-       glFeedbackBuffer
-       glFinish
-       glFlush
-       glFogf
-       glFogfv
-       glFogi
-       glFogiv
-       glFrontFace
-       glFrustum
-       glGenLists
-       glGenTextures
-       glGetBooleanv
-       glGetClipPlane
-       glGetDoublev
-       glGetError
-       glGetFloatv
-       glGetIntegerv
-       glGetLightfv
-       glGetLightiv
-       glGetMapdv
-       glGetMapfv
-       glGetMapiv
-       glGetMaterialfv
-       glGetMaterialiv
-       glGetPixelMapfv
-       glGetPixelMapuiv
-       glGetPixelMapusv
-       glGetPointerv
-       glGetPolygonStipple
-       glGetString
-       glGetTexEnvfv
-       glGetTexEnviv
-       glGetTexGendv
-       glGetTexGenfv
-       glGetTexGeniv
-       glGetTexImage
-       glGetTexLevelParameterfv
-       glGetTexLevelParameteriv
-       glGetTexParameterfv
-       glGetTexParameteriv
-       glHint
-       glIndexMask
-       glIndexPointer
-       glIndexd
-       glIndexdv
-       glIndexf
-       glIndexfv
-       glIndexi
-       glIndexiv
-       glIndexs
-       glIndexsv
-       glIndexub
-       glIndexubv
-       glInitNames
-       glInterleavedArrays
-       glIsEnabled
-       glIsList
-       glIsTexture
-       glLightModelf
-       glLightModelfv
-       glLightModeli
-       glLightModeliv
-       glLightf
-       glLightfv
-       glLighti
-       glLightiv
-       glLineStipple
-       glLineWidth
-       glListBase
-       glLoadIdentity
-       glLoadMatrixd
-       glLoadMatrixf
-       glLoadName
-       glLogicOp
-       glMap1d
-       glMap1f
-       glMap2d
-       glMap2f
-       glMapGrid1d
-       glMapGrid1f
-       glMapGrid2d
-       glMapGrid2f
-       glMaterialf
-       glMaterialfv
-       glMateriali
-       glMaterialiv
-       glMatrixMode
-       glMultMatrixd
-       glMultMatrixf
-       glNewList
-       glNormal3b
-       glNormal3bv
-       glNormal3d
-       glNormal3dv
-       glNormal3f
-       glNormal3fv
-       glNormal3i
-       glNormal3iv
-       glNormal3s
-       glNormal3sv
-       glNormalPointer
-       glOrtho
-       glPassThrough
-       glPixelMapfv
-       glPixelMapuiv
-       glPixelMapusv
-       glPixelStoref
-       glPixelStorei
-       glPixelTransferf
-       glPixelTransferi
-       glPixelZoom
-       glPointSize
-       glPolygonMode
-       glPolygonOffset
-       glPolygonStipple
-       glPopAttrib
-       glPopClientAttrib
-       glPopMatrix
-       glPopName
-       glPrioritizeTextures
-       glPushAttrib
-       glPushClientAttrib
-       glPushMatrix
-       glPushName
-       glRasterPos2d
-       glRasterPos2dv
-       glRasterPos2f
-       glRasterPos2fv
-       glRasterPos2i
-       glRasterPos2iv
-       glRasterPos2s
-       glRasterPos2sv
-       glRasterPos3d
-       glRasterPos3dv
-       glRasterPos3f
-       glRasterPos3fv
-       glRasterPos3i
-       glRasterPos3iv
-       glRasterPos3s
-       glRasterPos3sv
-       glRasterPos4d
-       glRasterPos4dv
-       glRasterPos4f
-       glRasterPos4fv
-       glRasterPos4i
-       glRasterPos4iv
-       glRasterPos4s
-       glRasterPos4sv
-       glReadBuffer
-       glReadPixels
-       glRectd
-       glRectdv
-       glRectf
-       glRectfv
-       glRecti
-       glRectiv
-       glRects
-       glRectsv
-       glRenderMode
-       glRotated
-       glRotatef
-       glScaled
-       glScalef
-       glScissor
-       glSelectBuffer
-       glShadeModel
-       glStencilFunc
-       glStencilMask
-       glStencilOp
-       glTexCoord1d
-       glTexCoord1dv
-       glTexCoord1f
-       glTexCoord1fv
-       glTexCoord1i
-       glTexCoord1iv
-       glTexCoord1s
-       glTexCoord1sv
-       glTexCoord2d
-       glTexCoord2dv
-       glTexCoord2f
-       glTexCoord2fv
-       glTexCoord2i
-       glTexCoord2iv
-       glTexCoord2s
-       glTexCoord2sv
-       glTexCoord3d
-       glTexCoord3dv
-       glTexCoord3f
-       glTexCoord3fv
-       glTexCoord3i
-       glTexCoord3iv
-       glTexCoord3s
-       glTexCoord3sv
-       glTexCoord4d
-       glTexCoord4dv
-       glTexCoord4f
-       glTexCoord4fv
-       glTexCoord4i
-       glTexCoord4iv
-       glTexCoord4s
-       glTexCoord4sv
-       glTexCoordPointer
-       glTexEnvf
-       glTexEnvfv
-       glTexEnvi
-       glTexEnviv
-       glTexGend
-       glTexGendv
-       glTexGenf
-       glTexGenfv
-       glTexGeni
-       glTexGeniv
-       glTexImage1D
-       glTexImage2D
-       glTexParameterf
-       glTexParameterfv
-       glTexParameteri
-       glTexParameteriv
-       glTexSubImage1D
-       glTexSubImage2D
-       glTranslated
-       glTranslatef
-       glVertex2d
-       glVertex2dv
-       glVertex2f
-       glVertex2fv
-       glVertex2i
-       glVertex2iv
-       glVertex2s
-       glVertex2sv
-       glVertex3d
-       glVertex3dv
-       glVertex3f
-       glVertex3fv
-       glVertex3i
-       glVertex3iv
-       glVertex3s
-       glVertex3sv
-       glVertex4d
-       glVertex4dv
-       glVertex4f
-       glVertex4fv
-       glVertex4i
-       glVertex4iv
-       glVertex4s
-       glVertex4sv
-       glVertexPointer
-       glViewport
-       wglChoosePixelFormat
-       wglCopyContext
-       wglCreateContext
-       wglCreateLayerContext
-       wglDeleteContext
-       wglDescribeLayerPlane
-       wglDescribePixelFormat
-       wglGetCurrentContext
-       wglGetCurrentDC
-       wglGetDefaultProcAddress
-       wglGetLayerPaletteEntries
-       wglGetPixelFormat
-       wglGetProcAddress
-       wglMakeCurrent
-       wglRealizeLayerPalette
-       wglSetLayerPaletteEntries
-       wglSetPixelFormat
-       wglShareLists
-       wglSwapBuffers
-       wglSwapLayerBuffers
-       wglSwapMultipleBuffers
-       wglUseFontBitmapsA
-       wglUseFontBitmapsW
-       wglUseFontOutlinesA
-       wglUseFontOutlinesW
index 940ce4424a6c948390be1f8647c704a923dba461..88488440cc603a9a679648d3232e27a446644ee2 100755 (executable)
@@ -36,7 +36,7 @@ import optparse
 
 class DeclParser:
 
-    token_re = re.compile(r'(\d[x0-9a-fA-F.UL]*|\w+|\s+|.)')
+    token_re = re.compile(r'(\d[x0-9a-fA-F.UL]*|\w+|\s+|"[^"]*"|.)')
 
     multi_comment_re = re.compile(r'/\*.*?\*/', flags = re.DOTALL)
     single_comment_re = re.compile(r'//.*',)
@@ -97,8 +97,8 @@ class DeclParser:
             self.parse_define()
         elif self.match('enum'):
             self.parse_enum()
-        elif self.match('interface'):
-            self.parse_interface()
+        elif self.match('class', 'interface'):
+            self.parse_interface(self.lookahead())
         elif self.match('mask'):
             self.parse_value('mask', 'Flags')
         elif self.match('struct'):
@@ -182,11 +182,25 @@ class DeclParser:
     def parse_struct(self):
         self.consume('struct')
         name = self.consume()
-        self.consume('{')
 
         print '%s = Struct("%s", [' % (name, name)
+        for type, name in self.parse_members():
+            print '    (%s, "%s"),' % (type, name)
+        print '])'
+        print
 
-        value = 0
+    def parse_union(self):
+        self.consume('union')
+        if not self.match('{'):
+            name = self.consume()
+        else:
+            name = None
+        members = self.parse_members()
+        return 'Union("%s", [%s])' % (name, ', '.join('%s, "%s"' % member for member in members))
+
+    def parse_members(self):
+        members = []
+        self.consume('{')
         while self.lookahead() != '}':
             type, name = self.parse_named_type()
 
@@ -197,15 +211,12 @@ class DeclParser:
             if self.match(','):
                 self.consume(',')
             self.consume(';')
-            print '    (%s, "%s"),' % (type, name) 
-            value += 1
+            members.append((type, name))
         self.consume('}')
+        return members
 
-        print '])'
-        print
-
-    def parse_interface(self):
-        self.consume('interface')
+    def parse_interface(self, ref_token):
+        self.consume(ref_token)
         name = self.consume()
         if self.match(';'):
             return
@@ -219,22 +230,26 @@ class DeclParser:
         print '%s.methods += [' % (name,)
 
         while self.lookahead() != '}':
-            self.parse_prototype('Method')
-            self.consume(';')
+            if self.lookahead() in ('public', 'private'):
+                self.consume()
+                self.consume(':')
+            else:
+                self.parse_prototype('Method')
+                self.consume(';')
         self.consume('}')
 
         print ']'
         print
 
     def parse_prototype(self, creator = 'Function'):
-        if self.match('extern'):
+        if self.match('extern', 'virtual'):
             self.consume()
 
         ret = self.parse_type()
 
         if self.match('__stdcall', 'WINAPI'):
             self.consume()
-            creator = 'StdFunction'
+            creator = 'Std' + creator
 
         name = self.consume()
         extra = ''
@@ -252,9 +267,13 @@ class DeclParser:
             if self.match(','):
                 self.consume()
         self.consume(')')
-        if self.lookahead() == 'const':
+        if self.match('const', 'CONST'):
             self.consume()
             extra = ', const=True' + extra
+
+        if self.lookahead() == '=':
+            self.consume()
+            self.consume('0')
         
         print '    %s(%s, "%s", [%s]%s),' % (creator, ret, name, ', '.join(args), extra)
 
@@ -264,7 +283,7 @@ class DeclParser:
         type, name = self.parse_named_type()
 
         arg = '(%s, "%s")' % (type, name)
-        if 'out' in tags:
+        if 'out' in tags or 'inout' in tags:
             arg = 'Out' + arg
 
         if self.match('='):
@@ -282,20 +301,58 @@ class DeclParser:
                 tag = self.consume()
                 tags.append(tag)
             self.consume(']')
+            if tags[0] == 'annotation':
+                assert tags[1] == '('
+                assert tags[3] == ')'
+                tags = tags[2]
+                assert tags[0] == '"'
+                assert tags[-1] == '"'
+                tags = tags[1:-1]
+                tags = parse_sal_annotation(tags)
+        token = self.lookahead()
+        if token[0] == '_' and (token[1] == '_' or token[-1] == '_'):
+            # Parse __in, __out, etc tags
+            tag = self.consume()
+            if self.match('('):
+                tag += self.consume()
+                while not self.match(')'):
+                    tag += self.consume()
+                tag += self.consume(')')
+            tags.extend(self.parse_sal_annotation(tag))
+        return tags
+
+    def parse_sal_annotation(self, tags):
+        try:
+            tags, args = tags.split('(')
+        except ValueError:
+            pass
+        assert tags[0] == '_'
+        if tags[1] == '_':
+            tags = tags[2:]
+        if tags[-1] == '_':
+            tags = tags[1:-1]
+        tags = tags.lower()
+        tags = tags.split('_')
         return tags
 
     def parse_named_type(self):
         type = self.parse_type()
-        name = self.consume()
-        if self.match('['):
-            self.consume()
-            length = self.consume()
-            self.consume(']')
-            try:
-                int(length)
-            except ValueError:
-                length = "%s" % length
-            type = 'Array(%s, %s)' % (type, length)
+        
+        if self.match(',', ';', '}', ')'):
+            name = None
+        else:
+            name = self.consume()
+            if self.match('['):
+                self.consume()
+                length = ''
+                while not self.match(']'):
+                    length += self.consume()
+                self.consume(']')
+                try:
+                    int(length)
+                except ValueError:
+                    length = '"%s"' % length
+                type = 'Array(%s, %s)' % (type, length)
         return type, name
 
     int_tokens = ('unsigned', 'signed', 'int', 'long', 'short', 'char')
@@ -315,19 +372,22 @@ class DeclParser:
 
     def parse_type(self):
         const = False
-        token = self.consume()
-        if token == 'const':
-            token = self.consume()
+        if self.match('const', 'CONST'):
+            self.consume()
             const = True
-        if token == 'void':
+        if self.match('void'):
+            self.consume()
             type = 'Void'
-        elif token in self.int_tokens:
+        elif self.match('union'):
+            type = self.parse_union()
+        elif self.match(*self.int_tokens):
             unsigned = False
             signed = False
             long = 0
             short = 0
             char = False
-            while token in self.int_tokens:
+            while self.match(*self.int_tokens):
+                token = self.consume()
                 if token == 'unsigned':
                     unsigned = True
                 if token == 'signed':
@@ -338,10 +398,6 @@ class DeclParser:
                     short += 1
                 if token == 'char':
                     char = False
-                if self.lookahead() in self.int_tokens:
-                    token = self.consume()
-                else:
-                    token = None
             if char:
                 type = 'Char'
                 if signed:
@@ -355,15 +411,16 @@ class DeclParser:
             if unsigned:
                 type = 'U' + type
         else:
+            token = self.consume()
             type = self.type_table.get(token, token)
         if const:
             type = 'Const(%s)' % type
         while True:
             if self.match('*'):
                 self.consume('*')
-                type = 'OpaquePointer(%s)' % type
-            elif self.match('const'):
-                self.consume('const')
+                type = 'Pointer(%s)' % type
+            elif self.match('const', 'CONST'):
+                self.consume()
                 type = 'Const(%s)' % type
             else:
                 break
index ab5957a7d19d4dba78d849cfd366743503cf295d..f21b08d5bf82f6670ecea07a44a77d537cfc4f24 100755 (executable)
@@ -235,12 +235,16 @@ class SpecParser(LineParser):
                     try:
                         int(length)
                     except ValueError:
-                        length = "%s" % length
+                        length = '"%s"' % length
                     arg_type = '%s(%s, %s)' % (constructor, base_type, length)
                 else:
-                    length = length.replace("COMPSIZE", "__%s_size" % function_name)
-                    length = length.replace("/", ", ")
-                    arg_type = 'Opaque%s(%s, %s)' % (constructor, base_type, length)
+                    if length == "COMPSIZE(pname)":
+                        length = "_gl_param_size(pname)"
+                        arg_type = '%s(%s, "%s")' % (constructor, base_type, length)
+                    else:
+                        length = length.replace("COMPSIZE", "_%s_size" % function_name)
+                        length = length.replace("/", ", ")
+                        arg_type = 'Opaque%s(%s, "%s")' % (constructor, base_type, length)
         else:
             assert False
         
index 6aa4089f6d0984880f475bf57a87d75fc0d2cd5e..cde94cb6fa522a583f0deb31edce660901d6c9cb 100644 (file)
@@ -41,7 +41,10 @@ class Type:
         # on this type, so it should preferrably be something representative of
         # the type.
         if tag is None:
-            tag = ''.join([c for c in expr if c.isalnum() or c in '_'])
+            if expr is not None:
+                tag = ''.join([c for c in expr if c.isalnum() or c in '_'])
+            else:
+                tag = 'anonynoums'
         else:
             for c in tag:
                 assert c.isalnum() or c in '_'
@@ -65,6 +68,12 @@ class Type:
     def visit(self, visitor, *args, **kwargs):
         raise NotImplementedError
 
+    def mutable(self):
+        '''Return a mutable version of this type.
+
+        Convenience wrapper around MutableRebuilder.'''
+        visitor = MutableRebuilder()
+        return visitor.visit(self)
 
 
 class _Void(Type):
@@ -93,17 +102,41 @@ class Literal(Type):
         return visitor.visitLiteral(self, *args, **kwargs)
 
 
+Bool = Literal("bool", "Bool")
+SChar = Literal("signed char", "SInt")
+UChar = Literal("unsigned char", "UInt")
+Short = Literal("short", "SInt")
+Int = Literal("int", "SInt")
+Long = Literal("long", "SInt")
+LongLong = Literal("long long", "SInt")
+UShort = Literal("unsigned short", "UInt")
+UInt = Literal("unsigned int", "UInt")
+ULong = Literal("unsigned long", "UInt")
+ULongLong = Literal("unsigned long long", "UInt")
+Float = Literal("float", "Float")
+Double = Literal("double", "Double")
+SizeT = Literal("size_t", "UInt")
+
+Char = Literal("char", "SInt")
+WChar = Literal("wchar_t", "SInt")
+
+Int8 = Literal("int8_t", "SInt")
+UInt8 = Literal("uint8_t", "UInt")
+Int16 = Literal("int16_t", "SInt")
+UInt16 = Literal("uint16_t", "UInt")
+Int32 = Literal("int32_t", "SInt")
+UInt32 = Literal("uint32_t", "UInt")
+Int64 = Literal("int64_t", "SInt")
+UInt64 = Literal("uint64_t", "UInt")
+
+
 class Const(Type):
 
     def __init__(self, type):
         # While "const foo" and "foo const" are synonymous, "const foo *" and
         # "foo * const" are not quite the same, and some compilers do enforce
         # strict const correctness.
-        if isinstance(type, String) or type is WString:
-            # For strings we never intend to say a const pointer to chars, but
-            # rather a point to const chars.
-            expr = "const " + type.expr
-        elif type.expr.startswith("const ") or '*' in type.expr:
+        if type.expr.startswith("const ") or '*' in type.expr:
             expr = type.expr + " const"
         else:
             # The most legible
@@ -134,8 +167,19 @@ class IntPointer(Type):
         return visitor.visitIntPointer(self, *args, **kwargs)
 
 
+class ObjPointer(Type):
+    '''Pointer to an object.'''
+
+    def __init__(self, type):
+        Type.__init__(self, type.expr + " *", 'P' + type.tag)
+        self.type = type
+
+    def visit(self, visitor, *args, **kwargs):
+        return visitor.visitObjPointer(self, *args, **kwargs)
+
+
 class LinearPointer(Type):
-    '''Integer encoded as a pointer.'''
+    '''Pointer to a linear range of memory.'''
 
     def __init__(self, type, size = None):
         Type.__init__(self, type.expr + " *", 'P' + type.tag)
@@ -146,6 +190,17 @@ class LinearPointer(Type):
         return visitor.visitLinearPointer(self, *args, **kwargs)
 
 
+class Reference(Type):
+    '''C++ references.'''
+
+    def __init__(self, type):
+        Type.__init__(self, type.expr + " &", 'R' + type.tag)
+        self.type = type
+
+    def visit(self, visitor, *args, **kwargs):
+        return visitor.visitReference(self, *args, **kwargs)
+
+
 class Handle(Type):
 
     def __init__(self, name, type, range=None, key=None):
@@ -235,12 +290,35 @@ class Struct(Type):
         Struct.__id += 1
 
         self.name = name
-        self.members = members
+        self.members = []
+
+        # Eliminate anonymous unions
+        for type, name in members:
+            if name is not None:
+                self.members.append((type, name))
+            else:
+                assert isinstance(type, Union)
+                assert type.name is None
+                self.members.extend(type.members)
 
     def visit(self, visitor, *args, **kwargs):
         return visitor.visitStruct(self, *args, **kwargs)
 
 
+class Union(Type):
+
+    __id = 0
+
+    def __init__(self, name, members):
+        Type.__init__(self, name)
+
+        self.id = Union.__id
+        Union.__id += 1
+
+        self.name = name
+        self.members = members
+
+
 class Alias(Type):
 
     def __init__(self, expr, type):
@@ -250,17 +328,12 @@ class Alias(Type):
     def visit(self, visitor, *args, **kwargs):
         return visitor.visitAlias(self, *args, **kwargs)
 
-
-def Out(type, name):
-    arg = Arg(type, name, output=True)
-    return arg
-
-
 class Arg:
 
-    def __init__(self, type, name, output=False):
+    def __init__(self, type, name, input=True, output=False):
         self.type = type
         self.name = name
+        self.input = input
         self.output = output
         self.index = None
 
@@ -268,12 +341,22 @@ class Arg:
         return '%s %s' % (self.type, self.name)
 
 
+def In(type, name):
+    return Arg(type, name, input=True, output=False)
+
+def Out(type, name):
+    return Arg(type, name, input=False, output=True)
+
+def InOut(type, name):
+    return Arg(type, name, input=True, output=True)
+
+
 class Function:
 
     # 0-3 are reserved to memcpy, malloc, free, and realloc
     __id = 4
 
-    def __init__(self, type, name, args, call = '', fail = None, sideeffects=True):
+    def __init__(self, type, name, args, call = '', fail = None, sideeffects=True, internal=False):
         self.id = Function.__id
         Function.__id += 1
 
@@ -297,6 +380,7 @@ class Function:
         self.call = call
         self.fail = fail
         self.sideeffects = sideeffects
+        self.internal = internal
 
     def prototype(self, name=None):
         if name is not None:
@@ -342,6 +426,12 @@ class Interface(Type):
     def visit(self, visitor, *args, **kwargs):
         return visitor.visitInterface(self, *args, **kwargs)
 
+    def getMethodByName(self, name):
+        for method in self.iterMethods():
+            if method.name == name:
+                return method
+        return None
+
     def iterMethods(self):
         if self.base is not None:
             for method in self.base.iterMethods():
@@ -350,6 +440,13 @@ class Interface(Type):
             yield method
         raise StopIteration
 
+    def iterBases(self):
+        iface = self
+        while iface is not None:
+            yield iface
+            iface = iface.base
+        raise StopIteration
+
     def iterBaseMethods(self):
         if self.base is not None:
             for iface, method in self.base.iterBaseMethods():
@@ -361,8 +458,8 @@ class Interface(Type):
 
 class Method(Function):
 
-    def __init__(self, type, name, args, const=False):
-        Function.__init__(self, type, name, args, call = '__stdcall')
+    def __init__(self, type, name, args, call = '__stdcall', const=False, sideeffects=True):
+        Function.__init__(self, type, name, args, call = call, sideeffects=sideeffects)
         for index in range(len(self.args)):
             self.args[index].index = index + 1
         self.const = const
@@ -374,12 +471,20 @@ class Method(Function):
         return s
 
 
+def StdMethod(*args, **kwargs):
+    kwargs.setdefault('call', '__stdcall')
+    return Method(*args, **kwargs)
+
+
 class String(Type):
+    '''Human-legible character string.'''
 
-    def __init__(self, expr = "char *", length = None, kind = 'String'):
-        Type.__init__(self, expr)
+    def __init__(self, type = Char, length = None, wide = False):
+        assert isinstance(type, Type)
+        Type.__init__(self, type.expr + ' *')
+        self.type = type
         self.length = length
-        self.kind = kind
+        self.wide = wide
 
     def visit(self, visitor, *args, **kwargs):
         return visitor.visitString(self, *args, **kwargs)
@@ -407,11 +512,12 @@ def OpaqueBlob(type, size):
 
 class Polymorphic(Type):
 
-    def __init__(self, defaultType, switchExpr, switchTypes):
+    def __init__(self, switchExpr, switchTypes, defaultType, contextLess=True):
         Type.__init__(self, defaultType.expr)
-        self.defaultType = defaultType
         self.switchExpr = switchExpr
         self.switchTypes = switchTypes
+        self.defaultType = defaultType
+        self.contextLess = contextLess
 
     def visit(self, visitor, *args, **kwargs):
         return visitor.visitPolymorphic(self, *args, **kwargs)
@@ -433,6 +539,13 @@ class Polymorphic(Type):
         return zip(cases, types)
 
 
+def EnumPolymorphic(enumName, switchExpr, switchTypes, defaultType, contextLess=True):
+    enumValues = [expr for expr, type in switchTypes]
+    enum = Enum(enumName, enumValues)
+    polymorphic = Polymorphic(switchExpr, switchTypes, defaultType, contextLess)
+    return enum, polymorphic
+
+
 class Visitor:
     '''Abstract visitor for the type hierarchy.'''
 
@@ -472,9 +585,15 @@ class Visitor:
     def visitIntPointer(self, pointer, *args, **kwargs):
         raise NotImplementedError
 
+    def visitObjPointer(self, pointer, *args, **kwargs):
+        raise NotImplementedError
+
     def visitLinearPointer(self, pointer, *args, **kwargs):
         raise NotImplementedError
 
+    def visitReference(self, reference, *args, **kwargs):
+        raise NotImplementedError
+
     def visitHandle(self, handle, *args, **kwargs):
         raise NotImplementedError
 
@@ -518,10 +637,18 @@ class Rebuilder(Visitor):
         return literal
 
     def visitString(self, string):
-        return string
+        string_type = self.visit(string.type)
+        if string_type is string.type:
+            return string
+        else:
+            return String(string_type, string.length, string.wide)
 
     def visitConst(self, const):
-        return Const(const.type)
+        const_type = self.visit(const.type)
+        if const_type is const.type:
+            return const
+        else:
+            return Const(const_type)
 
     def visitStruct(self, struct):
         members = [(self.visit(type), name) for type, name in struct.members]
@@ -543,23 +670,49 @@ class Rebuilder(Visitor):
         return Bitmask(type, bitmask.values)
 
     def visitPointer(self, pointer):
-        type = self.visit(pointer.type)
-        return Pointer(type)
+        pointer_type = self.visit(pointer.type)
+        if pointer_type is pointer.type:
+            return pointer
+        else:
+            return Pointer(pointer_type)
 
     def visitIntPointer(self, pointer):
         return pointer
 
+    def visitObjPointer(self, pointer):
+        pointer_type = self.visit(pointer.type)
+        if pointer_type is pointer.type:
+            return pointer
+        else:
+            return ObjPointer(pointer_type)
+
     def visitLinearPointer(self, pointer):
-        type = self.visit(pointer.type)
-        return LinearPointer(type, pointer.size)
+        pointer_type = self.visit(pointer.type)
+        if pointer_type is pointer.type:
+            return pointer
+        else:
+            return LinearPointer(pointer_type)
+
+    def visitReference(self, reference):
+        reference_type = self.visit(reference.type)
+        if reference_type is reference.type:
+            return reference
+        else:
+            return Reference(reference_type)
 
     def visitHandle(self, handle):
-        type = self.visit(handle.type)
-        return Handle(handle.name, type, range=handle.range, key=handle.key)
+        handle_type = self.visit(handle.type)
+        if handle_type is handle.type:
+            return handle
+        else:
+            return Handle(handle.name, handle_type, range=handle.range, key=handle.key)
 
     def visitAlias(self, alias):
-        type = self.visit(alias.type)
-        return Alias(alias.expr, type)
+        alias_type = self.visit(alias.type)
+        if alias_type is alias.type:
+            return alias
+        else:
+            return Alias(alias.expr, alias_type)
 
     def visitOpaque(self, opaque):
         return opaque
@@ -568,84 +721,117 @@ class Rebuilder(Visitor):
         return interface
 
     def visitPolymorphic(self, polymorphic):
-        defaultType = self.visit(polymorphic.defaultType)
         switchExpr = polymorphic.switchExpr
         switchTypes = [(expr, self.visit(type)) for expr, type in polymorphic.switchTypes]
-        return Polymorphic(defaultType, switchExpr, switchTypes)
+        defaultType = self.visit(polymorphic.defaultType)
+        return Polymorphic(switchExpr, switchTypes, defaultType, polymorphic.contextLess)
 
 
-class Collector(Visitor):
-    '''Visitor which collects all unique types as it traverses them.'''
+class MutableRebuilder(Rebuilder):
+    '''Type visitor which derives a mutable type.'''
 
-    def __init__(self):
-        self.__visited = set()
-        self.types = []
+    def visitString(self, string):
+        return string
 
-    def visit(self, type):
-        if type in self.__visited:
-            return
-        self.__visited.add(type)
-        Visitor.visit(self, type)
-        self.types.append(type)
+    def visitConst(self, const):
+        # Strip out const qualifier
+        return const.type
+
+    def visitAlias(self, alias):
+        # Tear the alias on type changes
+        type = self.visit(alias.type)
+        if type is alias.type:
+            return alias
+        return type
+
+    def visitReference(self, reference):
+        # Strip out references
+        return reference.type
+
+
+class Traverser(Visitor):
+    '''Visitor which all types.'''
 
-    def visitVoid(self, literal):
+    def visitVoid(self, void, *args, **kwargs):
         pass
 
-    def visitLiteral(self, literal):
+    def visitLiteral(self, literal, *args, **kwargs):
         pass
 
-    def visitString(self, string):
+    def visitString(self, string, *args, **kwargs):
         pass
 
-    def visitConst(self, const):
-        self.visit(const.type)
+    def visitConst(self, const, *args, **kwargs):
+        self.visit(const.type, *args, **kwargs)
 
-    def visitStruct(self, struct):
+    def visitStruct(self, struct, *args, **kwargs):
         for type, name in struct.members:
-            self.visit(type)
+            self.visit(type, *args, **kwargs)
 
-    def visitArray(self, array):
-        self.visit(array.type)
+    def visitArray(self, array, *args, **kwargs):
+        self.visit(array.type, *args, **kwargs)
 
-    def visitBlob(self, array):
+    def visitBlob(self, array, *args, **kwargs):
         pass
 
-    def visitEnum(self, enum):
+    def visitEnum(self, enum, *args, **kwargs):
         pass
 
-    def visitBitmask(self, bitmask):
-        self.visit(bitmask.type)
+    def visitBitmask(self, bitmask, *args, **kwargs):
+        self.visit(bitmask.type, *args, **kwargs)
 
-    def visitPointer(self, pointer):
-        self.visit(pointer.type)
+    def visitPointer(self, pointer, *args, **kwargs):
+        self.visit(pointer.type, *args, **kwargs)
 
-    def visitIntPointer(self, pointer):
+    def visitIntPointer(self, pointer, *args, **kwargs):
         pass
 
-    def visitLinearPointer(self, pointer):
-        self.visit(pointer.type)
+    def visitObjPointer(self, pointer, *args, **kwargs):
+        self.visit(pointer.type, *args, **kwargs)
 
-    def visitHandle(self, handle):
-        self.visit(handle.type)
+    def visitLinearPointer(self, pointer, *args, **kwargs):
+        self.visit(pointer.type, *args, **kwargs)
 
-    def visitAlias(self, alias):
-        self.visit(alias.type)
+    def visitReference(self, reference, *args, **kwargs):
+        self.visit(reference.type, *args, **kwargs)
 
-    def visitOpaque(self, opaque):
+    def visitHandle(self, handle, *args, **kwargs):
+        self.visit(handle.type, *args, **kwargs)
+
+    def visitAlias(self, alias, *args, **kwargs):
+        self.visit(alias.type, *args, **kwargs)
+
+    def visitOpaque(self, opaque, *args, **kwargs):
         pass
 
-    def visitInterface(self, interface):
+    def visitInterface(self, interface, *args, **kwargs):
         if interface.base is not None:
-            self.visit(interface.base)
+            self.visit(interface.base, *args, **kwargs)
         for method in interface.iterMethods():
             for arg in method.args:
-                self.visit(arg.type)
-            self.visit(method.type)
+                self.visit(arg.type, *args, **kwargs)
+            self.visit(method.type, *args, **kwargs)
 
-    def visitPolymorphic(self, polymorphic):
-        self.visit(polymorphic.defaultType)
+    def visitPolymorphic(self, polymorphic, *args, **kwargs):
+        self.visit(polymorphic.defaultType, *args, **kwargs)
         for expr, type in polymorphic.switchTypes:
-            self.visit(type)
+            self.visit(type, *args, **kwargs)
+
+
+class Collector(Traverser):
+    '''Visitor which collects all unique types as it traverses them.'''
+
+    def __init__(self):
+        self.__visited = set()
+        self.types = []
+
+    def visit(self, type):
+        if type in self.__visited:
+            return
+        self.__visited.add(type)
+        Visitor.visit(self, type)
+        self.types.append(type)
+
 
 
 class API:
@@ -700,37 +886,15 @@ class API:
         self.addFunctions(api.functions)
         self.addInterfaces(api.interfaces)
 
-    def get_function_by_name(self, name):
+    def getFunctionByName(self, name):
         for function in self.functions:
             if function.name == name:
                 return function
         return None
 
 
-Bool = Literal("bool", "Bool")
-SChar = Literal("signed char", "SInt")
-UChar = Literal("unsigned char", "UInt")
-Short = Literal("short", "SInt")
-Int = Literal("int", "SInt")
-Long = Literal("long", "SInt")
-LongLong = Literal("long long", "SInt")
-UShort = Literal("unsigned short", "UInt")
-UInt = Literal("unsigned int", "UInt")
-ULong = Literal("unsigned long", "UInt")
-ULongLong = Literal("unsigned long long", "UInt")
-Float = Literal("float", "Float")
-Double = Literal("double", "Double")
-SizeT = Literal("size_t", "UInt")
-
 # C string (i.e., zero terminated)
-CString = String()
-WString = String("wchar_t *", kind="WString")
-
-Int8 = Literal("int8_t", "SInt")
-UInt8 = Literal("uint8_t", "UInt")
-Int16 = Literal("int16_t", "SInt")
-UInt16 = Literal("uint16_t", "UInt")
-Int32 = Literal("int32_t", "SInt")
-UInt32 = Literal("uint32_t", "UInt")
-Int64 = Literal("int64_t", "SInt")
-UInt64 = Literal("uint64_t", "UInt")
+CString = String(Char)
+WString = String(WChar, wide=True)
+ConstCString = String(Const(Char))
+ConstWString = String(Const(WChar), wide=True)
index 5e0ee9f1d969bef35efb93fde2db6499b3f0403b..e3d8b2366f593fd53f4f72cd6902280af92489b7 100644 (file)
@@ -175,19 +175,19 @@ wglapi.addFunctions([
     StdFunction(BOOL, "wglRestoreBufferRegionARB", [(HANDLE, "hRegion"), (Int, "x"), (Int, "y"), (Int, "width"), (Int, "height"), (Int, "xSrc"), (Int, "ySrc")]),
 
     # WGL_ARB_extensions_string
-    StdFunction(Const(CString), "wglGetExtensionsStringARB", [(HDC, "hdc")], sideeffects=False),
+    StdFunction(ConstCString, "wglGetExtensionsStringARB", [(HDC, "hdc")], sideeffects=False),
 
     # WGL_ARB_pixel_format
     StdFunction(BOOL, "wglGetPixelFormatAttribivARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
     StdFunction(BOOL, "wglGetPixelFormatAttribfvARB", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
-    StdFunction(BOOL, "wglChoosePixelFormatARB", [(HDC, "hdc"), (Array(Const(WGLenum), "__AttribPairList_size(piAttribIList)"), "piAttribIList"), (Array(Const(FLOAT), "__AttribPairList_size(pfAttribFList)"), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "(*nNumFormats)"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
+    StdFunction(BOOL, "wglChoosePixelFormatARB", [(HDC, "hdc"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribIList)"), "piAttribIList"), (Array(Const(FLOAT), "_AttribPairList_size(pfAttribFList)"), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "(*nNumFormats)"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
 
     # WGL_ARB_make_current_read
     StdFunction(BOOL, "wglMakeContextCurrentARB", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
     StdFunction(HDC, "wglGetCurrentReadDCARB", [], sideeffects=False),
 
     # WGL_ARB_pbuffer
-    StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Array(Const(WGLenum), "__AttribPairList_size(piAttribList)"), "piAttribList")]),
+    StdFunction(HPBUFFERARB, "wglCreatePbufferARB", [(HDC, "hDC"), (Int, "iPixelFormat"), (Int, "iWidth"), (Int, "iHeight"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribList)"), "piAttribList")]),
     StdFunction(HDC, "wglGetPbufferDCARB", [(HPBUFFERARB, "hPbuffer")]),
     StdFunction(Int, "wglReleasePbufferDCARB", [(HPBUFFERARB, "hPbuffer"), (HDC, "hDC")]),
     StdFunction(BOOL, "wglDestroyPbufferARB", [(HPBUFFERARB, "hPbuffer")]),
@@ -196,13 +196,13 @@ wglapi.addFunctions([
     # WGL_ARB_render_texture
     StdFunction(BOOL, "wglBindTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
     StdFunction(BOOL, "wglReleaseTexImageARB", [(HPBUFFERARB, "hPbuffer"), (Int, "iBuffer")]),
-    StdFunction(BOOL, "wglSetPbufferAttribARB", [(HPBUFFERARB, "hPbuffer"), (Array(Const(WGLenum), "__AttribPairList_size(piAttribList)"), "piAttribList")]),
+    StdFunction(BOOL, "wglSetPbufferAttribARB", [(HPBUFFERARB, "hPbuffer"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribList)"), "piAttribList")]),
 
     # WGL_ARB_create_context
-    StdFunction(HGLRC, "wglCreateContextAttribsARB", [(HDC, "hDC"), (HGLRC, "hShareContext"), (Array(Const(WGLenum), "__AttribPairList_size(attribList)"), "attribList")]),
+    StdFunction(HGLRC, "wglCreateContextAttribsARB", [(HDC, "hDC"), (HGLRC, "hShareContext"), (Array(Const(WGLenum), "_AttribPairList_size(attribList)"), "attribList")]),
 
     # WGL_EXT_extensions_string
-    StdFunction(Const(CString), "wglGetExtensionsStringEXT", [], sideeffects=False),
+    StdFunction(ConstCString, "wglGetExtensionsStringEXT", [], sideeffects=False),
 
     # WGL_EXT_make_current_read
     StdFunction(BOOL, "wglMakeContextCurrentEXT", [(HDC, "hDrawDC"), (HDC, "hReadDC"), (HGLRC, "hglrc")]),
@@ -211,7 +211,7 @@ wglapi.addFunctions([
     # WGL_EXT_pixel_format
     StdFunction(BOOL, "wglGetPixelFormatAttribivEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(Int, "nAttributes"), "piValues")], sideeffects=False),
     StdFunction(BOOL, "wglGetPixelFormatAttribfvEXT", [(HDC, "hdc"), (Int, "iPixelFormat"), (Int, "iLayerPlane"), (UINT, "nAttributes"), (Array(WGLenum, "nAttributes"), "piAttributes"), Out(Array(FLOAT, "nAttributes"), "pfValues")], sideeffects=False),
-    StdFunction(BOOL, "wglChoosePixelFormatEXT", [(HDC, "hdc"), (Array(Const(WGLenum), "__AttribPairList_size(piAttribIList)"), "piAttribIList"), (Array(Const(FLOAT), "__AttribPairList_size(pfAttribFList)"), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "*nNumFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
+    StdFunction(BOOL, "wglChoosePixelFormatEXT", [(HDC, "hdc"), (Array(Const(WGLenum), "_AttribPairList_size(piAttribIList)"), "piAttribIList"), (Array(Const(FLOAT), "_AttribPairList_size(pfAttribFList)"), "pfAttribFList"), (UINT, "nMaxFormats"), Out(Array(Int, "*nNumFormats"), "piFormats"), Out(Pointer(UINT), "nNumFormats")]),
 
     # WGL_EXT_swap_control
     StdFunction(BOOL, "wglSwapIntervalEXT", [(Int, "interval")]),
index 017cf5f0e527dab0094998a44326c6404e638f1e..23d6419f36bab0051f025a30f3b195d32233333c 100644 (file)
 
 """Win32 API type description."""
 
+
 from stdapi import *
 
+
 SHORT = Alias("SHORT", Short)
 USHORT = Alias("USHORT", UShort)
 INT = Alias("INT", Int)
@@ -49,9 +51,13 @@ BYTE = Alias("BYTE", UInt8)
 WORD = Alias("WORD", UInt16)
 DWORD = Alias("DWORD", UInt32)
 
+UCHAR = Alias("UCHAR", UChar)
 WCHAR = Alias("WCHAR", Short)
 
-BOOL = Alias("BOOL", Bool)
+BOOL = Enum("BOOL", [
+    "FALSE",
+    "TRUE",
+])
 
 LPLONG = Pointer(LONG)
 LPWORD = Pointer(WORD)
@@ -59,9 +65,9 @@ LPDWORD = Pointer(DWORD)
 LPBOOL = Pointer(BOOL)
 
 LPSTR = CString
-LPCSTR = Const(CString)
+LPCSTR = ConstCString
 LPWSTR = WString
-LPCWSTR = Const(WString)
+LPCWSTR = ConstWString
 
 LARGE_INTEGER = Struct("LARGE_INTEGER", [
     (LONGLONG, 'QuadPart'),
@@ -69,15 +75,18 @@ LARGE_INTEGER = Struct("LARGE_INTEGER", [
 
 SIZE_T = Alias("SIZE_T", SizeT)
 
-HRESULT = Alias("HRESULT", Int)
-
 VOID = Void
-PVOID = Opaque("PVOID")
+PVOID = OpaquePointer(VOID)
 LPVOID = PVOID
-HANDLE = Opaque("HANDLE")
-HWND = Opaque("HWND")
-HDC = Opaque("HDC")
-HMONITOR = Opaque("HMONITOR")
+LPCVOID = OpaquePointer(Const(VOID))
+
+def DECLARE_HANDLE(expr):
+    return Handle(expr, IntPointer(expr))
+
+HANDLE = DECLARE_HANDLE("HANDLE")
+HWND = DECLARE_HANDLE("HWND")
+HDC = DECLARE_HANDLE("HDC")
+HMONITOR = DECLARE_HANDLE("HMONITOR")
 
 GUID = Struct("GUID", [
     (DWORD, "Data1"),
@@ -87,16 +96,13 @@ GUID = Struct("GUID", [
 ])
 LPGUID = Pointer(GUID)
 
-#REFGUID = Alias("REFGUID", Pointer(GUID))
-REFGUID = Alias("REFGUID", GUID)
+REFGUID = Alias("REFGUID", Reference(GUID))
 
 IID = Alias("IID", GUID)
-#REFIID = Alias("REFIID", Pointer(IID))
-REFIID = Alias("REFIID", IID)
+REFIID = Alias("REFIID", Reference(IID))
 
 CLSID = Alias("CLSID", GUID)
-#REFCLSID = Alias("REFCLSID", Pointer(CLSID))
-REFCLSID = Alias("REFCLSID", CLSID)
+REFCLSID = Alias("REFCLSID", Reference(CLSID))
 
 LUID = Struct("LUID", [
     (DWORD, "LowPart"),
@@ -146,9 +152,7 @@ RGNDATA = Struct("RGNDATA", [
 ])
 LPRGNDATA = Pointer(RGNDATA)
 
-HMODULE = Opaque("HMODULE")
-
-IUnknown = Interface("IUnknown")
+HMODULE = DECLARE_HANDLE("HMODULE")
 
 FILETIME = Struct("FILETIME", [
     (DWORD, "dwLowDateTime"),
@@ -174,16 +178,36 @@ LOGFONTW = Struct("LOGFONTW", [
     (WString, "lfFaceName"),
 ])
 
-HRESULT_com = FakeEnum(HRESULT, [
-    "S_OK",
-    "E_NOINTERFACE",
-    "E_POINTER",
-])
+
+# http://msdn.microsoft.com/en-us/library/ff485842.aspx
+# http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381.aspx
+def MAKE_HRESULT(errors, ok = "S_OK", false = "S_FALSE"):
+    values = [ok, false]
+    values.extend(errors)
+    values.extend([
+        "E_PENDING", # 0x8000000A
+        "E_NOTIMPL", # 0x80004001
+        "E_NOINTERFACE", # 0x80004002
+        "E_POINTER", # 0x80004003
+        "E_ABORT", # 0x80004004
+        "E_FAIL", # 0x80004005
+        "E_UNEXPECTED", # 0x8000FFFF
+        "E_ACCESSDENIED", # 0x80070005
+        "E_HANDLE", # 0x80070006
+        "E_OUTOFMEMORY", # 0x8007000E
+        "E_INVALIDARG", # 0x80070057
+    ])
+    return Enum("HRESULT", values)
+
+HRESULT = MAKE_HRESULT([])
+
+
+IUnknown = Interface("IUnknown")
 
 IUnknown.methods = (
-       Method(HRESULT_com, "QueryInterface", ((REFIID, "riid"), Out(Pointer(OpaquePointer(Void)), "ppvObj"))),
-       Method(ULONG, "AddRef", ()),
-       Method(ULONG, "Release", ()),
+       StdMethod(HRESULT, "QueryInterface", ((REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppvObj"))),
+       StdMethod(ULONG, "AddRef", (), sideeffects=False),
+       StdMethod(ULONG, "Release", ()),
 )
 
 
diff --git a/thirdparty/glext/.gitignore b/thirdparty/glext/.gitignore
deleted file mode 100644 (file)
index 2460008..0000000
+++ /dev/null
@@ -1 +0,0 @@
-!Makefile
diff --git a/thirdparty/glext/GL/Makefile b/thirdparty/glext/GL/Makefile
deleted file mode 100644 (file)
index 5a80007..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-update: glext.h glxext.h wglext.h
-
-%.h: FORCE
-       wget -N "http://www.opengl.org/registry/api/$@"
-
-glext.h: glext.sed FORCE
-       wget -O - "http://www.opengl.org/registry/api/$@" | sed -f $*.sed > $@
-
-.PHONY: update
-
-FORCE:
diff --git a/thirdparty/glext/GL/glext.h b/thirdparty/glext/GL/glext.h
deleted file mode 100644 (file)
index c640bb8..0000000
+++ /dev/null
@@ -1,11490 +0,0 @@
-#ifndef __glext_h_
-#define __glext_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-** Copyright (c) 2007-2011 The Khronos Group Inc.
-** 
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-** 
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-** 
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
-/* Header file version number, required by OpenGL ABI for Linux */
-/* glext.h last updated $Date: 2011-10-02 22:22:16 -0700 (Sun, 02 Oct 2011) $ */
-/* Current version at http://www.opengl.org/registry/ */
-#define GL_GLEXT_VERSION 73
-/* Function declaration macros - to move into glplatform.h */
-
-#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
-#define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
-#endif
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-#ifndef APIENTRYP
-#define APIENTRYP APIENTRY *
-#endif
-#ifndef GLAPI
-#define GLAPI extern
-#endif
-
-/*************************************************************/
-
-#ifndef GL_VERSION_1_2
-#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_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_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_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_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_ALIASED_LINE_WIDTH_RANGE       0x846E
-#endif
-
-#ifndef GL_VERSION_1_2_DEPRECATED
-#define GL_RESCALE_NORMAL                 0x803A
-#define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8
-#define GL_SINGLE_COLOR                   0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR        0x81FA
-#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
-#endif
-
-#ifndef GL_ARB_imaging
-#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
-#endif
-
-#ifndef GL_ARB_imaging_DEPRECATED
-#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_CONSTANT_BORDER                0x8151
-#define GL_REPLICATE_BORDER               0x8153
-#define GL_CONVOLUTION_BORDER_COLOR       0x8154
-#endif
-
-#ifndef GL_VERSION_1_3
-#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_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_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_COMPRESSED_RGB                 0x84ED
-#define GL_COMPRESSED_RGBA                0x84EE
-#define GL_TEXTURE_COMPRESSION_HINT       0x84EF
-#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_CLAMP_TO_BORDER                0x812D
-#endif
-
-#ifndef GL_VERSION_1_3_DEPRECATED
-#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_MULTISAMPLE_BIT                0x20000000
-#define GL_NORMAL_MAP                     0x8511
-#define GL_REFLECTION_MAP                 0x8512
-#define GL_COMPRESSED_ALPHA               0x84E9
-#define GL_COMPRESSED_LUMINANCE           0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA     0x84EB
-#define GL_COMPRESSED_INTENSITY           0x84EC
-#define GL_COMBINE                        0x8570
-#define GL_COMBINE_RGB                    0x8571
-#define GL_COMBINE_ALPHA                  0x8572
-#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_RGB_SCALE                      0x8573
-#define GL_ADD_SIGNED                     0x8574
-#define GL_INTERPOLATE                    0x8575
-#define GL_SUBTRACT                       0x84E7
-#define GL_CONSTANT                       0x8576
-#define GL_PRIMARY_COLOR                  0x8577
-#define GL_PREVIOUS                       0x8578
-#define GL_DOT3_RGB                       0x86AE
-#define GL_DOT3_RGBA                      0x86AF
-#endif
-
-#ifndef GL_VERSION_1_4
-#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_FADE_THRESHOLD_SIZE      0x8128
-#define GL_DEPTH_COMPONENT16              0x81A5
-#define GL_DEPTH_COMPONENT24              0x81A6
-#define GL_DEPTH_COMPONENT32              0x81A7
-#define GL_MIRRORED_REPEAT                0x8370
-#define GL_MAX_TEXTURE_LOD_BIAS           0x84FD
-#define GL_TEXTURE_LOD_BIAS               0x8501
-#define GL_INCR_WRAP                      0x8507
-#define GL_DECR_WRAP                      0x8508
-#define GL_TEXTURE_DEPTH_SIZE             0x884A
-#define GL_TEXTURE_COMPARE_MODE           0x884C
-#define GL_TEXTURE_COMPARE_FUNC           0x884D
-#endif
-
-#ifndef GL_VERSION_1_4_DEPRECATED
-#define GL_POINT_SIZE_MIN                 0x8126
-#define GL_POINT_SIZE_MAX                 0x8127
-#define GL_POINT_DISTANCE_ATTENUATION     0x8129
-#define GL_GENERATE_MIPMAP                0x8191
-#define GL_GENERATE_MIPMAP_HINT           0x8192
-#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_TEXTURE_FILTER_CONTROL         0x8500
-#define GL_DEPTH_TEXTURE_MODE             0x884B
-#define GL_COMPARE_R_TO_TEXTURE           0x884E
-#endif
-
-#ifndef GL_VERSION_1_5
-#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_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
-#endif
-
-#ifndef GL_VERSION_1_5_DEPRECATED
-#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_FOG_COORD_SRC                  0x8450
-#define GL_FOG_COORD                      0x8451
-#define GL_CURRENT_FOG_COORD              0x8453
-#define GL_FOG_COORD_ARRAY_TYPE           0x8454
-#define GL_FOG_COORD_ARRAY_STRIDE         0x8455
-#define GL_FOG_COORD_ARRAY_POINTER        0x8456
-#define GL_FOG_COORD_ARRAY                0x8457
-#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
-#define GL_SRC0_RGB                       0x8580
-#define GL_SRC1_RGB                       0x8581
-#define GL_SRC2_RGB                       0x8582
-#define GL_SRC0_ALPHA                     0x8588
-#define GL_SRC1_ALPHA                     0x8589
-#define GL_SRC2_ALPHA                     0x858A
-#endif
-
-#ifndef GL_VERSION_2_0
-#define GL_BLEND_EQUATION_RGB             0x8009
-#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_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_MAX_VERTEX_ATTRIBS             0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#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
-#endif
-
-#ifndef GL_VERSION_2_0_DEPRECATED
-#define GL_VERTEX_PROGRAM_TWO_SIDE        0x8643
-#define GL_POINT_SPRITE                   0x8861
-#define GL_COORD_REPLACE                  0x8862
-#define GL_MAX_TEXTURE_COORDS             0x8871
-#endif
-
-#ifndef GL_VERSION_2_1
-#define GL_PIXEL_PACK_BUFFER              0x88EB
-#define GL_PIXEL_UNPACK_BUFFER            0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING      0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING    0x88EF
-#define GL_FLOAT_MAT2x3                   0x8B65
-#define GL_FLOAT_MAT2x4                   0x8B66
-#define GL_FLOAT_MAT3x2                   0x8B67
-#define GL_FLOAT_MAT3x4                   0x8B68
-#define GL_FLOAT_MAT4x2                   0x8B69
-#define GL_FLOAT_MAT4x3                   0x8B6A
-#define GL_SRGB                           0x8C40
-#define GL_SRGB8                          0x8C41
-#define GL_SRGB_ALPHA                     0x8C42
-#define GL_SRGB8_ALPHA8                   0x8C43
-#define GL_COMPRESSED_SRGB                0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA          0x8C49
-#endif
-
-#ifndef GL_VERSION_2_1_DEPRECATED
-#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
-#define GL_SLUMINANCE_ALPHA               0x8C44
-#define GL_SLUMINANCE8_ALPHA8             0x8C45
-#define GL_SLUMINANCE                     0x8C46
-#define GL_SLUMINANCE8                    0x8C47
-#define GL_COMPRESSED_SLUMINANCE          0x8C4A
-#define GL_COMPRESSED_SLUMINANCE_ALPHA    0x8C4B
-#endif
-
-#ifndef GL_VERSION_3_0
-#define GL_COMPARE_REF_TO_TEXTURE         0x884E
-#define GL_CLIP_DISTANCE0                 0x3000
-#define GL_CLIP_DISTANCE1                 0x3001
-#define GL_CLIP_DISTANCE2                 0x3002
-#define GL_CLIP_DISTANCE3                 0x3003
-#define GL_CLIP_DISTANCE4                 0x3004
-#define GL_CLIP_DISTANCE5                 0x3005
-#define GL_CLIP_DISTANCE6                 0x3006
-#define GL_CLIP_DISTANCE7                 0x3007
-#define GL_MAX_CLIP_DISTANCES             0x0D32
-#define GL_MAJOR_VERSION                  0x821B
-#define GL_MINOR_VERSION                  0x821C
-#define GL_NUM_EXTENSIONS                 0x821D
-#define GL_CONTEXT_FLAGS                  0x821E
-#define GL_COMPRESSED_RED                 0x8225
-#define GL_COMPRESSED_RG                  0x8226
-#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001
-#define GL_RGBA32F                        0x8814
-#define GL_RGB32F                         0x8815
-#define GL_RGBA16F                        0x881A
-#define GL_RGB16F                         0x881B
-#define GL_VERTEX_ATTRIB_ARRAY_INTEGER    0x88FD
-#define GL_MAX_ARRAY_TEXTURE_LAYERS       0x88FF
-#define GL_MIN_PROGRAM_TEXEL_OFFSET       0x8904
-#define GL_MAX_PROGRAM_TEXEL_OFFSET       0x8905
-#define GL_CLAMP_READ_COLOR               0x891C
-#define GL_FIXED_ONLY                     0x891D
-#define GL_MAX_VARYING_COMPONENTS         0x8B4B
-#define GL_TEXTURE_1D_ARRAY               0x8C18
-#define GL_PROXY_TEXTURE_1D_ARRAY         0x8C19
-#define GL_TEXTURE_2D_ARRAY               0x8C1A
-#define GL_PROXY_TEXTURE_2D_ARRAY         0x8C1B
-#define GL_TEXTURE_BINDING_1D_ARRAY       0x8C1C
-#define GL_TEXTURE_BINDING_2D_ARRAY       0x8C1D
-#define GL_R11F_G11F_B10F                 0x8C3A
-#define GL_UNSIGNED_INT_10F_11F_11F_REV   0x8C3B
-#define GL_RGB9_E5                        0x8C3D
-#define GL_UNSIGNED_INT_5_9_9_9_REV       0x8C3E
-#define GL_TEXTURE_SHARED_SIZE            0x8C3F
-#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
-#define GL_TRANSFORM_FEEDBACK_VARYINGS    0x8C83
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
-#define GL_PRIMITIVES_GENERATED           0x8C87
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
-#define GL_RASTERIZER_DISCARD             0x8C89
-#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
-#define GL_INTERLEAVED_ATTRIBS            0x8C8C
-#define GL_SEPARATE_ATTRIBS               0x8C8D
-#define GL_TRANSFORM_FEEDBACK_BUFFER      0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
-#define GL_RGBA32UI                       0x8D70
-#define GL_RGB32UI                        0x8D71
-#define GL_RGBA16UI                       0x8D76
-#define GL_RGB16UI                        0x8D77
-#define GL_RGBA8UI                        0x8D7C
-#define GL_RGB8UI                         0x8D7D
-#define GL_RGBA32I                        0x8D82
-#define GL_RGB32I                         0x8D83
-#define GL_RGBA16I                        0x8D88
-#define GL_RGB16I                         0x8D89
-#define GL_RGBA8I                         0x8D8E
-#define GL_RGB8I                          0x8D8F
-#define GL_RED_INTEGER                    0x8D94
-#define GL_GREEN_INTEGER                  0x8D95
-#define GL_BLUE_INTEGER                   0x8D96
-#define GL_RGB_INTEGER                    0x8D98
-#define GL_RGBA_INTEGER                   0x8D99
-#define GL_BGR_INTEGER                    0x8D9A
-#define GL_BGRA_INTEGER                   0x8D9B
-#define GL_SAMPLER_1D_ARRAY               0x8DC0
-#define GL_SAMPLER_2D_ARRAY               0x8DC1
-#define GL_SAMPLER_1D_ARRAY_SHADOW        0x8DC3
-#define GL_SAMPLER_2D_ARRAY_SHADOW        0x8DC4
-#define GL_SAMPLER_CUBE_SHADOW            0x8DC5
-#define GL_UNSIGNED_INT_VEC2              0x8DC6
-#define GL_UNSIGNED_INT_VEC3              0x8DC7
-#define GL_UNSIGNED_INT_VEC4              0x8DC8
-#define GL_INT_SAMPLER_1D                 0x8DC9
-#define GL_INT_SAMPLER_2D                 0x8DCA
-#define GL_INT_SAMPLER_3D                 0x8DCB
-#define GL_INT_SAMPLER_CUBE               0x8DCC
-#define GL_INT_SAMPLER_1D_ARRAY           0x8DCE
-#define GL_INT_SAMPLER_2D_ARRAY           0x8DCF
-#define GL_UNSIGNED_INT_SAMPLER_1D        0x8DD1
-#define GL_UNSIGNED_INT_SAMPLER_2D        0x8DD2
-#define GL_UNSIGNED_INT_SAMPLER_3D        0x8DD3
-#define GL_UNSIGNED_INT_SAMPLER_CUBE      0x8DD4
-#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY  0x8DD6
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY  0x8DD7
-#define GL_QUERY_WAIT                     0x8E13
-#define GL_QUERY_NO_WAIT                  0x8E14
-#define GL_QUERY_BY_REGION_WAIT           0x8E15
-#define GL_QUERY_BY_REGION_NO_WAIT        0x8E16
-#define GL_BUFFER_ACCESS_FLAGS            0x911F
-#define GL_BUFFER_MAP_LENGTH              0x9120
-#define GL_BUFFER_MAP_OFFSET              0x9121
-/* Reuse tokens from ARB_depth_buffer_float */
-/* reuse GL_DEPTH_COMPONENT32F */
-/* reuse GL_DEPTH32F_STENCIL8 */
-/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */
-/* Reuse tokens from ARB_framebuffer_object */
-/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
-/* reuse GL_FRAMEBUFFER_DEFAULT */
-/* reuse GL_FRAMEBUFFER_UNDEFINED */
-/* reuse GL_DEPTH_STENCIL_ATTACHMENT */
-/* reuse GL_INDEX */
-/* reuse GL_MAX_RENDERBUFFER_SIZE */
-/* reuse GL_DEPTH_STENCIL */
-/* reuse GL_UNSIGNED_INT_24_8 */
-/* reuse GL_DEPTH24_STENCIL8 */
-/* reuse GL_TEXTURE_STENCIL_SIZE */
-/* reuse GL_TEXTURE_RED_TYPE */
-/* reuse GL_TEXTURE_GREEN_TYPE */
-/* reuse GL_TEXTURE_BLUE_TYPE */
-/* reuse GL_TEXTURE_ALPHA_TYPE */
-/* reuse GL_TEXTURE_DEPTH_TYPE */
-/* reuse GL_UNSIGNED_NORMALIZED */
-/* reuse GL_FRAMEBUFFER_BINDING */
-/* reuse GL_DRAW_FRAMEBUFFER_BINDING */
-/* reuse GL_RENDERBUFFER_BINDING */
-/* reuse GL_READ_FRAMEBUFFER */
-/* reuse GL_DRAW_FRAMEBUFFER */
-/* reuse GL_READ_FRAMEBUFFER_BINDING */
-/* reuse GL_RENDERBUFFER_SAMPLES */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
-/* reuse GL_FRAMEBUFFER_COMPLETE */
-/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
-/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
-/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */
-/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */
-/* reuse GL_FRAMEBUFFER_UNSUPPORTED */
-/* reuse GL_MAX_COLOR_ATTACHMENTS */
-/* reuse GL_COLOR_ATTACHMENT0 */
-/* reuse GL_COLOR_ATTACHMENT1 */
-/* reuse GL_COLOR_ATTACHMENT2 */
-/* reuse GL_COLOR_ATTACHMENT3 */
-/* reuse GL_COLOR_ATTACHMENT4 */
-/* reuse GL_COLOR_ATTACHMENT5 */
-/* reuse GL_COLOR_ATTACHMENT6 */
-/* reuse GL_COLOR_ATTACHMENT7 */
-/* reuse GL_COLOR_ATTACHMENT8 */
-/* reuse GL_COLOR_ATTACHMENT9 */
-/* reuse GL_COLOR_ATTACHMENT10 */
-/* reuse GL_COLOR_ATTACHMENT11 */
-/* reuse GL_COLOR_ATTACHMENT12 */
-/* reuse GL_COLOR_ATTACHMENT13 */
-/* reuse GL_COLOR_ATTACHMENT14 */
-/* reuse GL_COLOR_ATTACHMENT15 */
-/* reuse GL_DEPTH_ATTACHMENT */
-/* reuse GL_STENCIL_ATTACHMENT */
-/* reuse GL_FRAMEBUFFER */
-/* reuse GL_RENDERBUFFER */
-/* reuse GL_RENDERBUFFER_WIDTH */
-/* reuse GL_RENDERBUFFER_HEIGHT */
-/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */
-/* reuse GL_STENCIL_INDEX1 */
-/* reuse GL_STENCIL_INDEX4 */
-/* reuse GL_STENCIL_INDEX8 */
-/* reuse GL_STENCIL_INDEX16 */
-/* reuse GL_RENDERBUFFER_RED_SIZE */
-/* reuse GL_RENDERBUFFER_GREEN_SIZE */
-/* reuse GL_RENDERBUFFER_BLUE_SIZE */
-/* reuse GL_RENDERBUFFER_ALPHA_SIZE */
-/* reuse GL_RENDERBUFFER_DEPTH_SIZE */
-/* reuse GL_RENDERBUFFER_STENCIL_SIZE */
-/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
-/* reuse GL_MAX_SAMPLES */
-/* Reuse tokens from ARB_framebuffer_sRGB */
-/* reuse GL_FRAMEBUFFER_SRGB */
-/* Reuse tokens from ARB_half_float_vertex */
-/* reuse GL_HALF_FLOAT */
-/* Reuse tokens from ARB_map_buffer_range */
-/* reuse GL_MAP_READ_BIT */
-/* reuse GL_MAP_WRITE_BIT */
-/* reuse GL_MAP_INVALIDATE_RANGE_BIT */
-/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */
-/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */
-/* reuse GL_MAP_UNSYNCHRONIZED_BIT */
-/* Reuse tokens from ARB_texture_compression_rgtc */
-/* reuse GL_COMPRESSED_RED_RGTC1 */
-/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */
-/* reuse GL_COMPRESSED_RG_RGTC2 */
-/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */
-/* Reuse tokens from ARB_texture_rg */
-/* reuse GL_RG */
-/* reuse GL_RG_INTEGER */
-/* reuse GL_R8 */
-/* reuse GL_R16 */
-/* reuse GL_RG8 */
-/* reuse GL_RG16 */
-/* reuse GL_R16F */
-/* reuse GL_R32F */
-/* reuse GL_RG16F */
-/* reuse GL_RG32F */
-/* reuse GL_R8I */
-/* reuse GL_R8UI */
-/* reuse GL_R16I */
-/* reuse GL_R16UI */
-/* reuse GL_R32I */
-/* reuse GL_R32UI */
-/* reuse GL_RG8I */
-/* reuse GL_RG8UI */
-/* reuse GL_RG16I */
-/* reuse GL_RG16UI */
-/* reuse GL_RG32I */
-/* reuse GL_RG32UI */
-/* Reuse tokens from ARB_vertex_array_object */
-/* reuse GL_VERTEX_ARRAY_BINDING */
-#endif
-
-#ifndef GL_VERSION_3_0_DEPRECATED
-#define GL_CLAMP_VERTEX_COLOR             0x891A
-#define GL_CLAMP_FRAGMENT_COLOR           0x891B
-#define GL_ALPHA_INTEGER                  0x8D97
-/* Reuse tokens from ARB_framebuffer_object */
-/* reuse GL_TEXTURE_LUMINANCE_TYPE */
-/* reuse GL_TEXTURE_INTENSITY_TYPE */
-#endif
-
-#ifndef GL_VERSION_3_1
-#define GL_SAMPLER_2D_RECT                0x8B63
-#define GL_SAMPLER_2D_RECT_SHADOW         0x8B64
-#define GL_SAMPLER_BUFFER                 0x8DC2
-#define GL_INT_SAMPLER_2D_RECT            0x8DCD
-#define GL_INT_SAMPLER_BUFFER             0x8DD0
-#define GL_UNSIGNED_INT_SAMPLER_2D_RECT   0x8DD5
-#define GL_UNSIGNED_INT_SAMPLER_BUFFER    0x8DD8
-#define GL_TEXTURE_BUFFER                 0x8C2A
-#define GL_MAX_TEXTURE_BUFFER_SIZE        0x8C2B
-#define GL_TEXTURE_BINDING_BUFFER         0x8C2C
-#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
-#define GL_TEXTURE_BUFFER_FORMAT          0x8C2E
-#define GL_TEXTURE_RECTANGLE              0x84F5
-#define GL_TEXTURE_BINDING_RECTANGLE      0x84F6
-#define GL_PROXY_TEXTURE_RECTANGLE        0x84F7
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE     0x84F8
-#define GL_RED_SNORM                      0x8F90
-#define GL_RG_SNORM                       0x8F91
-#define GL_RGB_SNORM                      0x8F92
-#define GL_RGBA_SNORM                     0x8F93
-#define GL_R8_SNORM                       0x8F94
-#define GL_RG8_SNORM                      0x8F95
-#define GL_RGB8_SNORM                     0x8F96
-#define GL_RGBA8_SNORM                    0x8F97
-#define GL_R16_SNORM                      0x8F98
-#define GL_RG16_SNORM                     0x8F99
-#define GL_RGB16_SNORM                    0x8F9A
-#define GL_RGBA16_SNORM                   0x8F9B
-#define GL_SIGNED_NORMALIZED              0x8F9C
-#define GL_PRIMITIVE_RESTART              0x8F9D
-#define GL_PRIMITIVE_RESTART_INDEX        0x8F9E
-/* Reuse tokens from ARB_copy_buffer */
-/* reuse GL_COPY_READ_BUFFER */
-/* reuse GL_COPY_WRITE_BUFFER */
-/* Reuse tokens from ARB_draw_instanced (none) */
-/* Reuse tokens from ARB_uniform_buffer_object */
-/* reuse GL_UNIFORM_BUFFER */
-/* reuse GL_UNIFORM_BUFFER_BINDING */
-/* reuse GL_UNIFORM_BUFFER_START */
-/* reuse GL_UNIFORM_BUFFER_SIZE */
-/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */
-/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */
-/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */
-/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */
-/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */
-/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */
-/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */
-/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */
-/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */
-/* reuse GL_ACTIVE_UNIFORM_BLOCKS */
-/* reuse GL_UNIFORM_TYPE */
-/* reuse GL_UNIFORM_SIZE */
-/* reuse GL_UNIFORM_NAME_LENGTH */
-/* reuse GL_UNIFORM_BLOCK_INDEX */
-/* reuse GL_UNIFORM_OFFSET */
-/* reuse GL_UNIFORM_ARRAY_STRIDE */
-/* reuse GL_UNIFORM_MATRIX_STRIDE */
-/* reuse GL_UNIFORM_IS_ROW_MAJOR */
-/* reuse GL_UNIFORM_BLOCK_BINDING */
-/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */
-/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */
-/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */
-/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */
-/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */
-/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */
-/* reuse GL_INVALID_INDEX */
-#endif
-
-#ifndef GL_VERSION_3_2
-#define GL_CONTEXT_CORE_PROFILE_BIT       0x00000001
-#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
-#define GL_LINES_ADJACENCY                0x000A
-#define GL_LINE_STRIP_ADJACENCY           0x000B
-#define GL_TRIANGLES_ADJACENCY            0x000C
-#define GL_TRIANGLE_STRIP_ADJACENCY       0x000D
-#define GL_PROGRAM_POINT_SIZE             0x8642
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
-#define GL_GEOMETRY_SHADER                0x8DD9
-#define GL_GEOMETRY_VERTICES_OUT          0x8916
-#define GL_GEOMETRY_INPUT_TYPE            0x8917
-#define GL_GEOMETRY_OUTPUT_TYPE           0x8918
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES   0x8DE0
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS   0x9122
-#define GL_MAX_GEOMETRY_INPUT_COMPONENTS  0x9123
-#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
-#define GL_MAX_FRAGMENT_INPUT_COMPONENTS  0x9125
-#define GL_CONTEXT_PROFILE_MASK           0x9126
-/* reuse GL_MAX_VARYING_COMPONENTS */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
-/* Reuse tokens from ARB_depth_clamp */
-/* reuse GL_DEPTH_CLAMP */
-/* Reuse tokens from ARB_draw_elements_base_vertex (none) */
-/* Reuse tokens from ARB_fragment_coord_conventions (none) */
-/* Reuse tokens from ARB_provoking_vertex */
-/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
-/* reuse GL_FIRST_VERTEX_CONVENTION */
-/* reuse GL_LAST_VERTEX_CONVENTION */
-/* reuse GL_PROVOKING_VERTEX */
-/* Reuse tokens from ARB_seamless_cube_map */
-/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
-/* Reuse tokens from ARB_sync */
-/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */
-/* reuse GL_OBJECT_TYPE */
-/* reuse GL_SYNC_CONDITION */
-/* reuse GL_SYNC_STATUS */
-/* reuse GL_SYNC_FLAGS */
-/* reuse GL_SYNC_FENCE */
-/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */
-/* reuse GL_UNSIGNALED */
-/* reuse GL_SIGNALED */
-/* reuse GL_ALREADY_SIGNALED */
-/* reuse GL_TIMEOUT_EXPIRED */
-/* reuse GL_CONDITION_SATISFIED */
-/* reuse GL_WAIT_FAILED */
-/* reuse GL_TIMEOUT_IGNORED */
-/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */
-/* reuse GL_TIMEOUT_IGNORED */
-/* Reuse tokens from ARB_texture_multisample */
-/* reuse GL_SAMPLE_POSITION */
-/* reuse GL_SAMPLE_MASK */
-/* reuse GL_SAMPLE_MASK_VALUE */
-/* reuse GL_MAX_SAMPLE_MASK_WORDS */
-/* reuse GL_TEXTURE_2D_MULTISAMPLE */
-/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */
-/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */
-/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_TEXTURE_SAMPLES */
-/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */
-/* reuse GL_SAMPLER_2D_MULTISAMPLE */
-/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */
-/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */
-/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */
-/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */
-/* reuse GL_MAX_INTEGER_SAMPLES */
-/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */
-#endif
-
-#ifndef GL_VERSION_3_3
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR    0x88FE
-/* Reuse tokens from ARB_blend_func_extended */
-/* reuse GL_SRC1_COLOR */
-/* reuse GL_ONE_MINUS_SRC1_COLOR */
-/* reuse GL_ONE_MINUS_SRC1_ALPHA */
-/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */
-/* Reuse tokens from ARB_explicit_attrib_location (none) */
-/* Reuse tokens from ARB_occlusion_query2 */
-/* reuse GL_ANY_SAMPLES_PASSED */
-/* Reuse tokens from ARB_sampler_objects */
-/* reuse GL_SAMPLER_BINDING */
-/* Reuse tokens from ARB_shader_bit_encoding (none) */
-/* Reuse tokens from ARB_texture_rgb10_a2ui */
-/* reuse GL_RGB10_A2UI */
-/* Reuse tokens from ARB_texture_swizzle */
-/* reuse GL_TEXTURE_SWIZZLE_R */
-/* reuse GL_TEXTURE_SWIZZLE_G */
-/* reuse GL_TEXTURE_SWIZZLE_B */
-/* reuse GL_TEXTURE_SWIZZLE_A */
-/* reuse GL_TEXTURE_SWIZZLE_RGBA */
-/* Reuse tokens from ARB_timer_query */
-/* reuse GL_TIME_ELAPSED */
-/* reuse GL_TIMESTAMP */
-/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */
-/* reuse GL_INT_2_10_10_10_REV */
-#endif
-
-#ifndef GL_VERSION_4_0
-#define GL_SAMPLE_SHADING                 0x8C36
-#define GL_MIN_SAMPLE_SHADING_VALUE       0x8C37
-#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
-#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
-#define GL_TEXTURE_CUBE_MAP_ARRAY         0x9009
-#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A
-#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY   0x900B
-#define GL_SAMPLER_CUBE_MAP_ARRAY         0x900C
-#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW  0x900D
-#define GL_INT_SAMPLER_CUBE_MAP_ARRAY     0x900E
-#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
-/* Reuse tokens from ARB_texture_query_lod (none) */
-/* Reuse tokens from ARB_draw_buffers_blend (none) */
-/* Reuse tokens from ARB_draw_indirect */
-/* reuse GL_DRAW_INDIRECT_BUFFER */
-/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */
-/* Reuse tokens from ARB_gpu_shader5 */
-/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */
-/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */
-/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */
-/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */
-/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */
-/* reuse GL_MAX_VERTEX_STREAMS */
-/* Reuse tokens from ARB_gpu_shader_fp64 */
-/* reuse GL_DOUBLE_VEC2 */
-/* reuse GL_DOUBLE_VEC3 */
-/* reuse GL_DOUBLE_VEC4 */
-/* reuse GL_DOUBLE_MAT2 */
-/* reuse GL_DOUBLE_MAT3 */
-/* reuse GL_DOUBLE_MAT4 */
-/* reuse GL_DOUBLE_MAT2x3 */
-/* reuse GL_DOUBLE_MAT2x4 */
-/* reuse GL_DOUBLE_MAT3x2 */
-/* reuse GL_DOUBLE_MAT3x4 */
-/* reuse GL_DOUBLE_MAT4x2 */
-/* reuse GL_DOUBLE_MAT4x3 */
-/* Reuse tokens from ARB_shader_subroutine */
-/* reuse GL_ACTIVE_SUBROUTINES */
-/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */
-/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */
-/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */
-/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */
-/* reuse GL_MAX_SUBROUTINES */
-/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */
-/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */
-/* reuse GL_COMPATIBLE_SUBROUTINES */
-/* Reuse tokens from ARB_tessellation_shader */
-/* reuse GL_PATCHES */
-/* reuse GL_PATCH_VERTICES */
-/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */
-/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */
-/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */
-/* reuse GL_TESS_GEN_MODE */
-/* reuse GL_TESS_GEN_SPACING */
-/* reuse GL_TESS_GEN_VERTEX_ORDER */
-/* reuse GL_TESS_GEN_POINT_MODE */
-/* reuse GL_ISOLINES */
-/* reuse GL_FRACTIONAL_ODD */
-/* reuse GL_FRACTIONAL_EVEN */
-/* reuse GL_MAX_PATCH_VERTICES */
-/* reuse GL_MAX_TESS_GEN_LEVEL */
-/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */
-/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */
-/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */
-/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */
-/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */
-/* reuse GL_MAX_TESS_PATCH_COMPONENTS */
-/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */
-/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */
-/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */
-/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */
-/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */
-/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */
-/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */
-/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */
-/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */
-/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */
-/* reuse GL_TESS_EVALUATION_SHADER */
-/* reuse GL_TESS_CONTROL_SHADER */
-/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */
-/* Reuse tokens from ARB_transform_feedback2 */
-/* reuse GL_TRANSFORM_FEEDBACK */
-/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */
-/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */
-/* reuse GL_TRANSFORM_FEEDBACK_BINDING */
-/* Reuse tokens from ARB_transform_feedback3 */
-/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */
-/* reuse GL_MAX_VERTEX_STREAMS */
-#endif
-
-#ifndef GL_VERSION_4_1
-/* Reuse tokens from ARB_ES2_compatibility */
-/* reuse GL_FIXED */
-/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */
-/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */
-/* reuse GL_LOW_FLOAT */
-/* reuse GL_MEDIUM_FLOAT */
-/* reuse GL_HIGH_FLOAT */
-/* reuse GL_LOW_INT */
-/* reuse GL_MEDIUM_INT */
-/* reuse GL_HIGH_INT */
-/* reuse GL_SHADER_COMPILER */
-/* reuse GL_NUM_SHADER_BINARY_FORMATS */
-/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */
-/* reuse GL_MAX_VARYING_VECTORS */
-/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */
-/* Reuse tokens from ARB_get_program_binary */
-/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */
-/* reuse GL_PROGRAM_BINARY_LENGTH */
-/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */
-/* reuse GL_PROGRAM_BINARY_FORMATS */
-/* Reuse tokens from ARB_separate_shader_objects */
-/* reuse GL_VERTEX_SHADER_BIT */
-/* reuse GL_FRAGMENT_SHADER_BIT */
-/* reuse GL_GEOMETRY_SHADER_BIT */
-/* reuse GL_TESS_CONTROL_SHADER_BIT */
-/* reuse GL_TESS_EVALUATION_SHADER_BIT */
-/* reuse GL_ALL_SHADER_BITS */
-/* reuse GL_PROGRAM_SEPARABLE */
-/* reuse GL_ACTIVE_PROGRAM */
-/* reuse GL_PROGRAM_PIPELINE_BINDING */
-/* Reuse tokens from ARB_shader_precision (none) */
-/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */
-/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */
-/* reuse GL_MAX_VIEWPORTS */
-/* reuse GL_VIEWPORT_SUBPIXEL_BITS */
-/* reuse GL_VIEWPORT_BOUNDS_RANGE */
-/* reuse GL_LAYER_PROVOKING_VERTEX */
-/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */
-/* reuse GL_UNDEFINED_VERTEX */
-#endif
-
-#ifndef GL_VERSION_4_2
-/* Reuse tokens from ARB_base_instance (none) */
-/* Reuse tokens from ARB_shading_language_420pack (none) */
-/* Reuse tokens from ARB_transform_feedback_instanced (none) */
-/* Reuse tokens from ARB_compressed_texture_pixel_storage */
-/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */
-/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */
-/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */
-/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */
-/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */
-/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */
-/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */
-/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */
-/* Reuse tokens from ARB_conservative_depth (none) */
-/* Reuse tokens from ARB_internalformat_query */
-/* reuse GL_NUM_SAMPLE_COUNTS */
-/* Reuse tokens from ARB_map_buffer_alignment */
-/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */
-/* Reuse tokens from ARB_shader_atomic_counters */
-/* reuse GL_ATOMIC_COUNTER_BUFFER */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_START */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */
-/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */
-/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */
-/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */
-/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */
-/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */
-/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */
-/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */
-/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */
-/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */
-/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */
-/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */
-/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */
-/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */
-/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */
-/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */
-/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */
-/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */
-/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */
-/* Reuse tokens from ARB_shader_image_load_store */
-/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */
-/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */
-/* reuse GL_UNIFORM_BARRIER_BIT */
-/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */
-/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */
-/* reuse GL_COMMAND_BARRIER_BIT */
-/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */
-/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */
-/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */
-/* reuse GL_FRAMEBUFFER_BARRIER_BIT */
-/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */
-/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */
-/* reuse GL_ALL_BARRIER_BITS */
-/* reuse GL_MAX_IMAGE_UNITS */
-/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */
-/* reuse GL_IMAGE_BINDING_NAME */
-/* reuse GL_IMAGE_BINDING_LEVEL */
-/* reuse GL_IMAGE_BINDING_LAYERED */
-/* reuse GL_IMAGE_BINDING_LAYER */
-/* reuse GL_IMAGE_BINDING_ACCESS */
-/* reuse GL_IMAGE_1D */
-/* reuse GL_IMAGE_2D */
-/* reuse GL_IMAGE_3D */
-/* reuse GL_IMAGE_2D_RECT */
-/* reuse GL_IMAGE_CUBE */
-/* reuse GL_IMAGE_BUFFER */
-/* reuse GL_IMAGE_1D_ARRAY */
-/* reuse GL_IMAGE_2D_ARRAY */
-/* reuse GL_IMAGE_CUBE_MAP_ARRAY */
-/* reuse GL_IMAGE_2D_MULTISAMPLE */
-/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_INT_IMAGE_1D */
-/* reuse GL_INT_IMAGE_2D */
-/* reuse GL_INT_IMAGE_3D */
-/* reuse GL_INT_IMAGE_2D_RECT */
-/* reuse GL_INT_IMAGE_CUBE */
-/* reuse GL_INT_IMAGE_BUFFER */
-/* reuse GL_INT_IMAGE_1D_ARRAY */
-/* reuse GL_INT_IMAGE_2D_ARRAY */
-/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */
-/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */
-/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_UNSIGNED_INT_IMAGE_1D */
-/* reuse GL_UNSIGNED_INT_IMAGE_2D */
-/* reuse GL_UNSIGNED_INT_IMAGE_3D */
-/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */
-/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */
-/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */
-/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */
-/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */
-/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */
-/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */
-/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
-/* reuse GL_MAX_IMAGE_SAMPLES */
-/* reuse GL_IMAGE_BINDING_FORMAT */
-/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */
-/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */
-/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */
-/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */
-/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */
-/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */
-/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */
-/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */
-/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */
-/* Reuse tokens from ARB_shading_language_packing (none) */
-/* Reuse tokens from ARB_texture_storage */
-/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */
-#endif
-
-#ifndef GL_ARB_multitexture
-#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
-#endif
-
-#ifndef GL_ARB_transpose_matrix
-#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
-#endif
-
-#ifndef GL_ARB_multisample
-#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
-#endif
-
-#ifndef GL_ARB_texture_env_add
-#endif
-
-#ifndef GL_ARB_texture_cube_map
-#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
-#endif
-
-#ifndef GL_ARB_texture_compression
-#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
-#endif
-
-#ifndef GL_ARB_texture_border_clamp
-#define GL_CLAMP_TO_BORDER_ARB            0x812D
-#endif
-
-#ifndef GL_ARB_point_parameters
-#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
-#endif
-
-#ifndef GL_ARB_vertex_blend
-#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_MODELVIEW0_ARB                 0x1700
-#define GL_MODELVIEW1_ARB                 0x850A
-#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
-#endif
-
-#ifndef GL_ARB_matrix_palette
-#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
-#endif
-
-#ifndef GL_ARB_texture_env_combine
-#define GL_COMBINE_ARB                    0x8570
-#define GL_COMBINE_RGB_ARB                0x8571
-#define GL_COMBINE_ALPHA_ARB              0x8572
-#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_RGB_SCALE_ARB                  0x8573
-#define GL_ADD_SIGNED_ARB                 0x8574
-#define GL_INTERPOLATE_ARB                0x8575
-#define GL_SUBTRACT_ARB                   0x84E7
-#define GL_CONSTANT_ARB                   0x8576
-#define GL_PRIMARY_COLOR_ARB              0x8577
-#define GL_PREVIOUS_ARB                   0x8578
-#endif
-
-#ifndef GL_ARB_texture_env_crossbar
-#endif
-
-#ifndef GL_ARB_texture_env_dot3
-#define GL_DOT3_RGB_ARB                   0x86AE
-#define GL_DOT3_RGBA_ARB                  0x86AF
-#endif
-
-#ifndef GL_ARB_texture_mirrored_repeat
-#define GL_MIRRORED_REPEAT_ARB            0x8370
-#endif
-
-#ifndef GL_ARB_depth_texture
-#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
-#endif
-
-#ifndef GL_ARB_shadow
-#define GL_TEXTURE_COMPARE_MODE_ARB       0x884C
-#define GL_TEXTURE_COMPARE_FUNC_ARB       0x884D
-#define GL_COMPARE_R_TO_TEXTURE_ARB       0x884E
-#endif
-
-#ifndef GL_ARB_shadow_ambient
-#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
-#endif
-
-#ifndef GL_ARB_window_pos
-#endif
-
-#ifndef GL_ARB_vertex_program
-#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
-#endif
-
-#ifndef GL_ARB_fragment_program
-#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
-#endif
-
-#ifndef GL_ARB_vertex_buffer_object
-#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
-#endif
-
-#ifndef GL_ARB_occlusion_query
-#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
-#endif
-
-#ifndef GL_ARB_shader_objects
-#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
-#endif
-
-#ifndef GL_ARB_vertex_shader
-#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
-#endif
-
-#ifndef GL_ARB_fragment_shader
-#define GL_FRAGMENT_SHADER_ARB            0x8B30
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
-#endif
-
-#ifndef GL_ARB_shading_language_100
-#define GL_SHADING_LANGUAGE_VERSION_ARB   0x8B8C
-#endif
-
-#ifndef GL_ARB_texture_non_power_of_two
-#endif
-
-#ifndef GL_ARB_point_sprite
-#define GL_POINT_SPRITE_ARB               0x8861
-#define GL_COORD_REPLACE_ARB              0x8862
-#endif
-
-#ifndef GL_ARB_fragment_program_shadow
-#endif
-
-#ifndef GL_ARB_draw_buffers
-#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
-#endif
-
-#ifndef GL_ARB_texture_rectangle
-#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
-#endif
-
-#ifndef GL_ARB_color_buffer_float
-#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
-#endif
-
-#ifndef GL_ARB_half_float_pixel
-#define GL_HALF_FLOAT_ARB                 0x140B
-#endif
-
-#ifndef GL_ARB_texture_float
-#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_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
-#endif
-
-#ifndef GL_ARB_pixel_buffer_object
-#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
-#endif
-
-#ifndef GL_ARB_depth_buffer_float
-#define GL_DEPTH_COMPONENT32F             0x8CAC
-#define GL_DEPTH32F_STENCIL8              0x8CAD
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
-#endif
-
-#ifndef GL_ARB_draw_instanced
-#endif
-
-#ifndef GL_ARB_framebuffer_object
-#define GL_INVALID_FRAMEBUFFER_OPERATION  0x0506
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
-#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
-#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
-#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
-#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
-#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
-#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
-#define GL_FRAMEBUFFER_DEFAULT            0x8218
-#define GL_FRAMEBUFFER_UNDEFINED          0x8219
-#define GL_DEPTH_STENCIL_ATTACHMENT       0x821A
-#define GL_MAX_RENDERBUFFER_SIZE          0x84E8
-#define GL_DEPTH_STENCIL                  0x84F9
-#define GL_UNSIGNED_INT_24_8              0x84FA
-#define GL_DEPTH24_STENCIL8               0x88F0
-#define GL_TEXTURE_STENCIL_SIZE           0x88F1
-#define GL_TEXTURE_RED_TYPE               0x8C10
-#define GL_TEXTURE_GREEN_TYPE             0x8C11
-#define GL_TEXTURE_BLUE_TYPE              0x8C12
-#define GL_TEXTURE_ALPHA_TYPE             0x8C13
-#define GL_TEXTURE_DEPTH_TYPE             0x8C16
-#define GL_UNSIGNED_NORMALIZED            0x8C17
-#define GL_FRAMEBUFFER_BINDING            0x8CA6
-#define GL_DRAW_FRAMEBUFFER_BINDING       GL_FRAMEBUFFER_BINDING
-#define GL_RENDERBUFFER_BINDING           0x8CA7
-#define GL_READ_FRAMEBUFFER               0x8CA8
-#define GL_DRAW_FRAMEBUFFER               0x8CA9
-#define GL_READ_FRAMEBUFFER_BINDING       0x8CAA
-#define GL_RENDERBUFFER_SAMPLES           0x8CAB
-#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_LAYER 0x8CD4
-#define GL_FRAMEBUFFER_COMPLETE           0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED        0x8CDD
-#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                    0x8D40
-#define GL_RENDERBUFFER                   0x8D41
-#define GL_RENDERBUFFER_WIDTH             0x8D42
-#define GL_RENDERBUFFER_HEIGHT            0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT   0x8D44
-#define GL_STENCIL_INDEX1                 0x8D46
-#define GL_STENCIL_INDEX4                 0x8D47
-#define GL_STENCIL_INDEX8                 0x8D48
-#define GL_STENCIL_INDEX16                0x8D49
-#define GL_RENDERBUFFER_RED_SIZE          0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE        0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE         0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE        0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE        0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE      0x8D55
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
-#define GL_MAX_SAMPLES                    0x8D57
-#endif
-
-#ifndef GL_ARB_framebuffer_object_DEPRECATED
-#define GL_INDEX                          0x8222
-#define GL_TEXTURE_LUMINANCE_TYPE         0x8C14
-#define GL_TEXTURE_INTENSITY_TYPE         0x8C15
-#endif
-
-#ifndef GL_ARB_framebuffer_sRGB
-#define GL_FRAMEBUFFER_SRGB               0x8DB9
-#endif
-
-#ifndef GL_ARB_geometry_shader4
-#define GL_LINES_ADJACENCY_ARB            0x000A
-#define GL_LINE_STRIP_ADJACENCY_ARB       0x000B
-#define GL_TRIANGLES_ADJACENCY_ARB        0x000C
-#define GL_TRIANGLE_STRIP_ADJACENCY_ARB   0x000D
-#define GL_PROGRAM_POINT_SIZE_ARB         0x8642
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9
-#define GL_GEOMETRY_SHADER_ARB            0x8DD9
-#define GL_GEOMETRY_VERTICES_OUT_ARB      0x8DDA
-#define GL_GEOMETRY_INPUT_TYPE_ARB        0x8DDB
-#define GL_GEOMETRY_OUTPUT_TYPE_ARB       0x8DDC
-#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD
-#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1
-/* reuse GL_MAX_VARYING_COMPONENTS */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
-#endif
-
-#ifndef GL_ARB_half_float_vertex
-#define GL_HALF_FLOAT                     0x140B
-#endif
-
-#ifndef GL_ARB_instanced_arrays
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE
-#endif
-
-#ifndef GL_ARB_map_buffer_range
-#define GL_MAP_READ_BIT                   0x0001
-#define GL_MAP_WRITE_BIT                  0x0002
-#define GL_MAP_INVALIDATE_RANGE_BIT       0x0004
-#define GL_MAP_INVALIDATE_BUFFER_BIT      0x0008
-#define GL_MAP_FLUSH_EXPLICIT_BIT         0x0010
-#define GL_MAP_UNSYNCHRONIZED_BIT         0x0020
-#endif
-
-#ifndef GL_ARB_texture_buffer_object
-#define GL_TEXTURE_BUFFER_ARB             0x8C2A
-#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB    0x8C2B
-#define GL_TEXTURE_BINDING_BUFFER_ARB     0x8C2C
-#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D
-#define GL_TEXTURE_BUFFER_FORMAT_ARB      0x8C2E
-#endif
-
-#ifndef GL_ARB_texture_compression_rgtc
-#define GL_COMPRESSED_RED_RGTC1           0x8DBB
-#define GL_COMPRESSED_SIGNED_RED_RGTC1    0x8DBC
-#define GL_COMPRESSED_RG_RGTC2            0x8DBD
-#define GL_COMPRESSED_SIGNED_RG_RGTC2     0x8DBE
-#endif
-
-#ifndef GL_ARB_texture_rg
-#define GL_RG                             0x8227
-#define GL_RG_INTEGER                     0x8228
-#define GL_R8                             0x8229
-#define GL_R16                            0x822A
-#define GL_RG8                            0x822B
-#define GL_RG16                           0x822C
-#define GL_R16F                           0x822D
-#define GL_R32F                           0x822E
-#define GL_RG16F                          0x822F
-#define GL_RG32F                          0x8230
-#define GL_R8I                            0x8231
-#define GL_R8UI                           0x8232
-#define GL_R16I                           0x8233
-#define GL_R16UI                          0x8234
-#define GL_R32I                           0x8235
-#define GL_R32UI                          0x8236
-#define GL_RG8I                           0x8237
-#define GL_RG8UI                          0x8238
-#define GL_RG16I                          0x8239
-#define GL_RG16UI                         0x823A
-#define GL_RG32I                          0x823B
-#define GL_RG32UI                         0x823C
-#endif
-
-#ifndef GL_ARB_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING           0x85B5
-#endif
-
-#ifndef GL_ARB_uniform_buffer_object
-#define GL_UNIFORM_BUFFER                 0x8A11
-#define GL_UNIFORM_BUFFER_BINDING         0x8A28
-#define GL_UNIFORM_BUFFER_START           0x8A29
-#define GL_UNIFORM_BUFFER_SIZE            0x8A2A
-#define GL_MAX_VERTEX_UNIFORM_BLOCKS      0x8A2B
-#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS    0x8A2C
-#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS    0x8A2D
-#define GL_MAX_COMBINED_UNIFORM_BLOCKS    0x8A2E
-#define GL_MAX_UNIFORM_BUFFER_BINDINGS    0x8A2F
-#define GL_MAX_UNIFORM_BLOCK_SIZE         0x8A30
-#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
-#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
-#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
-#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
-#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
-#define GL_ACTIVE_UNIFORM_BLOCKS          0x8A36
-#define GL_UNIFORM_TYPE                   0x8A37
-#define GL_UNIFORM_SIZE                   0x8A38
-#define GL_UNIFORM_NAME_LENGTH            0x8A39
-#define GL_UNIFORM_BLOCK_INDEX            0x8A3A
-#define GL_UNIFORM_OFFSET                 0x8A3B
-#define GL_UNIFORM_ARRAY_STRIDE           0x8A3C
-#define GL_UNIFORM_MATRIX_STRIDE          0x8A3D
-#define GL_UNIFORM_IS_ROW_MAJOR           0x8A3E
-#define GL_UNIFORM_BLOCK_BINDING          0x8A3F
-#define GL_UNIFORM_BLOCK_DATA_SIZE        0x8A40
-#define GL_UNIFORM_BLOCK_NAME_LENGTH      0x8A41
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS  0x8A42
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
-#define GL_INVALID_INDEX                  0xFFFFFFFFu
-#endif
-
-#ifndef GL_ARB_compatibility
-/* ARB_compatibility just defines tokens from core 3.0 */
-#endif
-
-#ifndef GL_ARB_copy_buffer
-#define GL_COPY_READ_BUFFER               0x8F36
-#define GL_COPY_WRITE_BUFFER              0x8F37
-#endif
-
-#ifndef GL_ARB_shader_texture_lod
-#endif
-
-#ifndef GL_ARB_depth_clamp
-#define GL_DEPTH_CLAMP                    0x864F
-#endif
-
-#ifndef GL_ARB_draw_elements_base_vertex
-#endif
-
-#ifndef GL_ARB_fragment_coord_conventions
-#endif
-
-#ifndef GL_ARB_provoking_vertex
-#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
-#define GL_FIRST_VERTEX_CONVENTION        0x8E4D
-#define GL_LAST_VERTEX_CONVENTION         0x8E4E
-#define GL_PROVOKING_VERTEX               0x8E4F
-#endif
-
-#ifndef GL_ARB_seamless_cube_map
-#define GL_TEXTURE_CUBE_MAP_SEAMLESS      0x884F
-#endif
-
-#ifndef GL_ARB_sync
-#define GL_MAX_SERVER_WAIT_TIMEOUT        0x9111
-#define GL_OBJECT_TYPE                    0x9112
-#define GL_SYNC_CONDITION                 0x9113
-#define GL_SYNC_STATUS                    0x9114
-#define GL_SYNC_FLAGS                     0x9115
-#define GL_SYNC_FENCE                     0x9116
-#define GL_SYNC_GPU_COMMANDS_COMPLETE     0x9117
-#define GL_UNSIGNALED                     0x9118
-#define GL_SIGNALED                       0x9119
-#define GL_ALREADY_SIGNALED               0x911A
-#define GL_TIMEOUT_EXPIRED                0x911B
-#define GL_CONDITION_SATISFIED            0x911C
-#define GL_WAIT_FAILED                    0x911D
-#define GL_SYNC_FLUSH_COMMANDS_BIT        0x00000001
-#define GL_TIMEOUT_IGNORED                0xFFFFFFFFFFFFFFFFull
-#endif
-
-#ifndef GL_ARB_texture_multisample
-#define GL_SAMPLE_POSITION                0x8E50
-#define GL_SAMPLE_MASK                    0x8E51
-#define GL_SAMPLE_MASK_VALUE              0x8E52
-#define GL_MAX_SAMPLE_MASK_WORDS          0x8E59
-#define GL_TEXTURE_2D_MULTISAMPLE         0x9100
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE   0x9101
-#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY   0x9102
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
-#define GL_TEXTURE_SAMPLES                0x9106
-#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
-#define GL_SAMPLER_2D_MULTISAMPLE         0x9108
-#define GL_INT_SAMPLER_2D_MULTISAMPLE     0x9109
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
-#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY   0x910B
-#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
-#define GL_MAX_COLOR_TEXTURE_SAMPLES      0x910E
-#define GL_MAX_DEPTH_TEXTURE_SAMPLES      0x910F
-#define GL_MAX_INTEGER_SAMPLES            0x9110
-#endif
-
-#ifndef GL_ARB_vertex_array_bgra
-/* reuse GL_BGRA */
-#endif
-
-#ifndef GL_ARB_draw_buffers_blend
-#endif
-
-#ifndef GL_ARB_sample_shading
-#define GL_SAMPLE_SHADING_ARB             0x8C36
-#define GL_MIN_SAMPLE_SHADING_VALUE_ARB   0x8C37
-#endif
-
-#ifndef GL_ARB_texture_cube_map_array
-#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB     0x9009
-#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A
-#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B
-#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB     0x900C
-#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D
-#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E
-#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F
-#endif
-
-#ifndef GL_ARB_texture_gather
-#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E
-#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F
-#endif
-
-#ifndef GL_ARB_texture_query_lod
-#endif
-
-#ifndef GL_ARB_shading_language_include
-#define GL_SHADER_INCLUDE_ARB             0x8DAE
-#define GL_NAMED_STRING_LENGTH_ARB        0x8DE9
-#define GL_NAMED_STRING_TYPE_ARB          0x8DEA
-#endif
-
-#ifndef GL_ARB_texture_compression_bptc
-#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
-#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
-#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
-#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
-#endif
-
-#ifndef GL_ARB_blend_func_extended
-#define GL_SRC1_COLOR                     0x88F9
-/* reuse GL_SRC1_ALPHA */
-#define GL_ONE_MINUS_SRC1_COLOR           0x88FA
-#define GL_ONE_MINUS_SRC1_ALPHA           0x88FB
-#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS   0x88FC
-#endif
-
-#ifndef GL_ARB_explicit_attrib_location
-#endif
-
-#ifndef GL_ARB_occlusion_query2
-#define GL_ANY_SAMPLES_PASSED             0x8C2F
-#endif
-
-#ifndef GL_ARB_sampler_objects
-#define GL_SAMPLER_BINDING                0x8919
-#endif
-
-#ifndef GL_ARB_shader_bit_encoding
-#endif
-
-#ifndef GL_ARB_texture_rgb10_a2ui
-#define GL_RGB10_A2UI                     0x906F
-#endif
-
-#ifndef GL_ARB_texture_swizzle
-#define GL_TEXTURE_SWIZZLE_R              0x8E42
-#define GL_TEXTURE_SWIZZLE_G              0x8E43
-#define GL_TEXTURE_SWIZZLE_B              0x8E44
-#define GL_TEXTURE_SWIZZLE_A              0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA           0x8E46
-#endif
-
-#ifndef GL_ARB_timer_query
-#define GL_TIME_ELAPSED                   0x88BF
-#define GL_TIMESTAMP                      0x8E28
-#endif
-
-#ifndef GL_ARB_vertex_type_2_10_10_10_rev
-/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */
-#define GL_INT_2_10_10_10_REV             0x8D9F
-#endif
-
-#ifndef GL_ARB_draw_indirect
-#define GL_DRAW_INDIRECT_BUFFER           0x8F3F
-#define GL_DRAW_INDIRECT_BUFFER_BINDING   0x8F43
-#endif
-
-#ifndef GL_ARB_gpu_shader5
-#define GL_GEOMETRY_SHADER_INVOCATIONS    0x887F
-#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A
-#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B
-#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C
-#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D
-/* reuse GL_MAX_VERTEX_STREAMS */
-#endif
-
-#ifndef GL_ARB_gpu_shader_fp64
-/* reuse GL_DOUBLE */
-#define GL_DOUBLE_VEC2                    0x8FFC
-#define GL_DOUBLE_VEC3                    0x8FFD
-#define GL_DOUBLE_VEC4                    0x8FFE
-#define GL_DOUBLE_MAT2                    0x8F46
-#define GL_DOUBLE_MAT3                    0x8F47
-#define GL_DOUBLE_MAT4                    0x8F48
-#define GL_DOUBLE_MAT2x3                  0x8F49
-#define GL_DOUBLE_MAT2x4                  0x8F4A
-#define GL_DOUBLE_MAT3x2                  0x8F4B
-#define GL_DOUBLE_MAT3x4                  0x8F4C
-#define GL_DOUBLE_MAT4x2                  0x8F4D
-#define GL_DOUBLE_MAT4x3                  0x8F4E
-#endif
-
-#ifndef GL_ARB_shader_subroutine
-#define GL_ACTIVE_SUBROUTINES             0x8DE5
-#define GL_ACTIVE_SUBROUTINE_UNIFORMS     0x8DE6
-#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47
-#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH   0x8E48
-#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49
-#define GL_MAX_SUBROUTINES                0x8DE7
-#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8
-#define GL_NUM_COMPATIBLE_SUBROUTINES     0x8E4A
-#define GL_COMPATIBLE_SUBROUTINES         0x8E4B
-/* reuse GL_UNIFORM_SIZE */
-/* reuse GL_UNIFORM_NAME_LENGTH */
-#endif
-
-#ifndef GL_ARB_tessellation_shader
-#define GL_PATCHES                        0x000E
-#define GL_PATCH_VERTICES                 0x8E72
-#define GL_PATCH_DEFAULT_INNER_LEVEL      0x8E73
-#define GL_PATCH_DEFAULT_OUTER_LEVEL      0x8E74
-#define GL_TESS_CONTROL_OUTPUT_VERTICES   0x8E75
-#define GL_TESS_GEN_MODE                  0x8E76
-#define GL_TESS_GEN_SPACING               0x8E77
-#define GL_TESS_GEN_VERTEX_ORDER          0x8E78
-#define GL_TESS_GEN_POINT_MODE            0x8E79
-/* reuse GL_TRIANGLES */
-/* reuse GL_QUADS */
-#define GL_ISOLINES                       0x8E7A
-/* reuse GL_EQUAL */
-#define GL_FRACTIONAL_ODD                 0x8E7B
-#define GL_FRACTIONAL_EVEN                0x8E7C
-/* reuse GL_CCW */
-/* reuse GL_CW */
-#define GL_MAX_PATCH_VERTICES             0x8E7D
-#define GL_MAX_TESS_GEN_LEVEL             0x8E7E
-#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F
-#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80
-#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81
-#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82
-#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83
-#define GL_MAX_TESS_PATCH_COMPONENTS      0x8E84
-#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85
-#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86
-#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89
-#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A
-#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C
-#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D
-#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E
-#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1
-#define GL_TESS_EVALUATION_SHADER         0x8E87
-#define GL_TESS_CONTROL_SHADER            0x8E88
-#endif
-
-#ifndef GL_ARB_texture_buffer_object_rgb32
-/* reuse GL_RGB32F */
-/* reuse GL_RGB32UI */
-/* reuse GL_RGB32I */
-#endif
-
-#ifndef GL_ARB_transform_feedback2
-#define GL_TRANSFORM_FEEDBACK             0x8E22
-#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23
-#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24
-#define GL_TRANSFORM_FEEDBACK_BINDING     0x8E25
-#endif
-
-#ifndef GL_ARB_transform_feedback3
-#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70
-#define GL_MAX_VERTEX_STREAMS             0x8E71
-#endif
-
-#ifndef GL_ARB_ES2_compatibility
-#define GL_FIXED                          0x140C
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-#define GL_LOW_FLOAT                      0x8DF0
-#define GL_MEDIUM_FLOAT                   0x8DF1
-#define GL_HIGH_FLOAT                     0x8DF2
-#define GL_LOW_INT                        0x8DF3
-#define GL_MEDIUM_INT                     0x8DF4
-#define GL_HIGH_INT                       0x8DF5
-#define GL_SHADER_COMPILER                0x8DFA
-#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9
-#define GL_MAX_VERTEX_UNIFORM_VECTORS     0x8DFB
-#define GL_MAX_VARYING_VECTORS            0x8DFC
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS   0x8DFD
-#endif
-
-#ifndef GL_ARB_get_program_binary
-#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
-#define GL_PROGRAM_BINARY_LENGTH          0x8741
-#define GL_NUM_PROGRAM_BINARY_FORMATS     0x87FE
-#define GL_PROGRAM_BINARY_FORMATS         0x87FF
-#endif
-
-#ifndef GL_ARB_separate_shader_objects
-#define GL_VERTEX_SHADER_BIT              0x00000001
-#define GL_FRAGMENT_SHADER_BIT            0x00000002
-#define GL_GEOMETRY_SHADER_BIT            0x00000004
-#define GL_TESS_CONTROL_SHADER_BIT        0x00000008
-#define GL_TESS_EVALUATION_SHADER_BIT     0x00000010
-#define GL_ALL_SHADER_BITS                0xFFFFFFFF
-#define GL_PROGRAM_SEPARABLE              0x8258
-#define GL_ACTIVE_PROGRAM                 0x8259
-#define GL_PROGRAM_PIPELINE_BINDING       0x825A
-#endif
-
-#ifndef GL_ARB_shader_precision
-#endif
-
-#ifndef GL_ARB_vertex_attrib_64bit
-/* reuse GL_RGB32I */
-/* reuse GL_DOUBLE_VEC2 */
-/* reuse GL_DOUBLE_VEC3 */
-/* reuse GL_DOUBLE_VEC4 */
-/* reuse GL_DOUBLE_MAT2 */
-/* reuse GL_DOUBLE_MAT3 */
-/* reuse GL_DOUBLE_MAT4 */
-/* reuse GL_DOUBLE_MAT2x3 */
-/* reuse GL_DOUBLE_MAT2x4 */
-/* reuse GL_DOUBLE_MAT3x2 */
-/* reuse GL_DOUBLE_MAT3x4 */
-/* reuse GL_DOUBLE_MAT4x2 */
-/* reuse GL_DOUBLE_MAT4x3 */
-#endif
-
-#ifndef GL_ARB_viewport_array
-/* reuse GL_SCISSOR_BOX */
-/* reuse GL_VIEWPORT */
-/* reuse GL_DEPTH_RANGE */
-/* reuse GL_SCISSOR_TEST */
-#define GL_MAX_VIEWPORTS                  0x825B
-#define GL_VIEWPORT_SUBPIXEL_BITS         0x825C
-#define GL_VIEWPORT_BOUNDS_RANGE          0x825D
-#define GL_LAYER_PROVOKING_VERTEX         0x825E
-#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F
-#define GL_UNDEFINED_VERTEX               0x8260
-/* reuse GL_FIRST_VERTEX_CONVENTION */
-/* reuse GL_LAST_VERTEX_CONVENTION */
-/* reuse GL_PROVOKING_VERTEX */
-#endif
-
-#ifndef GL_ARB_cl_event
-#define GL_SYNC_CL_EVENT_ARB              0x8240
-#define GL_SYNC_CL_EVENT_COMPLETE_ARB     0x8241
-#endif
-
-#ifndef GL_ARB_debug_output
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB   0x8242
-#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
-#define GL_DEBUG_CALLBACK_FUNCTION_ARB    0x8244
-#define GL_DEBUG_CALLBACK_USER_PARAM_ARB  0x8245
-#define GL_DEBUG_SOURCE_API_ARB           0x8246
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
-#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB   0x8249
-#define GL_DEBUG_SOURCE_APPLICATION_ARB   0x824A
-#define GL_DEBUG_SOURCE_OTHER_ARB         0x824B
-#define GL_DEBUG_TYPE_ERROR_ARB           0x824C
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
-#define GL_DEBUG_TYPE_PORTABILITY_ARB     0x824F
-#define GL_DEBUG_TYPE_PERFORMANCE_ARB     0x8250
-#define GL_DEBUG_TYPE_OTHER_ARB           0x8251
-#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB   0x9143
-#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB  0x9144
-#define GL_DEBUG_LOGGED_MESSAGES_ARB      0x9145
-#define GL_DEBUG_SEVERITY_HIGH_ARB        0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM_ARB      0x9147
-#define GL_DEBUG_SEVERITY_LOW_ARB         0x9148
-#endif
-
-#ifndef GL_ARB_robustness
-/* reuse GL_NO_ERROR */
-#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define GL_LOSE_CONTEXT_ON_RESET_ARB      0x8252
-#define GL_GUILTY_CONTEXT_RESET_ARB       0x8253
-#define GL_INNOCENT_CONTEXT_RESET_ARB     0x8254
-#define GL_UNKNOWN_CONTEXT_RESET_ARB      0x8255
-#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GL_NO_RESET_NOTIFICATION_ARB      0x8261
-#endif
-
-#ifndef GL_ARB_shader_stencil_export
-#endif
-
-#ifndef GL_ARB_base_instance
-#endif
-
-#ifndef GL_ARB_shading_language_420pack
-#endif
-
-#ifndef GL_ARB_transform_feedback_instanced
-#endif
-
-#ifndef GL_ARB_compressed_texture_pixel_storage
-#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH  0x9127
-#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
-#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH  0x9129
-#define GL_UNPACK_COMPRESSED_BLOCK_SIZE   0x912A
-#define GL_PACK_COMPRESSED_BLOCK_WIDTH    0x912B
-#define GL_PACK_COMPRESSED_BLOCK_HEIGHT   0x912C
-#define GL_PACK_COMPRESSED_BLOCK_DEPTH    0x912D
-#define GL_PACK_COMPRESSED_BLOCK_SIZE     0x912E
-#endif
-
-#ifndef GL_ARB_conservative_depth
-#endif
-
-#ifndef GL_ARB_internalformat_query
-#define GL_NUM_SAMPLE_COUNTS              0x9380
-#endif
-
-#ifndef GL_ARB_map_buffer_alignment
-#define GL_MIN_MAP_BUFFER_ALIGNMENT       0x90BC
-#endif
-
-#ifndef GL_ARB_shader_atomic_counters
-#define GL_ATOMIC_COUNTER_BUFFER          0x92C0
-#define GL_ATOMIC_COUNTER_BUFFER_BINDING  0x92C1
-#define GL_ATOMIC_COUNTER_BUFFER_START    0x92C2
-#define GL_ATOMIC_COUNTER_BUFFER_SIZE     0x92C3
-#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4
-#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5
-#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6
-#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7
-#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8
-#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9
-#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA
-#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB
-#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
-#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD
-#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE
-#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF
-#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
-#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
-#define GL_MAX_VERTEX_ATOMIC_COUNTERS     0x92D2
-#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3
-#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4
-#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS   0x92D5
-#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS   0x92D6
-#define GL_MAX_COMBINED_ATOMIC_COUNTERS   0x92D7
-#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
-#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
-#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS  0x92D9
-#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA
-#define GL_UNSIGNED_INT_ATOMIC_COUNTER    0x92DB
-#endif
-
-#ifndef GL_ARB_shader_image_load_store
-#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
-#define GL_ELEMENT_ARRAY_BARRIER_BIT      0x00000002
-#define GL_UNIFORM_BARRIER_BIT            0x00000004
-#define GL_TEXTURE_FETCH_BARRIER_BIT      0x00000008
-#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
-#define GL_COMMAND_BARRIER_BIT            0x00000040
-#define GL_PIXEL_BUFFER_BARRIER_BIT       0x00000080
-#define GL_TEXTURE_UPDATE_BARRIER_BIT     0x00000100
-#define GL_BUFFER_UPDATE_BARRIER_BIT      0x00000200
-#define GL_FRAMEBUFFER_BARRIER_BIT        0x00000400
-#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
-#define GL_ATOMIC_COUNTER_BARRIER_BIT     0x00001000
-#define GL_ALL_BARRIER_BITS               0xFFFFFFFF
-#define GL_MAX_IMAGE_UNITS                0x8F38
-#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
-#define GL_IMAGE_BINDING_NAME             0x8F3A
-#define GL_IMAGE_BINDING_LEVEL            0x8F3B
-#define GL_IMAGE_BINDING_LAYERED          0x8F3C
-#define GL_IMAGE_BINDING_LAYER            0x8F3D
-#define GL_IMAGE_BINDING_ACCESS           0x8F3E
-#define GL_IMAGE_1D                       0x904C
-#define GL_IMAGE_2D                       0x904D
-#define GL_IMAGE_3D                       0x904E
-#define GL_IMAGE_2D_RECT                  0x904F
-#define GL_IMAGE_CUBE                     0x9050
-#define GL_IMAGE_BUFFER                   0x9051
-#define GL_IMAGE_1D_ARRAY                 0x9052
-#define GL_IMAGE_2D_ARRAY                 0x9053
-#define GL_IMAGE_CUBE_MAP_ARRAY           0x9054
-#define GL_IMAGE_2D_MULTISAMPLE           0x9055
-#define GL_IMAGE_2D_MULTISAMPLE_ARRAY     0x9056
-#define GL_INT_IMAGE_1D                   0x9057
-#define GL_INT_IMAGE_2D                   0x9058
-#define GL_INT_IMAGE_3D                   0x9059
-#define GL_INT_IMAGE_2D_RECT              0x905A
-#define GL_INT_IMAGE_CUBE                 0x905B
-#define GL_INT_IMAGE_BUFFER               0x905C
-#define GL_INT_IMAGE_1D_ARRAY             0x905D
-#define GL_INT_IMAGE_2D_ARRAY             0x905E
-#define GL_INT_IMAGE_CUBE_MAP_ARRAY       0x905F
-#define GL_INT_IMAGE_2D_MULTISAMPLE       0x9060
-#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
-#define GL_UNSIGNED_INT_IMAGE_1D          0x9062
-#define GL_UNSIGNED_INT_IMAGE_2D          0x9063
-#define GL_UNSIGNED_INT_IMAGE_3D          0x9064
-#define GL_UNSIGNED_INT_IMAGE_2D_RECT     0x9065
-#define GL_UNSIGNED_INT_IMAGE_CUBE        0x9066
-#define GL_UNSIGNED_INT_IMAGE_BUFFER      0x9067
-#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY    0x9068
-#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY    0x9069
-#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
-#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
-#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
-#define GL_MAX_IMAGE_SAMPLES              0x906D
-#define GL_IMAGE_BINDING_FORMAT           0x906E
-#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
-#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
-#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
-#define GL_MAX_VERTEX_IMAGE_UNIFORMS      0x90CA
-#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
-#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
-#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS    0x90CD
-#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS    0x90CE
-#define GL_MAX_COMBINED_IMAGE_UNIFORMS    0x90CF
-#endif
-
-#ifndef GL_ARB_shading_language_packing
-#endif
-
-#ifndef GL_ARB_texture_storage
-#define GL_TEXTURE_IMMUTABLE_FORMAT       0x912F
-#endif
-
-#ifndef GL_EXT_abgr
-#define GL_ABGR_EXT                       0x8000
-#endif
-
-#ifndef GL_EXT_blend_color
-#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
-#endif
-
-#ifndef GL_EXT_polygon_offset
-#define GL_POLYGON_OFFSET_EXT             0x8037
-#define GL_POLYGON_OFFSET_FACTOR_EXT      0x8038
-#define GL_POLYGON_OFFSET_BIAS_EXT        0x8039
-#endif
-
-#ifndef GL_EXT_texture
-#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_TEXTURE_TOO_LARGE_EXT          0x8065
-#endif
-
-#ifndef GL_EXT_texture3D
-#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
-#endif
-
-#ifndef GL_SGIS_texture_filter4
-#define GL_FILTER4_SGIS                   0x8146
-#define GL_TEXTURE_FILTER4_SIZE_SGIS      0x8147
-#endif
-
-#ifndef GL_EXT_subtexture
-#endif
-
-#ifndef GL_EXT_copy_texture
-#endif
-
-#ifndef GL_EXT_histogram
-#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_TABLE_TOO_LARGE_EXT            0x8031
-#endif
-
-#ifndef GL_EXT_convolution
-#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
-#endif
-
-#ifndef GL_SGI_color_matrix
-#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
-#endif
-
-#ifndef GL_SGI_color_table
-#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
-#endif
-
-#ifndef GL_SGIS_pixel_texture
-#define GL_PIXEL_TEXTURE_SGIS             0x8353
-#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354
-#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355
-#define GL_PIXEL_GROUP_COLOR_SGIS         0x8356
-#endif
-
-#ifndef GL_SGIX_pixel_texture
-#define GL_PIXEL_TEX_GEN_SGIX             0x8139
-#define GL_PIXEL_TEX_GEN_MODE_SGIX        0x832B
-#endif
-
-#ifndef GL_SGIS_texture4D
-#define GL_PACK_SKIP_VOLUMES_SGIS         0x8130
-#define GL_PACK_IMAGE_DEPTH_SGIS          0x8131
-#define GL_UNPACK_SKIP_VOLUMES_SGIS       0x8132
-#define GL_UNPACK_IMAGE_DEPTH_SGIS        0x8133
-#define GL_TEXTURE_4D_SGIS                0x8134
-#define GL_PROXY_TEXTURE_4D_SGIS          0x8135
-#define GL_TEXTURE_4DSIZE_SGIS            0x8136
-#define GL_TEXTURE_WRAP_Q_SGIS            0x8137
-#define GL_MAX_4D_TEXTURE_SIZE_SGIS       0x8138
-#define GL_TEXTURE_4D_BINDING_SGIS        0x814F
-#endif
-
-#ifndef GL_SGI_texture_color_table
-#define GL_TEXTURE_COLOR_TABLE_SGI        0x80BC
-#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI  0x80BD
-#endif
-
-#ifndef GL_EXT_cmyka
-#define GL_CMYK_EXT                       0x800C
-#define GL_CMYKA_EXT                      0x800D
-#define GL_PACK_CMYK_HINT_EXT             0x800E
-#define GL_UNPACK_CMYK_HINT_EXT           0x800F
-#endif
-
-#ifndef GL_EXT_texture_object
-#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
-#endif
-
-#ifndef GL_SGIS_detail_texture
-#define GL_DETAIL_TEXTURE_2D_SGIS         0x8095
-#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096
-#define GL_LINEAR_DETAIL_SGIS             0x8097
-#define GL_LINEAR_DETAIL_ALPHA_SGIS       0x8098
-#define GL_LINEAR_DETAIL_COLOR_SGIS       0x8099
-#define GL_DETAIL_TEXTURE_LEVEL_SGIS      0x809A
-#define GL_DETAIL_TEXTURE_MODE_SGIS       0x809B
-#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C
-#endif
-
-#ifndef GL_SGIS_sharpen_texture
-#define GL_LINEAR_SHARPEN_SGIS            0x80AD
-#define GL_LINEAR_SHARPEN_ALPHA_SGIS      0x80AE
-#define GL_LINEAR_SHARPEN_COLOR_SGIS      0x80AF
-#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0
-#endif
-
-#ifndef GL_EXT_packed_pixels
-#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
-#endif
-
-#ifndef GL_SGIS_texture_lod
-#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
-#endif
-
-#ifndef GL_SGIS_multisample
-#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
-#endif
-
-#ifndef GL_EXT_rescale_normal
-#define GL_RESCALE_NORMAL_EXT             0x803A
-#endif
-
-#ifndef GL_EXT_vertex_array
-#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
-#endif
-
-#ifndef GL_EXT_misc_attribute
-#endif
-
-#ifndef GL_SGIS_generate_mipmap
-#define GL_GENERATE_MIPMAP_SGIS           0x8191
-#define GL_GENERATE_MIPMAP_HINT_SGIS      0x8192
-#endif
-
-#ifndef GL_SGIX_clipmap
-#define GL_LINEAR_CLIPMAP_LINEAR_SGIX     0x8170
-#define GL_TEXTURE_CLIPMAP_CENTER_SGIX    0x8171
-#define GL_TEXTURE_CLIPMAP_FRAME_SGIX     0x8172
-#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX    0x8173
-#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174
-#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175
-#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX     0x8176
-#define GL_MAX_CLIPMAP_DEPTH_SGIX         0x8177
-#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178
-#define GL_NEAREST_CLIPMAP_NEAREST_SGIX   0x844D
-#define GL_NEAREST_CLIPMAP_LINEAR_SGIX    0x844E
-#define GL_LINEAR_CLIPMAP_NEAREST_SGIX    0x844F
-#endif
-
-#ifndef GL_SGIX_shadow
-#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
-#endif
-
-#ifndef GL_SGIS_texture_edge_clamp
-#define GL_CLAMP_TO_EDGE_SGIS             0x812F
-#endif
-
-#ifndef GL_SGIS_texture_border_clamp
-#define GL_CLAMP_TO_BORDER_SGIS           0x812D
-#endif
-
-#ifndef GL_EXT_blend_minmax
-#define GL_FUNC_ADD_EXT                   0x8006
-#define GL_MIN_EXT                        0x8007
-#define GL_MAX_EXT                        0x8008
-#define GL_BLEND_EQUATION_EXT             0x8009
-#endif
-
-#ifndef GL_EXT_blend_subtract
-#define GL_FUNC_SUBTRACT_EXT              0x800A
-#define GL_FUNC_REVERSE_SUBTRACT_EXT      0x800B
-#endif
-
-#ifndef GL_EXT_blend_logic_op
-#endif
-
-#ifndef GL_SGIX_interlace
-#define GL_INTERLACE_SGIX                 0x8094
-#endif
-
-#ifndef GL_SGIX_pixel_tiles
-#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E
-#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F
-#define GL_PIXEL_TILE_WIDTH_SGIX          0x8140
-#define GL_PIXEL_TILE_HEIGHT_SGIX         0x8141
-#define GL_PIXEL_TILE_GRID_WIDTH_SGIX     0x8142
-#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX    0x8143
-#define GL_PIXEL_TILE_GRID_DEPTH_SGIX     0x8144
-#define GL_PIXEL_TILE_CACHE_SIZE_SGIX     0x8145
-#endif
-
-#ifndef GL_SGIS_texture_select
-#define GL_DUAL_ALPHA4_SGIS               0x8110
-#define GL_DUAL_ALPHA8_SGIS               0x8111
-#define GL_DUAL_ALPHA12_SGIS              0x8112
-#define GL_DUAL_ALPHA16_SGIS              0x8113
-#define GL_DUAL_LUMINANCE4_SGIS           0x8114
-#define GL_DUAL_LUMINANCE8_SGIS           0x8115
-#define GL_DUAL_LUMINANCE12_SGIS          0x8116
-#define GL_DUAL_LUMINANCE16_SGIS          0x8117
-#define GL_DUAL_INTENSITY4_SGIS           0x8118
-#define GL_DUAL_INTENSITY8_SGIS           0x8119
-#define GL_DUAL_INTENSITY12_SGIS          0x811A
-#define GL_DUAL_INTENSITY16_SGIS          0x811B
-#define GL_DUAL_LUMINANCE_ALPHA4_SGIS     0x811C
-#define GL_DUAL_LUMINANCE_ALPHA8_SGIS     0x811D
-#define GL_QUAD_ALPHA4_SGIS               0x811E
-#define GL_QUAD_ALPHA8_SGIS               0x811F
-#define GL_QUAD_LUMINANCE4_SGIS           0x8120
-#define GL_QUAD_LUMINANCE8_SGIS           0x8121
-#define GL_QUAD_INTENSITY4_SGIS           0x8122
-#define GL_QUAD_INTENSITY8_SGIS           0x8123
-#define GL_DUAL_TEXTURE_SELECT_SGIS       0x8124
-#define GL_QUAD_TEXTURE_SELECT_SGIS       0x8125
-#endif
-
-#ifndef GL_SGIX_sprite
-#define GL_SPRITE_SGIX                    0x8148
-#define GL_SPRITE_MODE_SGIX               0x8149
-#define GL_SPRITE_AXIS_SGIX               0x814A
-#define GL_SPRITE_TRANSLATION_SGIX        0x814B
-#define GL_SPRITE_AXIAL_SGIX              0x814C
-#define GL_SPRITE_OBJECT_ALIGNED_SGIX     0x814D
-#define GL_SPRITE_EYE_ALIGNED_SGIX        0x814E
-#endif
-
-#ifndef GL_SGIX_texture_multi_buffer
-#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
-#endif
-
-#ifndef GL_EXT_point_parameters
-#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
-#endif
-
-#ifndef GL_SGIS_point_parameters
-#define GL_POINT_SIZE_MIN_SGIS            0x8126
-#define GL_POINT_SIZE_MAX_SGIS            0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
-#define GL_DISTANCE_ATTENUATION_SGIS      0x8129
-#endif
-
-#ifndef GL_SGIX_instruments
-#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180
-#define GL_INSTRUMENT_MEASUREMENTS_SGIX   0x8181
-#endif
-
-#ifndef GL_SGIX_texture_scale_bias
-#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
-#endif
-
-#ifndef GL_SGIX_framezoom
-#define GL_FRAMEZOOM_SGIX                 0x818B
-#define GL_FRAMEZOOM_FACTOR_SGIX          0x818C
-#define GL_MAX_FRAMEZOOM_FACTOR_SGIX      0x818D
-#endif
-
-#ifndef GL_SGIX_tag_sample_buffer
-#endif
-
-#ifndef GL_FfdMaskSGIX
-#define GL_TEXTURE_DEFORMATION_BIT_SGIX   0x00000001
-#define GL_GEOMETRY_DEFORMATION_BIT_SGIX  0x00000002
-#endif
-
-#ifndef GL_SGIX_polynomial_ffd
-#define GL_GEOMETRY_DEFORMATION_SGIX      0x8194
-#define GL_TEXTURE_DEFORMATION_SGIX       0x8195
-#define GL_DEFORMATIONS_MASK_SGIX         0x8196
-#define GL_MAX_DEFORMATION_ORDER_SGIX     0x8197
-#endif
-
-#ifndef GL_SGIX_reference_plane
-#define GL_REFERENCE_PLANE_SGIX           0x817D
-#define GL_REFERENCE_PLANE_EQUATION_SGIX  0x817E
-#endif
-
-#ifndef GL_SGIX_flush_raster
-#endif
-
-#ifndef GL_SGIX_depth_texture
-#define GL_DEPTH_COMPONENT16_SGIX         0x81A5
-#define GL_DEPTH_COMPONENT24_SGIX         0x81A6
-#define GL_DEPTH_COMPONENT32_SGIX         0x81A7
-#endif
-
-#ifndef GL_SGIS_fog_function
-#define GL_FOG_FUNC_SGIS                  0x812A
-#define GL_FOG_FUNC_POINTS_SGIS           0x812B
-#define GL_MAX_FOG_FUNC_POINTS_SGIS       0x812C
-#endif
-
-#ifndef GL_SGIX_fog_offset
-#define GL_FOG_OFFSET_SGIX                0x8198
-#define GL_FOG_OFFSET_VALUE_SGIX          0x8199
-#endif
-
-#ifndef GL_HP_image_transform
-#define GL_IMAGE_SCALE_X_HP               0x8155
-#define GL_IMAGE_SCALE_Y_HP               0x8156
-#define GL_IMAGE_TRANSLATE_X_HP           0x8157
-#define GL_IMAGE_TRANSLATE_Y_HP           0x8158
-#define GL_IMAGE_ROTATE_ANGLE_HP          0x8159
-#define GL_IMAGE_ROTATE_ORIGIN_X_HP       0x815A
-#define GL_IMAGE_ROTATE_ORIGIN_Y_HP       0x815B
-#define GL_IMAGE_MAG_FILTER_HP            0x815C
-#define GL_IMAGE_MIN_FILTER_HP            0x815D
-#define GL_IMAGE_CUBIC_WEIGHT_HP          0x815E
-#define GL_CUBIC_HP                       0x815F
-#define GL_AVERAGE_HP                     0x8160
-#define GL_IMAGE_TRANSFORM_2D_HP          0x8161
-#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162
-#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163
-#endif
-
-#ifndef GL_HP_convolution_border_modes
-#define GL_IGNORE_BORDER_HP               0x8150
-#define GL_CONSTANT_BORDER_HP             0x8151
-#define GL_REPLICATE_BORDER_HP            0x8153
-#define GL_CONVOLUTION_BORDER_COLOR_HP    0x8154
-#endif
-
-#ifndef GL_INGR_palette_buffer
-#endif
-
-#ifndef GL_SGIX_texture_add_env
-#define GL_TEXTURE_ENV_BIAS_SGIX          0x80BE
-#endif
-
-#ifndef GL_EXT_color_subtable
-#endif
-
-#ifndef GL_PGI_vertex_hints
-#define GL_VERTEX_DATA_HINT_PGI           0x1A22A
-#define GL_VERTEX_CONSISTENT_HINT_PGI     0x1A22B
-#define GL_MATERIAL_SIDE_HINT_PGI         0x1A22C
-#define GL_MAX_VERTEX_HINT_PGI            0x1A22D
-#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_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_VERTEX23_BIT_PGI               0x00000004
-#define GL_VERTEX4_BIT_PGI                0x00000008
-#endif
-
-#ifndef GL_PGI_misc_hints
-#define GL_PREFER_DOUBLEBUFFER_HINT_PGI   0x1A1F8
-#define GL_CONSERVE_MEMORY_HINT_PGI       0x1A1FD
-#define GL_RECLAIM_MEMORY_HINT_PGI        0x1A1FE
-#define GL_NATIVE_GRAPHICS_HANDLE_PGI     0x1A202
-#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203
-#define GL_NATIVE_GRAPHICS_END_HINT_PGI   0x1A204
-#define GL_ALWAYS_FAST_HINT_PGI           0x1A20C
-#define GL_ALWAYS_SOFT_HINT_PGI           0x1A20D
-#define GL_ALLOW_DRAW_OBJ_HINT_PGI        0x1A20E
-#define GL_ALLOW_DRAW_WIN_HINT_PGI        0x1A20F
-#define GL_ALLOW_DRAW_FRG_HINT_PGI        0x1A210
-#define GL_ALLOW_DRAW_MEM_HINT_PGI        0x1A211
-#define GL_STRICT_DEPTHFUNC_HINT_PGI      0x1A216
-#define GL_STRICT_LIGHTING_HINT_PGI       0x1A217
-#define GL_STRICT_SCISSOR_HINT_PGI        0x1A218
-#define GL_FULL_STIPPLE_HINT_PGI          0x1A219
-#define GL_CLIP_NEAR_HINT_PGI             0x1A220
-#define GL_CLIP_FAR_HINT_PGI              0x1A221
-#define GL_WIDE_LINE_HINT_PGI             0x1A222
-#define GL_BACK_NORMALS_HINT_PGI          0x1A223
-#endif
-
-#ifndef GL_EXT_paletted_texture
-#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
-#endif
-
-#ifndef GL_EXT_clip_volume_hint
-#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT  0x80F0
-#endif
-
-#ifndef GL_SGIX_list_priority
-#define GL_LIST_PRIORITY_SGIX             0x8182
-#endif
-
-#ifndef GL_SGIX_ir_instrument1
-#define GL_IR_INSTRUMENT1_SGIX            0x817F
-#endif
-
-#ifndef GL_SGIX_calligraphic_fragment
-#define GL_CALLIGRAPHIC_FRAGMENT_SGIX     0x8183
-#endif
-
-#ifndef GL_SGIX_texture_lod_bias
-#define GL_TEXTURE_LOD_BIAS_S_SGIX        0x818E
-#define GL_TEXTURE_LOD_BIAS_T_SGIX        0x818F
-#define GL_TEXTURE_LOD_BIAS_R_SGIX        0x8190
-#endif
-
-#ifndef GL_SGIX_shadow_ambient
-#define GL_SHADOW_AMBIENT_SGIX            0x80BF
-#endif
-
-#ifndef GL_EXT_index_texture
-#endif
-
-#ifndef GL_EXT_index_material
-#define GL_INDEX_MATERIAL_EXT             0x81B8
-#define GL_INDEX_MATERIAL_PARAMETER_EXT   0x81B9
-#define GL_INDEX_MATERIAL_FACE_EXT        0x81BA
-#endif
-
-#ifndef GL_EXT_index_func
-#define GL_INDEX_TEST_EXT                 0x81B5
-#define GL_INDEX_TEST_FUNC_EXT            0x81B6
-#define GL_INDEX_TEST_REF_EXT             0x81B7
-#endif
-
-#ifndef GL_EXT_index_array_formats
-#define GL_IUI_V2F_EXT                    0x81AD
-#define GL_IUI_V3F_EXT                    0x81AE
-#define GL_IUI_N3F_V2F_EXT                0x81AF
-#define GL_IUI_N3F_V3F_EXT                0x81B0
-#define GL_T2F_IUI_V2F_EXT                0x81B1
-#define GL_T2F_IUI_V3F_EXT                0x81B2
-#define GL_T2F_IUI_N3F_V2F_EXT            0x81B3
-#define GL_T2F_IUI_N3F_V3F_EXT            0x81B4
-#endif
-
-#ifndef GL_EXT_compiled_vertex_array
-#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT   0x81A8
-#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT   0x81A9
-#endif
-
-#ifndef GL_EXT_cull_vertex
-#define GL_CULL_VERTEX_EXT                0x81AA
-#define GL_CULL_VERTEX_EYE_POSITION_EXT   0x81AB
-#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC
-#endif
-
-#ifndef GL_SGIX_ycrcb
-#define GL_YCRCB_422_SGIX                 0x81BB
-#define GL_YCRCB_444_SGIX                 0x81BC
-#endif
-
-#ifndef GL_SGIX_fragment_lighting
-#define GL_FRAGMENT_LIGHTING_SGIX         0x8400
-#define GL_FRAGMENT_COLOR_MATERIAL_SGIX   0x8401
-#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402
-#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403
-#define GL_MAX_FRAGMENT_LIGHTS_SGIX       0x8404
-#define GL_MAX_ACTIVE_LIGHTS_SGIX         0x8405
-#define GL_CURRENT_RASTER_NORMAL_SGIX     0x8406
-#define GL_LIGHT_ENV_MODE_SGIX            0x8407
-#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408
-#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409
-#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A
-#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B
-#define GL_FRAGMENT_LIGHT0_SGIX           0x840C
-#define GL_FRAGMENT_LIGHT1_SGIX           0x840D
-#define GL_FRAGMENT_LIGHT2_SGIX           0x840E
-#define GL_FRAGMENT_LIGHT3_SGIX           0x840F
-#define GL_FRAGMENT_LIGHT4_SGIX           0x8410
-#define GL_FRAGMENT_LIGHT5_SGIX           0x8411
-#define GL_FRAGMENT_LIGHT6_SGIX           0x8412
-#define GL_FRAGMENT_LIGHT7_SGIX           0x8413
-#endif
-
-#ifndef GL_IBM_rasterpos_clip
-#define GL_RASTER_POSITION_UNCLIPPED_IBM  0x19262
-#endif
-
-#ifndef GL_HP_texture_lighting
-#define GL_TEXTURE_LIGHTING_MODE_HP       0x8167
-#define GL_TEXTURE_POST_SPECULAR_HP       0x8168
-#define GL_TEXTURE_PRE_SPECULAR_HP        0x8169
-#endif
-
-#ifndef GL_EXT_draw_range_elements
-#define GL_MAX_ELEMENTS_VERTICES_EXT      0x80E8
-#define GL_MAX_ELEMENTS_INDICES_EXT       0x80E9
-#endif
-
-#ifndef GL_WIN_phong_shading
-#define GL_PHONG_WIN                      0x80EA
-#define GL_PHONG_HINT_WIN                 0x80EB
-#endif
-
-#ifndef GL_WIN_specular_fog
-#define GL_FOG_SPECULAR_TEXTURE_WIN       0x80EC
-#endif
-
-#ifndef GL_EXT_light_texture
-#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
-/* reuse GL_FRAGMENT_DEPTH_EXT */
-#endif
-
-#ifndef GL_SGIX_blend_alpha_minmax
-#define GL_ALPHA_MIN_SGIX                 0x8320
-#define GL_ALPHA_MAX_SGIX                 0x8321
-#endif
-
-#ifndef GL_SGIX_impact_pixel_texture
-#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX   0x8184
-#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX     0x8185
-#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX     0x8186
-#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187
-#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188
-#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX    0x8189
-#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX    0x818A
-#endif
-
-#ifndef GL_EXT_bgra
-#define GL_BGR_EXT                        0x80E0
-#define GL_BGRA_EXT                       0x80E1
-#endif
-
-#ifndef GL_SGIX_async
-#define GL_ASYNC_MARKER_SGIX              0x8329
-#endif
-
-#ifndef GL_SGIX_async_pixel
-#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
-#endif
-
-#ifndef GL_SGIX_async_histogram
-#define GL_ASYNC_HISTOGRAM_SGIX           0x832C
-#define GL_MAX_ASYNC_HISTOGRAM_SGIX       0x832D
-#endif
-
-#ifndef GL_INTEL_texture_scissor
-#endif
-
-#ifndef GL_INTEL_parallel_arrays
-#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
-#endif
-
-#ifndef GL_HP_occlusion_test
-#define GL_OCCLUSION_TEST_HP              0x8165
-#define GL_OCCLUSION_TEST_RESULT_HP       0x8166
-#endif
-
-#ifndef GL_EXT_pixel_transform
-#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
-#endif
-
-#ifndef GL_EXT_pixel_transform_color_table
-#endif
-
-#ifndef GL_EXT_shared_texture_palette
-#define GL_SHARED_TEXTURE_PALETTE_EXT     0x81FB
-#endif
-
-#ifndef GL_EXT_separate_specular_color
-#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT  0x81F8
-#define GL_SINGLE_COLOR_EXT               0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR_EXT    0x81FA
-#endif
-
-#ifndef GL_EXT_secondary_color
-#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
-#endif
-
-#ifndef GL_EXT_texture_perturb_normal
-#define GL_PERTURB_EXT                    0x85AE
-#define GL_TEXTURE_NORMAL_EXT             0x85AF
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#endif
-
-#ifndef GL_EXT_fog_coord
-#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
-#endif
-
-#ifndef GL_REND_screen_coordinates
-#define GL_SCREEN_COORDINATES_REND        0x8490
-#define GL_INVERTED_SCREEN_W_REND         0x8491
-#endif
-
-#ifndef GL_EXT_coordinate_frame
-#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
-#endif
-
-#ifndef GL_EXT_texture_env_combine
-#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
-#endif
-
-#ifndef GL_APPLE_specular_vector
-#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
-#endif
-
-#ifndef GL_APPLE_transform_hint
-#define GL_TRANSFORM_HINT_APPLE           0x85B1
-#endif
-
-#ifndef GL_SGIX_fog_scale
-#define GL_FOG_SCALE_SGIX                 0x81FC
-#define GL_FOG_SCALE_VALUE_SGIX           0x81FD
-#endif
-
-#ifndef GL_SUNX_constant_data
-#define GL_UNPACK_CONSTANT_DATA_SUNX      0x81D5
-#define GL_TEXTURE_CONSTANT_DATA_SUNX     0x81D6
-#endif
-
-#ifndef GL_SUN_global_alpha
-#define GL_GLOBAL_ALPHA_SUN               0x81D9
-#define GL_GLOBAL_ALPHA_FACTOR_SUN        0x81DA
-#endif
-
-#ifndef GL_SUN_triangle_list
-#define GL_RESTART_SUN                    0x0001
-#define GL_REPLACE_MIDDLE_SUN             0x0002
-#define GL_REPLACE_OLDEST_SUN             0x0003
-#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
-#endif
-
-#ifndef GL_SUN_vertex
-#endif
-
-#ifndef GL_EXT_blend_func_separate
-#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
-#endif
-
-#ifndef GL_INGR_color_clamp
-#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
-#endif
-
-#ifndef GL_INGR_interlace_read
-#define GL_INTERLACE_READ_INGR            0x8568
-#endif
-
-#ifndef GL_EXT_stencil_wrap
-#define GL_INCR_WRAP_EXT                  0x8507
-#define GL_DECR_WRAP_EXT                  0x8508
-#endif
-
-#ifndef GL_EXT_422_pixels
-#define GL_422_EXT                        0x80CC
-#define GL_422_REV_EXT                    0x80CD
-#define GL_422_AVERAGE_EXT                0x80CE
-#define GL_422_REV_AVERAGE_EXT            0x80CF
-#endif
-
-#ifndef GL_NV_texgen_reflection
-#define GL_NORMAL_MAP_NV                  0x8511
-#define GL_REFLECTION_MAP_NV              0x8512
-#endif
-
-#ifndef GL_EXT_texture_cube_map
-#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
-#endif
-
-#ifndef GL_SUN_convolution_border_modes
-#define GL_WRAP_BORDER_SUN                0x81D4
-#endif
-
-#ifndef GL_EXT_texture_env_add
-#endif
-
-#ifndef GL_EXT_texture_lod_bias
-#define GL_MAX_TEXTURE_LOD_BIAS_EXT       0x84FD
-#define GL_TEXTURE_FILTER_CONTROL_EXT     0x8500
-#define GL_TEXTURE_LOD_BIAS_EXT           0x8501
-#endif
-
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
-#endif
-
-#ifndef GL_EXT_vertex_weighting
-#define GL_MODELVIEW0_STACK_DEPTH_EXT     GL_MODELVIEW_STACK_DEPTH
-#define GL_MODELVIEW1_STACK_DEPTH_EXT     0x8502
-#define GL_MODELVIEW0_MATRIX_EXT          GL_MODELVIEW_MATRIX
-#define GL_MODELVIEW1_MATRIX_EXT          0x8506
-#define GL_VERTEX_WEIGHTING_EXT           0x8509
-#define GL_MODELVIEW0_EXT                 GL_MODELVIEW
-#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
-#endif
-
-#ifndef GL_NV_light_max_exponent
-#define GL_MAX_SHININESS_NV               0x8504
-#define GL_MAX_SPOT_EXPONENT_NV           0x8505
-#endif
-
-#ifndef GL_NV_vertex_array_range
-#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
-#endif
-
-#ifndef GL_NV_register_combiners
-#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
-/* reuse GL_TEXTURE0_ARB */
-/* reuse GL_TEXTURE1_ARB */
-/* reuse GL_ZERO */
-/* reuse GL_NONE */
-/* reuse GL_FOG */
-#endif
-
-#ifndef GL_NV_fog_distance
-#define GL_FOG_DISTANCE_MODE_NV           0x855A
-#define GL_EYE_RADIAL_NV                  0x855B
-#define GL_EYE_PLANE_ABSOLUTE_NV          0x855C
-/* reuse GL_EYE_PLANE */
-#endif
-
-#ifndef GL_NV_texgen_emboss
-#define GL_EMBOSS_LIGHT_NV                0x855D
-#define GL_EMBOSS_CONSTANT_NV             0x855E
-#define GL_EMBOSS_MAP_NV                  0x855F
-#endif
-
-#ifndef GL_NV_blend_square
-#endif
-
-#ifndef GL_NV_texture_env_combine4
-#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
-#endif
-
-#ifndef GL_MESA_resize_buffers
-#endif
-
-#ifndef GL_MESA_window_pos
-#endif
-
-#ifndef GL_EXT_texture_compression_s3tc
-#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
-#endif
-
-#ifndef GL_IBM_cull_vertex
-#define GL_CULL_VERTEX_IBM                103050
-#endif
-
-#ifndef GL_IBM_multimode_draw_arrays
-#endif
-
-#ifndef GL_IBM_vertex_array_lists
-#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
-#endif
-
-#ifndef GL_SGIX_subsample
-#define GL_PACK_SUBSAMPLE_RATE_SGIX       0x85A0
-#define GL_UNPACK_SUBSAMPLE_RATE_SGIX     0x85A1
-#define GL_PIXEL_SUBSAMPLE_4444_SGIX      0x85A2
-#define GL_PIXEL_SUBSAMPLE_2424_SGIX      0x85A3
-#define GL_PIXEL_SUBSAMPLE_4242_SGIX      0x85A4
-#endif
-
-#ifndef GL_SGIX_ycrcb_subsample
-#endif
-
-#ifndef GL_SGIX_ycrcba
-#define GL_YCRCB_SGIX                     0x8318
-#define GL_YCRCBA_SGIX                    0x8319
-#endif
-
-#ifndef GL_SGI_depth_pass_instrument
-#define GL_DEPTH_PASS_INSTRUMENT_SGIX     0x8310
-#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311
-#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312
-#endif
-
-#ifndef GL_3DFX_texture_compression_FXT1
-#define GL_COMPRESSED_RGB_FXT1_3DFX       0x86B0
-#define GL_COMPRESSED_RGBA_FXT1_3DFX      0x86B1
-#endif
-
-#ifndef GL_3DFX_multisample
-#define GL_MULTISAMPLE_3DFX               0x86B2
-#define GL_SAMPLE_BUFFERS_3DFX            0x86B3
-#define GL_SAMPLES_3DFX                   0x86B4
-#define GL_MULTISAMPLE_BIT_3DFX           0x20000000
-#endif
-
-#ifndef GL_3DFX_tbuffer
-#endif
-
-#ifndef GL_EXT_multisample
-#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
-#endif
-
-#ifndef GL_SGIX_vertex_preclip
-#define GL_VERTEX_PRECLIP_SGIX            0x83EE
-#define GL_VERTEX_PRECLIP_HINT_SGIX       0x83EF
-#endif
-
-#ifndef GL_SGIX_convolution_accuracy
-#define GL_CONVOLUTION_HINT_SGIX          0x8316
-#endif
-
-#ifndef GL_SGIX_resample
-#define GL_PACK_RESAMPLE_SGIX             0x842C
-#define GL_UNPACK_RESAMPLE_SGIX           0x842D
-#define GL_RESAMPLE_REPLICATE_SGIX        0x842E
-#define GL_RESAMPLE_ZERO_FILL_SGIX        0x842F
-#define GL_RESAMPLE_DECIMATE_SGIX         0x8430
-#endif
-
-#ifndef GL_SGIS_point_line_texgen
-#define GL_EYE_DISTANCE_TO_POINT_SGIS     0x81F0
-#define GL_OBJECT_DISTANCE_TO_POINT_SGIS  0x81F1
-#define GL_EYE_DISTANCE_TO_LINE_SGIS      0x81F2
-#define GL_OBJECT_DISTANCE_TO_LINE_SGIS   0x81F3
-#define GL_EYE_POINT_SGIS                 0x81F4
-#define GL_OBJECT_POINT_SGIS              0x81F5
-#define GL_EYE_LINE_SGIS                  0x81F6
-#define GL_OBJECT_LINE_SGIS               0x81F7
-#endif
-
-#ifndef GL_SGIS_texture_color_mask
-#define GL_TEXTURE_COLOR_WRITEMASK_SGIS   0x81EF
-#endif
-
-#ifndef GL_EXT_texture_env_dot3
-#define GL_DOT3_RGB_EXT                   0x8740
-#define GL_DOT3_RGBA_EXT                  0x8741
-#endif
-
-#ifndef GL_ATI_texture_mirror_once
-#define GL_MIRROR_CLAMP_ATI               0x8742
-#define GL_MIRROR_CLAMP_TO_EDGE_ATI       0x8743
-#endif
-
-#ifndef GL_NV_fence
-#define GL_ALL_COMPLETED_NV               0x84F2
-#define GL_FENCE_STATUS_NV                0x84F3
-#define GL_FENCE_CONDITION_NV             0x84F4
-#endif
-
-#ifndef GL_IBM_texture_mirrored_repeat
-#define GL_MIRRORED_REPEAT_IBM            0x8370
-#endif
-
-#ifndef GL_NV_evaluators
-#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
-#endif
-
-#ifndef GL_NV_packed_depth_stencil
-#define GL_DEPTH_STENCIL_NV               0x84F9
-#define GL_UNSIGNED_INT_24_8_NV           0x84FA
-#endif
-
-#ifndef GL_NV_register_combiners2
-#define GL_PER_STAGE_CONSTANTS_NV         0x8535
-#endif
-
-#ifndef GL_NV_texture_compression_vtc
-#endif
-
-#ifndef GL_NV_texture_rectangle
-#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
-#endif
-
-#ifndef GL_NV_texture_shader
-#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_OFFSET_TEXTURE_2D_MATRIX_NV    GL_OFFSET_TEXTURE_MATRIX_NV
-#define GL_OFFSET_TEXTURE_2D_SCALE_NV     GL_OFFSET_TEXTURE_SCALE_NV
-#define GL_OFFSET_TEXTURE_2D_BIAS_NV      GL_OFFSET_TEXTURE_BIAS_NV
-#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
-#endif
-
-#ifndef GL_NV_texture_shader2
-#define GL_DOT_PRODUCT_TEXTURE_3D_NV      0x86EF
-#endif
-
-#ifndef GL_NV_vertex_array_range2
-#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533
-#endif
-
-#ifndef GL_NV_vertex_program
-#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
-#endif
-
-#ifndef GL_SGIX_texture_coordinate_clamp
-#define GL_TEXTURE_MAX_CLAMP_S_SGIX       0x8369
-#define GL_TEXTURE_MAX_CLAMP_T_SGIX       0x836A
-#define GL_TEXTURE_MAX_CLAMP_R_SGIX       0x836B
-#endif
-
-#ifndef GL_SGIX_scalebias_hint
-#define GL_SCALEBIAS_HINT_SGIX            0x8322
-#endif
-
-#ifndef GL_OML_interlace
-#define GL_INTERLACE_OML                  0x8980
-#define GL_INTERLACE_READ_OML             0x8981
-#endif
-
-#ifndef GL_OML_subsample
-#define GL_FORMAT_SUBSAMPLE_24_24_OML     0x8982
-#define GL_FORMAT_SUBSAMPLE_244_244_OML   0x8983
-#endif
-
-#ifndef GL_OML_resample
-#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
-#endif
-
-#ifndef GL_NV_copy_depth_to_color
-#define GL_DEPTH_STENCIL_TO_RGBA_NV       0x886E
-#define GL_DEPTH_STENCIL_TO_BGRA_NV       0x886F
-#endif
-
-#ifndef GL_ATI_envmap_bumpmap
-#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
-#endif
-
-#ifndef GL_ATI_fragment_shader
-#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_REG_6_ATI                      0x8927
-#define GL_REG_7_ATI                      0x8928
-#define GL_REG_8_ATI                      0x8929
-#define GL_REG_9_ATI                      0x892A
-#define GL_REG_10_ATI                     0x892B
-#define GL_REG_11_ATI                     0x892C
-#define GL_REG_12_ATI                     0x892D
-#define GL_REG_13_ATI                     0x892E
-#define GL_REG_14_ATI                     0x892F
-#define GL_REG_15_ATI                     0x8930
-#define GL_REG_16_ATI                     0x8931
-#define GL_REG_17_ATI                     0x8932
-#define GL_REG_18_ATI                     0x8933
-#define GL_REG_19_ATI                     0x8934
-#define GL_REG_20_ATI                     0x8935
-#define GL_REG_21_ATI                     0x8936
-#define GL_REG_22_ATI                     0x8937
-#define GL_REG_23_ATI                     0x8938
-#define GL_REG_24_ATI                     0x8939
-#define GL_REG_25_ATI                     0x893A
-#define GL_REG_26_ATI                     0x893B
-#define GL_REG_27_ATI                     0x893C
-#define GL_REG_28_ATI                     0x893D
-#define GL_REG_29_ATI                     0x893E
-#define GL_REG_30_ATI                     0x893F
-#define GL_REG_31_ATI                     0x8940
-#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_CON_8_ATI                      0x8949
-#define GL_CON_9_ATI                      0x894A
-#define GL_CON_10_ATI                     0x894B
-#define GL_CON_11_ATI                     0x894C
-#define GL_CON_12_ATI                     0x894D
-#define GL_CON_13_ATI                     0x894E
-#define GL_CON_14_ATI                     0x894F
-#define GL_CON_15_ATI                     0x8950
-#define GL_CON_16_ATI                     0x8951
-#define GL_CON_17_ATI                     0x8952
-#define GL_CON_18_ATI                     0x8953
-#define GL_CON_19_ATI                     0x8954
-#define GL_CON_20_ATI                     0x8955
-#define GL_CON_21_ATI                     0x8956
-#define GL_CON_22_ATI                     0x8957
-#define GL_CON_23_ATI                     0x8958
-#define GL_CON_24_ATI                     0x8959
-#define GL_CON_25_ATI                     0x895A
-#define GL_CON_26_ATI                     0x895B
-#define GL_CON_27_ATI                     0x895C
-#define GL_CON_28_ATI                     0x895D
-#define GL_CON_29_ATI                     0x895E
-#define GL_CON_30_ATI                     0x895F
-#define GL_CON_31_ATI                     0x8960
-#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_RED_BIT_ATI                    0x00000001
-#define GL_GREEN_BIT_ATI                  0x00000002
-#define GL_BLUE_BIT_ATI                   0x00000004
-#define GL_2X_BIT_ATI                     0x00000001
-#define GL_4X_BIT_ATI                     0x00000002
-#define GL_8X_BIT_ATI                     0x00000004
-#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_COMP_BIT_ATI                   0x00000002
-#define GL_NEGATE_BIT_ATI                 0x00000004
-#define GL_BIAS_BIT_ATI                   0x00000008
-#endif
-
-#ifndef GL_ATI_pn_triangles
-#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
-#endif
-
-#ifndef GL_ATI_vertex_array_object
-#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
-#endif
-
-#ifndef GL_EXT_vertex_shader
-#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_LOCAL_CONSTANTS_EXT 0x87CC
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_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
-#endif
-
-#ifndef GL_ATI_vertex_streams
-#define GL_MAX_VERTEX_STREAMS_ATI         0x876B
-#define GL_VERTEX_STREAM0_ATI             0x876C
-#define GL_VERTEX_STREAM1_ATI             0x876D
-#define GL_VERTEX_STREAM2_ATI             0x876E
-#define GL_VERTEX_STREAM3_ATI             0x876F
-#define GL_VERTEX_STREAM4_ATI             0x8770
-#define GL_VERTEX_STREAM5_ATI             0x8771
-#define GL_VERTEX_STREAM6_ATI             0x8772
-#define GL_VERTEX_STREAM7_ATI             0x8773
-#define GL_VERTEX_SOURCE_ATI              0x8774
-#endif
-
-#ifndef GL_ATI_element_array
-#define GL_ELEMENT_ARRAY_ATI              0x8768
-#define GL_ELEMENT_ARRAY_TYPE_ATI         0x8769
-#define GL_ELEMENT_ARRAY_POINTER_ATI      0x876A
-#endif
-
-#ifndef GL_SUN_mesh_array
-#define GL_QUAD_MESH_SUN                  0x8614
-#define GL_TRIANGLE_MESH_SUN              0x8615
-#endif
-
-#ifndef GL_SUN_slice_accum
-#define GL_SLICE_ACCUM_SUN                0x85CC
-#endif
-
-#ifndef GL_NV_multisample_filter_hint
-#define GL_MULTISAMPLE_FILTER_HINT_NV     0x8534
-#endif
-
-#ifndef GL_NV_depth_clamp
-#define GL_DEPTH_CLAMP_NV                 0x864F
-#endif
-
-#ifndef GL_NV_occlusion_query
-#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
-#endif
-
-#ifndef GL_NV_point_sprite
-#define GL_POINT_SPRITE_NV                0x8861
-#define GL_COORD_REPLACE_NV               0x8862
-#define GL_POINT_SPRITE_R_MODE_NV         0x8863
-#endif
-
-#ifndef GL_NV_texture_shader3
-#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
-#endif
-
-#ifndef GL_NV_vertex_program1_1
-#endif
-
-#ifndef GL_EXT_shadow_funcs
-#endif
-
-#ifndef GL_EXT_stencil_two_side
-#define GL_STENCIL_TEST_TWO_SIDE_EXT      0x8910
-#define GL_ACTIVE_STENCIL_FACE_EXT        0x8911
-#endif
-
-#ifndef GL_ATI_text_fragment_shader
-#define GL_TEXT_FRAGMENT_SHADER_ATI       0x8200
-#endif
-
-#ifndef GL_APPLE_client_storage
-#define GL_UNPACK_CLIENT_STORAGE_APPLE    0x85B2
-#endif
-
-#ifndef GL_APPLE_element_array
-#define GL_ELEMENT_ARRAY_APPLE            0x8A0C
-#define GL_ELEMENT_ARRAY_TYPE_APPLE       0x8A0D
-#define GL_ELEMENT_ARRAY_POINTER_APPLE    0x8A0E
-#endif
-
-#ifndef GL_APPLE_fence
-#define GL_DRAW_PIXELS_APPLE              0x8A0A
-#define GL_FENCE_APPLE                    0x8A0B
-#endif
-
-#ifndef GL_APPLE_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING_APPLE     0x85B5
-#endif
-
-#ifndef GL_APPLE_vertex_array_range
-#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_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521
-#define GL_STORAGE_CLIENT_APPLE           0x85B4
-#define GL_STORAGE_CACHED_APPLE           0x85BE
-#define GL_STORAGE_SHARED_APPLE           0x85BF
-#endif
-
-#ifndef GL_APPLE_ycbcr_422
-#define GL_YCBCR_422_APPLE                0x85B9
-#define GL_UNSIGNED_SHORT_8_8_APPLE       0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_APPLE   0x85BB
-#endif
-
-#ifndef GL_S3_s3tc
-#define GL_RGB_S3TC                       0x83A0
-#define GL_RGB4_S3TC                      0x83A1
-#define GL_RGBA_S3TC                      0x83A2
-#define GL_RGBA4_S3TC                     0x83A3
-#endif
-
-#ifndef GL_ATI_draw_buffers
-#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
-#endif
-
-#ifndef GL_ATI_pixel_format_float
-#define GL_TYPE_RGBA_FLOAT_ATI            0x8820
-#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
-#endif
-
-#ifndef GL_ATI_texture_env_combine3
-#define GL_MODULATE_ADD_ATI               0x8744
-#define GL_MODULATE_SIGNED_ADD_ATI        0x8745
-#define GL_MODULATE_SUBTRACT_ATI          0x8746
-#endif
-
-#ifndef GL_ATI_texture_float
-#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
-#endif
-
-#ifndef GL_NV_float_buffer
-#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
-#endif
-
-#ifndef GL_NV_fragment_program
-#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
-#endif
-
-#ifndef GL_NV_half_float
-#define GL_HALF_FLOAT_NV                  0x140B
-#endif
-
-#ifndef GL_NV_pixel_data_range
-#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
-#endif
-
-#ifndef GL_NV_primitive_restart
-#define GL_PRIMITIVE_RESTART_NV           0x8558
-#define GL_PRIMITIVE_RESTART_INDEX_NV     0x8559
-#endif
-
-#ifndef GL_NV_texture_expand_normal
-#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F
-#endif
-
-#ifndef GL_NV_vertex_program2
-#endif
-
-#ifndef GL_ATI_map_object_buffer
-#endif
-
-#ifndef GL_ATI_separate_stencil
-#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
-#endif
-
-#ifndef GL_ATI_vertex_attrib_array_object
-#endif
-
-#ifndef GL_OES_read_format
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
-#endif
-
-#ifndef GL_EXT_depth_bounds_test
-#define GL_DEPTH_BOUNDS_TEST_EXT          0x8890
-#define GL_DEPTH_BOUNDS_EXT               0x8891
-#endif
-
-#ifndef GL_EXT_texture_mirror_clamp
-#define GL_MIRROR_CLAMP_EXT               0x8742
-#define GL_MIRROR_CLAMP_TO_EDGE_EXT       0x8743
-#define GL_MIRROR_CLAMP_TO_BORDER_EXT     0x8912
-#endif
-
-#ifndef GL_EXT_blend_equation_separate
-#define GL_BLEND_EQUATION_RGB_EXT         0x8009
-#define GL_BLEND_EQUATION_ALPHA_EXT       0x883D
-#endif
-
-#ifndef GL_MESA_pack_invert
-#define GL_PACK_INVERT_MESA               0x8758
-#endif
-
-#ifndef GL_MESA_ycbcr_texture
-#define GL_UNSIGNED_SHORT_8_8_MESA        0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_MESA    0x85BB
-#define GL_YCBCR_MESA                     0x8757
-#endif
-
-#ifndef GL_EXT_pixel_buffer_object
-#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
-#endif
-
-#ifndef GL_NV_fragment_program_option
-#endif
-
-#ifndef GL_NV_fragment_program2
-#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
-#endif
-
-#ifndef GL_NV_vertex_program2_option
-/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
-/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */
-#endif
-
-#ifndef GL_NV_vertex_program3
-/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
-#endif
-
-#ifndef GL_EXT_framebuffer_object
-#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
-#endif
-
-#ifndef GL_GREMEDY_string_marker
-#endif
-
-#ifndef GL_EXT_packed_depth_stencil
-#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
-#endif
-
-#ifndef GL_EXT_stencil_clear_tag
-#define GL_STENCIL_TAG_BITS_EXT           0x88F2
-#define GL_STENCIL_CLEAR_TAG_VALUE_EXT    0x88F3
-#endif
-
-#ifndef GL_EXT_texture_sRGB
-#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
-#endif
-
-#ifndef GL_EXT_framebuffer_blit
-#define GL_READ_FRAMEBUFFER_EXT           0x8CA8
-#define GL_DRAW_FRAMEBUFFER_EXT           0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_EXT   GL_FRAMEBUFFER_BINDING_EXT
-#define GL_READ_FRAMEBUFFER_BINDING_EXT   0x8CAA
-#endif
-
-#ifndef GL_EXT_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_EXT       0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
-#define GL_MAX_SAMPLES_EXT                0x8D57
-#endif
-
-#ifndef GL_MESAX_texture_stack
-#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
-#endif
-
-#ifndef GL_EXT_timer_query
-#define GL_TIME_ELAPSED_EXT               0x88BF
-#endif
-
-#ifndef GL_EXT_gpu_program_parameters
-#endif
-
-#ifndef GL_APPLE_flush_buffer_range
-#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12
-#define GL_BUFFER_FLUSHING_UNMAP_APPLE    0x8A13
-#endif
-
-#ifndef GL_NV_gpu_program4
-#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV    0x8904
-#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV    0x8905
-#define GL_PROGRAM_ATTRIB_COMPONENTS_NV   0x8906
-#define GL_PROGRAM_RESULT_COMPONENTS_NV   0x8907
-#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908
-#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909
-#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5
-#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6
-#endif
-
-#ifndef GL_NV_geometry_program4
-#define GL_LINES_ADJACENCY_EXT            0x000A
-#define GL_LINE_STRIP_ADJACENCY_EXT       0x000B
-#define GL_TRIANGLES_ADJACENCY_EXT        0x000C
-#define GL_TRIANGLE_STRIP_ADJACENCY_EXT   0x000D
-#define GL_GEOMETRY_PROGRAM_NV            0x8C26
-#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27
-#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28
-#define GL_GEOMETRY_VERTICES_OUT_EXT      0x8DDA
-#define GL_GEOMETRY_INPUT_TYPE_EXT        0x8DDB
-#define GL_GEOMETRY_OUTPUT_TYPE_EXT       0x8DDC
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
-#define GL_PROGRAM_POINT_SIZE_EXT         0x8642
-#endif
-
-#ifndef GL_EXT_geometry_shader4
-#define GL_GEOMETRY_SHADER_EXT            0x8DD9
-/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */
-/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */
-/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */
-/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */
-#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD
-#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE
-#define GL_MAX_VARYING_COMPONENTS_EXT     0x8B4B
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
-/* reuse GL_LINES_ADJACENCY_EXT */
-/* reuse GL_LINE_STRIP_ADJACENCY_EXT */
-/* reuse GL_TRIANGLES_ADJACENCY_EXT */
-/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */
-/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */
-/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
-/* reuse GL_PROGRAM_POINT_SIZE_EXT */
-#endif
-
-#ifndef GL_NV_vertex_program4
-#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD
-#endif
-
-#ifndef GL_EXT_gpu_shader4
-#define GL_SAMPLER_1D_ARRAY_EXT           0x8DC0
-#define GL_SAMPLER_2D_ARRAY_EXT           0x8DC1
-#define GL_SAMPLER_BUFFER_EXT             0x8DC2
-#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT    0x8DC3
-#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT    0x8DC4
-#define GL_SAMPLER_CUBE_SHADOW_EXT        0x8DC5
-#define GL_UNSIGNED_INT_VEC2_EXT          0x8DC6
-#define GL_UNSIGNED_INT_VEC3_EXT          0x8DC7
-#define GL_UNSIGNED_INT_VEC4_EXT          0x8DC8
-#define GL_INT_SAMPLER_1D_EXT             0x8DC9
-#define GL_INT_SAMPLER_2D_EXT             0x8DCA
-#define GL_INT_SAMPLER_3D_EXT             0x8DCB
-#define GL_INT_SAMPLER_CUBE_EXT           0x8DCC
-#define GL_INT_SAMPLER_2D_RECT_EXT        0x8DCD
-#define GL_INT_SAMPLER_1D_ARRAY_EXT       0x8DCE
-#define GL_INT_SAMPLER_2D_ARRAY_EXT       0x8DCF
-#define GL_INT_SAMPLER_BUFFER_EXT         0x8DD0
-#define GL_UNSIGNED_INT_SAMPLER_1D_EXT    0x8DD1
-#define GL_UNSIGNED_INT_SAMPLER_2D_EXT    0x8DD2
-#define GL_UNSIGNED_INT_SAMPLER_3D_EXT    0x8DD3
-#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT  0x8DD4
-#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5
-#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7
-#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
-#endif
-
-#ifndef GL_EXT_draw_instanced
-#endif
-
-#ifndef GL_EXT_packed_float
-#define GL_R11F_G11F_B10F_EXT             0x8C3A
-#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B
-#define GL_RGBA_SIGNED_COMPONENTS_EXT     0x8C3C
-#endif
-
-#ifndef GL_EXT_texture_array
-#define GL_TEXTURE_1D_ARRAY_EXT           0x8C18
-#define GL_PROXY_TEXTURE_1D_ARRAY_EXT     0x8C19
-#define GL_TEXTURE_2D_ARRAY_EXT           0x8C1A
-#define GL_PROXY_TEXTURE_2D_ARRAY_EXT     0x8C1B
-#define GL_TEXTURE_BINDING_1D_ARRAY_EXT   0x8C1C
-#define GL_TEXTURE_BINDING_2D_ARRAY_EXT   0x8C1D
-#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT   0x88FF
-#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E
-/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
-#endif
-
-#ifndef GL_EXT_texture_buffer_object
-#define GL_TEXTURE_BUFFER_EXT             0x8C2A
-#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT    0x8C2B
-#define GL_TEXTURE_BINDING_BUFFER_EXT     0x8C2C
-#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
-#define GL_TEXTURE_BUFFER_FORMAT_EXT      0x8C2E
-#endif
-
-#ifndef GL_EXT_texture_compression_latc
-#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70
-#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71
-#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72
-#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73
-#endif
-
-#ifndef GL_EXT_texture_compression_rgtc
-#define GL_COMPRESSED_RED_RGTC1_EXT       0x8DBB
-#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
-#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
-#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
-#endif
-
-#ifndef GL_EXT_texture_shared_exponent
-#define GL_RGB9_E5_EXT                    0x8C3D
-#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT   0x8C3E
-#define GL_TEXTURE_SHARED_SIZE_EXT        0x8C3F
-#endif
-
-#ifndef GL_NV_depth_buffer_float
-#define GL_DEPTH_COMPONENT32F_NV          0x8DAB
-#define GL_DEPTH32F_STENCIL8_NV           0x8DAC
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD
-#define GL_DEPTH_BUFFER_FLOAT_MODE_NV     0x8DAF
-#endif
-
-#ifndef GL_NV_fragment_program4
-#endif
-
-#ifndef GL_NV_framebuffer_multisample_coverage
-#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB
-#define GL_RENDERBUFFER_COLOR_SAMPLES_NV  0x8E10
-#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
-#define GL_MULTISAMPLE_COVERAGE_MODES_NV  0x8E12
-#endif
-
-#ifndef GL_EXT_framebuffer_sRGB
-#define GL_FRAMEBUFFER_SRGB_EXT           0x8DB9
-#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT   0x8DBA
-#endif
-
-#ifndef GL_NV_geometry_shader4
-#endif
-
-#ifndef GL_NV_parameter_buffer_object
-#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0
-#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1
-#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2
-#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3
-#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4
-#endif
-
-#ifndef GL_EXT_draw_buffers2
-#endif
-
-#ifndef GL_NV_transform_feedback
-#define GL_BACK_PRIMARY_COLOR_NV          0x8C77
-#define GL_BACK_SECONDARY_COLOR_NV        0x8C78
-#define GL_TEXTURE_COORD_NV               0x8C79
-#define GL_CLIP_DISTANCE_NV               0x8C7A
-#define GL_VERTEX_ID_NV                   0x8C7B
-#define GL_PRIMITIVE_ID_NV                0x8C7C
-#define GL_GENERIC_ATTRIB_NV              0x8C7D
-#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV  0x8C7E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80
-#define GL_ACTIVE_VARYINGS_NV             0x8C81
-#define GL_ACTIVE_VARYING_MAX_LENGTH_NV   0x8C82
-#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85
-#define GL_TRANSFORM_FEEDBACK_RECORD_NV   0x8C86
-#define GL_PRIMITIVES_GENERATED_NV        0x8C87
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88
-#define GL_RASTERIZER_DISCARD_NV          0x8C89
-#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B
-#define GL_INTERLEAVED_ATTRIBS_NV         0x8C8C
-#define GL_SEPARATE_ATTRIBS_NV            0x8C8D
-#define GL_TRANSFORM_FEEDBACK_BUFFER_NV   0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F
-#define GL_LAYER_NV                       0x8DAA
-#define GL_NEXT_BUFFER_NV                 -2
-#define GL_SKIP_COMPONENTS4_NV            -3
-#define GL_SKIP_COMPONENTS3_NV            -4
-#define GL_SKIP_COMPONENTS2_NV            -5
-#define GL_SKIP_COMPONENTS1_NV            -6
-#endif
-
-#ifndef GL_EXT_bindable_uniform
-#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2
-#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3
-#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4
-#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT  0x8DED
-#define GL_UNIFORM_BUFFER_EXT             0x8DEE
-#define GL_UNIFORM_BUFFER_BINDING_EXT     0x8DEF
-#endif
-
-#ifndef GL_EXT_texture_integer
-#define GL_RGBA32UI_EXT                   0x8D70
-#define GL_RGB32UI_EXT                    0x8D71
-#define GL_ALPHA32UI_EXT                  0x8D72
-#define GL_INTENSITY32UI_EXT              0x8D73
-#define GL_LUMINANCE32UI_EXT              0x8D74
-#define GL_LUMINANCE_ALPHA32UI_EXT        0x8D75
-#define GL_RGBA16UI_EXT                   0x8D76
-#define GL_RGB16UI_EXT                    0x8D77
-#define GL_ALPHA16UI_EXT                  0x8D78
-#define GL_INTENSITY16UI_EXT              0x8D79
-#define GL_LUMINANCE16UI_EXT              0x8D7A
-#define GL_LUMINANCE_ALPHA16UI_EXT        0x8D7B
-#define GL_RGBA8UI_EXT                    0x8D7C
-#define GL_RGB8UI_EXT                     0x8D7D
-#define GL_ALPHA8UI_EXT                   0x8D7E
-#define GL_INTENSITY8UI_EXT               0x8D7F
-#define GL_LUMINANCE8UI_EXT               0x8D80
-#define GL_LUMINANCE_ALPHA8UI_EXT         0x8D81
-#define GL_RGBA32I_EXT                    0x8D82
-#define GL_RGB32I_EXT                     0x8D83
-#define GL_ALPHA32I_EXT                   0x8D84
-#define GL_INTENSITY32I_EXT               0x8D85
-#define GL_LUMINANCE32I_EXT               0x8D86
-#define GL_LUMINANCE_ALPHA32I_EXT         0x8D87
-#define GL_RGBA16I_EXT                    0x8D88
-#define GL_RGB16I_EXT                     0x8D89
-#define GL_ALPHA16I_EXT                   0x8D8A
-#define GL_INTENSITY16I_EXT               0x8D8B
-#define GL_LUMINANCE16I_EXT               0x8D8C
-#define GL_LUMINANCE_ALPHA16I_EXT         0x8D8D
-#define GL_RGBA8I_EXT                     0x8D8E
-#define GL_RGB8I_EXT                      0x8D8F
-#define GL_ALPHA8I_EXT                    0x8D90
-#define GL_INTENSITY8I_EXT                0x8D91
-#define GL_LUMINANCE8I_EXT                0x8D92
-#define GL_LUMINANCE_ALPHA8I_EXT          0x8D93
-#define GL_RED_INTEGER_EXT                0x8D94
-#define GL_GREEN_INTEGER_EXT              0x8D95
-#define GL_BLUE_INTEGER_EXT               0x8D96
-#define GL_ALPHA_INTEGER_EXT              0x8D97
-#define GL_RGB_INTEGER_EXT                0x8D98
-#define GL_RGBA_INTEGER_EXT               0x8D99
-#define GL_BGR_INTEGER_EXT                0x8D9A
-#define GL_BGRA_INTEGER_EXT               0x8D9B
-#define GL_LUMINANCE_INTEGER_EXT          0x8D9C
-#define GL_LUMINANCE_ALPHA_INTEGER_EXT    0x8D9D
-#define GL_RGBA_INTEGER_MODE_EXT          0x8D9E
-#endif
-
-#ifndef GL_GREMEDY_frame_terminator
-#endif
-
-#ifndef GL_NV_conditional_render
-#define GL_QUERY_WAIT_NV                  0x8E13
-#define GL_QUERY_NO_WAIT_NV               0x8E14
-#define GL_QUERY_BY_REGION_WAIT_NV        0x8E15
-#define GL_QUERY_BY_REGION_NO_WAIT_NV     0x8E16
-#endif
-
-#ifndef GL_NV_present_video
-#define GL_FRAME_NV                       0x8E26
-#define GL_FIELDS_NV                      0x8E27
-#define GL_CURRENT_TIME_NV                0x8E28
-#define GL_NUM_FILL_STREAMS_NV            0x8E29
-#define GL_PRESENT_TIME_NV                0x8E2A
-#define GL_PRESENT_DURATION_NV            0x8E2B
-#endif
-
-#ifndef GL_EXT_transform_feedback
-#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT  0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F
-#define GL_INTERLEAVED_ATTRIBS_EXT        0x8C8C
-#define GL_SEPARATE_ATTRIBS_EXT           0x8C8D
-#define GL_PRIMITIVES_GENERATED_EXT       0x8C87
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88
-#define GL_RASTERIZER_DISCARD_EXT         0x8C89
-#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80
-#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F
-#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76
-#endif
-
-#ifndef GL_EXT_direct_state_access
-#define GL_PROGRAM_MATRIX_EXT             0x8E2D
-#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT   0x8E2E
-#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F
-#endif
-
-#ifndef GL_EXT_vertex_array_bgra
-/* reuse GL_BGRA */
-#endif
-
-#ifndef GL_EXT_texture_swizzle
-#define GL_TEXTURE_SWIZZLE_R_EXT          0x8E42
-#define GL_TEXTURE_SWIZZLE_G_EXT          0x8E43
-#define GL_TEXTURE_SWIZZLE_B_EXT          0x8E44
-#define GL_TEXTURE_SWIZZLE_A_EXT          0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA_EXT       0x8E46
-#endif
-
-#ifndef GL_NV_explicit_multisample
-#define GL_SAMPLE_POSITION_NV             0x8E50
-#define GL_SAMPLE_MASK_NV                 0x8E51
-#define GL_SAMPLE_MASK_VALUE_NV           0x8E52
-#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53
-#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54
-#define GL_TEXTURE_RENDERBUFFER_NV        0x8E55
-#define GL_SAMPLER_RENDERBUFFER_NV        0x8E56
-#define GL_INT_SAMPLER_RENDERBUFFER_NV    0x8E57
-#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58
-#define GL_MAX_SAMPLE_MASK_WORDS_NV       0x8E59
-#endif
-
-#ifndef GL_NV_transform_feedback2
-#define GL_TRANSFORM_FEEDBACK_NV          0x8E22
-#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23
-#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24
-#define GL_TRANSFORM_FEEDBACK_BINDING_NV  0x8E25
-#endif
-
-#ifndef GL_ATI_meminfo
-#define GL_VBO_FREE_MEMORY_ATI            0x87FB
-#define GL_TEXTURE_FREE_MEMORY_ATI        0x87FC
-#define GL_RENDERBUFFER_FREE_MEMORY_ATI   0x87FD
-#endif
-
-#ifndef GL_AMD_performance_monitor
-#define GL_COUNTER_TYPE_AMD               0x8BC0
-#define GL_COUNTER_RANGE_AMD              0x8BC1
-#define GL_UNSIGNED_INT64_AMD             0x8BC2
-#define GL_PERCENTAGE_AMD                 0x8BC3
-#define GL_PERFMON_RESULT_AVAILABLE_AMD   0x8BC4
-#define GL_PERFMON_RESULT_SIZE_AMD        0x8BC5
-#define GL_PERFMON_RESULT_AMD             0x8BC6
-#endif
-
-#ifndef GL_AMD_texture_texture4
-#endif
-
-#ifndef GL_AMD_vertex_shader_tesselator
-#define GL_SAMPLER_BUFFER_AMD             0x9001
-#define GL_INT_SAMPLER_BUFFER_AMD         0x9002
-#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003
-#define GL_TESSELLATION_MODE_AMD          0x9004
-#define GL_TESSELLATION_FACTOR_AMD        0x9005
-#define GL_DISCRETE_AMD                   0x9006
-#define GL_CONTINUOUS_AMD                 0x9007
-#endif
-
-#ifndef GL_EXT_provoking_vertex
-#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C
-#define GL_FIRST_VERTEX_CONVENTION_EXT    0x8E4D
-#define GL_LAST_VERTEX_CONVENTION_EXT     0x8E4E
-#define GL_PROVOKING_VERTEX_EXT           0x8E4F
-#endif
-
-#ifndef GL_EXT_texture_snorm
-#define GL_ALPHA_SNORM                    0x9010
-#define GL_LUMINANCE_SNORM                0x9011
-#define GL_LUMINANCE_ALPHA_SNORM          0x9012
-#define GL_INTENSITY_SNORM                0x9013
-#define GL_ALPHA8_SNORM                   0x9014
-#define GL_LUMINANCE8_SNORM               0x9015
-#define GL_LUMINANCE8_ALPHA8_SNORM        0x9016
-#define GL_INTENSITY8_SNORM               0x9017
-#define GL_ALPHA16_SNORM                  0x9018
-#define GL_LUMINANCE16_SNORM              0x9019
-#define GL_LUMINANCE16_ALPHA16_SNORM      0x901A
-#define GL_INTENSITY16_SNORM              0x901B
-/* reuse GL_RED_SNORM */
-/* reuse GL_RG_SNORM */
-/* reuse GL_RGB_SNORM */
-/* reuse GL_RGBA_SNORM */
-/* reuse GL_R8_SNORM */
-/* reuse GL_RG8_SNORM */
-/* reuse GL_RGB8_SNORM */
-/* reuse GL_RGBA8_SNORM */
-/* reuse GL_R16_SNORM */
-/* reuse GL_RG16_SNORM */
-/* reuse GL_RGB16_SNORM */
-/* reuse GL_RGBA16_SNORM */
-/* reuse GL_SIGNED_NORMALIZED */
-#endif
-
-#ifndef GL_AMD_draw_buffers_blend
-#endif
-
-#ifndef GL_APPLE_texture_range
-#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
-/* reuse GL_STORAGE_CACHED_APPLE */
-/* reuse GL_STORAGE_SHARED_APPLE */
-#endif
-
-#ifndef GL_APPLE_float_pixels
-#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
-#endif
-
-#ifndef GL_APPLE_vertex_program_evaluators
-#define GL_VERTEX_ATTRIB_MAP1_APPLE       0x8A00
-#define GL_VERTEX_ATTRIB_MAP2_APPLE       0x8A01
-#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE  0x8A02
-#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03
-#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04
-#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05
-#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE  0x8A06
-#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07
-#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08
-#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09
-#endif
-
-#ifndef GL_APPLE_aux_depth_stencil
-#define GL_AUX_DEPTH_STENCIL_APPLE        0x8A14
-#endif
-
-#ifndef GL_APPLE_object_purgeable
-#define GL_BUFFER_OBJECT_APPLE            0x85B3
-#define GL_RELEASED_APPLE                 0x8A19
-#define GL_VOLATILE_APPLE                 0x8A1A
-#define GL_RETAINED_APPLE                 0x8A1B
-#define GL_UNDEFINED_APPLE                0x8A1C
-#define GL_PURGEABLE_APPLE                0x8A1D
-#endif
-
-#ifndef GL_APPLE_row_bytes
-#define GL_PACK_ROW_BYTES_APPLE           0x8A15
-#define GL_UNPACK_ROW_BYTES_APPLE         0x8A16
-#endif
-
-#ifndef GL_APPLE_rgb_422
-#define GL_RGB_422_APPLE                  0x8A1F
-/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */
-/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */
-#endif
-
-#ifndef GL_NV_video_capture
-#define GL_VIDEO_BUFFER_NV                0x9020
-#define GL_VIDEO_BUFFER_BINDING_NV        0x9021
-#define GL_FIELD_UPPER_NV                 0x9022
-#define GL_FIELD_LOWER_NV                 0x9023
-#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV   0x9024
-#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025
-#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026
-#define GL_LAST_VIDEO_CAPTURE_STATUS_NV   0x9027
-#define GL_VIDEO_BUFFER_PITCH_NV          0x9028
-#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029
-#define GL_VIDEO_COLOR_CONVERSION_MAX_NV  0x902A
-#define GL_VIDEO_COLOR_CONVERSION_MIN_NV  0x902B
-#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C
-#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D
-#define GL_PARTIAL_SUCCESS_NV             0x902E
-#define GL_SUCCESS_NV                     0x902F
-#define GL_FAILURE_NV                     0x9030
-#define GL_YCBYCR8_422_NV                 0x9031
-#define GL_YCBAYCR8A_4224_NV              0x9032
-#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV  0x9033
-#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034
-#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV  0x9035
-#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036
-#define GL_Z4Y12Z4CB12Z4CR12_444_NV       0x9037
-#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV   0x9038
-#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV  0x9039
-#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A
-#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B
-#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C
-#endif
-
-#ifndef GL_NV_copy_image
-#endif
-
-#ifndef GL_EXT_separate_shader_objects
-#define GL_ACTIVE_PROGRAM_EXT             0x8B8D
-#endif
-
-#ifndef GL_NV_parameter_buffer_object2
-#endif
-
-#ifndef GL_NV_shader_buffer_load
-#define GL_BUFFER_GPU_ADDRESS_NV          0x8F1D
-#define GL_GPU_ADDRESS_NV                 0x8F34
-#define GL_MAX_SHADER_BUFFER_ADDRESS_NV   0x8F35
-#endif
-
-#ifndef GL_NV_vertex_buffer_unified_memory
-#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E
-#define GL_ELEMENT_ARRAY_UNIFIED_NV       0x8F1F
-#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20
-#define GL_VERTEX_ARRAY_ADDRESS_NV        0x8F21
-#define GL_NORMAL_ARRAY_ADDRESS_NV        0x8F22
-#define GL_COLOR_ARRAY_ADDRESS_NV         0x8F23
-#define GL_INDEX_ARRAY_ADDRESS_NV         0x8F24
-#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25
-#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV     0x8F26
-#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27
-#define GL_FOG_COORD_ARRAY_ADDRESS_NV     0x8F28
-#define GL_ELEMENT_ARRAY_ADDRESS_NV       0x8F29
-#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV  0x8F2A
-#define GL_VERTEX_ARRAY_LENGTH_NV         0x8F2B
-#define GL_NORMAL_ARRAY_LENGTH_NV         0x8F2C
-#define GL_COLOR_ARRAY_LENGTH_NV          0x8F2D
-#define GL_INDEX_ARRAY_LENGTH_NV          0x8F2E
-#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV  0x8F2F
-#define GL_EDGE_FLAG_ARRAY_LENGTH_NV      0x8F30
-#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31
-#define GL_FOG_COORD_ARRAY_LENGTH_NV      0x8F32
-#define GL_ELEMENT_ARRAY_LENGTH_NV        0x8F33
-#define GL_DRAW_INDIRECT_UNIFIED_NV       0x8F40
-#define GL_DRAW_INDIRECT_ADDRESS_NV       0x8F41
-#define GL_DRAW_INDIRECT_LENGTH_NV        0x8F42
-#endif
-
-#ifndef GL_NV_texture_barrier
-#endif
-
-#ifndef GL_AMD_shader_stencil_export
-#endif
-
-#ifndef GL_AMD_seamless_cubemap_per_texture
-/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
-#endif
-
-#ifndef GL_AMD_conservative_depth
-#endif
-
-#ifndef GL_EXT_shader_image_load_store
-#define GL_MAX_IMAGE_UNITS_EXT            0x8F38
-#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39
-#define GL_IMAGE_BINDING_NAME_EXT         0x8F3A
-#define GL_IMAGE_BINDING_LEVEL_EXT        0x8F3B
-#define GL_IMAGE_BINDING_LAYERED_EXT      0x8F3C
-#define GL_IMAGE_BINDING_LAYER_EXT        0x8F3D
-#define GL_IMAGE_BINDING_ACCESS_EXT       0x8F3E
-#define GL_IMAGE_1D_EXT                   0x904C
-#define GL_IMAGE_2D_EXT                   0x904D
-#define GL_IMAGE_3D_EXT                   0x904E
-#define GL_IMAGE_2D_RECT_EXT              0x904F
-#define GL_IMAGE_CUBE_EXT                 0x9050
-#define GL_IMAGE_BUFFER_EXT               0x9051
-#define GL_IMAGE_1D_ARRAY_EXT             0x9052
-#define GL_IMAGE_2D_ARRAY_EXT             0x9053
-#define GL_IMAGE_CUBE_MAP_ARRAY_EXT       0x9054
-#define GL_IMAGE_2D_MULTISAMPLE_EXT       0x9055
-#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056
-#define GL_INT_IMAGE_1D_EXT               0x9057
-#define GL_INT_IMAGE_2D_EXT               0x9058
-#define GL_INT_IMAGE_3D_EXT               0x9059
-#define GL_INT_IMAGE_2D_RECT_EXT          0x905A
-#define GL_INT_IMAGE_CUBE_EXT             0x905B
-#define GL_INT_IMAGE_BUFFER_EXT           0x905C
-#define GL_INT_IMAGE_1D_ARRAY_EXT         0x905D
-#define GL_INT_IMAGE_2D_ARRAY_EXT         0x905E
-#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT   0x905F
-#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT   0x9060
-#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061
-#define GL_UNSIGNED_INT_IMAGE_1D_EXT      0x9062
-#define GL_UNSIGNED_INT_IMAGE_2D_EXT      0x9063
-#define GL_UNSIGNED_INT_IMAGE_3D_EXT      0x9064
-#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065
-#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT    0x9066
-#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT  0x9067
-#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068
-#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069
-#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
-#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B
-#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C
-#define GL_MAX_IMAGE_SAMPLES_EXT          0x906D
-#define GL_IMAGE_BINDING_FORMAT_EXT       0x906E
-#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001
-#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT  0x00000002
-#define GL_UNIFORM_BARRIER_BIT_EXT        0x00000004
-#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT  0x00000008
-#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020
-#define GL_COMMAND_BARRIER_BIT_EXT        0x00000040
-#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT   0x00000080
-#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100
-#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT  0x00000200
-#define GL_FRAMEBUFFER_BARRIER_BIT_EXT    0x00000400
-#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800
-#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000
-#define GL_ALL_BARRIER_BITS_EXT           0xFFFFFFFF
-#endif
-
-#ifndef GL_EXT_vertex_attrib_64bit
-/* reuse GL_DOUBLE */
-#define GL_DOUBLE_VEC2_EXT                0x8FFC
-#define GL_DOUBLE_VEC3_EXT                0x8FFD
-#define GL_DOUBLE_VEC4_EXT                0x8FFE
-#define GL_DOUBLE_MAT2_EXT                0x8F46
-#define GL_DOUBLE_MAT3_EXT                0x8F47
-#define GL_DOUBLE_MAT4_EXT                0x8F48
-#define GL_DOUBLE_MAT2x3_EXT              0x8F49
-#define GL_DOUBLE_MAT2x4_EXT              0x8F4A
-#define GL_DOUBLE_MAT3x2_EXT              0x8F4B
-#define GL_DOUBLE_MAT3x4_EXT              0x8F4C
-#define GL_DOUBLE_MAT4x2_EXT              0x8F4D
-#define GL_DOUBLE_MAT4x3_EXT              0x8F4E
-#endif
-
-#ifndef GL_NV_gpu_program5
-#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A
-#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B
-#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C
-#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D
-#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E
-#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F
-#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44
-#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV  0x8F45
-#endif
-
-#ifndef GL_NV_gpu_shader5
-#define GL_INT64_NV                       0x140E
-#define GL_UNSIGNED_INT64_NV              0x140F
-#define GL_INT8_NV                        0x8FE0
-#define GL_INT8_VEC2_NV                   0x8FE1
-#define GL_INT8_VEC3_NV                   0x8FE2
-#define GL_INT8_VEC4_NV                   0x8FE3
-#define GL_INT16_NV                       0x8FE4
-#define GL_INT16_VEC2_NV                  0x8FE5
-#define GL_INT16_VEC3_NV                  0x8FE6
-#define GL_INT16_VEC4_NV                  0x8FE7
-#define GL_INT64_VEC2_NV                  0x8FE9
-#define GL_INT64_VEC3_NV                  0x8FEA
-#define GL_INT64_VEC4_NV                  0x8FEB
-#define GL_UNSIGNED_INT8_NV               0x8FEC
-#define GL_UNSIGNED_INT8_VEC2_NV          0x8FED
-#define GL_UNSIGNED_INT8_VEC3_NV          0x8FEE
-#define GL_UNSIGNED_INT8_VEC4_NV          0x8FEF
-#define GL_UNSIGNED_INT16_NV              0x8FF0
-#define GL_UNSIGNED_INT16_VEC2_NV         0x8FF1
-#define GL_UNSIGNED_INT16_VEC3_NV         0x8FF2
-#define GL_UNSIGNED_INT16_VEC4_NV         0x8FF3
-#define GL_UNSIGNED_INT64_VEC2_NV         0x8FF5
-#define GL_UNSIGNED_INT64_VEC3_NV         0x8FF6
-#define GL_UNSIGNED_INT64_VEC4_NV         0x8FF7
-#define GL_FLOAT16_NV                     0x8FF8
-#define GL_FLOAT16_VEC2_NV                0x8FF9
-#define GL_FLOAT16_VEC3_NV                0x8FFA
-#define GL_FLOAT16_VEC4_NV                0x8FFB
-/* reuse GL_PATCHES */
-#endif
-
-#ifndef GL_NV_shader_buffer_store
-#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010
-/* reuse GL_READ_WRITE */
-/* reuse GL_WRITE_ONLY */
-#endif
-
-#ifndef GL_NV_tessellation_program5
-#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV   0x86D8
-#define GL_TESS_CONTROL_PROGRAM_NV        0x891E
-#define GL_TESS_EVALUATION_PROGRAM_NV     0x891F
-#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74
-#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75
-#endif
-
-#ifndef GL_NV_vertex_attrib_integer_64bit
-/* reuse GL_INT64_NV */
-/* reuse GL_UNSIGNED_INT64_NV */
-#endif
-
-#ifndef GL_NV_multisample_coverage
-#define GL_COVERAGE_SAMPLES_NV            0x80A9
-#define GL_COLOR_SAMPLES_NV               0x8E20
-#endif
-
-#ifndef GL_AMD_name_gen_delete
-#define GL_DATA_BUFFER_AMD                0x9151
-#define GL_PERFORMANCE_MONITOR_AMD        0x9152
-#define GL_QUERY_OBJECT_AMD               0x9153
-#define GL_VERTEX_ARRAY_OBJECT_AMD        0x9154
-#define GL_SAMPLER_OBJECT_AMD             0x9155
-#endif
-
-#ifndef GL_AMD_debug_output
-#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD  0x9144
-#define GL_DEBUG_LOGGED_MESSAGES_AMD      0x9145
-#define GL_DEBUG_SEVERITY_HIGH_AMD        0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM_AMD      0x9147
-#define GL_DEBUG_SEVERITY_LOW_AMD         0x9148
-#define GL_DEBUG_CATEGORY_API_ERROR_AMD   0x9149
-#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A
-#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B
-#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C
-#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D
-#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E
-#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F
-#define GL_DEBUG_CATEGORY_OTHER_AMD       0x9150
-#endif
-
-#ifndef GL_NV_vdpau_interop
-#define GL_SURFACE_STATE_NV               0x86EB
-#define GL_SURFACE_REGISTERED_NV          0x86FD
-#define GL_SURFACE_MAPPED_NV              0x8700
-#define GL_WRITE_DISCARD_NV               0x88BE
-#endif
-
-#ifndef GL_AMD_transform_feedback3_lines_triangles
-#endif
-
-#ifndef GL_AMD_depth_clamp_separate
-#define GL_DEPTH_CLAMP_NEAR_AMD           0x901E
-#define GL_DEPTH_CLAMP_FAR_AMD            0x901F
-#endif
-
-#ifndef GL_EXT_texture_sRGB_decode
-#define GL_TEXTURE_SRGB_DECODE_EXT        0x8A48
-#define GL_DECODE_EXT                     0x8A49
-#define GL_SKIP_DECODE_EXT                0x8A4A
-#endif
-
-#ifndef GL_NV_texture_multisample
-#define GL_TEXTURE_COVERAGE_SAMPLES_NV    0x9045
-#define GL_TEXTURE_COLOR_SAMPLES_NV       0x9046
-#endif
-
-#ifndef GL_AMD_blend_minmax_factor
-#define GL_FACTOR_MIN_AMD                 0x901C
-#define GL_FACTOR_MAX_AMD                 0x901D
-#endif
-
-#ifndef GL_AMD_sample_positions
-#define GL_SUBSAMPLE_DISTANCE_AMD         0x883F
-#endif
-
-#ifndef GL_EXT_x11_sync_object
-#define GL_SYNC_X11_FENCE_EXT             0x90E1
-#endif
-
-#ifndef GL_AMD_multi_draw_indirect
-#endif
-
-#ifndef GL_EXT_framebuffer_multisample_blit_scaled
-#define GL_SCALED_RESOLVE_FASTEST_EXT     0x90BA
-#define GL_SCALED_RESOLVE_NICEST_EXT      0x90BB
-#endif
-
-
-/*************************************************************/
-
-#include <stddef.h>
-#ifndef GL_VERSION_2_0
-/* GL type for program/shader text */
-typedef char GLchar;
-#endif
-
-#ifndef GL_VERSION_1_5
-/* GL types for handling large vertex buffer objects */
-typedef ptrdiff_t GLintptr;
-typedef ptrdiff_t GLsizeiptr;
-#endif
-
-#ifndef GL_ARB_vertex_buffer_object
-/* GL types for handling large vertex buffer objects */
-typedef ptrdiff_t GLintptrARB;
-typedef ptrdiff_t GLsizeiptrARB;
-#endif
-
-#ifndef GL_ARB_shader_objects
-/* GL types for program/shader text and shader object handles */
-typedef char GLcharARB;
-#ifdef __APPLE__
-typedef unsigned long GLhandleARB;
-#else
-typedef unsigned int GLhandleARB;
-#endif
-#endif
-
-/* GL type for "half" precision (s10e5) float data in host memory */
-#ifndef GL_ARB_half_float_pixel
-typedef unsigned short GLhalfARB;
-#endif
-
-#ifndef GL_NV_half_float
-typedef unsigned short GLhalfNV;
-#endif
-
-#ifndef GLEXT_64_TYPES_DEFINED
-/* This code block is duplicated in glxext.h, so must be protected */
-#define GLEXT_64_TYPES_DEFINED
-/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
-/* (as used in the GL_EXT_timer_query extension). */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#include <inttypes.h>
-#elif defined(__sun__) || defined(__digital__)
-#include <inttypes.h>
-#if defined(__STDC__)
-#if defined(__arch64__) || defined(_LP64)
-typedef long int int64_t;
-typedef unsigned long int uint64_t;
-#else
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#endif /* __arch64__ */
-#endif /* __STDC__ */
-#elif defined( __VMS ) || defined(__sgi)
-#include <inttypes.h>
-#elif defined(__SCO__) || defined(__USLC__)
-#include <stdint.h>
-#elif defined(__UNIXOS2__) || defined(__SOL64__)
-typedef long int int32_t;
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#elif defined(_WIN32) && defined(__GNUC__)
-#include <stdint.h>
-#elif defined(_WIN32)
-typedef __int32 int32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#else
-/* Fallback if nothing above works */
-#include <inttypes.h>
-#endif
-#endif
-
-#ifndef GL_EXT_timer_query
-typedef int64_t GLint64EXT;
-typedef uint64_t GLuint64EXT;
-#endif
-
-#ifndef GL_ARB_sync
-typedef int64_t GLint64;
-typedef uint64_t GLuint64;
-typedef struct __GLsync *GLsync;
-#endif
-
-#ifndef GL_ARB_cl_event
-/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */
-struct _cl_context;
-struct _cl_event;
-#endif
-
-#ifndef GL_ARB_debug_output
-typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
-#endif
-
-#ifndef GL_AMD_debug_output
-typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
-#endif
-
-#ifndef GL_NV_vdpau_interop
-typedef GLintptr GLvdpauSurfaceNV;
-#endif
-
-#ifndef GL_VERSION_1_2
-#define GL_VERSION_1_2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-GLAPI void APIENTRY glBlendEquation (GLenum mode);
-GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
-GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
-typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-#endif
-
-#ifndef GL_VERSION_1_2_DEPRECATED
-#define GL_VERSION_1_2_DEPRECATED 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table);
-GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params);
-GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params);
-GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image);
-GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
-GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
-GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
-GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink);
-GLAPI void APIENTRY glResetHistogram (GLenum target);
-GLAPI void APIENTRY glResetMinmax (GLenum target);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
-typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
-#endif
-
-#ifndef GL_VERSION_1_3
-#define GL_VERSION_1_3 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glActiveTexture (GLenum texture);
-GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
-GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
-#endif
-
-#ifndef GL_VERSION_1_3_DEPRECATED
-#define GL_VERSION_1_3_DEPRECATED 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glClientActiveTexture (GLenum texture);
-GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s);
-GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s);
-GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s);
-GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s);
-GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v);
-GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t);
-GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t);
-GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t);
-GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t);
-GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v);
-GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r);
-GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r);
-GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v);
-GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q);
-GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v);
-GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m);
-GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m);
-GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m);
-GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
-#endif
-
-#ifndef GL_VERSION_1_4
-#define GL_VERSION_1_4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param);
-GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
-#endif
-
-#ifndef GL_VERSION_1_4_DEPRECATED
-#define GL_VERSION_1_4_DEPRECATED 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFogCoordf (GLfloat coord);
-GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord);
-GLAPI void APIENTRY glFogCoordd (GLdouble coord);
-GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord);
-GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue);
-GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v);
-GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue);
-GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v);
-GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue);
-GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v);
-GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue);
-GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v);
-GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue);
-GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v);
-GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue);
-GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v);
-GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue);
-GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v);
-GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue);
-GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v);
-GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y);
-GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v);
-GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y);
-GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v);
-GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y);
-GLAPI void APIENTRY glWindowPos2iv (const GLint *v);
-GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y);
-GLAPI void APIENTRY glWindowPos2sv (const GLshort *v);
-GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v);
-GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v);
-GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z);
-GLAPI void APIENTRY glWindowPos3iv (const GLint *v);
-GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z);
-GLAPI void APIENTRY glWindowPos3sv (const GLshort *v);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
-typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v);
-#endif
-
-#ifndef GL_VERSION_1_5
-#define GL_VERSION_1_5 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids);
-GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids);
-GLAPI GLboolean APIENTRY glIsQuery (GLuint id);
-GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id);
-GLAPI void APIENTRY glEndQuery (GLenum target);
-GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params);
-GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer);
-GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
-GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
-GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer);
-GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
-GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
-GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
-GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access);
-GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target);
-GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids);
-typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
-typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
-typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
-typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
-typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params);
-#endif
-
-#ifndef GL_VERSION_2_0
-#define GL_VERSION_2_0 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
-GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs);
-GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
-GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
-GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader);
-GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);
-GLAPI void APIENTRY glCompileShader (GLuint shader);
-GLAPI GLuint APIENTRY glCreateProgram (void);
-GLAPI GLuint APIENTRY glCreateShader (GLenum type);
-GLAPI void APIENTRY glDeleteProgram (GLuint program);
-GLAPI void APIENTRY glDeleteShader (GLuint shader);
-GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader);
-GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index);
-GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index);
-GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
-GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
-GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
-GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
-GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);
-GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);
-GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params);
-GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer);
-GLAPI GLboolean APIENTRY glIsProgram (GLuint program);
-GLAPI GLboolean APIENTRY glIsShader (GLuint shader);
-GLAPI void APIENTRY glLinkProgram (GLuint program);
-GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
-GLAPI void APIENTRY glUseProgram (GLuint program);
-GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0);
-GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
-GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-GLAPI void APIENTRY glUniform1i (GLint location, GLint v0);
-GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
-GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
-GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glValidateProgram (GLuint program);
-GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x);
-GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);
-GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x);
-GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
-GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y);
-GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z);
-GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v);
-GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v);
-GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v);
-GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v);
-GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v);
-GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v);
-GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
-typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
-typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask);
-typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
-typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
-typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
-typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
-typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
-typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
-typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
-typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
-typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
-typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
-typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
-typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
-typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
-typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
-typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
-typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
-typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_VERSION_2_1
-#define GL_VERSION_2_1 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-#endif
-
-#ifndef GL_VERSION_3_0
-#define GL_VERSION_3_0 1
-/* OpenGL 3.0 also reuses entry points from these extensions: */
-/* ARB_framebuffer_object */
-/* ARB_map_buffer_range */
-/* ARB_vertex_array_object */
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data);
-GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data);
-GLAPI void APIENTRY glEnablei (GLenum target, GLuint index);
-GLAPI void APIENTRY glDisablei (GLenum target, GLuint index);
-GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index);
-GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode);
-GLAPI void APIENTRY glEndTransformFeedback (void);
-GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);
-GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
-GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
-GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp);
-GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode);
-GLAPI void APIENTRY glEndConditionalRender (void);
-GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params);
-GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x);
-GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y);
-GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z);
-GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);
-GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x);
-GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y);
-GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z);
-GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v);
-GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v);
-GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v);
-GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params);
-GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name);
-GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);
-GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0);
-GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);
-GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);
-GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params);
-GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params);
-GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value);
-GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value);
-GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value);
-GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
-GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);
-typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index);
-typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index);
-typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index);
-typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode);
-typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void);
-typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);
-typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
-typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
-typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp);
-typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode);
-typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params);
-typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name);
-typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name);
-typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0);
-typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1);
-typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
-typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params);
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value);
-typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value);
-typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);
-typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
-typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
-#endif
-
-#ifndef GL_VERSION_3_1
-#define GL_VERSION_3_1 1
-/* OpenGL 3.1 also reuses entry points from these extensions: */
-/* ARB_copy_buffer */
-/* ARB_uniform_buffer_object */
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer);
-GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer);
-typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index);
-#endif
-
-#ifndef GL_VERSION_3_2
-#define GL_VERSION_3_2 1
-/* OpenGL 3.2 also reuses entry points from these extensions: */
-/* ARB_draw_elements_base_vertex */
-/* ARB_provoking_vertex */
-/* ARB_sync */
-/* ARB_texture_multisample */
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data);
-GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params);
-GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
-#endif
-
-#ifndef GL_VERSION_3_3
-#define GL_VERSION_3_3 1
-/* OpenGL 3.3 also reuses entry points from these extensions: */
-/* ARB_blend_func_extended */
-/* ARB_sampler_objects */
-/* ARB_explicit_attrib_location, but it has none */
-/* ARB_occlusion_query2 (no entry points) */
-/* ARB_shader_bit_encoding (no entry points) */
-/* ARB_texture_rgb10_a2ui (no entry points) */
-/* ARB_texture_swizzle (no entry points) */
-/* ARB_timer_query */
-/* ARB_vertex_type_2_10_10_10_rev */
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
-#endif
-
-#ifndef GL_VERSION_4_0
-#define GL_VERSION_4_0 1
-/* OpenGL 4.0 also reuses entry points from these extensions: */
-/* ARB_texture_query_lod (no entry points) */
-/* ARB_draw_indirect */
-/* ARB_gpu_shader5 (no entry points) */
-/* ARB_gpu_shader_fp64 */
-/* ARB_shader_subroutine */
-/* ARB_tessellation_shader */
-/* ARB_texture_buffer_object_rgb32 (no entry points) */
-/* ARB_texture_cube_map_array (no entry points) */
-/* ARB_texture_gather (no entry points) */
-/* ARB_transform_feedback2 */
-/* ARB_transform_feedback3 */
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMinSampleShading (GLclampf value);
-GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode);
-GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst);
-GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLclampf value);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst);
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-#endif
-
-#ifndef GL_VERSION_4_1
-#define GL_VERSION_4_1 1
-/* OpenGL 4.1 reuses entry points from these extensions: */
-/* ARB_ES2_compatibility */
-/* ARB_get_program_binary */
-/* ARB_separate_shader_objects */
-/* ARB_shader_precision (no entry points) */
-/* ARB_vertex_attrib_64bit */
-/* ARB_viewport_array */
-#endif
-
-#ifndef GL_VERSION_4_2
-#define GL_VERSION_4_2 1
-/* OpenGL 4.2 reuses entry points from these extensions: */
-/* ARB_base_instance */
-/* ARB_shading_language_420pack (no entry points) */
-/* ARB_transform_feedback_instanced */
-/* ARB_compressed_texture_pixel_storage (no entry points) */
-/* ARB_conservative_depth (no entry points) */
-/* ARB_internalformat_query */
-/* ARB_map_buffer_alignment (no entry points) */
-/* ARB_shader_atomic_counters */
-/* ARB_shader_image_load_store */
-/* ARB_shading_language_packing (no entry points) */
-/* ARB_texture_storage */
-#endif
-
-#ifndef GL_ARB_multitexture
-#define GL_ARB_multitexture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glActiveTextureARB (GLenum texture);
-GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture);
-GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s);
-GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s);
-GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s);
-GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s);
-GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v);
-GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t);
-GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t);
-GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t);
-GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t);
-GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v);
-GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r);
-GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r);
-GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v);
-GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v);
-GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v);
-GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q);
-GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v);
-GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
-#endif
-
-#ifndef GL_ARB_transpose_matrix
-#define GL_ARB_transpose_matrix 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m);
-GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m);
-GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m);
-GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
-#endif
-
-#ifndef GL_ARB_multisample
-#define GL_ARB_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSampleCoverageARB (GLclampf value, GLboolean invert);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);
-#endif
-
-#ifndef GL_ARB_texture_env_add
-#define GL_ARB_texture_env_add 1
-#endif
-
-#ifndef GL_ARB_texture_cube_map
-#define GL_ARB_texture_cube_map 1
-#endif
-
-#ifndef GL_ARB_texture_compression
-#define GL_ARB_texture_compression 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img);
-#endif
-
-#ifndef GL_ARB_texture_border_clamp
-#define GL_ARB_texture_border_clamp 1
-#endif
-
-#ifndef GL_ARB_point_parameters
-#define GL_ARB_point_parameters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_ARB_vertex_blend
-#define GL_ARB_vertex_blend 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights);
-GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights);
-GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights);
-GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights);
-GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights);
-GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights);
-GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights);
-GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights);
-GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glVertexBlendARB (GLint count);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights);
-typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights);
-typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights);
-typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
-typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights);
-typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights);
-typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights);
-typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights);
-typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
-#endif
-
-#ifndef GL_ARB_matrix_palette
-#define GL_ARB_matrix_palette 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index);
-GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices);
-GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices);
-GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices);
-GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);
-typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices);
-typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices);
-typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);
-typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_ARB_texture_env_combine
-#define GL_ARB_texture_env_combine 1
-#endif
-
-#ifndef GL_ARB_texture_env_crossbar
-#define GL_ARB_texture_env_crossbar 1
-#endif
-
-#ifndef GL_ARB_texture_env_dot3
-#define GL_ARB_texture_env_dot3 1
-#endif
-
-#ifndef GL_ARB_texture_mirrored_repeat
-#define GL_ARB_texture_mirrored_repeat 1
-#endif
-
-#ifndef GL_ARB_depth_texture
-#define GL_ARB_depth_texture 1
-#endif
-
-#ifndef GL_ARB_shadow
-#define GL_ARB_shadow 1
-#endif
-
-#ifndef GL_ARB_shadow_ambient
-#define GL_ARB_shadow_ambient 1
-#endif
-
-#ifndef GL_ARB_window_pos
-#define GL_ARB_window_pos 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y);
-GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v);
-GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y);
-GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v);
-GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y);
-GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v);
-GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y);
-GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v);
-GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v);
-GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v);
-GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z);
-GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v);
-GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z);
-GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v);
-#endif
-
-#ifndef GL_ARB_vertex_program
-#define GL_ARB_vertex_program 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x);
-GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x);
-GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x);
-GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y);
-GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y);
-GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z);
-GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v);
-GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v);
-GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v);
-GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v);
-GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v);
-GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v);
-GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index);
-GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index);
-GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
-GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program);
-GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs);
-GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs);
-GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);
-GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);
-GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);
-GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);
-GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params);
-GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params);
-GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params);
-GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params);
-GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string);
-GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params);
-GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer);
-GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
-typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);
-typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
-typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program);
-#endif
-
-#ifndef GL_ARB_fragment_program
-#define GL_ARB_fragment_program 1
-/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
-#endif
-
-#ifndef GL_ARB_vertex_buffer_object
-#define GL_ARB_vertex_buffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer);
-GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers);
-GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers);
-GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer);
-GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
-GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
-GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
-GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access);
-GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target);
-GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
-typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
-typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
-typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
-typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
-#endif
-
-#ifndef GL_ARB_occlusion_query
-#define GL_ARB_occlusion_query 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids);
-GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids);
-GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id);
-GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id);
-GLAPI void APIENTRY glEndQueryARB (GLenum target);
-GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids);
-typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params);
-#endif
-
-#ifndef GL_ARB_shader_objects
-#define GL_ARB_shader_objects 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj);
-GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname);
-GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj);
-GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType);
-GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
-GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj);
-GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);
-GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj);
-GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj);
-GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj);
-GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj);
-GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0);
-GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1);
-GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0);
-GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1);
-GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2);
-GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
-GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
-GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name);
-GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params);
-GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params);
-GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
-typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
-typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
-typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
-typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
-typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
-typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
-typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
-typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
-typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
-typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
-typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
-typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
-typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
-typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
-typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
-#endif
-
-#ifndef GL_ARB_vertex_shader
-#define GL_ARB_vertex_shader 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name);
-GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
-#endif
-
-#ifndef GL_ARB_fragment_shader
-#define GL_ARB_fragment_shader 1
-#endif
-
-#ifndef GL_ARB_shading_language_100
-#define GL_ARB_shading_language_100 1
-#endif
-
-#ifndef GL_ARB_texture_non_power_of_two
-#define GL_ARB_texture_non_power_of_two 1
-#endif
-
-#ifndef GL_ARB_point_sprite
-#define GL_ARB_point_sprite 1
-#endif
-
-#ifndef GL_ARB_fragment_program_shadow
-#define GL_ARB_fragment_program_shadow 1
-#endif
-
-#ifndef GL_ARB_draw_buffers
-#define GL_ARB_draw_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
-#endif
-
-#ifndef GL_ARB_texture_rectangle
-#define GL_ARB_texture_rectangle 1
-#endif
-
-#ifndef GL_ARB_color_buffer_float
-#define GL_ARB_color_buffer_float 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
-#endif
-
-#ifndef GL_ARB_half_float_pixel
-#define GL_ARB_half_float_pixel 1
-#endif
-
-#ifndef GL_ARB_texture_float
-#define GL_ARB_texture_float 1
-#endif
-
-#ifndef GL_ARB_pixel_buffer_object
-#define GL_ARB_pixel_buffer_object 1
-#endif
-
-#ifndef GL_ARB_depth_buffer_float
-#define GL_ARB_depth_buffer_float 1
-#endif
-
-#ifndef GL_ARB_draw_instanced
-#define GL_ARB_draw_instanced 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-#endif
-
-#ifndef GL_ARB_framebuffer_object
-#define GL_ARB_framebuffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer);
-GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
-GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);
-GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);
-GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);
-GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer);
-GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
-GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);
-GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);
-GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target);
-GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGenerateMipmap (GLenum target);
-GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers);
-typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);
-typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);
-typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers);
-typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);
-typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-#endif
-
-#ifndef GL_ARB_framebuffer_sRGB
-#define GL_ARB_framebuffer_sRGB 1
-#endif
-
-#ifndef GL_ARB_geometry_shader4
-#define GL_ARB_geometry_shader4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value);
-GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level);
-GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
-#endif
-
-#ifndef GL_ARB_half_float_vertex
-#define GL_ARB_half_float_vertex 1
-#endif
-
-#ifndef GL_ARB_instanced_arrays
-#define GL_ARB_instanced_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);
-#endif
-
-#ifndef GL_ARB_map_buffer_range
-#define GL_ARB_map_buffer_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
-#endif
-
-#ifndef GL_ARB_texture_buffer_object
-#define GL_ARB_texture_buffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer);
-#endif
-
-#ifndef GL_ARB_texture_compression_rgtc
-#define GL_ARB_texture_compression_rgtc 1
-#endif
-
-#ifndef GL_ARB_texture_rg
-#define GL_ARB_texture_rg 1
-#endif
-
-#ifndef GL_ARB_vertex_array_object
-#define GL_ARB_vertex_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindVertexArray (GLuint array);
-GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);
-GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
-GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
-typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
-typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
-typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array);
-#endif
-
-#ifndef GL_ARB_uniform_buffer_object
-#define GL_ARB_uniform_buffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices);
-GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
-GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName);
-GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
-GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
-typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
-typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
-#endif
-
-#ifndef GL_ARB_compatibility
-#define GL_ARB_compatibility 1
-#endif
-
-#ifndef GL_ARB_copy_buffer
-#define GL_ARB_copy_buffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-#endif
-
-#ifndef GL_ARB_shader_texture_lod
-#define GL_ARB_shader_texture_lod 1
-#endif
-
-#ifndef GL_ARB_depth_clamp
-#define GL_ARB_depth_clamp 1
-#endif
-
-#ifndef GL_ARB_draw_elements_base_vertex
-#define GL_ARB_draw_elements_base_vertex 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
-GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
-GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex);
-GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex);
-#endif
-
-#ifndef GL_ARB_fragment_coord_conventions
-#define GL_ARB_fragment_coord_conventions 1
-#endif
-
-#ifndef GL_ARB_provoking_vertex
-#define GL_ARB_provoking_vertex 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProvokingVertex (GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode);
-#endif
-
-#ifndef GL_ARB_seamless_cube_map
-#define GL_ARB_seamless_cube_map 1
-#endif
-
-#ifndef GL_ARB_sync
-#define GL_ARB_sync 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags);
-GLAPI GLboolean APIENTRY glIsSync (GLsync sync);
-GLAPI void APIENTRY glDeleteSync (GLsync sync);
-GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
-GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
-GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params);
-GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);
-typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync);
-typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync);
-typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
-typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
-typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params);
-typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
-#endif
-
-#ifndef GL_ARB_texture_multisample
-#define GL_ARB_texture_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
-GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
-GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val);
-GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
-typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
-typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val);
-typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);
-#endif
-
-#ifndef GL_ARB_vertex_array_bgra
-#define GL_ARB_vertex_array_bgra 1
-#endif
-
-#ifndef GL_ARB_draw_buffers_blend
-#define GL_ARB_draw_buffers_blend 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode);
-GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst);
-GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst);
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-#endif
-
-#ifndef GL_ARB_sample_shading
-#define GL_ARB_sample_shading 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value);
-#endif
-
-#ifndef GL_ARB_texture_cube_map_array
-#define GL_ARB_texture_cube_map_array 1
-#endif
-
-#ifndef GL_ARB_texture_gather
-#define GL_ARB_texture_gather 1
-#endif
-
-#ifndef GL_ARB_texture_query_lod
-#define GL_ARB_texture_query_lod 1
-#endif
-
-#ifndef GL_ARB_shading_language_include
-#define GL_ARB_shading_language_include 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);
-GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name);
-GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length);
-GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name);
-GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);
-GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);
-typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);
-typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length);
-typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);
-typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);
-typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_ARB_texture_compression_bptc
-#define GL_ARB_texture_compression_bptc 1
-#endif
-
-#ifndef GL_ARB_blend_func_extended
-#define GL_ARB_blend_func_extended 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
-GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
-typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name);
-#endif
-
-#ifndef GL_ARB_explicit_attrib_location
-#define GL_ARB_explicit_attrib_location 1
-#endif
-
-#ifndef GL_ARB_occlusion_query2
-#define GL_ARB_occlusion_query2 1
-#endif
-
-#ifndef GL_ARB_sampler_objects
-#define GL_ARB_sampler_objects 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers);
-GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers);
-GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler);
-GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
-GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
-GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param);
-GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param);
-GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param);
-GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param);
-GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);
-typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers);
-typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler);
-typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param);
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params);
-#endif
-
-#ifndef GL_ARB_shader_bit_encoding
-#define GL_ARB_shader_bit_encoding 1
-#endif
-
-#ifndef GL_ARB_texture_rgb10_a2ui
-#define GL_ARB_texture_rgb10_a2ui 1
-#endif
-
-#ifndef GL_ARB_texture_swizzle
-#define GL_ARB_texture_swizzle 1
-#endif
-
-#ifndef GL_ARB_timer_query
-#define GL_ARB_timer_query 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target);
-GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params);
-GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params);
-#endif
-
-#ifndef GL_ARB_vertex_type_2_10_10_10_rev
-#define GL_ARB_vertex_type_2_10_10_10_rev 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value);
-GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value);
-GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value);
-GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value);
-GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value);
-GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value);
-GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords);
-GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords);
-GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords);
-GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords);
-GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords);
-GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords);
-GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords);
-GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords);
-GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords);
-GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords);
-GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color);
-GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color);
-GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color);
-GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color);
-GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color);
-GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color);
-GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value);
-typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value);
-typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value);
-typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value);
-typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value);
-typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value);
-typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords);
-typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords);
-typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color);
-typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color);
-typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color);
-typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
-#endif
-
-#ifndef GL_ARB_draw_indirect
-#define GL_ARB_draw_indirect 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect);
-GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect);
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect);
-#endif
-
-#ifndef GL_ARB_gpu_shader5
-#define GL_ARB_gpu_shader5 1
-#endif
-
-#ifndef GL_ARB_gpu_shader_fp64
-#define GL_ARB_gpu_shader_fp64 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x);
-GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x);
-typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params);
-#endif
-
-#ifndef GL_ARB_shader_subroutine
-#define GL_ARB_shader_subroutine 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name);
-GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name);
-GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);
-GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
-GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
-GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices);
-GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params);
-GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name);
-typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name);
-typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);
-typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
-typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
-typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices);
-typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values);
-#endif
-
-#ifndef GL_ARB_tessellation_shader
-#define GL_ARB_tessellation_shader 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value);
-GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value);
-typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values);
-#endif
-
-#ifndef GL_ARB_texture_buffer_object_rgb32
-#define GL_ARB_texture_buffer_object_rgb32 1
-#endif
-
-#ifndef GL_ARB_transform_feedback2
-#define GL_ARB_transform_feedback2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id);
-GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids);
-GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids);
-GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id);
-GLAPI void APIENTRY glPauseTransformFeedback (void);
-GLAPI void APIENTRY glResumeTransformFeedback (void);
-GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids);
-typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void);
-typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void);
-typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id);
-#endif
-
-#ifndef GL_ARB_transform_feedback3
-#define GL_ARB_transform_feedback3 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream);
-GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id);
-GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index);
-GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream);
-typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id);
-typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index);
-typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_ARB_ES2_compatibility
-#define GL_ARB_ES2_compatibility 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glReleaseShaderCompiler (void);
-GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length);
-GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
-GLAPI void APIENTRY glDepthRangef (GLclampf n, GLclampf f);
-GLAPI void APIENTRY glClearDepthf (GLclampf d);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void);
-typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length);
-typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
-typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f);
-typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d);
-#endif
-
-#ifndef GL_ARB_get_program_binary
-#define GL_ARB_get_program_binary 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
-GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
-#endif
-
-#ifndef GL_ARB_separate_shader_objects
-#define GL_ARB_separate_shader_objects 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program);
-GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program);
-GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings);
-GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline);
-GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines);
-GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines);
-GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline);
-GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params);
-GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0);
-GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0);
-GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0);
-GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0);
-GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1);
-GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1);
-GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1);
-GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1);
-GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
-GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
-GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
-GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
-GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline);
-GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
-typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program);
-typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings);
-typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline);
-typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines);
-typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines);
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline);
-typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline);
-typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-#endif
-
-#ifndef GL_ARB_vertex_attrib_64bit
-#define GL_ARB_vertex_attrib_64bit 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x);
-GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params);
-#endif
-
-#ifndef GL_ARB_viewport_array
-#define GL_ARB_viewport_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v);
-GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
-GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v);
-GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v);
-GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v);
-GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f);
-GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data);
-GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
-typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v);
-typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v);
-typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f);
-typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data);
-typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data);
-#endif
-
-#ifndef GL_ARB_cl_event
-#define GL_ARB_cl_event 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags);
-#endif
-
-#ifndef GL_ARB_debug_output
-#define GL_ARB_debug_output 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
-GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam);
-GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam);
-typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
-#endif
-
-#ifndef GL_ARB_robustness
-#define GL_ARB_robustness 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void);
-GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);
-GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);
-GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v);
-GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values);
-GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values);
-GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values);
-GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern);
-GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table);
-GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image);
-GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span);
-GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
-GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
-GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img);
-GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
-GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img);
-GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
-GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params);
-GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
-GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void);
-typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);
-typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);
-typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v);
-typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values);
-typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values);
-typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values);
-typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern);
-typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table);
-typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image);
-typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span);
-typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img);
-typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
-typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img);
-typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
-typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
-typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);
-#endif
-
-#ifndef GL_ARB_shader_stencil_export
-#define GL_ARB_shader_stencil_export 1
-#endif
-
-#ifndef GL_ARB_base_instance
-#define GL_ARB_base_instance 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);
-GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance);
-GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance);
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);
-#endif
-
-#ifndef GL_ARB_shading_language_420pack
-#define GL_ARB_shading_language_420pack 1
-#endif
-
-#ifndef GL_ARB_transform_feedback_instanced
-#define GL_ARB_transform_feedback_instanced 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount);
-GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount);
-typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);
-#endif
-
-#ifndef GL_ARB_compressed_texture_pixel_storage
-#define GL_ARB_compressed_texture_pixel_storage 1
-#endif
-
-#ifndef GL_ARB_conservative_depth
-#define GL_ARB_conservative_depth 1
-#endif
-
-#ifndef GL_ARB_internalformat_query
-#define GL_ARB_internalformat_query 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
-#endif
-
-#ifndef GL_ARB_map_buffer_alignment
-#define GL_ARB_map_buffer_alignment 1
-#endif
-
-#ifndef GL_ARB_shader_atomic_counters
-#define GL_ARB_shader_atomic_counters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_ARB_shader_image_load_store
-#define GL_ARB_shader_image_load_store 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
-GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
-typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);
-#endif
-
-#ifndef GL_ARB_shading_language_packing
-#define GL_ARB_shading_language_packing 1
-#endif
-
-#ifndef GL_ARB_texture_storage
-#define GL_ARB_texture_storage 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-#endif
-
-#ifndef GL_EXT_abgr
-#define GL_EXT_abgr 1
-#endif
-
-#ifndef GL_EXT_blend_color
-#define GL_EXT_blend_color 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-#endif
-
-#ifndef GL_EXT_polygon_offset
-#define GL_EXT_polygon_offset 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);
-#endif
-
-#ifndef GL_EXT_texture
-#define GL_EXT_texture 1
-#endif
-
-#ifndef GL_EXT_texture3D
-#define GL_EXT_texture3D 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-#endif
-
-#ifndef GL_SGIS_texture_filter4
-#define GL_SGIS_texture_filter4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights);
-GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);
-typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
-#endif
-
-#ifndef GL_EXT_subtexture
-#define GL_EXT_subtexture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
-#endif
-
-#ifndef GL_EXT_copy_texture
-#define GL_EXT_copy_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-#endif
-
-#ifndef GL_EXT_histogram
-#define GL_EXT_histogram 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
-GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink);
-GLAPI void APIENTRY glResetHistogramEXT (GLenum target);
-GLAPI void APIENTRY glResetMinmaxEXT (GLenum target);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target);
-#endif
-
-#ifndef GL_EXT_convolution
-#define GL_EXT_convolution 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params);
-GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params);
-GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image);
-GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
-GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
-typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
-#endif
-
-#ifndef GL_SGI_color_matrix
-#define GL_SGI_color_matrix 1
-#endif
-
-#ifndef GL_SGI_color_table
-#define GL_SGI_color_table 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table);
-GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_SGIX_pixel_texture
-#define GL_SGIX_pixel_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);
-#endif
-
-#ifndef GL_SGIS_pixel_texture
-#define GL_SGIS_pixel_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param);
-GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params);
-GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_SGIS_texture4D
-#define GL_SGIS_texture4D 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
-#endif
-
-#ifndef GL_SGI_texture_color_table
-#define GL_SGI_texture_color_table 1
-#endif
-
-#ifndef GL_EXT_cmyka
-#define GL_EXT_cmyka 1
-#endif
-
-#ifndef GL_EXT_texture_object
-#define GL_EXT_texture_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences);
-GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture);
-GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures);
-GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures);
-GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture);
-GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);
-typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);
-typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);
-typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);
-typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture);
-typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
-#endif
-
-#ifndef GL_SGIS_detail_texture
-#define GL_SGIS_detail_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);
-GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
-typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
-#endif
-
-#ifndef GL_SGIS_sharpen_texture
-#define GL_SGIS_sharpen_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);
-GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
-typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
-#endif
-
-#ifndef GL_EXT_packed_pixels
-#define GL_EXT_packed_pixels 1
-#endif
-
-#ifndef GL_SGIS_texture_lod
-#define GL_SGIS_texture_lod 1
-#endif
-
-#ifndef GL_SGIS_multisample
-#define GL_SGIS_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert);
-GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);
-#endif
-
-#ifndef GL_EXT_rescale_normal
-#define GL_EXT_rescale_normal 1
-#endif
-
-#ifndef GL_EXT_vertex_array
-#define GL_EXT_vertex_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glArrayElementEXT (GLint i);
-GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count);
-GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer);
-GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params);
-GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i);
-typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
-typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
-typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-#endif
-
-#ifndef GL_EXT_misc_attribute
-#define GL_EXT_misc_attribute 1
-#endif
-
-#ifndef GL_SGIS_generate_mipmap
-#define GL_SGIS_generate_mipmap 1
-#endif
-
-#ifndef GL_SGIX_clipmap
-#define GL_SGIX_clipmap 1
-#endif
-
-#ifndef GL_SGIX_shadow
-#define GL_SGIX_shadow 1
-#endif
-
-#ifndef GL_SGIS_texture_edge_clamp
-#define GL_SGIS_texture_edge_clamp 1
-#endif
-
-#ifndef GL_SGIS_texture_border_clamp
-#define GL_SGIS_texture_border_clamp 1
-#endif
-
-#ifndef GL_EXT_blend_minmax
-#define GL_EXT_blend_minmax 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendEquationEXT (GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);
-#endif
-
-#ifndef GL_EXT_blend_subtract
-#define GL_EXT_blend_subtract 1
-#endif
-
-#ifndef GL_EXT_blend_logic_op
-#define GL_EXT_blend_logic_op 1
-#endif
-
-#ifndef GL_SGIX_interlace
-#define GL_SGIX_interlace 1
-#endif
-
-#ifndef GL_SGIX_pixel_tiles
-#define GL_SGIX_pixel_tiles 1
-#endif
-
-#ifndef GL_SGIX_texture_select
-#define GL_SGIX_texture_select 1
-#endif
-
-#ifndef GL_SGIX_sprite
-#define GL_SGIX_sprite 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param);
-GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);
-#endif
-
-#ifndef GL_SGIX_texture_multi_buffer
-#define GL_SGIX_texture_multi_buffer 1
-#endif
-
-#ifndef GL_EXT_point_parameters
-#define GL_EXT_point_parameters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_SGIS_point_parameters
-#define GL_SGIS_point_parameters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_SGIX_instruments
-#define GL_SGIX_instruments 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLint APIENTRY glGetInstrumentsSGIX (void);
-GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer);
-GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p);
-GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker);
-GLAPI void APIENTRY glStartInstrumentsSGIX (void);
-GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void);
-typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);
-typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);
-typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);
-typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void);
-typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);
-#endif
-
-#ifndef GL_SGIX_texture_scale_bias
-#define GL_SGIX_texture_scale_bias 1
-#endif
-
-#ifndef GL_SGIX_framezoom
-#define GL_SGIX_framezoom 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFrameZoomSGIX (GLint factor);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor);
-#endif
-
-#ifndef GL_SGIX_tag_sample_buffer
-#define GL_SGIX_tag_sample_buffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTagSampleBufferSGIX (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);
-#endif
-
-#ifndef GL_SGIX_polynomial_ffd
-#define GL_SGIX_polynomial_ffd 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
-GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
-GLAPI void APIENTRY glDeformSGIX (GLbitfield mask);
-GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
-typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
-typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask);
-typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask);
-#endif
-
-#ifndef GL_SGIX_reference_plane
-#define GL_SGIX_reference_plane 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);
-#endif
-
-#ifndef GL_SGIX_flush_raster
-#define GL_SGIX_flush_raster 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFlushRasterSGIX (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void);
-#endif
-
-#ifndef GL_SGIX_depth_texture
-#define GL_SGIX_depth_texture 1
-#endif
-
-#ifndef GL_SGIS_fog_function
-#define GL_SGIS_fog_function 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points);
-GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);
-typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points);
-#endif
-
-#ifndef GL_SGIX_fog_offset
-#define GL_SGIX_fog_offset 1
-#endif
-
-#ifndef GL_HP_image_transform
-#define GL_HP_image_transform 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param);
-GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_HP_convolution_border_modes
-#define GL_HP_convolution_border_modes 1
-#endif
-
-#ifndef GL_SGIX_texture_add_env
-#define GL_SGIX_texture_add_env 1
-#endif
-
-#ifndef GL_EXT_color_subtable
-#define GL_EXT_color_subtable 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
-#endif
-
-#ifndef GL_PGI_vertex_hints
-#define GL_PGI_vertex_hints 1
-#endif
-
-#ifndef GL_PGI_misc_hints
-#define GL_PGI_misc_hints 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode);
-#endif
-
-#ifndef GL_EXT_paletted_texture
-#define GL_EXT_paletted_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data);
-GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_EXT_clip_volume_hint
-#define GL_EXT_clip_volume_hint 1
-#endif
-
-#ifndef GL_SGIX_list_priority
-#define GL_SGIX_list_priority 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params);
-GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param);
-GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);
-#endif
-
-#ifndef GL_SGIX_ir_instrument1
-#define GL_SGIX_ir_instrument1 1
-#endif
-
-#ifndef GL_SGIX_calligraphic_fragment
-#define GL_SGIX_calligraphic_fragment 1
-#endif
-
-#ifndef GL_SGIX_texture_lod_bias
-#define GL_SGIX_texture_lod_bias 1
-#endif
-
-#ifndef GL_SGIX_shadow_ambient
-#define GL_SGIX_shadow_ambient 1
-#endif
-
-#ifndef GL_EXT_index_texture
-#define GL_EXT_index_texture 1
-#endif
-
-#ifndef GL_EXT_index_material
-#define GL_EXT_index_material 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);
-#endif
-
-#ifndef GL_EXT_index_func
-#define GL_EXT_index_func 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);
-#endif
-
-#ifndef GL_EXT_index_array_formats
-#define GL_EXT_index_array_formats 1
-#endif
-
-#ifndef GL_EXT_compiled_vertex_array
-#define GL_EXT_compiled_vertex_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count);
-GLAPI void APIENTRY glUnlockArraysEXT (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void);
-#endif
-
-#ifndef GL_EXT_cull_vertex
-#define GL_EXT_cull_vertex 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params);
-GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_SGIX_ycrcb
-#define GL_SGIX_ycrcb 1
-#endif
-
-#ifndef GL_SGIX_fragment_lighting
-#define GL_SGIX_fragment_lighting 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode);
-GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param);
-GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param);
-GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params);
-GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param);
-GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params);
-GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);
-#endif
-
-#ifndef GL_IBM_rasterpos_clip
-#define GL_IBM_rasterpos_clip 1
-#endif
-
-#ifndef GL_HP_texture_lighting
-#define GL_HP_texture_lighting 1
-#endif
-
-#ifndef GL_EXT_draw_range_elements
-#define GL_EXT_draw_range_elements 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
-#endif
-
-#ifndef GL_WIN_phong_shading
-#define GL_WIN_phong_shading 1
-#endif
-
-#ifndef GL_WIN_specular_fog
-#define GL_WIN_specular_fog 1
-#endif
-
-#ifndef GL_EXT_light_texture
-#define GL_EXT_light_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glApplyTextureEXT (GLenum mode);
-GLAPI void APIENTRY glTextureLightEXT (GLenum pname);
-GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);
-typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);
-#endif
-
-#ifndef GL_SGIX_blend_alpha_minmax
-#define GL_SGIX_blend_alpha_minmax 1
-#endif
-
-#ifndef GL_EXT_bgra
-#define GL_EXT_bgra 1
-#endif
-
-#ifndef GL_SGIX_async
-#define GL_SGIX_async 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker);
-GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp);
-GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp);
-GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range);
-GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range);
-GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker);
-typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp);
-typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp);
-typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);
-typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);
-typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);
-#endif
-
-#ifndef GL_SGIX_async_pixel
-#define GL_SGIX_async_pixel 1
-#endif
-
-#ifndef GL_SGIX_async_histogram
-#define GL_SGIX_async_histogram 1
-#endif
-
-#ifndef GL_INTEL_parallel_arrays
-#define GL_INTEL_parallel_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
-GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer);
-GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
-GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
-typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer);
-typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
-#endif
-
-#ifndef GL_HP_occlusion_test
-#define GL_HP_occlusion_test 1
-#endif
-
-#ifndef GL_EXT_pixel_transform
-#define GL_EXT_pixel_transform 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param);
-GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_EXT_pixel_transform_color_table
-#define GL_EXT_pixel_transform_color_table 1
-#endif
-
-#ifndef GL_EXT_shared_texture_palette
-#define GL_EXT_shared_texture_palette 1
-#endif
-
-#ifndef GL_EXT_separate_specular_color
-#define GL_EXT_separate_specular_color 1
-#endif
-
-#ifndef GL_EXT_secondary_color
-#define GL_EXT_secondary_color 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue);
-GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v);
-GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue);
-GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v);
-GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue);
-GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v);
-GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue);
-GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v);
-GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue);
-GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v);
-GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue);
-GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v);
-GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue);
-GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v);
-GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue);
-GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v);
-GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_EXT_texture_perturb_normal
-#define GL_EXT_texture_perturb_normal 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTextureNormalEXT (GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-#endif
-
-#ifndef GL_EXT_fog_coord
-#define GL_EXT_fog_coord 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord);
-GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord);
-GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord);
-GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord);
-GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
-typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_REND_screen_coordinates
-#define GL_REND_screen_coordinates 1
-#endif
-
-#ifndef GL_EXT_coordinate_frame
-#define GL_EXT_coordinate_frame 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz);
-GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v);
-GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz);
-GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v);
-GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz);
-GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v);
-GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz);
-GLAPI void APIENTRY glTangent3ivEXT (const GLint *v);
-GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz);
-GLAPI void APIENTRY glTangent3svEXT (const GLshort *v);
-GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz);
-GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v);
-GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz);
-GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v);
-GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz);
-GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v);
-GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz);
-GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v);
-GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz);
-GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v);
-GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz);
-typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz);
-typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz);
-typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz);
-typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz);
-typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz);
-typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz);
-typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz);
-typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz);
-typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz);
-typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_EXT_texture_env_combine
-#define GL_EXT_texture_env_combine 1
-#endif
-
-#ifndef GL_APPLE_specular_vector
-#define GL_APPLE_specular_vector 1
-#endif
-
-#ifndef GL_APPLE_transform_hint
-#define GL_APPLE_transform_hint 1
-#endif
-
-#ifndef GL_SGIX_fog_scale
-#define GL_SGIX_fog_scale 1
-#endif
-
-#ifndef GL_SUNX_constant_data
-#define GL_SUNX_constant_data 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFinishTextureSUNX (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void);
-#endif
-
-#ifndef GL_SUN_global_alpha
-#define GL_SUN_global_alpha 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor);
-GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor);
-GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor);
-GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor);
-GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor);
-GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor);
-GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor);
-GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);
-#endif
-
-#ifndef GL_SUN_triangle_list
-#define GL_SUN_triangle_list 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code);
-GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code);
-GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code);
-GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code);
-GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code);
-GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code);
-GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer);
-#endif
-
-#ifndef GL_SUN_vertex
-#define GL_SUN_vertex 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
-GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v);
-GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v);
-GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v);
-GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v);
-GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v);
-GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
-GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
-GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-#endif
-
-#ifndef GL_EXT_blend_func_separate
-#define GL_EXT_blend_func_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-#endif
-
-#ifndef GL_INGR_blend_func_separate
-#define GL_INGR_blend_func_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-#endif
-
-#ifndef GL_INGR_color_clamp
-#define GL_INGR_color_clamp 1
-#endif
-
-#ifndef GL_INGR_interlace_read
-#define GL_INGR_interlace_read 1
-#endif
-
-#ifndef GL_EXT_stencil_wrap
-#define GL_EXT_stencil_wrap 1
-#endif
-
-#ifndef GL_EXT_422_pixels
-#define GL_EXT_422_pixels 1
-#endif
-
-#ifndef GL_NV_texgen_reflection
-#define GL_NV_texgen_reflection 1
-#endif
-
-#ifndef GL_SUN_convolution_border_modes
-#define GL_SUN_convolution_border_modes 1
-#endif
-
-#ifndef GL_EXT_texture_env_add
-#define GL_EXT_texture_env_add 1
-#endif
-
-#ifndef GL_EXT_texture_lod_bias
-#define GL_EXT_texture_lod_bias 1
-#endif
-
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_EXT_texture_filter_anisotropic 1
-#endif
-
-#ifndef GL_EXT_vertex_weighting
-#define GL_EXT_vertex_weighting 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight);
-GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight);
-GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_NV_light_max_exponent
-#define GL_NV_light_max_exponent 1
-#endif
-
-#ifndef GL_NV_vertex_array_range
-#define GL_NV_vertex_array_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFlushVertexArrayRangeNV (void);
-GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);
-typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer);
-#endif
-
-#ifndef GL_NV_register_combiners
-#define GL_NV_register_combiners 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param);
-GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params);
-GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param);
-GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
-GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
-typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_NV_fog_distance
-#define GL_NV_fog_distance 1
-#endif
-
-#ifndef GL_NV_texgen_emboss
-#define GL_NV_texgen_emboss 1
-#endif
-
-#ifndef GL_NV_blend_square
-#define GL_NV_blend_square 1
-#endif
-
-#ifndef GL_NV_texture_env_combine4
-#define GL_NV_texture_env_combine4 1
-#endif
-
-#ifndef GL_MESA_resize_buffers
-#define GL_MESA_resize_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glResizeBuffersMESA (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void);
-#endif
-
-#ifndef GL_MESA_window_pos
-#define GL_MESA_window_pos 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y);
-GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v);
-GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y);
-GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v);
-GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y);
-GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v);
-GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y);
-GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v);
-GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v);
-GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v);
-GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z);
-GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v);
-GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z);
-GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v);
-GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v);
-GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v);
-GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w);
-GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v);
-GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);
-#endif
-
-#ifndef GL_IBM_cull_vertex
-#define GL_IBM_cull_vertex 1
-#endif
-
-#ifndef GL_IBM_multimode_draw_arrays
-#define GL_IBM_multimode_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
-GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
-typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
-#endif
-
-#ifndef GL_IBM_vertex_array_lists
-#define GL_IBM_vertex_array_lists 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride);
-GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-#endif
-
-#ifndef GL_SGIX_subsample
-#define GL_SGIX_subsample 1
-#endif
-
-#ifndef GL_SGIX_ycrcba
-#define GL_SGIX_ycrcba 1
-#endif
-
-#ifndef GL_SGIX_ycrcb_subsample
-#define GL_SGIX_ycrcb_subsample 1
-#endif
-
-#ifndef GL_SGIX_depth_pass_instrument
-#define GL_SGIX_depth_pass_instrument 1
-#endif
-
-#ifndef GL_3DFX_texture_compression_FXT1
-#define GL_3DFX_texture_compression_FXT1 1
-#endif
-
-#ifndef GL_3DFX_multisample
-#define GL_3DFX_multisample 1
-#endif
-
-#ifndef GL_3DFX_tbuffer
-#define GL_3DFX_tbuffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
-#endif
-
-#ifndef GL_EXT_multisample
-#define GL_EXT_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert);
-GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);
-#endif
-
-#ifndef GL_SGIX_vertex_preclip
-#define GL_SGIX_vertex_preclip 1
-#endif
-
-#ifndef GL_SGIX_convolution_accuracy
-#define GL_SGIX_convolution_accuracy 1
-#endif
-
-#ifndef GL_SGIX_resample
-#define GL_SGIX_resample 1
-#endif
-
-#ifndef GL_SGIS_point_line_texgen
-#define GL_SGIS_point_line_texgen 1
-#endif
-
-#ifndef GL_SGIS_texture_color_mask
-#define GL_SGIS_texture_color_mask 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-#endif
-
-#ifndef GL_SGIX_igloo_interface
-#define GL_SGIX_igloo_interface 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params);
-#endif
-
-#ifndef GL_EXT_texture_env_dot3
-#define GL_EXT_texture_env_dot3 1
-#endif
-
-#ifndef GL_ATI_texture_mirror_once
-#define GL_ATI_texture_mirror_once 1
-#endif
-
-#ifndef GL_NV_fence
-#define GL_NV_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);
-GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
-GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence);
-GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence);
-GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);
-GLAPI void APIENTRY glFinishFenceNV (GLuint fence);
-GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
-typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
-typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
-typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
-typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
-#endif
-
-#ifndef GL_NV_evaluators
-#define GL_NV_evaluators 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
-GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
-GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
-typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
-typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);
-#endif
-
-#ifndef GL_NV_packed_depth_stencil
-#define GL_NV_packed_depth_stencil 1
-#endif
-
-#ifndef GL_NV_register_combiners2
-#define GL_NV_register_combiners2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_NV_texture_compression_vtc
-#define GL_NV_texture_compression_vtc 1
-#endif
-
-#ifndef GL_NV_texture_rectangle
-#define GL_NV_texture_rectangle 1
-#endif
-
-#ifndef GL_NV_texture_shader
-#define GL_NV_texture_shader 1
-#endif
-
-#ifndef GL_NV_texture_shader2
-#define GL_NV_texture_shader2 1
-#endif
-
-#ifndef GL_NV_vertex_array_range2
-#define GL_NV_vertex_array_range2 1
-#endif
-
-#ifndef GL_NV_vertex_program
-#define GL_NV_vertex_program 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences);
-GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id);
-GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs);
-GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params);
-GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs);
-GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params);
-GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program);
-GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params);
-GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer);
-GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id);
-GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
-GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
-GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
-GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs);
-GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform);
-GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x);
-GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x);
-GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x);
-GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y);
-GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y);
-GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z);
-GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v);
-GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v);
-GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v);
-GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v);
-GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v);
-GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v);
-GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences);
-typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
-typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs);
-typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program);
-typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
-typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v);
-#endif
-
-#ifndef GL_SGIX_texture_coordinate_clamp
-#define GL_SGIX_texture_coordinate_clamp 1
-#endif
-
-#ifndef GL_SGIX_scalebias_hint
-#define GL_SGIX_scalebias_hint 1
-#endif
-
-#ifndef GL_OML_interlace
-#define GL_OML_interlace 1
-#endif
-
-#ifndef GL_OML_subsample
-#define GL_OML_subsample 1
-#endif
-
-#ifndef GL_OML_resample
-#define GL_OML_resample 1
-#endif
-
-#ifndef GL_NV_copy_depth_to_color
-#define GL_NV_copy_depth_to_color 1
-#endif
-
-#ifndef GL_ATI_envmap_bumpmap
-#define GL_ATI_envmap_bumpmap 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param);
-GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param);
-GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param);
-GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param);
-typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param);
-typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);
-typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);
-#endif
-
-#ifndef GL_ATI_fragment_shader
-#define GL_ATI_fragment_shader 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range);
-GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id);
-GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id);
-GLAPI void APIENTRY glBeginFragmentShaderATI (void);
-GLAPI void APIENTRY glEndFragmentShaderATI (void);
-GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle);
-GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle);
-GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);
-typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void);
-typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void);
-typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);
-typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value);
-#endif
-
-#ifndef GL_ATI_pn_triangles
-#define GL_ATI_pn_triangles 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param);
-GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);
-#endif
-
-#ifndef GL_ATI_vertex_array_object
-#define GL_ATI_vertex_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage);
-GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer);
-GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
-GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params);
-GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer);
-GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params);
-GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage);
-typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_EXT_vertex_shader
-#define GL_EXT_vertex_shader 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBeginVertexShaderEXT (void);
-GLAPI void APIENTRY glEndVertexShaderEXT (void);
-GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id);
-GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range);
-GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id);
-GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1);
-GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
-GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
-GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num);
-GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num);
-GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
-GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr);
-GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr);
-GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr);
-GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr);
-GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr);
-GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr);
-GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr);
-GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr);
-GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr);
-GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr);
-GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
-GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id);
-GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id);
-GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value);
-GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value);
-GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value);
-GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value);
-GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value);
-GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap);
-GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
-GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data);
-GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
-GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data);
-GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
-GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data);
-GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
-GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
-GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data);
-GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void);
-typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void);
-typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);
-typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);
-typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);
-typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
-typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
-typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
-typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
-typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
-typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
-typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
-typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr);
-typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr);
-typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr);
-typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr);
-typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr);
-typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr);
-typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr);
-typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr);
-typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
-typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
-typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value);
-typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);
-typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
-typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
-typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data);
-typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
-typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
-#endif
-
-#ifndef GL_ATI_vertex_streams
-#define GL_ATI_vertex_streams 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x);
-GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords);
-GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x);
-GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords);
-GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x);
-GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords);
-GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x);
-GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords);
-GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y);
-GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords);
-GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y);
-GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords);
-GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y);
-GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords);
-GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords);
-GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z);
-GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords);
-GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z);
-GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords);
-GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords);
-GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords);
-GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords);
-GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w);
-GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords);
-GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords);
-GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords);
-GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
-GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords);
-GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
-GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords);
-GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz);
-GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords);
-GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
-GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords);
-GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
-GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords);
-GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream);
-GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param);
-GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);
-typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);
-#endif
-
-#ifndef GL_ATI_element_array
-#define GL_ATI_element_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer);
-GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count);
-GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);
-#endif
-
-#ifndef GL_SUN_mesh_array
-#define GL_SUN_mesh_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width);
-#endif
-
-#ifndef GL_SUN_slice_accum
-#define GL_SUN_slice_accum 1
-#endif
-
-#ifndef GL_NV_multisample_filter_hint
-#define GL_NV_multisample_filter_hint 1
-#endif
-
-#ifndef GL_NV_depth_clamp
-#define GL_NV_depth_clamp 1
-#endif
-
-#ifndef GL_NV_occlusion_query
-#define GL_NV_occlusion_query 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids);
-GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids);
-GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id);
-GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id);
-GLAPI void APIENTRY glEndOcclusionQueryNV (void);
-GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
-typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void);
-typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
-#endif
-
-#ifndef GL_NV_point_sprite
-#define GL_NV_point_sprite 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param);
-GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
-#endif
-
-#ifndef GL_NV_texture_shader3
-#define GL_NV_texture_shader3 1
-#endif
-
-#ifndef GL_NV_vertex_program1_1
-#define GL_NV_vertex_program1_1 1
-#endif
-
-#ifndef GL_EXT_shadow_funcs
-#define GL_EXT_shadow_funcs 1
-#endif
-
-#ifndef GL_EXT_stencil_two_side
-#define GL_EXT_stencil_two_side 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
-#endif
-
-#ifndef GL_ATI_text_fragment_shader
-#define GL_ATI_text_fragment_shader 1
-#endif
-
-#ifndef GL_APPLE_client_storage
-#define GL_APPLE_client_storage 1
-#endif
-
-#ifndef GL_APPLE_element_array
-#define GL_APPLE_element_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer);
-GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count);
-GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
-GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
-#endif
-
-#ifndef GL_APPLE_fence
-#define GL_APPLE_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences);
-GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences);
-GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence);
-GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence);
-GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence);
-GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence);
-GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name);
-GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences);
-typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences);
-typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence);
-typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);
-typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);
-#endif
-
-#ifndef GL_APPLE_vertex_array_object
-#define GL_APPLE_vertex_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array);
-GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays);
-GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays);
-GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
-typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
-typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays);
-typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
-#endif
-
-#ifndef GL_APPLE_vertex_array_range
-#define GL_APPLE_vertex_array_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer);
-GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer);
-GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
-typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);
-#endif
-
-#ifndef GL_APPLE_ycbcr_422
-#define GL_APPLE_ycbcr_422 1
-#endif
-
-#ifndef GL_S3_s3tc
-#define GL_S3_s3tc 1
-#endif
-
-#ifndef GL_ATI_draw_buffers
-#define GL_ATI_draw_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);
-#endif
-
-#ifndef GL_ATI_pixel_format_float
-#define GL_ATI_pixel_format_float 1
-/* This is really a WGL extension, but defines some associated GL enums.
- * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string.
- */
-#endif
-
-#ifndef GL_ATI_texture_env_combine3
-#define GL_ATI_texture_env_combine3 1
-#endif
-
-#ifndef GL_ATI_texture_float
-#define GL_ATI_texture_float 1
-#endif
-
-#ifndef GL_NV_float_buffer
-#define GL_NV_float_buffer 1
-#endif
-
-#ifndef GL_NV_fragment_program
-#define GL_NV_fragment_program 1
-/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
-GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
-GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
-GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
-typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
-#endif
-
-#ifndef GL_NV_half_float
-#define GL_NV_half_float 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y);
-GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z);
-GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
-GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
-GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s);
-GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t);
-GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r);
-GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s);
-GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v);
-GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t);
-GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v);
-GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
-GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v);
-GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v);
-GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog);
-GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog);
-GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v);
-GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight);
-GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight);
-GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x);
-GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v);
-GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y);
-GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v);
-GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
-GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v);
-GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v);
-GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
-GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
-GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
-GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
-typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
-typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
-typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
-typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s);
-typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
-typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
-typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog);
-typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-#endif
-
-#ifndef GL_NV_pixel_data_range
-#define GL_NV_pixel_data_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer);
-GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer);
-typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);
-#endif
-
-#ifndef GL_NV_primitive_restart
-#define GL_NV_primitive_restart 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPrimitiveRestartNV (void);
-GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void);
-typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);
-#endif
-
-#ifndef GL_NV_texture_expand_normal
-#define GL_NV_texture_expand_normal 1
-#endif
-
-#ifndef GL_NV_vertex_program2
-#define GL_NV_vertex_program2 1
-#endif
-
-#ifndef GL_ATI_map_object_buffer
-#define GL_ATI_map_object_buffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer);
-GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);
-#endif
-
-#ifndef GL_ATI_separate_stencil
-#define GL_ATI_separate_stencil 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
-#endif
-
-#ifndef GL_ATI_vertex_attrib_array_object
-#define GL_ATI_vertex_attrib_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
-GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_OES_read_format
-#define GL_OES_read_format 1
-#endif
-
-#ifndef GL_EXT_depth_bounds_test
-#define GL_EXT_depth_bounds_test 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);
-#endif
-
-#ifndef GL_EXT_texture_mirror_clamp
-#define GL_EXT_texture_mirror_clamp 1
-#endif
-
-#ifndef GL_EXT_blend_equation_separate
-#define GL_EXT_blend_equation_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
-#endif
-
-#ifndef GL_MESA_pack_invert
-#define GL_MESA_pack_invert 1
-#endif
-
-#ifndef GL_MESA_ycbcr_texture
-#define GL_MESA_ycbcr_texture 1
-#endif
-
-#ifndef GL_EXT_pixel_buffer_object
-#define GL_EXT_pixel_buffer_object 1
-#endif
-
-#ifndef GL_NV_fragment_program_option
-#define GL_NV_fragment_program_option 1
-#endif
-
-#ifndef GL_NV_fragment_program2
-#define GL_NV_fragment_program2 1
-#endif
-
-#ifndef GL_NV_vertex_program2_option
-#define GL_NV_vertex_program2_option 1
-#endif
-
-#ifndef GL_NV_vertex_program3
-#define GL_NV_vertex_program3 1
-#endif
-
-#ifndef GL_EXT_framebuffer_object
-#define GL_EXT_framebuffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer);
-GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer);
-GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers);
-GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers);
-GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params);
-GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer);
-GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer);
-GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers);
-GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers);
-GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target);
-GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
-typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
-typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
-typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
-typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
-typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
-#endif
-
-#ifndef GL_GREMEDY_string_marker
-#define GL_GREMEDY_string_marker 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
-#endif
-
-#ifndef GL_EXT_packed_depth_stencil
-#define GL_EXT_packed_depth_stencil 1
-#endif
-
-#ifndef GL_EXT_stencil_clear_tag
-#define GL_EXT_stencil_clear_tag 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag);
-#endif
-
-#ifndef GL_EXT_texture_sRGB
-#define GL_EXT_texture_sRGB 1
-#endif
-
-#ifndef GL_EXT_framebuffer_blit
-#define GL_EXT_framebuffer_blit 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif
-
-#ifndef GL_EXT_framebuffer_multisample
-#define GL_EXT_framebuffer_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
-
-#ifndef GL_MESAX_texture_stack
-#define GL_MESAX_texture_stack 1
-#endif
-
-#ifndef GL_EXT_timer_query
-#define GL_EXT_timer_query 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params);
-GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);
-#endif
-
-#ifndef GL_EXT_gpu_program_parameters
-#define GL_EXT_gpu_program_parameters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
-GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
-#endif
-
-#ifndef GL_APPLE_flush_buffer_range
-#define GL_APPLE_flush_buffer_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param);
-GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size);
-#endif
-
-#ifndef GL_NV_gpu_program4
-#define GL_NV_gpu_program4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
-GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params);
-GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);
-GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);
-GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);
-GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
-GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params);
-GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);
-GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);
-GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);
-GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params);
-GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params);
-GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params);
-GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
-#endif
-
-#ifndef GL_NV_geometry_program4
-#define GL_NV_geometry_program4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit);
-GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level);
-GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
-#endif
-
-#ifndef GL_EXT_geometry_shader4
-#define GL_EXT_geometry_shader4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
-#endif
-
-#ifndef GL_NV_vertex_program4
-#define GL_NV_vertex_program4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x);
-GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y);
-GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z);
-GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w);
-GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x);
-GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y);
-GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z);
-GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v);
-GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v);
-GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v);
-GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v);
-GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v);
-GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v);
-GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params);
-#endif
-
-#ifndef GL_EXT_gpu_shader4
-#define GL_EXT_gpu_shader4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params);
-GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name);
-GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name);
-GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0);
-GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1);
-GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2);
-GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params);
-typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);
-typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name);
-typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);
-typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1);
-typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
-typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
-#endif
-
-#ifndef GL_EXT_draw_instanced
-#define GL_EXT_draw_instanced 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
-GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-#endif
-
-#ifndef GL_EXT_packed_float
-#define GL_EXT_packed_float 1
-#endif
-
-#ifndef GL_EXT_texture_array
-#define GL_EXT_texture_array 1
-#endif
-
-#ifndef GL_EXT_texture_buffer_object
-#define GL_EXT_texture_buffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);
-#endif
-
-#ifndef GL_EXT_texture_compression_latc
-#define GL_EXT_texture_compression_latc 1
-#endif
-
-#ifndef GL_EXT_texture_compression_rgtc
-#define GL_EXT_texture_compression_rgtc 1
-#endif
-
-#ifndef GL_EXT_texture_shared_exponent
-#define GL_EXT_texture_shared_exponent 1
-#endif
-
-#ifndef GL_NV_depth_buffer_float
-#define GL_NV_depth_buffer_float 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar);
-GLAPI void APIENTRY glClearDepthdNV (GLdouble depth);
-GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar);
-typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth);
-typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax);
-#endif
-
-#ifndef GL_NV_fragment_program4
-#define GL_NV_fragment_program4 1
-#endif
-
-#ifndef GL_NV_framebuffer_multisample_coverage
-#define GL_NV_framebuffer_multisample_coverage 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
-
-#ifndef GL_EXT_framebuffer_sRGB
-#define GL_EXT_framebuffer_sRGB 1
-#endif
-
-#ifndef GL_NV_geometry_shader4
-#define GL_NV_geometry_shader4 1
-#endif
-
-#ifndef GL_NV_parameter_buffer_object
-#define GL_NV_parameter_buffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params);
-GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params);
-GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params);
-typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params);
-typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params);
-#endif
-
-#ifndef GL_EXT_draw_buffers2
-#define GL_EXT_draw_buffers2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data);
-GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data);
-GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index);
-GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index);
-GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data);
-typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
-typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
-typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index);
-#endif
-
-#ifndef GL_NV_transform_feedback
-#define GL_NV_transform_feedback 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode);
-GLAPI void APIENTRY glEndTransformFeedbackNV (void);
-GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode);
-GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
-GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer);
-GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
-GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name);
-GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name);
-GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
-GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location);
-GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode);
-typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void);
-typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode);
-typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
-typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);
-typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
-typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);
-typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);
-typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
-typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location);
-typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);
-#endif
-
-#ifndef GL_EXT_bindable_uniform
-#define GL_EXT_bindable_uniform 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer);
-GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location);
-GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer);
-typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location);
-typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location);
-#endif
-
-#ifndef GL_EXT_texture_integer
-#define GL_EXT_texture_integer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);
-GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params);
-GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha);
-GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha);
-typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
-#endif
-
-#ifndef GL_GREMEDY_frame_terminator
-#define GL_GREMEDY_frame_terminator 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFrameTerminatorGREMEDY (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);
-#endif
-
-#ifndef GL_NV_conditional_render
-#define GL_NV_conditional_render 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode);
-GLAPI void APIENTRY glEndConditionalRenderNV (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);
-typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void);
-#endif
-
-#ifndef GL_NV_present_video
-#define GL_NV_present_video 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
-GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
-GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params);
-GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params);
-GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
-typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
-typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params);
-typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params);
-#endif
-
-#ifndef GL_EXT_transform_feedback
-#define GL_EXT_transform_feedback 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode);
-GLAPI void APIENTRY glEndTransformFeedbackEXT (void);
-GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
-GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer);
-GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
-GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode);
-typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void);
-typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
-typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer);
-typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
-typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
-#endif
-
-#ifndef GL_EXT_direct_state_access
-#define GL_EXT_direct_state_access 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask);
-GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask);
-GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m);
-GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m);
-GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m);
-GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m);
-GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode);
-GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
-GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
-GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
-GLAPI void APIENTRY glMatrixPopEXT (GLenum mode);
-GLAPI void APIENTRY glMatrixPushEXT (GLenum mode);
-GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m);
-GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m);
-GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m);
-GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m);
-GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param);
-GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
-GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
-GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);
-GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
-GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);
-GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture);
-GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index);
-GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index);
-GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);
-GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);
-GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);
-GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);
-GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param);
-GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);
-GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data);
-GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data);
-GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data);
-GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img);
-GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
-GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img);
-GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string);
-GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params);
-GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params);
-GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params);
-GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params);
-GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string);
-GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);
-GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
-GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params);
-GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);
-GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params);
-GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);
-GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params);
-GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params);
-GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params);
-GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params);
-GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);
-GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params);
-GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0);
-GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1);
-GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0);
-GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1);
-GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
-GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0);
-GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1);
-GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
-GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
-GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage);
-GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data);
-GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access);
-GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer);
-GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
-GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length);
-GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params);
-GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data);
-GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);
-GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);
-GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params);
-GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target);
-GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target);
-GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target);
-GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode);
-GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs);
-GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode);
-GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params);
-GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
-GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
-GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);
-GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer);
-GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer);
-GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x);
-GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
-typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
-typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m);
-typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m);
-typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m);
-typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m);
-typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
-typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
-typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
-typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
-typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
-typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
-typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
-typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
-typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);
-typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
-typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
-typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);
-typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);
-typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data);
-typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data);
-typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img);
-typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params);
-typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);
-typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params);
-typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params);
-typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params);
-typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
-typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage);
-typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data);
-typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);
-typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
-typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
-typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);
-typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params);
-typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data);
-typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);
-typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);
-typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params);
-typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);
-typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);
-typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
-#endif
-
-#ifndef GL_EXT_vertex_array_bgra
-#define GL_EXT_vertex_array_bgra 1
-#endif
-
-#ifndef GL_EXT_texture_swizzle
-#define GL_EXT_texture_swizzle 1
-#endif
-
-#ifndef GL_NV_explicit_multisample
-#define GL_NV_explicit_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val);
-GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask);
-GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val);
-typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask);
-typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer);
-#endif
-
-#ifndef GL_NV_transform_feedback2
-#define GL_NV_transform_feedback2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id);
-GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids);
-GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids);
-GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id);
-GLAPI void APIENTRY glPauseTransformFeedbackNV (void);
-GLAPI void APIENTRY glResumeTransformFeedbackNV (void);
-GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids);
-typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);
-typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);
-typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);
-#endif
-
-#ifndef GL_ATI_meminfo
-#define GL_ATI_meminfo 1
-#endif
-
-#ifndef GL_AMD_performance_monitor
-#define GL_AMD_performance_monitor 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
-GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
-GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
-GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
-GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
-GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
-GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
-GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
-GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor);
-GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
-typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
-typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
-typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
-typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
-typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
-#endif
-
-#ifndef GL_AMD_texture_texture4
-#define GL_AMD_texture_texture4 1
-#endif
-
-#ifndef GL_AMD_vertex_shader_tesselator
-#define GL_AMD_vertex_shader_tesselator 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor);
-GLAPI void APIENTRY glTessellationModeAMD (GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);
-typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);
-#endif
-
-#ifndef GL_EXT_provoking_vertex
-#define GL_EXT_provoking_vertex 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);
-#endif
-
-#ifndef GL_EXT_texture_snorm
-#define GL_EXT_texture_snorm 1
-#endif
-
-#ifndef GL_AMD_draw_buffers_blend
-#define GL_AMD_draw_buffers_blend 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst);
-GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode);
-GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-#endif
-
-#ifndef GL_APPLE_texture_range
-#define GL_APPLE_texture_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer);
-GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params);
-#endif
-
-#ifndef GL_APPLE_float_pixels
-#define GL_APPLE_float_pixels 1
-#endif
-
-#ifndef GL_APPLE_vertex_program_evaluators
-#define GL_APPLE_vertex_program_evaluators 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname);
-GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname);
-GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname);
-GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
-GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
-GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
-GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
-typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);
-typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
-typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
-typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
-typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
-#endif
-
-#ifndef GL_APPLE_aux_depth_stencil
-#define GL_APPLE_aux_depth_stencil 1
-#endif
-
-#ifndef GL_APPLE_object_purgeable
-#define GL_APPLE_object_purgeable 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);
-GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);
-GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
-typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
-typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_APPLE_row_bytes
-#define GL_APPLE_row_bytes 1
-#endif
-
-#ifndef GL_APPLE_rgb_422
-#define GL_APPLE_rgb_422 1
-#endif
-
-#ifndef GL_NV_video_capture
-#define GL_NV_video_capture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot);
-GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
-GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
-GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot);
-GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
-GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
-GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
-GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
-GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
-GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
-GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
-typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
-typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
-typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
-typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
-typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
-typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
-#endif
-
-#ifndef GL_NV_copy_image
-#define GL_NV_copy_image 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
-#endif
-
-#ifndef GL_EXT_separate_shader_objects
-#define GL_EXT_separate_shader_objects 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program);
-GLAPI void APIENTRY glActiveProgramEXT (GLuint program);
-GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);
-typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);
-typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string);
-#endif
-
-#ifndef GL_NV_parameter_buffer_object2
-#define GL_NV_parameter_buffer_object2 1
-#endif
-
-#ifndef GL_NV_shader_buffer_load
-#define GL_NV_shader_buffer_load 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access);
-GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target);
-GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target);
-GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access);
-GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer);
-GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer);
-GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params);
-GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params);
-GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result);
-GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value);
-GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params);
-GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value);
-GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);
-typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);
-typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);
-typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer);
-typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params);
-typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params);
-typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result);
-typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);
-typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-#endif
-
-#ifndef GL_NV_vertex_buffer_unified_memory
-#define GL_NV_vertex_buffer_unified_memory 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
-GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride);
-GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride);
-GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride);
-GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride);
-GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride);
-GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride);
-GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride);
-GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride);
-GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
-GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);
-GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
-typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
-typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
-#endif
-
-#ifndef GL_NV_texture_barrier
-#define GL_NV_texture_barrier 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTextureBarrierNV (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void);
-#endif
-
-#ifndef GL_AMD_shader_stencil_export
-#define GL_AMD_shader_stencil_export 1
-#endif
-
-#ifndef GL_AMD_seamless_cubemap_per_texture
-#define GL_AMD_seamless_cubemap_per_texture 1
-#endif
-
-#ifndef GL_AMD_conservative_depth
-#define GL_AMD_conservative_depth 1
-#endif
-
-#ifndef GL_EXT_shader_image_load_store
-#define GL_EXT_shader_image_load_store 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);
-GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);
-typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers);
-#endif
-
-#ifndef GL_EXT_vertex_attrib_64bit
-#define GL_EXT_vertex_attrib_64bit 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x);
-GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y);
-GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v);
-GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params);
-GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
-#endif
-
-#ifndef GL_NV_gpu_program5
-#define GL_NV_gpu_program5 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params);
-GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param);
-#endif
-
-#ifndef GL_NV_gpu_shader5
-#define GL_NV_gpu_shader5 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x);
-GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y);
-GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
-GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
-GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x);
-GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y);
-GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
-GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
-GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params);
-GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x);
-GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);
-GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
-GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
-GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x);
-GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);
-GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
-GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
-GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x);
-typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y);
-typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
-typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
-typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x);
-typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y);
-typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
-typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
-typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
-#endif
-
-#ifndef GL_NV_shader_buffer_store
-#define GL_NV_shader_buffer_store 1
-#endif
-
-#ifndef GL_NV_tessellation_program5
-#define GL_NV_tessellation_program5 1
-#endif
-
-#ifndef GL_NV_vertex_attrib_integer_64bit
-#define GL_NV_vertex_attrib_integer_64bit 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x);
-GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y);
-GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);
-GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
-GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v);
-GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v);
-GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v);
-GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v);
-GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x);
-GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y);
-GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
-GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
-GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v);
-GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v);
-GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v);
-GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v);
-GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params);
-GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params);
-GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
-#endif
-
-#ifndef GL_NV_multisample_coverage
-#define GL_NV_multisample_coverage 1
-#endif
-
-#ifndef GL_AMD_name_gen_delete
-#define GL_AMD_name_gen_delete 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names);
-GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names);
-GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names);
-typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names);
-typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name);
-#endif
-
-#ifndef GL_AMD_debug_output
-#define GL_AMD_debug_output 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);
-GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam);
-GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam);
-typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);
-#endif
-
-#ifndef GL_NV_vdpau_interop
-#define GL_NV_vdpau_interop 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress);
-GLAPI void APIENTRY glVDPAUFiniNV (void);
-GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
-GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
-GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface);
-GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface);
-GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
-GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access);
-GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);
-GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress);
-typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void);
-typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
-typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
-typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface);
-typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface);
-typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
-typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access);
-typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);
-typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
-#endif
-
-#ifndef GL_AMD_transform_feedback3_lines_triangles
-#define GL_AMD_transform_feedback3_lines_triangles 1
-#endif
-
-#ifndef GL_AMD_depth_clamp_separate
-#define GL_AMD_depth_clamp_separate 1
-#endif
-
-#ifndef GL_EXT_texture_sRGB_decode
-#define GL_EXT_texture_sRGB_decode 1
-#endif
-
-#ifndef GL_NV_texture_multisample
-#define GL_NV_texture_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
-GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
-GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
-GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
-GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
-GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
-typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
-typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
-typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
-typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
-typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
-#endif
-
-#ifndef GL_AMD_blend_minmax_factor
-#define GL_AMD_blend_minmax_factor 1
-#endif
-
-#ifndef GL_AMD_sample_positions
-#define GL_AMD_sample_positions 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val);
-#endif
-
-#ifndef GL_EXT_x11_sync_object
-#define GL_EXT_x11_sync_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
-#endif
-
-#ifndef GL_AMD_multi_draw_indirect
-#define GL_AMD_multi_draw_indirect 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
-GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
-#endif
-
-#ifndef GL_EXT_framebuffer_multisample_blit_scaled
-#define GL_EXT_framebuffer_multisample_blit_scaled 1
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/thirdparty/glext/GL/glext.sed b/thirdparty/glext/GL/glext.sed
deleted file mode 100644 (file)
index bc4835d..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# MacOSX doesn't follow the official glext.h definition for GLhandleARB, and
-# instead defines it as:
-#
-#   typedef void *GLhandleARB;
-#
-# But to avoid integer to pointer conversion issues, we simply use 'unsigned
-# long' which should be the same size on all supported architectures.
-
-/^typedef unsigned int GLhandleARB;$/ {
-
-    i\
-#ifdef __APPLE__\
-typedef unsigned long GLhandleARB;\
-#else
-
-    a\
-#endif
-
-}
diff --git a/thirdparty/glext/GL/glxext.h b/thirdparty/glext/GL/glxext.h
deleted file mode 100644 (file)
index 3c47dc3..0000000
+++ /dev/null
@@ -1,993 +0,0 @@
-#ifndef __glxext_h_
-#define __glxext_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-** Copyright (c) 2007-2010 The Khronos Group Inc.
-** 
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-** 
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-** 
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
-/* Function declaration macros - to move into glplatform.h */
-
-#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
-#define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
-#endif
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-#ifndef APIENTRYP
-#define APIENTRYP APIENTRY *
-#endif
-#ifndef GLAPI
-#define GLAPI extern
-#endif
-
-/*************************************************************/
-
-/* Header file version number, required by OpenGL ABI for Linux */
-/* glxext.h last updated 2010/08/06 */
-/* Current version at http://www.opengl.org/registry/ */
-#define GLX_GLXEXT_VERSION 32
-
-#ifndef GLX_VERSION_1_3
-#define GLX_WINDOW_BIT                     0x00000001
-#define GLX_PIXMAP_BIT                     0x00000002
-#define GLX_PBUFFER_BIT                    0x00000004
-#define GLX_RGBA_BIT                       0x00000001
-#define GLX_COLOR_INDEX_BIT                0x00000002
-#define GLX_PBUFFER_CLOBBER_MASK           0x08000000
-#define GLX_FRONT_LEFT_BUFFER_BIT          0x00000001
-#define GLX_FRONT_RIGHT_BUFFER_BIT         0x00000002
-#define GLX_BACK_LEFT_BUFFER_BIT           0x00000004
-#define GLX_BACK_RIGHT_BUFFER_BIT          0x00000008
-#define GLX_AUX_BUFFERS_BIT                0x00000010
-#define GLX_DEPTH_BUFFER_BIT               0x00000020
-#define GLX_STENCIL_BUFFER_BIT             0x00000040
-#define GLX_ACCUM_BUFFER_BIT               0x00000080
-#define GLX_CONFIG_CAVEAT                  0x20
-#define GLX_X_VISUAL_TYPE                  0x22
-#define GLX_TRANSPARENT_TYPE               0x23
-#define GLX_TRANSPARENT_INDEX_VALUE        0x24
-#define GLX_TRANSPARENT_RED_VALUE          0x25
-#define GLX_TRANSPARENT_GREEN_VALUE        0x26
-#define GLX_TRANSPARENT_BLUE_VALUE         0x27
-#define GLX_TRANSPARENT_ALPHA_VALUE        0x28
-#define GLX_DONT_CARE                      0xFFFFFFFF
-#define GLX_NONE                           0x8000
-#define GLX_SLOW_CONFIG                    0x8001
-#define GLX_TRUE_COLOR                     0x8002
-#define GLX_DIRECT_COLOR                   0x8003
-#define GLX_PSEUDO_COLOR                   0x8004
-#define GLX_STATIC_COLOR                   0x8005
-#define GLX_GRAY_SCALE                     0x8006
-#define GLX_STATIC_GRAY                    0x8007
-#define GLX_TRANSPARENT_RGB                0x8008
-#define GLX_TRANSPARENT_INDEX              0x8009
-#define GLX_VISUAL_ID                      0x800B
-#define GLX_SCREEN                         0x800C
-#define GLX_NON_CONFORMANT_CONFIG          0x800D
-#define GLX_DRAWABLE_TYPE                  0x8010
-#define GLX_RENDER_TYPE                    0x8011
-#define GLX_X_RENDERABLE                   0x8012
-#define GLX_FBCONFIG_ID                    0x8013
-#define GLX_RGBA_TYPE                      0x8014
-#define GLX_COLOR_INDEX_TYPE               0x8015
-#define GLX_MAX_PBUFFER_WIDTH              0x8016
-#define GLX_MAX_PBUFFER_HEIGHT             0x8017
-#define GLX_MAX_PBUFFER_PIXELS             0x8018
-#define GLX_PRESERVED_CONTENTS             0x801B
-#define GLX_LARGEST_PBUFFER                0x801C
-#define GLX_WIDTH                          0x801D
-#define GLX_HEIGHT                         0x801E
-#define GLX_EVENT_MASK                     0x801F
-#define GLX_DAMAGED                        0x8020
-#define GLX_SAVED                          0x8021
-#define GLX_WINDOW                         0x8022
-#define GLX_PBUFFER                        0x8023
-#define GLX_PBUFFER_HEIGHT                 0x8040
-#define GLX_PBUFFER_WIDTH                  0x8041
-#endif
-
-#ifndef GLX_VERSION_1_4
-#define GLX_SAMPLE_BUFFERS                 100000
-#define GLX_SAMPLES                        100001
-#endif
-
-#ifndef GLX_ARB_get_proc_address
-#endif
-
-#ifndef GLX_ARB_multisample
-#define GLX_SAMPLE_BUFFERS_ARB             100000
-#define GLX_SAMPLES_ARB                    100001
-#endif
-
-#ifndef GLX_ARB_vertex_buffer_object
-#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095
-#endif
-
-#ifndef GLX_ARB_fbconfig_float
-#define GLX_RGBA_FLOAT_TYPE_ARB            0x20B9
-#define GLX_RGBA_FLOAT_BIT_ARB             0x00000004
-#endif
-
-#ifndef GLX_ARB_framebuffer_sRGB
-#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB   0x20B2
-#endif
-
-#ifndef GLX_ARB_create_context
-#define GLX_CONTEXT_DEBUG_BIT_ARB          0x00000001
-#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
-#define GLX_CONTEXT_MAJOR_VERSION_ARB      0x2091
-#define GLX_CONTEXT_MINOR_VERSION_ARB      0x2092
-#define GLX_CONTEXT_FLAGS_ARB              0x2094
-#endif
-
-#ifndef GLX_ARB_create_context_profile
-#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB   0x00000001
-#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
-#define GLX_CONTEXT_PROFILE_MASK_ARB       0x9126
-#endif
-
-#ifndef GLX_ARB_create_context_robustness
-#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB  0x00000004
-#define GLX_LOSE_CONTEXT_ON_RESET_ARB      0x8252
-#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GLX_NO_RESET_NOTIFICATION_ARB      0x8261
-#endif
-
-#ifndef GLX_SGIS_multisample
-#define GLX_SAMPLE_BUFFERS_SGIS            100000
-#define GLX_SAMPLES_SGIS                   100001
-#endif
-
-#ifndef GLX_EXT_visual_info
-#define GLX_X_VISUAL_TYPE_EXT              0x22
-#define GLX_TRANSPARENT_TYPE_EXT           0x23
-#define GLX_TRANSPARENT_INDEX_VALUE_EXT    0x24
-#define GLX_TRANSPARENT_RED_VALUE_EXT      0x25
-#define GLX_TRANSPARENT_GREEN_VALUE_EXT    0x26
-#define GLX_TRANSPARENT_BLUE_VALUE_EXT     0x27
-#define GLX_TRANSPARENT_ALPHA_VALUE_EXT    0x28
-#define GLX_NONE_EXT                       0x8000
-#define GLX_TRUE_COLOR_EXT                 0x8002
-#define GLX_DIRECT_COLOR_EXT               0x8003
-#define GLX_PSEUDO_COLOR_EXT               0x8004
-#define GLX_STATIC_COLOR_EXT               0x8005
-#define GLX_GRAY_SCALE_EXT                 0x8006
-#define GLX_STATIC_GRAY_EXT                0x8007
-#define GLX_TRANSPARENT_RGB_EXT            0x8008
-#define GLX_TRANSPARENT_INDEX_EXT          0x8009
-#endif
-
-#ifndef GLX_SGI_swap_control
-#endif
-
-#ifndef GLX_SGI_video_sync
-#endif
-
-#ifndef GLX_SGI_make_current_read
-#endif
-
-#ifndef GLX_SGIX_video_source
-#endif
-
-#ifndef GLX_EXT_visual_rating
-#define GLX_VISUAL_CAVEAT_EXT              0x20
-#define GLX_SLOW_VISUAL_EXT                0x8001
-#define GLX_NON_CONFORMANT_VISUAL_EXT      0x800D
-/* reuse GLX_NONE_EXT */
-#endif
-
-#ifndef GLX_EXT_import_context
-#define GLX_SHARE_CONTEXT_EXT              0x800A
-#define GLX_VISUAL_ID_EXT                  0x800B
-#define GLX_SCREEN_EXT                     0x800C
-#endif
-
-#ifndef GLX_SGIX_fbconfig
-#define GLX_WINDOW_BIT_SGIX                0x00000001
-#define GLX_PIXMAP_BIT_SGIX                0x00000002
-#define GLX_RGBA_BIT_SGIX                  0x00000001
-#define GLX_COLOR_INDEX_BIT_SGIX           0x00000002
-#define GLX_DRAWABLE_TYPE_SGIX             0x8010
-#define GLX_RENDER_TYPE_SGIX               0x8011
-#define GLX_X_RENDERABLE_SGIX              0x8012
-#define GLX_FBCONFIG_ID_SGIX               0x8013
-#define GLX_RGBA_TYPE_SGIX                 0x8014
-#define GLX_COLOR_INDEX_TYPE_SGIX          0x8015
-/* reuse GLX_SCREEN_EXT */
-#endif
-
-#ifndef GLX_SGIX_pbuffer
-#define GLX_PBUFFER_BIT_SGIX               0x00000004
-#define GLX_BUFFER_CLOBBER_MASK_SGIX       0x08000000
-#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX     0x00000001
-#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX    0x00000002
-#define GLX_BACK_LEFT_BUFFER_BIT_SGIX      0x00000004
-#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX     0x00000008
-#define GLX_AUX_BUFFERS_BIT_SGIX           0x00000010
-#define GLX_DEPTH_BUFFER_BIT_SGIX          0x00000020
-#define GLX_STENCIL_BUFFER_BIT_SGIX        0x00000040
-#define GLX_ACCUM_BUFFER_BIT_SGIX          0x00000080
-#define GLX_SAMPLE_BUFFERS_BIT_SGIX        0x00000100
-#define GLX_MAX_PBUFFER_WIDTH_SGIX         0x8016
-#define GLX_MAX_PBUFFER_HEIGHT_SGIX        0x8017
-#define GLX_MAX_PBUFFER_PIXELS_SGIX        0x8018
-#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX     0x8019
-#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX    0x801A
-#define GLX_PRESERVED_CONTENTS_SGIX        0x801B
-#define GLX_LARGEST_PBUFFER_SGIX           0x801C
-#define GLX_WIDTH_SGIX                     0x801D
-#define GLX_HEIGHT_SGIX                    0x801E
-#define GLX_EVENT_MASK_SGIX                0x801F
-#define GLX_DAMAGED_SGIX                   0x8020
-#define GLX_SAVED_SGIX                     0x8021
-#define GLX_WINDOW_SGIX                    0x8022
-#define GLX_PBUFFER_SGIX                   0x8023
-#endif
-
-#ifndef GLX_SGI_cushion
-#endif
-
-#ifndef GLX_SGIX_video_resize
-#define GLX_SYNC_FRAME_SGIX                0x00000000
-#define GLX_SYNC_SWAP_SGIX                 0x00000001
-#endif
-
-#ifndef GLX_SGIX_dmbuffer
-#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX     0x8024
-#endif
-
-#ifndef GLX_SGIX_swap_group
-#endif
-
-#ifndef GLX_SGIX_swap_barrier
-#endif
-
-#ifndef GLX_SGIS_blended_overlay
-#define GLX_BLENDED_RGBA_SGIS              0x8025
-#endif
-
-#ifndef GLX_SGIS_shared_multisample
-#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026
-#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027
-#endif
-
-#ifndef GLX_SUN_get_transparent_index
-#endif
-
-#ifndef GLX_3DFX_multisample
-#define GLX_SAMPLE_BUFFERS_3DFX            0x8050
-#define GLX_SAMPLES_3DFX                   0x8051
-#endif
-
-#ifndef GLX_MESA_copy_sub_buffer
-#endif
-
-#ifndef GLX_MESA_pixmap_colormap
-#endif
-
-#ifndef GLX_MESA_release_buffers
-#endif
-
-#ifndef GLX_MESA_set_3dfx_mode
-#define GLX_3DFX_WINDOW_MODE_MESA          0x1
-#define GLX_3DFX_FULLSCREEN_MODE_MESA      0x2
-#endif
-
-#ifndef GLX_SGIX_visual_select_group
-#define GLX_VISUAL_SELECT_GROUP_SGIX       0x8028
-#endif
-
-#ifndef GLX_OML_swap_method
-#define GLX_SWAP_METHOD_OML                0x8060
-#define GLX_SWAP_EXCHANGE_OML              0x8061
-#define GLX_SWAP_COPY_OML                  0x8062
-#define GLX_SWAP_UNDEFINED_OML             0x8063
-#endif
-
-#ifndef GLX_OML_sync_control
-#endif
-
-#ifndef GLX_NV_float_buffer
-#define GLX_FLOAT_COMPONENTS_NV            0x20B0
-#endif
-
-#ifndef GLX_SGIX_hyperpipe
-#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80
-#define GLX_BAD_HYPERPIPE_CONFIG_SGIX      91
-#define GLX_BAD_HYPERPIPE_SGIX             92
-#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX    0x00000001
-#define GLX_HYPERPIPE_RENDER_PIPE_SGIX     0x00000002
-#define GLX_PIPE_RECT_SGIX                 0x00000001
-#define GLX_PIPE_RECT_LIMITS_SGIX          0x00000002
-#define GLX_HYPERPIPE_STEREO_SGIX          0x00000003
-#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX   0x00000004
-#define GLX_HYPERPIPE_ID_SGIX              0x8030
-#endif
-
-#ifndef GLX_MESA_agp_offset
-#endif
-
-#ifndef GLX_EXT_fbconfig_packed_float
-#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT   0x20B1
-#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT    0x00000008
-#endif
-
-#ifndef GLX_EXT_framebuffer_sRGB
-#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT   0x20B2
-#endif
-
-#ifndef GLX_EXT_texture_from_pixmap
-#define GLX_TEXTURE_1D_BIT_EXT             0x00000001
-#define GLX_TEXTURE_2D_BIT_EXT             0x00000002
-#define GLX_TEXTURE_RECTANGLE_BIT_EXT      0x00000004
-#define GLX_BIND_TO_TEXTURE_RGB_EXT        0x20D0
-#define GLX_BIND_TO_TEXTURE_RGBA_EXT       0x20D1
-#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT     0x20D2
-#define GLX_BIND_TO_TEXTURE_TARGETS_EXT    0x20D3
-#define GLX_Y_INVERTED_EXT                 0x20D4
-#define GLX_TEXTURE_FORMAT_EXT             0x20D5
-#define GLX_TEXTURE_TARGET_EXT             0x20D6
-#define GLX_MIPMAP_TEXTURE_EXT             0x20D7
-#define GLX_TEXTURE_FORMAT_NONE_EXT        0x20D8
-#define GLX_TEXTURE_FORMAT_RGB_EXT         0x20D9
-#define GLX_TEXTURE_FORMAT_RGBA_EXT        0x20DA
-#define GLX_TEXTURE_1D_EXT                 0x20DB
-#define GLX_TEXTURE_2D_EXT                 0x20DC
-#define GLX_TEXTURE_RECTANGLE_EXT          0x20DD
-#define GLX_FRONT_LEFT_EXT                 0x20DE
-#define GLX_FRONT_RIGHT_EXT                0x20DF
-#define GLX_BACK_LEFT_EXT                  0x20E0
-#define GLX_BACK_RIGHT_EXT                 0x20E1
-#define GLX_FRONT_EXT                      GLX_FRONT_LEFT_EXT
-#define GLX_BACK_EXT                       GLX_BACK_LEFT_EXT
-#define GLX_AUX0_EXT                       0x20E2
-#define GLX_AUX1_EXT                       0x20E3
-#define GLX_AUX2_EXT                       0x20E4
-#define GLX_AUX3_EXT                       0x20E5
-#define GLX_AUX4_EXT                       0x20E6
-#define GLX_AUX5_EXT                       0x20E7
-#define GLX_AUX6_EXT                       0x20E8
-#define GLX_AUX7_EXT                       0x20E9
-#define GLX_AUX8_EXT                       0x20EA
-#define GLX_AUX9_EXT                       0x20EB
-#endif
-
-#ifndef GLX_NV_present_video
-#define GLX_NUM_VIDEO_SLOTS_NV             0x20F0
-#endif
-
-#ifndef GLX_NV_video_out
-#define GLX_VIDEO_OUT_COLOR_NV             0x20C3
-#define GLX_VIDEO_OUT_ALPHA_NV             0x20C4
-#define GLX_VIDEO_OUT_DEPTH_NV             0x20C5
-#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV   0x20C6
-#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV   0x20C7
-#define GLX_VIDEO_OUT_FRAME_NV             0x20C8
-#define GLX_VIDEO_OUT_FIELD_1_NV           0x20C9
-#define GLX_VIDEO_OUT_FIELD_2_NV           0x20CA
-#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB
-#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC
-#endif
-
-#ifndef GLX_NV_swap_group
-#endif
-
-#ifndef GLX_NV_video_capture
-#define GLX_DEVICE_ID_NV                   0x20CD
-#define GLX_UNIQUE_ID_NV                   0x20CE
-#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV     0x20CF
-#endif
-
-#ifndef GLX_EXT_swap_control
-#define GLX_SWAP_INTERVAL_EXT              0x20F1
-#define GLX_MAX_SWAP_INTERVAL_EXT          0x20F2
-#endif
-
-#ifndef GLX_NV_copy_image
-#endif
-
-#ifndef GLX_INTEL_swap_event
-#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000
-#define GLX_EXCHANGE_COMPLETE_INTEL        0x8180
-#define GLX_COPY_COMPLETE_INTEL            0x8181
-#define GLX_FLIP_COMPLETE_INTEL            0x8182
-#endif
-
-#ifndef GLX_NV_multisample_coverage
-#define GLX_COVERAGE_SAMPLES_NV            100001
-#define GLX_COLOR_SAMPLES_NV               0x20B3
-#endif
-
-#ifndef GLX_AMD_gpu_association
-#define GLX_GPU_VENDOR_AMD                 0x1F00
-#define GLX_GPU_RENDERER_STRING_AMD        0x1F01
-#define GLX_GPU_OPENGL_VERSION_STRING_AMD  0x1F02
-#define GLX_GPU_FASTEST_TARGET_GPUS_AMD    0x21A2
-#define GLX_GPU_RAM_AMD                    0x21A3
-#define GLX_GPU_CLOCK_AMD                  0x21A4
-#define GLX_GPU_NUM_PIPES_AMD              0x21A5
-#define GLX_GPU_NUM_SIMD_AMD               0x21A6
-#define GLX_GPU_NUM_RB_AMD                 0x21A7
-#define GLX_GPU_NUM_SPI_AMD                0x21A8
-#endif
-
-#ifndef GLX_EXT_create_context_es2_profile
-#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT    0x00000004
-#endif
-
-
-/*************************************************************/
-
-#ifndef GLX_ARB_get_proc_address
-typedef void (*__GLXextFuncPtr)(void);
-#endif
-
-#ifndef GLX_SGIX_video_source
-typedef XID GLXVideoSourceSGIX;
-#endif
-
-#ifndef GLX_SGIX_fbconfig
-typedef XID GLXFBConfigIDSGIX;
-typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
-#endif
-
-#ifndef GLX_SGIX_pbuffer
-typedef XID GLXPbufferSGIX;
-typedef struct {
-    int type;
-    unsigned long serial;        /* # of last request processed by server */
-    Bool send_event;             /* true if this came for SendEvent request */
-    Display *display;            /* display the event was read from */
-    GLXDrawable drawable;        /* i.d. of Drawable */
-    int event_type;              /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */
-    int draw_type;               /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */
-    unsigned int mask;   /* mask indicating which buffers are affected*/
-    int x, y;
-    int width, height;
-    int count;           /* if nonzero, at least this many more */
-} GLXBufferClobberEventSGIX;
-#endif
-
-#ifndef GLX_NV_video_output
-typedef unsigned int GLXVideoDeviceNV;
-#endif
-
-#ifndef GLX_NV_video_capture
-typedef XID GLXVideoCaptureDeviceNV;
-#endif
-
-#ifndef GLEXT_64_TYPES_DEFINED
-/* This code block is duplicated in glext.h, so must be protected */
-#define GLEXT_64_TYPES_DEFINED
-/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
-/* (as used in the GLX_OML_sync_control extension). */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#include <inttypes.h>
-#elif defined(__sun__) || defined(__digital__)
-#include <inttypes.h>
-#if defined(__STDC__)
-#if defined(__arch64__) || defined(_LP64)
-typedef long int int64_t;
-typedef unsigned long int uint64_t;
-#else
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#endif /* __arch64__ */
-#endif /* __STDC__ */
-#elif defined( __VMS ) || defined(__sgi)
-#include <inttypes.h>
-#elif defined(__SCO__) || defined(__USLC__)
-#include <stdint.h>
-#elif defined(__UNIXOS2__) || defined(__SOL64__)
-typedef long int int32_t;
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#elif defined(_WIN32) && defined(__GNUC__)
-#include <stdint.h>
-#elif defined(_WIN32)
-typedef __int32 int32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#else
-#include <inttypes.h>     /* Fallback option */
-#endif
-#endif
-
-#ifndef GLX_VERSION_1_3
-#define GLX_VERSION_1_3 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern GLXFBConfig * glXGetFBConfigs (Display *dpy, int screen, int *nelements);
-extern GLXFBConfig * glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements);
-extern int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value);
-extern XVisualInfo * glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config);
-extern GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
-extern void glXDestroyWindow (Display *dpy, GLXWindow win);
-extern GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
-extern void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap);
-extern GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list);
-extern void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf);
-extern void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
-extern GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
-extern Bool glXMakeContextCurrent (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
-extern GLXDrawable glXGetCurrentReadDrawable (void);
-extern Display * glXGetCurrentDisplay (void);
-extern int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value);
-extern void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask);
-extern void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
-typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
-typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
-typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
-typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
-typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
-typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
-typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
-typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
-typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
-typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
-typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
-typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
-typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
-typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void);
-typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
-typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
-typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
-#endif
-
-#ifndef GLX_VERSION_1_4
-#define GLX_VERSION_1_4 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *procName);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
-#endif
-
-#ifndef GLX_ARB_get_proc_address
-#define GLX_ARB_get_proc_address 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);
-#endif
-
-#ifndef GLX_ARB_multisample
-#define GLX_ARB_multisample 1
-#endif
-
-#ifndef GLX_ARB_fbconfig_float
-#define GLX_ARB_fbconfig_float 1
-#endif
-
-#ifndef GLX_ARB_framebuffer_sRGB
-#define GLX_ARB_framebuffer_sRGB 1
-#endif
-
-#ifndef GLX_ARB_create_context
-#define GLX_ARB_create_context 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern GLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
-#endif
-
-#ifndef GLX_ARB_create_context_profile
-#define GLX_ARB_create_context_profile 1
-#endif
-
-#ifndef GLX_ARB_create_context_robustness
-#define GLX_ARB_create_context_robustness 1
-#endif
-
-#ifndef GLX_SGIS_multisample
-#define GLX_SGIS_multisample 1
-#endif
-
-#ifndef GLX_EXT_visual_info
-#define GLX_EXT_visual_info 1
-#endif
-
-#ifndef GLX_SGI_swap_control
-#define GLX_SGI_swap_control 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXSwapIntervalSGI (int interval);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
-#endif
-
-#ifndef GLX_SGI_video_sync
-#define GLX_SGI_video_sync 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXGetVideoSyncSGI (unsigned int *count);
-extern int glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count);
-typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count);
-#endif
-
-#ifndef GLX_SGI_make_current_read
-#define GLX_SGI_make_current_read 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Bool glXMakeCurrentReadSGI (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
-extern GLXDrawable glXGetCurrentReadDrawableSGI (void);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
-typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);
-#endif
-
-#ifndef GLX_SGIX_video_source
-#define GLX_SGIX_video_source 1
-#ifdef _VL_H
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
-extern void glXDestroyGLXVideoSourceSGIX (Display *dpy, GLXVideoSourceSGIX glxvideosource);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
-typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource);
-#endif /* _VL_H */
-#endif
-
-#ifndef GLX_EXT_visual_rating
-#define GLX_EXT_visual_rating 1
-#endif
-
-#ifndef GLX_EXT_import_context
-#define GLX_EXT_import_context 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Display * glXGetCurrentDisplayEXT (void);
-extern int glXQueryContextInfoEXT (Display *dpy, GLXContext context, int attribute, int *value);
-extern GLXContextID glXGetContextIDEXT (const GLXContext context);
-extern GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID);
-extern void glXFreeContextEXT (Display *dpy, GLXContext context);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void);
-typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value);
-typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);
-typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID);
-typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context);
-#endif
-
-#ifndef GLX_SGIX_fbconfig
-#define GLX_SGIX_fbconfig 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXGetFBConfigAttribSGIX (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
-extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *dpy, int screen, int *attrib_list, int *nelements);
-extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
-extern GLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
-extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config);
-extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
-typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements);
-typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
-typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
-typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config);
-typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis);
-#endif
-
-#ifndef GLX_SGIX_pbuffer
-#define GLX_SGIX_pbuffer 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
-extern void glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf);
-extern int glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
-extern void glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask);
-extern void glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
-typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf);
-typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
-typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask);
-typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask);
-#endif
-
-#ifndef GLX_SGI_cushion
-#define GLX_SGI_cushion 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern void glXCushionSGI (Display *dpy, Window window, float cushion);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion);
-#endif
-
-#ifndef GLX_SGIX_video_resize
-#define GLX_SGIX_video_resize 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXBindChannelToWindowSGIX (Display *display, int screen, int channel, Window window);
-extern int glXChannelRectSGIX (Display *display, int screen, int channel, int x, int y, int w, int h);
-extern int glXQueryChannelRectSGIX (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
-extern int glXQueryChannelDeltasSGIX (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
-extern int glXChannelRectSyncSGIX (Display *display, int screen, int channel, GLenum synctype);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window);
-typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h);
-typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
-typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
-typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype);
-#endif
-
-#ifndef GLX_SGIX_dmbuffer
-#define GLX_SGIX_dmbuffer 1
-#ifdef _DM_BUFFER_H_
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Bool glXAssociateDMPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
-#endif /* _DM_BUFFER_H_ */
-#endif
-
-#ifndef GLX_SGIX_swap_group
-#define GLX_SGIX_swap_group 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern void glXJoinSwapGroupSGIX (Display *dpy, GLXDrawable drawable, GLXDrawable member);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);
-#endif
-
-#ifndef GLX_SGIX_swap_barrier
-#define GLX_SGIX_swap_barrier 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern void glXBindSwapBarrierSGIX (Display *dpy, GLXDrawable drawable, int barrier);
-extern Bool glXQueryMaxSwapBarriersSGIX (Display *dpy, int screen, int *max);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);
-typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);
-#endif
-
-#ifndef GLX_SUN_get_transparent_index
-#define GLX_SUN_get_transparent_index 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
-#endif
-
-#ifndef GLX_MESA_copy_sub_buffer
-#define GLX_MESA_copy_sub_buffer 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern void glXCopySubBufferMESA (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
-#endif
-
-#ifndef GLX_MESA_pixmap_colormap
-#define GLX_MESA_pixmap_colormap 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
-#endif
-
-#ifndef GLX_MESA_release_buffers
-#define GLX_MESA_release_buffers 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Bool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable);
-#endif
-
-#ifndef GLX_MESA_set_3dfx_mode
-#define GLX_MESA_set_3dfx_mode 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Bool glXSet3DfxModeMESA (int mode);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode);
-#endif
-
-#ifndef GLX_SGIX_visual_select_group
-#define GLX_SGIX_visual_select_group 1
-#endif
-
-#ifndef GLX_OML_swap_method
-#define GLX_OML_swap_method 1
-#endif
-
-#ifndef GLX_OML_sync_control
-#define GLX_OML_sync_control 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Bool glXGetSyncValuesOML (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
-extern Bool glXGetMscRateOML (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
-extern int64_t glXSwapBuffersMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
-extern Bool glXWaitForMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
-extern Bool glXWaitForSbcOML (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
-typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
-typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
-typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
-typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
-#endif
-
-#ifndef GLX_NV_float_buffer
-#define GLX_NV_float_buffer 1
-#endif
-
-#ifndef GLX_SGIX_hyperpipe
-#define GLX_SGIX_hyperpipe 1
-
-typedef struct {
-    char    pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
-    int     networkId;
-} GLXHyperpipeNetworkSGIX;
-
-typedef struct {
-    char    pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
-    int     channel;
-    unsigned int
-      participationType;
-    int     timeSlice;
-} GLXHyperpipeConfigSGIX;
-
-typedef struct {
-    char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
-    int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
-    int destXOrigin, destYOrigin, destWidth, destHeight;
-} GLXPipeRect;
-
-typedef struct {
-    char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
-    int XOrigin, YOrigin, maxHeight, maxWidth;
-} GLXPipeRectLimits;
-
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *dpy, int *npipes);
-extern int glXHyperpipeConfigSGIX (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
-extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *dpy, int hpId, int *npipes);
-extern int glXDestroyHyperpipeConfigSGIX (Display *dpy, int hpId);
-extern int glXBindHyperpipeSGIX (Display *dpy, int hpId);
-extern int glXQueryHyperpipeBestAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
-extern int glXHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
-extern int glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);
-typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
-typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);
-typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);
-typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);
-typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
-typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
-typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
-#endif
-
-#ifndef GLX_MESA_agp_offset
-#define GLX_MESA_agp_offset 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern unsigned int glXGetAGPOffsetMESA (const void *pointer);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer);
-#endif
-
-#ifndef GLX_EXT_fbconfig_packed_float
-#define GLX_EXT_fbconfig_packed_float 1
-#endif
-
-#ifndef GLX_EXT_framebuffer_sRGB
-#define GLX_EXT_framebuffer_sRGB 1
-#endif
-
-#ifndef GLX_EXT_texture_from_pixmap
-#define GLX_EXT_texture_from_pixmap 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern void glXBindTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
-extern void glXReleaseTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
-typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer);
-#endif
-
-#ifndef GLX_NV_present_video
-#define GLX_NV_present_video 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern unsigned int * glXEnumerateVideoDevicesNV (Display *dpy, int screen, int *nelements);
-extern int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef unsigned int * ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);
-typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
-#endif
-
-#ifndef GLX_NV_video_output
-#define GLX_NV_video_output 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXGetVideoDeviceNV (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
-extern int glXReleaseVideoDeviceNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
-extern int glXBindVideoImageNV (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
-extern int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf);
-extern int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
-extern int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
-typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
-typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
-typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf);
-typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
-typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
-#endif
-
-#ifndef GLX_NV_swap_group
-#define GLX_NV_swap_group 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern Bool glXJoinSwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint group);
-extern Bool glXBindSwapBarrierNV (Display *dpy, GLuint group, GLuint barrier);
-extern Bool glXQuerySwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
-extern Bool glXQueryMaxSwapGroupsNV (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
-extern Bool glXQueryFrameCountNV (Display *dpy, int screen, GLuint *count);
-extern Bool glXResetFrameCountNV (Display *dpy, int screen);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group);
-typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier);
-typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
-typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
-typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count);
-typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen);
-#endif
-
-#ifndef GLX_NV_video_capture
-#define GLX_NV_video_capture 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXBindVideoCaptureDeviceNV (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
-extern GLXVideoCaptureDeviceNV * glXEnumerateVideoCaptureDevicesNV (Display *dpy, int screen, int *nelements);
-extern void glXLockVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);
-extern int glXQueryVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
-extern void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
-typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements);
-typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
-typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
-typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
-#endif
-
-#ifndef GLX_EXT_swap_control
-#define GLX_EXT_swap_control 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern int glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef int ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
-#endif
-
-#ifndef GLX_NV_copy_image
-#define GLX_NV_copy_image 1
-#ifdef GLX_GLXEXT_PROTOTYPES
-extern void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
-#endif /* GLX_GLXEXT_PROTOTYPES */
-typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
-#endif
-
-#ifndef GLX_INTEL_swap_event
-#define GLX_INTEL_swap_event 1
-#endif
-
-#ifndef GLX_NV_multisample_coverage
-#define GLX_NV_multisample_coverage 1
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/thirdparty/glext/GL/wglext.h b/thirdparty/glext/GL/wglext.h
deleted file mode 100644 (file)
index 3fe2e2d..0000000
+++ /dev/null
@@ -1,929 +0,0 @@
-#ifndef __wglext_h_
-#define __wglext_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-** Copyright (c) 2007-2010 The Khronos Group Inc.
-** 
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-** 
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-** 
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
-/* Function declaration macros - to move into glplatform.h */
-
-#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
-#define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
-#endif
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-#ifndef APIENTRYP
-#define APIENTRYP APIENTRY *
-#endif
-#ifndef GLAPI
-#define GLAPI extern
-#endif
-
-/*************************************************************/
-
-/* Header file version number */
-/* wglext.h last updated 2011/04/13 */
-/* Current version at http://www.opengl.org/registry/ */
-#define WGL_WGLEXT_VERSION 23
-
-#ifndef WGL_ARB_buffer_region
-#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
-#define WGL_BACK_COLOR_BUFFER_BIT_ARB  0x00000002
-#define WGL_DEPTH_BUFFER_BIT_ARB       0x00000004
-#define WGL_STENCIL_BUFFER_BIT_ARB     0x00000008
-#endif
-
-#ifndef WGL_ARB_multisample
-#define WGL_SAMPLE_BUFFERS_ARB         0x2041
-#define WGL_SAMPLES_ARB                0x2042
-#endif
-
-#ifndef WGL_ARB_extensions_string
-#endif
-
-#ifndef WGL_ARB_pixel_format
-#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_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_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
-#endif
-
-#ifndef WGL_ARB_make_current_read
-#define ERROR_INVALID_PIXEL_TYPE_ARB   0x2043
-#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
-#endif
-
-#ifndef WGL_ARB_pbuffer
-#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
-#endif
-
-#ifndef WGL_ARB_render_texture
-#define WGL_BIND_TO_TEXTURE_RGB_ARB    0x2070
-#define WGL_BIND_TO_TEXTURE_RGBA_ARB   0x2071
-#define WGL_TEXTURE_FORMAT_ARB         0x2072
-#define WGL_TEXTURE_TARGET_ARB         0x2073
-#define WGL_MIPMAP_TEXTURE_ARB         0x2074
-#define WGL_TEXTURE_RGB_ARB            0x2075
-#define WGL_TEXTURE_RGBA_ARB           0x2076
-#define WGL_NO_TEXTURE_ARB             0x2077
-#define WGL_TEXTURE_CUBE_MAP_ARB       0x2078
-#define WGL_TEXTURE_1D_ARB             0x2079
-#define WGL_TEXTURE_2D_ARB             0x207A
-#define WGL_MIPMAP_LEVEL_ARB           0x207B
-#define WGL_CUBE_MAP_FACE_ARB          0x207C
-#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
-#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
-#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
-#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
-#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
-#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
-#define WGL_FRONT_LEFT_ARB             0x2083
-#define WGL_FRONT_RIGHT_ARB            0x2084
-#define WGL_BACK_LEFT_ARB              0x2085
-#define WGL_BACK_RIGHT_ARB             0x2086
-#define WGL_AUX0_ARB                   0x2087
-#define WGL_AUX1_ARB                   0x2088
-#define WGL_AUX2_ARB                   0x2089
-#define WGL_AUX3_ARB                   0x208A
-#define WGL_AUX4_ARB                   0x208B
-#define WGL_AUX5_ARB                   0x208C
-#define WGL_AUX6_ARB                   0x208D
-#define WGL_AUX7_ARB                   0x208E
-#define WGL_AUX8_ARB                   0x208F
-#define WGL_AUX9_ARB                   0x2090
-#endif
-
-#ifndef WGL_ARB_pixel_format_float
-#define WGL_TYPE_RGBA_FLOAT_ARB        0x21A0
-#endif
-
-#ifndef WGL_ARB_framebuffer_sRGB
-#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
-#endif
-
-#ifndef WGL_ARB_create_context
-#define WGL_CONTEXT_DEBUG_BIT_ARB      0x00000001
-#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
-#define WGL_CONTEXT_MAJOR_VERSION_ARB  0x2091
-#define WGL_CONTEXT_MINOR_VERSION_ARB  0x2092
-#define WGL_CONTEXT_LAYER_PLANE_ARB    0x2093
-#define WGL_CONTEXT_FLAGS_ARB          0x2094
-#define ERROR_INVALID_VERSION_ARB      0x2095
-#endif
-
-#ifndef WGL_ARB_create_context_profile
-#define WGL_CONTEXT_PROFILE_MASK_ARB   0x9126
-#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
-#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
-#define ERROR_INVALID_PROFILE_ARB      0x2096
-#endif
-
-#ifndef WGL_ARB_create_context_robustness
-#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define WGL_LOSE_CONTEXT_ON_RESET_ARB  0x8252
-#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define WGL_NO_RESET_NOTIFICATION_ARB  0x8261
-#endif
-
-#ifndef WGL_EXT_make_current_read
-#define ERROR_INVALID_PIXEL_TYPE_EXT   0x2043
-#endif
-
-#ifndef WGL_EXT_pixel_format
-#define WGL_NUMBER_PIXEL_FORMATS_EXT   0x2000
-#define WGL_DRAW_TO_WINDOW_EXT         0x2001
-#define WGL_DRAW_TO_BITMAP_EXT         0x2002
-#define WGL_ACCELERATION_EXT           0x2003
-#define WGL_NEED_PALETTE_EXT           0x2004
-#define WGL_NEED_SYSTEM_PALETTE_EXT    0x2005
-#define WGL_SWAP_LAYER_BUFFERS_EXT     0x2006
-#define WGL_SWAP_METHOD_EXT            0x2007
-#define WGL_NUMBER_OVERLAYS_EXT        0x2008
-#define WGL_NUMBER_UNDERLAYS_EXT       0x2009
-#define WGL_TRANSPARENT_EXT            0x200A
-#define WGL_TRANSPARENT_VALUE_EXT      0x200B
-#define WGL_SHARE_DEPTH_EXT            0x200C
-#define WGL_SHARE_STENCIL_EXT          0x200D
-#define WGL_SHARE_ACCUM_EXT            0x200E
-#define WGL_SUPPORT_GDI_EXT            0x200F
-#define WGL_SUPPORT_OPENGL_EXT         0x2010
-#define WGL_DOUBLE_BUFFER_EXT          0x2011
-#define WGL_STEREO_EXT                 0x2012
-#define WGL_PIXEL_TYPE_EXT             0x2013
-#define WGL_COLOR_BITS_EXT             0x2014
-#define WGL_RED_BITS_EXT               0x2015
-#define WGL_RED_SHIFT_EXT              0x2016
-#define WGL_GREEN_BITS_EXT             0x2017
-#define WGL_GREEN_SHIFT_EXT            0x2018
-#define WGL_BLUE_BITS_EXT              0x2019
-#define WGL_BLUE_SHIFT_EXT             0x201A
-#define WGL_ALPHA_BITS_EXT             0x201B
-#define WGL_ALPHA_SHIFT_EXT            0x201C
-#define WGL_ACCUM_BITS_EXT             0x201D
-#define WGL_ACCUM_RED_BITS_EXT         0x201E
-#define WGL_ACCUM_GREEN_BITS_EXT       0x201F
-#define WGL_ACCUM_BLUE_BITS_EXT        0x2020
-#define WGL_ACCUM_ALPHA_BITS_EXT       0x2021
-#define WGL_DEPTH_BITS_EXT             0x2022
-#define WGL_STENCIL_BITS_EXT           0x2023
-#define WGL_AUX_BUFFERS_EXT            0x2024
-#define WGL_NO_ACCELERATION_EXT        0x2025
-#define WGL_GENERIC_ACCELERATION_EXT   0x2026
-#define WGL_FULL_ACCELERATION_EXT      0x2027
-#define WGL_SWAP_EXCHANGE_EXT          0x2028
-#define WGL_SWAP_COPY_EXT              0x2029
-#define WGL_SWAP_UNDEFINED_EXT         0x202A
-#define WGL_TYPE_RGBA_EXT              0x202B
-#define WGL_TYPE_COLORINDEX_EXT        0x202C
-#endif
-
-#ifndef WGL_EXT_pbuffer
-#define WGL_DRAW_TO_PBUFFER_EXT        0x202D
-#define WGL_MAX_PBUFFER_PIXELS_EXT     0x202E
-#define WGL_MAX_PBUFFER_WIDTH_EXT      0x202F
-#define WGL_MAX_PBUFFER_HEIGHT_EXT     0x2030
-#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT  0x2031
-#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
-#define WGL_PBUFFER_LARGEST_EXT        0x2033
-#define WGL_PBUFFER_WIDTH_EXT          0x2034
-#define WGL_PBUFFER_HEIGHT_EXT         0x2035
-#endif
-
-#ifndef WGL_EXT_depth_float
-#define WGL_DEPTH_FLOAT_EXT            0x2040
-#endif
-
-#ifndef WGL_3DFX_multisample
-#define WGL_SAMPLE_BUFFERS_3DFX        0x2060
-#define WGL_SAMPLES_3DFX               0x2061
-#endif
-
-#ifndef WGL_EXT_multisample
-#define WGL_SAMPLE_BUFFERS_EXT         0x2041
-#define WGL_SAMPLES_EXT                0x2042
-#endif
-
-#ifndef WGL_I3D_digital_video_control
-#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
-#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
-#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
-#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
-#endif
-
-#ifndef WGL_I3D_gamma
-#define WGL_GAMMA_TABLE_SIZE_I3D       0x204E
-#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D  0x204F
-#endif
-
-#ifndef WGL_I3D_genlock
-#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
-#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
-#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
-#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
-#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
-#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
-#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
-#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
-#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
-#endif
-
-#ifndef WGL_I3D_image_buffer
-#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
-#define WGL_IMAGE_BUFFER_LOCK_I3D      0x00000002
-#endif
-
-#ifndef WGL_I3D_swap_frame_lock
-#endif
-
-#ifndef WGL_NV_render_depth_texture
-#define WGL_BIND_TO_TEXTURE_DEPTH_NV   0x20A3
-#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
-#define WGL_DEPTH_TEXTURE_FORMAT_NV    0x20A5
-#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
-#define WGL_DEPTH_COMPONENT_NV         0x20A7
-#endif
-
-#ifndef WGL_NV_render_texture_rectangle
-#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
-#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
-#define WGL_TEXTURE_RECTANGLE_NV       0x20A2
-#endif
-
-#ifndef WGL_ATI_pixel_format_float
-#define WGL_TYPE_RGBA_FLOAT_ATI        0x21A0
-#endif
-
-#ifndef WGL_NV_float_buffer
-#define WGL_FLOAT_COMPONENTS_NV        0x20B0
-#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
-#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
-#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
-#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
-#define WGL_TEXTURE_FLOAT_R_NV         0x20B5
-#define WGL_TEXTURE_FLOAT_RG_NV        0x20B6
-#define WGL_TEXTURE_FLOAT_RGB_NV       0x20B7
-#define WGL_TEXTURE_FLOAT_RGBA_NV      0x20B8
-#endif
-
-#ifndef WGL_3DL_stereo_control
-#define WGL_STEREO_EMITTER_ENABLE_3DL  0x2055
-#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
-#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
-#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
-#endif
-
-#ifndef WGL_EXT_pixel_format_packed_float
-#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
-#endif
-
-#ifndef WGL_EXT_framebuffer_sRGB
-#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
-#endif
-
-#ifndef WGL_NV_present_video
-#define WGL_NUM_VIDEO_SLOTS_NV         0x20F0
-#endif
-
-#ifndef WGL_NV_video_out
-#define WGL_BIND_TO_VIDEO_RGB_NV       0x20C0
-#define WGL_BIND_TO_VIDEO_RGBA_NV      0x20C1
-#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
-#define WGL_VIDEO_OUT_COLOR_NV         0x20C3
-#define WGL_VIDEO_OUT_ALPHA_NV         0x20C4
-#define WGL_VIDEO_OUT_DEPTH_NV         0x20C5
-#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
-#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
-#define WGL_VIDEO_OUT_FRAME            0x20C8
-#define WGL_VIDEO_OUT_FIELD_1          0x20C9
-#define WGL_VIDEO_OUT_FIELD_2          0x20CA
-#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
-#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
-#endif
-
-#ifndef WGL_NV_swap_group
-#endif
-
-#ifndef WGL_NV_gpu_affinity
-#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
-#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
-#endif
-
-#ifndef WGL_AMD_gpu_association
-#define WGL_GPU_VENDOR_AMD             0x1F00
-#define WGL_GPU_RENDERER_STRING_AMD    0x1F01
-#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
-#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
-#define WGL_GPU_RAM_AMD                0x21A3
-#define WGL_GPU_CLOCK_AMD              0x21A4
-#define WGL_GPU_NUM_PIPES_AMD          0x21A5
-#define WGL_GPU_NUM_SIMD_AMD           0x21A6
-#define WGL_GPU_NUM_RB_AMD             0x21A7
-#define WGL_GPU_NUM_SPI_AMD            0x21A8
-#endif
-
-#ifndef WGL_NV_video_capture
-#define WGL_UNIQUE_ID_NV               0x20CE
-#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
-#endif
-
-#ifndef WGL_NV_copy_image
-#endif
-
-#ifndef WGL_NV_multisample_coverage
-#define WGL_COVERAGE_SAMPLES_NV        0x2042
-#define WGL_COLOR_SAMPLES_NV           0x20B9
-#endif
-
-#ifndef WGL_EXT_create_context_es2_profile
-#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
-#endif
-
-#ifndef WGL_NV_DX_interop
-#define WGL_ACCESS_READ_ONLY_NV        0x00000000
-#define WGL_ACCESS_READ_WRITE_NV       0x00000001
-#define WGL_ACCESS_WRITE_DISCARD_NV    0x00000002
-#endif
-
-
-/*************************************************************/
-
-#ifndef WGL_ARB_pbuffer
-DECLARE_HANDLE(HPBUFFERARB);
-#endif
-#ifndef WGL_EXT_pbuffer
-DECLARE_HANDLE(HPBUFFEREXT);
-#endif
-#ifndef WGL_NV_present_video
-DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
-#endif
-#ifndef WGL_NV_video_output
-DECLARE_HANDLE(HPVIDEODEV);
-#endif
-#ifndef WGL_NV_gpu_affinity
-DECLARE_HANDLE(HPGPUNV);
-DECLARE_HANDLE(HGPUNV);
-
-typedef struct _GPU_DEVICE {
-    DWORD  cb;
-    CHAR   DeviceName[32];
-    CHAR   DeviceString[128];
-    DWORD  Flags;
-    RECT   rcVirtualScreen;
-} GPU_DEVICE, *PGPU_DEVICE;
-#endif
-#ifndef WGL_NV_video_capture
-DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
-#endif
-
-#ifndef WGL_ARB_buffer_region
-#define WGL_ARB_buffer_region 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
-extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
-extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
-extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
-typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
-typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
-typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
-#endif
-
-#ifndef WGL_ARB_multisample
-#define WGL_ARB_multisample 1
-#endif
-
-#ifndef WGL_ARB_extensions_string
-#define WGL_ARB_extensions_string 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
-#endif
-
-#ifndef WGL_ARB_pixel_format
-#define WGL_ARB_pixel_format 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
-extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
-extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
-typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
-typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
-#endif
-
-#ifndef WGL_ARB_make_current_read
-#define WGL_ARB_make_current_read 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-extern HDC WINAPI wglGetCurrentReadDCARB (void);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
-#endif
-
-#ifndef WGL_ARB_pbuffer
-#define WGL_ARB_pbuffer 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
-extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
-extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
-extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
-extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
-typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
-typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
-typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
-typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
-#endif
-
-#ifndef WGL_ARB_render_texture
-#define WGL_ARB_render_texture 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
-extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
-extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
-typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
-typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
-#endif
-
-#ifndef WGL_ARB_pixel_format_float
-#define WGL_ARB_pixel_format_float 1
-#endif
-
-#ifndef WGL_ARB_framebuffer_sRGB
-#define WGL_ARB_framebuffer_sRGB 1
-#endif
-
-#ifndef WGL_ARB_create_context
-#define WGL_ARB_create_context 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
-#endif
-
-#ifndef WGL_ARB_create_context_profile
-#define WGL_ARB_create_context_profile 1
-#endif
-
-#ifndef WGL_ARB_create_context_robustness
-#define WGL_ARB_create_context_robustness 1
-#endif
-
-#ifndef WGL_EXT_display_color_table
-#define WGL_EXT_display_color_table 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
-extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
-extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
-extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
-typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
-typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
-typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
-#endif
-
-#ifndef WGL_EXT_extensions_string
-#define WGL_EXT_extensions_string 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern const char * WINAPI wglGetExtensionsStringEXT (void);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
-#endif
-
-#ifndef WGL_EXT_make_current_read
-#define WGL_EXT_make_current_read 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-extern HDC WINAPI wglGetCurrentReadDCEXT (void);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
-#endif
-
-#ifndef WGL_EXT_pbuffer
-#define WGL_EXT_pbuffer 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
-extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
-extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
-extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
-extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
-typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
-typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
-typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
-typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
-#endif
-
-#ifndef WGL_EXT_pixel_format
-#define WGL_EXT_pixel_format 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
-extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
-extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
-typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
-typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
-#endif
-
-#ifndef WGL_EXT_swap_control
-#define WGL_EXT_swap_control 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglSwapIntervalEXT (int interval);
-extern int WINAPI wglGetSwapIntervalEXT (void);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
-typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
-#endif
-
-#ifndef WGL_EXT_depth_float
-#define WGL_EXT_depth_float 1
-#endif
-
-#ifndef WGL_NV_vertex_array_range
-#define WGL_NV_vertex_array_range 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
-extern void WINAPI wglFreeMemoryNV (void *pointer);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
-typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
-#endif
-
-#ifndef WGL_3DFX_multisample
-#define WGL_3DFX_multisample 1
-#endif
-
-#ifndef WGL_EXT_multisample
-#define WGL_EXT_multisample 1
-#endif
-
-#ifndef WGL_OML_sync_control
-#define WGL_OML_sync_control 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
-extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
-extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
-extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
-extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
-extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
-typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
-typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
-typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
-typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
-typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
-#endif
-
-#ifndef WGL_I3D_digital_video_control
-#define WGL_I3D_digital_video_control 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
-extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
-typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
-#endif
-
-#ifndef WGL_I3D_gamma
-#define WGL_I3D_gamma 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
-extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
-extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
-extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
-typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
-typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
-typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
-#endif
-
-#ifndef WGL_I3D_genlock
-#define WGL_I3D_genlock 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
-extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
-extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
-extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
-extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
-extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
-extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
-extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
-extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
-extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
-extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
-extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
-typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
-typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
-typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
-typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
-typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
-typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
-typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
-typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
-typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
-typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
-typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
-#endif
-
-#ifndef WGL_I3D_image_buffer
-#define WGL_I3D_image_buffer 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
-extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
-extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
-extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
-typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
-typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
-typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
-#endif
-
-#ifndef WGL_I3D_swap_frame_lock
-#define WGL_I3D_swap_frame_lock 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglEnableFrameLockI3D (void);
-extern BOOL WINAPI wglDisableFrameLockI3D (void);
-extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
-extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
-typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
-typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
-typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
-#endif
-
-#ifndef WGL_I3D_swap_frame_usage
-#define WGL_I3D_swap_frame_usage 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
-extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
-extern BOOL WINAPI wglEndFrameTrackingI3D (void);
-extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
-typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
-typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
-typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
-#endif
-
-#ifndef WGL_ATI_pixel_format_float
-#define WGL_ATI_pixel_format_float 1
-#endif
-
-#ifndef WGL_NV_float_buffer
-#define WGL_NV_float_buffer 1
-#endif
-
-#ifndef WGL_3DL_stereo_control
-#define WGL_3DL_stereo_control 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
-#endif
-
-#ifndef WGL_EXT_pixel_format_packed_float
-#define WGL_EXT_pixel_format_packed_float 1
-#endif
-
-#ifndef WGL_EXT_framebuffer_sRGB
-#define WGL_EXT_framebuffer_sRGB 1
-#endif
-
-#ifndef WGL_NV_present_video
-#define WGL_NV_present_video 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
-extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
-extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
-typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
-typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
-#endif
-
-#ifndef WGL_NV_video_output
-#define WGL_NV_video_output 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
-extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
-extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
-extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
-extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
-extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
-typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
-typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
-typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
-typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
-typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
-#endif
-
-#ifndef WGL_NV_swap_group
-#define WGL_NV_swap_group 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
-extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
-extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
-extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
-extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
-extern BOOL WINAPI wglResetFrameCountNV (HDC hDC);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
-typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
-typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
-typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
-typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
-typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
-#endif
-
-#ifndef WGL_NV_gpu_affinity
-#define WGL_NV_gpu_affinity 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
-extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
-extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
-extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
-extern BOOL WINAPI wglDeleteDCNV (HDC hdc);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
-typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
-typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
-typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
-typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
-#endif
-
-#ifndef WGL_AMD_gpu_association
-#define WGL_AMD_gpu_association 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
-extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);
-extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
-extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
-extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
-extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
-extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
-extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
-extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
-typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);
-typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
-typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
-typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
-typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
-typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
-typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
-typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif
-
-#ifndef WGL_NV_video_capture
-#define WGL_NV_video_capture 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
-extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
-extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
-extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
-extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
-typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
-typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
-typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
-typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
-#endif
-
-#ifndef WGL_NV_copy_image
-#define WGL_NV_copy_image 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
-#endif
-
-#ifndef WGL_NV_multisample_coverage
-#define WGL_NV_multisample_coverage 1
-#endif
-
-#ifndef WGL_NV_DX_interop
-#define WGL_NV_DX_interop 1
-#ifdef WGL_WGLEXT_PROTOTYPES
-extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
-extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
-extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
-extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
-extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
-extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
-extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
-extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
-#endif /* WGL_WGLEXT_PROTOTYPES */
-typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
-typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
-typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
-typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
-typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
-typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
-typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
-typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/thirdparty/khr/EGL/egl.h b/thirdparty/khr/EGL/egl.h
deleted file mode 100644 (file)
index 99ea342..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/* -*- mode: c; tab-width: 8; -*- */
-/* vi: set sw=4 ts=8: */
-/* Reference version of egl.h for EGL 1.4.
- * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
- */
-
-/*
-** Copyright (c) 2007-2009 The Khronos Group Inc.
-**
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-**
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-**
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
-#ifndef __egl_h_
-#define __egl_h_
-
-/* All platform-dependent types and macro boilerplate (such as EGLAPI
- * and EGLAPIENTRY) should go in eglplatform.h.
- */
-#include <EGL/eglplatform.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* EGL Types */
-/* EGLint is defined in eglplatform.h */
-typedef unsigned int EGLBoolean;
-typedef unsigned int EGLenum;
-typedef void *EGLConfig;
-typedef void *EGLContext;
-typedef void *EGLDisplay;
-typedef void *EGLSurface;
-typedef void *EGLClientBuffer;
-
-/* EGL Versioning */
-#define EGL_VERSION_1_0                        1
-#define EGL_VERSION_1_1                        1
-#define EGL_VERSION_1_2                        1
-#define EGL_VERSION_1_3                        1
-#define EGL_VERSION_1_4                        1
-
-/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
- * enums are assigned unique values starting at 0x3000.
- */
-
-/* EGL aliases */
-#define EGL_FALSE                      0
-#define EGL_TRUE                       1
-
-/* Out-of-band handle values */
-#define EGL_DEFAULT_DISPLAY            ((EGLNativeDisplayType)0)
-#define EGL_NO_CONTEXT                 ((EGLContext)0)
-#define EGL_NO_DISPLAY                 ((EGLDisplay)0)
-#define EGL_NO_SURFACE                 ((EGLSurface)0)
-
-/* Out-of-band attribute value */
-#define EGL_DONT_CARE                  ((EGLint)-1)
-
-/* Errors / GetError return values */
-#define EGL_SUCCESS                    0x3000
-#define EGL_NOT_INITIALIZED            0x3001
-#define EGL_BAD_ACCESS                 0x3002
-#define EGL_BAD_ALLOC                  0x3003
-#define EGL_BAD_ATTRIBUTE              0x3004
-#define EGL_BAD_CONFIG                 0x3005
-#define EGL_BAD_CONTEXT                        0x3006
-#define EGL_BAD_CURRENT_SURFACE                0x3007
-#define EGL_BAD_DISPLAY                        0x3008
-#define EGL_BAD_MATCH                  0x3009
-#define EGL_BAD_NATIVE_PIXMAP          0x300A
-#define EGL_BAD_NATIVE_WINDOW          0x300B
-#define EGL_BAD_PARAMETER              0x300C
-#define EGL_BAD_SURFACE                        0x300D
-#define EGL_CONTEXT_LOST               0x300E  /* EGL 1.1 - IMG_power_management */
-
-/* Reserved 0x300F-0x301F for additional errors */
-
-/* Config attributes */
-#define EGL_BUFFER_SIZE                        0x3020
-#define EGL_ALPHA_SIZE                 0x3021
-#define EGL_BLUE_SIZE                  0x3022
-#define EGL_GREEN_SIZE                 0x3023
-#define EGL_RED_SIZE                   0x3024
-#define EGL_DEPTH_SIZE                 0x3025
-#define EGL_STENCIL_SIZE               0x3026
-#define EGL_CONFIG_CAVEAT              0x3027
-#define EGL_CONFIG_ID                  0x3028
-#define EGL_LEVEL                      0x3029
-#define EGL_MAX_PBUFFER_HEIGHT         0x302A
-#define EGL_MAX_PBUFFER_PIXELS         0x302B
-#define EGL_MAX_PBUFFER_WIDTH          0x302C
-#define EGL_NATIVE_RENDERABLE          0x302D
-#define EGL_NATIVE_VISUAL_ID           0x302E
-#define EGL_NATIVE_VISUAL_TYPE         0x302F
-#define EGL_SAMPLES                    0x3031
-#define EGL_SAMPLE_BUFFERS             0x3032
-#define EGL_SURFACE_TYPE               0x3033
-#define EGL_TRANSPARENT_TYPE           0x3034
-#define EGL_TRANSPARENT_BLUE_VALUE     0x3035
-#define EGL_TRANSPARENT_GREEN_VALUE    0x3036
-#define EGL_TRANSPARENT_RED_VALUE      0x3037
-#define EGL_NONE                       0x3038  /* Attrib list terminator */
-#define EGL_BIND_TO_TEXTURE_RGB                0x3039
-#define EGL_BIND_TO_TEXTURE_RGBA       0x303A
-#define EGL_MIN_SWAP_INTERVAL          0x303B
-#define EGL_MAX_SWAP_INTERVAL          0x303C
-#define EGL_LUMINANCE_SIZE             0x303D
-#define EGL_ALPHA_MASK_SIZE            0x303E
-#define EGL_COLOR_BUFFER_TYPE          0x303F
-#define EGL_RENDERABLE_TYPE            0x3040
-#define EGL_MATCH_NATIVE_PIXMAP                0x3041  /* Pseudo-attribute (not queryable) */
-#define EGL_CONFORMANT                 0x3042
-
-/* Reserved 0x3041-0x304F for additional config attributes */
-
-/* Config attribute values */
-#define EGL_SLOW_CONFIG                        0x3050  /* EGL_CONFIG_CAVEAT value */
-#define EGL_NON_CONFORMANT_CONFIG      0x3051  /* EGL_CONFIG_CAVEAT value */
-#define EGL_TRANSPARENT_RGB            0x3052  /* EGL_TRANSPARENT_TYPE value */
-#define EGL_RGB_BUFFER                 0x308E  /* EGL_COLOR_BUFFER_TYPE value */
-#define EGL_LUMINANCE_BUFFER           0x308F  /* EGL_COLOR_BUFFER_TYPE value */
-
-/* More config attribute values, for EGL_TEXTURE_FORMAT */
-#define EGL_NO_TEXTURE                 0x305C
-#define EGL_TEXTURE_RGB                        0x305D
-#define EGL_TEXTURE_RGBA               0x305E
-#define EGL_TEXTURE_2D                 0x305F
-
-/* Config attribute mask bits */
-#define EGL_PBUFFER_BIT                        0x0001  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_PIXMAP_BIT                 0x0002  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_WINDOW_BIT                 0x0004  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_VG_COLORSPACE_LINEAR_BIT   0x0020  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_VG_ALPHA_FORMAT_PRE_BIT    0x0040  /* EGL_SURFACE_TYPE mask bits */
-#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
-#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
-
-#define EGL_OPENGL_ES_BIT              0x0001  /* EGL_RENDERABLE_TYPE mask bits */
-#define EGL_OPENVG_BIT                 0x0002  /* EGL_RENDERABLE_TYPE mask bits */
-#define EGL_OPENGL_ES2_BIT             0x0004  /* EGL_RENDERABLE_TYPE mask bits */
-#define EGL_OPENGL_BIT                 0x0008  /* EGL_RENDERABLE_TYPE mask bits */
-
-/* QueryString targets */
-#define EGL_VENDOR                     0x3053
-#define EGL_VERSION                    0x3054
-#define EGL_EXTENSIONS                 0x3055
-#define EGL_CLIENT_APIS                        0x308D
-
-/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
-#define EGL_HEIGHT                     0x3056
-#define EGL_WIDTH                      0x3057
-#define EGL_LARGEST_PBUFFER            0x3058
-#define EGL_TEXTURE_FORMAT             0x3080
-#define EGL_TEXTURE_TARGET             0x3081
-#define EGL_MIPMAP_TEXTURE             0x3082
-#define EGL_MIPMAP_LEVEL               0x3083
-#define EGL_RENDER_BUFFER              0x3086
-#define EGL_VG_COLORSPACE              0x3087
-#define EGL_VG_ALPHA_FORMAT            0x3088
-#define EGL_HORIZONTAL_RESOLUTION      0x3090
-#define EGL_VERTICAL_RESOLUTION                0x3091
-#define EGL_PIXEL_ASPECT_RATIO         0x3092
-#define EGL_SWAP_BEHAVIOR              0x3093
-#define EGL_MULTISAMPLE_RESOLVE                0x3099
-
-/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
-#define EGL_BACK_BUFFER                        0x3084
-#define EGL_SINGLE_BUFFER              0x3085
-
-/* OpenVG color spaces */
-#define EGL_VG_COLORSPACE_sRGB         0x3089  /* EGL_VG_COLORSPACE value */
-#define EGL_VG_COLORSPACE_LINEAR       0x308A  /* EGL_VG_COLORSPACE value */
-
-/* OpenVG alpha formats */
-#define EGL_VG_ALPHA_FORMAT_NONPRE     0x308B  /* EGL_ALPHA_FORMAT value */
-#define EGL_VG_ALPHA_FORMAT_PRE                0x308C  /* EGL_ALPHA_FORMAT value */
-
-/* Constant scale factor by which fractional display resolutions &
- * aspect ratio are scaled when queried as integer values.
- */
-#define EGL_DISPLAY_SCALING            10000
-
-/* Unknown display resolution/aspect ratio */
-#define EGL_UNKNOWN                    ((EGLint)-1)
-
-/* Back buffer swap behaviors */
-#define EGL_BUFFER_PRESERVED           0x3094  /* EGL_SWAP_BEHAVIOR value */
-#define EGL_BUFFER_DESTROYED           0x3095  /* EGL_SWAP_BEHAVIOR value */
-
-/* CreatePbufferFromClientBuffer buffer types */
-#define EGL_OPENVG_IMAGE               0x3096
-
-/* QueryContext targets */
-#define EGL_CONTEXT_CLIENT_TYPE                0x3097
-
-/* CreateContext attributes */
-#define EGL_CONTEXT_CLIENT_VERSION     0x3098
-
-/* Multisample resolution behaviors */
-#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
-#define EGL_MULTISAMPLE_RESOLVE_BOX    0x309B  /* EGL_MULTISAMPLE_RESOLVE value */
-
-/* BindAPI/QueryAPI targets */
-#define EGL_OPENGL_ES_API              0x30A0
-#define EGL_OPENVG_API                 0x30A1
-#define EGL_OPENGL_API                 0x30A2
-
-/* GetCurrentSurface targets */
-#define EGL_DRAW                       0x3059
-#define EGL_READ                       0x305A
-
-/* WaitNative engines */
-#define EGL_CORE_NATIVE_ENGINE         0x305B
-
-/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
-#define EGL_COLORSPACE                 EGL_VG_COLORSPACE
-#define EGL_ALPHA_FORMAT               EGL_VG_ALPHA_FORMAT
-#define EGL_COLORSPACE_sRGB            EGL_VG_COLORSPACE_sRGB
-#define EGL_COLORSPACE_LINEAR          EGL_VG_COLORSPACE_LINEAR
-#define EGL_ALPHA_FORMAT_NONPRE                EGL_VG_ALPHA_FORMAT_NONPRE
-#define EGL_ALPHA_FORMAT_PRE           EGL_VG_ALPHA_FORMAT_PRE
-
-/* EGL extensions must request enum blocks from the Khronos
- * API Registrar, who maintains the enumerant registry. Submit
- * a bug in Khronos Bugzilla against task "Registry".
- */
-
-
-
-/* EGL Functions */
-
-EGLAPI EGLint EGLAPIENTRY eglGetError(void);
-
-EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
-EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
-EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
-
-EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
-                        EGLint config_size, EGLint *num_config);
-EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
-                          EGLConfig *configs, EGLint config_size,
-                          EGLint *num_config);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
-                             EGLint attribute, EGLint *value);
-
-EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
-                                 EGLNativeWindowType win,
-                                 const EGLint *attrib_list);
-EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
-                                  const EGLint *attrib_list);
-EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
-                                 EGLNativePixmapType pixmap,
-                                 const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
-EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
-                          EGLint attribute, EGLint *value);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
-EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
-
-EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
-             EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
-             EGLConfig config, const EGLint *attrib_list);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
-                           EGLint attribute, EGLint value);
-EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-
-
-EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
-
-
-EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
-                           EGLContext share_context,
-                           const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
-EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
-                         EGLSurface read, EGLContext ctx);
-
-EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
-EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
-EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
-                          EGLint attribute, EGLint *value);
-
-EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
-EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
-EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
-EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
-                         EGLNativePixmapType target);
-
-/* This is a generic function pointer type, whose name indicates it must
- * be cast to the proper type *and calling convention* before use.
- */
-typedef void (*__eglMustCastToProperFunctionPointerType)(void);
-
-/* Now, define eglGetProcAddress using the generic function ptr. type */
-EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
-       eglGetProcAddress(const char *procname);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __egl_h_ */
diff --git a/thirdparty/khr/EGL/eglext.h b/thirdparty/khr/EGL/eglext.h
deleted file mode 100644 (file)
index 5e52a34..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-#ifndef __eglext_h_
-#define __eglext_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-** Copyright (c) 2007-2010 The Khronos Group Inc.
-**
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-**
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-**
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
-#include <EGL/eglplatform.h>
-
-/*************************************************************/
-
-/* Header file version number */
-/* Current version at http://www.khronos.org/registry/egl/ */
-/* $Revision: 15052 $ on $Date: 2011-07-06 17:43:46 -0700 (Wed, 06 Jul 2011) $ */
-#define EGL_EGLEXT_VERSION 10
-
-#ifndef EGL_KHR_config_attribs
-#define EGL_KHR_config_attribs 1
-#define EGL_CONFORMANT_KHR                     0x3042  /* EGLConfig attribute */
-#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR       0x0020  /* EGL_SURFACE_TYPE bitfield */
-#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR                0x0040  /* EGL_SURFACE_TYPE bitfield */
-#endif
-
-#ifndef EGL_KHR_lock_surface
-#define EGL_KHR_lock_surface 1
-#define EGL_READ_SURFACE_BIT_KHR               0x0001  /* EGL_LOCK_USAGE_HINT_KHR bitfield */
-#define EGL_WRITE_SURFACE_BIT_KHR              0x0002  /* EGL_LOCK_USAGE_HINT_KHR bitfield */
-#define EGL_LOCK_SURFACE_BIT_KHR               0x0080  /* EGL_SURFACE_TYPE bitfield */
-#define EGL_OPTIMAL_FORMAT_BIT_KHR             0x0100  /* EGL_SURFACE_TYPE bitfield */
-#define EGL_MATCH_FORMAT_KHR                   0x3043  /* EGLConfig attribute */
-#define EGL_FORMAT_RGB_565_EXACT_KHR           0x30C0  /* EGL_MATCH_FORMAT_KHR value */
-#define EGL_FORMAT_RGB_565_KHR                 0x30C1  /* EGL_MATCH_FORMAT_KHR value */
-#define EGL_FORMAT_RGBA_8888_EXACT_KHR         0x30C2  /* EGL_MATCH_FORMAT_KHR value */
-#define EGL_FORMAT_RGBA_8888_KHR               0x30C3  /* EGL_MATCH_FORMAT_KHR value */
-#define EGL_MAP_PRESERVE_PIXELS_KHR            0x30C4  /* eglLockSurfaceKHR attribute */
-#define EGL_LOCK_USAGE_HINT_KHR                        0x30C5  /* eglLockSurfaceKHR attribute */
-#define EGL_BITMAP_POINTER_KHR                 0x30C6  /* eglQuerySurface attribute */
-#define EGL_BITMAP_PITCH_KHR                   0x30C7  /* eglQuerySurface attribute */
-#define EGL_BITMAP_ORIGIN_KHR                  0x30C8  /* eglQuerySurface attribute */
-#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR                0x30C9  /* eglQuerySurface attribute */
-#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR      0x30CA  /* eglQuerySurface attribute */
-#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR       0x30CB  /* eglQuerySurface attribute */
-#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR      0x30CC  /* eglQuerySurface attribute */
-#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR  0x30CD  /* eglQuerySurface attribute */
-#define EGL_LOWER_LEFT_KHR                     0x30CE  /* EGL_BITMAP_ORIGIN_KHR value */
-#define EGL_UPPER_LEFT_KHR                     0x30CF  /* EGL_BITMAP_ORIGIN_KHR value */
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
-#endif
-
-#ifndef EGL_KHR_image
-#define EGL_KHR_image 1
-#define EGL_NATIVE_PIXMAP_KHR                  0x30B0  /* eglCreateImageKHR target */
-typedef void *EGLImageKHR;
-#define EGL_NO_IMAGE_KHR                       ((EGLImageKHR)0)
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
-#endif
-
-#ifndef EGL_KHR_vg_parent_image
-#define EGL_KHR_vg_parent_image 1
-#define EGL_VG_PARENT_IMAGE_KHR                        0x30BA  /* eglCreateImageKHR target */
-#endif
-
-#ifndef EGL_KHR_gl_texture_2D_image
-#define EGL_KHR_gl_texture_2D_image 1
-#define EGL_GL_TEXTURE_2D_KHR                  0x30B1  /* eglCreateImageKHR target */
-#define EGL_GL_TEXTURE_LEVEL_KHR               0x30BC  /* eglCreateImageKHR attribute */
-#endif
-
-#ifndef EGL_KHR_gl_texture_cubemap_image
-#define EGL_KHR_gl_texture_cubemap_image 1
-#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3  /* eglCreateImageKHR target */
-#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4  /* eglCreateImageKHR target */
-#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5  /* eglCreateImageKHR target */
-#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6  /* eglCreateImageKHR target */
-#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7  /* eglCreateImageKHR target */
-#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8  /* eglCreateImageKHR target */
-#endif
-
-#ifndef EGL_KHR_gl_texture_3D_image
-#define EGL_KHR_gl_texture_3D_image 1
-#define EGL_GL_TEXTURE_3D_KHR                  0x30B2  /* eglCreateImageKHR target */
-#define EGL_GL_TEXTURE_ZOFFSET_KHR             0x30BD  /* eglCreateImageKHR attribute */
-#endif
-
-#ifndef EGL_KHR_gl_renderbuffer_image
-#define EGL_KHR_gl_renderbuffer_image 1
-#define EGL_GL_RENDERBUFFER_KHR                        0x30B9  /* eglCreateImageKHR target */
-#endif
-
-#if KHRONOS_SUPPORT_INT64   /* EGLTimeKHR requires 64-bit uint support */
-#ifndef EGL_KHR_reusable_sync
-#define EGL_KHR_reusable_sync 1
-
-typedef void* EGLSyncKHR;
-typedef khronos_utime_nanoseconds_t EGLTimeKHR;
-
-#define EGL_SYNC_STATUS_KHR                    0x30F1
-#define EGL_SIGNALED_KHR                       0x30F2
-#define EGL_UNSIGNALED_KHR                     0x30F3
-#define EGL_TIMEOUT_EXPIRED_KHR                        0x30F5
-#define EGL_CONDITION_SATISFIED_KHR            0x30F6
-#define EGL_SYNC_TYPE_KHR                      0x30F7
-#define EGL_SYNC_REUSABLE_KHR                  0x30FA
-#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR                0x0001  /* eglClientWaitSyncKHR <flags> bitfield */
-#define EGL_FOREVER_KHR                                0xFFFFFFFFFFFFFFFFull
-#define EGL_NO_SYNC_KHR                                ((EGLSyncKHR)0)
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
-EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
-EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
-typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
-#endif
-#endif
-
-#ifndef EGL_KHR_image_base
-#define EGL_KHR_image_base 1
-/* Most interfaces defined by EGL_KHR_image_pixmap above */
-#define EGL_IMAGE_PRESERVED_KHR                        0x30D2  /* eglCreateImageKHR attribute */
-#endif
-
-#ifndef EGL_KHR_image_pixmap
-#define EGL_KHR_image_pixmap 1
-/* Interfaces defined by EGL_KHR_image above */
-#endif
-
-#ifndef EGL_IMG_context_priority
-#define EGL_IMG_context_priority 1
-#define EGL_CONTEXT_PRIORITY_LEVEL_IMG         0x3100
-#define EGL_CONTEXT_PRIORITY_HIGH_IMG          0x3101
-#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG                0x3102
-#define EGL_CONTEXT_PRIORITY_LOW_IMG           0x3103
-#endif
-
-#ifndef EGL_KHR_lock_surface2
-#define EGL_KHR_lock_surface2 1
-#define EGL_BITMAP_PIXEL_SIZE_KHR              0x3110
-#endif
-
-#ifndef EGL_NV_coverage_sample
-#define EGL_NV_coverage_sample 1
-#define EGL_COVERAGE_BUFFERS_NV 0x30E0
-#define EGL_COVERAGE_SAMPLES_NV 0x30E1
-#endif
-
-#ifndef EGL_NV_depth_nonlinear
-#define EGL_NV_depth_nonlinear 1
-#define EGL_DEPTH_ENCODING_NV 0x30E2
-#define EGL_DEPTH_ENCODING_NONE_NV 0
-#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
-#endif
-
-#if KHRONOS_SUPPORT_INT64   /* EGLTimeNV requires 64-bit uint support */
-#ifndef EGL_NV_sync
-#define EGL_NV_sync 1
-#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV    0x30E6
-#define EGL_SYNC_STATUS_NV                     0x30E7
-#define EGL_SIGNALED_NV                                0x30E8
-#define EGL_UNSIGNALED_NV                      0x30E9
-#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV         0x0001
-#define EGL_FOREVER_NV                         0xFFFFFFFFFFFFFFFFull
-#define EGL_ALREADY_SIGNALED_NV                        0x30EA
-#define EGL_TIMEOUT_EXPIRED_NV                 0x30EB
-#define EGL_CONDITION_SATISFIED_NV             0x30EC
-#define EGL_SYNC_TYPE_NV                       0x30ED
-#define EGL_SYNC_CONDITION_NV                  0x30EE
-#define EGL_SYNC_FENCE_NV                      0x30EF
-#define EGL_NO_SYNC_NV                         ((EGLSyncNV)0)
-typedef void* EGLSyncNV;
-typedef khronos_utime_nanoseconds_t EGLTimeNV;
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
-EGLBoolean eglDestroySyncNV (EGLSyncNV sync);
-EGLBoolean eglFenceNV (EGLSyncNV sync);
-EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
-EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
-EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
-typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
-#endif
-#endif
-
-#if KHRONOS_SUPPORT_INT64   /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
-#ifndef EGL_KHR_fence_sync
-#define EGL_KHR_fence_sync 1
-/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
-#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR   0x30F0
-#define EGL_SYNC_CONDITION_KHR                 0x30F8
-#define EGL_SYNC_FENCE_KHR                     0x30F9
-#endif
-#endif
-
-#ifndef EGL_HI_clientpixmap
-#define EGL_HI_clientpixmap 1
-
-/* Surface Attribute */
-#define EGL_CLIENT_PIXMAP_POINTER_HI           0x8F74
-/*
- * Structure representing a client pixmap
- * (pixmap's data is in client-space memory).
- */
-struct EGLClientPixmapHI
-{
-       void*           pData;
-       EGLint          iWidth;
-       EGLint          iHeight;
-       EGLint          iStride;
-};
-
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
-#endif /* EGL_HI_clientpixmap */
-
-#ifndef EGL_HI_colorformats
-#define EGL_HI_colorformats 1
-/* Config Attribute */
-#define EGL_COLOR_FORMAT_HI                    0x8F70
-/* Color Formats */
-#define EGL_COLOR_RGB_HI                       0x8F71
-#define EGL_COLOR_RGBA_HI                      0x8F72
-#define EGL_COLOR_ARGB_HI                      0x8F73
-#endif /* EGL_HI_colorformats */
-
-#ifndef EGL_MESA_drm_image
-#define EGL_MESA_drm_image 1
-#define EGL_DRM_BUFFER_FORMAT_MESA             0x31D0      /* CreateDRMImageMESA attribute */
-#define EGL_DRM_BUFFER_USE_MESA                        0x31D1      /* CreateDRMImageMESA attribute */
-#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA      0x31D2      /* EGL_IMAGE_FORMAT_MESA attribute value */
-#define EGL_DRM_BUFFER_MESA                    0x31D3      /* eglCreateImageKHR target */
-#define EGL_DRM_BUFFER_STRIDE_MESA             0x31D4
-#define EGL_DRM_BUFFER_USE_SCANOUT_MESA                0x00000001  /* EGL_DRM_BUFFER_USE_MESA bits */
-#define EGL_DRM_BUFFER_USE_SHARE_MESA          0x00000002  /* EGL_DRM_BUFFER_USE_MESA bits */
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
-#endif
-
-#ifndef EGL_NV_post_sub_buffer
-#define EGL_NV_post_sub_buffer 1
-#define EGL_POST_SUB_BUFFER_SUPPORTED_NV       0x30BE
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
-#endif
-
-#ifndef EGL_ANGLE_query_surface_pointer
-#define EGL_ANGLE_query_surface_pointer 1
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
-#endif
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
-#endif
-
-#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
-#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
-#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE  0x3200
-#endif
-
-#ifndef EGL_NV_coverage_sample_resolve
-#define EGL_NV_coverage_sample_resolve 1
-#define EGL_COVERAGE_SAMPLE_RESOLVE_NV         0x3131
-#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
-#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV    0x3133
-#endif
-
-#if KHRONOS_SUPPORT_INT64   /* EGLTimeKHR requires 64-bit uint support */
-#ifndef EGL_NV_system_time
-#define EGL_NV_system_time 1
-
-typedef khronos_utime_nanoseconds_t EGLuint64NV;
-
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
-EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
-typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
-#endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/thirdparty/khr/GLES/glext.h b/thirdparty/khr/GLES/glext.h
deleted file mode 100644 (file)
index 130e4b0..0000000
+++ /dev/null
@@ -1,1073 +0,0 @@
-#ifndef __glext_h_
-#define __glext_h_
-
-/* $Revision: 13240 $ on $Date:: 2010-12-17 15:16:00 -0800 #$ */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * This document is licensed under the SGI Free Software B License Version
- * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
- */
-
-#ifndef GL_APIENTRYP
-#   define GL_APIENTRYP GL_APIENTRY*
-#endif
-
-/*------------------------------------------------------------------------*
- * OES extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_OES_blend_equation_separate */
-#ifndef GL_OES_blend_equation_separate
-/* BLEND_EQUATION_RGB_OES same as BLEND_EQUATION_OES */
-#define GL_BLEND_EQUATION_RGB_OES                               0x8009
-#define GL_BLEND_EQUATION_ALPHA_OES                             0x883D
-#endif
-
-/* GL_OES_blend_func_separate */
-#ifndef GL_OES_blend_func_separate
-#define GL_BLEND_DST_RGB_OES                                    0x80C8
-#define GL_BLEND_SRC_RGB_OES                                    0x80C9
-#define GL_BLEND_DST_ALPHA_OES                                  0x80CA
-#define GL_BLEND_SRC_ALPHA_OES                                  0x80CB
-#endif
-
-/* GL_OES_blend_subtract */
-#ifndef GL_OES_blend_subtract
-#define GL_BLEND_EQUATION_OES                                   0x8009
-#define GL_FUNC_ADD_OES                                         0x8006
-#define GL_FUNC_SUBTRACT_OES                                    0x800A
-#define GL_FUNC_REVERSE_SUBTRACT_OES                            0x800B
-#endif
-
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_ETC1_RGB8_OES                                        0x8D64
-#endif
-
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_DEPTH_COMPONENT24_OES                                0x81A6
-#endif
-
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_DEPTH_COMPONENT32_OES                                0x81A7
-#endif
-
-/* GL_OES_draw_texture */
-#ifndef GL_OES_draw_texture
-#define GL_TEXTURE_CROP_RECT_OES                                0x8B9D
-#endif
-
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-typedef void* GLeglImageOES;
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-/* GLeglImageOES defined in GL_OES_EGL_image already. */
-#define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
-#define GL_TEXTURE_BINDING_EXTERNAL_OES                         0x8D67
-#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES                     0x8D68
-#endif
-
-/* GL_OES_element_index_uint */
-#ifndef GL_OES_element_index_uint
-#define GL_UNSIGNED_INT                                         0x1405
-#endif
-
-/* GL_OES_fixed_point */
-#ifndef GL_OES_fixed_point
-#define GL_FIXED_OES                                            0x140C
-#endif
-
-/* GL_OES_framebuffer_object */
-#ifndef GL_OES_framebuffer_object
-#define GL_NONE_OES                                             0
-#define GL_FRAMEBUFFER_OES                                      0x8D40
-#define GL_RENDERBUFFER_OES                                     0x8D41
-#define GL_RGBA4_OES                                            0x8056
-#define GL_RGB5_A1_OES                                          0x8057
-#define GL_RGB565_OES                                           0x8D62
-#define GL_DEPTH_COMPONENT16_OES                                0x81A5
-#define GL_RENDERBUFFER_WIDTH_OES                               0x8D42
-#define GL_RENDERBUFFER_HEIGHT_OES                              0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES                     0x8D44
-#define GL_RENDERBUFFER_RED_SIZE_OES                            0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE_OES                          0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE_OES                           0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE_OES                          0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE_OES                          0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE_OES                        0x8D55
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES               0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES               0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES             0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES     0x8CD3
-#define GL_COLOR_ATTACHMENT0_OES                                0x8CE0
-#define GL_DEPTH_ATTACHMENT_OES                                 0x8D00
-#define GL_STENCIL_ATTACHMENT_OES                               0x8D20
-#define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES                0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES        0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES                0x8CD9
-#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES                   0x8CDA
-#define GL_FRAMEBUFFER_UNSUPPORTED_OES                          0x8CDD
-#define GL_FRAMEBUFFER_BINDING_OES                              0x8CA6
-#define GL_RENDERBUFFER_BINDING_OES                             0x8CA7
-#define GL_MAX_RENDERBUFFER_SIZE_OES                            0x84E8
-#define GL_INVALID_FRAMEBUFFER_OPERATION_OES                    0x0506
-#endif
-
-/* GL_OES_mapbuffer */
-#ifndef GL_OES_mapbuffer
-#define GL_WRITE_ONLY_OES                                       0x88B9
-#define GL_BUFFER_ACCESS_OES                                    0x88BB
-#define GL_BUFFER_MAPPED_OES                                    0x88BC
-#define GL_BUFFER_MAP_POINTER_OES                               0x88BD
-#endif
-
-/* GL_OES_matrix_get */
-#ifndef GL_OES_matrix_get
-#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES               0x898D
-#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES              0x898E
-#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES                 0x898F
-#endif
-
-/* GL_OES_matrix_palette */
-#ifndef GL_OES_matrix_palette
-#define GL_MAX_VERTEX_UNITS_OES                                 0x86A4
-#define GL_MAX_PALETTE_MATRICES_OES                             0x8842
-#define GL_MATRIX_PALETTE_OES                                   0x8840
-#define GL_MATRIX_INDEX_ARRAY_OES                               0x8844
-#define GL_WEIGHT_ARRAY_OES                                     0x86AD
-#define GL_CURRENT_PALETTE_MATRIX_OES                           0x8843
-#define GL_MATRIX_INDEX_ARRAY_SIZE_OES                          0x8846
-#define GL_MATRIX_INDEX_ARRAY_TYPE_OES                          0x8847
-#define GL_MATRIX_INDEX_ARRAY_STRIDE_OES                        0x8848
-#define GL_MATRIX_INDEX_ARRAY_POINTER_OES                       0x8849
-#define GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES                0x8B9E
-#define GL_WEIGHT_ARRAY_SIZE_OES                                0x86AB
-#define GL_WEIGHT_ARRAY_TYPE_OES                                0x86A9
-#define GL_WEIGHT_ARRAY_STRIDE_OES                              0x86AA
-#define GL_WEIGHT_ARRAY_POINTER_OES                             0x86AC
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING_OES                      0x889E
-#endif
-
-/* GL_OES_packed_depth_stencil */
-#ifndef GL_OES_packed_depth_stencil
-#define GL_DEPTH_STENCIL_OES                                    0x84F9
-#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
-#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
-#endif
-
-/* GL_OES_rgb8_rgba8 */
-#ifndef GL_OES_rgb8_rgba8
-#define GL_RGB8_OES                                             0x8051
-#define GL_RGBA8_OES                                            0x8058
-#endif
-
-/* GL_OES_stencil1 */
-#ifndef GL_OES_stencil1
-#define GL_STENCIL_INDEX1_OES                                   0x8D46
-#endif
-
-/* GL_OES_stencil4 */
-#ifndef GL_OES_stencil4
-#define GL_STENCIL_INDEX4_OES                                   0x8D47
-#endif
-
-/* GL_OES_stencil8 */
-#ifndef GL_OES_stencil8
-#define GL_STENCIL_INDEX8_OES                                   0x8D48
-#endif
-
-/* GL_OES_stencil_wrap */
-#ifndef GL_OES_stencil_wrap
-#define GL_INCR_WRAP_OES                                        0x8507
-#define GL_DECR_WRAP_OES                                        0x8508
-#endif
-
-/* GL_OES_texture_cube_map */
-#ifndef GL_OES_texture_cube_map
-#define GL_NORMAL_MAP_OES                                       0x8511
-#define GL_REFLECTION_MAP_OES                                   0x8512
-#define GL_TEXTURE_CUBE_MAP_OES                                 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP_OES                         0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES                      0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES                      0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES                      0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES                      0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES                      0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES                      0x851A
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES                        0x851C
-#define GL_TEXTURE_GEN_MODE_OES                                 0x2500
-#define GL_TEXTURE_GEN_STR_OES                                  0x8D60
-#endif
-
-/* GL_OES_texture_mirrored_repeat */
-#ifndef GL_OES_texture_mirrored_repeat
-#define GL_MIRRORED_REPEAT_OES                                  0x8370
-#endif
-
-/* GL_OES_vertex_array_object */
-#ifndef GL_OES_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING_OES                             0x85B5
-#endif
-
-/*------------------------------------------------------------------------*
- * AMD extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
-#ifndef GL_AMD_compressed_3DC_texture
-#define GL_3DC_X_AMD                                            0x87F9
-#define GL_3DC_XY_AMD                                           0x87FA
-#endif
-
-/* GL_AMD_compressed_ATC_texture */
-#ifndef GL_AMD_compressed_ATC_texture
-#define GL_ATC_RGB_AMD                                          0x8C92
-#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
-#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_APPLE_texture_2D_limited_npot */
-/* No new tokens introduced by this extension. */
-
-/* GL_APPLE_framebuffer_multisample */
-#ifndef GL_APPLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_APPLE                           0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE             0x8D56
-#define GL_MAX_SAMPLES_APPLE                                    0x8D57
-#define GL_READ_FRAMEBUFFER_APPLE                               0x8CA8
-#define GL_DRAW_FRAMEBUFFER_APPLE                               0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE                       0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_APPLE                       0x8CAA
-#endif
-
-/* GL_APPLE_texture_format_BGRA8888 */
-#ifndef GL_APPLE_texture_format_BGRA8888
-#define GL_BGRA_EXT                                             0x80E1
-#endif
-
-/* GL_APPLE_texture_max_level */
-#ifndef GL_APPLE_texture_max_level
-#define GL_TEXTURE_MAX_LEVEL_APPLE                              0x813D
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ARM_rgba8 */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * EXT extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_EXT_blend_minmax */
-#ifndef GL_EXT_blend_minmax
-#define GL_MIN_EXT                                              0x8007
-#define GL_MAX_EXT                                              0x8008
-#endif
-
-/* GL_EXT_discard_framebuffer */
-#ifndef GL_EXT_discard_framebuffer
-#define GL_COLOR_EXT                                            0x1800
-#define GL_DEPTH_EXT                                            0x1801
-#define GL_STENCIL_EXT                                          0x1802
-#endif
-
-/* GL_EXT_multi_draw_arrays */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_read_format_bgra */
-#ifndef GL_EXT_read_format_bgra
-#define GL_BGRA_EXT                                             0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT                       0x8365
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT                       0x8366
-#endif
-
-/* GL_EXT_texture_filter_anisotropic */
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF
-#endif
-
-/* GL_EXT_texture_format_BGRA8888 */
-#ifndef GL_EXT_texture_format_BGRA8888
-#define GL_BGRA_EXT                                             0x80E1
-#endif
-
-/* GL_EXT_texture_lod_bias */
-#ifndef GL_EXT_texture_lod_bias
-#define GL_MAX_TEXTURE_LOD_BIAS_EXT                             0x84FD
-#define GL_TEXTURE_FILTER_CONTROL_EXT                           0x8500
-#define GL_TEXTURE_LOD_BIAS_EXT                                 0x8501
-#endif
-
-/*------------------------------------------------------------------------*
- * IMG extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_IMG_read_format */
-#ifndef GL_IMG_read_format
-#define GL_BGRA_IMG                                             0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG                       0x8365
-#endif
-
-/* GL_IMG_texture_compression_pvrtc */
-#ifndef GL_IMG_texture_compression_pvrtc
-#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
-#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
-#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
-#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
-#endif
-
-/* GL_IMG_texture_env_enhanced_fixed_function */
-#ifndef GL_IMG_texture_env_enhanced_fixed_function
-#define GL_MODULATE_COLOR_IMG                                   0x8C04
-#define GL_RECIP_ADD_SIGNED_ALPHA_IMG                           0x8C05
-#define GL_TEXTURE_ALPHA_MODULATE_IMG                           0x8C06
-#define GL_FACTOR_ALPHA_MODULATE_IMG                            0x8C07
-#define GL_FRAGMENT_ALPHA_MODULATE_IMG                          0x8C08
-#define GL_ADD_BLEND_IMG                                        0x8C09
-#define GL_DOT3_RGBA_IMG                                        0x86AF
-#endif
-
-/* GL_IMG_user_clip_plane */
-#ifndef GL_IMG_user_clip_plane
-#define GL_CLIP_PLANE0_IMG                                      0x3000
-#define GL_CLIP_PLANE1_IMG                                      0x3001
-#define GL_CLIP_PLANE2_IMG                                      0x3002
-#define GL_CLIP_PLANE3_IMG                                      0x3003
-#define GL_CLIP_PLANE4_IMG                                      0x3004
-#define GL_CLIP_PLANE5_IMG                                      0x3005
-#define GL_MAX_CLIP_PLANES_IMG                                  0x0D32
-#endif
-
-/* GL_IMG_multisampled_render_to_texture */
-#ifndef GL_IMG_multisampled_render_to_texture
-#define GL_RENDERBUFFER_SAMPLES_IMG                             0x9133
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG               0x9134
-#define GL_MAX_SAMPLES_IMG                                      0x9135
-#define GL_TEXTURE_SAMPLES_IMG                                  0x9136
-#endif
-
-/*------------------------------------------------------------------------*
- * NV extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_NV_fence */
-#ifndef GL_NV_fence
-#define GL_ALL_COMPLETED_NV                                     0x84F2
-#define GL_FENCE_STATUS_NV                                      0x84F3
-#define GL_FENCE_CONDITION_NV                                   0x84F4
-#endif
-
-/*------------------------------------------------------------------------*
- * QCOM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_driver_control */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_extended_get */
-#ifndef GL_QCOM_extended_get
-#define GL_TEXTURE_WIDTH_QCOM                                   0x8BD2
-#define GL_TEXTURE_HEIGHT_QCOM                                  0x8BD3
-#define GL_TEXTURE_DEPTH_QCOM                                   0x8BD4
-#define GL_TEXTURE_INTERNAL_FORMAT_QCOM                         0x8BD5
-#define GL_TEXTURE_FORMAT_QCOM                                  0x8BD6
-#define GL_TEXTURE_TYPE_QCOM                                    0x8BD7
-#define GL_TEXTURE_IMAGE_VALID_QCOM                             0x8BD8
-#define GL_TEXTURE_NUM_LEVELS_QCOM                              0x8BD9
-#define GL_TEXTURE_TARGET_QCOM                                  0x8BDA
-#define GL_TEXTURE_OBJECT_VALID_QCOM                            0x8BDB
-#define GL_STATE_RESTORE                                        0x8BDC
-#endif
-
-/* GL_QCOM_extended_get2 */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_perfmon_global_mode */
-#ifndef GL_QCOM_perfmon_global_mode
-#define GL_PERFMON_GLOBAL_MODE_QCOM                             0x8FA0
-#endif
-
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_WRITEONLY_RENDERING_QCOM                             0x8823
-#endif
-
-/* GL_QCOM_tiled_rendering */
-#ifndef GL_QCOM_tiled_rendering
-#define GL_COLOR_BUFFER_BIT0_QCOM                               0x00000001
-#define GL_COLOR_BUFFER_BIT1_QCOM                               0x00000002
-#define GL_COLOR_BUFFER_BIT2_QCOM                               0x00000004
-#define GL_COLOR_BUFFER_BIT3_QCOM                               0x00000008
-#define GL_COLOR_BUFFER_BIT4_QCOM                               0x00000010
-#define GL_COLOR_BUFFER_BIT5_QCOM                               0x00000020
-#define GL_COLOR_BUFFER_BIT6_QCOM                               0x00000040
-#define GL_COLOR_BUFFER_BIT7_QCOM                               0x00000080
-#define GL_DEPTH_BUFFER_BIT0_QCOM                               0x00000100
-#define GL_DEPTH_BUFFER_BIT1_QCOM                               0x00000200
-#define GL_DEPTH_BUFFER_BIT2_QCOM                               0x00000400
-#define GL_DEPTH_BUFFER_BIT3_QCOM                               0x00000800
-#define GL_DEPTH_BUFFER_BIT4_QCOM                               0x00001000
-#define GL_DEPTH_BUFFER_BIT5_QCOM                               0x00002000
-#define GL_DEPTH_BUFFER_BIT6_QCOM                               0x00004000
-#define GL_DEPTH_BUFFER_BIT7_QCOM                               0x00008000
-#define GL_STENCIL_BUFFER_BIT0_QCOM                             0x00010000
-#define GL_STENCIL_BUFFER_BIT1_QCOM                             0x00020000
-#define GL_STENCIL_BUFFER_BIT2_QCOM                             0x00040000
-#define GL_STENCIL_BUFFER_BIT3_QCOM                             0x00080000
-#define GL_STENCIL_BUFFER_BIT4_QCOM                             0x00100000
-#define GL_STENCIL_BUFFER_BIT5_QCOM                             0x00200000
-#define GL_STENCIL_BUFFER_BIT6_QCOM                             0x00400000
-#define GL_STENCIL_BUFFER_BIT7_QCOM                             0x00800000
-#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM                         0x01000000
-#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM                         0x02000000
-#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM                         0x04000000
-#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM                         0x08000000
-#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM                         0x10000000
-#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM                         0x20000000
-#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM                         0x40000000
-#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM                         0x80000000
-#endif
-
-/*------------------------------------------------------------------------*
- * End of extension tokens, start of corresponding extension functions
- *------------------------------------------------------------------------*/
-
-/*------------------------------------------------------------------------*
- * OES extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_OES_blend_equation_separate */
-#ifndef GL_OES_blend_equation_separate
-#define GL_OES_blend_equation_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha);
-#endif
-typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEOESPROC) (GLenum modeRGB, GLenum modeAlpha);
-#endif
-
-/* GL_OES_blend_func_separate */
-#ifndef GL_OES_blend_func_separate
-#define GL_OES_blend_func_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glBlendFuncSeparateOES (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-#endif
-typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-#endif
-
-/* GL_OES_blend_subtract */
-#ifndef GL_OES_blend_subtract
-#define GL_OES_blend_subtract 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glBlendEquationOES (GLenum mode);
-#endif
-typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC) (GLenum mode);
-#endif
-
-/* GL_OES_byte_coordinates */
-#ifndef GL_OES_byte_coordinates
-#define GL_OES_byte_coordinates 1
-#endif
-
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_OES_compressed_ETC1_RGB8_texture 1
-#endif
-
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_OES_depth24 1
-#endif
-
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_OES_depth32 1
-#endif
-
-/* GL_OES_draw_texture */
-#ifndef GL_OES_draw_texture
-#define GL_OES_draw_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
-GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height);
-GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
-GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords);
-GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords);
-GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords);
-GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
-GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords);
-#endif
-typedef void (GL_APIENTRYP PFNGLDRAWTEXSOESPROC) (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
-typedef void (GL_APIENTRYP PFNGLDRAWTEXIOESPROC) (GLint x, GLint y, GLint z, GLint width, GLint height);
-typedef void (GL_APIENTRYP PFNGLDRAWTEXXOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
-typedef void (GL_APIENTRYP PFNGLDRAWTEXSVOESPROC) (const GLshort *coords);
-typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOESPROC) (const GLint *coords);
-typedef void (GL_APIENTRYP PFNGLDRAWTEXXVOESPROC) (const GLfixed *coords);
-typedef void (GL_APIENTRYP PFNGLDRAWTEXFOESPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
-typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOESPROC) (const GLfloat *coords);
-#endif
-
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-#define GL_OES_EGL_image 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
-GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
-#endif
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-#define GL_OES_EGL_image_external 1
-/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */
-#endif
-
-/* GL_OES_element_index_uint */
-#ifndef GL_OES_element_index_uint
-#define GL_OES_element_index_uint 1
-#endif
-
-/* GL_OES_extended_matrix_palette */
-#ifndef GL_OES_extended_matrix_palette
-#define GL_OES_extended_matrix_palette 1
-#endif
-
-/* GL_OES_fbo_render_mipmap */
-#ifndef GL_OES_fbo_render_mipmap
-#define GL_OES_fbo_render_mipmap 1
-#endif
-
-/* GL_OES_fixed_point */
-#ifndef GL_OES_fixed_point
-#define GL_OES_fixed_point 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glAlphaFuncxOES (GLenum func, GLclampx ref);
-GL_API void GL_APIENTRY glClearColorxOES (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
-GL_API void GL_APIENTRY glClearDepthxOES (GLclampx depth);
-GL_API void GL_APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation);
-GL_API void GL_APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
-GL_API void GL_APIENTRY glDepthRangexOES (GLclampx zNear, GLclampx zFar);
-GL_API void GL_APIENTRY glFogxOES (GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glFogxvOES (GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glFrustumxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-GL_API void GL_APIENTRY glGetClipPlanexOES (GLenum pname, GLfixed eqn[4]);
-GL_API void GL_APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetLightxvOES (GLenum light, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetMaterialxvOES (GLenum face, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetTexEnvxvOES (GLenum env, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params);
-GL_API void GL_APIENTRY glLightModelxOES (GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glLineWidthxOES (GLfixed width);
-GL_API void GL_APIENTRY glLoadMatrixxOES (const GLfixed *m);
-GL_API void GL_APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glMultMatrixxOES (const GLfixed *m);
-GL_API void GL_APIENTRY glMultiTexCoord4xOES (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
-GL_API void GL_APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz);
-GL_API void GL_APIENTRY glOrthoxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-GL_API void GL_APIENTRY glPointParameterxOES (GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glPointSizexOES (GLfixed size);
-GL_API void GL_APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units);
-GL_API void GL_APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
-GL_API void GL_APIENTRY glSampleCoveragexOES (GLclampx value, GLboolean invert);
-GL_API void GL_APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z);
-GL_API void GL_APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z);
-#endif
-typedef void (GL_APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLclampx ref);
-typedef void (GL_APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
-typedef void (GL_APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLclampx depth);
-typedef void (GL_APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation);
-typedef void (GL_APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
-typedef void (GL_APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLclampx zNear, GLclampx zFar);
-typedef void (GL_APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum pname, GLfixed eqn[4]);
-typedef void (GL_APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLGETLIGHTXVOESPROC) (GLenum light, GLenum pname, GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLGETMATERIALXVOESPROC) (GLenum face, GLenum pname, GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum env, GLenum pname, GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width);
-typedef void (GL_APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m);
-typedef void (GL_APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m);
-typedef void (GL_APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
-typedef void (GL_APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz);
-typedef void (GL_APIENTRYP PFNGLORTHOXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
-typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXOESPROC) (GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size);
-typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units);
-typedef void (GL_APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
-typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEXOESPROC) (GLclampx value, GLboolean invert);
-typedef void (GL_APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
-typedef void (GL_APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
-#endif
-
-/* GL_OES_framebuffer_object */
-#ifndef GL_OES_framebuffer_object
-#define GL_OES_framebuffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API GLboolean GL_APIENTRY glIsRenderbufferOES (GLuint renderbuffer);
-GL_API void GL_APIENTRY glBindRenderbufferOES (GLenum target, GLuint renderbuffer);
-GL_API void GL_APIENTRY glDeleteRenderbuffersOES (GLsizei n, const GLuint* renderbuffers);
-GL_API void GL_APIENTRY glGenRenderbuffersOES (GLsizei n, GLuint* renderbuffers);
-GL_API void GL_APIENTRY glRenderbufferStorageOES (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GL_API void GL_APIENTRY glGetRenderbufferParameterivOES (GLenum target, GLenum pname, GLint* params);
-GL_API GLboolean GL_APIENTRY glIsFramebufferOES (GLuint framebuffer);
-GL_API void GL_APIENTRY glBindFramebufferOES (GLenum target, GLuint framebuffer);
-GL_API void GL_APIENTRY glDeleteFramebuffersOES (GLsizei n, const GLuint* framebuffers);
-GL_API void GL_APIENTRY glGenFramebuffersOES (GLsizei n, GLuint* framebuffers);
-GL_API GLenum GL_APIENTRY glCheckFramebufferStatusOES (GLenum target);
-GL_API void GL_APIENTRY glFramebufferRenderbufferOES (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GL_API void GL_APIENTRY glFramebufferTexture2DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GL_API void GL_APIENTRY glGetFramebufferAttachmentParameterivOES (GLenum target, GLenum attachment, GLenum pname, GLint* params);
-GL_API void GL_APIENTRY glGenerateMipmapOES (GLenum target);
-#endif
-typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer);
-typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer);
-typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers);
-typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers);
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params);
-typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer);
-typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer);
-typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers);
-typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers);
-typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
-typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOESPROC) (GLenum target);
-#endif
-
-/* GL_OES_mapbuffer */
-#ifndef GL_OES_mapbuffer
-#define GL_OES_mapbuffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
-GL_API GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
-GL_API void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid ** params);
-#endif
-typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
-typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid ** params);
-#endif
-
-/* GL_OES_matrix_get */
-#ifndef GL_OES_matrix_get
-#define GL_OES_matrix_get 1
-#endif
-
-/* GL_OES_matrix_palette */
-#ifndef GL_OES_matrix_palette
-#define GL_OES_matrix_palette 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glCurrentPaletteMatrixOES (GLuint matrixpaletteindex);
-GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES (void);
-GL_API void GL_APIENTRY glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-GL_API void GL_APIENTRY glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-typedef void (GL_APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC) (GLuint matrixpaletteindex);
-typedef void (GL_APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC) (void);
-typedef void (GL_APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-/* GL_OES_packed_depth_stencil */
-#ifndef GL_OES_packed_depth_stencil
-#define GL_OES_packed_depth_stencil 1
-#endif
-
-/* GL_OES_query_matrix */
-#ifndef GL_OES_query_matrix
-#define GL_OES_query_matrix 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES (GLfixed mantissa[16], GLint exponent[16]);
-#endif
-typedef GLbitfield (GL_APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed mantissa[16], GLint exponent[16]);
-#endif
-
-/* GL_OES_rgb8_rgba8 */
-#ifndef GL_OES_rgb8_rgba8
-#define GL_OES_rgb8_rgba8 1
-#endif
-
-/* GL_OES_single_precision */
-#ifndef GL_OES_single_precision
-#define GL_OES_single_precision 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar);
-GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);
-GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]);
-GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth);
-#endif
-typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar);
-typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-typedef void (GL_APIENTRYP PFNGLORTHOFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
-typedef void (GL_APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation);
-typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum pname, GLfloat eqn[4]);
-typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth);
-#endif
-
-/* GL_OES_stencil1 */
-#ifndef GL_OES_stencil1
-#define GL_OES_stencil1 1
-#endif
-
-/* GL_OES_stencil4 */
-#ifndef GL_OES_stencil4
-#define GL_OES_stencil4 1
-#endif
-
-/* GL_OES_stencil8 */
-#ifndef GL_OES_stencil8
-#define GL_OES_stencil8 1
-#endif
-
-/* GL_OES_stencil_wrap */
-#ifndef GL_OES_stencil_wrap
-#define GL_OES_stencil_wrap 1
-#endif
-
-/* GL_OES_texture_cube_map */
-#ifndef GL_OES_texture_cube_map
-#define GL_OES_texture_cube_map 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param);
-GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params);
-GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param);
-GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params);
-GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param);
-GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params);
-GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params);
-GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params);
-GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params);
-#endif
-typedef void (GL_APIENTRYP PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param);
-typedef void (GL_APIENTRYP PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params);
-typedef void (GL_APIENTRYP PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param);
-typedef void (GL_APIENTRYP PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params);
-typedef void (GL_APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);
-typedef void (GL_APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);
-typedef void (GL_APIENTRYP PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params);
-typedef void (GL_APIENTRYP PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
-#endif
-
-/* GL_OES_texture_env_crossbar */
-#ifndef GL_OES_texture_env_crossbar
-#define GL_OES_texture_env_crossbar 1
-#endif
-
-/* GL_OES_texture_mirrored_repeat */
-#ifndef GL_OES_texture_mirrored_repeat
-#define GL_OES_texture_mirrored_repeat 1
-#endif
-
-/* GL_OES_vertex_array_object */
-#ifndef GL_OES_vertex_array_object
-#define GL_OES_vertex_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glBindVertexArrayOES (GLuint array);
-GL_API void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);
-GL_API void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);
-GL_API GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);
-#endif
-typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
-typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
-typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
-typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
-#endif
-
-/*------------------------------------------------------------------------*
- * AMD extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
-#ifndef GL_AMD_compressed_3DC_texture
-#define GL_AMD_compressed_3DC_texture 1
-#endif
-
-/* GL_AMD_compressed_ATC_texture */
-#ifndef GL_AMD_compressed_ATC_texture
-#define GL_AMD_compressed_ATC_texture 1
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_APPLE_texture_2D_limited_npot */
-#ifndef GL_APPLE_texture_2D_limited_npot
-#define GL_APPLE_texture_2D_limited_npot 1
-#endif
-
-/* GL_APPLE_framebuffer_multisample */
-#ifndef GL_APPLE_framebuffer_multisample
-#define GL_APPLE_framebuffer_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_API void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
-#endif
-
-/* GL_APPLE_texture_format_BGRA8888 */
-#ifndef GL_APPLE_texture_format_BGRA8888
-#define GL_APPLE_texture_format_BGRA8888 1
-#endif
-
-/* GL_APPLE_texture_max_level */
-#ifndef GL_APPLE_texture_max_level
-#define GL_APPLE_texture_max_level 1
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_ARM_rgba8 */
-#ifndef GL_ARM_rgba8
-#define GL_ARM_rgba8 1
-#endif
-
-/*------------------------------------------------------------------------*
- * EXT extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_EXT_blend_minmax */
-#ifndef GL_EXT_blend_minmax
-#define GL_EXT_blend_minmax 1
-#endif
-
-/* GL_EXT_discard_framebuffer */
-#ifndef GL_EXT_discard_framebuffer
-#define GL_EXT_discard_framebuffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
-#endif
-typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
-#endif
-
-/* GL_EXT_multi_draw_arrays */
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
-GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-#endif
-
-/* GL_EXT_read_format_bgra */
-#ifndef GL_EXT_read_format_bgra
-#define GL_EXT_read_format_bgra 1
-#endif
-
-/* GL_EXT_texture_filter_anisotropic */
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_EXT_texture_filter_anisotropic 1
-#endif
-
-/* GL_EXT_texture_format_BGRA8888 */
-#ifndef GL_EXT_texture_format_BGRA8888
-#define GL_EXT_texture_format_BGRA8888 1
-#endif
-
-/* GL_EXT_texture_lod_bias */
-#ifndef GL_EXT_texture_lod_bias
-#define GL_EXT_texture_lod_bias 1
-#endif
-
-/*------------------------------------------------------------------------*
- * IMG extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_IMG_read_format */
-#ifndef GL_IMG_read_format
-#define GL_IMG_read_format 1
-#endif
-
-/* GL_IMG_texture_compression_pvrtc */
-#ifndef GL_IMG_texture_compression_pvrtc
-#define GL_IMG_texture_compression_pvrtc 1
-#endif
-
-/* GL_IMG_texture_env_enhanced_fixed_function */
-#ifndef GL_IMG_texture_env_enhanced_fixed_function
-#define GL_IMG_texture_env_enhanced_fixed_function 1
-#endif
-
-/* GL_IMG_user_clip_plane */
-#ifndef GL_IMG_user_clip_plane
-#define GL_IMG_user_clip_plane 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glClipPlanefIMG (GLenum, const GLfloat *);
-GL_API void GL_APIENTRY glClipPlanexIMG (GLenum, const GLfixed *);
-#endif
-typedef void (GL_APIENTRYP PFNGLCLIPPLANEFIMGPROC) (GLenum p, const GLfloat *eqn);
-typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMGPROC) (GLenum p, const GLfixed *eqn);
-#endif
-
-/* GL_IMG_multisampled_render_to_texture */
-#ifndef GL_IMG_multisampled_render_to_texture
-#define GL_IMG_multisampled_render_to_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
-#endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
-#endif
-
-/*------------------------------------------------------------------------*
- * NV extension functions
- *------------------------------------------------------------------------*/
-
-/* NV_fence */
-#ifndef GL_NV_fence
-#define GL_NV_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
-GL_API void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
-GL_API GLboolean GL_APIENTRY glIsFenceNV (GLuint);
-GL_API GLboolean GL_APIENTRY glTestFenceNV (GLuint);
-GL_API void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
-GL_API void GL_APIENTRY glFinishFenceNV (GLuint);
-GL_API void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
-#endif
-typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
-typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
-typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
-typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
-typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
-typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
-#endif
-
-/*------------------------------------------------------------------------*
- * QCOM extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_driver_control */
-#ifndef GL_QCOM_driver_control
-#define GL_QCOM_driver_control 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
-GL_API void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
-GL_API void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
-GL_API void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
-#endif
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
-typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-#endif
-
-/* GL_QCOM_extended_get */
-#ifndef GL_QCOM_extended_get
-#define GL_QCOM_extended_get 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);
-GL_API void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
-GL_API void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
-GL_API void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
-GL_API void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
-GL_API void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);
-GL_API void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-GL_API void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);
-#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);
-#endif
-
-/* GL_QCOM_extended_get2 */
-#ifndef GL_QCOM_extended_get2
-#define GL_QCOM_extended_get2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);
-GL_API void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
-GL_API GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);
-GL_API void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
-#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
-typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
-#endif
-
-/* GL_QCOM_perfmon_global_mode */
-#ifndef GL_QCOM_perfmon_global_mode
-#define GL_QCOM_perfmon_global_mode 1
-#endif
-
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_QCOM_writeonly_rendering 1
-#endif
-
-/* GL_QCOM_tiled_rendering */
-#ifndef GL_QCOM_tiled_rendering
-#define GL_QCOM_tiled_rendering 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_API void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
-GL_API void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);
-#endif
-typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
-typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __glext_h_ */
-
diff --git a/thirdparty/khr/GLES2/gl2ext.h b/thirdparty/khr/GLES2/gl2ext.h
deleted file mode 100644 (file)
index 4eae246..0000000
+++ /dev/null
@@ -1,1138 +0,0 @@
-#ifndef __gl2ext_h_
-#define __gl2ext_h_
-
-/* $Revision: 15049 $ on $Date:: 2011-07-06 17:28:16 -0700 #$ */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * This document is licensed under the SGI Free Software B License Version
- * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
- */
-
-#ifndef GL_APIENTRYP
-#   define GL_APIENTRYP GL_APIENTRY*
-#endif
-
-/*------------------------------------------------------------------------*
- * OES extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_ETC1_RGB8_OES                                        0x8D64
-#endif
-
-/* GL_OES_compressed_paletted_texture */
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_PALETTE4_RGB8_OES                                    0x8B90
-#define GL_PALETTE4_RGBA8_OES                                   0x8B91
-#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92
-#define GL_PALETTE4_RGBA4_OES                                   0x8B93
-#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94
-#define GL_PALETTE8_RGB8_OES                                    0x8B95
-#define GL_PALETTE8_RGBA8_OES                                   0x8B96
-#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97
-#define GL_PALETTE8_RGBA4_OES                                   0x8B98
-#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99
-#endif
-
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_DEPTH_COMPONENT24_OES                                0x81A6
-#endif
-
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_DEPTH_COMPONENT32_OES                                0x81A7
-#endif
-
-/* GL_OES_depth_texture */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-typedef void* GLeglImageOES;
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-/* GLeglImageOES defined in GL_OES_EGL_image already. */
-#define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
-#define GL_SAMPLER_EXTERNAL_OES                                 0x8D66
-#define GL_TEXTURE_BINDING_EXTERNAL_OES                         0x8D67
-#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES                     0x8D68
-#endif
-
-/* GL_OES_element_index_uint */
-#ifndef GL_OES_element_index_uint
-#define GL_UNSIGNED_INT                                         0x1405
-#endif
-
-/* GL_OES_get_program_binary */
-#ifndef GL_OES_get_program_binary
-#define GL_PROGRAM_BINARY_LENGTH_OES                            0x8741
-#define GL_NUM_PROGRAM_BINARY_FORMATS_OES                       0x87FE
-#define GL_PROGRAM_BINARY_FORMATS_OES                           0x87FF
-#endif
-
-/* GL_OES_mapbuffer */
-#ifndef GL_OES_mapbuffer
-#define GL_WRITE_ONLY_OES                                       0x88B9
-#define GL_BUFFER_ACCESS_OES                                    0x88BB
-#define GL_BUFFER_MAPPED_OES                                    0x88BC
-#define GL_BUFFER_MAP_POINTER_OES                               0x88BD
-#endif
-
-/* GL_OES_packed_depth_stencil */
-#ifndef GL_OES_packed_depth_stencil
-#define GL_DEPTH_STENCIL_OES                                    0x84F9
-#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
-#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
-#endif
-
-/* GL_OES_rgb8_rgba8 */
-#ifndef GL_OES_rgb8_rgba8
-#define GL_RGB8_OES                                             0x8051
-#define GL_RGBA8_OES                                            0x8058
-#endif
-
-/* GL_OES_standard_derivatives */
-#ifndef GL_OES_standard_derivatives
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES                  0x8B8B
-#endif
-
-/* GL_OES_stencil1 */
-#ifndef GL_OES_stencil1
-#define GL_STENCIL_INDEX1_OES                                   0x8D46
-#endif
-
-/* GL_OES_stencil4 */
-#ifndef GL_OES_stencil4
-#define GL_STENCIL_INDEX4_OES                                   0x8D47
-#endif
-
-/* GL_OES_texture_3D */
-#ifndef GL_OES_texture_3D
-#define GL_TEXTURE_WRAP_R_OES                                   0x8072
-#define GL_TEXTURE_3D_OES                                       0x806F
-#define GL_TEXTURE_BINDING_3D_OES                               0x806A
-#define GL_MAX_3D_TEXTURE_SIZE_OES                              0x8073
-#define GL_SAMPLER_3D_OES                                       0x8B5F
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES        0x8CD4
-#endif
-
-/* GL_OES_texture_float */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_half_float */
-#ifndef GL_OES_texture_half_float
-#define GL_HALF_FLOAT_OES                                       0x8D61
-#endif
-
-/* GL_OES_texture_half_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_npot */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_vertex_array_object */
-#ifndef GL_OES_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING_OES                             0x85B5
-#endif
-
-/* GL_OES_vertex_half_float */
-/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */
-
-/* GL_OES_vertex_type_10_10_10_2 */
-#ifndef GL_OES_vertex_type_10_10_10_2
-#define GL_UNSIGNED_INT_10_10_10_2_OES                          0x8DF6
-#define GL_INT_10_10_10_2_OES                                   0x8DF7
-#endif
-
-/*------------------------------------------------------------------------*
- * AMD extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
-#ifndef GL_AMD_compressed_3DC_texture
-#define GL_3DC_X_AMD                                            0x87F9
-#define GL_3DC_XY_AMD                                           0x87FA
-#endif
-
-/* GL_AMD_compressed_ATC_texture */
-#ifndef GL_AMD_compressed_ATC_texture
-#define GL_ATC_RGB_AMD                                          0x8C92
-#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
-#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
-#endif
-
-/* GL_AMD_performance_monitor */
-#ifndef GL_AMD_performance_monitor
-#define GL_COUNTER_TYPE_AMD                                     0x8BC0
-#define GL_COUNTER_RANGE_AMD                                    0x8BC1
-#define GL_UNSIGNED_INT64_AMD                                   0x8BC2
-#define GL_PERCENTAGE_AMD                                       0x8BC3
-#define GL_PERFMON_RESULT_AVAILABLE_AMD                         0x8BC4
-#define GL_PERFMON_RESULT_SIZE_AMD                              0x8BC5
-#define GL_PERFMON_RESULT_AMD                                   0x8BC6
-#endif
-
-/* GL_AMD_program_binary_Z400 */
-#ifndef GL_AMD_program_binary_Z400
-#define GL_Z400_BINARY_AMD                                      0x8740
-#endif
-
-/*------------------------------------------------------------------------*
- * ANGLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ANGLE_framebuffer_blit */
-#ifndef GL_ANGLE_framebuffer_blit
-#define GL_READ_FRAMEBUFFER_ANGLE                               0x8CA8
-#define GL_DRAW_FRAMEBUFFER_ANGLE                               0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE                       0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_ANGLE                       0x8CAA
-#endif
-
-/* GL_ANGLE_framebuffer_multisample */
-#ifndef GL_ANGLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_ANGLE                           0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE             0x8D56
-#define GL_MAX_SAMPLES_ANGLE                                    0x8D57
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_RGB_422_APPLE                                        0x8A1F
-#define GL_UNSIGNED_SHORT_8_8_APPLE                             0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_APPLE                         0x85BB
-#endif
-
-/* GL_APPLE_framebuffer_multisample */
-#ifndef GL_APPLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_APPLE                           0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE             0x8D56
-#define GL_MAX_SAMPLES_APPLE                                    0x8D57
-#define GL_READ_FRAMEBUFFER_APPLE                               0x8CA8
-#define GL_DRAW_FRAMEBUFFER_APPLE                               0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE                       0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_APPLE                       0x8CAA
-#endif
-
-/* GL_APPLE_texture_format_BGRA8888 */
-#ifndef GL_APPLE_texture_format_BGRA8888
-#define GL_BGRA_EXT                                             0x80E1
-#endif
-
-/* GL_APPLE_texture_max_level */
-#ifndef GL_APPLE_texture_max_level
-#define GL_TEXTURE_MAX_LEVEL_APPLE                              0x813D
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ARM_mali_shader_binary */
-#ifndef GL_ARM_mali_shader_binary
-#define GL_MALI_SHADER_BINARY_ARM                               0x8F60
-#endif
-
-/* GL_ARM_rgba8 */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * EXT extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_EXT_blend_minmax */
-#ifndef GL_EXT_blend_minmax
-#define GL_MIN_EXT                                              0x8007
-#define GL_MAX_EXT                                              0x8008
-#endif
-
-/* GL_EXT_discard_framebuffer */
-#ifndef GL_EXT_discard_framebuffer
-#define GL_COLOR_EXT                                            0x1800
-#define GL_DEPTH_EXT                                            0x1801
-#define GL_STENCIL_EXT                                          0x1802
-#endif
-
-/* GL_EXT_multi_draw_arrays */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_read_format_bgra */
-#ifndef GL_EXT_read_format_bgra
-#define GL_BGRA_EXT                                             0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT                       0x8365
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT                       0x8366
-#endif
-
-/* GL_EXT_shader_texture_lod */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_texture_filter_anisotropic */
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF
-#endif
-
-/* GL_EXT_texture_format_BGRA8888 */
-#ifndef GL_EXT_texture_format_BGRA8888
-#define GL_BGRA_EXT                                             0x80E1
-#endif
-
-/* GL_EXT_texture_type_2_10_10_10_REV */
-#ifndef GL_EXT_texture_type_2_10_10_10_REV
-#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT                      0x8368
-#endif
-
-/* GL_EXT_texture_compression_dxt1 */
-#ifndef GL_EXT_texture_compression_dxt1
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT                         0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT                        0x83F1
-#endif
-
-/* GL_EXT_unpack_subimage */
-#ifndef GL_EXT_unpack_subimage
-#define GL_UNPACK_ROW_LENGTH                                    0x0CF2
-#define GL_UNPACK_SKIP_ROWS                                     0x0CF3
-#define GL_UNPACK_SKIP_PIXELS                                   0x0CF4
-#endif
-
-/*------------------------------------------------------------------------*
- * DMP extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_DMP_shader_binary */
-#ifndef GL_DMP_shader_binary
-#define GL_SHADER_BINARY_DMP                                    0x9250
-#endif
-
-/*------------------------------------------------------------------------*
- * IMG extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_IMG_program_binary */
-#ifndef GL_IMG_program_binary
-#define GL_SGX_PROGRAM_BINARY_IMG                               0x9130
-#endif
-
-/* GL_IMG_read_format */
-#ifndef GL_IMG_read_format
-#define GL_BGRA_IMG                                             0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG                       0x8365
-#endif
-
-/* GL_IMG_shader_binary */
-#ifndef GL_IMG_shader_binary
-#define GL_SGX_BINARY_IMG                                       0x8C0A
-#endif
-
-/* GL_IMG_texture_compression_pvrtc */
-#ifndef GL_IMG_texture_compression_pvrtc
-#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
-#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
-#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
-#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
-#endif
-
-/* GL_IMG_multisampled_render_to_texture */
-#ifndef GL_IMG_multisampled_render_to_texture
-#define GL_RENDERBUFFER_SAMPLES_IMG                             0x9133
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG               0x9134
-#define GL_MAX_SAMPLES_IMG                                      0x9135
-#define GL_TEXTURE_SAMPLES_IMG                                  0x9136
-#endif
-
-/*------------------------------------------------------------------------*
- * NV extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_NV_coverage_sample */
-#ifndef GL_NV_coverage_sample
-#define GL_COVERAGE_COMPONENT_NV                                0x8ED0
-#define GL_COVERAGE_COMPONENT4_NV                               0x8ED1
-#define GL_COVERAGE_ATTACHMENT_NV                               0x8ED2
-#define GL_COVERAGE_BUFFERS_NV                                  0x8ED3
-#define GL_COVERAGE_SAMPLES_NV                                  0x8ED4
-#define GL_COVERAGE_ALL_FRAGMENTS_NV                            0x8ED5
-#define GL_COVERAGE_EDGE_FRAGMENTS_NV                           0x8ED6
-#define GL_COVERAGE_AUTOMATIC_NV                                0x8ED7
-#define GL_COVERAGE_BUFFER_BIT_NV                               0x8000
-#endif
-
-/* GL_NV_depth_nonlinear */
-#ifndef GL_NV_depth_nonlinear
-#define GL_DEPTH_COMPONENT16_NONLINEAR_NV                       0x8E2C
-#endif
-
-/* GL_NV_draw_buffers */
-#ifndef GL_NV_draw_buffers
-#define GL_MAX_DRAW_BUFFERS_NV                                  0x8824
-#define GL_DRAW_BUFFER0_NV                                      0x8825
-#define GL_DRAW_BUFFER1_NV                                      0x8826
-#define GL_DRAW_BUFFER2_NV                                      0x8827
-#define GL_DRAW_BUFFER3_NV                                      0x8828
-#define GL_DRAW_BUFFER4_NV                                      0x8829
-#define GL_DRAW_BUFFER5_NV                                      0x882A
-#define GL_DRAW_BUFFER6_NV                                      0x882B
-#define GL_DRAW_BUFFER7_NV                                      0x882C
-#define GL_DRAW_BUFFER8_NV                                      0x882D
-#define GL_DRAW_BUFFER9_NV                                      0x882E
-#define GL_DRAW_BUFFER10_NV                                     0x882F
-#define GL_DRAW_BUFFER11_NV                                     0x8830
-#define GL_DRAW_BUFFER12_NV                                     0x8831
-#define GL_DRAW_BUFFER13_NV                                     0x8832
-#define GL_DRAW_BUFFER14_NV                                     0x8833
-#define GL_DRAW_BUFFER15_NV                                     0x8834
-#define GL_COLOR_ATTACHMENT0_NV                                 0x8CE0
-#define GL_COLOR_ATTACHMENT1_NV                                 0x8CE1
-#define GL_COLOR_ATTACHMENT2_NV                                 0x8CE2
-#define GL_COLOR_ATTACHMENT3_NV                                 0x8CE3
-#define GL_COLOR_ATTACHMENT4_NV                                 0x8CE4
-#define GL_COLOR_ATTACHMENT5_NV                                 0x8CE5
-#define GL_COLOR_ATTACHMENT6_NV                                 0x8CE6
-#define GL_COLOR_ATTACHMENT7_NV                                 0x8CE7
-#define GL_COLOR_ATTACHMENT8_NV                                 0x8CE8
-#define GL_COLOR_ATTACHMENT9_NV                                 0x8CE9
-#define GL_COLOR_ATTACHMENT10_NV                                0x8CEA
-#define GL_COLOR_ATTACHMENT11_NV                                0x8CEB
-#define GL_COLOR_ATTACHMENT12_NV                                0x8CEC
-#define GL_COLOR_ATTACHMENT13_NV                                0x8CED
-#define GL_COLOR_ATTACHMENT14_NV                                0x8CEE
-#define GL_COLOR_ATTACHMENT15_NV                                0x8CEF
-#endif
-
-/* GL_NV_fbo_color_attachments */
-#ifndef GL_NV_fbo_color_attachments
-#define GL_MAX_COLOR_ATTACHMENTS_NV                             0x8CDF
-/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */
-#endif
-
-/* GL_NV_fence */
-#ifndef GL_NV_fence
-#define GL_ALL_COMPLETED_NV                                     0x84F2
-#define GL_FENCE_STATUS_NV                                      0x84F3
-#define GL_FENCE_CONDITION_NV                                   0x84F4
-#endif
-
-/* GL_NV_read_buffer */
-#ifndef GL_NV_read_buffer
-#define GL_READ_BUFFER_NV                                       0x0C02
-#endif
-
-/* GL_NV_read_buffer_front */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_depth */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_depth_stencil */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_stencil */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_texture_compression_s3tc_update */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_texture_npot_2D_mipmap */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * QCOM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_alpha_test */
-#ifndef GL_QCOM_alpha_test
-#define GL_ALPHA_TEST_QCOM                                      0x0BC0
-#define GL_ALPHA_TEST_FUNC_QCOM                                 0x0BC1
-#define GL_ALPHA_TEST_REF_QCOM                                  0x0BC2
-#endif
-
-/* GL_QCOM_driver_control */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_extended_get */
-#ifndef GL_QCOM_extended_get
-#define GL_TEXTURE_WIDTH_QCOM                                   0x8BD2
-#define GL_TEXTURE_HEIGHT_QCOM                                  0x8BD3
-#define GL_TEXTURE_DEPTH_QCOM                                   0x8BD4
-#define GL_TEXTURE_INTERNAL_FORMAT_QCOM                         0x8BD5
-#define GL_TEXTURE_FORMAT_QCOM                                  0x8BD6
-#define GL_TEXTURE_TYPE_QCOM                                    0x8BD7
-#define GL_TEXTURE_IMAGE_VALID_QCOM                             0x8BD8
-#define GL_TEXTURE_NUM_LEVELS_QCOM                              0x8BD9
-#define GL_TEXTURE_TARGET_QCOM                                  0x8BDA
-#define GL_TEXTURE_OBJECT_VALID_QCOM                            0x8BDB
-#define GL_STATE_RESTORE                                        0x8BDC
-#endif
-
-/* GL_QCOM_extended_get2 */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_perfmon_global_mode */
-#ifndef GL_QCOM_perfmon_global_mode
-#define GL_PERFMON_GLOBAL_MODE_QCOM                             0x8FA0
-#endif
-
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_WRITEONLY_RENDERING_QCOM                             0x8823
-#endif
-
-/* GL_QCOM_tiled_rendering */
-#ifndef GL_QCOM_tiled_rendering
-#define GL_COLOR_BUFFER_BIT0_QCOM                               0x00000001
-#define GL_COLOR_BUFFER_BIT1_QCOM                               0x00000002
-#define GL_COLOR_BUFFER_BIT2_QCOM                               0x00000004
-#define GL_COLOR_BUFFER_BIT3_QCOM                               0x00000008
-#define GL_COLOR_BUFFER_BIT4_QCOM                               0x00000010
-#define GL_COLOR_BUFFER_BIT5_QCOM                               0x00000020
-#define GL_COLOR_BUFFER_BIT6_QCOM                               0x00000040
-#define GL_COLOR_BUFFER_BIT7_QCOM                               0x00000080
-#define GL_DEPTH_BUFFER_BIT0_QCOM                               0x00000100
-#define GL_DEPTH_BUFFER_BIT1_QCOM                               0x00000200
-#define GL_DEPTH_BUFFER_BIT2_QCOM                               0x00000400
-#define GL_DEPTH_BUFFER_BIT3_QCOM                               0x00000800
-#define GL_DEPTH_BUFFER_BIT4_QCOM                               0x00001000
-#define GL_DEPTH_BUFFER_BIT5_QCOM                               0x00002000
-#define GL_DEPTH_BUFFER_BIT6_QCOM                               0x00004000
-#define GL_DEPTH_BUFFER_BIT7_QCOM                               0x00008000
-#define GL_STENCIL_BUFFER_BIT0_QCOM                             0x00010000
-#define GL_STENCIL_BUFFER_BIT1_QCOM                             0x00020000
-#define GL_STENCIL_BUFFER_BIT2_QCOM                             0x00040000
-#define GL_STENCIL_BUFFER_BIT3_QCOM                             0x00080000
-#define GL_STENCIL_BUFFER_BIT4_QCOM                             0x00100000
-#define GL_STENCIL_BUFFER_BIT5_QCOM                             0x00200000
-#define GL_STENCIL_BUFFER_BIT6_QCOM                             0x00400000
-#define GL_STENCIL_BUFFER_BIT7_QCOM                             0x00800000
-#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM                         0x01000000
-#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM                         0x02000000
-#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM                         0x04000000
-#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM                         0x08000000
-#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM                         0x10000000
-#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM                         0x20000000
-#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM                         0x40000000
-#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM                         0x80000000
-#endif
-
-/*------------------------------------------------------------------------*
- * VIV extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_VIV_shader_binary */
-#ifndef GL_VIV_shader_binary
-#define GL_SHADER_BINARY_VIV                                    0x8FC4
-#endif
-
-/*------------------------------------------------------------------------*
- * End of extension tokens, start of corresponding extension functions
- *------------------------------------------------------------------------*/
-
-/*------------------------------------------------------------------------*
- * OES extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_OES_compressed_ETC1_RGB8_texture 1
-#endif
-
-/* GL_OES_compressed_paletted_texture */
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_OES_compressed_paletted_texture 1
-#endif
-
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_OES_depth24 1
-#endif
-
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_OES_depth32 1
-#endif
-
-/* GL_OES_depth_texture */
-#ifndef GL_OES_depth_texture
-#define GL_OES_depth_texture 1
-#endif
-
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-#define GL_OES_EGL_image 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
-GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
-#endif
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-#define GL_OES_EGL_image_external 1
-/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */
-#endif
-
-/* GL_OES_element_index_uint */
-#ifndef GL_OES_element_index_uint
-#define GL_OES_element_index_uint 1
-#endif
-
-/* GL_OES_fbo_render_mipmap */
-#ifndef GL_OES_fbo_render_mipmap
-#define GL_OES_fbo_render_mipmap 1
-#endif
-
-/* GL_OES_fragment_precision_high */
-#ifndef GL_OES_fragment_precision_high
-#define GL_OES_fragment_precision_high 1
-#endif
-
-/* GL_OES_get_program_binary */
-#ifndef GL_OES_get_program_binary
-#define GL_OES_get_program_binary 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
-#endif
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
-#endif
-
-/* GL_OES_mapbuffer */
-#ifndef GL_OES_mapbuffer
-#define GL_OES_mapbuffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
-GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
-GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params);
-#endif
-typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
-typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params);
-#endif
-
-/* GL_OES_packed_depth_stencil */
-#ifndef GL_OES_packed_depth_stencil
-#define GL_OES_packed_depth_stencil 1
-#endif
-
-/* GL_OES_rgb8_rgba8 */
-#ifndef GL_OES_rgb8_rgba8
-#define GL_OES_rgb8_rgba8 1
-#endif
-
-/* GL_OES_standard_derivatives */
-#ifndef GL_OES_standard_derivatives
-#define GL_OES_standard_derivatives 1
-#endif
-
-/* GL_OES_stencil1 */
-#ifndef GL_OES_stencil1
-#define GL_OES_stencil1 1
-#endif
-
-/* GL_OES_stencil4 */
-#ifndef GL_OES_stencil4
-#define GL_OES_stencil4 1
-#endif
-
-/* GL_OES_texture_3D */
-#ifndef GL_OES_texture_3D
-#define GL_OES_texture_3D 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-#endif
-typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
-typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-#endif
-
-/* GL_OES_texture_float */
-#ifndef GL_OES_texture_float
-#define GL_OES_texture_float 1
-#endif
-
-/* GL_OES_texture_float_linear */
-#ifndef GL_OES_texture_float_linear
-#define GL_OES_texture_float_linear 1
-#endif
-
-/* GL_OES_texture_half_float */
-#ifndef GL_OES_texture_half_float
-#define GL_OES_texture_half_float 1
-#endif
-
-/* GL_OES_texture_half_float_linear */
-#ifndef GL_OES_texture_half_float_linear
-#define GL_OES_texture_half_float_linear 1
-#endif
-
-/* GL_OES_texture_npot */
-#ifndef GL_OES_texture_npot
-#define GL_OES_texture_npot 1
-#endif
-
-/* GL_OES_vertex_array_object */
-#ifndef GL_OES_vertex_array_object
-#define GL_OES_vertex_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array);
-GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);
-GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);
-GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);
-#endif
-typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
-typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
-typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
-typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
-#endif
-
-/* GL_OES_vertex_half_float */
-#ifndef GL_OES_vertex_half_float
-#define GL_OES_vertex_half_float 1
-#endif
-
-/* GL_OES_vertex_type_10_10_10_2 */
-#ifndef GL_OES_vertex_type_10_10_10_2
-#define GL_OES_vertex_type_10_10_10_2 1
-#endif
-
-/*------------------------------------------------------------------------*
- * AMD extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
-#ifndef GL_AMD_compressed_3DC_texture
-#define GL_AMD_compressed_3DC_texture 1
-#endif
-
-/* GL_AMD_compressed_ATC_texture */
-#ifndef GL_AMD_compressed_ATC_texture
-#define GL_AMD_compressed_ATC_texture 1
-#endif
-
-/* AMD_performance_monitor */
-#ifndef GL_AMD_performance_monitor
-#define GL_AMD_performance_monitor 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
-GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
-GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
-GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
-GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
-GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
-GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
-GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
-GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor);
-GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
-#endif
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
-typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
-typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
-#endif
-
-/* GL_AMD_program_binary_Z400 */
-#ifndef GL_AMD_program_binary_Z400
-#define GL_AMD_program_binary_Z400 1
-#endif
-
-/*------------------------------------------------------------------------*
- * ANGLE extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_ANGLE_framebuffer_blit */
-#ifndef GL_ANGLE_framebuffer_blit
-#define GL_ANGLE_framebuffer_blit 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif
-typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif
-
-/* GL_ANGLE_framebuffer_multisample */
-#ifndef GL_ANGLE_framebuffer_multisample
-#define GL_ANGLE_framebuffer_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_APPLE_rgb_422 1
-#endif
-
-/* GL_APPLE_framebuffer_multisample */
-#ifndef GL_APPLE_framebuffer_multisample
-#define GL_APPLE_framebuffer_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
-#endif
-
-/* GL_APPLE_texture_format_BGRA8888 */
-#ifndef GL_APPLE_texture_format_BGRA8888
-#define GL_APPLE_texture_format_BGRA8888 1
-#endif
-
-/* GL_APPLE_texture_max_level */
-#ifndef GL_APPLE_texture_max_level
-#define GL_APPLE_texture_max_level 1
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_ARM_mali_shader_binary */
-#ifndef GL_ARM_mali_shader_binary
-#define GL_ARM_mali_shader_binary 1
-#endif
-
-/* GL_ARM_rgba8 */
-#ifndef GL_ARM_rgba8
-#define GL_ARM_rgba8 1
-#endif
-
-/*------------------------------------------------------------------------*
- * EXT extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_EXT_blend_minmax */
-#ifndef GL_EXT_blend_minmax
-#define GL_EXT_blend_minmax 1
-#endif
-
-/* GL_EXT_discard_framebuffer */
-#ifndef GL_EXT_discard_framebuffer
-#define GL_EXT_discard_framebuffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
-#endif
-typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
-GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-#endif
-
-/* GL_EXT_read_format_bgra */
-#ifndef GL_EXT_read_format_bgra
-#define GL_EXT_read_format_bgra 1
-#endif
-
-/* GL_EXT_shader_texture_lod */
-#ifndef GL_EXT_shader_texture_lod
-#define GL_EXT_shader_texture_lod 1
-#endif
-
-/* GL_EXT_texture_filter_anisotropic */
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_EXT_texture_filter_anisotropic 1
-#endif
-
-/* GL_EXT_texture_format_BGRA8888 */
-#ifndef GL_EXT_texture_format_BGRA8888
-#define GL_EXT_texture_format_BGRA8888 1
-#endif
-
-/* GL_EXT_texture_type_2_10_10_10_REV */
-#ifndef GL_EXT_texture_type_2_10_10_10_REV
-#define GL_EXT_texture_type_2_10_10_10_REV 1
-#endif
-
-/* GL_EXT_texture_compression_dxt1 */
-#ifndef GL_EXT_texture_compression_dxt1
-#define GL_EXT_texture_compression_dxt1 1
-#endif
-
-/* GL_EXT_unpack_subimage */
-#ifndef GL_EXT_unpack_subimage
-#define GL_EXT_unpack_subimage 1
-#endif
-
-/*------------------------------------------------------------------------*
- * DMP extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_DMP_shader_binary */
-#ifndef GL_DMP_shader_binary
-#define GL_DMP_shader_binary 1
-#endif
-
-/*------------------------------------------------------------------------*
- * IMG extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_IMG_program_binary */
-#ifndef GL_IMG_program_binary
-#define GL_IMG_program_binary 1
-#endif
-
-/* GL_IMG_read_format */
-#ifndef GL_IMG_read_format
-#define GL_IMG_read_format 1
-#endif
-
-/* GL_IMG_shader_binary */
-#ifndef GL_IMG_shader_binary
-#define GL_IMG_shader_binary 1
-#endif
-
-/* GL_IMG_texture_compression_pvrtc */
-#ifndef GL_IMG_texture_compression_pvrtc
-#define GL_IMG_texture_compression_pvrtc 1
-#endif
-
-/* GL_IMG_multisampled_render_to_texture */
-#ifndef GL_IMG_multisampled_render_to_texture
-#define GL_IMG_multisampled_render_to_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
-#endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
-#endif
-
-/*------------------------------------------------------------------------*
- * NV extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_NV_coverage_sample */
-#ifndef GL_NV_coverage_sample
-#define GL_NV_coverage_sample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);
-GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);
-#endif
-typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
-typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
-#endif
-
-/* GL_NV_depth_nonlinear */
-#ifndef GL_NV_depth_nonlinear
-#define GL_NV_depth_nonlinear 1
-#endif
-
-/* GL_NV_draw_buffers */
-#ifndef GL_NV_draw_buffers
-#define GL_NV_draw_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
-#endif
-typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
-#endif
-
-/* GL_NV_fbo_color_attachments */
-#ifndef GL_NV_fbo_color_attachments
-#define GL_NV_fbo_color_attachments 1
-#endif
-
-/* GL_NV_fence */
-#ifndef GL_NV_fence
-#define GL_NV_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
-GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
-GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint);
-GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint);
-GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
-GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint);
-GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
-#endif
-typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
-typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
-typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
-typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
-typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
-typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
-#endif
-
-/* GL_NV_read_buffer */
-#ifndef GL_NV_read_buffer
-#define GL_NV_read_buffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);
-#endif
-typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
-#endif
-
-/* GL_NV_read_buffer_front */
-#ifndef GL_NV_read_buffer_front
-#define GL_NV_read_buffer_front 1
-#endif
-
-/* GL_NV_read_depth */
-#ifndef GL_NV_read_depth
-#define GL_NV_read_depth 1
-#endif
-
-/* GL_NV_read_depth_stencil */
-#ifndef GL_NV_read_depth_stencil
-#define GL_NV_read_depth_stencil 1
-#endif
-
-/* GL_NV_read_stencil */
-#ifndef GL_NV_read_stencil
-#define GL_NV_read_stencil 1
-#endif
-
-/* GL_NV_texture_compression_s3tc_update */
-#ifndef GL_NV_texture_compression_s3tc_update
-#define GL_NV_texture_compression_s3tc_update 1
-#endif
-
-/* GL_NV_texture_npot_2D_mipmap */
-#ifndef GL_NV_texture_npot_2D_mipmap
-#define GL_NV_texture_npot_2D_mipmap 1
-#endif
-
-/*------------------------------------------------------------------------*
- * QCOM extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_alpha_test */
-#ifndef GL_QCOM_alpha_test
-#define GL_QCOM_alpha_test 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
-#endif
-typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
-#endif
-
-/* GL_QCOM_driver_control */
-#ifndef GL_QCOM_driver_control
-#define GL_QCOM_driver_control 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
-GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
-GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
-GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
-#endif
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
-typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-#endif
-
-/* GL_QCOM_extended_get */
-#ifndef GL_QCOM_extended_get
-#define GL_QCOM_extended_get 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);
-GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
-GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
-GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
-GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
-GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);
-#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);
-#endif
-
-/* GL_QCOM_extended_get2 */
-#ifndef GL_QCOM_extended_get2
-#define GL_QCOM_extended_get2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);
-GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
-GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);
-GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
-#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
-typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
-#endif
-
-/* GL_QCOM_perfmon_global_mode */
-#ifndef GL_QCOM_perfmon_global_mode
-#define GL_QCOM_perfmon_global_mode 1
-#endif
-
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_QCOM_writeonly_rendering 1
-#endif
-
-/* GL_QCOM_tiled_rendering */
-#ifndef GL_QCOM_tiled_rendering
-#define GL_QCOM_tiled_rendering 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
-GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);
-#endif
-typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
-typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
-#endif
-
-/*------------------------------------------------------------------------*
- * VIV extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_VIV_shader_binary */
-#ifndef GL_VIV_shader_binary
-#define GL_VIV_shader_binary 1
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gl2ext_h_ */
diff --git a/thirdparty/khronos/.gitignore b/thirdparty/khronos/.gitignore
new file mode 100644 (file)
index 0000000..2460008
--- /dev/null
@@ -0,0 +1 @@
+!Makefile
diff --git a/thirdparty/khronos/EGL/egl.h b/thirdparty/khronos/EGL/egl.h
new file mode 100644 (file)
index 0000000..99ea342
--- /dev/null
@@ -0,0 +1,329 @@
+/* -*- mode: c; tab-width: 8; -*- */
+/* vi: set sw=4 ts=8: */
+/* Reference version of egl.h for EGL 1.4.
+ * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
+ */
+
+/*
+** Copyright (c) 2007-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+#ifndef __egl_h_
+#define __egl_h_
+
+/* All platform-dependent types and macro boilerplate (such as EGLAPI
+ * and EGLAPIENTRY) should go in eglplatform.h.
+ */
+#include <EGL/eglplatform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* EGL Types */
+/* EGLint is defined in eglplatform.h */
+typedef unsigned int EGLBoolean;
+typedef unsigned int EGLenum;
+typedef void *EGLConfig;
+typedef void *EGLContext;
+typedef void *EGLDisplay;
+typedef void *EGLSurface;
+typedef void *EGLClientBuffer;
+
+/* EGL Versioning */
+#define EGL_VERSION_1_0                        1
+#define EGL_VERSION_1_1                        1
+#define EGL_VERSION_1_2                        1
+#define EGL_VERSION_1_3                        1
+#define EGL_VERSION_1_4                        1
+
+/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
+ * enums are assigned unique values starting at 0x3000.
+ */
+
+/* EGL aliases */
+#define EGL_FALSE                      0
+#define EGL_TRUE                       1
+
+/* Out-of-band handle values */
+#define EGL_DEFAULT_DISPLAY            ((EGLNativeDisplayType)0)
+#define EGL_NO_CONTEXT                 ((EGLContext)0)
+#define EGL_NO_DISPLAY                 ((EGLDisplay)0)
+#define EGL_NO_SURFACE                 ((EGLSurface)0)
+
+/* Out-of-band attribute value */
+#define EGL_DONT_CARE                  ((EGLint)-1)
+
+/* Errors / GetError return values */
+#define EGL_SUCCESS                    0x3000
+#define EGL_NOT_INITIALIZED            0x3001
+#define EGL_BAD_ACCESS                 0x3002
+#define EGL_BAD_ALLOC                  0x3003
+#define EGL_BAD_ATTRIBUTE              0x3004
+#define EGL_BAD_CONFIG                 0x3005
+#define EGL_BAD_CONTEXT                        0x3006
+#define EGL_BAD_CURRENT_SURFACE                0x3007
+#define EGL_BAD_DISPLAY                        0x3008
+#define EGL_BAD_MATCH                  0x3009
+#define EGL_BAD_NATIVE_PIXMAP          0x300A
+#define EGL_BAD_NATIVE_WINDOW          0x300B
+#define EGL_BAD_PARAMETER              0x300C
+#define EGL_BAD_SURFACE                        0x300D
+#define EGL_CONTEXT_LOST               0x300E  /* EGL 1.1 - IMG_power_management */
+
+/* Reserved 0x300F-0x301F for additional errors */
+
+/* Config attributes */
+#define EGL_BUFFER_SIZE                        0x3020
+#define EGL_ALPHA_SIZE                 0x3021
+#define EGL_BLUE_SIZE                  0x3022
+#define EGL_GREEN_SIZE                 0x3023
+#define EGL_RED_SIZE                   0x3024
+#define EGL_DEPTH_SIZE                 0x3025
+#define EGL_STENCIL_SIZE               0x3026
+#define EGL_CONFIG_CAVEAT              0x3027
+#define EGL_CONFIG_ID                  0x3028
+#define EGL_LEVEL                      0x3029
+#define EGL_MAX_PBUFFER_HEIGHT         0x302A
+#define EGL_MAX_PBUFFER_PIXELS         0x302B
+#define EGL_MAX_PBUFFER_WIDTH          0x302C
+#define EGL_NATIVE_RENDERABLE          0x302D
+#define EGL_NATIVE_VISUAL_ID           0x302E
+#define EGL_NATIVE_VISUAL_TYPE         0x302F
+#define EGL_SAMPLES                    0x3031
+#define EGL_SAMPLE_BUFFERS             0x3032
+#define EGL_SURFACE_TYPE               0x3033
+#define EGL_TRANSPARENT_TYPE           0x3034
+#define EGL_TRANSPARENT_BLUE_VALUE     0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE    0x3036
+#define EGL_TRANSPARENT_RED_VALUE      0x3037
+#define EGL_NONE                       0x3038  /* Attrib list terminator */
+#define EGL_BIND_TO_TEXTURE_RGB                0x3039
+#define EGL_BIND_TO_TEXTURE_RGBA       0x303A
+#define EGL_MIN_SWAP_INTERVAL          0x303B
+#define EGL_MAX_SWAP_INTERVAL          0x303C
+#define EGL_LUMINANCE_SIZE             0x303D
+#define EGL_ALPHA_MASK_SIZE            0x303E
+#define EGL_COLOR_BUFFER_TYPE          0x303F
+#define EGL_RENDERABLE_TYPE            0x3040
+#define EGL_MATCH_NATIVE_PIXMAP                0x3041  /* Pseudo-attribute (not queryable) */
+#define EGL_CONFORMANT                 0x3042
+
+/* Reserved 0x3041-0x304F for additional config attributes */
+
+/* Config attribute values */
+#define EGL_SLOW_CONFIG                        0x3050  /* EGL_CONFIG_CAVEAT value */
+#define EGL_NON_CONFORMANT_CONFIG      0x3051  /* EGL_CONFIG_CAVEAT value */
+#define EGL_TRANSPARENT_RGB            0x3052  /* EGL_TRANSPARENT_TYPE value */
+#define EGL_RGB_BUFFER                 0x308E  /* EGL_COLOR_BUFFER_TYPE value */
+#define EGL_LUMINANCE_BUFFER           0x308F  /* EGL_COLOR_BUFFER_TYPE value */
+
+/* More config attribute values, for EGL_TEXTURE_FORMAT */
+#define EGL_NO_TEXTURE                 0x305C
+#define EGL_TEXTURE_RGB                        0x305D
+#define EGL_TEXTURE_RGBA               0x305E
+#define EGL_TEXTURE_2D                 0x305F
+
+/* Config attribute mask bits */
+#define EGL_PBUFFER_BIT                        0x0001  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_PIXMAP_BIT                 0x0002  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_WINDOW_BIT                 0x0004  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_VG_COLORSPACE_LINEAR_BIT   0x0020  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT    0x0040  /* EGL_SURFACE_TYPE mask bits */
+#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
+#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
+
+#define EGL_OPENGL_ES_BIT              0x0001  /* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENVG_BIT                 0x0002  /* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENGL_ES2_BIT             0x0004  /* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENGL_BIT                 0x0008  /* EGL_RENDERABLE_TYPE mask bits */
+
+/* QueryString targets */
+#define EGL_VENDOR                     0x3053
+#define EGL_VERSION                    0x3054
+#define EGL_EXTENSIONS                 0x3055
+#define EGL_CLIENT_APIS                        0x308D
+
+/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
+#define EGL_HEIGHT                     0x3056
+#define EGL_WIDTH                      0x3057
+#define EGL_LARGEST_PBUFFER            0x3058
+#define EGL_TEXTURE_FORMAT             0x3080
+#define EGL_TEXTURE_TARGET             0x3081
+#define EGL_MIPMAP_TEXTURE             0x3082
+#define EGL_MIPMAP_LEVEL               0x3083
+#define EGL_RENDER_BUFFER              0x3086
+#define EGL_VG_COLORSPACE              0x3087
+#define EGL_VG_ALPHA_FORMAT            0x3088
+#define EGL_HORIZONTAL_RESOLUTION      0x3090
+#define EGL_VERTICAL_RESOLUTION                0x3091
+#define EGL_PIXEL_ASPECT_RATIO         0x3092
+#define EGL_SWAP_BEHAVIOR              0x3093
+#define EGL_MULTISAMPLE_RESOLVE                0x3099
+
+/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
+#define EGL_BACK_BUFFER                        0x3084
+#define EGL_SINGLE_BUFFER              0x3085
+
+/* OpenVG color spaces */
+#define EGL_VG_COLORSPACE_sRGB         0x3089  /* EGL_VG_COLORSPACE value */
+#define EGL_VG_COLORSPACE_LINEAR       0x308A  /* EGL_VG_COLORSPACE value */
+
+/* OpenVG alpha formats */
+#define EGL_VG_ALPHA_FORMAT_NONPRE     0x308B  /* EGL_ALPHA_FORMAT value */
+#define EGL_VG_ALPHA_FORMAT_PRE                0x308C  /* EGL_ALPHA_FORMAT value */
+
+/* Constant scale factor by which fractional display resolutions &
+ * aspect ratio are scaled when queried as integer values.
+ */
+#define EGL_DISPLAY_SCALING            10000
+
+/* Unknown display resolution/aspect ratio */
+#define EGL_UNKNOWN                    ((EGLint)-1)
+
+/* Back buffer swap behaviors */
+#define EGL_BUFFER_PRESERVED           0x3094  /* EGL_SWAP_BEHAVIOR value */
+#define EGL_BUFFER_DESTROYED           0x3095  /* EGL_SWAP_BEHAVIOR value */
+
+/* CreatePbufferFromClientBuffer buffer types */
+#define EGL_OPENVG_IMAGE               0x3096
+
+/* QueryContext targets */
+#define EGL_CONTEXT_CLIENT_TYPE                0x3097
+
+/* CreateContext attributes */
+#define EGL_CONTEXT_CLIENT_VERSION     0x3098
+
+/* Multisample resolution behaviors */
+#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
+#define EGL_MULTISAMPLE_RESOLVE_BOX    0x309B  /* EGL_MULTISAMPLE_RESOLVE value */
+
+/* BindAPI/QueryAPI targets */
+#define EGL_OPENGL_ES_API              0x30A0
+#define EGL_OPENVG_API                 0x30A1
+#define EGL_OPENGL_API                 0x30A2
+
+/* GetCurrentSurface targets */
+#define EGL_DRAW                       0x3059
+#define EGL_READ                       0x305A
+
+/* WaitNative engines */
+#define EGL_CORE_NATIVE_ENGINE         0x305B
+
+/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
+#define EGL_COLORSPACE                 EGL_VG_COLORSPACE
+#define EGL_ALPHA_FORMAT               EGL_VG_ALPHA_FORMAT
+#define EGL_COLORSPACE_sRGB            EGL_VG_COLORSPACE_sRGB
+#define EGL_COLORSPACE_LINEAR          EGL_VG_COLORSPACE_LINEAR
+#define EGL_ALPHA_FORMAT_NONPRE                EGL_VG_ALPHA_FORMAT_NONPRE
+#define EGL_ALPHA_FORMAT_PRE           EGL_VG_ALPHA_FORMAT_PRE
+
+/* EGL extensions must request enum blocks from the Khronos
+ * API Registrar, who maintains the enumerant registry. Submit
+ * a bug in Khronos Bugzilla against task "Registry".
+ */
+
+
+
+/* EGL Functions */
+
+EGLAPI EGLint EGLAPIENTRY eglGetError(void);
+
+EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
+EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
+EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
+
+EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
+                        EGLint config_size, EGLint *num_config);
+EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
+                          EGLConfig *configs, EGLint config_size,
+                          EGLint *num_config);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
+                             EGLint attribute, EGLint *value);
+
+EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
+                                 EGLNativeWindowType win,
+                                 const EGLint *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
+                                  const EGLint *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
+                                 EGLNativePixmapType pixmap,
+                                 const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
+EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
+                          EGLint attribute, EGLint *value);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
+EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
+
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
+             EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
+             EGLConfig config, const EGLint *attrib_list);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
+                           EGLint attribute, EGLint value);
+EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+
+
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
+
+
+EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
+                           EGLContext share_context,
+                           const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
+EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
+                         EGLSurface read, EGLContext ctx);
+
+EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
+EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
+EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
+                          EGLint attribute, EGLint *value);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
+EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
+                         EGLNativePixmapType target);
+
+/* This is a generic function pointer type, whose name indicates it must
+ * be cast to the proper type *and calling convention* before use.
+ */
+typedef void (*__eglMustCastToProperFunctionPointerType)(void);
+
+/* Now, define eglGetProcAddress using the generic function ptr. type */
+EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
+       eglGetProcAddress(const char *procname);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __egl_h_ */
diff --git a/thirdparty/khronos/EGL/eglext.h b/thirdparty/khronos/EGL/eglext.h
new file mode 100644 (file)
index 0000000..0b6d289
--- /dev/null
@@ -0,0 +1,464 @@
+#ifndef __eglext_h_
+#define __eglext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2012 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+#include <EGL/eglplatform.h>
+
+/*************************************************************/
+
+/* Header file version number */
+/* Current version at http://www.khronos.org/registry/egl/ */
+/* $Revision: 18699 $ on $Date: 2012-07-31 03:04:59 -0700 (Tue, 31 Jul 2012) $ */
+#define EGL_EGLEXT_VERSION 14
+
+#ifndef EGL_KHR_config_attribs
+#define EGL_KHR_config_attribs 1
+#define EGL_CONFORMANT_KHR                     0x3042  /* EGLConfig attribute */
+#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR       0x0020  /* EGL_SURFACE_TYPE bitfield */
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR                0x0040  /* EGL_SURFACE_TYPE bitfield */
+#endif
+
+#ifndef EGL_KHR_lock_surface
+#define EGL_KHR_lock_surface 1
+#define EGL_READ_SURFACE_BIT_KHR               0x0001  /* EGL_LOCK_USAGE_HINT_KHR bitfield */
+#define EGL_WRITE_SURFACE_BIT_KHR              0x0002  /* EGL_LOCK_USAGE_HINT_KHR bitfield */
+#define EGL_LOCK_SURFACE_BIT_KHR               0x0080  /* EGL_SURFACE_TYPE bitfield */
+#define EGL_OPTIMAL_FORMAT_BIT_KHR             0x0100  /* EGL_SURFACE_TYPE bitfield */
+#define EGL_MATCH_FORMAT_KHR                   0x3043  /* EGLConfig attribute */
+#define EGL_FORMAT_RGB_565_EXACT_KHR           0x30C0  /* EGL_MATCH_FORMAT_KHR value */
+#define EGL_FORMAT_RGB_565_KHR                 0x30C1  /* EGL_MATCH_FORMAT_KHR value */
+#define EGL_FORMAT_RGBA_8888_EXACT_KHR         0x30C2  /* EGL_MATCH_FORMAT_KHR value */
+#define EGL_FORMAT_RGBA_8888_KHR               0x30C3  /* EGL_MATCH_FORMAT_KHR value */
+#define EGL_MAP_PRESERVE_PIXELS_KHR            0x30C4  /* eglLockSurfaceKHR attribute */
+#define EGL_LOCK_USAGE_HINT_KHR                        0x30C5  /* eglLockSurfaceKHR attribute */
+#define EGL_BITMAP_POINTER_KHR                 0x30C6  /* eglQuerySurface attribute */
+#define EGL_BITMAP_PITCH_KHR                   0x30C7  /* eglQuerySurface attribute */
+#define EGL_BITMAP_ORIGIN_KHR                  0x30C8  /* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR                0x30C9  /* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR      0x30CA  /* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR       0x30CB  /* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR      0x30CC  /* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR  0x30CD  /* eglQuerySurface attribute */
+#define EGL_LOWER_LEFT_KHR                     0x30CE  /* EGL_BITMAP_ORIGIN_KHR value */
+#define EGL_UPPER_LEFT_KHR                     0x30CF  /* EGL_BITMAP_ORIGIN_KHR value */
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
+#endif
+
+#ifndef EGL_KHR_image
+#define EGL_KHR_image 1
+#define EGL_NATIVE_PIXMAP_KHR                  0x30B0  /* eglCreateImageKHR target */
+typedef void *EGLImageKHR;
+#define EGL_NO_IMAGE_KHR                       ((EGLImageKHR)0)
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
+#endif
+
+#ifndef EGL_KHR_vg_parent_image
+#define EGL_KHR_vg_parent_image 1
+#define EGL_VG_PARENT_IMAGE_KHR                        0x30BA  /* eglCreateImageKHR target */
+#endif
+
+#ifndef EGL_KHR_gl_texture_2D_image
+#define EGL_KHR_gl_texture_2D_image 1
+#define EGL_GL_TEXTURE_2D_KHR                  0x30B1  /* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_LEVEL_KHR               0x30BC  /* eglCreateImageKHR attribute */
+#endif
+
+#ifndef EGL_KHR_gl_texture_cubemap_image
+#define EGL_KHR_gl_texture_cubemap_image 1
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3  /* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4  /* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5  /* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6  /* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7  /* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8  /* eglCreateImageKHR target */
+#endif
+
+#ifndef EGL_KHR_gl_texture_3D_image
+#define EGL_KHR_gl_texture_3D_image 1
+#define EGL_GL_TEXTURE_3D_KHR                  0x30B2  /* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_ZOFFSET_KHR             0x30BD  /* eglCreateImageKHR attribute */
+#endif
+
+#ifndef EGL_KHR_gl_renderbuffer_image
+#define EGL_KHR_gl_renderbuffer_image 1
+#define EGL_GL_RENDERBUFFER_KHR                        0x30B9  /* eglCreateImageKHR target */
+#endif
+
+#if KHRONOS_SUPPORT_INT64   /* EGLTimeKHR requires 64-bit uint support */
+#ifndef EGL_KHR_reusable_sync
+#define EGL_KHR_reusable_sync 1
+
+typedef void* EGLSyncKHR;
+typedef khronos_utime_nanoseconds_t EGLTimeKHR;
+
+#define EGL_SYNC_STATUS_KHR                    0x30F1
+#define EGL_SIGNALED_KHR                       0x30F2
+#define EGL_UNSIGNALED_KHR                     0x30F3
+#define EGL_TIMEOUT_EXPIRED_KHR                        0x30F5
+#define EGL_CONDITION_SATISFIED_KHR            0x30F6
+#define EGL_SYNC_TYPE_KHR                      0x30F7
+#define EGL_SYNC_REUSABLE_KHR                  0x30FA
+#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR                0x0001  /* eglClientWaitSyncKHR <flags> bitfield */
+#define EGL_FOREVER_KHR                                0xFFFFFFFFFFFFFFFFull
+#define EGL_NO_SYNC_KHR                                ((EGLSyncKHR)0)
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
+EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
+typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
+#endif
+#endif
+
+#ifndef EGL_KHR_image_base
+#define EGL_KHR_image_base 1
+/* Most interfaces defined by EGL_KHR_image_pixmap above */
+#define EGL_IMAGE_PRESERVED_KHR                        0x30D2  /* eglCreateImageKHR attribute */
+#endif
+
+#ifndef EGL_KHR_image_pixmap
+#define EGL_KHR_image_pixmap 1
+/* Interfaces defined by EGL_KHR_image above */
+#endif
+
+#ifndef EGL_IMG_context_priority
+#define EGL_IMG_context_priority 1
+#define EGL_CONTEXT_PRIORITY_LEVEL_IMG         0x3100
+#define EGL_CONTEXT_PRIORITY_HIGH_IMG          0x3101
+#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG                0x3102
+#define EGL_CONTEXT_PRIORITY_LOW_IMG           0x3103
+#endif
+
+#ifndef EGL_KHR_lock_surface2
+#define EGL_KHR_lock_surface2 1
+#define EGL_BITMAP_PIXEL_SIZE_KHR              0x3110
+#endif
+
+#ifndef EGL_NV_coverage_sample
+#define EGL_NV_coverage_sample 1
+#define EGL_COVERAGE_BUFFERS_NV                        0x30E0
+#define EGL_COVERAGE_SAMPLES_NV                        0x30E1
+#endif
+
+#ifndef EGL_NV_depth_nonlinear
+#define EGL_NV_depth_nonlinear 1
+#define EGL_DEPTH_ENCODING_NV                  0x30E2
+#define EGL_DEPTH_ENCODING_NONE_NV 0
+#define EGL_DEPTH_ENCODING_NONLINEAR_NV                0x30E3
+#endif
+
+#if KHRONOS_SUPPORT_INT64   /* EGLTimeNV requires 64-bit uint support */
+#ifndef EGL_NV_sync
+#define EGL_NV_sync 1
+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV    0x30E6
+#define EGL_SYNC_STATUS_NV                     0x30E7
+#define EGL_SIGNALED_NV                                0x30E8
+#define EGL_UNSIGNALED_NV                      0x30E9
+#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV         0x0001
+#define EGL_FOREVER_NV                         0xFFFFFFFFFFFFFFFFull
+#define EGL_ALREADY_SIGNALED_NV                        0x30EA
+#define EGL_TIMEOUT_EXPIRED_NV                 0x30EB
+#define EGL_CONDITION_SATISFIED_NV             0x30EC
+#define EGL_SYNC_TYPE_NV                       0x30ED
+#define EGL_SYNC_CONDITION_NV                  0x30EE
+#define EGL_SYNC_FENCE_NV                      0x30EF
+#define EGL_NO_SYNC_NV                         ((EGLSyncNV)0)
+typedef void* EGLSyncNV;
+typedef khronos_utime_nanoseconds_t EGLTimeNV;
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);
+EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);
+EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
+EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
+typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
+#endif
+#endif
+
+#if KHRONOS_SUPPORT_INT64   /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
+#ifndef EGL_KHR_fence_sync
+#define EGL_KHR_fence_sync 1
+/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
+#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR   0x30F0
+#define EGL_SYNC_CONDITION_KHR                 0x30F8
+#define EGL_SYNC_FENCE_KHR                     0x30F9
+#endif
+#endif
+
+#ifndef EGL_HI_clientpixmap
+#define EGL_HI_clientpixmap 1
+
+/* Surface Attribute */
+#define EGL_CLIENT_PIXMAP_POINTER_HI           0x8F74
+/*
+ * Structure representing a client pixmap
+ * (pixmap's data is in client-space memory).
+ */
+struct EGLClientPixmapHI
+{
+       void*           pData;
+       EGLint          iWidth;
+       EGLint          iHeight;
+       EGLint          iStride;
+};
+
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
+#endif /* EGL_HI_clientpixmap */
+
+#ifndef EGL_HI_colorformats
+#define EGL_HI_colorformats 1
+/* Config Attribute */
+#define EGL_COLOR_FORMAT_HI                    0x8F70
+/* Color Formats */
+#define EGL_COLOR_RGB_HI                       0x8F71
+#define EGL_COLOR_RGBA_HI                      0x8F72
+#define EGL_COLOR_ARGB_HI                      0x8F73
+#endif /* EGL_HI_colorformats */
+
+#ifndef EGL_MESA_drm_image
+#define EGL_MESA_drm_image 1
+#define EGL_DRM_BUFFER_FORMAT_MESA             0x31D0      /* CreateDRMImageMESA attribute */
+#define EGL_DRM_BUFFER_USE_MESA                        0x31D1      /* CreateDRMImageMESA attribute */
+#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA      0x31D2      /* EGL_IMAGE_FORMAT_MESA attribute value */
+#define EGL_DRM_BUFFER_MESA                    0x31D3      /* eglCreateImageKHR target */
+#define EGL_DRM_BUFFER_STRIDE_MESA             0x31D4
+#define EGL_DRM_BUFFER_USE_SCANOUT_MESA                0x00000001  /* EGL_DRM_BUFFER_USE_MESA bits */
+#define EGL_DRM_BUFFER_USE_SHARE_MESA          0x00000002  /* EGL_DRM_BUFFER_USE_MESA bits */
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
+#endif
+
+#ifndef EGL_NV_post_sub_buffer
+#define EGL_NV_post_sub_buffer 1
+#define EGL_POST_SUB_BUFFER_SUPPORTED_NV       0x30BE
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
+#endif
+
+#ifndef EGL_ANGLE_query_surface_pointer
+#define EGL_ANGLE_query_surface_pointer 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
+#endif
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
+#endif
+
+#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
+#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
+#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE  0x3200
+#endif
+
+#ifndef EGL_NV_coverage_sample_resolve
+#define EGL_NV_coverage_sample_resolve 1
+#define EGL_COVERAGE_SAMPLE_RESOLVE_NV         0x3131
+#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
+#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV    0x3133
+#endif
+
+#if KHRONOS_SUPPORT_INT64   /* EGLuint64NV requires 64-bit uint support */
+#ifndef EGL_NV_system_time
+#define EGL_NV_system_time 1
+
+typedef khronos_utime_nanoseconds_t EGLuint64NV;
+
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
+EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
+typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
+#endif
+#endif
+
+#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */
+#ifndef EGL_KHR_stream
+#define EGL_KHR_stream 1
+typedef void* EGLStreamKHR;
+typedef khronos_uint64_t EGLuint64KHR;
+#define EGL_NO_STREAM_KHR                      ((EGLStreamKHR)0)
+#define EGL_CONSUMER_LATENCY_USEC_KHR          0x3210
+#define EGL_PRODUCER_FRAME_KHR                 0x3212
+#define EGL_CONSUMER_FRAME_KHR                 0x3213
+#define EGL_STREAM_STATE_KHR                   0x3214
+#define EGL_STREAM_STATE_CREATED_KHR           0x3215
+#define EGL_STREAM_STATE_CONNECTING_KHR                0x3216
+#define EGL_STREAM_STATE_EMPTY_KHR             0x3217
+#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR    0x3218
+#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR    0x3219
+#define EGL_STREAM_STATE_DISCONNECTED_KHR      0x321A
+#define EGL_BAD_STREAM_KHR                     0x321B
+#define EGL_BAD_STATE_KHR                      0x321C
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_consumer_gltexture
+#define EGL_KHR_stream_consumer_gltexture 1
+#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR  0x321E
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_eglsurface
+#define EGL_KHR_stream_producer_eglsurface 1
+#define EGL_STREAM_BIT_KHR                     0x0800
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_producer_aldatalocator
+#define EGL_KHR_stream_producer_aldatalocator 1
+#endif
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_fifo
+#define EGL_KHR_stream_fifo 1
+/* reuse EGLTimeKHR */
+#define EGL_STREAM_FIFO_LENGTH_KHR             0x31FC
+#define EGL_STREAM_TIME_NOW_KHR                        0x31FD
+#define EGL_STREAM_TIME_CONSUMER_KHR           0x31FE
+#define EGL_STREAM_TIME_PRODUCER_KHR           0x31FF
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+#endif
+#endif
+
+#ifndef EGL_EXT_create_context_robustness
+#define EGL_EXT_create_context_robustness 1
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT   0x30BF
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
+#define EGL_NO_RESET_NOTIFICATION_EXT          0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET_EXT          0x31BF
+#endif
+
+#ifndef EGL_ANGLE_d3d_share_handle_client_buffer
+#define EGL_ANGLE_d3d_share_handle_client_buffer 1
+/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */
+#endif
+
+#ifndef EGL_KHR_create_context
+#define EGL_KHR_create_context 1
+#define EGL_CONTEXT_MAJOR_VERSION_KHR                      EGL_CONTEXT_CLIENT_VERSION
+#define EGL_CONTEXT_MINOR_VERSION_KHR                      0x30FB
+#define EGL_CONTEXT_FLAGS_KHR                              0x30FC
+#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR                0x30FD
+#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR  0x31BD
+#define EGL_NO_RESET_NOTIFICATION_KHR                      0x31BE
+#define EGL_LOSE_CONTEXT_ON_RESET_KHR                      0x31BF
+#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR                   0x00000001
+#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR      0x00000002
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR           0x00000004
+#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR                    0x00000001
+#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR    0x00000002
+#endif
+
+#ifndef EGL_KHR_surfaceless_context
+#define EGL_KHR_surfaceless_context 1
+/* No tokens/entry points, just relaxes an error condition */
+#endif
+
+#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
+#ifndef EGL_KHR_stream_cross_process_fd
+#define EGL_KHR_stream_cross_process_fd 1
+typedef int EGLNativeFileDescriptorKHR;
+#define EGL_NO_FILE_DESCRIPTOR_KHR             ((EGLNativeFileDescriptorKHR)(-1))
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
+EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
+typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/thirdparty/khronos/EGL/eglplatform.h b/thirdparty/khronos/EGL/eglplatform.h
new file mode 100644 (file)
index 0000000..b5995ec
--- /dev/null
@@ -0,0 +1,131 @@
+#ifndef __eglplatform_h_
+#define __eglplatform_h_
+
+/*
+** Copyright (c) 2007-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Platform-specific types and definitions for egl.h
+ * $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product "EGL" component "Registry".
+ */
+
+#include <KHR/khrplatform.h>
+
+/* Macros used in EGL function prototype declarations.
+ *
+ * EGL functions should be prototyped as:
+ *
+ * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
+ * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
+ *
+ * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
+ */
+
+#ifndef EGLAPI
+#define EGLAPI KHRONOS_APICALL
+#endif
+
+#ifndef EGLAPIENTRY
+#define EGLAPIENTRY  KHRONOS_APIENTRY
+#endif
+#define EGLAPIENTRYP EGLAPIENTRY*
+
+/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
+ * are aliases of window-system-dependent types, such as X Display * or
+ * Windows Device Context. They must be defined in platform-specific
+ * code below. The EGL-prefixed versions of Native*Type are the same
+ * types, renamed in EGL 1.3 so all types in the API start with "EGL".
+ *
+ * Khronos STRONGLY RECOMMENDS that you use the default definitions
+ * provided below, since these changes affect both binary and source
+ * portability of applications using EGL running on different EGL
+ * implementations.
+ */
+
+#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+
+typedef HDC     EGLNativeDisplayType;
+typedef HBITMAP EGLNativePixmapType;
+typedef HWND    EGLNativeWindowType;
+
+#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
+
+typedef int   EGLNativeDisplayType;
+typedef void *EGLNativeWindowType;
+typedef void *EGLNativePixmapType;
+
+#elif defined(__ANDROID__) || defined(ANDROID)
+
+#include <android/native_window.h>
+
+struct egl_native_pixmap_t;
+
+typedef struct ANativeWindow*           EGLNativeWindowType;
+typedef struct egl_native_pixmap_t*     EGLNativePixmapType;
+typedef void*                           EGLNativeDisplayType;
+
+#elif defined(__APPLE__)
+
+typedef void *EGLNativeDisplayType;
+typedef void *EGLNativePixmapType;
+typedef void *EGLNativeWindowType;
+
+#elif defined(__unix__)
+
+/* X11 (tentative)  */
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+typedef Display *EGLNativeDisplayType;
+typedef Pixmap   EGLNativePixmapType;
+typedef Window   EGLNativeWindowType;
+
+#else
+#error "Platform not recognized"
+#endif
+
+/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
+typedef EGLNativeDisplayType NativeDisplayType;
+typedef EGLNativePixmapType  NativePixmapType;
+typedef EGLNativeWindowType  NativeWindowType;
+
+
+/* Define EGLint. This must be a signed integral type large enough to contain
+ * all legal attribute names and values passed into and out of EGL, whether
+ * their type is boolean, bitmask, enumerant (symbolic constant), integer,
+ * handle, or other.  While in general a 32-bit integer will suffice, if
+ * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
+ * integer type.
+ */
+typedef khronos_int32_t EGLint;
+
+#endif /* __eglplatform_h */
diff --git a/thirdparty/khronos/EGL/eglplatform.patch b/thirdparty/khronos/EGL/eglplatform.patch
new file mode 100644 (file)
index 0000000..d35bca3
--- /dev/null
@@ -0,0 +1,27 @@
+diff --git a/thirdparty/khronos/EGL/eglplatform.h b/thirdparty/khronos/EGL/eglplatform.h
+index 6d34ab5..5f30ef1 100644
+--- a/thirdparty/khronos/EGL/eglplatform.h
++++ b/thirdparty/khronos/EGL/eglplatform.h
+@@ -83,6 +83,22 @@ typedef int   EGLNativeDisplayType;
+ typedef void *EGLNativeWindowType;
+ typedef void *EGLNativePixmapType;
++#elif defined(__ANDROID__) || defined(ANDROID)
++
++#include <android/native_window.h>
++
++struct egl_native_pixmap_t;
++
++typedef struct ANativeWindow*           EGLNativeWindowType;
++typedef struct egl_native_pixmap_t*     EGLNativePixmapType;
++typedef void*                           EGLNativeDisplayType;
++
++#elif defined(__APPLE__)
++
++typedef void *EGLNativeDisplayType;
++typedef void *EGLNativePixmapType;
++typedef void *EGLNativeWindowType;
++
+ #elif defined(__unix__)
+ /* X11 (tentative)  */
diff --git a/thirdparty/khronos/GL/gl.h b/thirdparty/khronos/GL/gl.h
new file mode 100644 (file)
index 0000000..e59f6bc
--- /dev/null
@@ -0,0 +1,1957 @@
+#ifndef __gl_h_
+#define __gl_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef int GLint;
+typedef int GLsizei;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned int GLuint;
+typedef float GLfloat;
+typedef float GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void GLvoid;
+
+/*************************************************************/
+
+/* Version */
+#define GL_VERSION_1_1                    1
+#define GL_VERSION_1_2                    1
+
+/* Extensions */
+#define GL_ARB_imaging                    1
+#define GL_ARB_multitexture               1
+
+/* AccumOp */
+#define GL_ACCUM                          0x0100
+#define GL_LOAD                           0x0101
+#define GL_RETURN                         0x0102
+#define GL_MULT                           0x0103
+#define GL_ADD                            0x0104
+
+/* AlphaFunction */
+#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
+
+/* AttribMask */
+#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
+
+/* BeginMode */
+#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
+
+/* BlendEquationMode */
+/*      GL_LOGIC_OP */
+/*      GL_FUNC_ADD */
+/*      GL_MIN */
+/*      GL_MAX */
+/*      GL_FUNC_SUBTRACT */
+/*      GL_FUNC_REVERSE_SUBTRACT */
+
+/* BlendingFactorDest */
+#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
+/*      GL_CONSTANT_COLOR */
+/*      GL_ONE_MINUS_CONSTANT_COLOR */
+/*      GL_CONSTANT_ALPHA */
+/*      GL_ONE_MINUS_CONSTANT_ALPHA */
+
+/* BlendingFactorSrc */
+/*      GL_ZERO */
+/*      GL_ONE */
+#define GL_DST_COLOR                      0x0306
+#define GL_ONE_MINUS_DST_COLOR            0x0307
+#define GL_SRC_ALPHA_SATURATE             0x0308
+/*      GL_SRC_ALPHA */
+/*      GL_ONE_MINUS_SRC_ALPHA */
+/*      GL_DST_ALPHA */
+/*      GL_ONE_MINUS_DST_ALPHA */
+/*      GL_CONSTANT_COLOR */
+/*      GL_ONE_MINUS_CONSTANT_COLOR */
+/*      GL_CONSTANT_ALPHA */
+/*      GL_ONE_MINUS_CONSTANT_ALPHA */
+
+/* Boolean */
+#define GL_TRUE                           1
+#define GL_FALSE                          0
+
+/* ClearBufferMask */
+/*      GL_COLOR_BUFFER_BIT */
+/*      GL_ACCUM_BUFFER_BIT */
+/*      GL_STENCIL_BUFFER_BIT */
+/*      GL_DEPTH_BUFFER_BIT */
+
+/* ClientArrayType */
+/*      GL_VERTEX_ARRAY */
+/*      GL_NORMAL_ARRAY */
+/*      GL_COLOR_ARRAY */
+/*      GL_INDEX_ARRAY */
+/*      GL_TEXTURE_COORD_ARRAY */
+/*      GL_EDGE_FLAG_ARRAY */
+
+/* ClipPlaneName */
+#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
+
+/* ColorMaterialFace */
+/*      GL_FRONT */
+/*      GL_BACK */
+/*      GL_FRONT_AND_BACK */
+
+/* ColorMaterialParameter */
+/*      GL_AMBIENT */
+/*      GL_DIFFUSE */
+/*      GL_SPECULAR */
+/*      GL_EMISSION */
+/*      GL_AMBIENT_AND_DIFFUSE */
+
+/* ColorPointerType */
+/*      GL_BYTE */
+/*      GL_UNSIGNED_BYTE */
+/*      GL_SHORT */
+/*      GL_UNSIGNED_SHORT */
+/*      GL_INT */
+/*      GL_UNSIGNED_INT */
+/*      GL_FLOAT */
+/*      GL_DOUBLE */
+
+/* ColorTableParameterPName */
+/*      GL_COLOR_TABLE_SCALE */
+/*      GL_COLOR_TABLE_BIAS */
+
+/* ColorTableTarget */
+/*      GL_COLOR_TABLE */
+/*      GL_POST_CONVOLUTION_COLOR_TABLE */
+/*      GL_POST_COLOR_MATRIX_COLOR_TABLE */
+/*      GL_PROXY_COLOR_TABLE */
+/*      GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+/*      GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+
+/* ConvolutionBorderMode */
+/*      GL_REDUCE */
+/*      GL_IGNORE_BORDER */
+/*      GL_CONSTANT_BORDER */
+
+/* ConvolutionParameter */
+/*      GL_CONVOLUTION_BORDER_MODE */
+/*      GL_CONVOLUTION_FILTER_SCALE */
+/*      GL_CONVOLUTION_FILTER_BIAS */
+
+/* ConvolutionTarget */
+/*      GL_CONVOLUTION_1D */
+/*      GL_CONVOLUTION_2D */
+
+/* CullFaceMode */
+/*      GL_FRONT */
+/*      GL_BACK */
+/*      GL_FRONT_AND_BACK */
+
+/* DataType */
+#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
+
+/* DepthFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* DrawBufferMode */
+#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
+
+/* Enable */
+/*      GL_FOG */
+/*      GL_LIGHTING */
+/*      GL_TEXTURE_1D */
+/*      GL_TEXTURE_2D */
+/*      GL_LINE_STIPPLE */
+/*      GL_POLYGON_STIPPLE */
+/*      GL_CULL_FACE */
+/*      GL_ALPHA_TEST */
+/*      GL_BLEND */
+/*      GL_INDEX_LOGIC_OP */
+/*      GL_COLOR_LOGIC_OP */
+/*      GL_DITHER */
+/*      GL_STENCIL_TEST */
+/*      GL_DEPTH_TEST */
+/*      GL_CLIP_PLANE0 */
+/*      GL_CLIP_PLANE1 */
+/*      GL_CLIP_PLANE2 */
+/*      GL_CLIP_PLANE3 */
+/*      GL_CLIP_PLANE4 */
+/*      GL_CLIP_PLANE5 */
+/*      GL_LIGHT0 */
+/*      GL_LIGHT1 */
+/*      GL_LIGHT2 */
+/*      GL_LIGHT3 */
+/*      GL_LIGHT4 */
+/*      GL_LIGHT5 */
+/*      GL_LIGHT6 */
+/*      GL_LIGHT7 */
+/*      GL_TEXTURE_GEN_S */
+/*      GL_TEXTURE_GEN_T */
+/*      GL_TEXTURE_GEN_R */
+/*      GL_TEXTURE_GEN_Q */
+/*      GL_MAP1_VERTEX_3 */
+/*      GL_MAP1_VERTEX_4 */
+/*      GL_MAP1_COLOR_4 */
+/*      GL_MAP1_INDEX */
+/*      GL_MAP1_NORMAL */
+/*      GL_MAP1_TEXTURE_COORD_1 */
+/*      GL_MAP1_TEXTURE_COORD_2 */
+/*      GL_MAP1_TEXTURE_COORD_3 */
+/*      GL_MAP1_TEXTURE_COORD_4 */
+/*      GL_MAP2_VERTEX_3 */
+/*      GL_MAP2_VERTEX_4 */
+/*      GL_MAP2_COLOR_4 */
+/*      GL_MAP2_INDEX */
+/*      GL_MAP2_NORMAL */
+/*      GL_MAP2_TEXTURE_COORD_1 */
+/*      GL_MAP2_TEXTURE_COORD_2 */
+/*      GL_MAP2_TEXTURE_COORD_3 */
+/*      GL_MAP2_TEXTURE_COORD_4 */
+/*      GL_POINT_SMOOTH */
+/*      GL_LINE_SMOOTH */
+/*      GL_POLYGON_SMOOTH */
+/*      GL_SCISSOR_TEST */
+/*      GL_COLOR_MATERIAL */
+/*      GL_NORMALIZE */
+/*      GL_AUTO_NORMAL */
+/*      GL_VERTEX_ARRAY */
+/*      GL_NORMAL_ARRAY */
+/*      GL_COLOR_ARRAY */
+/*      GL_INDEX_ARRAY */
+/*      GL_TEXTURE_COORD_ARRAY */
+/*      GL_EDGE_FLAG_ARRAY */
+/*      GL_POLYGON_OFFSET_POINT */
+/*      GL_POLYGON_OFFSET_LINE */
+/*      GL_POLYGON_OFFSET_FILL */
+/*      GL_COLOR_TABLE */
+/*      GL_POST_CONVOLUTION_COLOR_TABLE */
+/*      GL_POST_COLOR_MATRIX_COLOR_TABLE */
+/*      GL_CONVOLUTION_1D */
+/*      GL_CONVOLUTION_2D */
+/*      GL_SEPARABLE_2D */
+/*      GL_HISTOGRAM */
+/*      GL_MINMAX */
+/*      GL_RESCALE_NORMAL */
+/*      GL_TEXTURE_3D */
+
+/* ErrorCode */
+#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
+/*      GL_TABLE_TOO_LARGE */
+
+/* FeedBackMode */
+#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
+
+/* FeedBackToken */
+#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
+
+/* FogMode */
+/*      GL_LINEAR */
+#define GL_EXP                            0x0800
+#define GL_EXP2                           0x0801
+
+/* FogParameter */
+/*      GL_FOG_COLOR */
+/*      GL_FOG_DENSITY */
+/*      GL_FOG_END */
+/*      GL_FOG_INDEX */
+/*      GL_FOG_MODE */
+/*      GL_FOG_START */
+
+/* FrontFaceDirection */
+#define GL_CW                             0x0900
+#define GL_CCW                            0x0901
+
+/* GetColorTableParameterPName */
+/*      GL_COLOR_TABLE_SCALE */
+/*      GL_COLOR_TABLE_BIAS */
+/*      GL_COLOR_TABLE_FORMAT */
+/*      GL_COLOR_TABLE_WIDTH */
+/*      GL_COLOR_TABLE_RED_SIZE */
+/*      GL_COLOR_TABLE_GREEN_SIZE */
+/*      GL_COLOR_TABLE_BLUE_SIZE */
+/*      GL_COLOR_TABLE_ALPHA_SIZE */
+/*      GL_COLOR_TABLE_LUMINANCE_SIZE */
+/*      GL_COLOR_TABLE_INTENSITY_SIZE */
+
+/* GetConvolutionParameterPName */
+/*      GL_CONVOLUTION_BORDER_COLOR */
+/*      GL_CONVOLUTION_BORDER_MODE */
+/*      GL_CONVOLUTION_FILTER_SCALE */
+/*      GL_CONVOLUTION_FILTER_BIAS */
+/*      GL_CONVOLUTION_FORMAT */
+/*      GL_CONVOLUTION_WIDTH */
+/*      GL_CONVOLUTION_HEIGHT */
+/*      GL_MAX_CONVOLUTION_WIDTH */
+/*      GL_MAX_CONVOLUTION_HEIGHT */
+
+/* GetHistogramParameterPName */
+/*      GL_HISTOGRAM_WIDTH */
+/*      GL_HISTOGRAM_FORMAT */
+/*      GL_HISTOGRAM_RED_SIZE */
+/*      GL_HISTOGRAM_GREEN_SIZE */
+/*      GL_HISTOGRAM_BLUE_SIZE */
+/*      GL_HISTOGRAM_ALPHA_SIZE */
+/*      GL_HISTOGRAM_LUMINANCE_SIZE */
+/*      GL_HISTOGRAM_SINK */
+
+/* GetMapTarget */
+#define GL_COEFF                          0x0A00
+#define GL_ORDER                          0x0A01
+#define GL_DOMAIN                         0x0A02
+
+/* GetMinmaxParameterPName */
+/*      GL_MINMAX_FORMAT */
+/*      GL_MINMAX_SINK */
+
+/* GetPixelMap */
+/*      GL_PIXEL_MAP_I_TO_I */
+/*      GL_PIXEL_MAP_S_TO_S */
+/*      GL_PIXEL_MAP_I_TO_R */
+/*      GL_PIXEL_MAP_I_TO_G */
+/*      GL_PIXEL_MAP_I_TO_B */
+/*      GL_PIXEL_MAP_I_TO_A */
+/*      GL_PIXEL_MAP_R_TO_R */
+/*      GL_PIXEL_MAP_G_TO_G */
+/*      GL_PIXEL_MAP_B_TO_B */
+/*      GL_PIXEL_MAP_A_TO_A */
+
+/* GetPointerTarget */
+/*      GL_VERTEX_ARRAY_POINTER */
+/*      GL_NORMAL_ARRAY_POINTER */
+/*      GL_COLOR_ARRAY_POINTER */
+/*      GL_INDEX_ARRAY_POINTER */
+/*      GL_TEXTURE_COORD_ARRAY_POINTER */
+/*      GL_EDGE_FLAG_ARRAY_POINTER */
+
+/* GetTarget */
+#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
+/*      GL_SMOOTH_POINT_SIZE_RANGE */
+/*      GL_SMOOTH_POINT_SIZE_GRANULARITY */
+/*      GL_SMOOTH_LINE_WIDTH_RANGE */
+/*      GL_SMOOTH_LINE_WIDTH_GRANULARITY */
+/*      GL_ALIASED_POINT_SIZE_RANGE */
+/*      GL_ALIASED_LINE_WIDTH_RANGE */
+#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
+/*      GL_TEXTURE_BINDING_1D */
+/*      GL_TEXTURE_BINDING_2D */
+/*      GL_TEXTURE_BINDING_3D */
+/*      GL_VERTEX_ARRAY */
+/*      GL_NORMAL_ARRAY */
+/*      GL_COLOR_ARRAY */
+/*      GL_INDEX_ARRAY */
+/*      GL_TEXTURE_COORD_ARRAY */
+/*      GL_EDGE_FLAG_ARRAY */
+/*      GL_VERTEX_ARRAY_SIZE */
+/*      GL_VERTEX_ARRAY_TYPE */
+/*      GL_VERTEX_ARRAY_STRIDE */
+/*      GL_NORMAL_ARRAY_TYPE */
+/*      GL_NORMAL_ARRAY_STRIDE */
+/*      GL_COLOR_ARRAY_SIZE */
+/*      GL_COLOR_ARRAY_TYPE */
+/*      GL_COLOR_ARRAY_STRIDE */
+/*      GL_INDEX_ARRAY_TYPE */
+/*      GL_INDEX_ARRAY_STRIDE */
+/*      GL_TEXTURE_COORD_ARRAY_SIZE */
+/*      GL_TEXTURE_COORD_ARRAY_TYPE */
+/*      GL_TEXTURE_COORD_ARRAY_STRIDE */
+/*      GL_EDGE_FLAG_ARRAY_STRIDE */
+/*      GL_POLYGON_OFFSET_FACTOR */
+/*      GL_POLYGON_OFFSET_UNITS */
+/*      GL_COLOR_TABLE */
+/*      GL_POST_CONVOLUTION_COLOR_TABLE */
+/*      GL_POST_COLOR_MATRIX_COLOR_TABLE */
+/*      GL_CONVOLUTION_1D */
+/*      GL_CONVOLUTION_2D */
+/*      GL_SEPARABLE_2D */
+/*      GL_POST_CONVOLUTION_RED_SCALE */
+/*      GL_POST_CONVOLUTION_GREEN_SCALE */
+/*      GL_POST_CONVOLUTION_BLUE_SCALE */
+/*      GL_POST_CONVOLUTION_ALPHA_SCALE */
+/*      GL_POST_CONVOLUTION_RED_BIAS */
+/*      GL_POST_CONVOLUTION_GREEN_BIAS */
+/*      GL_POST_CONVOLUTION_BLUE_BIAS */
+/*      GL_POST_CONVOLUTION_ALPHA_BIAS */
+/*      GL_COLOR_MATRIX */
+/*      GL_COLOR_MATRIX_STACK_DEPTH */
+/*      GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+/*      GL_POST_COLOR_MATRIX_RED_SCALE */
+/*      GL_POST_COLOR_MATRIX_GREEN_SCALE */
+/*      GL_POST_COLOR_MATRIX_BLUE_SCALE */
+/*      GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+/*      GL_POST_COLOR_MATRIX_RED_BIAS */
+/*      GL_POST_COLOR_MATRIX_GREEN_BIAS */
+/*      GL_POST_COLOR_MATRIX_BLUE_BIAS */
+/*      GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+/*      GL_HISTOGRAM */
+/*      GL_MINMAX */
+/*      GL_MAX_ELEMENTS_VERTICES */
+/*      GL_MAX_ELEMENTS_INDICES */
+/*      GL_RESCALE_NORMAL */
+/*      GL_LIGHT_MODEL_COLOR_CONTROL */
+/*      GL_PACK_SKIP_IMAGES */
+/*      GL_PACK_IMAGE_HEIGHT */
+/*      GL_UNPACK_SKIP_IMAGES */
+/*      GL_UNPACK_IMAGE_HEIGHT */
+/*      GL_TEXTURE_3D */
+/*      GL_MAX_3D_TEXTURE_SIZE */
+/*      GL_BLEND_COLOR */
+/*      GL_BLEND_EQUATION */
+/*      GL_ACTIVE_TEXTURE_ARB */
+/*      GL_CLIENT_ACTIVE_TEXTURE_ARB */
+/*      GL_MAX_TEXTURE_UNITS_ARB */
+
+/* GetTextureParameter */
+/*      GL_TEXTURE_MAG_FILTER */
+/*      GL_TEXTURE_MIN_FILTER */
+/*      GL_TEXTURE_WRAP_S */
+/*      GL_TEXTURE_WRAP_T */
+#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
+/*      GL_TEXTURE_RED_SIZE */
+/*      GL_TEXTURE_GREEN_SIZE */
+/*      GL_TEXTURE_BLUE_SIZE */
+/*      GL_TEXTURE_ALPHA_SIZE */
+/*      GL_TEXTURE_LUMINANCE_SIZE */
+/*      GL_TEXTURE_INTENSITY_SIZE */
+/*      GL_TEXTURE_PRIORITY */
+/*      GL_TEXTURE_RESIDENT */
+/*      GL_TEXTURE_DEPTH */
+/*      GL_TEXTURE_WRAP_R */
+/*      GL_TEXTURE_MIN_LOD */
+/*      GL_TEXTURE_MAX_LOD */
+/*      GL_TEXTURE_BASE_LEVEL */
+/*      GL_TEXTURE_MAX_LEVEL */
+
+/* HintMode */
+#define GL_DONT_CARE                      0x1100
+#define GL_FASTEST                        0x1101
+#define GL_NICEST                         0x1102
+
+/* HintTarget */
+/*      GL_PERSPECTIVE_CORRECTION_HINT */
+/*      GL_POINT_SMOOTH_HINT */
+/*      GL_LINE_SMOOTH_HINT */
+/*      GL_POLYGON_SMOOTH_HINT */
+/*      GL_FOG_HINT */
+
+/* HistogramTarget */
+/*      GL_HISTOGRAM */
+/*      GL_PROXY_HISTOGRAM */
+
+/* IndexPointerType */
+/*      GL_SHORT */
+/*      GL_INT */
+/*      GL_FLOAT */
+/*      GL_DOUBLE */
+
+/* LightModelColorControl */
+/*      GL_SINGLE_COLOR */
+/*      GL_SEPARATE_SPECULAR_COLOR */
+
+/* LightModelParameter */
+/*      GL_LIGHT_MODEL_AMBIENT */
+/*      GL_LIGHT_MODEL_LOCAL_VIEWER */
+/*      GL_LIGHT_MODEL_TWO_SIDE */
+/*      GL_LIGHT_MODEL_COLOR_CONTROL */
+
+/* LightName */
+#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
+
+/* LightParameter */
+#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
+
+/* InterleavedArrays */
+/*      GL_V2F */
+/*      GL_V3F */
+/*      GL_C4UB_V2F */
+/*      GL_C4UB_V3F */
+/*      GL_C3F_V3F */
+/*      GL_N3F_V3F */
+/*      GL_C4F_N3F_V3F */
+/*      GL_T2F_V3F */
+/*      GL_T4F_V4F */
+/*      GL_T2F_C4UB_V3F */
+/*      GL_T2F_C3F_V3F */
+/*      GL_T2F_N3F_V3F */
+/*      GL_T2F_C4F_N3F_V3F */
+/*      GL_T4F_C4F_N3F_V4F */
+
+/* ListMode */
+#define GL_COMPILE                        0x1300
+#define GL_COMPILE_AND_EXECUTE            0x1301
+
+/* ListNameType */
+/*      GL_BYTE */
+/*      GL_UNSIGNED_BYTE */
+/*      GL_SHORT */
+/*      GL_UNSIGNED_SHORT */
+/*      GL_INT */
+/*      GL_UNSIGNED_INT */
+/*      GL_FLOAT */
+/*      GL_2_BYTES */
+/*      GL_3_BYTES */
+/*      GL_4_BYTES */
+
+/* LogicOp */
+#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
+
+/* MapTarget */
+/*      GL_MAP1_COLOR_4 */
+/*      GL_MAP1_INDEX */
+/*      GL_MAP1_NORMAL */
+/*      GL_MAP1_TEXTURE_COORD_1 */
+/*      GL_MAP1_TEXTURE_COORD_2 */
+/*      GL_MAP1_TEXTURE_COORD_3 */
+/*      GL_MAP1_TEXTURE_COORD_4 */
+/*      GL_MAP1_VERTEX_3 */
+/*      GL_MAP1_VERTEX_4 */
+/*      GL_MAP2_COLOR_4 */
+/*      GL_MAP2_INDEX */
+/*      GL_MAP2_NORMAL */
+/*      GL_MAP2_TEXTURE_COORD_1 */
+/*      GL_MAP2_TEXTURE_COORD_2 */
+/*      GL_MAP2_TEXTURE_COORD_3 */
+/*      GL_MAP2_TEXTURE_COORD_4 */
+/*      GL_MAP2_VERTEX_3 */
+/*      GL_MAP2_VERTEX_4 */
+
+/* MaterialFace */
+/*      GL_FRONT */
+/*      GL_BACK */
+/*      GL_FRONT_AND_BACK */
+
+/* MaterialParameter */
+#define GL_EMISSION                       0x1600
+#define GL_SHININESS                      0x1601
+#define GL_AMBIENT_AND_DIFFUSE            0x1602
+#define GL_COLOR_INDEXES                  0x1603
+/*      GL_AMBIENT */
+/*      GL_DIFFUSE */
+/*      GL_SPECULAR */
+
+/* MatrixMode */
+#define GL_MODELVIEW                      0x1700
+#define GL_PROJECTION                     0x1701
+#define GL_TEXTURE                        0x1702
+
+/* MeshMode1 */
+/*      GL_POINT */
+/*      GL_LINE */
+
+/* MeshMode2 */
+/*      GL_POINT */
+/*      GL_LINE */
+/*      GL_FILL */
+
+/* MinmaxTarget */
+/*      GL_MINMAX */
+
+/* NormalPointerType */
+/*      GL_BYTE */
+/*      GL_SHORT */
+/*      GL_INT */
+/*      GL_FLOAT */
+/*      GL_DOUBLE */
+
+/* PixelCopyType */
+#define GL_COLOR                          0x1800
+#define GL_DEPTH                          0x1801
+#define GL_STENCIL                        0x1802
+
+/* PixelFormat */
+#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
+/*      GL_ABGR */
+
+/* PixelInternalFormat */
+/*      GL_ALPHA4 */
+/*      GL_ALPHA8 */
+/*      GL_ALPHA12 */
+/*      GL_ALPHA16 */
+/*      GL_LUMINANCE4 */
+/*      GL_LUMINANCE8 */
+/*      GL_LUMINANCE12 */
+/*      GL_LUMINANCE16 */
+/*      GL_LUMINANCE4_ALPHA4 */
+/*      GL_LUMINANCE6_ALPHA2 */
+/*      GL_LUMINANCE8_ALPHA8 */
+/*      GL_LUMINANCE12_ALPHA4 */
+/*      GL_LUMINANCE12_ALPHA12 */
+/*      GL_LUMINANCE16_ALPHA16 */
+/*      GL_INTENSITY */
+/*      GL_INTENSITY4 */
+/*      GL_INTENSITY8 */
+/*      GL_INTENSITY12 */
+/*      GL_INTENSITY16 */
+/*      GL_R3_G3_B2 */
+/*      GL_RGB4 */
+/*      GL_RGB5 */
+/*      GL_RGB8 */
+/*      GL_RGB10 */
+/*      GL_RGB12 */
+/*      GL_RGB16 */
+/*      GL_RGBA2 */
+/*      GL_RGBA4 */
+/*      GL_RGB5_A1 */
+/*      GL_RGBA8 */
+/*      GL_RGB10_A2 */
+/*      GL_RGBA12 */
+/*      GL_RGBA16 */
+
+/* PixelMap */
+/*      GL_PIXEL_MAP_I_TO_I */
+/*      GL_PIXEL_MAP_S_TO_S */
+/*      GL_PIXEL_MAP_I_TO_R */
+/*      GL_PIXEL_MAP_I_TO_G */
+/*      GL_PIXEL_MAP_I_TO_B */
+/*      GL_PIXEL_MAP_I_TO_A */
+/*      GL_PIXEL_MAP_R_TO_R */
+/*      GL_PIXEL_MAP_G_TO_G */
+/*      GL_PIXEL_MAP_B_TO_B */
+/*      GL_PIXEL_MAP_A_TO_A */
+
+/* PixelStore */
+/*      GL_UNPACK_SWAP_BYTES */
+/*      GL_UNPACK_LSB_FIRST */
+/*      GL_UNPACK_ROW_LENGTH */
+/*      GL_UNPACK_SKIP_ROWS */
+/*      GL_UNPACK_SKIP_PIXELS */
+/*      GL_UNPACK_ALIGNMENT */
+/*      GL_PACK_SWAP_BYTES */
+/*      GL_PACK_LSB_FIRST */
+/*      GL_PACK_ROW_LENGTH */
+/*      GL_PACK_SKIP_ROWS */
+/*      GL_PACK_SKIP_PIXELS */
+/*      GL_PACK_ALIGNMENT */
+/*      GL_PACK_SKIP_IMAGES */
+/*      GL_PACK_IMAGE_HEIGHT */
+/*      GL_UNPACK_SKIP_IMAGES */
+/*      GL_UNPACK_IMAGE_HEIGHT */
+
+/* PixelTransfer */
+/*      GL_MAP_COLOR */
+/*      GL_MAP_STENCIL */
+/*      GL_INDEX_SHIFT */
+/*      GL_INDEX_OFFSET */
+/*      GL_RED_SCALE */
+/*      GL_RED_BIAS */
+/*      GL_GREEN_SCALE */
+/*      GL_GREEN_BIAS */
+/*      GL_BLUE_SCALE */
+/*      GL_BLUE_BIAS */
+/*      GL_ALPHA_SCALE */
+/*      GL_ALPHA_BIAS */
+/*      GL_DEPTH_SCALE */
+/*      GL_DEPTH_BIAS */
+/*      GL_POST_CONVOLUTION_RED_SCALE */
+/*      GL_POST_CONVOLUTION_GREEN_SCALE */
+/*      GL_POST_CONVOLUTION_BLUE_SCALE */
+/*      GL_POST_CONVOLUTION_ALPHA_SCALE */
+/*      GL_POST_CONVOLUTION_RED_BIAS */
+/*      GL_POST_CONVOLUTION_GREEN_BIAS */
+/*      GL_POST_CONVOLUTION_BLUE_BIAS */
+/*      GL_POST_CONVOLUTION_ALPHA_BIAS */
+/*      GL_POST_COLOR_MATRIX_RED_SCALE */
+/*      GL_POST_COLOR_MATRIX_GREEN_SCALE */
+/*      GL_POST_COLOR_MATRIX_BLUE_SCALE */
+/*      GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+/*      GL_POST_COLOR_MATRIX_RED_BIAS */
+/*      GL_POST_COLOR_MATRIX_GREEN_BIAS */
+/*      GL_POST_COLOR_MATRIX_BLUE_BIAS */
+/*      GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+
+/* PixelType */
+#define GL_BITMAP                         0x1A00
+/*      GL_BYTE */
+/*      GL_UNSIGNED_BYTE */
+/*      GL_SHORT */
+/*      GL_UNSIGNED_SHORT */
+/*      GL_INT */
+/*      GL_UNSIGNED_INT */
+/*      GL_FLOAT */
+/*      GL_BGR */
+/*      GL_BGRA */
+/*      GL_UNSIGNED_BYTE_3_3_2 */
+/*      GL_UNSIGNED_SHORT_4_4_4_4 */
+/*      GL_UNSIGNED_SHORT_5_5_5_1 */
+/*      GL_UNSIGNED_INT_8_8_8_8 */
+/*      GL_UNSIGNED_INT_10_10_10_2 */
+/*      GL_UNSIGNED_SHORT_5_6_5 */
+/*      GL_UNSIGNED_BYTE_2_3_3_REV */
+/*      GL_UNSIGNED_SHORT_5_6_5_REV */
+/*      GL_UNSIGNED_SHORT_4_4_4_4_REV */
+/*      GL_UNSIGNED_SHORT_1_5_5_5_REV */
+/*      GL_UNSIGNED_INT_8_8_8_8_REV */
+/*      GL_UNSIGNED_INT_2_10_10_10_REV */
+
+/* PolygonMode */
+#define GL_POINT                          0x1B00
+#define GL_LINE                           0x1B01
+#define GL_FILL                           0x1B02
+
+/* ReadBufferMode */
+/*      GL_FRONT_LEFT */
+/*      GL_FRONT_RIGHT */
+/*      GL_BACK_LEFT */
+/*      GL_BACK_RIGHT */
+/*      GL_FRONT */
+/*      GL_BACK */
+/*      GL_LEFT */
+/*      GL_RIGHT */
+/*      GL_AUX0 */
+/*      GL_AUX1 */
+/*      GL_AUX2 */
+/*      GL_AUX3 */
+
+/* RenderingMode */
+#define GL_RENDER                         0x1C00
+#define GL_FEEDBACK                       0x1C01
+#define GL_SELECT                         0x1C02
+
+/* SeparableTarget */
+/*      GL_SEPARABLE_2D */
+
+/* ShadingModel */
+#define GL_FLAT                           0x1D00
+#define GL_SMOOTH                         0x1D01
+
+/* StencilFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* StencilOp */
+/*      GL_ZERO */
+#define GL_KEEP                           0x1E00
+#define GL_REPLACE                        0x1E01
+#define GL_INCR                           0x1E02
+#define GL_DECR                           0x1E03
+/*      GL_INVERT */
+
+/* StringName */
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+
+/* TextureCoordName */
+#define GL_S                              0x2000
+#define GL_T                              0x2001
+#define GL_R                              0x2002
+#define GL_Q                              0x2003
+
+/* TexCoordPointerType */
+/*      GL_SHORT */
+/*      GL_INT */
+/*      GL_FLOAT */
+/*      GL_DOUBLE */
+
+/* TextureEnvMode */
+#define GL_MODULATE                       0x2100
+#define GL_DECAL                          0x2101
+/*      GL_BLEND */
+/*      GL_REPLACE */
+
+/* TextureEnvParameter */
+#define GL_TEXTURE_ENV_MODE               0x2200
+#define GL_TEXTURE_ENV_COLOR              0x2201
+
+/* TextureEnvTarget */
+#define GL_TEXTURE_ENV                    0x2300
+
+/* TextureGenMode */
+#define GL_EYE_LINEAR                     0x2400
+#define GL_OBJECT_LINEAR                  0x2401
+#define GL_SPHERE_MAP                     0x2402
+
+/* TextureGenParameter */
+#define GL_TEXTURE_GEN_MODE               0x2500
+#define GL_OBJECT_PLANE                   0x2501
+#define GL_EYE_PLANE                      0x2502
+
+/* TextureMagFilter */
+#define GL_NEAREST                        0x2600
+#define GL_LINEAR                         0x2601
+
+/* TextureMinFilter */
+/*      GL_NEAREST */
+/*      GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST         0x2700
+#define GL_LINEAR_MIPMAP_NEAREST          0x2701
+#define GL_NEAREST_MIPMAP_LINEAR          0x2702
+#define GL_LINEAR_MIPMAP_LINEAR           0x2703
+
+/* TextureParameterName */
+#define GL_TEXTURE_MAG_FILTER             0x2800
+#define GL_TEXTURE_MIN_FILTER             0x2801
+#define GL_TEXTURE_WRAP_S                 0x2802
+#define GL_TEXTURE_WRAP_T                 0x2803
+/*      GL_TEXTURE_BORDER_COLOR */
+/*      GL_TEXTURE_PRIORITY */
+/*      GL_TEXTURE_WRAP_R */
+/*      GL_TEXTURE_MIN_LOD */
+/*      GL_TEXTURE_MAX_LOD */
+/*      GL_TEXTURE_BASE_LEVEL */
+/*      GL_TEXTURE_MAX_LEVEL */
+
+/* TextureTarget */
+/*      GL_TEXTURE_1D */
+/*      GL_TEXTURE_2D */
+/*      GL_PROXY_TEXTURE_1D */
+/*      GL_PROXY_TEXTURE_2D */
+/*      GL_TEXTURE_3D */
+/*      GL_PROXY_TEXTURE_3D */
+
+/* TextureUnit */
+/*      GL_TEXTURE0_ARB */
+/*      GL_TEXTURE1_ARB */
+/*      GL_TEXTURE2_ARB */
+/*      GL_TEXTURE3_ARB */
+/*      GL_TEXTURE4_ARB */
+/*      GL_TEXTURE5_ARB */
+/*      GL_TEXTURE6_ARB */
+/*      GL_TEXTURE7_ARB */
+/*      GL_TEXTURE8_ARB */
+/*      GL_TEXTURE9_ARB */
+/*      GL_TEXTURE10_ARB */
+/*      GL_TEXTURE11_ARB */
+/*      GL_TEXTURE12_ARB */
+/*      GL_TEXTURE13_ARB */
+/*      GL_TEXTURE14_ARB */
+/*      GL_TEXTURE15_ARB */
+/*      GL_TEXTURE16_ARB */
+/*      GL_TEXTURE17_ARB */
+/*      GL_TEXTURE18_ARB */
+/*      GL_TEXTURE19_ARB */
+/*      GL_TEXTURE20_ARB */
+/*      GL_TEXTURE21_ARB */
+/*      GL_TEXTURE22_ARB */
+/*      GL_TEXTURE23_ARB */
+/*      GL_TEXTURE24_ARB */
+/*      GL_TEXTURE25_ARB */
+/*      GL_TEXTURE26_ARB */
+/*      GL_TEXTURE27_ARB */
+/*      GL_TEXTURE28_ARB */
+/*      GL_TEXTURE29_ARB */
+/*      GL_TEXTURE30_ARB */
+/*      GL_TEXTURE31_ARB */
+
+/* TextureWrapMode */
+#define GL_CLAMP                          0x2900
+#define GL_REPEAT                         0x2901
+/*      GL_CLAMP_TO_EDGE */
+
+/* VertexPointerType */
+/*      GL_SHORT */
+/*      GL_INT */
+/*      GL_FLOAT */
+/*      GL_DOUBLE */
+
+/* ClientAttribMask */
+#define GL_CLIENT_PIXEL_STORE_BIT         0x00000001
+#define GL_CLIENT_VERTEX_ARRAY_BIT        0x00000002
+#define GL_CLIENT_ALL_ATTRIB_BITS         0xffffffff
+
+/* polygon_offset */
+#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
+
+/* texture */
+#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
+
+/* texture_object */
+#define GL_TEXTURE_PRIORITY               0x8066
+#define GL_TEXTURE_RESIDENT               0x8067
+#define GL_TEXTURE_BINDING_1D             0x8068
+#define GL_TEXTURE_BINDING_2D             0x8069
+#define GL_TEXTURE_BINDING_3D             0x806A
+
+/* vertex_array */
+#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
+
+/* bgra */
+#define GL_BGR                            0x80E0
+#define GL_BGRA                           0x80E1
+
+/* blend_color */
+#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
+
+/* blend_minmax */
+#define GL_FUNC_ADD                       0x8006
+#define GL_MIN                            0x8007
+#define GL_MAX                            0x8008
+#define GL_BLEND_EQUATION                 0x8009
+
+/* blend_subtract */
+#define GL_FUNC_SUBTRACT                  0x800A
+#define GL_FUNC_REVERSE_SUBTRACT          0x800B
+
+/* color_matrix */
+#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
+
+/* color_table */
+#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
+
+/* convolution */
+#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_CONSTANT_BORDER                0x8151
+#define GL_REPLICATE_BORDER               0x8153
+#define GL_CONVOLUTION_BORDER_COLOR       0x8154
+
+/* draw_range_elements */
+#define GL_MAX_ELEMENTS_VERTICES          0x80E8
+#define GL_MAX_ELEMENTS_INDICES           0x80E9
+
+/* histogram */
+#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
+
+/* packed_pixels */
+#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_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
+
+/* rescale_normal */
+#define GL_RESCALE_NORMAL                 0x803A
+
+/* separate_specular_color */
+#define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8
+#define GL_SINGLE_COLOR                   0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR        0x81FA
+
+/* texture3D */
+#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
+
+/* texture_edge_clamp */
+#define GL_CLAMP_TO_EDGE                  0x812F
+
+/* texture_lod */
+#define GL_TEXTURE_MIN_LOD                0x813A
+#define GL_TEXTURE_MAX_LOD                0x813B
+#define GL_TEXTURE_BASE_LEVEL             0x813C
+#define GL_TEXTURE_MAX_LEVEL              0x813D
+
+/* GetTarget1_2 */
+#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_ALIASED_POINT_SIZE_RANGE       0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
+
+/* multitexture */
+#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
+
+/* For compatibility with OpenGL v1.0 */
+#define GL_LOGIC_OP GL_INDEX_LOGIC_OP
+#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT
+
+/*************************************************************/
+
+GLAPI void APIENTRY glAccum (GLenum op, GLfloat value);
+GLAPI void APIENTRY glActiveTextureARB (GLenum texture);
+GLAPI void APIENTRY glAlphaFunc (GLenum func, GLclampf ref);
+GLAPI GLboolean APIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences);
+GLAPI void APIENTRY glArrayElement (GLint i);
+GLAPI void APIENTRY glBegin (GLenum mode);
+GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture);
+GLAPI void APIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
+GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GLAPI void APIENTRY glBlendEquation (GLenum mode);
+GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GLAPI void APIENTRY glCallList (GLuint list);
+GLAPI void APIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists);
+GLAPI void APIENTRY glClear (GLbitfield mask);
+GLAPI void APIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GLAPI void APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GLAPI void APIENTRY glClearDepth (GLclampd depth);
+GLAPI void APIENTRY glClearIndex (GLfloat c);
+GLAPI void APIENTRY glClearStencil (GLint s);
+GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture);
+GLAPI void APIENTRY glClipPlane (GLenum plane, const GLdouble *equation);
+GLAPI void APIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue);
+GLAPI void APIENTRY glColor3bv (const GLbyte *v);
+GLAPI void APIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue);
+GLAPI void APIENTRY glColor3dv (const GLdouble *v);
+GLAPI void APIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue);
+GLAPI void APIENTRY glColor3fv (const GLfloat *v);
+GLAPI void APIENTRY glColor3i (GLint red, GLint green, GLint blue);
+GLAPI void APIENTRY glColor3iv (const GLint *v);
+GLAPI void APIENTRY glColor3s (GLshort red, GLshort green, GLshort blue);
+GLAPI void APIENTRY glColor3sv (const GLshort *v);
+GLAPI void APIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue);
+GLAPI void APIENTRY glColor3ubv (const GLubyte *v);
+GLAPI void APIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue);
+GLAPI void APIENTRY glColor3uiv (const GLuint *v);
+GLAPI void APIENTRY glColor3us (GLushort red, GLushort green, GLushort blue);
+GLAPI void APIENTRY glColor3usv (const GLushort *v);
+GLAPI void APIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
+GLAPI void APIENTRY glColor4bv (const GLbyte *v);
+GLAPI void APIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
+GLAPI void APIENTRY glColor4dv (const GLdouble *v);
+GLAPI void APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GLAPI void APIENTRY glColor4fv (const GLfloat *v);
+GLAPI void APIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha);
+GLAPI void APIENTRY glColor4iv (const GLint *v);
+GLAPI void APIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha);
+GLAPI void APIENTRY glColor4sv (const GLshort *v);
+GLAPI void APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+GLAPI void APIENTRY glColor4ubv (const GLubyte *v);
+GLAPI void APIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha);
+GLAPI void APIENTRY glColor4uiv (const GLuint *v);
+GLAPI void APIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha);
+GLAPI void APIENTRY glColor4usv (const GLushort *v);
+GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GLAPI void APIENTRY glColorMaterial (GLenum face, GLenum mode);
+GLAPI void APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params);
+GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params);
+GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
+GLAPI void APIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glCullFace (GLenum mode);
+GLAPI void APIENTRY glDeleteLists (GLuint list, GLsizei range);
+GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
+GLAPI void APIENTRY glDepthFunc (GLenum func);
+GLAPI void APIENTRY glDepthMask (GLboolean flag);
+GLAPI void APIENTRY glDepthRange (GLclampd zNear, GLclampd zFar);
+GLAPI void APIENTRY glDisable (GLenum cap);
+GLAPI void APIENTRY glDisableClientState (GLenum array);
+GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GLAPI void APIENTRY glDrawBuffer (GLenum mode);
+GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+GLAPI void APIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+GLAPI void APIENTRY glEdgeFlag (GLboolean flag);
+GLAPI void APIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glEdgeFlagv (const GLboolean *flag);
+GLAPI void APIENTRY glEnable (GLenum cap);
+GLAPI void APIENTRY glEnableClientState (GLenum array);
+GLAPI void APIENTRY glEnd (void);
+GLAPI void APIENTRY glEndList (void);
+GLAPI void APIENTRY glEvalCoord1d (GLdouble u);
+GLAPI void APIENTRY glEvalCoord1dv (const GLdouble *u);
+GLAPI void APIENTRY glEvalCoord1f (GLfloat u);
+GLAPI void APIENTRY glEvalCoord1fv (const GLfloat *u);
+GLAPI void APIENTRY glEvalCoord2d (GLdouble u, GLdouble v);
+GLAPI void APIENTRY glEvalCoord2dv (const GLdouble *u);
+GLAPI void APIENTRY glEvalCoord2f (GLfloat u, GLfloat v);
+GLAPI void APIENTRY glEvalCoord2fv (const GLfloat *u);
+GLAPI void APIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2);
+GLAPI void APIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
+GLAPI void APIENTRY glEvalPoint1 (GLint i);
+GLAPI void APIENTRY glEvalPoint2 (GLint i, GLint j);
+GLAPI void APIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer);
+GLAPI void APIENTRY glFinish (void);
+GLAPI void APIENTRY glFlush (void);
+GLAPI void APIENTRY glFogf (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFogfv (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFogi (GLenum pname, GLint param);
+GLAPI void APIENTRY glFogiv (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glFrontFace (GLenum mode);
+GLAPI void APIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+GLAPI GLuint APIENTRY glGenLists (GLsizei range);
+GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures);
+GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params);
+GLAPI void APIENTRY glGetClipPlane (GLenum plane, GLdouble *equation);
+GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table);
+GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image);
+GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *params);
+GLAPI GLenum APIENTRY glGetError (void);
+GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v);
+GLAPI void APIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v);
+GLAPI void APIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v);
+GLAPI void APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetPixelMapfv (GLenum map, GLfloat *values);
+GLAPI void APIENTRY glGetPixelMapuiv (GLenum map, GLuint *values);
+GLAPI void APIENTRY glGetPixelMapusv (GLenum map, GLushort *values);
+GLAPI void APIENTRY glGetPointerv (GLenum pname, GLvoid* *params);
+GLAPI void APIENTRY glGetPolygonStipple (GLubyte *mask);
+GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+GLAPI const GLubyte * APIENTRY glGetString (GLenum name);
+GLAPI void APIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glHint (GLenum target, GLenum mode);
+GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glIndexMask (GLuint mask);
+GLAPI void APIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glIndexd (GLdouble c);
+GLAPI void APIENTRY glIndexdv (const GLdouble *c);
+GLAPI void APIENTRY glIndexf (GLfloat c);
+GLAPI void APIENTRY glIndexfv (const GLfloat *c);
+GLAPI void APIENTRY glIndexi (GLint c);
+GLAPI void APIENTRY glIndexiv (const GLint *c);
+GLAPI void APIENTRY glIndexs (GLshort c);
+GLAPI void APIENTRY glIndexsv (const GLshort *c);
+GLAPI void APIENTRY glIndexub (GLubyte c);
+GLAPI void APIENTRY glIndexubv (const GLubyte *c);
+GLAPI void APIENTRY glInitNames (void);
+GLAPI void APIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer);
+GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap);
+GLAPI GLboolean APIENTRY glIsList (GLuint list);
+GLAPI GLboolean APIENTRY glIsTexture (GLuint texture);
+GLAPI void APIENTRY glLightModelf (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glLightModelfv (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glLightModeli (GLenum pname, GLint param);
+GLAPI void APIENTRY glLightModeliv (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glLighti (GLenum light, GLenum pname, GLint param);
+GLAPI void APIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glLineStipple (GLint factor, GLushort pattern);
+GLAPI void APIENTRY glLineWidth (GLfloat width);
+GLAPI void APIENTRY glListBase (GLuint base);
+GLAPI void APIENTRY glLoadIdentity (void);
+GLAPI void APIENTRY glLoadMatrixd (const GLdouble *m);
+GLAPI void APIENTRY glLoadMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glLoadName (GLuint name);
+GLAPI void APIENTRY glLogicOp (GLenum opcode);
+GLAPI void APIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
+GLAPI void APIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
+GLAPI void APIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
+GLAPI void APIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
+GLAPI void APIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2);
+GLAPI void APIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2);
+GLAPI void APIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
+GLAPI void APIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMateriali (GLenum face, GLenum pname, GLint param);
+GLAPI void APIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMatrixMode (GLenum mode);
+GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glMultMatrixd (const GLdouble *m);
+GLAPI void APIENTRY glMultMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s);
+GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s);
+GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s);
+GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s);
+GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t);
+GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t);
+GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t);
+GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t);
+GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r);
+GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r);
+GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q);
+GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glNewList (GLuint list, GLenum mode);
+GLAPI void APIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz);
+GLAPI void APIENTRY glNormal3bv (const GLbyte *v);
+GLAPI void APIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz);
+GLAPI void APIENTRY glNormal3dv (const GLdouble *v);
+GLAPI void APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);
+GLAPI void APIENTRY glNormal3fv (const GLfloat *v);
+GLAPI void APIENTRY glNormal3i (GLint nx, GLint ny, GLint nz);
+GLAPI void APIENTRY glNormal3iv (const GLint *v);
+GLAPI void APIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz);
+GLAPI void APIENTRY glNormal3sv (const GLshort *v);
+GLAPI void APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+GLAPI void APIENTRY glPassThrough (GLfloat token);
+GLAPI void APIENTRY glPixelMapfv (GLenum map, GLint mapsize, const GLfloat *values);
+GLAPI void APIENTRY glPixelMapuiv (GLenum map, GLint mapsize, const GLuint *values);
+GLAPI void APIENTRY glPixelMapusv (GLenum map, GLint mapsize, const GLushort *values);
+GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param);
+GLAPI void APIENTRY glPixelTransferf (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPixelTransferi (GLenum pname, GLint param);
+GLAPI void APIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor);
+GLAPI void APIENTRY glPointSize (GLfloat size);
+GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode);
+GLAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GLAPI void APIENTRY glPolygonStipple (const GLubyte *mask);
+GLAPI void APIENTRY glPopAttrib (void);
+GLAPI void APIENTRY glPopClientAttrib (void);
+GLAPI void APIENTRY glPopMatrix (void);
+GLAPI void APIENTRY glPopName (void);
+GLAPI void APIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+GLAPI void APIENTRY glPushAttrib (GLbitfield mask);
+GLAPI void APIENTRY glPushClientAttrib (GLbitfield mask);
+GLAPI void APIENTRY glPushMatrix (void);
+GLAPI void APIENTRY glPushName (GLuint name);
+GLAPI void APIENTRY glRasterPos2d (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glRasterPos2dv (const GLdouble *v);
+GLAPI void APIENTRY glRasterPos2f (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glRasterPos2fv (const GLfloat *v);
+GLAPI void APIENTRY glRasterPos2i (GLint x, GLint y);
+GLAPI void APIENTRY glRasterPos2iv (const GLint *v);
+GLAPI void APIENTRY glRasterPos2s (GLshort x, GLshort y);
+GLAPI void APIENTRY glRasterPos2sv (const GLshort *v);
+GLAPI void APIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glRasterPos3dv (const GLdouble *v);
+GLAPI void APIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glRasterPos3fv (const GLfloat *v);
+GLAPI void APIENTRY glRasterPos3i (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glRasterPos3iv (const GLint *v);
+GLAPI void APIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glRasterPos3sv (const GLshort *v);
+GLAPI void APIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glRasterPos4dv (const GLdouble *v);
+GLAPI void APIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glRasterPos4fv (const GLfloat *v);
+GLAPI void APIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glRasterPos4iv (const GLint *v);
+GLAPI void APIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glRasterPos4sv (const GLshort *v);
+GLAPI void APIENTRY glReadBuffer (GLenum mode);
+GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+GLAPI void APIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
+GLAPI void APIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2);
+GLAPI void APIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
+GLAPI void APIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2);
+GLAPI void APIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2);
+GLAPI void APIENTRY glRectiv (const GLint *v1, const GLint *v2);
+GLAPI void APIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2);
+GLAPI void APIENTRY glRectsv (const GLshort *v1, const GLshort *v2);
+GLAPI GLint APIENTRY glRenderMode (GLenum mode);
+GLAPI void APIENTRY glResetHistogram (GLenum target);
+GLAPI void APIENTRY glResetMinmax (GLenum target);
+GLAPI void APIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glSelectBuffer (GLsizei size, GLuint *buffer);
+GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+GLAPI void APIENTRY glShadeModel (GLenum mode);
+GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GLAPI void APIENTRY glStencilMask (GLuint mask);
+GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GLAPI void APIENTRY glTexCoord1d (GLdouble s);
+GLAPI void APIENTRY glTexCoord1dv (const GLdouble *v);
+GLAPI void APIENTRY glTexCoord1f (GLfloat s);
+GLAPI void APIENTRY glTexCoord1fv (const GLfloat *v);
+GLAPI void APIENTRY glTexCoord1i (GLint s);
+GLAPI void APIENTRY glTexCoord1iv (const GLint *v);
+GLAPI void APIENTRY glTexCoord1s (GLshort s);
+GLAPI void APIENTRY glTexCoord1sv (const GLshort *v);
+GLAPI void APIENTRY glTexCoord2d (GLdouble s, GLdouble t);
+GLAPI void APIENTRY glTexCoord2dv (const GLdouble *v);
+GLAPI void APIENTRY glTexCoord2f (GLfloat s, GLfloat t);
+GLAPI void APIENTRY glTexCoord2fv (const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2i (GLint s, GLint t);
+GLAPI void APIENTRY glTexCoord2iv (const GLint *v);
+GLAPI void APIENTRY glTexCoord2s (GLshort s, GLshort t);
+GLAPI void APIENTRY glTexCoord2sv (const GLshort *v);
+GLAPI void APIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r);
+GLAPI void APIENTRY glTexCoord3dv (const GLdouble *v);
+GLAPI void APIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r);
+GLAPI void APIENTRY glTexCoord3fv (const GLfloat *v);
+GLAPI void APIENTRY glTexCoord3i (GLint s, GLint t, GLint r);
+GLAPI void APIENTRY glTexCoord3iv (const GLint *v);
+GLAPI void APIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r);
+GLAPI void APIENTRY glTexCoord3sv (const GLshort *v);
+GLAPI void APIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void APIENTRY glTexCoord4dv (const GLdouble *v);
+GLAPI void APIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void APIENTRY glTexCoord4fv (const GLfloat *v);
+GLAPI void APIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q);
+GLAPI void APIENTRY glTexCoord4iv (const GLint *v);
+GLAPI void APIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void APIENTRY glTexCoord4sv (const GLshort *v);
+GLAPI void APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param);
+GLAPI void APIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params);
+GLAPI void APIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param);
+GLAPI void APIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertex2d (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertex2dv (const GLdouble *v);
+GLAPI void APIENTRY glVertex2f (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertex2fv (const GLfloat *v);
+GLAPI void APIENTRY glVertex2i (GLint x, GLint y);
+GLAPI void APIENTRY glVertex2iv (const GLint *v);
+GLAPI void APIENTRY glVertex2s (GLshort x, GLshort y);
+GLAPI void APIENTRY glVertex2sv (const GLshort *v);
+GLAPI void APIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertex3dv (const GLdouble *v);
+GLAPI void APIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertex3fv (const GLfloat *v);
+GLAPI void APIENTRY glVertex3i (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glVertex3iv (const GLint *v);
+GLAPI void APIENTRY glVertex3s (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertex3sv (const GLshort *v);
+GLAPI void APIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertex4dv (const GLdouble *v);
+GLAPI void APIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertex4fv (const GLfloat *v);
+GLAPI void APIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glVertex4iv (const GLint *v);
+GLAPI void APIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertex4sv (const GLshort *v);
+GLAPI void APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl_h_ */
diff --git a/thirdparty/khronos/GL/glext.h b/thirdparty/khronos/GL/glext.h
new file mode 100644 (file)
index 0000000..f8b102a
--- /dev/null
@@ -0,0 +1,12804 @@
+#ifndef __glext_h_
+#define __glext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2012 The Khronos Group Inc.
+** 
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+** 
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+** 
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Header file version number, required by OpenGL ABI for Linux */
+/* glext.h last updated $Date: 2012-08-06 02:01:01 -0700 (Mon, 06 Aug 2012) $ */
+/* Current version at http://www.opengl.org/registry/ */
+#define GL_GLEXT_VERSION 83
+/* Function declaration macros - to move into glplatform.h */
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+#ifndef GL_VERSION_1_2
+#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_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_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_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_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_ALIASED_LINE_WIDTH_RANGE       0x846E
+#endif
+
+#ifndef GL_VERSION_1_2_DEPRECATED
+#define GL_RESCALE_NORMAL                 0x803A
+#define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8
+#define GL_SINGLE_COLOR                   0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR        0x81FA
+#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
+#endif
+
+#ifndef GL_ARB_imaging
+#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
+#endif
+
+#ifndef GL_ARB_imaging_DEPRECATED
+#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_CONSTANT_BORDER                0x8151
+#define GL_REPLICATE_BORDER               0x8153
+#define GL_CONVOLUTION_BORDER_COLOR       0x8154
+#endif
+
+#ifndef GL_VERSION_1_3
+#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_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_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_COMPRESSED_RGB                 0x84ED
+#define GL_COMPRESSED_RGBA                0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT       0x84EF
+#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_CLAMP_TO_BORDER                0x812D
+#endif
+
+#ifndef GL_VERSION_1_3_DEPRECATED
+#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_MULTISAMPLE_BIT                0x20000000
+#define GL_NORMAL_MAP                     0x8511
+#define GL_REFLECTION_MAP                 0x8512
+#define GL_COMPRESSED_ALPHA               0x84E9
+#define GL_COMPRESSED_LUMINANCE           0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA     0x84EB
+#define GL_COMPRESSED_INTENSITY           0x84EC
+#define GL_COMBINE                        0x8570
+#define GL_COMBINE_RGB                    0x8571
+#define GL_COMBINE_ALPHA                  0x8572
+#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_RGB_SCALE                      0x8573
+#define GL_ADD_SIGNED                     0x8574
+#define GL_INTERPOLATE                    0x8575
+#define GL_SUBTRACT                       0x84E7
+#define GL_CONSTANT                       0x8576
+#define GL_PRIMARY_COLOR                  0x8577
+#define GL_PREVIOUS                       0x8578
+#define GL_DOT3_RGB                       0x86AE
+#define GL_DOT3_RGBA                      0x86AF
+#endif
+
+#ifndef GL_VERSION_1_4
+#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_FADE_THRESHOLD_SIZE      0x8128
+#define GL_DEPTH_COMPONENT16              0x81A5
+#define GL_DEPTH_COMPONENT24              0x81A6
+#define GL_DEPTH_COMPONENT32              0x81A7
+#define GL_MIRRORED_REPEAT                0x8370
+#define GL_MAX_TEXTURE_LOD_BIAS           0x84FD
+#define GL_TEXTURE_LOD_BIAS               0x8501
+#define GL_INCR_WRAP                      0x8507
+#define GL_DECR_WRAP                      0x8508
+#define GL_TEXTURE_DEPTH_SIZE             0x884A
+#define GL_TEXTURE_COMPARE_MODE           0x884C
+#define GL_TEXTURE_COMPARE_FUNC           0x884D
+#endif
+
+#ifndef GL_VERSION_1_4_DEPRECATED
+#define GL_POINT_SIZE_MIN                 0x8126
+#define GL_POINT_SIZE_MAX                 0x8127
+#define GL_POINT_DISTANCE_ATTENUATION     0x8129
+#define GL_GENERATE_MIPMAP                0x8191
+#define GL_GENERATE_MIPMAP_HINT           0x8192
+#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_TEXTURE_FILTER_CONTROL         0x8500
+#define GL_DEPTH_TEXTURE_MODE             0x884B
+#define GL_COMPARE_R_TO_TEXTURE           0x884E
+#endif
+
+#ifndef GL_VERSION_1_5
+#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_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
+#endif
+
+#ifndef GL_VERSION_1_5_DEPRECATED
+#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_FOG_COORD_SRC                  0x8450
+#define GL_FOG_COORD                      0x8451
+#define GL_CURRENT_FOG_COORD              0x8453
+#define GL_FOG_COORD_ARRAY_TYPE           0x8454
+#define GL_FOG_COORD_ARRAY_STRIDE         0x8455
+#define GL_FOG_COORD_ARRAY_POINTER        0x8456
+#define GL_FOG_COORD_ARRAY                0x8457
+#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
+#define GL_SRC0_RGB                       0x8580
+#define GL_SRC1_RGB                       0x8581
+#define GL_SRC2_RGB                       0x8582
+#define GL_SRC0_ALPHA                     0x8588
+#define GL_SRC1_ALPHA                     0x8589
+#define GL_SRC2_ALPHA                     0x858A
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_BLEND_EQUATION_RGB             0x8009
+#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_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_MAX_VERTEX_ATTRIBS             0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#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
+#endif
+
+#ifndef GL_VERSION_2_0_DEPRECATED
+#define GL_VERTEX_PROGRAM_TWO_SIDE        0x8643
+#define GL_POINT_SPRITE                   0x8861
+#define GL_COORD_REPLACE                  0x8862
+#define GL_MAX_TEXTURE_COORDS             0x8871
+#endif
+
+#ifndef GL_VERSION_2_1
+#define GL_PIXEL_PACK_BUFFER              0x88EB
+#define GL_PIXEL_UNPACK_BUFFER            0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING      0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING    0x88EF
+#define GL_FLOAT_MAT2x3                   0x8B65
+#define GL_FLOAT_MAT2x4                   0x8B66
+#define GL_FLOAT_MAT3x2                   0x8B67
+#define GL_FLOAT_MAT3x4                   0x8B68
+#define GL_FLOAT_MAT4x2                   0x8B69
+#define GL_FLOAT_MAT4x3                   0x8B6A
+#define GL_SRGB                           0x8C40
+#define GL_SRGB8                          0x8C41
+#define GL_SRGB_ALPHA                     0x8C42
+#define GL_SRGB8_ALPHA8                   0x8C43
+#define GL_COMPRESSED_SRGB                0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA          0x8C49
+#endif
+
+#ifndef GL_VERSION_2_1_DEPRECATED
+#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
+#define GL_SLUMINANCE_ALPHA               0x8C44
+#define GL_SLUMINANCE8_ALPHA8             0x8C45
+#define GL_SLUMINANCE                     0x8C46
+#define GL_SLUMINANCE8                    0x8C47
+#define GL_COMPRESSED_SLUMINANCE          0x8C4A
+#define GL_COMPRESSED_SLUMINANCE_ALPHA    0x8C4B
+#endif
+
+#ifndef GL_VERSION_3_0
+#define GL_COMPARE_REF_TO_TEXTURE         0x884E
+#define GL_CLIP_DISTANCE0                 0x3000
+#define GL_CLIP_DISTANCE1                 0x3001
+#define GL_CLIP_DISTANCE2                 0x3002
+#define GL_CLIP_DISTANCE3                 0x3003
+#define GL_CLIP_DISTANCE4                 0x3004
+#define GL_CLIP_DISTANCE5                 0x3005
+#define GL_CLIP_DISTANCE6                 0x3006
+#define GL_CLIP_DISTANCE7                 0x3007
+#define GL_MAX_CLIP_DISTANCES             0x0D32
+#define GL_MAJOR_VERSION                  0x821B
+#define GL_MINOR_VERSION                  0x821C
+#define GL_NUM_EXTENSIONS                 0x821D
+#define GL_CONTEXT_FLAGS                  0x821E
+#define GL_COMPRESSED_RED                 0x8225
+#define GL_COMPRESSED_RG                  0x8226
+#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001
+#define GL_RGBA32F                        0x8814
+#define GL_RGB32F                         0x8815
+#define GL_RGBA16F                        0x881A
+#define GL_RGB16F                         0x881B
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER    0x88FD
+#define GL_MAX_ARRAY_TEXTURE_LAYERS       0x88FF
+#define GL_MIN_PROGRAM_TEXEL_OFFSET       0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET       0x8905
+#define GL_CLAMP_READ_COLOR               0x891C
+#define GL_FIXED_ONLY                     0x891D
+#define GL_MAX_VARYING_COMPONENTS         0x8B4B
+#define GL_TEXTURE_1D_ARRAY               0x8C18
+#define GL_PROXY_TEXTURE_1D_ARRAY         0x8C19
+#define GL_TEXTURE_2D_ARRAY               0x8C1A
+#define GL_PROXY_TEXTURE_2D_ARRAY         0x8C1B
+#define GL_TEXTURE_BINDING_1D_ARRAY       0x8C1C
+#define GL_TEXTURE_BINDING_2D_ARRAY       0x8C1D
+#define GL_R11F_G11F_B10F                 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV   0x8C3B
+#define GL_RGB9_E5                        0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV       0x8C3E
+#define GL_TEXTURE_SHARED_SIZE            0x8C3F
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS    0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
+#define GL_PRIMITIVES_GENERATED           0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
+#define GL_RASTERIZER_DISCARD             0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS            0x8C8C
+#define GL_SEPARATE_ATTRIBS               0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER      0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
+#define GL_RGBA32UI                       0x8D70
+#define GL_RGB32UI                        0x8D71
+#define GL_RGBA16UI                       0x8D76
+#define GL_RGB16UI                        0x8D77
+#define GL_RGBA8UI                        0x8D7C
+#define GL_RGB8UI                         0x8D7D
+#define GL_RGBA32I                        0x8D82
+#define GL_RGB32I                         0x8D83
+#define GL_RGBA16I                        0x8D88
+#define GL_RGB16I                         0x8D89
+#define GL_RGBA8I                         0x8D8E
+#define GL_RGB8I                          0x8D8F
+#define GL_RED_INTEGER                    0x8D94
+#define GL_GREEN_INTEGER                  0x8D95
+#define GL_BLUE_INTEGER                   0x8D96
+#define GL_RGB_INTEGER                    0x8D98
+#define GL_RGBA_INTEGER                   0x8D99
+#define GL_BGR_INTEGER                    0x8D9A
+#define GL_BGRA_INTEGER                   0x8D9B
+#define GL_SAMPLER_1D_ARRAY               0x8DC0
+#define GL_SAMPLER_2D_ARRAY               0x8DC1
+#define GL_SAMPLER_1D_ARRAY_SHADOW        0x8DC3
+#define GL_SAMPLER_2D_ARRAY_SHADOW        0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW            0x8DC5
+#define GL_UNSIGNED_INT_VEC2              0x8DC6
+#define GL_UNSIGNED_INT_VEC3              0x8DC7
+#define GL_UNSIGNED_INT_VEC4              0x8DC8
+#define GL_INT_SAMPLER_1D                 0x8DC9
+#define GL_INT_SAMPLER_2D                 0x8DCA
+#define GL_INT_SAMPLER_3D                 0x8DCB
+#define GL_INT_SAMPLER_CUBE               0x8DCC
+#define GL_INT_SAMPLER_1D_ARRAY           0x8DCE
+#define GL_INT_SAMPLER_2D_ARRAY           0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_1D        0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_2D        0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D        0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE      0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY  0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY  0x8DD7
+#define GL_QUERY_WAIT                     0x8E13
+#define GL_QUERY_NO_WAIT                  0x8E14
+#define GL_QUERY_BY_REGION_WAIT           0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT        0x8E16
+#define GL_BUFFER_ACCESS_FLAGS            0x911F
+#define GL_BUFFER_MAP_LENGTH              0x9120
+#define GL_BUFFER_MAP_OFFSET              0x9121
+/* Reuse tokens from ARB_depth_buffer_float */
+/* reuse GL_DEPTH_COMPONENT32F */
+/* reuse GL_DEPTH32F_STENCIL8 */
+/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */
+/* Reuse tokens from ARB_framebuffer_object */
+/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
+/* reuse GL_FRAMEBUFFER_DEFAULT */
+/* reuse GL_FRAMEBUFFER_UNDEFINED */
+/* reuse GL_DEPTH_STENCIL_ATTACHMENT */
+/* reuse GL_INDEX */
+/* reuse GL_MAX_RENDERBUFFER_SIZE */
+/* reuse GL_DEPTH_STENCIL */
+/* reuse GL_UNSIGNED_INT_24_8 */
+/* reuse GL_DEPTH24_STENCIL8 */
+/* reuse GL_TEXTURE_STENCIL_SIZE */
+/* reuse GL_TEXTURE_RED_TYPE */
+/* reuse GL_TEXTURE_GREEN_TYPE */
+/* reuse GL_TEXTURE_BLUE_TYPE */
+/* reuse GL_TEXTURE_ALPHA_TYPE */
+/* reuse GL_TEXTURE_DEPTH_TYPE */
+/* reuse GL_UNSIGNED_NORMALIZED */
+/* reuse GL_FRAMEBUFFER_BINDING */
+/* reuse GL_DRAW_FRAMEBUFFER_BINDING */
+/* reuse GL_RENDERBUFFER_BINDING */
+/* reuse GL_READ_FRAMEBUFFER */
+/* reuse GL_DRAW_FRAMEBUFFER */
+/* reuse GL_READ_FRAMEBUFFER_BINDING */
+/* reuse GL_RENDERBUFFER_SAMPLES */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+/* reuse GL_FRAMEBUFFER_COMPLETE */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */
+/* reuse GL_FRAMEBUFFER_UNSUPPORTED */
+/* reuse GL_MAX_COLOR_ATTACHMENTS */
+/* reuse GL_COLOR_ATTACHMENT0 */
+/* reuse GL_COLOR_ATTACHMENT1 */
+/* reuse GL_COLOR_ATTACHMENT2 */
+/* reuse GL_COLOR_ATTACHMENT3 */
+/* reuse GL_COLOR_ATTACHMENT4 */
+/* reuse GL_COLOR_ATTACHMENT5 */
+/* reuse GL_COLOR_ATTACHMENT6 */
+/* reuse GL_COLOR_ATTACHMENT7 */
+/* reuse GL_COLOR_ATTACHMENT8 */
+/* reuse GL_COLOR_ATTACHMENT9 */
+/* reuse GL_COLOR_ATTACHMENT10 */
+/* reuse GL_COLOR_ATTACHMENT11 */
+/* reuse GL_COLOR_ATTACHMENT12 */
+/* reuse GL_COLOR_ATTACHMENT13 */
+/* reuse GL_COLOR_ATTACHMENT14 */
+/* reuse GL_COLOR_ATTACHMENT15 */
+/* reuse GL_DEPTH_ATTACHMENT */
+/* reuse GL_STENCIL_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER */
+/* reuse GL_RENDERBUFFER */
+/* reuse GL_RENDERBUFFER_WIDTH */
+/* reuse GL_RENDERBUFFER_HEIGHT */
+/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */
+/* reuse GL_STENCIL_INDEX1 */
+/* reuse GL_STENCIL_INDEX4 */
+/* reuse GL_STENCIL_INDEX8 */
+/* reuse GL_STENCIL_INDEX16 */
+/* reuse GL_RENDERBUFFER_RED_SIZE */
+/* reuse GL_RENDERBUFFER_GREEN_SIZE */
+/* reuse GL_RENDERBUFFER_BLUE_SIZE */
+/* reuse GL_RENDERBUFFER_ALPHA_SIZE */
+/* reuse GL_RENDERBUFFER_DEPTH_SIZE */
+/* reuse GL_RENDERBUFFER_STENCIL_SIZE */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
+/* reuse GL_MAX_SAMPLES */
+/* Reuse tokens from ARB_framebuffer_sRGB */
+/* reuse GL_FRAMEBUFFER_SRGB */
+/* Reuse tokens from ARB_half_float_vertex */
+/* reuse GL_HALF_FLOAT */
+/* Reuse tokens from ARB_map_buffer_range */
+/* reuse GL_MAP_READ_BIT */
+/* reuse GL_MAP_WRITE_BIT */
+/* reuse GL_MAP_INVALIDATE_RANGE_BIT */
+/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */
+/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */
+/* reuse GL_MAP_UNSYNCHRONIZED_BIT */
+/* Reuse tokens from ARB_texture_compression_rgtc */
+/* reuse GL_COMPRESSED_RED_RGTC1 */
+/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */
+/* reuse GL_COMPRESSED_RG_RGTC2 */
+/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */
+/* Reuse tokens from ARB_texture_rg */
+/* reuse GL_RG */
+/* reuse GL_RG_INTEGER */
+/* reuse GL_R8 */
+/* reuse GL_R16 */
+/* reuse GL_RG8 */
+/* reuse GL_RG16 */
+/* reuse GL_R16F */
+/* reuse GL_R32F */
+/* reuse GL_RG16F */
+/* reuse GL_RG32F */
+/* reuse GL_R8I */
+/* reuse GL_R8UI */
+/* reuse GL_R16I */
+/* reuse GL_R16UI */
+/* reuse GL_R32I */
+/* reuse GL_R32UI */
+/* reuse GL_RG8I */
+/* reuse GL_RG8UI */
+/* reuse GL_RG16I */
+/* reuse GL_RG16UI */
+/* reuse GL_RG32I */
+/* reuse GL_RG32UI */
+/* Reuse tokens from ARB_vertex_array_object */
+/* reuse GL_VERTEX_ARRAY_BINDING */
+#endif
+
+#ifndef GL_VERSION_3_0_DEPRECATED
+#define GL_CLAMP_VERTEX_COLOR             0x891A
+#define GL_CLAMP_FRAGMENT_COLOR           0x891B
+#define GL_ALPHA_INTEGER                  0x8D97
+/* Reuse tokens from ARB_framebuffer_object */
+/* reuse GL_TEXTURE_LUMINANCE_TYPE */
+/* reuse GL_TEXTURE_INTENSITY_TYPE */
+#endif
+
+#ifndef GL_VERSION_3_1
+#define GL_SAMPLER_2D_RECT                0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW         0x8B64
+#define GL_SAMPLER_BUFFER                 0x8DC2
+#define GL_INT_SAMPLER_2D_RECT            0x8DCD
+#define GL_INT_SAMPLER_BUFFER             0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT   0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER    0x8DD8
+#define GL_TEXTURE_BUFFER                 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE        0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER         0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT          0x8C2E
+#define GL_TEXTURE_RECTANGLE              0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE      0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE        0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE     0x84F8
+#define GL_RED_SNORM                      0x8F90
+#define GL_RG_SNORM                       0x8F91
+#define GL_RGB_SNORM                      0x8F92
+#define GL_RGBA_SNORM                     0x8F93
+#define GL_R8_SNORM                       0x8F94
+#define GL_RG8_SNORM                      0x8F95
+#define GL_RGB8_SNORM                     0x8F96
+#define GL_RGBA8_SNORM                    0x8F97
+#define GL_R16_SNORM                      0x8F98
+#define GL_RG16_SNORM                     0x8F99
+#define GL_RGB16_SNORM                    0x8F9A
+#define GL_RGBA16_SNORM                   0x8F9B
+#define GL_SIGNED_NORMALIZED              0x8F9C
+#define GL_PRIMITIVE_RESTART              0x8F9D
+#define GL_PRIMITIVE_RESTART_INDEX        0x8F9E
+/* Reuse tokens from ARB_copy_buffer */
+/* reuse GL_COPY_READ_BUFFER */
+/* reuse GL_COPY_WRITE_BUFFER */
+/* Reuse tokens from ARB_draw_instanced (none) */
+/* Reuse tokens from ARB_uniform_buffer_object */
+/* reuse GL_UNIFORM_BUFFER */
+/* reuse GL_UNIFORM_BUFFER_BINDING */
+/* reuse GL_UNIFORM_BUFFER_START */
+/* reuse GL_UNIFORM_BUFFER_SIZE */
+/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */
+/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */
+/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */
+/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */
+/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */
+/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */
+/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */
+/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */
+/* reuse GL_ACTIVE_UNIFORM_BLOCKS */
+/* reuse GL_UNIFORM_TYPE */
+/* reuse GL_UNIFORM_SIZE */
+/* reuse GL_UNIFORM_NAME_LENGTH */
+/* reuse GL_UNIFORM_BLOCK_INDEX */
+/* reuse GL_UNIFORM_OFFSET */
+/* reuse GL_UNIFORM_ARRAY_STRIDE */
+/* reuse GL_UNIFORM_MATRIX_STRIDE */
+/* reuse GL_UNIFORM_IS_ROW_MAJOR */
+/* reuse GL_UNIFORM_BLOCK_BINDING */
+/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */
+/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */
+/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */
+/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */
+/* reuse GL_INVALID_INDEX */
+#endif
+
+#ifndef GL_VERSION_3_2
+#define GL_CONTEXT_CORE_PROFILE_BIT       0x00000001
+#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
+#define GL_LINES_ADJACENCY                0x000A
+#define GL_LINE_STRIP_ADJACENCY           0x000B
+#define GL_TRIANGLES_ADJACENCY            0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY       0x000D
+#define GL_PROGRAM_POINT_SIZE             0x8642
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
+#define GL_GEOMETRY_SHADER                0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT          0x8916
+#define GL_GEOMETRY_INPUT_TYPE            0x8917
+#define GL_GEOMETRY_OUTPUT_TYPE           0x8918
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES   0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS   0x9122
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS  0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS  0x9125
+#define GL_CONTEXT_PROFILE_MASK           0x9126
+/* reuse GL_MAX_VARYING_COMPONENTS */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+/* Reuse tokens from ARB_depth_clamp */
+/* reuse GL_DEPTH_CLAMP */
+/* Reuse tokens from ARB_draw_elements_base_vertex (none) */
+/* Reuse tokens from ARB_fragment_coord_conventions (none) */
+/* Reuse tokens from ARB_provoking_vertex */
+/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
+/* reuse GL_FIRST_VERTEX_CONVENTION */
+/* reuse GL_LAST_VERTEX_CONVENTION */
+/* reuse GL_PROVOKING_VERTEX */
+/* Reuse tokens from ARB_seamless_cube_map */
+/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
+/* Reuse tokens from ARB_sync */
+/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */
+/* reuse GL_OBJECT_TYPE */
+/* reuse GL_SYNC_CONDITION */
+/* reuse GL_SYNC_STATUS */
+/* reuse GL_SYNC_FLAGS */
+/* reuse GL_SYNC_FENCE */
+/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */
+/* reuse GL_UNSIGNALED */
+/* reuse GL_SIGNALED */
+/* reuse GL_ALREADY_SIGNALED */
+/* reuse GL_TIMEOUT_EXPIRED */
+/* reuse GL_CONDITION_SATISFIED */
+/* reuse GL_WAIT_FAILED */
+/* reuse GL_TIMEOUT_IGNORED */
+/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */
+/* reuse GL_TIMEOUT_IGNORED */
+/* Reuse tokens from ARB_texture_multisample */
+/* reuse GL_SAMPLE_POSITION */
+/* reuse GL_SAMPLE_MASK */
+/* reuse GL_SAMPLE_MASK_VALUE */
+/* reuse GL_MAX_SAMPLE_MASK_WORDS */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE */
+/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */
+/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_TEXTURE_SAMPLES */
+/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */
+/* reuse GL_SAMPLER_2D_MULTISAMPLE */
+/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */
+/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */
+/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */
+/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */
+/* reuse GL_MAX_INTEGER_SAMPLES */
+/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */
+#endif
+
+#ifndef GL_VERSION_3_3
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR    0x88FE
+/* Reuse tokens from ARB_blend_func_extended */
+/* reuse GL_SRC1_COLOR */
+/* reuse GL_ONE_MINUS_SRC1_COLOR */
+/* reuse GL_ONE_MINUS_SRC1_ALPHA */
+/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */
+/* Reuse tokens from ARB_explicit_attrib_location (none) */
+/* Reuse tokens from ARB_occlusion_query2 */
+/* reuse GL_ANY_SAMPLES_PASSED */
+/* Reuse tokens from ARB_sampler_objects */
+/* reuse GL_SAMPLER_BINDING */
+/* Reuse tokens from ARB_shader_bit_encoding (none) */
+/* Reuse tokens from ARB_texture_rgb10_a2ui */
+/* reuse GL_RGB10_A2UI */
+/* Reuse tokens from ARB_texture_swizzle */
+/* reuse GL_TEXTURE_SWIZZLE_R */
+/* reuse GL_TEXTURE_SWIZZLE_G */
+/* reuse GL_TEXTURE_SWIZZLE_B */
+/* reuse GL_TEXTURE_SWIZZLE_A */
+/* reuse GL_TEXTURE_SWIZZLE_RGBA */
+/* Reuse tokens from ARB_timer_query */
+/* reuse GL_TIME_ELAPSED */
+/* reuse GL_TIMESTAMP */
+/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */
+/* reuse GL_INT_2_10_10_10_REV */
+#endif
+
+#ifndef GL_VERSION_4_0
+#define GL_SAMPLE_SHADING                 0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE       0x8C37
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
+#define GL_TEXTURE_CUBE_MAP_ARRAY         0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY   0x900B
+#define GL_SAMPLER_CUBE_MAP_ARRAY         0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW  0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY     0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
+/* Reuse tokens from ARB_texture_query_lod (none) */
+/* Reuse tokens from ARB_draw_buffers_blend (none) */
+/* Reuse tokens from ARB_draw_indirect */
+/* reuse GL_DRAW_INDIRECT_BUFFER */
+/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */
+/* Reuse tokens from ARB_gpu_shader5 */
+/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */
+/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */
+/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */
+/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */
+/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */
+/* reuse GL_MAX_VERTEX_STREAMS */
+/* Reuse tokens from ARB_gpu_shader_fp64 */
+/* reuse GL_DOUBLE_VEC2 */
+/* reuse GL_DOUBLE_VEC3 */
+/* reuse GL_DOUBLE_VEC4 */
+/* reuse GL_DOUBLE_MAT2 */
+/* reuse GL_DOUBLE_MAT3 */
+/* reuse GL_DOUBLE_MAT4 */
+/* reuse GL_DOUBLE_MAT2x3 */
+/* reuse GL_DOUBLE_MAT2x4 */
+/* reuse GL_DOUBLE_MAT3x2 */
+/* reuse GL_DOUBLE_MAT3x4 */
+/* reuse GL_DOUBLE_MAT4x2 */
+/* reuse GL_DOUBLE_MAT4x3 */
+/* Reuse tokens from ARB_shader_subroutine */
+/* reuse GL_ACTIVE_SUBROUTINES */
+/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */
+/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */
+/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */
+/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */
+/* reuse GL_MAX_SUBROUTINES */
+/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */
+/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */
+/* reuse GL_COMPATIBLE_SUBROUTINES */
+/* Reuse tokens from ARB_tessellation_shader */
+/* reuse GL_PATCHES */
+/* reuse GL_PATCH_VERTICES */
+/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */
+/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */
+/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */
+/* reuse GL_TESS_GEN_MODE */
+/* reuse GL_TESS_GEN_SPACING */
+/* reuse GL_TESS_GEN_VERTEX_ORDER */
+/* reuse GL_TESS_GEN_POINT_MODE */
+/* reuse GL_ISOLINES */
+/* reuse GL_FRACTIONAL_ODD */
+/* reuse GL_FRACTIONAL_EVEN */
+/* reuse GL_MAX_PATCH_VERTICES */
+/* reuse GL_MAX_TESS_GEN_LEVEL */
+/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */
+/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */
+/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_PATCH_COMPONENTS */
+/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */
+/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */
+/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */
+/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */
+/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */
+/* reuse GL_TESS_EVALUATION_SHADER */
+/* reuse GL_TESS_CONTROL_SHADER */
+/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */
+/* Reuse tokens from ARB_transform_feedback2 */
+/* reuse GL_TRANSFORM_FEEDBACK */
+/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */
+/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */
+/* reuse GL_TRANSFORM_FEEDBACK_BINDING */
+/* Reuse tokens from ARB_transform_feedback3 */
+/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */
+/* reuse GL_MAX_VERTEX_STREAMS */
+#endif
+
+#ifndef GL_VERSION_4_1
+/* Reuse tokens from ARB_ES2_compatibility */
+/* reuse GL_FIXED */
+/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */
+/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */
+/* reuse GL_LOW_FLOAT */
+/* reuse GL_MEDIUM_FLOAT */
+/* reuse GL_HIGH_FLOAT */
+/* reuse GL_LOW_INT */
+/* reuse GL_MEDIUM_INT */
+/* reuse GL_HIGH_INT */
+/* reuse GL_SHADER_COMPILER */
+/* reuse GL_NUM_SHADER_BINARY_FORMATS */
+/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */
+/* reuse GL_MAX_VARYING_VECTORS */
+/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */
+/* reuse GL_RGB565 */
+/* Reuse tokens from ARB_get_program_binary */
+/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */
+/* reuse GL_PROGRAM_BINARY_LENGTH */
+/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */
+/* reuse GL_PROGRAM_BINARY_FORMATS */
+/* Reuse tokens from ARB_separate_shader_objects */
+/* reuse GL_VERTEX_SHADER_BIT */
+/* reuse GL_FRAGMENT_SHADER_BIT */
+/* reuse GL_GEOMETRY_SHADER_BIT */
+/* reuse GL_TESS_CONTROL_SHADER_BIT */
+/* reuse GL_TESS_EVALUATION_SHADER_BIT */
+/* reuse GL_ALL_SHADER_BITS */
+/* reuse GL_PROGRAM_SEPARABLE */
+/* reuse GL_ACTIVE_PROGRAM */
+/* reuse GL_PROGRAM_PIPELINE_BINDING */
+/* Reuse tokens from ARB_shader_precision (none) */
+/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */
+/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */
+/* reuse GL_MAX_VIEWPORTS */
+/* reuse GL_VIEWPORT_SUBPIXEL_BITS */
+/* reuse GL_VIEWPORT_BOUNDS_RANGE */
+/* reuse GL_LAYER_PROVOKING_VERTEX */
+/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */
+/* reuse GL_UNDEFINED_VERTEX */
+#endif
+
+#ifndef GL_VERSION_4_2
+/* Reuse tokens from ARB_base_instance (none) */
+/* Reuse tokens from ARB_shading_language_420pack (none) */
+/* Reuse tokens from ARB_transform_feedback_instanced (none) */
+/* Reuse tokens from ARB_compressed_texture_pixel_storage */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */
+/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */
+/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */
+/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */
+/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */
+/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */
+/* Reuse tokens from ARB_conservative_depth (none) */
+/* Reuse tokens from ARB_internalformat_query */
+/* reuse GL_NUM_SAMPLE_COUNTS */
+/* Reuse tokens from ARB_map_buffer_alignment */
+/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */
+/* Reuse tokens from ARB_shader_atomic_counters */
+/* reuse GL_ATOMIC_COUNTER_BUFFER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_START */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */
+/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */
+/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */
+/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */
+/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */
+/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */
+/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */
+/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */
+/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */
+/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */
+/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */
+/* Reuse tokens from ARB_shader_image_load_store */
+/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */
+/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */
+/* reuse GL_UNIFORM_BARRIER_BIT */
+/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */
+/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */
+/* reuse GL_COMMAND_BARRIER_BIT */
+/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */
+/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */
+/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */
+/* reuse GL_FRAMEBUFFER_BARRIER_BIT */
+/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */
+/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */
+/* reuse GL_ALL_BARRIER_BITS */
+/* reuse GL_MAX_IMAGE_UNITS */
+/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */
+/* reuse GL_IMAGE_BINDING_NAME */
+/* reuse GL_IMAGE_BINDING_LEVEL */
+/* reuse GL_IMAGE_BINDING_LAYERED */
+/* reuse GL_IMAGE_BINDING_LAYER */
+/* reuse GL_IMAGE_BINDING_ACCESS */
+/* reuse GL_IMAGE_1D */
+/* reuse GL_IMAGE_2D */
+/* reuse GL_IMAGE_3D */
+/* reuse GL_IMAGE_2D_RECT */
+/* reuse GL_IMAGE_CUBE */
+/* reuse GL_IMAGE_BUFFER */
+/* reuse GL_IMAGE_1D_ARRAY */
+/* reuse GL_IMAGE_2D_ARRAY */
+/* reuse GL_IMAGE_CUBE_MAP_ARRAY */
+/* reuse GL_IMAGE_2D_MULTISAMPLE */
+/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_INT_IMAGE_1D */
+/* reuse GL_INT_IMAGE_2D */
+/* reuse GL_INT_IMAGE_3D */
+/* reuse GL_INT_IMAGE_2D_RECT */
+/* reuse GL_INT_IMAGE_CUBE */
+/* reuse GL_INT_IMAGE_BUFFER */
+/* reuse GL_INT_IMAGE_1D_ARRAY */
+/* reuse GL_INT_IMAGE_2D_ARRAY */
+/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */
+/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */
+/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_1D */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D */
+/* reuse GL_UNSIGNED_INT_IMAGE_3D */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */
+/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */
+/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */
+/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */
+/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_MAX_IMAGE_SAMPLES */
+/* reuse GL_IMAGE_BINDING_FORMAT */
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */
+/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */
+/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */
+/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */
+/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */
+/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */
+/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */
+/* Reuse tokens from ARB_shading_language_packing (none) */
+/* Reuse tokens from ARB_texture_storage */
+/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */
+#endif
+
+#ifndef GL_VERSION_4_3
+#define GL_NUM_SHADING_LANGUAGE_VERSIONS  0x82E9
+#define GL_VERTEX_ATTRIB_ARRAY_LONG       0x874E
+/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */
+/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */
+/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */
+/* Reuse tokens from ARB_ES3_compatibility */
+/* reuse GL_COMPRESSED_RGB8_ETC2 */
+/* reuse GL_COMPRESSED_SRGB8_ETC2 */
+/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */
+/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */
+/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */
+/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */
+/* reuse GL_COMPRESSED_R11_EAC */
+/* reuse GL_COMPRESSED_SIGNED_R11_EAC */
+/* reuse GL_COMPRESSED_RG11_EAC */
+/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */
+/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */
+/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */
+/* reuse GL_MAX_ELEMENT_INDEX */
+/* Reuse tokens from ARB_clear_buffer_object (none) */
+/* Reuse tokens from ARB_compute_shader */
+/* reuse GL_COMPUTE_SHADER */
+/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */
+/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */
+/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */
+/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */
+/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */
+/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */
+/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */
+/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */
+/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */
+/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */
+/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */
+/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */
+/* reuse GL_DISPATCH_INDIRECT_BUFFER */
+/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */
+/* Reuse tokens from ARB_copy_image (none) */
+/* Reuse tokens from KHR_debug */
+/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */
+/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */
+/* reuse GL_DEBUG_CALLBACK_FUNCTION */
+/* reuse GL_DEBUG_CALLBACK_USER_PARAM */
+/* reuse GL_DEBUG_SOURCE_API */
+/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */
+/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */
+/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */
+/* reuse GL_DEBUG_SOURCE_APPLICATION */
+/* reuse GL_DEBUG_SOURCE_OTHER */
+/* reuse GL_DEBUG_TYPE_ERROR */
+/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */
+/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */
+/* reuse GL_DEBUG_TYPE_PORTABILITY */
+/* reuse GL_DEBUG_TYPE_PERFORMANCE */
+/* reuse GL_DEBUG_TYPE_OTHER */
+/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */
+/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */
+/* reuse GL_DEBUG_LOGGED_MESSAGES */
+/* reuse GL_DEBUG_SEVERITY_HIGH */
+/* reuse GL_DEBUG_SEVERITY_MEDIUM */
+/* reuse GL_DEBUG_SEVERITY_LOW */
+/* reuse GL_DEBUG_TYPE_MARKER */
+/* reuse GL_DEBUG_TYPE_PUSH_GROUP */
+/* reuse GL_DEBUG_TYPE_POP_GROUP */
+/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */
+/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */
+/* reuse GL_DEBUG_GROUP_STACK_DEPTH */
+/* reuse GL_BUFFER */
+/* reuse GL_SHADER */
+/* reuse GL_PROGRAM */
+/* reuse GL_QUERY */
+/* reuse GL_PROGRAM_PIPELINE */
+/* reuse GL_SAMPLER */
+/* reuse GL_DISPLAY_LIST */
+/* reuse GL_MAX_LABEL_LENGTH */
+/* reuse GL_DEBUG_OUTPUT */
+/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */
+/* reuse GL_STACK_UNDERFLOW */
+/* reuse GL_STACK_OVERFLOW */
+/* Reuse tokens from ARB_explicit_uniform_location */
+/* reuse GL_MAX_UNIFORM_LOCATIONS */
+/* Reuse tokens from ARB_framebuffer_no_attachments */
+/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */
+/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */
+/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */
+/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */
+/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */
+/* reuse GL_MAX_FRAMEBUFFER_WIDTH */
+/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */
+/* reuse GL_MAX_FRAMEBUFFER_LAYERS */
+/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */
+/* Reuse tokens from ARB_internalformat_query2 */
+/* reuse GL_INTERNALFORMAT_SUPPORTED */
+/* reuse GL_INTERNALFORMAT_PREFERRED */
+/* reuse GL_INTERNALFORMAT_RED_SIZE */
+/* reuse GL_INTERNALFORMAT_GREEN_SIZE */
+/* reuse GL_INTERNALFORMAT_BLUE_SIZE */
+/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */
+/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */
+/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */
+/* reuse GL_INTERNALFORMAT_SHARED_SIZE */
+/* reuse GL_INTERNALFORMAT_RED_TYPE */
+/* reuse GL_INTERNALFORMAT_GREEN_TYPE */
+/* reuse GL_INTERNALFORMAT_BLUE_TYPE */
+/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */
+/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */
+/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */
+/* reuse GL_MAX_WIDTH */
+/* reuse GL_MAX_HEIGHT */
+/* reuse GL_MAX_DEPTH */
+/* reuse GL_MAX_LAYERS */
+/* reuse GL_MAX_COMBINED_DIMENSIONS */
+/* reuse GL_COLOR_COMPONENTS */
+/* reuse GL_DEPTH_COMPONENTS */
+/* reuse GL_STENCIL_COMPONENTS */
+/* reuse GL_COLOR_RENDERABLE */
+/* reuse GL_DEPTH_RENDERABLE */
+/* reuse GL_STENCIL_RENDERABLE */
+/* reuse GL_FRAMEBUFFER_RENDERABLE */
+/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */
+/* reuse GL_FRAMEBUFFER_BLEND */
+/* reuse GL_READ_PIXELS */
+/* reuse GL_READ_PIXELS_FORMAT */
+/* reuse GL_READ_PIXELS_TYPE */
+/* reuse GL_TEXTURE_IMAGE_FORMAT */
+/* reuse GL_TEXTURE_IMAGE_TYPE */
+/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */
+/* reuse GL_GET_TEXTURE_IMAGE_TYPE */
+/* reuse GL_MIPMAP */
+/* reuse GL_MANUAL_GENERATE_MIPMAP */
+/* reuse GL_AUTO_GENERATE_MIPMAP */
+/* reuse GL_COLOR_ENCODING */
+/* reuse GL_SRGB_READ */
+/* reuse GL_SRGB_WRITE */
+/* reuse GL_FILTER */
+/* reuse GL_VERTEX_TEXTURE */
+/* reuse GL_TESS_CONTROL_TEXTURE */
+/* reuse GL_TESS_EVALUATION_TEXTURE */
+/* reuse GL_GEOMETRY_TEXTURE */
+/* reuse GL_FRAGMENT_TEXTURE */
+/* reuse GL_COMPUTE_TEXTURE */
+/* reuse GL_TEXTURE_SHADOW */
+/* reuse GL_TEXTURE_GATHER */
+/* reuse GL_TEXTURE_GATHER_SHADOW */
+/* reuse GL_SHADER_IMAGE_LOAD */
+/* reuse GL_SHADER_IMAGE_STORE */
+/* reuse GL_SHADER_IMAGE_ATOMIC */
+/* reuse GL_IMAGE_TEXEL_SIZE */
+/* reuse GL_IMAGE_COMPATIBILITY_CLASS */
+/* reuse GL_IMAGE_PIXEL_FORMAT */
+/* reuse GL_IMAGE_PIXEL_TYPE */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */
+/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */
+/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */
+/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */
+/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */
+/* reuse GL_CLEAR_BUFFER */
+/* reuse GL_TEXTURE_VIEW */
+/* reuse GL_VIEW_COMPATIBILITY_CLASS */
+/* reuse GL_FULL_SUPPORT */
+/* reuse GL_CAVEAT_SUPPORT */
+/* reuse GL_IMAGE_CLASS_4_X_32 */
+/* reuse GL_IMAGE_CLASS_2_X_32 */
+/* reuse GL_IMAGE_CLASS_1_X_32 */
+/* reuse GL_IMAGE_CLASS_4_X_16 */
+/* reuse GL_IMAGE_CLASS_2_X_16 */
+/* reuse GL_IMAGE_CLASS_1_X_16 */
+/* reuse GL_IMAGE_CLASS_4_X_8 */
+/* reuse GL_IMAGE_CLASS_2_X_8 */
+/* reuse GL_IMAGE_CLASS_1_X_8 */
+/* reuse GL_IMAGE_CLASS_11_11_10 */
+/* reuse GL_IMAGE_CLASS_10_10_10_2 */
+/* reuse GL_VIEW_CLASS_128_BITS */
+/* reuse GL_VIEW_CLASS_96_BITS */
+/* reuse GL_VIEW_CLASS_64_BITS */
+/* reuse GL_VIEW_CLASS_48_BITS */
+/* reuse GL_VIEW_CLASS_32_BITS */
+/* reuse GL_VIEW_CLASS_24_BITS */
+/* reuse GL_VIEW_CLASS_16_BITS */
+/* reuse GL_VIEW_CLASS_8_BITS */
+/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */
+/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */
+/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */
+/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */
+/* reuse GL_VIEW_CLASS_RGTC1_RED */
+/* reuse GL_VIEW_CLASS_RGTC2_RG */
+/* reuse GL_VIEW_CLASS_BPTC_UNORM */
+/* reuse GL_VIEW_CLASS_BPTC_FLOAT */
+/* Reuse tokens from ARB_invalidate_subdata (none) */
+/* Reuse tokens from ARB_multi_draw_indirect (none) */
+/* Reuse tokens from ARB_program_interface_query */
+/* reuse GL_UNIFORM */
+/* reuse GL_UNIFORM_BLOCK */
+/* reuse GL_PROGRAM_INPUT */
+/* reuse GL_PROGRAM_OUTPUT */
+/* reuse GL_BUFFER_VARIABLE */
+/* reuse GL_SHADER_STORAGE_BLOCK */
+/* reuse GL_VERTEX_SUBROUTINE */
+/* reuse GL_TESS_CONTROL_SUBROUTINE */
+/* reuse GL_TESS_EVALUATION_SUBROUTINE */
+/* reuse GL_GEOMETRY_SUBROUTINE */
+/* reuse GL_FRAGMENT_SUBROUTINE */
+/* reuse GL_COMPUTE_SUBROUTINE */
+/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */
+/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */
+/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */
+/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */
+/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */
+/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */
+/* reuse GL_TRANSFORM_FEEDBACK_VARYING */
+/* reuse GL_ACTIVE_RESOURCES */
+/* reuse GL_MAX_NAME_LENGTH */
+/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */
+/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */
+/* reuse GL_NAME_LENGTH */
+/* reuse GL_TYPE */
+/* reuse GL_ARRAY_SIZE */
+/* reuse GL_OFFSET */
+/* reuse GL_BLOCK_INDEX */
+/* reuse GL_ARRAY_STRIDE */
+/* reuse GL_MATRIX_STRIDE */
+/* reuse GL_IS_ROW_MAJOR */
+/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */
+/* reuse GL_BUFFER_BINDING */
+/* reuse GL_BUFFER_DATA_SIZE */
+/* reuse GL_NUM_ACTIVE_VARIABLES */
+/* reuse GL_ACTIVE_VARIABLES */
+/* reuse GL_REFERENCED_BY_VERTEX_SHADER */
+/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */
+/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */
+/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */
+/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */
+/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */
+/* reuse GL_TOP_LEVEL_ARRAY_SIZE */
+/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */
+/* reuse GL_LOCATION */
+/* reuse GL_LOCATION_INDEX */
+/* reuse GL_IS_PER_PATCH */
+/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */
+/* Reuse tokens from ARB_shader_storage_buffer_object */
+/* reuse GL_SHADER_STORAGE_BUFFER */
+/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */
+/* reuse GL_SHADER_STORAGE_BUFFER_START */
+/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */
+/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */
+/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */
+/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */
+/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */
+/* reuse GL_SHADER_STORAGE_BARRIER_BIT */
+/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */
+/* Reuse tokens from ARB_stencil_texturing */
+/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */
+/* Reuse tokens from ARB_texture_buffer_range */
+/* reuse GL_TEXTURE_BUFFER_OFFSET */
+/* reuse GL_TEXTURE_BUFFER_SIZE */
+/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */
+/* Reuse tokens from ARB_texture_query_levels (none) */
+/* Reuse tokens from ARB_texture_storage_multisample (none) */
+/* Reuse tokens from ARB_texture_view */
+/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */
+/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */
+/* reuse GL_TEXTURE_VIEW_MIN_LAYER */
+/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */
+/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */
+/* Reuse tokens from ARB_vertex_attrib_binding */
+/* reuse GL_VERTEX_ATTRIB_BINDING */
+/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */
+/* reuse GL_VERTEX_BINDING_DIVISOR */
+/* reuse GL_VERTEX_BINDING_OFFSET */
+/* reuse GL_VERTEX_BINDING_STRIDE */
+/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */
+/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */
+#endif
+
+#ifndef GL_ARB_multitexture
+#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
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#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
+#endif
+
+#ifndef GL_ARB_multisample
+#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
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#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
+#endif
+
+#ifndef GL_ARB_texture_compression
+#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
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_ARB            0x812D
+#endif
+
+#ifndef GL_ARB_point_parameters
+#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
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#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_MODELVIEW0_ARB                 0x1700
+#define GL_MODELVIEW1_ARB                 0x850A
+#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
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#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
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_COMBINE_ARB                    0x8570
+#define GL_COMBINE_RGB_ARB                0x8571
+#define GL_COMBINE_ALPHA_ARB              0x8572
+#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_RGB_SCALE_ARB                  0x8573
+#define GL_ADD_SIGNED_ARB                 0x8574
+#define GL_INTERPOLATE_ARB                0x8575
+#define GL_SUBTRACT_ARB                   0x84E7
+#define GL_CONSTANT_ARB                   0x8576
+#define GL_PRIMARY_COLOR_ARB              0x8577
+#define GL_PREVIOUS_ARB                   0x8578
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_DOT3_RGB_ARB                   0x86AE
+#define GL_DOT3_RGBA_ARB                  0x86AF
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_ARB            0x8370
+#endif
+
+#ifndef GL_ARB_depth_texture
+#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
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_TEXTURE_COMPARE_MODE_ARB       0x884C
+#define GL_TEXTURE_COMPARE_FUNC_ARB       0x884D
+#define GL_COMPARE_R_TO_TEXTURE_ARB       0x884E
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
+#endif
+
+#ifndef GL_ARB_window_pos
+#endif
+
+#ifndef GL_ARB_vertex_program
+#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
+#endif
+
+#ifndef GL_ARB_fragment_program
+#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
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#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
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#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
+#endif
+
+#ifndef GL_ARB_shader_objects
+#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
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#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
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_FRAGMENT_SHADER_ARB            0x8B30
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_SHADING_LANGUAGE_VERSION_ARB   0x8B8C
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_POINT_SPRITE_ARB               0x8861
+#define GL_COORD_REPLACE_ARB              0x8862
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#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
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#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
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#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
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_HALF_FLOAT_ARB                 0x140B
+#endif
+
+#ifndef GL_ARB_texture_float
+#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_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
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#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
+#endif
+
+#ifndef GL_ARB_depth_buffer_float
+#define GL_DEPTH_COMPONENT32F             0x8CAC
+#define GL_DEPTH32F_STENCIL8              0x8CAD
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
+#endif
+
+#ifndef GL_ARB_draw_instanced
+#endif
+
+#ifndef GL_ARB_framebuffer_object
+#define GL_INVALID_FRAMEBUFFER_OPERATION  0x0506
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
+#define GL_FRAMEBUFFER_DEFAULT            0x8218
+#define GL_FRAMEBUFFER_UNDEFINED          0x8219
+#define GL_DEPTH_STENCIL_ATTACHMENT       0x821A
+#define GL_MAX_RENDERBUFFER_SIZE          0x84E8
+#define GL_DEPTH_STENCIL                  0x84F9
+#define GL_UNSIGNED_INT_24_8              0x84FA
+#define GL_DEPTH24_STENCIL8               0x88F0
+#define GL_TEXTURE_STENCIL_SIZE           0x88F1
+#define GL_TEXTURE_RED_TYPE               0x8C10
+#define GL_TEXTURE_GREEN_TYPE             0x8C11
+#define GL_TEXTURE_BLUE_TYPE              0x8C12
+#define GL_TEXTURE_ALPHA_TYPE             0x8C13
+#define GL_TEXTURE_DEPTH_TYPE             0x8C16
+#define GL_UNSIGNED_NORMALIZED            0x8C17
+#define GL_FRAMEBUFFER_BINDING            0x8CA6
+#define GL_DRAW_FRAMEBUFFER_BINDING       GL_FRAMEBUFFER_BINDING
+#define GL_RENDERBUFFER_BINDING           0x8CA7
+#define GL_READ_FRAMEBUFFER               0x8CA8
+#define GL_DRAW_FRAMEBUFFER               0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING       0x8CAA
+#define GL_RENDERBUFFER_SAMPLES           0x8CAB
+#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_LAYER 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE           0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED        0x8CDD
+#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                    0x8D40
+#define GL_RENDERBUFFER                   0x8D41
+#define GL_RENDERBUFFER_WIDTH             0x8D42
+#define GL_RENDERBUFFER_HEIGHT            0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT   0x8D44
+#define GL_STENCIL_INDEX1                 0x8D46
+#define GL_STENCIL_INDEX4                 0x8D47
+#define GL_STENCIL_INDEX8                 0x8D48
+#define GL_STENCIL_INDEX16                0x8D49
+#define GL_RENDERBUFFER_RED_SIZE          0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE        0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE         0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE        0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE        0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE      0x8D55
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+#define GL_MAX_SAMPLES                    0x8D57
+#endif
+
+#ifndef GL_ARB_framebuffer_object_DEPRECATED
+#define GL_INDEX                          0x8222
+#define GL_TEXTURE_LUMINANCE_TYPE         0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE         0x8C15
+#endif
+
+#ifndef GL_ARB_framebuffer_sRGB
+#define GL_FRAMEBUFFER_SRGB               0x8DB9
+#endif
+
+#ifndef GL_ARB_geometry_shader4
+#define GL_LINES_ADJACENCY_ARB            0x000A
+#define GL_LINE_STRIP_ADJACENCY_ARB       0x000B
+#define GL_TRIANGLES_ADJACENCY_ARB        0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_ARB   0x000D
+#define GL_PROGRAM_POINT_SIZE_ARB         0x8642
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9
+#define GL_GEOMETRY_SHADER_ARB            0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT_ARB      0x8DDA
+#define GL_GEOMETRY_INPUT_TYPE_ARB        0x8DDB
+#define GL_GEOMETRY_OUTPUT_TYPE_ARB       0x8DDC
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1
+/* reuse GL_MAX_VARYING_COMPONENTS */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+#endif
+
+#ifndef GL_ARB_half_float_vertex
+#define GL_HALF_FLOAT                     0x140B
+#endif
+
+#ifndef GL_ARB_instanced_arrays
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE
+#endif
+
+#ifndef GL_ARB_map_buffer_range
+#define GL_MAP_READ_BIT                   0x0001
+#define GL_MAP_WRITE_BIT                  0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT       0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT      0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT         0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT         0x0020
+#endif
+
+#ifndef GL_ARB_texture_buffer_object
+#define GL_TEXTURE_BUFFER_ARB             0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB    0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_ARB     0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT_ARB      0x8C2E
+#endif
+
+#ifndef GL_ARB_texture_compression_rgtc
+#define GL_COMPRESSED_RED_RGTC1           0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1    0x8DBC
+#define GL_COMPRESSED_RG_RGTC2            0x8DBD
+#define GL_COMPRESSED_SIGNED_RG_RGTC2     0x8DBE
+#endif
+
+#ifndef GL_ARB_texture_rg
+#define GL_RG                             0x8227
+#define GL_RG_INTEGER                     0x8228
+#define GL_R8                             0x8229
+#define GL_R16                            0x822A
+#define GL_RG8                            0x822B
+#define GL_RG16                           0x822C
+#define GL_R16F                           0x822D
+#define GL_R32F                           0x822E
+#define GL_RG16F                          0x822F
+#define GL_RG32F                          0x8230
+#define GL_R8I                            0x8231
+#define GL_R8UI                           0x8232
+#define GL_R16I                           0x8233
+#define GL_R16UI                          0x8234
+#define GL_R32I                           0x8235
+#define GL_R32UI                          0x8236
+#define GL_RG8I                           0x8237
+#define GL_RG8UI                          0x8238
+#define GL_RG16I                          0x8239
+#define GL_RG16UI                         0x823A
+#define GL_RG32I                          0x823B
+#define GL_RG32UI                         0x823C
+#endif
+
+#ifndef GL_ARB_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING           0x85B5
+#endif
+
+#ifndef GL_ARB_uniform_buffer_object
+#define GL_UNIFORM_BUFFER                 0x8A11
+#define GL_UNIFORM_BUFFER_BINDING         0x8A28
+#define GL_UNIFORM_BUFFER_START           0x8A29
+#define GL_UNIFORM_BUFFER_SIZE            0x8A2A
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS      0x8A2B
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS    0x8A2C
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS    0x8A2D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS    0x8A2E
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS    0x8A2F
+#define GL_MAX_UNIFORM_BLOCK_SIZE         0x8A30
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS          0x8A36
+#define GL_UNIFORM_TYPE                   0x8A37
+#define GL_UNIFORM_SIZE                   0x8A38
+#define GL_UNIFORM_NAME_LENGTH            0x8A39
+#define GL_UNIFORM_BLOCK_INDEX            0x8A3A
+#define GL_UNIFORM_OFFSET                 0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE           0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE          0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR           0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING          0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE        0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH      0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS  0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
+#define GL_INVALID_INDEX                  0xFFFFFFFFu
+#endif
+
+#ifndef GL_ARB_compatibility
+/* ARB_compatibility just defines tokens from core 3.0 */
+#endif
+
+#ifndef GL_ARB_copy_buffer
+#define GL_COPY_READ_BUFFER_BINDING       0x8F36
+#define GL_COPY_READ_BUFFER               GL_COPY_READ_BUFFER_BINDING
+#define GL_COPY_WRITE_BUFFER_BINDING      0x8F37
+#define GL_COPY_WRITE_BUFFER              GL_COPY_WRITE_BUFFER_BINDING
+#endif
+
+#ifndef GL_ARB_shader_texture_lod
+#endif
+
+#ifndef GL_ARB_depth_clamp
+#define GL_DEPTH_CLAMP                    0x864F
+#endif
+
+#ifndef GL_ARB_draw_elements_base_vertex
+#endif
+
+#ifndef GL_ARB_fragment_coord_conventions
+#endif
+
+#ifndef GL_ARB_provoking_vertex
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION        0x8E4D
+#define GL_LAST_VERTEX_CONVENTION         0x8E4E
+#define GL_PROVOKING_VERTEX               0x8E4F
+#endif
+
+#ifndef GL_ARB_seamless_cube_map
+#define GL_TEXTURE_CUBE_MAP_SEAMLESS      0x884F
+#endif
+
+#ifndef GL_ARB_sync
+#define GL_MAX_SERVER_WAIT_TIMEOUT        0x9111
+#define GL_OBJECT_TYPE                    0x9112
+#define GL_SYNC_CONDITION                 0x9113
+#define GL_SYNC_STATUS                    0x9114
+#define GL_SYNC_FLAGS                     0x9115
+#define GL_SYNC_FENCE                     0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE     0x9117
+#define GL_UNSIGNALED                     0x9118
+#define GL_SIGNALED                       0x9119
+#define GL_ALREADY_SIGNALED               0x911A
+#define GL_TIMEOUT_EXPIRED                0x911B
+#define GL_CONDITION_SATISFIED            0x911C
+#define GL_WAIT_FAILED                    0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT        0x00000001
+#define GL_TIMEOUT_IGNORED                0xFFFFFFFFFFFFFFFFull
+#endif
+
+#ifndef GL_ARB_texture_multisample
+#define GL_SAMPLE_POSITION                0x8E50
+#define GL_SAMPLE_MASK                    0x8E51
+#define GL_SAMPLE_MASK_VALUE              0x8E52
+#define GL_MAX_SAMPLE_MASK_WORDS          0x8E59
+#define GL_TEXTURE_2D_MULTISAMPLE         0x9100
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE   0x9101
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY   0x9102
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
+#define GL_TEXTURE_SAMPLES                0x9106
+#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
+#define GL_SAMPLER_2D_MULTISAMPLE         0x9108
+#define GL_INT_SAMPLER_2D_MULTISAMPLE     0x9109
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY   0x910B
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
+#define GL_MAX_COLOR_TEXTURE_SAMPLES      0x910E
+#define GL_MAX_DEPTH_TEXTURE_SAMPLES      0x910F
+#define GL_MAX_INTEGER_SAMPLES            0x9110
+#endif
+
+#ifndef GL_ARB_vertex_array_bgra
+/* reuse GL_BGRA */
+#endif
+
+#ifndef GL_ARB_draw_buffers_blend
+#endif
+
+#ifndef GL_ARB_sample_shading
+#define GL_SAMPLE_SHADING_ARB             0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE_ARB   0x8C37
+#endif
+
+#ifndef GL_ARB_texture_cube_map_array
+#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB     0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B
+#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB     0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F
+#endif
+
+#ifndef GL_ARB_texture_gather
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F
+#endif
+
+#ifndef GL_ARB_texture_query_lod
+#endif
+
+#ifndef GL_ARB_shading_language_include
+#define GL_SHADER_INCLUDE_ARB             0x8DAE
+#define GL_NAMED_STRING_LENGTH_ARB        0x8DE9
+#define GL_NAMED_STRING_TYPE_ARB          0x8DEA
+#endif
+
+#ifndef GL_ARB_texture_compression_bptc
+#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
+#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
+#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
+#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
+#endif
+
+#ifndef GL_ARB_blend_func_extended
+#define GL_SRC1_COLOR                     0x88F9
+/* reuse GL_SRC1_ALPHA */
+#define GL_ONE_MINUS_SRC1_COLOR           0x88FA
+#define GL_ONE_MINUS_SRC1_ALPHA           0x88FB
+#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS   0x88FC
+#endif
+
+#ifndef GL_ARB_explicit_attrib_location
+#endif
+
+#ifndef GL_ARB_occlusion_query2
+#define GL_ANY_SAMPLES_PASSED             0x8C2F
+#endif
+
+#ifndef GL_ARB_sampler_objects
+#define GL_SAMPLER_BINDING                0x8919
+#endif
+
+#ifndef GL_ARB_shader_bit_encoding
+#endif
+
+#ifndef GL_ARB_texture_rgb10_a2ui
+#define GL_RGB10_A2UI                     0x906F
+#endif
+
+#ifndef GL_ARB_texture_swizzle
+#define GL_TEXTURE_SWIZZLE_R              0x8E42
+#define GL_TEXTURE_SWIZZLE_G              0x8E43
+#define GL_TEXTURE_SWIZZLE_B              0x8E44
+#define GL_TEXTURE_SWIZZLE_A              0x8E45
+#define GL_TEXTURE_SWIZZLE_RGBA           0x8E46
+#endif
+
+#ifndef GL_ARB_timer_query
+#define GL_TIME_ELAPSED                   0x88BF
+#define GL_TIMESTAMP                      0x8E28
+#endif
+
+#ifndef GL_ARB_vertex_type_2_10_10_10_rev
+/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */
+#define GL_INT_2_10_10_10_REV             0x8D9F
+#endif
+
+#ifndef GL_ARB_draw_indirect
+#define GL_DRAW_INDIRECT_BUFFER           0x8F3F
+#define GL_DRAW_INDIRECT_BUFFER_BINDING   0x8F43
+#endif
+
+#ifndef GL_ARB_gpu_shader5
+#define GL_GEOMETRY_SHADER_INVOCATIONS    0x887F
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C
+#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D
+/* reuse GL_MAX_VERTEX_STREAMS */
+#endif
+
+#ifndef GL_ARB_gpu_shader_fp64
+/* reuse GL_DOUBLE */
+#define GL_DOUBLE_VEC2                    0x8FFC
+#define GL_DOUBLE_VEC3                    0x8FFD
+#define GL_DOUBLE_VEC4                    0x8FFE
+#define GL_DOUBLE_MAT2                    0x8F46
+#define GL_DOUBLE_MAT3                    0x8F47
+#define GL_DOUBLE_MAT4                    0x8F48
+#define GL_DOUBLE_MAT2x3                  0x8F49
+#define GL_DOUBLE_MAT2x4                  0x8F4A
+#define GL_DOUBLE_MAT3x2                  0x8F4B
+#define GL_DOUBLE_MAT3x4                  0x8F4C
+#define GL_DOUBLE_MAT4x2                  0x8F4D
+#define GL_DOUBLE_MAT4x3                  0x8F4E
+#endif
+
+#ifndef GL_ARB_shader_subroutine
+#define GL_ACTIVE_SUBROUTINES             0x8DE5
+#define GL_ACTIVE_SUBROUTINE_UNIFORMS     0x8DE6
+#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47
+#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH   0x8E48
+#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49
+#define GL_MAX_SUBROUTINES                0x8DE7
+#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8
+#define GL_NUM_COMPATIBLE_SUBROUTINES     0x8E4A
+#define GL_COMPATIBLE_SUBROUTINES         0x8E4B
+/* reuse GL_UNIFORM_SIZE */
+/* reuse GL_UNIFORM_NAME_LENGTH */
+#endif
+
+#ifndef GL_ARB_tessellation_shader
+#define GL_PATCHES                        0x000E
+#define GL_PATCH_VERTICES                 0x8E72
+#define GL_PATCH_DEFAULT_INNER_LEVEL      0x8E73
+#define GL_PATCH_DEFAULT_OUTER_LEVEL      0x8E74
+#define GL_TESS_CONTROL_OUTPUT_VERTICES   0x8E75
+#define GL_TESS_GEN_MODE                  0x8E76
+#define GL_TESS_GEN_SPACING               0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER          0x8E78
+#define GL_TESS_GEN_POINT_MODE            0x8E79
+/* reuse GL_TRIANGLES */
+/* reuse GL_QUADS */
+#define GL_ISOLINES                       0x8E7A
+/* reuse GL_EQUAL */
+#define GL_FRACTIONAL_ODD                 0x8E7B
+#define GL_FRACTIONAL_EVEN                0x8E7C
+/* reuse GL_CCW */
+/* reuse GL_CW */
+#define GL_MAX_PATCH_VERTICES             0x8E7D
+#define GL_MAX_TESS_GEN_LEVEL             0x8E7E
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83
+#define GL_MAX_TESS_PATCH_COMPONENTS      0x8E84
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1
+#define GL_TESS_EVALUATION_SHADER         0x8E87
+#define GL_TESS_CONTROL_SHADER            0x8E88
+#endif
+
+#ifndef GL_ARB_texture_buffer_object_rgb32
+/* reuse GL_RGB32F */
+/* reuse GL_RGB32UI */
+/* reuse GL_RGB32I */
+#endif
+
+#ifndef GL_ARB_transform_feedback2
+#define GL_TRANSFORM_FEEDBACK             0x8E22
+#define GL_TRANSFORM_FEEDBACK_PAUSED      0x8E23
+#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED GL_TRANSFORM_FEEDBACK_PAUSED
+#define GL_TRANSFORM_FEEDBACK_ACTIVE      0x8E24
+#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE GL_TRANSFORM_FEEDBACK_ACTIVE
+#define GL_TRANSFORM_FEEDBACK_BINDING     0x8E25
+#endif
+
+#ifndef GL_ARB_transform_feedback3
+#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70
+#define GL_MAX_VERTEX_STREAMS             0x8E71
+#endif
+
+#ifndef GL_ARB_ES2_compatibility
+#define GL_FIXED                          0x140C
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_LOW_FLOAT                      0x8DF0
+#define GL_MEDIUM_FLOAT                   0x8DF1
+#define GL_HIGH_FLOAT                     0x8DF2
+#define GL_LOW_INT                        0x8DF3
+#define GL_MEDIUM_INT                     0x8DF4
+#define GL_HIGH_INT                       0x8DF5
+#define GL_SHADER_COMPILER                0x8DFA
+#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9
+#define GL_MAX_VERTEX_UNIFORM_VECTORS     0x8DFB
+#define GL_MAX_VARYING_VECTORS            0x8DFC
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS   0x8DFD
+#define GL_RGB565                         0x8D62
+#endif
+
+#ifndef GL_ARB_get_program_binary
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
+#define GL_PROGRAM_BINARY_LENGTH          0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS     0x87FE
+#define GL_PROGRAM_BINARY_FORMATS         0x87FF
+#endif
+
+#ifndef GL_ARB_separate_shader_objects
+#define GL_VERTEX_SHADER_BIT              0x00000001
+#define GL_FRAGMENT_SHADER_BIT            0x00000002
+#define GL_GEOMETRY_SHADER_BIT            0x00000004
+#define GL_TESS_CONTROL_SHADER_BIT        0x00000008
+#define GL_TESS_EVALUATION_SHADER_BIT     0x00000010
+#define GL_ALL_SHADER_BITS                0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE              0x8258
+#define GL_ACTIVE_PROGRAM                 0x8259
+#define GL_PROGRAM_PIPELINE_BINDING       0x825A
+#endif
+
+#ifndef GL_ARB_shader_precision
+#endif
+
+#ifndef GL_ARB_vertex_attrib_64bit
+/* reuse GL_RGB32I */
+/* reuse GL_DOUBLE_VEC2 */
+/* reuse GL_DOUBLE_VEC3 */
+/* reuse GL_DOUBLE_VEC4 */
+/* reuse GL_DOUBLE_MAT2 */
+/* reuse GL_DOUBLE_MAT3 */
+/* reuse GL_DOUBLE_MAT4 */
+/* reuse GL_DOUBLE_MAT2x3 */
+/* reuse GL_DOUBLE_MAT2x4 */
+/* reuse GL_DOUBLE_MAT3x2 */
+/* reuse GL_DOUBLE_MAT3x4 */
+/* reuse GL_DOUBLE_MAT4x2 */
+/* reuse GL_DOUBLE_MAT4x3 */
+#endif
+
+#ifndef GL_ARB_viewport_array
+/* reuse GL_SCISSOR_BOX */
+/* reuse GL_VIEWPORT */
+/* reuse GL_DEPTH_RANGE */
+/* reuse GL_SCISSOR_TEST */
+#define GL_MAX_VIEWPORTS                  0x825B
+#define GL_VIEWPORT_SUBPIXEL_BITS         0x825C
+#define GL_VIEWPORT_BOUNDS_RANGE          0x825D
+#define GL_LAYER_PROVOKING_VERTEX         0x825E
+#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F
+#define GL_UNDEFINED_VERTEX               0x8260
+/* reuse GL_FIRST_VERTEX_CONVENTION */
+/* reuse GL_LAST_VERTEX_CONVENTION */
+/* reuse GL_PROVOKING_VERTEX */
+#endif
+
+#ifndef GL_ARB_cl_event
+#define GL_SYNC_CL_EVENT_ARB              0x8240
+#define GL_SYNC_CL_EVENT_COMPLETE_ARB     0x8241
+#endif
+
+#ifndef GL_ARB_debug_output
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB   0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION_ARB    0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM_ARB  0x8245
+#define GL_DEBUG_SOURCE_API_ARB           0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB   0x8249
+#define GL_DEBUG_SOURCE_APPLICATION_ARB   0x824A
+#define GL_DEBUG_SOURCE_OTHER_ARB         0x824B
+#define GL_DEBUG_TYPE_ERROR_ARB           0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY_ARB     0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE_ARB     0x8250
+#define GL_DEBUG_TYPE_OTHER_ARB           0x8251
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB   0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB  0x9144
+#define GL_DEBUG_LOGGED_MESSAGES_ARB      0x9145
+#define GL_DEBUG_SEVERITY_HIGH_ARB        0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM_ARB      0x9147
+#define GL_DEBUG_SEVERITY_LOW_ARB         0x9148
+#endif
+
+#ifndef GL_ARB_robustness
+/* reuse GL_NO_ERROR */
+#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
+#define GL_LOSE_CONTEXT_ON_RESET_ARB      0x8252
+#define GL_GUILTY_CONTEXT_RESET_ARB       0x8253
+#define GL_INNOCENT_CONTEXT_RESET_ARB     0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_ARB      0x8255
+#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define GL_NO_RESET_NOTIFICATION_ARB      0x8261
+#endif
+
+#ifndef GL_ARB_shader_stencil_export
+#endif
+
+#ifndef GL_ARB_base_instance
+#endif
+
+#ifndef GL_ARB_shading_language_420pack
+#endif
+
+#ifndef GL_ARB_transform_feedback_instanced
+#endif
+
+#ifndef GL_ARB_compressed_texture_pixel_storage
+#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH  0x9127
+#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
+#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH  0x9129
+#define GL_UNPACK_COMPRESSED_BLOCK_SIZE   0x912A
+#define GL_PACK_COMPRESSED_BLOCK_WIDTH    0x912B
+#define GL_PACK_COMPRESSED_BLOCK_HEIGHT   0x912C
+#define GL_PACK_COMPRESSED_BLOCK_DEPTH    0x912D
+#define GL_PACK_COMPRESSED_BLOCK_SIZE     0x912E
+#endif
+
+#ifndef GL_ARB_conservative_depth
+#endif
+
+#ifndef GL_ARB_internalformat_query
+#define GL_NUM_SAMPLE_COUNTS              0x9380
+#endif
+
+#ifndef GL_ARB_map_buffer_alignment
+#define GL_MIN_MAP_BUFFER_ALIGNMENT       0x90BC
+#endif
+
+#ifndef GL_ARB_shader_atomic_counters
+#define GL_ATOMIC_COUNTER_BUFFER          0x92C0
+#define GL_ATOMIC_COUNTER_BUFFER_BINDING  0x92C1
+#define GL_ATOMIC_COUNTER_BUFFER_START    0x92C2
+#define GL_ATOMIC_COUNTER_BUFFER_SIZE     0x92C3
+#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4
+#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5
+#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB
+#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
+#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
+#define GL_MAX_VERTEX_ATOMIC_COUNTERS     0x92D2
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS   0x92D5
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS   0x92D6
+#define GL_MAX_COMBINED_ATOMIC_COUNTERS   0x92D7
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
+#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS  0x92D9
+#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA
+#define GL_UNSIGNED_INT_ATOMIC_COUNTER    0x92DB
+#endif
+
+#ifndef GL_ARB_shader_image_load_store
+#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
+#define GL_ELEMENT_ARRAY_BARRIER_BIT      0x00000002
+#define GL_UNIFORM_BARRIER_BIT            0x00000004
+#define GL_TEXTURE_FETCH_BARRIER_BIT      0x00000008
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
+#define GL_COMMAND_BARRIER_BIT            0x00000040
+#define GL_PIXEL_BUFFER_BARRIER_BIT       0x00000080
+#define GL_TEXTURE_UPDATE_BARRIER_BIT     0x00000100
+#define GL_BUFFER_UPDATE_BARRIER_BIT      0x00000200
+#define GL_FRAMEBUFFER_BARRIER_BIT        0x00000400
+#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
+#define GL_ATOMIC_COUNTER_BARRIER_BIT     0x00001000
+#define GL_ALL_BARRIER_BITS               0xFFFFFFFF
+#define GL_MAX_IMAGE_UNITS                0x8F38
+#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
+#define GL_IMAGE_BINDING_NAME             0x8F3A
+#define GL_IMAGE_BINDING_LEVEL            0x8F3B
+#define GL_IMAGE_BINDING_LAYERED          0x8F3C
+#define GL_IMAGE_BINDING_LAYER            0x8F3D
+#define GL_IMAGE_BINDING_ACCESS           0x8F3E
+#define GL_IMAGE_1D                       0x904C
+#define GL_IMAGE_2D                       0x904D
+#define GL_IMAGE_3D                       0x904E
+#define GL_IMAGE_2D_RECT                  0x904F
+#define GL_IMAGE_CUBE                     0x9050
+#define GL_IMAGE_BUFFER                   0x9051
+#define GL_IMAGE_1D_ARRAY                 0x9052
+#define GL_IMAGE_2D_ARRAY                 0x9053
+#define GL_IMAGE_CUBE_MAP_ARRAY           0x9054
+#define GL_IMAGE_2D_MULTISAMPLE           0x9055
+#define GL_IMAGE_2D_MULTISAMPLE_ARRAY     0x9056
+#define GL_INT_IMAGE_1D                   0x9057
+#define GL_INT_IMAGE_2D                   0x9058
+#define GL_INT_IMAGE_3D                   0x9059
+#define GL_INT_IMAGE_2D_RECT              0x905A
+#define GL_INT_IMAGE_CUBE                 0x905B
+#define GL_INT_IMAGE_BUFFER               0x905C
+#define GL_INT_IMAGE_1D_ARRAY             0x905D
+#define GL_INT_IMAGE_2D_ARRAY             0x905E
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY       0x905F
+#define GL_INT_IMAGE_2D_MULTISAMPLE       0x9060
+#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
+#define GL_UNSIGNED_INT_IMAGE_1D          0x9062
+#define GL_UNSIGNED_INT_IMAGE_2D          0x9063
+#define GL_UNSIGNED_INT_IMAGE_3D          0x9064
+#define GL_UNSIGNED_INT_IMAGE_2D_RECT     0x9065
+#define GL_UNSIGNED_INT_IMAGE_CUBE        0x9066
+#define GL_UNSIGNED_INT_IMAGE_BUFFER      0x9067
+#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY    0x9068
+#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY    0x9069
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
+#define GL_MAX_IMAGE_SAMPLES              0x906D
+#define GL_IMAGE_BINDING_FORMAT           0x906E
+#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
+#define GL_MAX_VERTEX_IMAGE_UNIFORMS      0x90CA
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS    0x90CD
+#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS    0x90CE
+#define GL_MAX_COMBINED_IMAGE_UNIFORMS    0x90CF
+#endif
+
+#ifndef GL_ARB_shading_language_packing
+#endif
+
+#ifndef GL_ARB_texture_storage
+#define GL_TEXTURE_IMMUTABLE_FORMAT       0x912F
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR   0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR   0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR   0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR   0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR   0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR   0x93B5
+#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR   0x93B6
+#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR   0x93B7
+#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR  0x93B8
+#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR  0x93B9
+#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR  0x93BA
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+#endif
+
+#ifndef GL_KHR_debug
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS       0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION        0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM      0x8245
+#define GL_DEBUG_SOURCE_API               0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM     0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER   0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY       0x8249
+#define GL_DEBUG_SOURCE_APPLICATION       0x824A
+#define GL_DEBUG_SOURCE_OTHER             0x824B
+#define GL_DEBUG_TYPE_ERROR               0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR  0x824E
+#define GL_DEBUG_TYPE_PORTABILITY         0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE         0x8250
+#define GL_DEBUG_TYPE_OTHER               0x8251
+#define GL_DEBUG_TYPE_MARKER              0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP          0x8269
+#define GL_DEBUG_TYPE_POP_GROUP           0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION    0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH    0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH        0x826D
+#define GL_BUFFER                         0x82E0
+#define GL_SHADER                         0x82E1
+#define GL_PROGRAM                        0x82E2
+#define GL_QUERY                          0x82E3
+#define GL_PROGRAM_PIPELINE               0x82E4
+#define GL_SAMPLER                        0x82E6
+#define GL_DISPLAY_LIST                   0x82E7
+#define GL_MAX_LABEL_LENGTH               0x82E8
+#define GL_MAX_DEBUG_MESSAGE_LENGTH       0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES      0x9144
+#define GL_DEBUG_LOGGED_MESSAGES          0x9145
+#define GL_DEBUG_SEVERITY_HIGH            0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM          0x9147
+#define GL_DEBUG_SEVERITY_LOW             0x9148
+#define GL_DEBUG_OUTPUT                   0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT         0x00000002
+/* reuse GL_STACK_UNDERFLOW */
+/* reuse GL_STACK_OVERFLOW */
+#endif
+
+#ifndef GL_ARB_arrays_of_arrays
+#endif
+
+#ifndef GL_ARB_clear_buffer_object
+#endif
+
+#ifndef GL_ARB_compute_shader
+#define GL_COMPUTE_SHADER                 0x91B9
+#define GL_MAX_COMPUTE_UNIFORM_BLOCKS     0x91BB
+#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC
+#define GL_MAX_COMPUTE_IMAGE_UNIFORMS     0x91BD
+#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262
+#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263
+#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264
+#define GL_MAX_COMPUTE_ATOMIC_COUNTERS    0x8265
+#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266
+#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS  0x90EB
+#define GL_MAX_COMPUTE_WORK_GROUP_COUNT   0x91BE
+#define GL_MAX_COMPUTE_WORK_GROUP_SIZE    0x91BF
+#define GL_COMPUTE_LOCAL_WORK_SIZE        0x8267
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED
+#define GL_DISPATCH_INDIRECT_BUFFER       0x90EE
+#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF
+#define GL_COMPUTE_SHADER_BIT             0x00000020
+#endif
+
+#ifndef GL_ARB_copy_image
+#endif
+
+#ifndef GL_ARB_debug_group
+/* reuse GL_DEBUG_TYPE_MARKER */
+/* reuse GL_DEBUG_TYPE_PUSH_GROUP */
+/* reuse GL_DEBUG_TYPE_POP_GROUP */
+/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */
+/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */
+/* reuse GL_DEBUG_GROUP_STACK_DEPTH */
+/* reuse GL_STACK_UNDERFLOW */
+/* reuse GL_STACK_OVERFLOW */
+#endif
+
+#ifndef GL_ARB_debug_label
+/* reuse GL_BUFFER */
+/* reuse GL_SHADER */
+/* reuse GL_PROGRAM */
+/* reuse GL_QUERY */
+/* reuse GL_PROGRAM_PIPELINE */
+/* reuse GL_SAMPLER */
+/* DISPLAY_LIST used in compatibility profile only */
+/* reuse GL_DISPLAY_LIST */
+/* reuse GL_MAX_LABEL_LENGTH */
+/* reuse GL_VERTEX_ARRAY */
+#endif
+
+#ifndef GL_ARB_debug_output2
+/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */
+/* reuse GL_DEBUG_OUTPUT */
+#endif
+
+#ifndef GL_ARB_ES3_compatibility
+#define GL_COMPRESSED_RGB8_ETC2           0x9274
+#define GL_COMPRESSED_SRGB8_ETC2          0x9275
+#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
+#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
+#define GL_COMPRESSED_RGBA8_ETC2_EAC      0x9278
+#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
+#define GL_COMPRESSED_R11_EAC             0x9270
+#define GL_COMPRESSED_SIGNED_R11_EAC      0x9271
+#define GL_COMPRESSED_RG11_EAC            0x9272
+#define GL_COMPRESSED_SIGNED_RG11_EAC     0x9273
+#define GL_PRIMITIVE_RESTART_FIXED_INDEX  0x8D69
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
+#define GL_MAX_ELEMENT_INDEX              0x8D6B
+#endif
+
+#ifndef GL_ARB_explicit_uniform_location
+#define GL_MAX_UNIFORM_LOCATIONS          0x826E
+#endif
+
+#ifndef GL_ARB_fragment_layer_viewport
+#endif
+
+#ifndef GL_ARB_framebuffer_no_attachments
+#define GL_FRAMEBUFFER_DEFAULT_WIDTH      0x9310
+#define GL_FRAMEBUFFER_DEFAULT_HEIGHT     0x9311
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS     0x9312
+#define GL_FRAMEBUFFER_DEFAULT_SAMPLES    0x9313
+#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314
+#define GL_MAX_FRAMEBUFFER_WIDTH          0x9315
+#define GL_MAX_FRAMEBUFFER_HEIGHT         0x9316
+#define GL_MAX_FRAMEBUFFER_LAYERS         0x9317
+#define GL_MAX_FRAMEBUFFER_SAMPLES        0x9318
+#endif
+
+#ifndef GL_ARB_internalformat_query2
+/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */
+/* reuse GL_NUM_SAMPLE_COUNTS */
+/* reuse GL_RENDERBUFFER */
+/* reuse GL_SAMPLES */
+/* reuse GL_TEXTURE_1D */
+/* reuse GL_TEXTURE_1D_ARRAY */
+/* reuse GL_TEXTURE_2D */
+/* reuse GL_TEXTURE_2D_ARRAY */
+/* reuse GL_TEXTURE_3D */
+/* reuse GL_TEXTURE_CUBE_MAP */
+/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */
+/* reuse GL_TEXTURE_RECTANGLE */
+/* reuse GL_TEXTURE_BUFFER */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE */
+/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */
+/* reuse GL_TEXTURE_COMPRESSED */
+#define GL_INTERNALFORMAT_SUPPORTED       0x826F
+#define GL_INTERNALFORMAT_PREFERRED       0x8270
+#define GL_INTERNALFORMAT_RED_SIZE        0x8271
+#define GL_INTERNALFORMAT_GREEN_SIZE      0x8272
+#define GL_INTERNALFORMAT_BLUE_SIZE       0x8273
+#define GL_INTERNALFORMAT_ALPHA_SIZE      0x8274
+#define GL_INTERNALFORMAT_DEPTH_SIZE      0x8275
+#define GL_INTERNALFORMAT_STENCIL_SIZE    0x8276
+#define GL_INTERNALFORMAT_SHARED_SIZE     0x8277
+#define GL_INTERNALFORMAT_RED_TYPE        0x8278
+#define GL_INTERNALFORMAT_GREEN_TYPE      0x8279
+#define GL_INTERNALFORMAT_BLUE_TYPE       0x827A
+#define GL_INTERNALFORMAT_ALPHA_TYPE      0x827B
+#define GL_INTERNALFORMAT_DEPTH_TYPE      0x827C
+#define GL_INTERNALFORMAT_STENCIL_TYPE    0x827D
+#define GL_MAX_WIDTH                      0x827E
+#define GL_MAX_HEIGHT                     0x827F
+#define GL_MAX_DEPTH                      0x8280
+#define GL_MAX_LAYERS                     0x8281
+#define GL_MAX_COMBINED_DIMENSIONS        0x8282
+#define GL_COLOR_COMPONENTS               0x8283
+#define GL_DEPTH_COMPONENTS               0x8284
+#define GL_STENCIL_COMPONENTS             0x8285
+#define GL_COLOR_RENDERABLE               0x8286
+#define GL_DEPTH_RENDERABLE               0x8287
+#define GL_STENCIL_RENDERABLE             0x8288
+#define GL_FRAMEBUFFER_RENDERABLE         0x8289
+#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A
+#define GL_FRAMEBUFFER_BLEND              0x828B
+#define GL_READ_PIXELS                    0x828C
+#define GL_READ_PIXELS_FORMAT             0x828D
+#define GL_READ_PIXELS_TYPE               0x828E
+#define GL_TEXTURE_IMAGE_FORMAT           0x828F
+#define GL_TEXTURE_IMAGE_TYPE             0x8290
+#define GL_GET_TEXTURE_IMAGE_FORMAT       0x8291
+#define GL_GET_TEXTURE_IMAGE_TYPE         0x8292
+#define GL_MIPMAP                         0x8293
+#define GL_MANUAL_GENERATE_MIPMAP         0x8294
+#define GL_AUTO_GENERATE_MIPMAP           0x8295
+#define GL_COLOR_ENCODING                 0x8296
+#define GL_SRGB_READ                      0x8297
+#define GL_SRGB_WRITE                     0x8298
+#define GL_SRGB_DECODE_ARB                0x8299
+#define GL_FILTER                         0x829A
+#define GL_VERTEX_TEXTURE                 0x829B
+#define GL_TESS_CONTROL_TEXTURE           0x829C
+#define GL_TESS_EVALUATION_TEXTURE        0x829D
+#define GL_GEOMETRY_TEXTURE               0x829E
+#define GL_FRAGMENT_TEXTURE               0x829F
+#define GL_COMPUTE_TEXTURE                0x82A0
+#define GL_TEXTURE_SHADOW                 0x82A1
+#define GL_TEXTURE_GATHER                 0x82A2
+#define GL_TEXTURE_GATHER_SHADOW          0x82A3
+#define GL_SHADER_IMAGE_LOAD              0x82A4
+#define GL_SHADER_IMAGE_STORE             0x82A5
+#define GL_SHADER_IMAGE_ATOMIC            0x82A6
+#define GL_IMAGE_TEXEL_SIZE               0x82A7
+#define GL_IMAGE_COMPATIBILITY_CLASS      0x82A8
+#define GL_IMAGE_PIXEL_FORMAT             0x82A9
+#define GL_IMAGE_PIXEL_TYPE               0x82AA
+#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC
+#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD
+#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE
+#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF
+#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1
+#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2
+#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE  0x82B3
+#define GL_CLEAR_BUFFER                   0x82B4
+#define GL_TEXTURE_VIEW                   0x82B5
+#define GL_VIEW_COMPATIBILITY_CLASS       0x82B6
+#define GL_FULL_SUPPORT                   0x82B7
+#define GL_CAVEAT_SUPPORT                 0x82B8
+#define GL_IMAGE_CLASS_4_X_32             0x82B9
+#define GL_IMAGE_CLASS_2_X_32             0x82BA
+#define GL_IMAGE_CLASS_1_X_32             0x82BB
+#define GL_IMAGE_CLASS_4_X_16             0x82BC
+#define GL_IMAGE_CLASS_2_X_16             0x82BD
+#define GL_IMAGE_CLASS_1_X_16             0x82BE
+#define GL_IMAGE_CLASS_4_X_8              0x82BF
+#define GL_IMAGE_CLASS_2_X_8              0x82C0
+#define GL_IMAGE_CLASS_1_X_8              0x82C1
+#define GL_IMAGE_CLASS_11_11_10           0x82C2
+#define GL_IMAGE_CLASS_10_10_10_2         0x82C3
+#define GL_VIEW_CLASS_128_BITS            0x82C4
+#define GL_VIEW_CLASS_96_BITS             0x82C5
+#define GL_VIEW_CLASS_64_BITS             0x82C6
+#define GL_VIEW_CLASS_48_BITS             0x82C7
+#define GL_VIEW_CLASS_32_BITS             0x82C8
+#define GL_VIEW_CLASS_24_BITS             0x82C9
+#define GL_VIEW_CLASS_16_BITS             0x82CA
+#define GL_VIEW_CLASS_8_BITS              0x82CB
+#define GL_VIEW_CLASS_S3TC_DXT1_RGB       0x82CC
+#define GL_VIEW_CLASS_S3TC_DXT1_RGBA      0x82CD
+#define GL_VIEW_CLASS_S3TC_DXT3_RGBA      0x82CE
+#define GL_VIEW_CLASS_S3TC_DXT5_RGBA      0x82CF
+#define GL_VIEW_CLASS_RGTC1_RED           0x82D0
+#define GL_VIEW_CLASS_RGTC2_RG            0x82D1
+#define GL_VIEW_CLASS_BPTC_UNORM          0x82D2
+#define GL_VIEW_CLASS_BPTC_FLOAT          0x82D3
+#endif
+
+#ifndef GL_ARB_invalidate_subdata
+#endif
+
+#ifndef GL_ARB_multi_draw_indirect
+#endif
+
+#ifndef GL_ARB_program_interface_query
+#define GL_UNIFORM                        0x92E1
+#define GL_UNIFORM_BLOCK                  0x92E2
+#define GL_PROGRAM_INPUT                  0x92E3
+#define GL_PROGRAM_OUTPUT                 0x92E4
+#define GL_BUFFER_VARIABLE                0x92E5
+#define GL_SHADER_STORAGE_BLOCK           0x92E6
+/* reuse GL_ATOMIC_COUNTER_BUFFER */
+#define GL_VERTEX_SUBROUTINE              0x92E8
+#define GL_TESS_CONTROL_SUBROUTINE        0x92E9
+#define GL_TESS_EVALUATION_SUBROUTINE     0x92EA
+#define GL_GEOMETRY_SUBROUTINE            0x92EB
+#define GL_FRAGMENT_SUBROUTINE            0x92EC
+#define GL_COMPUTE_SUBROUTINE             0x92ED
+#define GL_VERTEX_SUBROUTINE_UNIFORM      0x92EE
+#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF
+#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0
+#define GL_GEOMETRY_SUBROUTINE_UNIFORM    0x92F1
+#define GL_FRAGMENT_SUBROUTINE_UNIFORM    0x92F2
+#define GL_COMPUTE_SUBROUTINE_UNIFORM     0x92F3
+#define GL_TRANSFORM_FEEDBACK_VARYING     0x92F4
+#define GL_ACTIVE_RESOURCES               0x92F5
+#define GL_MAX_NAME_LENGTH                0x92F6
+#define GL_MAX_NUM_ACTIVE_VARIABLES       0x92F7
+#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8
+#define GL_NAME_LENGTH                    0x92F9
+#define GL_TYPE                           0x92FA
+#define GL_ARRAY_SIZE                     0x92FB
+#define GL_OFFSET                         0x92FC
+#define GL_BLOCK_INDEX                    0x92FD
+#define GL_ARRAY_STRIDE                   0x92FE
+#define GL_MATRIX_STRIDE                  0x92FF
+#define GL_IS_ROW_MAJOR                   0x9300
+#define GL_ATOMIC_COUNTER_BUFFER_INDEX    0x9301
+#define GL_BUFFER_BINDING                 0x9302
+#define GL_BUFFER_DATA_SIZE               0x9303
+#define GL_NUM_ACTIVE_VARIABLES           0x9304
+#define GL_ACTIVE_VARIABLES               0x9305
+#define GL_REFERENCED_BY_VERTEX_SHADER    0x9306
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308
+#define GL_REFERENCED_BY_GEOMETRY_SHADER  0x9309
+#define GL_REFERENCED_BY_FRAGMENT_SHADER  0x930A
+#define GL_REFERENCED_BY_COMPUTE_SHADER   0x930B
+#define GL_TOP_LEVEL_ARRAY_SIZE           0x930C
+#define GL_TOP_LEVEL_ARRAY_STRIDE         0x930D
+#define GL_LOCATION                       0x930E
+#define GL_LOCATION_INDEX                 0x930F
+#define GL_IS_PER_PATCH                   0x92E7
+/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */
+/* reuse GL_COMPATIBLE_SUBROUTINES */
+#endif
+
+#ifndef GL_ARB_robust_buffer_access_behavior
+#endif
+
+#ifndef GL_ARB_shader_image_size
+#endif
+
+#ifndef GL_ARB_shader_storage_buffer_object
+#define GL_SHADER_STORAGE_BUFFER          0x90D2
+#define GL_SHADER_STORAGE_BUFFER_BINDING  0x90D3
+#define GL_SHADER_STORAGE_BUFFER_START    0x90D4
+#define GL_SHADER_STORAGE_BUFFER_SIZE     0x90D5
+#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9
+#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA
+#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB
+#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC
+#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD
+#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE  0x90DE
+#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF
+#define GL_SHADER_STORAGE_BARRIER_BIT     0x2000
+#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS
+/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */
+#endif
+
+#ifndef GL_ARB_stencil_texturing
+#define GL_DEPTH_STENCIL_TEXTURE_MODE     0x90EA
+#endif
+
+#ifndef GL_ARB_texture_buffer_range
+#define GL_TEXTURE_BUFFER_OFFSET          0x919D
+#define GL_TEXTURE_BUFFER_SIZE            0x919E
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F
+#endif
+
+#ifndef GL_ARB_texture_query_levels
+#endif
+
+#ifndef GL_ARB_texture_storage_multisample
+#endif
+
+#ifndef GL_ARB_texture_view
+#define GL_TEXTURE_VIEW_MIN_LEVEL         0x82DB
+#define GL_TEXTURE_VIEW_NUM_LEVELS        0x82DC
+#define GL_TEXTURE_VIEW_MIN_LAYER         0x82DD
+#define GL_TEXTURE_VIEW_NUM_LAYERS        0x82DE
+#define GL_TEXTURE_IMMUTABLE_LEVELS       0x82DF
+#endif
+
+#ifndef GL_ARB_vertex_attrib_binding
+#define GL_VERTEX_ATTRIB_BINDING          0x82D4
+#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET  0x82D5
+#define GL_VERTEX_BINDING_DIVISOR         0x82D6
+#define GL_VERTEX_BINDING_OFFSET          0x82D7
+#define GL_VERTEX_BINDING_STRIDE          0x82D8
+#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9
+#define GL_MAX_VERTEX_ATTRIB_BINDINGS     0x82DA
+#endif
+
+#ifndef GL_ARB_robustness_isolation
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_ABGR_EXT                       0x8000
+#endif
+
+#ifndef GL_EXT_blend_color
+#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
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_POLYGON_OFFSET_EXT             0x8037
+#define GL_POLYGON_OFFSET_FACTOR_EXT      0x8038
+#define GL_POLYGON_OFFSET_BIAS_EXT        0x8039
+#endif
+
+#ifndef GL_EXT_texture
+#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_TEXTURE_TOO_LARGE_EXT          0x8065
+#endif
+
+#ifndef GL_EXT_texture3D
+#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
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_FILTER4_SGIS                   0x8146
+#define GL_TEXTURE_FILTER4_SIZE_SGIS      0x8147
+#endif
+
+#ifndef GL_EXT_subtexture
+#endif
+
+#ifndef GL_EXT_copy_texture
+#endif
+
+#ifndef GL_EXT_histogram
+#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_TABLE_TOO_LARGE_EXT            0x8031
+#endif
+
+#ifndef GL_EXT_convolution
+#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
+#endif
+
+#ifndef GL_SGI_color_matrix
+#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
+#endif
+
+#ifndef GL_SGI_color_table
+#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
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#define GL_PIXEL_TEXTURE_SGIS             0x8353
+#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354
+#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355
+#define GL_PIXEL_GROUP_COLOR_SGIS         0x8356
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_PIXEL_TEX_GEN_SGIX             0x8139
+#define GL_PIXEL_TEX_GEN_MODE_SGIX        0x832B
+#endif
+
+#ifndef GL_SGIS_texture4D
+#define GL_PACK_SKIP_VOLUMES_SGIS         0x8130
+#define GL_PACK_IMAGE_DEPTH_SGIS          0x8131
+#define GL_UNPACK_SKIP_VOLUMES_SGIS       0x8132
+#define GL_UNPACK_IMAGE_DEPTH_SGIS        0x8133
+#define GL_TEXTURE_4D_SGIS                0x8134
+#define GL_PROXY_TEXTURE_4D_SGIS          0x8135
+#define GL_TEXTURE_4DSIZE_SGIS            0x8136
+#define GL_TEXTURE_WRAP_Q_SGIS            0x8137
+#define GL_MAX_4D_TEXTURE_SIZE_SGIS       0x8138
+#define GL_TEXTURE_4D_BINDING_SGIS        0x814F
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_TEXTURE_COLOR_TABLE_SGI        0x80BC
+#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI  0x80BD
+#endif
+
+#ifndef GL_EXT_cmyka
+#define GL_CMYK_EXT                       0x800C
+#define GL_CMYKA_EXT                      0x800D
+#define GL_PACK_CMYK_HINT_EXT             0x800E
+#define GL_UNPACK_CMYK_HINT_EXT           0x800F
+#endif
+
+#ifndef GL_EXT_texture_object
+#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
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_DETAIL_TEXTURE_2D_SGIS         0x8095
+#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096
+#define GL_LINEAR_DETAIL_SGIS             0x8097
+#define GL_LINEAR_DETAIL_ALPHA_SGIS       0x8098
+#define GL_LINEAR_DETAIL_COLOR_SGIS       0x8099
+#define GL_DETAIL_TEXTURE_LEVEL_SGIS      0x809A
+#define GL_DETAIL_TEXTURE_MODE_SGIS       0x809B
+#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_LINEAR_SHARPEN_SGIS            0x80AD
+#define GL_LINEAR_SHARPEN_ALPHA_SGIS      0x80AE
+#define GL_LINEAR_SHARPEN_COLOR_SGIS      0x80AF
+#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#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
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#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
+#endif
+
+#ifndef GL_SGIS_multisample
+#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
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_RESCALE_NORMAL_EXT             0x803A
+#endif
+
+#ifndef GL_EXT_vertex_array
+#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
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_GENERATE_MIPMAP_SGIS           0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS      0x8192
+#endif
+
+#ifndef GL_SGIX_clipmap
+#define GL_LINEAR_CLIPMAP_LINEAR_SGIX     0x8170
+#define GL_TEXTURE_CLIPMAP_CENTER_SGIX    0x8171
+#define GL_TEXTURE_CLIPMAP_FRAME_SGIX     0x8172
+#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX    0x8173
+#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174
+#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175
+#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX     0x8176
+#define GL_MAX_CLIPMAP_DEPTH_SGIX         0x8177
+#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178
+#define GL_NEAREST_CLIPMAP_NEAREST_SGIX   0x844D
+#define GL_NEAREST_CLIPMAP_LINEAR_SGIX    0x844E
+#define GL_LINEAR_CLIPMAP_NEAREST_SGIX    0x844F
+#endif
+
+#ifndef GL_SGIX_shadow
+#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
+#endif
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_CLAMP_TO_EDGE_SGIS             0x812F
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_SGIS           0x812D
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_FUNC_ADD_EXT                   0x8006
+#define GL_MIN_EXT                        0x8007
+#define GL_MAX_EXT                        0x8008
+#define GL_BLEND_EQUATION_EXT             0x8009
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_FUNC_SUBTRACT_EXT              0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_EXT      0x800B
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_INTERLACE_SGIX                 0x8094
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E
+#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F
+#define GL_PIXEL_TILE_WIDTH_SGIX          0x8140
+#define GL_PIXEL_TILE_HEIGHT_SGIX         0x8141
+#define GL_PIXEL_TILE_GRID_WIDTH_SGIX     0x8142
+#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX    0x8143
+#define GL_PIXEL_TILE_GRID_DEPTH_SGIX     0x8144
+#define GL_PIXEL_TILE_CACHE_SIZE_SGIX     0x8145
+#endif
+
+#ifndef GL_SGIS_texture_select
+#define GL_DUAL_ALPHA4_SGIS               0x8110
+#define GL_DUAL_ALPHA8_SGIS               0x8111
+#define GL_DUAL_ALPHA12_SGIS              0x8112
+#define GL_DUAL_ALPHA16_SGIS              0x8113
+#define GL_DUAL_LUMINANCE4_SGIS           0x8114
+#define GL_DUAL_LUMINANCE8_SGIS           0x8115
+#define GL_DUAL_LUMINANCE12_SGIS          0x8116
+#define GL_DUAL_LUMINANCE16_SGIS          0x8117
+#define GL_DUAL_INTENSITY4_SGIS           0x8118
+#define GL_DUAL_INTENSITY8_SGIS           0x8119
+#define GL_DUAL_INTENSITY12_SGIS          0x811A
+#define GL_DUAL_INTENSITY16_SGIS          0x811B
+#define GL_DUAL_LUMINANCE_ALPHA4_SGIS     0x811C
+#define GL_DUAL_LUMINANCE_ALPHA8_SGIS     0x811D
+#define GL_QUAD_ALPHA4_SGIS               0x811E
+#define GL_QUAD_ALPHA8_SGIS               0x811F
+#define GL_QUAD_LUMINANCE4_SGIS           0x8120
+#define GL_QUAD_LUMINANCE8_SGIS           0x8121
+#define GL_QUAD_INTENSITY4_SGIS           0x8122
+#define GL_QUAD_INTENSITY8_SGIS           0x8123
+#define GL_DUAL_TEXTURE_SELECT_SGIS       0x8124
+#define GL_QUAD_TEXTURE_SELECT_SGIS       0x8125
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SPRITE_SGIX                    0x8148
+#define GL_SPRITE_MODE_SGIX               0x8149
+#define GL_SPRITE_AXIS_SGIX               0x814A
+#define GL_SPRITE_TRANSLATION_SGIX        0x814B
+#define GL_SPRITE_AXIAL_SGIX              0x814C
+#define GL_SPRITE_OBJECT_ALIGNED_SGIX     0x814D
+#define GL_SPRITE_EYE_ALIGNED_SGIX        0x814E
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
+#endif
+
+#ifndef GL_EXT_point_parameters
+#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
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_POINT_SIZE_MIN_SGIS            0x8126
+#define GL_POINT_SIZE_MAX_SGIS            0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
+#define GL_DISTANCE_ATTENUATION_SGIS      0x8129
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180
+#define GL_INSTRUMENT_MEASUREMENTS_SGIX   0x8181
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#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
+#endif
+
+#ifndef GL_SGIX_framezoom
+#define GL_FRAMEZOOM_SGIX                 0x818B
+#define GL_FRAMEZOOM_FACTOR_SGIX          0x818C
+#define GL_MAX_FRAMEZOOM_FACTOR_SGIX      0x818D
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#endif
+
+#ifndef GL_FfdMaskSGIX
+#define GL_TEXTURE_DEFORMATION_BIT_SGIX   0x00000001
+#define GL_GEOMETRY_DEFORMATION_BIT_SGIX  0x00000002
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_GEOMETRY_DEFORMATION_SGIX      0x8194
+#define GL_TEXTURE_DEFORMATION_SGIX       0x8195
+#define GL_DEFORMATIONS_MASK_SGIX         0x8196
+#define GL_MAX_DEFORMATION_ORDER_SGIX     0x8197
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_REFERENCE_PLANE_SGIX           0x817D
+#define GL_REFERENCE_PLANE_EQUATION_SGIX  0x817E
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_DEPTH_COMPONENT16_SGIX         0x81A5
+#define GL_DEPTH_COMPONENT24_SGIX         0x81A6
+#define GL_DEPTH_COMPONENT32_SGIX         0x81A7
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_FOG_FUNC_SGIS                  0x812A
+#define GL_FOG_FUNC_POINTS_SGIS           0x812B
+#define GL_MAX_FOG_FUNC_POINTS_SGIS       0x812C
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_FOG_OFFSET_SGIX                0x8198
+#define GL_FOG_OFFSET_VALUE_SGIX          0x8199
+#endif
+
+#ifndef GL_HP_image_transform
+#define GL_IMAGE_SCALE_X_HP               0x8155
+#define GL_IMAGE_SCALE_Y_HP               0x8156
+#define GL_IMAGE_TRANSLATE_X_HP           0x8157
+#define GL_IMAGE_TRANSLATE_Y_HP           0x8158
+#define GL_IMAGE_ROTATE_ANGLE_HP          0x8159
+#define GL_IMAGE_ROTATE_ORIGIN_X_HP       0x815A
+#define GL_IMAGE_ROTATE_ORIGIN_Y_HP       0x815B
+#define GL_IMAGE_MAG_FILTER_HP            0x815C
+#define GL_IMAGE_MIN_FILTER_HP            0x815D
+#define GL_IMAGE_CUBIC_WEIGHT_HP          0x815E
+#define GL_CUBIC_HP                       0x815F
+#define GL_AVERAGE_HP                     0x8160
+#define GL_IMAGE_TRANSFORM_2D_HP          0x8161
+#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162
+#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#define GL_IGNORE_BORDER_HP               0x8150
+#define GL_CONSTANT_BORDER_HP             0x8151
+#define GL_REPLICATE_BORDER_HP            0x8153
+#define GL_CONVOLUTION_BORDER_COLOR_HP    0x8154
+#endif
+
+#ifndef GL_INGR_palette_buffer
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_TEXTURE_ENV_BIAS_SGIX          0x80BE
+#endif
+
+#ifndef GL_EXT_color_subtable
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_VERTEX_DATA_HINT_PGI           0x1A22A
+#define GL_VERTEX_CONSISTENT_HINT_PGI     0x1A22B
+#define GL_MATERIAL_SIDE_HINT_PGI         0x1A22C
+#define GL_MAX_VERTEX_HINT_PGI            0x1A22D
+#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_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_VERTEX23_BIT_PGI               0x00000004
+#define GL_VERTEX4_BIT_PGI                0x00000008
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PREFER_DOUBLEBUFFER_HINT_PGI   0x1A1F8
+#define GL_CONSERVE_MEMORY_HINT_PGI       0x1A1FD
+#define GL_RECLAIM_MEMORY_HINT_PGI        0x1A1FE
+#define GL_NATIVE_GRAPHICS_HANDLE_PGI     0x1A202
+#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203
+#define GL_NATIVE_GRAPHICS_END_HINT_PGI   0x1A204
+#define GL_ALWAYS_FAST_HINT_PGI           0x1A20C
+#define GL_ALWAYS_SOFT_HINT_PGI           0x1A20D
+#define GL_ALLOW_DRAW_OBJ_HINT_PGI        0x1A20E
+#define GL_ALLOW_DRAW_WIN_HINT_PGI        0x1A20F
+#define GL_ALLOW_DRAW_FRG_HINT_PGI        0x1A210
+#define GL_ALLOW_DRAW_MEM_HINT_PGI        0x1A211
+#define GL_STRICT_DEPTHFUNC_HINT_PGI      0x1A216
+#define GL_STRICT_LIGHTING_HINT_PGI       0x1A217
+#define GL_STRICT_SCISSOR_HINT_PGI        0x1A218
+#define GL_FULL_STIPPLE_HINT_PGI          0x1A219
+#define GL_CLIP_NEAR_HINT_PGI             0x1A220
+#define GL_CLIP_FAR_HINT_PGI              0x1A221
+#define GL_WIDE_LINE_HINT_PGI             0x1A222
+#define GL_BACK_NORMALS_HINT_PGI          0x1A223
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#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
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT  0x80F0
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_LIST_PRIORITY_SGIX             0x8182
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_IR_INSTRUMENT1_SGIX            0x817F
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_CALLIGRAPHIC_FRAGMENT_SGIX     0x8183
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#define GL_TEXTURE_LOD_BIAS_S_SGIX        0x818E
+#define GL_TEXTURE_LOD_BIAS_T_SGIX        0x818F
+#define GL_TEXTURE_LOD_BIAS_R_SGIX        0x8190
+#endif
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SHADOW_AMBIENT_SGIX            0x80BF
+#endif
+
+#ifndef GL_EXT_index_texture
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_INDEX_MATERIAL_EXT             0x81B8
+#define GL_INDEX_MATERIAL_PARAMETER_EXT   0x81B9
+#define GL_INDEX_MATERIAL_FACE_EXT        0x81BA
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_INDEX_TEST_EXT                 0x81B5
+#define GL_INDEX_TEST_FUNC_EXT            0x81B6
+#define GL_INDEX_TEST_REF_EXT             0x81B7
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#define GL_IUI_V2F_EXT                    0x81AD
+#define GL_IUI_V3F_EXT                    0x81AE
+#define GL_IUI_N3F_V2F_EXT                0x81AF
+#define GL_IUI_N3F_V3F_EXT                0x81B0
+#define GL_T2F_IUI_V2F_EXT                0x81B1
+#define GL_T2F_IUI_V3F_EXT                0x81B2
+#define GL_T2F_IUI_N3F_V2F_EXT            0x81B3
+#define GL_T2F_IUI_N3F_V3F_EXT            0x81B4
+#endif
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT   0x81A8
+#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT   0x81A9
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_CULL_VERTEX_EXT                0x81AA
+#define GL_CULL_VERTEX_EYE_POSITION_EXT   0x81AB
+#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_YCRCB_422_SGIX                 0x81BB
+#define GL_YCRCB_444_SGIX                 0x81BC
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_FRAGMENT_LIGHTING_SGIX         0x8400
+#define GL_FRAGMENT_COLOR_MATERIAL_SGIX   0x8401
+#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402
+#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403
+#define GL_MAX_FRAGMENT_LIGHTS_SGIX       0x8404
+#define GL_MAX_ACTIVE_LIGHTS_SGIX         0x8405
+#define GL_CURRENT_RASTER_NORMAL_SGIX     0x8406
+#define GL_LIGHT_ENV_MODE_SGIX            0x8407
+#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408
+#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409
+#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A
+#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B
+#define GL_FRAGMENT_LIGHT0_SGIX           0x840C
+#define GL_FRAGMENT_LIGHT1_SGIX           0x840D
+#define GL_FRAGMENT_LIGHT2_SGIX           0x840E
+#define GL_FRAGMENT_LIGHT3_SGIX           0x840F
+#define GL_FRAGMENT_LIGHT4_SGIX           0x8410
+#define GL_FRAGMENT_LIGHT5_SGIX           0x8411
+#define GL_FRAGMENT_LIGHT6_SGIX           0x8412
+#define GL_FRAGMENT_LIGHT7_SGIX           0x8413
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_RASTER_POSITION_UNCLIPPED_IBM  0x19262
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_TEXTURE_LIGHTING_MODE_HP       0x8167
+#define GL_TEXTURE_POST_SPECULAR_HP       0x8168
+#define GL_TEXTURE_PRE_SPECULAR_HP        0x8169
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_MAX_ELEMENTS_VERTICES_EXT      0x80E8
+#define GL_MAX_ELEMENTS_INDICES_EXT       0x80E9
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_PHONG_WIN                      0x80EA
+#define GL_PHONG_HINT_WIN                 0x80EB
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_FOG_SPECULAR_TEXTURE_WIN       0x80EC
+#endif
+
+#ifndef GL_EXT_light_texture
+#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
+/* reuse GL_FRAGMENT_DEPTH_EXT */
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_ALPHA_MIN_SGIX                 0x8320
+#define GL_ALPHA_MAX_SGIX                 0x8321
+#endif
+
+#ifndef GL_SGIX_impact_pixel_texture
+#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX   0x8184
+#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX     0x8185
+#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX     0x8186
+#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187
+#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188
+#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX    0x8189
+#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX    0x818A
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_BGR_EXT                        0x80E0
+#define GL_BGRA_EXT                       0x80E1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_ASYNC_MARKER_SGIX              0x8329
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#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
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_ASYNC_HISTOGRAM_SGIX           0x832C
+#define GL_MAX_ASYNC_HISTOGRAM_SGIX       0x832D
+#endif
+
+#ifndef GL_INTEL_texture_scissor
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#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
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_OCCLUSION_TEST_HP              0x8165
+#define GL_OCCLUSION_TEST_RESULT_HP       0x8166
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#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
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_SHARED_TEXTURE_PALETTE_EXT     0x81FB
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT  0x81F8
+#define GL_SINGLE_COLOR_EXT               0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR_EXT    0x81FA
+#endif
+
+#ifndef GL_EXT_secondary_color
+#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
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_PERTURB_EXT                    0x85AE
+#define GL_TEXTURE_NORMAL_EXT             0x85AF
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#endif
+
+#ifndef GL_EXT_fog_coord
+#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
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_SCREEN_COORDINATES_REND        0x8490
+#define GL_INVERTED_SCREEN_W_REND         0x8491
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#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
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#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
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_TRANSFORM_HINT_APPLE           0x85B1
+#endif
+
+#ifndef GL_SGIX_fog_scale
+#define GL_FOG_SCALE_SGIX                 0x81FC
+#define GL_FOG_SCALE_VALUE_SGIX           0x81FD
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_UNPACK_CONSTANT_DATA_SUNX      0x81D5
+#define GL_TEXTURE_CONSTANT_DATA_SUNX     0x81D6
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_GLOBAL_ALPHA_SUN               0x81D9
+#define GL_GLOBAL_ALPHA_FACTOR_SUN        0x81DA
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_RESTART_SUN                    0x0001
+#define GL_REPLACE_MIDDLE_SUN             0x0002
+#define GL_REPLACE_OLDEST_SUN             0x0003
+#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
+#endif
+
+#ifndef GL_SUN_vertex
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#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
+#endif
+
+#ifndef GL_INGR_color_clamp
+#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
+#endif
+
+#ifndef GL_INGR_interlace_read
+#define GL_INTERLACE_READ_INGR            0x8568
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_INCR_WRAP_EXT                  0x8507
+#define GL_DECR_WRAP_EXT                  0x8508
+#endif
+
+#ifndef GL_EXT_422_pixels
+#define GL_422_EXT                        0x80CC
+#define GL_422_REV_EXT                    0x80CD
+#define GL_422_AVERAGE_EXT                0x80CE
+#define GL_422_REV_AVERAGE_EXT            0x80CF
+#endif
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NORMAL_MAP_NV                  0x8511
+#define GL_REFLECTION_MAP_NV              0x8512
+#endif
+
+#ifndef GL_EXT_texture_cube_map
+#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
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_WRAP_BORDER_SUN                0x81D4
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT       0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT     0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT           0x8501
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_MODELVIEW0_STACK_DEPTH_EXT     GL_MODELVIEW_STACK_DEPTH
+#define GL_MODELVIEW1_STACK_DEPTH_EXT     0x8502
+#define GL_MODELVIEW0_MATRIX_EXT          GL_MODELVIEW_MATRIX
+#define GL_MODELVIEW1_MATRIX_EXT          0x8506
+#define GL_VERTEX_WEIGHTING_EXT           0x8509
+#define GL_MODELVIEW0_EXT                 GL_MODELVIEW
+#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
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_MAX_SHININESS_NV               0x8504
+#define GL_MAX_SPOT_EXPONENT_NV           0x8505
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#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
+#endif
+
+#ifndef GL_NV_register_combiners
+#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
+/* reuse GL_TEXTURE0_ARB */
+/* reuse GL_TEXTURE1_ARB */
+/* reuse GL_ZERO */
+/* reuse GL_NONE */
+/* reuse GL_FOG */
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_FOG_DISTANCE_MODE_NV           0x855A
+#define GL_EYE_RADIAL_NV                  0x855B
+#define GL_EYE_PLANE_ABSOLUTE_NV          0x855C
+/* reuse GL_EYE_PLANE */
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_EMBOSS_LIGHT_NV                0x855D
+#define GL_EMBOSS_CONSTANT_NV             0x855E
+#define GL_EMBOSS_MAP_NV                  0x855F
+#endif
+
+#ifndef GL_NV_blend_square
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#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
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#endif
+
+#ifndef GL_MESA_window_pos
+#endif
+
+#ifndef GL_EXT_texture_compression_s3tc
+#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
+#endif
+
+#ifndef GL_IBM_cull_vertex
+#define GL_CULL_VERTEX_IBM                103050
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#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
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_PACK_SUBSAMPLE_RATE_SGIX       0x85A0
+#define GL_UNPACK_SUBSAMPLE_RATE_SGIX     0x85A1
+#define GL_PIXEL_SUBSAMPLE_4444_SGIX      0x85A2
+#define GL_PIXEL_SUBSAMPLE_2424_SGIX      0x85A3
+#define GL_PIXEL_SUBSAMPLE_4242_SGIX      0x85A4
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_YCRCB_SGIX                     0x8318
+#define GL_YCRCBA_SGIX                    0x8319
+#endif
+
+#ifndef GL_SGI_depth_pass_instrument
+#define GL_DEPTH_PASS_INSTRUMENT_SGIX     0x8310
+#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311
+#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_COMPRESSED_RGB_FXT1_3DFX       0x86B0
+#define GL_COMPRESSED_RGBA_FXT1_3DFX      0x86B1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_MULTISAMPLE_3DFX               0x86B2
+#define GL_SAMPLE_BUFFERS_3DFX            0x86B3
+#define GL_SAMPLES_3DFX                   0x86B4
+#define GL_MULTISAMPLE_BIT_3DFX           0x20000000
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#endif
+
+#ifndef GL_EXT_multisample
+#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
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_VERTEX_PRECLIP_SGIX            0x83EE
+#define GL_VERTEX_PRECLIP_HINT_SGIX       0x83EF
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_CONVOLUTION_HINT_SGIX          0x8316
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_PACK_RESAMPLE_SGIX             0x842C
+#define GL_UNPACK_RESAMPLE_SGIX           0x842D
+#define GL_RESAMPLE_REPLICATE_SGIX        0x842E
+#define GL_RESAMPLE_ZERO_FILL_SGIX        0x842F
+#define GL_RESAMPLE_DECIMATE_SGIX         0x8430
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_EYE_DISTANCE_TO_POINT_SGIS     0x81F0
+#define GL_OBJECT_DISTANCE_TO_POINT_SGIS  0x81F1
+#define GL_EYE_DISTANCE_TO_LINE_SGIS      0x81F2
+#define GL_OBJECT_DISTANCE_TO_LINE_SGIS   0x81F3
+#define GL_EYE_POINT_SGIS                 0x81F4
+#define GL_OBJECT_POINT_SGIS              0x81F5
+#define GL_EYE_LINE_SGIS                  0x81F6
+#define GL_OBJECT_LINE_SGIS               0x81F7
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_TEXTURE_COLOR_WRITEMASK_SGIS   0x81EF
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_DOT3_RGB_EXT                   0x8740
+#define GL_DOT3_RGBA_EXT                  0x8741
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_MIRROR_CLAMP_ATI               0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_ATI       0x8743
+#endif
+
+#ifndef GL_NV_fence
+#define GL_ALL_COMPLETED_NV               0x84F2
+#define GL_FENCE_STATUS_NV                0x84F3
+#define GL_FENCE_CONDITION_NV             0x84F4
+#endif
+
+#ifndef GL_IBM_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_IBM            0x8370
+#endif
+
+#ifndef GL_NV_evaluators
+#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
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_DEPTH_STENCIL_NV               0x84F9
+#define GL_UNSIGNED_INT_24_8_NV           0x84FA
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_PER_STAGE_CONSTANTS_NV         0x8535
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#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
+#endif
+
+#ifndef GL_NV_texture_shader
+#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_OFFSET_TEXTURE_2D_MATRIX_NV    GL_OFFSET_TEXTURE_MATRIX_NV
+#define GL_OFFSET_TEXTURE_2D_SCALE_NV     GL_OFFSET_TEXTURE_SCALE_NV
+#define GL_OFFSET_TEXTURE_2D_BIAS_NV      GL_OFFSET_TEXTURE_BIAS_NV
+#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
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_DOT_PRODUCT_TEXTURE_3D_NV      0x86EF
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533
+#endif
+
+#ifndef GL_NV_vertex_program
+#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
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_TEXTURE_MAX_CLAMP_S_SGIX       0x8369
+#define GL_TEXTURE_MAX_CLAMP_T_SGIX       0x836A
+#define GL_TEXTURE_MAX_CLAMP_R_SGIX       0x836B
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SCALEBIAS_HINT_SGIX            0x8322
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_INTERLACE_OML                  0x8980
+#define GL_INTERLACE_READ_OML             0x8981
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_FORMAT_SUBSAMPLE_24_24_OML     0x8982
+#define GL_FORMAT_SUBSAMPLE_244_244_OML   0x8983
+#endif
+
+#ifndef GL_OML_resample
+#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
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_DEPTH_STENCIL_TO_RGBA_NV       0x886E
+#define GL_DEPTH_STENCIL_TO_BGRA_NV       0x886F
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#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
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#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_REG_6_ATI                      0x8927
+#define GL_REG_7_ATI                      0x8928
+#define GL_REG_8_ATI                      0x8929
+#define GL_REG_9_ATI                      0x892A
+#define GL_REG_10_ATI                     0x892B
+#define GL_REG_11_ATI                     0x892C
+#define GL_REG_12_ATI                     0x892D
+#define GL_REG_13_ATI                     0x892E
+#define GL_REG_14_ATI                     0x892F
+#define GL_REG_15_ATI                     0x8930
+#define GL_REG_16_ATI                     0x8931
+#define GL_REG_17_ATI                     0x8932
+#define GL_REG_18_ATI                     0x8933
+#define GL_REG_19_ATI                     0x8934
+#define GL_REG_20_ATI                     0x8935
+#define GL_REG_21_ATI                     0x8936
+#define GL_REG_22_ATI                     0x8937
+#define GL_REG_23_ATI                     0x8938
+#define GL_REG_24_ATI                     0x8939
+#define GL_REG_25_ATI                     0x893A
+#define GL_REG_26_ATI                     0x893B
+#define GL_REG_27_ATI                     0x893C
+#define GL_REG_28_ATI                     0x893D
+#define GL_REG_29_ATI                     0x893E
+#define GL_REG_30_ATI                     0x893F
+#define GL_REG_31_ATI                     0x8940
+#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_CON_8_ATI                      0x8949
+#define GL_CON_9_ATI                      0x894A
+#define GL_CON_10_ATI                     0x894B
+#define GL_CON_11_ATI                     0x894C
+#define GL_CON_12_ATI                     0x894D
+#define GL_CON_13_ATI                     0x894E
+#define GL_CON_14_ATI                     0x894F
+#define GL_CON_15_ATI                     0x8950
+#define GL_CON_16_ATI                     0x8951
+#define GL_CON_17_ATI                     0x8952
+#define GL_CON_18_ATI                     0x8953
+#define GL_CON_19_ATI                     0x8954
+#define GL_CON_20_ATI                     0x8955
+#define GL_CON_21_ATI                     0x8956
+#define GL_CON_22_ATI                     0x8957
+#define GL_CON_23_ATI                     0x8958
+#define GL_CON_24_ATI                     0x8959
+#define GL_CON_25_ATI                     0x895A
+#define GL_CON_26_ATI                     0x895B
+#define GL_CON_27_ATI                     0x895C
+#define GL_CON_28_ATI                     0x895D
+#define GL_CON_29_ATI                     0x895E
+#define GL_CON_30_ATI                     0x895F
+#define GL_CON_31_ATI                     0x8960
+#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_RED_BIT_ATI                    0x00000001
+#define GL_GREEN_BIT_ATI                  0x00000002
+#define GL_BLUE_BIT_ATI                   0x00000004
+#define GL_2X_BIT_ATI                     0x00000001
+#define GL_4X_BIT_ATI                     0x00000002
+#define GL_8X_BIT_ATI                     0x00000004
+#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_COMP_BIT_ATI                   0x00000002
+#define GL_NEGATE_BIT_ATI                 0x00000004
+#define GL_BIAS_BIT_ATI                   0x00000008
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#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
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#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
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#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_LOCAL_CONSTANTS_EXT 0x87CC
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_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
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_MAX_VERTEX_STREAMS_ATI         0x876B
+#define GL_VERTEX_STREAM0_ATI             0x876C
+#define GL_VERTEX_STREAM1_ATI             0x876D
+#define GL_VERTEX_STREAM2_ATI             0x876E
+#define GL_VERTEX_STREAM3_ATI             0x876F
+#define GL_VERTEX_STREAM4_ATI             0x8770
+#define GL_VERTEX_STREAM5_ATI             0x8771
+#define GL_VERTEX_STREAM6_ATI             0x8772
+#define GL_VERTEX_STREAM7_ATI             0x8773
+#define GL_VERTEX_SOURCE_ATI              0x8774
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ELEMENT_ARRAY_ATI              0x8768
+#define GL_ELEMENT_ARRAY_TYPE_ATI         0x8769
+#define GL_ELEMENT_ARRAY_POINTER_ATI      0x876A
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_QUAD_MESH_SUN                  0x8614
+#define GL_TRIANGLE_MESH_SUN              0x8615
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SLICE_ACCUM_SUN                0x85CC
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_MULTISAMPLE_FILTER_HINT_NV     0x8534
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_DEPTH_CLAMP_NV                 0x864F
+#endif
+
+#ifndef GL_NV_occlusion_query
+#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
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_POINT_SPRITE_NV                0x8861
+#define GL_COORD_REPLACE_NV               0x8862
+#define GL_POINT_SPRITE_R_MODE_NV         0x8863
+#endif
+
+#ifndef GL_NV_texture_shader3
+#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
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_STENCIL_TEST_TWO_SIDE_EXT      0x8910
+#define GL_ACTIVE_STENCIL_FACE_EXT        0x8911
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_TEXT_FRAGMENT_SHADER_ATI       0x8200
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_UNPACK_CLIENT_STORAGE_APPLE    0x85B2
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_ELEMENT_ARRAY_APPLE            0x8A0C
+#define GL_ELEMENT_ARRAY_TYPE_APPLE       0x8A0D
+#define GL_ELEMENT_ARRAY_POINTER_APPLE    0x8A0E
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_DRAW_PIXELS_APPLE              0x8A0A
+#define GL_FENCE_APPLE                    0x8A0B
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING_APPLE     0x85B5
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#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_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521
+#define GL_STORAGE_CLIENT_APPLE           0x85B4
+#define GL_STORAGE_CACHED_APPLE           0x85BE
+#define GL_STORAGE_SHARED_APPLE           0x85BF
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_YCBCR_422_APPLE                0x85B9
+#define GL_UNSIGNED_SHORT_8_8_APPLE       0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE   0x85BB
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_RGB_S3TC                       0x83A0
+#define GL_RGB4_S3TC                      0x83A1
+#define GL_RGBA_S3TC                      0x83A2
+#define GL_RGBA4_S3TC                     0x83A3
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#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
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_TYPE_RGBA_FLOAT_ATI            0x8820
+#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_MODULATE_ADD_ATI               0x8744
+#define GL_MODULATE_SIGNED_ADD_ATI        0x8745
+#define GL_MODULATE_SUBTRACT_ATI          0x8746
+#endif
+
+#ifndef GL_ATI_texture_float
+#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
+#endif
+
+#ifndef GL_NV_float_buffer
+#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
+#endif
+
+#ifndef GL_NV_fragment_program
+#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
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_HALF_FLOAT_NV                  0x140B
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#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
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_PRIMITIVE_RESTART_NV           0x8558
+#define GL_PRIMITIVE_RESTART_INDEX_NV     0x8559
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F
+#endif
+
+#ifndef GL_NV_vertex_program2
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#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
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_DEPTH_BOUNDS_TEST_EXT          0x8890
+#define GL_DEPTH_BOUNDS_EXT               0x8891
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_MIRROR_CLAMP_EXT               0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT       0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT     0x8912
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_BLEND_EQUATION_RGB_EXT         0x8009
+#define GL_BLEND_EQUATION_ALPHA_EXT       0x883D
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_PACK_INVERT_MESA               0x8758
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_UNSIGNED_SHORT_8_8_MESA        0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_MESA    0x85BB
+#define GL_YCBCR_MESA                     0x8757
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#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
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#endif
+
+#ifndef GL_NV_fragment_program2
+#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
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */
+#endif
+
+#ifndef GL_NV_vertex_program3
+/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#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
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#endif
+
+#ifndef GL_EXT_packed_depth_stencil
+#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
+#endif
+
+#ifndef GL_EXT_stencil_clear_tag
+#define GL_STENCIL_TAG_BITS_EXT           0x88F2
+#define GL_STENCIL_CLEAR_TAG_VALUE_EXT    0x88F3
+#endif
+
+#ifndef GL_EXT_texture_sRGB
+#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
+#endif
+
+#ifndef GL_EXT_framebuffer_blit
+#define GL_READ_FRAMEBUFFER_EXT           0x8CA8
+#define GL_DRAW_FRAMEBUFFER_EXT           0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_EXT   GL_FRAMEBUFFER_BINDING_EXT
+#define GL_READ_FRAMEBUFFER_BINDING_EXT   0x8CAA
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_RENDERBUFFER_SAMPLES_EXT       0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT                0x8D57
+#endif
+
+#ifndef GL_MESAX_texture_stack
+#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
+#endif
+
+#ifndef GL_EXT_timer_query
+#define GL_TIME_ELAPSED_EXT               0x88BF
+#endif
+
+#ifndef GL_EXT_gpu_program_parameters
+#endif
+
+#ifndef GL_APPLE_flush_buffer_range
+#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12
+#define GL_BUFFER_FLUSHING_UNMAP_APPLE    0x8A13
+#endif
+
+#ifndef GL_NV_gpu_program4
+#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV    0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV    0x8905
+#define GL_PROGRAM_ATTRIB_COMPONENTS_NV   0x8906
+#define GL_PROGRAM_RESULT_COMPONENTS_NV   0x8907
+#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908
+#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909
+#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5
+#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6
+#endif
+
+#ifndef GL_NV_geometry_program4
+#define GL_LINES_ADJACENCY_EXT            0x000A
+#define GL_LINE_STRIP_ADJACENCY_EXT       0x000B
+#define GL_TRIANGLES_ADJACENCY_EXT        0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT   0x000D
+#define GL_GEOMETRY_PROGRAM_NV            0x8C26
+#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27
+#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28
+#define GL_GEOMETRY_VERTICES_OUT_EXT      0x8DDA
+#define GL_GEOMETRY_INPUT_TYPE_EXT        0x8DDB
+#define GL_GEOMETRY_OUTPUT_TYPE_EXT       0x8DDC
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
+#define GL_PROGRAM_POINT_SIZE_EXT         0x8642
+#endif
+
+#ifndef GL_EXT_geometry_shader4
+#define GL_GEOMETRY_SHADER_EXT            0x8DD9
+/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */
+/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */
+/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */
+/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE
+#define GL_MAX_VARYING_COMPONENTS_EXT     0x8B4B
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+/* reuse GL_LINES_ADJACENCY_EXT */
+/* reuse GL_LINE_STRIP_ADJACENCY_EXT */
+/* reuse GL_TRIANGLES_ADJACENCY_EXT */
+/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+/* reuse GL_PROGRAM_POINT_SIZE_EXT */
+#endif
+
+#ifndef GL_NV_vertex_program4
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD
+#endif
+
+#ifndef GL_EXT_gpu_shader4
+#define GL_SAMPLER_1D_ARRAY_EXT           0x8DC0
+#define GL_SAMPLER_2D_ARRAY_EXT           0x8DC1
+#define GL_SAMPLER_BUFFER_EXT             0x8DC2
+#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT    0x8DC3
+#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT    0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW_EXT        0x8DC5
+#define GL_UNSIGNED_INT_VEC2_EXT          0x8DC6
+#define GL_UNSIGNED_INT_VEC3_EXT          0x8DC7
+#define GL_UNSIGNED_INT_VEC4_EXT          0x8DC8
+#define GL_INT_SAMPLER_1D_EXT             0x8DC9
+#define GL_INT_SAMPLER_2D_EXT             0x8DCA
+#define GL_INT_SAMPLER_3D_EXT             0x8DCB
+#define GL_INT_SAMPLER_CUBE_EXT           0x8DCC
+#define GL_INT_SAMPLER_2D_RECT_EXT        0x8DCD
+#define GL_INT_SAMPLER_1D_ARRAY_EXT       0x8DCE
+#define GL_INT_SAMPLER_2D_ARRAY_EXT       0x8DCF
+#define GL_INT_SAMPLER_BUFFER_EXT         0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_1D_EXT    0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_2D_EXT    0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D_EXT    0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT  0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#endif
+
+#ifndef GL_EXT_draw_instanced
+#endif
+
+#ifndef GL_EXT_packed_float
+#define GL_R11F_G11F_B10F_EXT             0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B
+#define GL_RGBA_SIGNED_COMPONENTS_EXT     0x8C3C
+#endif
+
+#ifndef GL_EXT_texture_array
+#define GL_TEXTURE_1D_ARRAY_EXT           0x8C18
+#define GL_PROXY_TEXTURE_1D_ARRAY_EXT     0x8C19
+#define GL_TEXTURE_2D_ARRAY_EXT           0x8C1A
+#define GL_PROXY_TEXTURE_2D_ARRAY_EXT     0x8C1B
+#define GL_TEXTURE_BINDING_1D_ARRAY_EXT   0x8C1C
+#define GL_TEXTURE_BINDING_2D_ARRAY_EXT   0x8C1D
+#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT   0x88FF
+#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+#endif
+
+#ifndef GL_EXT_texture_buffer_object
+#define GL_TEXTURE_BUFFER_EXT             0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT    0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_EXT     0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT_EXT      0x8C2E
+#endif
+
+#ifndef GL_EXT_texture_compression_latc
+#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70
+#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71
+#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72
+#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73
+#endif
+
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_COMPRESSED_RED_RGTC1_EXT       0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
+#endif
+
+#ifndef GL_EXT_texture_shared_exponent
+#define GL_RGB9_E5_EXT                    0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT   0x8C3E
+#define GL_TEXTURE_SHARED_SIZE_EXT        0x8C3F
+#endif
+
+#ifndef GL_NV_depth_buffer_float
+#define GL_DEPTH_COMPONENT32F_NV          0x8DAB
+#define GL_DEPTH32F_STENCIL8_NV           0x8DAC
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD
+#define GL_DEPTH_BUFFER_FLOAT_MODE_NV     0x8DAF
+#endif
+
+#ifndef GL_NV_fragment_program4
+#endif
+
+#ifndef GL_NV_framebuffer_multisample_coverage
+#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB
+#define GL_RENDERBUFFER_COLOR_SAMPLES_NV  0x8E10
+#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
+#define GL_MULTISAMPLE_COVERAGE_MODES_NV  0x8E12
+#endif
+
+#ifndef GL_EXT_framebuffer_sRGB
+#define GL_FRAMEBUFFER_SRGB_EXT           0x8DB9
+#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT   0x8DBA
+#endif
+
+#ifndef GL_NV_geometry_shader4
+#endif
+
+#ifndef GL_NV_parameter_buffer_object
+#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0
+#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1
+#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2
+#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3
+#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4
+#endif
+
+#ifndef GL_EXT_draw_buffers2
+#endif
+
+#ifndef GL_NV_transform_feedback
+#define GL_BACK_PRIMARY_COLOR_NV          0x8C77
+#define GL_BACK_SECONDARY_COLOR_NV        0x8C78
+#define GL_TEXTURE_COORD_NV               0x8C79
+#define GL_CLIP_DISTANCE_NV               0x8C7A
+#define GL_VERTEX_ID_NV                   0x8C7B
+#define GL_PRIMITIVE_ID_NV                0x8C7C
+#define GL_GENERIC_ATTRIB_NV              0x8C7D
+#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV  0x8C7E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80
+#define GL_ACTIVE_VARYINGS_NV             0x8C81
+#define GL_ACTIVE_VARYING_MAX_LENGTH_NV   0x8C82
+#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85
+#define GL_TRANSFORM_FEEDBACK_RECORD_NV   0x8C86
+#define GL_PRIMITIVES_GENERATED_NV        0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88
+#define GL_RASTERIZER_DISCARD_NV          0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS_NV         0x8C8C
+#define GL_SEPARATE_ATTRIBS_NV            0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER_NV   0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F
+#define GL_LAYER_NV                       0x8DAA
+#define GL_NEXT_BUFFER_NV                 -2
+#define GL_SKIP_COMPONENTS4_NV            -3
+#define GL_SKIP_COMPONENTS3_NV            -4
+#define GL_SKIP_COMPONENTS2_NV            -5
+#define GL_SKIP_COMPONENTS1_NV            -6
+#endif
+
+#ifndef GL_EXT_bindable_uniform
+#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2
+#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3
+#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4
+#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT  0x8DED
+#define GL_UNIFORM_BUFFER_EXT             0x8DEE
+#define GL_UNIFORM_BUFFER_BINDING_EXT     0x8DEF
+#endif
+
+#ifndef GL_EXT_texture_integer
+#define GL_RGBA32UI_EXT                   0x8D70
+#define GL_RGB32UI_EXT                    0x8D71
+#define GL_ALPHA32UI_EXT                  0x8D72
+#define GL_INTENSITY32UI_EXT              0x8D73
+#define GL_LUMINANCE32UI_EXT              0x8D74
+#define GL_LUMINANCE_ALPHA32UI_EXT        0x8D75
+#define GL_RGBA16UI_EXT                   0x8D76
+#define GL_RGB16UI_EXT                    0x8D77
+#define GL_ALPHA16UI_EXT                  0x8D78
+#define GL_INTENSITY16UI_EXT              0x8D79
+#define GL_LUMINANCE16UI_EXT              0x8D7A
+#define GL_LUMINANCE_ALPHA16UI_EXT        0x8D7B
+#define GL_RGBA8UI_EXT                    0x8D7C
+#define GL_RGB8UI_EXT                     0x8D7D
+#define GL_ALPHA8UI_EXT                   0x8D7E
+#define GL_INTENSITY8UI_EXT               0x8D7F
+#define GL_LUMINANCE8UI_EXT               0x8D80
+#define GL_LUMINANCE_ALPHA8UI_EXT         0x8D81
+#define GL_RGBA32I_EXT                    0x8D82
+#define GL_RGB32I_EXT                     0x8D83
+#define GL_ALPHA32I_EXT                   0x8D84
+#define GL_INTENSITY32I_EXT               0x8D85
+#define GL_LUMINANCE32I_EXT               0x8D86
+#define GL_LUMINANCE_ALPHA32I_EXT         0x8D87
+#define GL_RGBA16I_EXT                    0x8D88
+#define GL_RGB16I_EXT                     0x8D89
+#define GL_ALPHA16I_EXT                   0x8D8A
+#define GL_INTENSITY16I_EXT               0x8D8B
+#define GL_LUMINANCE16I_EXT               0x8D8C
+#define GL_LUMINANCE_ALPHA16I_EXT         0x8D8D
+#define GL_RGBA8I_EXT                     0x8D8E
+#define GL_RGB8I_EXT                      0x8D8F
+#define GL_ALPHA8I_EXT                    0x8D90
+#define GL_INTENSITY8I_EXT                0x8D91
+#define GL_LUMINANCE8I_EXT                0x8D92
+#define GL_LUMINANCE_ALPHA8I_EXT          0x8D93
+#define GL_RED_INTEGER_EXT                0x8D94
+#define GL_GREEN_INTEGER_EXT              0x8D95
+#define GL_BLUE_INTEGER_EXT               0x8D96
+#define GL_ALPHA_INTEGER_EXT              0x8D97
+#define GL_RGB_INTEGER_EXT                0x8D98
+#define GL_RGBA_INTEGER_EXT               0x8D99
+#define GL_BGR_INTEGER_EXT                0x8D9A
+#define GL_BGRA_INTEGER_EXT               0x8D9B
+#define GL_LUMINANCE_INTEGER_EXT          0x8D9C
+#define GL_LUMINANCE_ALPHA_INTEGER_EXT    0x8D9D
+#define GL_RGBA_INTEGER_MODE_EXT          0x8D9E
+#endif
+
+#ifndef GL_GREMEDY_frame_terminator
+#endif
+
+#ifndef GL_NV_conditional_render
+#define GL_QUERY_WAIT_NV                  0x8E13
+#define GL_QUERY_NO_WAIT_NV               0x8E14
+#define GL_QUERY_BY_REGION_WAIT_NV        0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT_NV     0x8E16
+#endif
+
+#ifndef GL_NV_present_video
+#define GL_FRAME_NV                       0x8E26
+#define GL_FIELDS_NV                      0x8E27
+#define GL_CURRENT_TIME_NV                0x8E28
+#define GL_NUM_FILL_STREAMS_NV            0x8E29
+#define GL_PRESENT_TIME_NV                0x8E2A
+#define GL_PRESENT_DURATION_NV            0x8E2B
+#endif
+
+#ifndef GL_EXT_transform_feedback
+#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT  0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F
+#define GL_INTERLEAVED_ATTRIBS_EXT        0x8C8C
+#define GL_SEPARATE_ATTRIBS_EXT           0x8C8D
+#define GL_PRIMITIVES_GENERATED_EXT       0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88
+#define GL_RASTERIZER_DISCARD_EXT         0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76
+#endif
+
+#ifndef GL_EXT_direct_state_access
+#define GL_PROGRAM_MATRIX_EXT             0x8E2D
+#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT   0x8E2E
+#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F
+#endif
+
+#ifndef GL_EXT_vertex_array_bgra
+/* reuse GL_BGRA */
+#endif
+
+#ifndef GL_EXT_texture_swizzle
+#define GL_TEXTURE_SWIZZLE_R_EXT          0x8E42
+#define GL_TEXTURE_SWIZZLE_G_EXT          0x8E43
+#define GL_TEXTURE_SWIZZLE_B_EXT          0x8E44
+#define GL_TEXTURE_SWIZZLE_A_EXT          0x8E45
+#define GL_TEXTURE_SWIZZLE_RGBA_EXT       0x8E46
+#endif
+
+#ifndef GL_NV_explicit_multisample
+#define GL_SAMPLE_POSITION_NV             0x8E50
+#define GL_SAMPLE_MASK_NV                 0x8E51
+#define GL_SAMPLE_MASK_VALUE_NV           0x8E52
+#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53
+#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54
+#define GL_TEXTURE_RENDERBUFFER_NV        0x8E55
+#define GL_SAMPLER_RENDERBUFFER_NV        0x8E56
+#define GL_INT_SAMPLER_RENDERBUFFER_NV    0x8E57
+#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58
+#define GL_MAX_SAMPLE_MASK_WORDS_NV       0x8E59
+#endif
+
+#ifndef GL_NV_transform_feedback2
+#define GL_TRANSFORM_FEEDBACK_NV          0x8E22
+#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23
+#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING_NV  0x8E25
+#endif
+
+#ifndef GL_ATI_meminfo
+#define GL_VBO_FREE_MEMORY_ATI            0x87FB
+#define GL_TEXTURE_FREE_MEMORY_ATI        0x87FC
+#define GL_RENDERBUFFER_FREE_MEMORY_ATI   0x87FD
+#endif
+
+#ifndef GL_AMD_performance_monitor
+#define GL_COUNTER_TYPE_AMD               0x8BC0
+#define GL_COUNTER_RANGE_AMD              0x8BC1
+#define GL_UNSIGNED_INT64_AMD             0x8BC2
+#define GL_PERCENTAGE_AMD                 0x8BC3
+#define GL_PERFMON_RESULT_AVAILABLE_AMD   0x8BC4
+#define GL_PERFMON_RESULT_SIZE_AMD        0x8BC5
+#define GL_PERFMON_RESULT_AMD             0x8BC6
+#endif
+
+#ifndef GL_AMD_texture_texture4
+#endif
+
+#ifndef GL_AMD_vertex_shader_tesselator
+#define GL_SAMPLER_BUFFER_AMD             0x9001
+#define GL_INT_SAMPLER_BUFFER_AMD         0x9002
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003
+#define GL_TESSELLATION_MODE_AMD          0x9004
+#define GL_TESSELLATION_FACTOR_AMD        0x9005
+#define GL_DISCRETE_AMD                   0x9006
+#define GL_CONTINUOUS_AMD                 0x9007
+#endif
+
+#ifndef GL_EXT_provoking_vertex
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION_EXT    0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_EXT     0x8E4E
+#define GL_PROVOKING_VERTEX_EXT           0x8E4F
+#endif
+
+#ifndef GL_EXT_texture_snorm
+#define GL_ALPHA_SNORM                    0x9010
+#define GL_LUMINANCE_SNORM                0x9011
+#define GL_LUMINANCE_ALPHA_SNORM          0x9012
+#define GL_INTENSITY_SNORM                0x9013
+#define GL_ALPHA8_SNORM                   0x9014
+#define GL_LUMINANCE8_SNORM               0x9015
+#define GL_LUMINANCE8_ALPHA8_SNORM        0x9016
+#define GL_INTENSITY8_SNORM               0x9017
+#define GL_ALPHA16_SNORM                  0x9018
+#define GL_LUMINANCE16_SNORM              0x9019
+#define GL_LUMINANCE16_ALPHA16_SNORM      0x901A
+#define GL_INTENSITY16_SNORM              0x901B
+/* reuse GL_RED_SNORM */
+/* reuse GL_RG_SNORM */
+/* reuse GL_RGB_SNORM */
+/* reuse GL_RGBA_SNORM */
+/* reuse GL_R8_SNORM */
+/* reuse GL_RG8_SNORM */
+/* reuse GL_RGB8_SNORM */
+/* reuse GL_RGBA8_SNORM */
+/* reuse GL_R16_SNORM */
+/* reuse GL_RG16_SNORM */
+/* reuse GL_RGB16_SNORM */
+/* reuse GL_RGBA16_SNORM */
+/* reuse GL_SIGNED_NORMALIZED */
+#endif
+
+#ifndef GL_AMD_draw_buffers_blend
+#endif
+
+#ifndef GL_APPLE_texture_range
+#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
+/* reuse GL_STORAGE_CACHED_APPLE */
+/* reuse GL_STORAGE_SHARED_APPLE */
+#endif
+
+#ifndef GL_APPLE_float_pixels
+#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
+#endif
+
+#ifndef GL_APPLE_vertex_program_evaluators
+#define GL_VERTEX_ATTRIB_MAP1_APPLE       0x8A00
+#define GL_VERTEX_ATTRIB_MAP2_APPLE       0x8A01
+#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE  0x8A02
+#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03
+#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04
+#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05
+#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE  0x8A06
+#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07
+#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08
+#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09
+#endif
+
+#ifndef GL_APPLE_aux_depth_stencil
+#define GL_AUX_DEPTH_STENCIL_APPLE        0x8A14
+#endif
+
+#ifndef GL_APPLE_object_purgeable
+#define GL_BUFFER_OBJECT_APPLE            0x85B3
+#define GL_RELEASED_APPLE                 0x8A19
+#define GL_VOLATILE_APPLE                 0x8A1A
+#define GL_RETAINED_APPLE                 0x8A1B
+#define GL_UNDEFINED_APPLE                0x8A1C
+#define GL_PURGEABLE_APPLE                0x8A1D
+#endif
+
+#ifndef GL_APPLE_row_bytes
+#define GL_PACK_ROW_BYTES_APPLE           0x8A15
+#define GL_UNPACK_ROW_BYTES_APPLE         0x8A16
+#endif
+
+#ifndef GL_APPLE_rgb_422
+#define GL_RGB_422_APPLE                  0x8A1F
+/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */
+/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+#endif
+
+#ifndef GL_NV_video_capture
+#define GL_VIDEO_BUFFER_NV                0x9020
+#define GL_VIDEO_BUFFER_BINDING_NV        0x9021
+#define GL_FIELD_UPPER_NV                 0x9022
+#define GL_FIELD_LOWER_NV                 0x9023
+#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV   0x9024
+#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025
+#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026
+#define GL_LAST_VIDEO_CAPTURE_STATUS_NV   0x9027
+#define GL_VIDEO_BUFFER_PITCH_NV          0x9028
+#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029
+#define GL_VIDEO_COLOR_CONVERSION_MAX_NV  0x902A
+#define GL_VIDEO_COLOR_CONVERSION_MIN_NV  0x902B
+#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C
+#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D
+#define GL_PARTIAL_SUCCESS_NV             0x902E
+#define GL_SUCCESS_NV                     0x902F
+#define GL_FAILURE_NV                     0x9030
+#define GL_YCBYCR8_422_NV                 0x9031
+#define GL_YCBAYCR8A_4224_NV              0x9032
+#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV  0x9033
+#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034
+#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV  0x9035
+#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036
+#define GL_Z4Y12Z4CB12Z4CR12_444_NV       0x9037
+#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV   0x9038
+#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV  0x9039
+#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A
+#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B
+#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C
+#endif
+
+#ifndef GL_NV_copy_image
+#endif
+
+#ifndef GL_EXT_separate_shader_objects
+#define GL_ACTIVE_PROGRAM_EXT             0x8B8D
+#endif
+
+#ifndef GL_NV_parameter_buffer_object2
+#endif
+
+#ifndef GL_NV_shader_buffer_load
+#define GL_BUFFER_GPU_ADDRESS_NV          0x8F1D
+#define GL_GPU_ADDRESS_NV                 0x8F34
+#define GL_MAX_SHADER_BUFFER_ADDRESS_NV   0x8F35
+#endif
+
+#ifndef GL_NV_vertex_buffer_unified_memory
+#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E
+#define GL_ELEMENT_ARRAY_UNIFIED_NV       0x8F1F
+#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20
+#define GL_VERTEX_ARRAY_ADDRESS_NV        0x8F21
+#define GL_NORMAL_ARRAY_ADDRESS_NV        0x8F22
+#define GL_COLOR_ARRAY_ADDRESS_NV         0x8F23
+#define GL_INDEX_ARRAY_ADDRESS_NV         0x8F24
+#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25
+#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV     0x8F26
+#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27
+#define GL_FOG_COORD_ARRAY_ADDRESS_NV     0x8F28
+#define GL_ELEMENT_ARRAY_ADDRESS_NV       0x8F29
+#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV  0x8F2A
+#define GL_VERTEX_ARRAY_LENGTH_NV         0x8F2B
+#define GL_NORMAL_ARRAY_LENGTH_NV         0x8F2C
+#define GL_COLOR_ARRAY_LENGTH_NV          0x8F2D
+#define GL_INDEX_ARRAY_LENGTH_NV          0x8F2E
+#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV  0x8F2F
+#define GL_EDGE_FLAG_ARRAY_LENGTH_NV      0x8F30
+#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31
+#define GL_FOG_COORD_ARRAY_LENGTH_NV      0x8F32
+#define GL_ELEMENT_ARRAY_LENGTH_NV        0x8F33
+#define GL_DRAW_INDIRECT_UNIFIED_NV       0x8F40
+#define GL_DRAW_INDIRECT_ADDRESS_NV       0x8F41
+#define GL_DRAW_INDIRECT_LENGTH_NV        0x8F42
+#endif
+
+#ifndef GL_NV_texture_barrier
+#endif
+
+#ifndef GL_AMD_shader_stencil_export
+#endif
+
+#ifndef GL_AMD_seamless_cubemap_per_texture
+/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
+#endif
+
+#ifndef GL_AMD_conservative_depth
+#endif
+
+#ifndef GL_EXT_shader_image_load_store
+#define GL_MAX_IMAGE_UNITS_EXT            0x8F38
+#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39
+#define GL_IMAGE_BINDING_NAME_EXT         0x8F3A
+#define GL_IMAGE_BINDING_LEVEL_EXT        0x8F3B
+#define GL_IMAGE_BINDING_LAYERED_EXT      0x8F3C
+#define GL_IMAGE_BINDING_LAYER_EXT        0x8F3D
+#define GL_IMAGE_BINDING_ACCESS_EXT       0x8F3E
+#define GL_IMAGE_1D_EXT                   0x904C
+#define GL_IMAGE_2D_EXT                   0x904D
+#define GL_IMAGE_3D_EXT                   0x904E
+#define GL_IMAGE_2D_RECT_EXT              0x904F
+#define GL_IMAGE_CUBE_EXT                 0x9050
+#define GL_IMAGE_BUFFER_EXT               0x9051
+#define GL_IMAGE_1D_ARRAY_EXT             0x9052
+#define GL_IMAGE_2D_ARRAY_EXT             0x9053
+#define GL_IMAGE_CUBE_MAP_ARRAY_EXT       0x9054
+#define GL_IMAGE_2D_MULTISAMPLE_EXT       0x9055
+#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056
+#define GL_INT_IMAGE_1D_EXT               0x9057
+#define GL_INT_IMAGE_2D_EXT               0x9058
+#define GL_INT_IMAGE_3D_EXT               0x9059
+#define GL_INT_IMAGE_2D_RECT_EXT          0x905A
+#define GL_INT_IMAGE_CUBE_EXT             0x905B
+#define GL_INT_IMAGE_BUFFER_EXT           0x905C
+#define GL_INT_IMAGE_1D_ARRAY_EXT         0x905D
+#define GL_INT_IMAGE_2D_ARRAY_EXT         0x905E
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT   0x905F
+#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT   0x9060
+#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061
+#define GL_UNSIGNED_INT_IMAGE_1D_EXT      0x9062
+#define GL_UNSIGNED_INT_IMAGE_2D_EXT      0x9063
+#define GL_UNSIGNED_INT_IMAGE_3D_EXT      0x9064
+#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065
+#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT    0x9066
+#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT  0x9067
+#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068
+#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C
+#define GL_MAX_IMAGE_SAMPLES_EXT          0x906D
+#define GL_IMAGE_BINDING_FORMAT_EXT       0x906E
+#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001
+#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT  0x00000002
+#define GL_UNIFORM_BARRIER_BIT_EXT        0x00000004
+#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT  0x00000008
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020
+#define GL_COMMAND_BARRIER_BIT_EXT        0x00000040
+#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT   0x00000080
+#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100
+#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT  0x00000200
+#define GL_FRAMEBUFFER_BARRIER_BIT_EXT    0x00000400
+#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800
+#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000
+#define GL_ALL_BARRIER_BITS_EXT           0xFFFFFFFF
+#endif
+
+#ifndef GL_EXT_vertex_attrib_64bit
+/* reuse GL_DOUBLE */
+#define GL_DOUBLE_VEC2_EXT                0x8FFC
+#define GL_DOUBLE_VEC3_EXT                0x8FFD
+#define GL_DOUBLE_VEC4_EXT                0x8FFE
+#define GL_DOUBLE_MAT2_EXT                0x8F46
+#define GL_DOUBLE_MAT3_EXT                0x8F47
+#define GL_DOUBLE_MAT4_EXT                0x8F48
+#define GL_DOUBLE_MAT2x3_EXT              0x8F49
+#define GL_DOUBLE_MAT2x4_EXT              0x8F4A
+#define GL_DOUBLE_MAT3x2_EXT              0x8F4B
+#define GL_DOUBLE_MAT3x4_EXT              0x8F4C
+#define GL_DOUBLE_MAT4x2_EXT              0x8F4D
+#define GL_DOUBLE_MAT4x3_EXT              0x8F4E
+#endif
+
+#ifndef GL_NV_gpu_program5
+#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C
+#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F
+#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44
+#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV  0x8F45
+#endif
+
+#ifndef GL_NV_gpu_shader5
+#define GL_INT64_NV                       0x140E
+#define GL_UNSIGNED_INT64_NV              0x140F
+#define GL_INT8_NV                        0x8FE0
+#define GL_INT8_VEC2_NV                   0x8FE1
+#define GL_INT8_VEC3_NV                   0x8FE2
+#define GL_INT8_VEC4_NV                   0x8FE3
+#define GL_INT16_NV                       0x8FE4
+#define GL_INT16_VEC2_NV                  0x8FE5
+#define GL_INT16_VEC3_NV                  0x8FE6
+#define GL_INT16_VEC4_NV                  0x8FE7
+#define GL_INT64_VEC2_NV                  0x8FE9
+#define GL_INT64_VEC3_NV                  0x8FEA
+#define GL_INT64_VEC4_NV                  0x8FEB
+#define GL_UNSIGNED_INT8_NV               0x8FEC
+#define GL_UNSIGNED_INT8_VEC2_NV          0x8FED
+#define GL_UNSIGNED_INT8_VEC3_NV          0x8FEE
+#define GL_UNSIGNED_INT8_VEC4_NV          0x8FEF
+#define GL_UNSIGNED_INT16_NV              0x8FF0
+#define GL_UNSIGNED_INT16_VEC2_NV         0x8FF1
+#define GL_UNSIGNED_INT16_VEC3_NV         0x8FF2
+#define GL_UNSIGNED_INT16_VEC4_NV         0x8FF3
+#define GL_UNSIGNED_INT64_VEC2_NV         0x8FF5
+#define GL_UNSIGNED_INT64_VEC3_NV         0x8FF6
+#define GL_UNSIGNED_INT64_VEC4_NV         0x8FF7
+#define GL_FLOAT16_NV                     0x8FF8
+#define GL_FLOAT16_VEC2_NV                0x8FF9
+#define GL_FLOAT16_VEC3_NV                0x8FFA
+#define GL_FLOAT16_VEC4_NV                0x8FFB
+/* reuse GL_PATCHES */
+#endif
+
+#ifndef GL_NV_shader_buffer_store
+#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010
+/* reuse GL_READ_WRITE */
+/* reuse GL_WRITE_ONLY */
+#endif
+
+#ifndef GL_NV_tessellation_program5
+#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV   0x86D8
+#define GL_TESS_CONTROL_PROGRAM_NV        0x891E
+#define GL_TESS_EVALUATION_PROGRAM_NV     0x891F
+#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74
+#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75
+#endif
+
+#ifndef GL_NV_vertex_attrib_integer_64bit
+/* reuse GL_INT64_NV */
+/* reuse GL_UNSIGNED_INT64_NV */
+#endif
+
+#ifndef GL_NV_multisample_coverage
+#define GL_COVERAGE_SAMPLES_NV            0x80A9
+#define GL_COLOR_SAMPLES_NV               0x8E20
+#endif
+
+#ifndef GL_AMD_name_gen_delete
+#define GL_DATA_BUFFER_AMD                0x9151
+#define GL_PERFORMANCE_MONITOR_AMD        0x9152
+#define GL_QUERY_OBJECT_AMD               0x9153
+#define GL_VERTEX_ARRAY_OBJECT_AMD        0x9154
+#define GL_SAMPLER_OBJECT_AMD             0x9155
+#endif
+
+#ifndef GL_AMD_debug_output
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD  0x9144
+#define GL_DEBUG_LOGGED_MESSAGES_AMD      0x9145
+#define GL_DEBUG_SEVERITY_HIGH_AMD        0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM_AMD      0x9147
+#define GL_DEBUG_SEVERITY_LOW_AMD         0x9148
+#define GL_DEBUG_CATEGORY_API_ERROR_AMD   0x9149
+#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A
+#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B
+#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C
+#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D
+#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E
+#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F
+#define GL_DEBUG_CATEGORY_OTHER_AMD       0x9150
+#endif
+
+#ifndef GL_NV_vdpau_interop
+#define GL_SURFACE_STATE_NV               0x86EB
+#define GL_SURFACE_REGISTERED_NV          0x86FD
+#define GL_SURFACE_MAPPED_NV              0x8700
+#define GL_WRITE_DISCARD_NV               0x88BE
+#endif
+
+#ifndef GL_AMD_transform_feedback3_lines_triangles
+#endif
+
+#ifndef GL_AMD_depth_clamp_separate
+#define GL_DEPTH_CLAMP_NEAR_AMD           0x901E
+#define GL_DEPTH_CLAMP_FAR_AMD            0x901F
+#endif
+
+#ifndef GL_EXT_texture_sRGB_decode
+#define GL_TEXTURE_SRGB_DECODE_EXT        0x8A48
+#define GL_DECODE_EXT                     0x8A49
+#define GL_SKIP_DECODE_EXT                0x8A4A
+#endif
+
+#ifndef GL_NV_texture_multisample
+#define GL_TEXTURE_COVERAGE_SAMPLES_NV    0x9045
+#define GL_TEXTURE_COLOR_SAMPLES_NV       0x9046
+#endif
+
+#ifndef GL_AMD_blend_minmax_factor
+#define GL_FACTOR_MIN_AMD                 0x901C
+#define GL_FACTOR_MAX_AMD                 0x901D
+#endif
+
+#ifndef GL_AMD_sample_positions
+#define GL_SUBSAMPLE_DISTANCE_AMD         0x883F
+#endif
+
+#ifndef GL_EXT_x11_sync_object
+#define GL_SYNC_X11_FENCE_EXT             0x90E1
+#endif
+
+#ifndef GL_AMD_multi_draw_indirect
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample_blit_scaled
+#define GL_SCALED_RESOLVE_FASTEST_EXT     0x90BA
+#define GL_SCALED_RESOLVE_NICEST_EXT      0x90BB
+#endif
+
+#ifndef GL_NV_path_rendering
+#define GL_PATH_FORMAT_SVG_NV             0x9070
+#define GL_PATH_FORMAT_PS_NV              0x9071
+#define GL_STANDARD_FONT_NAME_NV          0x9072
+#define GL_SYSTEM_FONT_NAME_NV            0x9073
+#define GL_FILE_NAME_NV                   0x9074
+#define GL_PATH_STROKE_WIDTH_NV           0x9075
+#define GL_PATH_END_CAPS_NV               0x9076
+#define GL_PATH_INITIAL_END_CAP_NV        0x9077
+#define GL_PATH_TERMINAL_END_CAP_NV       0x9078
+#define GL_PATH_JOIN_STYLE_NV             0x9079
+#define GL_PATH_MITER_LIMIT_NV            0x907A
+#define GL_PATH_DASH_CAPS_NV              0x907B
+#define GL_PATH_INITIAL_DASH_CAP_NV       0x907C
+#define GL_PATH_TERMINAL_DASH_CAP_NV      0x907D
+#define GL_PATH_DASH_OFFSET_NV            0x907E
+#define GL_PATH_CLIENT_LENGTH_NV          0x907F
+#define GL_PATH_FILL_MODE_NV              0x9080
+#define GL_PATH_FILL_MASK_NV              0x9081
+#define GL_PATH_FILL_COVER_MODE_NV        0x9082
+#define GL_PATH_STROKE_COVER_MODE_NV      0x9083
+#define GL_PATH_STROKE_MASK_NV            0x9084
+#define GL_PATH_SAMPLE_QUALITY_NV         0x9085
+#define GL_PATH_STROKE_BOUND_NV           0x9086
+#define GL_PATH_STROKE_OVERSAMPLE_COUNT_NV 0x9087
+#define GL_COUNT_UP_NV                    0x9088
+#define GL_COUNT_DOWN_NV                  0x9089
+#define GL_PATH_OBJECT_BOUNDING_BOX_NV    0x908A
+#define GL_CONVEX_HULL_NV                 0x908B
+#define GL_MULTI_HULLS_NV                 0x908C
+#define GL_BOUNDING_BOX_NV                0x908D
+#define GL_TRANSLATE_X_NV                 0x908E
+#define GL_TRANSLATE_Y_NV                 0x908F
+#define GL_TRANSLATE_2D_NV                0x9090
+#define GL_TRANSLATE_3D_NV                0x9091
+#define GL_AFFINE_2D_NV                   0x9092
+#define GL_PROJECTIVE_2D_NV               0x9093
+#define GL_AFFINE_3D_NV                   0x9094
+#define GL_PROJECTIVE_3D_NV               0x9095
+#define GL_TRANSPOSE_AFFINE_2D_NV         0x9096
+#define GL_TRANSPOSE_PROJECTIVE_2D_NV     0x9097
+#define GL_TRANSPOSE_AFFINE_3D_NV         0x9098
+#define GL_TRANSPOSE_PROJECTIVE_3D_NV     0x9099
+#define GL_UTF8_NV                        0x909A
+#define GL_UTF16_NV                       0x909B
+#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C
+#define GL_PATH_COMMAND_COUNT_NV          0x909D
+#define GL_PATH_COORD_COUNT_NV            0x909E
+#define GL_PATH_DASH_ARRAY_COUNT_NV       0x909F
+#define GL_PATH_COMPUTED_LENGTH_NV        0x90A0
+#define GL_PATH_FILL_BOUNDING_BOX_NV      0x90A1
+#define GL_PATH_STROKE_BOUNDING_BOX_NV    0x90A2
+#define GL_SQUARE_NV                      0x90A3
+#define GL_ROUND_NV                       0x90A4
+#define GL_TRIANGULAR_NV                  0x90A5
+#define GL_BEVEL_NV                       0x90A6
+#define GL_MITER_REVERT_NV                0x90A7
+#define GL_MITER_TRUNCATE_NV              0x90A8
+#define GL_SKIP_MISSING_GLYPH_NV          0x90A9
+#define GL_USE_MISSING_GLYPH_NV           0x90AA
+#define GL_PATH_ERROR_POSITION_NV         0x90AB
+#define GL_PATH_FOG_GEN_MODE_NV           0x90AC
+#define GL_ACCUM_ADJACENT_PAIRS_NV        0x90AD
+#define GL_ADJACENT_PAIRS_NV              0x90AE
+#define GL_FIRST_TO_REST_NV               0x90AF
+#define GL_PATH_GEN_MODE_NV               0x90B0
+#define GL_PATH_GEN_COEFF_NV              0x90B1
+#define GL_PATH_GEN_COLOR_FORMAT_NV       0x90B2
+#define GL_PATH_GEN_COMPONENTS_NV         0x90B3
+#define GL_PATH_STENCIL_FUNC_NV           0x90B7
+#define GL_PATH_STENCIL_REF_NV            0x90B8
+#define GL_PATH_STENCIL_VALUE_MASK_NV     0x90B9
+#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD
+#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE
+#define GL_PATH_COVER_DEPTH_FUNC_NV       0x90BF
+#define GL_PATH_DASH_OFFSET_RESET_NV      0x90B4
+#define GL_MOVE_TO_RESETS_NV              0x90B5
+#define GL_MOVE_TO_CONTINUES_NV           0x90B6
+#define GL_CLOSE_PATH_NV                  0x00
+#define GL_MOVE_TO_NV                     0x02
+#define GL_RELATIVE_MOVE_TO_NV            0x03
+#define GL_LINE_TO_NV                     0x04
+#define GL_RELATIVE_LINE_TO_NV            0x05
+#define GL_HORIZONTAL_LINE_TO_NV          0x06
+#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07
+#define GL_VERTICAL_LINE_TO_NV            0x08
+#define GL_RELATIVE_VERTICAL_LINE_TO_NV   0x09
+#define GL_QUADRATIC_CURVE_TO_NV          0x0A
+#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B
+#define GL_CUBIC_CURVE_TO_NV              0x0C
+#define GL_RELATIVE_CUBIC_CURVE_TO_NV     0x0D
+#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV   0x0E
+#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F
+#define GL_SMOOTH_CUBIC_CURVE_TO_NV       0x10
+#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11
+#define GL_SMALL_CCW_ARC_TO_NV            0x12
+#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV   0x13
+#define GL_SMALL_CW_ARC_TO_NV             0x14
+#define GL_RELATIVE_SMALL_CW_ARC_TO_NV    0x15
+#define GL_LARGE_CCW_ARC_TO_NV            0x16
+#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV   0x17
+#define GL_LARGE_CW_ARC_TO_NV             0x18
+#define GL_RELATIVE_LARGE_CW_ARC_TO_NV    0x19
+#define GL_RESTART_PATH_NV                0xF0
+#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV    0xF2
+#define GL_DUP_LAST_CUBIC_CURVE_TO_NV     0xF4
+#define GL_RECT_NV                        0xF6
+#define GL_CIRCULAR_CCW_ARC_TO_NV         0xF8
+#define GL_CIRCULAR_CW_ARC_TO_NV          0xFA
+#define GL_CIRCULAR_TANGENT_ARC_TO_NV     0xFC
+#define GL_ARC_TO_NV                      0xFE
+#define GL_RELATIVE_ARC_TO_NV             0xFF
+#define GL_BOLD_BIT_NV                    0x01
+#define GL_ITALIC_BIT_NV                  0x02
+#define GL_GLYPH_WIDTH_BIT_NV             0x01
+#define GL_GLYPH_HEIGHT_BIT_NV            0x02
+#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04
+#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08
+#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10
+#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20
+#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40
+#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80
+#define GL_GLYPH_HAS_KERNING_NV           0x100
+#define GL_FONT_X_MIN_BOUNDS_NV           0x00010000
+#define GL_FONT_Y_MIN_BOUNDS_NV           0x00020000
+#define GL_FONT_X_MAX_BOUNDS_NV           0x00040000
+#define GL_FONT_Y_MAX_BOUNDS_NV           0x00080000
+#define GL_FONT_UNITS_PER_EM_NV           0x00100000
+#define GL_FONT_ASCENDER_NV               0x00200000
+#define GL_FONT_DESCENDER_NV              0x00400000
+#define GL_FONT_HEIGHT_NV                 0x00800000
+#define GL_FONT_MAX_ADVANCE_WIDTH_NV      0x01000000
+#define GL_FONT_MAX_ADVANCE_HEIGHT_NV     0x02000000
+#define GL_FONT_UNDERLINE_POSITION_NV     0x04000000
+#define GL_FONT_UNDERLINE_THICKNESS_NV    0x08000000
+#define GL_FONT_HAS_KERNING_NV            0x10000000
+#endif
+
+#ifndef GL_AMD_pinned_memory
+#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160
+#endif
+
+#ifndef GL_AMD_stencil_operation_extended
+#define GL_SET_AMD                        0x874A
+#define GL_REPLACE_VALUE_AMD              0x874B
+#define GL_STENCIL_OP_VALUE_AMD           0x874C
+#define GL_STENCIL_BACK_OP_VALUE_AMD      0x874D
+#endif
+
+#ifndef GL_AMD_vertex_shader_viewport_index
+#endif
+
+#ifndef GL_AMD_vertex_shader_layer
+#endif
+
+#ifndef GL_NV_bindless_texture
+#endif
+
+#ifndef GL_NV_shader_atomic_float
+#endif
+
+#ifndef GL_AMD_query_buffer_object
+#define GL_QUERY_BUFFER_AMD               0x9192
+#define GL_QUERY_BUFFER_BINDING_AMD       0x9193
+#define GL_QUERY_RESULT_NO_WAIT_AMD       0x9194
+#endif
+
+
+/*************************************************************/
+
+#include <stddef.h>
+#ifndef GL_VERSION_2_0
+/* GL type for program/shader text */
+typedef char GLchar;
+#endif
+
+#ifndef GL_VERSION_1_5
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptr;
+typedef ptrdiff_t GLsizeiptr;
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptrARB;
+typedef ptrdiff_t GLsizeiptrARB;
+#endif
+
+#ifndef GL_ARB_shader_objects
+/* GL types for program/shader text and shader object handles */
+typedef char GLcharARB;
+#ifdef __APPLE__
+typedef unsigned long GLhandleARB;
+#else
+typedef unsigned int GLhandleARB;
+#endif
+#endif
+
+/* GL type for "half" precision (s10e5) float data in host memory */
+#ifndef GL_ARB_half_float_pixel
+typedef unsigned short GLhalfARB;
+#endif
+
+#ifndef GL_NV_half_float
+typedef unsigned short GLhalfNV;
+#endif
+
+#ifndef GLEXT_64_TYPES_DEFINED
+/* This code block is duplicated in glxext.h, so must be protected */
+#define GLEXT_64_TYPES_DEFINED
+/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
+/* (as used in the GL_EXT_timer_query extension). */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+#elif defined(__sun__) || defined(__digital__)
+#include <inttypes.h>
+#if defined(__STDC__)
+#if defined(__arch64__) || defined(_LP64)
+typedef long int int64_t;
+typedef unsigned long int uint64_t;
+#else
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#endif /* __arch64__ */
+#endif /* __STDC__ */
+#elif defined( __VMS ) || defined(__sgi)
+#include <inttypes.h>
+#elif defined(__SCO__) || defined(__USLC__)
+#include <stdint.h>
+#elif defined(__UNIXOS2__) || defined(__SOL64__)
+typedef long int int32_t;
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#elif defined(_WIN32) && defined(__GNUC__)
+#include <stdint.h>
+#elif defined(_WIN32)
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+/* Fallback if nothing above works */
+#include <inttypes.h>
+#endif
+#endif
+
+#ifndef GL_EXT_timer_query
+typedef int64_t GLint64EXT;
+typedef uint64_t GLuint64EXT;
+#endif
+
+#ifndef GL_ARB_sync
+typedef int64_t GLint64;
+typedef uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+#endif
+
+#ifndef GL_ARB_cl_event
+/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */
+struct _cl_context;
+struct _cl_event;
+#endif
+
+#ifndef GL_ARB_debug_output
+typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#endif
+
+#ifndef GL_AMD_debug_output
+typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#endif
+
+#ifndef GL_KHR_debug
+typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
+#endif
+
+#ifndef GL_NV_vdpau_interop
+typedef GLintptr GLvdpauSurfaceNV;
+#endif
+
+#ifndef GL_VERSION_1_2
+#define GL_VERSION_1_2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GLAPI void APIENTRY glBlendEquation (GLenum mode);
+GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_VERSION_1_2_DEPRECATED
+#define GL_VERSION_1_2_DEPRECATED 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table);
+GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params);
+GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params);
+GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image);
+GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glResetHistogram (GLenum target);
+GLAPI void APIENTRY glResetMinmax (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
+#endif
+
+#ifndef GL_VERSION_1_3
+#define GL_VERSION_1_3 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTexture (GLenum texture);
+GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
+GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_VERSION_1_3_DEPRECATED
+#define GL_VERSION_1_3_DEPRECATED 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClientActiveTexture (GLenum texture);
+GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s);
+GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s);
+GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s);
+GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s);
+GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t);
+GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t);
+GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t);
+GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t);
+GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r);
+GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r);
+GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q);
+GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m);
+GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+#endif
+
+#ifndef GL_VERSION_1_4
+#define GL_VERSION_1_4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);
+GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount);
+GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param);
+GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_VERSION_1_4_DEPRECATED
+#define GL_VERSION_1_4_DEPRECATED 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogCoordf (GLfloat coord);
+GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord);
+GLAPI void APIENTRY glFogCoordd (GLdouble coord);
+GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord);
+GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue);
+GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v);
+GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue);
+GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v);
+GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue);
+GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v);
+GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue);
+GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v);
+GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue);
+GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v);
+GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue);
+GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v);
+GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue);
+GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v);
+GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue);
+GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v);
+GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y);
+GLAPI void APIENTRY glWindowPos2iv (const GLint *v);
+GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y);
+GLAPI void APIENTRY glWindowPos2sv (const GLshort *v);
+GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glWindowPos3iv (const GLint *v);
+GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glWindowPos3sv (const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_VERSION_1_5
+#define GL_VERSION_1_5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids);
+GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids);
+GLAPI GLboolean APIENTRY glIsQuery (GLuint id);
+GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id);
+GLAPI void APIENTRY glEndQuery (GLenum target);
+GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
+GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
+GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer);
+GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
+GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access);
+GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target);
+GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
+GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs);
+GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
+GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
+GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader);
+GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);
+GLAPI void APIENTRY glCompileShader (GLuint shader);
+GLAPI GLuint APIENTRY glCreateProgram (void);
+GLAPI GLuint APIENTRY glCreateShader (GLenum type);
+GLAPI void APIENTRY glDeleteProgram (GLuint program);
+GLAPI void APIENTRY glDeleteShader (GLuint shader);
+GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader);
+GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index);
+GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index);
+GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);
+GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer);
+GLAPI GLboolean APIENTRY glIsProgram (GLuint program);
+GLAPI GLboolean APIENTRY glIsShader (GLuint shader);
+GLAPI void APIENTRY glLinkProgram (GLuint program);
+GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length);
+GLAPI void APIENTRY glUseProgram (GLuint program);
+GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0);
+GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glUniform1i (GLint location, GLint v0);
+GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glValidateProgram (GLuint program);
+GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);
+GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x);
+GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
+typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
+typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
+typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
+typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length);
+typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_VERSION_2_1
+#define GL_VERSION_2_1 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif
+
+#ifndef GL_VERSION_3_0
+#define GL_VERSION_3_0 1
+/* OpenGL 3.0 also reuses entry points from these extensions: */
+/* ARB_framebuffer_object */
+/* ARB_map_buffer_range */
+/* ARB_vertex_array_object */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data);
+GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data);
+GLAPI void APIENTRY glEnablei (GLenum target, GLuint index);
+GLAPI void APIENTRY glDisablei (GLenum target, GLuint index);
+GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index);
+GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode);
+GLAPI void APIENTRY glEndTransformFeedback (void);
+GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);
+GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode);
+GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp);
+GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode);
+GLAPI void APIENTRY glEndConditionalRender (void);
+GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x);
+GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y);
+GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x);
+GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y);
+GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z);
+GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params);
+GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name);
+GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0);
+GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value);
+GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value);
+GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value);
+GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);
+typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index);
+typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp);
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode);
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
+#endif
+
+#ifndef GL_VERSION_3_1
+#define GL_VERSION_3_1 1
+/* OpenGL 3.1 also reuses entry points from these extensions: */
+/* ARB_copy_buffer */
+/* ARB_uniform_buffer_object */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount);
+GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer);
+GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount);
+typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index);
+#endif
+
+#ifndef GL_VERSION_3_2
+#define GL_VERSION_3_2 1
+/* OpenGL 3.2 also reuses entry points from these extensions: */
+/* ARB_draw_elements_base_vertex */
+/* ARB_provoking_vertex */
+/* ARB_sync */
+/* ARB_texture_multisample */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data);
+GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params);
+GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+#endif
+
+#ifndef GL_VERSION_3_3
+#define GL_VERSION_3_3 1
+/* OpenGL 3.3 also reuses entry points from these extensions: */
+/* ARB_blend_func_extended */
+/* ARB_sampler_objects */
+/* ARB_explicit_attrib_location, but it has none */
+/* ARB_occlusion_query2 (no entry points) */
+/* ARB_shader_bit_encoding (no entry points) */
+/* ARB_texture_rgb10_a2ui (no entry points) */
+/* ARB_texture_swizzle (no entry points) */
+/* ARB_timer_query */
+/* ARB_vertex_type_2_10_10_10_rev */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
+#endif
+
+#ifndef GL_VERSION_4_0
+#define GL_VERSION_4_0 1
+/* OpenGL 4.0 also reuses entry points from these extensions: */
+/* ARB_texture_query_lod (no entry points) */
+/* ARB_draw_indirect */
+/* ARB_gpu_shader5 (no entry points) */
+/* ARB_gpu_shader_fp64 */
+/* ARB_shader_subroutine */
+/* ARB_tessellation_shader */
+/* ARB_texture_buffer_object_rgb32 (no entry points) */
+/* ARB_texture_cube_map_array (no entry points) */
+/* ARB_texture_gather (no entry points) */
+/* ARB_transform_feedback2 */
+/* ARB_transform_feedback3 */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMinSampleShading (GLfloat value);
+GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode);
+GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst);
+GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+
+#ifndef GL_VERSION_4_1
+#define GL_VERSION_4_1 1
+/* OpenGL 4.1 reuses entry points from these extensions: */
+/* ARB_ES2_compatibility */
+/* ARB_get_program_binary */
+/* ARB_separate_shader_objects */
+/* ARB_shader_precision (no entry points) */
+/* ARB_vertex_attrib_64bit */
+/* ARB_viewport_array */
+#endif
+
+#ifndef GL_VERSION_4_2
+#define GL_VERSION_4_2 1
+/* OpenGL 4.2 reuses entry points from these extensions: */
+/* ARB_base_instance */
+/* ARB_shading_language_420pack (no entry points) */
+/* ARB_transform_feedback_instanced */
+/* ARB_compressed_texture_pixel_storage (no entry points) */
+/* ARB_conservative_depth (no entry points) */
+/* ARB_internalformat_query */
+/* ARB_map_buffer_alignment (no entry points) */
+/* ARB_shader_atomic_counters */
+/* ARB_shader_image_load_store */
+/* ARB_shading_language_packing (no entry points) */
+/* ARB_texture_storage */
+#endif
+
+#ifndef GL_VERSION_4_3
+#define GL_VERSION_4_3 1
+/* OpenGL 4.3 reuses entry points from these extensions: */
+/* ARB_arrays_of_arrays (no entry points, GLSL only) */
+/* ARB_fragment_layer_viewport (no entry points, GLSL only) */
+/* ARB_shader_image_size (no entry points, GLSL only) */
+/* ARB_ES3_compatibility (no entry points) */
+/* ARB_clear_buffer_object */
+/* ARB_compute_shader */
+/* ARB_copy_image */
+/* ARB_debug_group */
+/* ARB_debug_label */
+/* KHR_debug (ARB_debug_output promoted to KHR without suffixes) */
+/* ARB_debug_output2 (no entry points) */
+/* ARB_explicit_uniform_location (no entry points) */
+/* ARB_framebuffer_no_attachments */
+/* ARB_internalformat_query2 */
+/* ARB_invalidate_subdata */
+/* ARB_multi_draw_indirect */
+/* ARB_program_interface_query */
+/* ARB_robust_buffer_access_behavior (no entry points) */
+/* ARB_shader_storage_buffer_object */
+/* ARB_stencil_texturing (no entry points) */
+/* ARB_texture_buffer_range */
+/* ARB_texture_query_levels (no entry points) */
+/* ARB_texture_storage_multisample */
+/* ARB_texture_view */
+/* ARB_vertex_attrib_binding */
+#endif
+
+#ifndef GL_ARB_multitexture
+#define GL_ARB_multitexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTextureARB (GLenum texture);
+GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture);
+GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s);
+GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s);
+GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s);
+GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s);
+GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t);
+GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t);
+GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t);
+GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t);
+GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r);
+GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r);
+GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v);
+GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v);
+GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v);
+GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q);
+GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v);
+GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#define GL_ARB_transpose_matrix 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m);
+GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m);
+GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m);
+GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+#endif
+
+#ifndef GL_ARB_multisample
+#define GL_ARB_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert);
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#define GL_ARB_texture_env_add 1
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#define GL_ARB_texture_cube_map 1
+#endif
+
+#ifndef GL_ARB_texture_compression
+#define GL_ARB_texture_compression 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_ARB_texture_border_clamp 1
+#endif
+
+#ifndef GL_ARB_point_parameters
+#define GL_ARB_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#define GL_ARB_vertex_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights);
+GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights);
+GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights);
+GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights);
+GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights);
+GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights);
+GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights);
+GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights);
+GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glVertexBlendARB (GLint count);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
+typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#define GL_ARB_matrix_palette 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index);
+GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices);
+GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices);
+GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices);
+GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_ARB_texture_env_combine 1
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#define GL_ARB_texture_env_crossbar 1
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_ARB_texture_env_dot3 1
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
+#endif
+
+#ifndef GL_ARB_depth_texture
+#define GL_ARB_depth_texture 1
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_ARB_shadow 1
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_ARB_shadow_ambient 1
+#endif
+
+#ifndef GL_ARB_window_pos
+#define GL_ARB_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y);
+GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v);
+GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y);
+GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v);
+GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v);
+GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_ARB_vertex_program
+#define GL_ARB_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x);
+GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x);
+GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index);
+GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index);
+GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program);
+GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs);
+GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs);
+GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);
+GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);
+GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);
+GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);
+GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params);
+GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params);
+GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params);
+GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params);
+GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string);
+GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer);
+GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program);
+#endif
+
+#ifndef GL_ARB_fragment_program
+#define GL_ARB_fragment_program 1
+/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_ARB_vertex_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer);
+GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers);
+GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers);
+GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer);
+GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
+GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
+GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
+GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access);
+GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target);
+GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#define GL_ARB_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids);
+GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids);
+GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id);
+GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id);
+GLAPI void APIENTRY glEndQueryARB (GLenum target);
+GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_ARB_shader_objects
+#define GL_ARB_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj);
+GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname);
+GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj);
+GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType);
+GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj);
+GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);
+GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj);
+GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj);
+GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj);
+GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj);
+GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0);
+GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0);
+GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name);
+GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params);
+GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params);
+GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
+typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
+typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
+typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
+typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#define GL_ARB_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name);
+GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_ARB_fragment_shader 1
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_ARB_shading_language_100 1
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#define GL_ARB_texture_non_power_of_two 1
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_ARB_point_sprite 1
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#define GL_ARB_fragment_program_shadow 1
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_ARB_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_ARB_texture_rectangle 1
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_ARB_color_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel 1
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+#endif
+
+#ifndef GL_ARB_depth_buffer_float
+#define GL_ARB_depth_buffer_float 1
+#endif
+
+#ifndef GL_ARB_draw_instanced
+#define GL_ARB_draw_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_ARB_framebuffer_object
+#define GL_ARB_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer);
+GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);
+GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);
+GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer);
+GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
+GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);
+GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);
+GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target);
+GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGenerateMipmap (GLenum target);
+GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+#endif
+
+#ifndef GL_ARB_framebuffer_sRGB
+#define GL_ARB_framebuffer_sRGB 1
+#endif
+
+#ifndef GL_ARB_geometry_shader4
+#define GL_ARB_geometry_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value);
+GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif
+
+#ifndef GL_ARB_half_float_vertex
+#define GL_ARB_half_float_vertex 1
+#endif
+
+#ifndef GL_ARB_instanced_arrays
+#define GL_ARB_instanced_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);
+#endif
+
+#ifndef GL_ARB_map_buffer_range
+#define GL_ARB_map_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+
+#ifndef GL_ARB_texture_buffer_object
+#define GL_ARB_texture_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+#endif
+
+#ifndef GL_ARB_texture_compression_rgtc
+#define GL_ARB_texture_compression_rgtc 1
+#endif
+
+#ifndef GL_ARB_texture_rg
+#define GL_ARB_texture_rg 1
+#endif
+
+#ifndef GL_ARB_vertex_array_object
+#define GL_ARB_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexArray (GLuint array);
+GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);
+GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
+GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array);
+#endif
+
+#ifndef GL_ARB_uniform_buffer_object
+#define GL_ARB_uniform_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices);
+GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
+GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName);
+GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
+typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+#endif
+
+#ifndef GL_ARB_compatibility
+#define GL_ARB_compatibility 1
+#endif
+
+#ifndef GL_ARB_copy_buffer
+#define GL_ARB_copy_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+#endif
+
+#ifndef GL_ARB_shader_texture_lod
+#define GL_ARB_shader_texture_lod 1
+#endif
+
+#ifndef GL_ARB_depth_clamp
+#define GL_ARB_depth_clamp 1
+#endif
+
+#ifndef GL_ARB_draw_elements_base_vertex
+#define GL_ARB_draw_elements_base_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex);
+GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex);
+#endif
+
+#ifndef GL_ARB_fragment_coord_conventions
+#define GL_ARB_fragment_coord_conventions 1
+#endif
+
+#ifndef GL_ARB_provoking_vertex
+#define GL_ARB_provoking_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProvokingVertex (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode);
+#endif
+
+#ifndef GL_ARB_seamless_cube_map
+#define GL_ARB_seamless_cube_map 1
+#endif
+
+#ifndef GL_ARB_sync
+#define GL_ARB_sync 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags);
+GLAPI GLboolean APIENTRY glIsSync (GLsync sync);
+GLAPI void APIENTRY glDeleteSync (GLsync sync);
+GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params);
+GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync);
+typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync);
+typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params);
+typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+
+#ifndef GL_ARB_texture_multisample
+#define GL_ARB_texture_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val);
+GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val);
+typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);
+#endif
+
+#ifndef GL_ARB_vertex_array_bgra
+#define GL_ARB_vertex_array_bgra 1
+#endif
+
+#ifndef GL_ARB_draw_buffers_blend
+#define GL_ARB_draw_buffers_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode);
+GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst);
+GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+
+#ifndef GL_ARB_sample_shading
+#define GL_ARB_sample_shading 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value);
+#endif
+
+#ifndef GL_ARB_texture_cube_map_array
+#define GL_ARB_texture_cube_map_array 1
+#endif
+
+#ifndef GL_ARB_texture_gather
+#define GL_ARB_texture_gather 1
+#endif
+
+#ifndef GL_ARB_texture_query_lod
+#define GL_ARB_texture_query_lod 1
+#endif
+
+#ifndef GL_ARB_shading_language_include
+#define GL_ARB_shading_language_include 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);
+GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name);
+GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length);
+GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name);
+GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);
+GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);
+typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);
+typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length);
+typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);
+typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_texture_compression_bptc
+#define GL_ARB_texture_compression_bptc 1
+#endif
+
+#ifndef GL_ARB_blend_func_extended
+#define GL_ARB_blend_func_extended 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
+GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name);
+#endif
+
+#ifndef GL_ARB_explicit_attrib_location
+#define GL_ARB_explicit_attrib_location 1
+#endif
+
+#ifndef GL_ARB_occlusion_query2
+#define GL_ARB_occlusion_query2 1
+#endif
+
+#ifndef GL_ARB_sampler_objects
+#define GL_ARB_sampler_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers);
+GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers);
+GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler);
+GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
+GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
+GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param);
+GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param);
+GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param);
+GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param);
+GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);
+typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers);
+typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler);
+typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_ARB_shader_bit_encoding
+#define GL_ARB_shader_bit_encoding 1
+#endif
+
+#ifndef GL_ARB_texture_rgb10_a2ui
+#define GL_ARB_texture_rgb10_a2ui 1
+#endif
+
+#ifndef GL_ARB_texture_swizzle
+#define GL_ARB_texture_swizzle 1
+#endif
+
+#ifndef GL_ARB_timer_query
+#define GL_ARB_timer_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target);
+GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params);
+GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params);
+#endif
+
+#ifndef GL_ARB_vertex_type_2_10_10_10_rev
+#define GL_ARB_vertex_type_2_10_10_10_rev 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value);
+GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value);
+GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value);
+GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value);
+GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value);
+GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value);
+GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords);
+GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords);
+GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords);
+GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color);
+GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color);
+GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color);
+GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color);
+GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color);
+GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color);
+GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value);
+typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords);
+typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords);
+typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color);
+typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color);
+typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color);
+typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+#endif
+
+#ifndef GL_ARB_draw_indirect
+#define GL_ARB_draw_indirect 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect);
+GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect);
+#endif
+
+#ifndef GL_ARB_gpu_shader5
+#define GL_ARB_gpu_shader5 1
+#endif
+
+#ifndef GL_ARB_gpu_shader_fp64
+#define GL_ARB_gpu_shader_fp64 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x);
+GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x);
+typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params);
+#endif
+
+#ifndef GL_ARB_shader_subroutine
+#define GL_ARB_shader_subroutine 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name);
+GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name);
+GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);
+GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices);
+GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params);
+GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name);
+typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices);
+typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values);
+#endif
+
+#ifndef GL_ARB_tessellation_shader
+#define GL_ARB_tessellation_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value);
+GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values);
+#endif
+
+#ifndef GL_ARB_texture_buffer_object_rgb32
+#define GL_ARB_texture_buffer_object_rgb32 1
+#endif
+
+#ifndef GL_ARB_transform_feedback2
+#define GL_ARB_transform_feedback2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id);
+GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids);
+GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids);
+GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id);
+GLAPI void APIENTRY glPauseTransformFeedback (void);
+GLAPI void APIENTRY glResumeTransformFeedback (void);
+GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids);
+typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void);
+typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void);
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id);
+#endif
+
+#ifndef GL_ARB_transform_feedback3
+#define GL_ARB_transform_feedback3 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream);
+GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id);
+GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index);
+GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream);
+typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_ES2_compatibility
+#define GL_ARB_ES2_compatibility 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReleaseShaderCompiler (void);
+GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length);
+GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
+GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f);
+GLAPI void APIENTRY glClearDepthf (GLfloat d);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void);
+typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length);
+typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
+typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f);
+typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d);
+#endif
+
+#ifndef GL_ARB_get_program_binary
+#define GL_ARB_get_program_binary 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
+GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
+#endif
+
+#ifndef GL_ARB_separate_shader_objects
+#define GL_ARB_separate_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program);
+GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program);
+GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings);
+GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline);
+GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines);
+GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines);
+GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline);
+GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params);
+GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0);
+GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0);
+GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0);
+GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0);
+GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1);
+GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
+GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
+GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline);
+GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
+typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings);
+typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines);
+typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline);
+typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline);
+typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif
+
+#ifndef GL_ARB_vertex_attrib_64bit
+#define GL_ARB_vertex_attrib_64bit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+#endif
+
+#ifndef GL_ARB_viewport_array
+#define GL_ARB_viewport_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v);
+GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v);
+GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f);
+GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data);
+GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v);
+typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f);
+typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data);
+#endif
+
+#ifndef GL_ARB_cl_event
+#define GL_ARB_cl_event 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags);
+#endif
+
+#ifndef GL_ARB_debug_output
+#define GL_ARB_debug_output 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam);
+GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam);
+typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+#endif
+
+#ifndef GL_ARB_robustness
+#define GL_ARB_robustness 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void);
+GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);
+GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);
+GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v);
+GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values);
+GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values);
+GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values);
+GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern);
+GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table);
+GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image);
+GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span);
+GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img);
+GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
+GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img);
+GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void);
+typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);
+typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);
+typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v);
+typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values);
+typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values);
+typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values);
+typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern);
+typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img);
+typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
+typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img);
+typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);
+#endif
+
+#ifndef GL_ARB_shader_stencil_export
+#define GL_ARB_shader_stencil_export 1
+#endif
+
+#ifndef GL_ARB_base_instance
+#define GL_ARB_base_instance 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);
+GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+#endif
+
+#ifndef GL_ARB_shading_language_420pack
+#define GL_ARB_shading_language_420pack 1
+#endif
+
+#ifndef GL_ARB_transform_feedback_instanced
+#define GL_ARB_transform_feedback_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount);
+GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount);
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);
+#endif
+
+#ifndef GL_ARB_compressed_texture_pixel_storage
+#define GL_ARB_compressed_texture_pixel_storage 1
+#endif
+
+#ifndef GL_ARB_conservative_depth
+#define GL_ARB_conservative_depth 1
+#endif
+
+#ifndef GL_ARB_internalformat_query
+#define GL_ARB_internalformat_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
+#endif
+
+#ifndef GL_ARB_map_buffer_alignment
+#define GL_ARB_map_buffer_alignment 1
+#endif
+
+#ifndef GL_ARB_shader_atomic_counters
+#define GL_ARB_shader_atomic_counters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_shader_image_load_store
+#define GL_ARB_shader_image_load_store 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);
+#endif
+
+#ifndef GL_ARB_shading_language_packing
+#define GL_ARB_shading_language_packing 1
+#endif
+
+#ifndef GL_ARB_texture_storage
+#define GL_ARB_texture_storage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+#ifndef GL_KHR_texture_compression_astc_ldr
+#define GL_KHR_texture_compression_astc_ldr 1
+#endif
+
+#ifndef GL_KHR_debug
+#define GL_KHR_debug 1
+/* KHR_debug also reuses entry points from ARB_debug_group and ARB_debug_label */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);
+GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GLAPI void APIENTRY glPopDebugGroup (void);
+GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);
+GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
+typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
+typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
+typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif
+
+#ifndef GL_ARB_arrays_of_arrays
+#define GL_ARB_arrays_of_arrays 1
+#endif
+
+#ifndef GL_ARB_clear_buffer_object
+#define GL_ARB_clear_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);
+GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
+GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);
+GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);
+typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
+typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);
+typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data);
+#endif
+
+#ifndef GL_ARB_compute_shader
+#define GL_ARB_compute_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect);
+#endif
+
+#ifndef GL_ARB_copy_image
+#define GL_ARB_copy_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+#endif
+
+#ifndef GL_ARB_debug_group
+#define GL_ARB_debug_group 1
+/* ARB_debug_group reuses entry points from KHR_debug */
+#endif
+
+#ifndef GL_ARB_debug_label
+#define GL_ARB_debug_label 1
+/* ARB_debug_label reuses entry points from KHR_debug */
+#endif
+
+#ifndef GL_ARB_debug_output2
+#define GL_ARB_debug_output2 1
+#endif
+
+#ifndef GL_ARB_ES3_compatibility
+#define GL_ARB_ES3_compatibility 1
+#endif
+
+#ifndef GL_ARB_explicit_uniform_location
+#define GL_ARB_explicit_uniform_location 1
+#endif
+
+#ifndef GL_ARB_fragment_layer_viewport
+#define GL_ARB_fragment_layer_viewport 1
+#endif
+
+#ifndef GL_ARB_framebuffer_no_attachments
+#define GL_ARB_framebuffer_no_attachments 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param);
+GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_ARB_internalformat_query2
+#define GL_ARB_internalformat_query2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);
+#endif
+
+#ifndef GL_ARB_invalidate_subdata
+#define GL_ARB_invalidate_subdata 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level);
+GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length);
+GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer);
+GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);
+typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_ARB_multi_draw_indirect
+#define GL_ARB_multi_draw_indirect 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
+GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
+#endif
+
+#ifndef GL_ARB_program_interface_query
+#define GL_ARB_program_interface_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params);
+GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name);
+GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
+GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);
+GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name);
+GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params);
+typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);
+typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name);
+#endif
+
+#ifndef GL_ARB_robust_buffer_access_behavior
+#define GL_ARB_robust_buffer_access_behavior 1
+#endif
+
+#ifndef GL_ARB_shader_image_size
+#define GL_ARB_shader_image_size 1
+#endif
+
+#ifndef GL_ARB_shader_storage_buffer_object
+#define GL_ARB_shader_storage_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
+#endif
+
+#ifndef GL_ARB_stencil_texturing
+#define GL_ARB_stencil_texturing 1
+#endif
+
+#ifndef GL_ARB_texture_buffer_range
+#define GL_ARB_texture_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+#endif
+
+#ifndef GL_ARB_texture_query_levels
+#define GL_ARB_texture_query_levels 1
+#endif
+
+#ifndef GL_ARB_texture_storage_multisample
+#define GL_ARB_texture_storage_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+#endif
+
+#ifndef GL_ARB_texture_view
+#define GL_ARB_texture_view 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+#endif
+
+#ifndef GL_ARB_vertex_attrib_binding
+#define GL_ARB_vertex_attrib_binding 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex);
+GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor);
+GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex);
+GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex);
+typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor);
+typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor);
+#endif
+
+#ifndef GL_ARB_robustness_isolation
+#define GL_ARB_robustness_isolation 1
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_EXT_abgr 1
+#endif
+
+#ifndef GL_EXT_blend_color
+#define GL_EXT_blend_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_EXT_polygon_offset 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);
+#endif
+
+#ifndef GL_EXT_texture
+#define GL_EXT_texture 1
+#endif
+
+#ifndef GL_EXT_texture3D
+#define GL_EXT_texture3D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_SGIS_texture_filter4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights);
+GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);
+typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
+#endif
+
+#ifndef GL_EXT_subtexture
+#define GL_EXT_subtexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_EXT_copy_texture
+#define GL_EXT_copy_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_EXT_histogram
+#define GL_EXT_histogram 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink);
+GLAPI void APIENTRY glResetHistogramEXT (GLenum target);
+GLAPI void APIENTRY glResetMinmaxEXT (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_EXT_convolution
+#define GL_EXT_convolution 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params);
+GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params);
+GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image);
+GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+#endif
+
+#ifndef GL_SGI_color_matrix
+#define GL_SGI_color_matrix 1
+#endif
+
+#ifndef GL_SGI_color_table
+#define GL_SGI_color_table 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table);
+GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_SGIX_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#define GL_SGIS_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param);
+GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_texture4D
+#define GL_SGIS_texture4D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_SGI_texture_color_table 1
+#endif
+
+#ifndef GL_EXT_cmyka
+#define GL_EXT_cmyka 1
+#endif
+
+#ifndef GL_EXT_texture_object
+#define GL_EXT_texture_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences);
+GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture);
+GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures);
+GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures);
+GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture);
+GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);
+typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);
+typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture);
+typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_SGIS_detail_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);
+GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_SGIS_sharpen_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);
+GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#define GL_EXT_packed_pixels 1
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#define GL_SGIS_texture_lod 1
+#endif
+
+#ifndef GL_SGIS_multisample
+#define GL_SGIS_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert);
+GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_EXT_rescale_normal 1
+#endif
+
+#ifndef GL_EXT_vertex_array
+#define GL_EXT_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glArrayElementEXT (GLint i);
+GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count);
+GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer);
+GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params);
+GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i);
+typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
+typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
+typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#define GL_EXT_misc_attribute 1
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_SGIS_generate_mipmap 1
+#endif
+
+#ifndef GL_SGIX_clipmap
+#define GL_SGIX_clipmap 1
+#endif
+
+#ifndef GL_SGIX_shadow
+#define GL_SGIX_shadow 1
+#endif
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_SGIS_texture_edge_clamp 1
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_SGIS_texture_border_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_EXT_blend_minmax 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationEXT (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_EXT_blend_subtract 1
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#define GL_EXT_blend_logic_op 1
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_SGIX_interlace 1
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_SGIX_pixel_tiles 1
+#endif
+
+#ifndef GL_SGIX_texture_select
+#define GL_SGIX_texture_select 1
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SGIX_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param);
+GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_SGIX_texture_multi_buffer 1
+#endif
+
+#ifndef GL_EXT_point_parameters
+#define GL_EXT_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_SGIS_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_SGIX_instruments 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLint APIENTRY glGetInstrumentsSGIX (void);
+GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer);
+GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p);
+GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker);
+GLAPI void APIENTRY glStartInstrumentsSGIX (void);
+GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);
+typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);
+typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);
+typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#define GL_SGIX_texture_scale_bias 1
+#endif
+
+#ifndef GL_SGIX_framezoom
+#define GL_SGIX_framezoom 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFrameZoomSGIX (GLint factor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor);
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#define GL_SGIX_tag_sample_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTagSampleBufferSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_SGIX_polynomial_ffd 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
+GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
+GLAPI void APIENTRY glDeformSGIX (GLbitfield mask);
+GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
+typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask);
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_SGIX_reference_plane 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#define GL_SGIX_flush_raster 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushRasterSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_SGIX_depth_texture 1
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_SGIS_fog_function 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points);
+GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points);
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_SGIX_fog_offset 1
+#endif
+
+#ifndef GL_HP_image_transform
+#define GL_HP_image_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#define GL_HP_convolution_border_modes 1
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_SGIX_texture_add_env 1
+#endif
+
+#ifndef GL_EXT_color_subtable
+#define GL_EXT_color_subtable 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_PGI_vertex_hints 1
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PGI_misc_hints 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode);
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#define GL_EXT_paletted_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data);
+GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_EXT_clip_volume_hint 1
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_SGIX_list_priority 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params);
+GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param);
+GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_SGIX_ir_instrument1 1
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_SGIX_calligraphic_fragment 1
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#define GL_SGIX_texture_lod_bias 1
+#endif
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SGIX_shadow_ambient 1
+#endif
+
+#ifndef GL_EXT_index_texture
+#define GL_EXT_index_texture 1
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_EXT_index_material 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_EXT_index_func 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#define GL_EXT_index_array_formats 1
+#endif
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_EXT_compiled_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count);
+GLAPI void APIENTRY glUnlockArraysEXT (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void);
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_EXT_cull_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_SGIX_ycrcb 1
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_SGIX_fragment_lighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode);
+GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param);
+GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param);
+GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param);
+GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params);
+GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_IBM_rasterpos_clip 1
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_HP_texture_lighting 1
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_EXT_draw_range_elements 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_WIN_phong_shading 1
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_WIN_specular_fog 1
+#endif
+
+#ifndef GL_EXT_light_texture
+#define GL_EXT_light_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glApplyTextureEXT (GLenum mode);
+GLAPI void APIENTRY glTextureLightEXT (GLenum pname);
+GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_SGIX_blend_alpha_minmax 1
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_EXT_bgra 1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_SGIX_async 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker);
+GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp);
+GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp);
+GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range);
+GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range);
+GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker);
+typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp);
+typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp);
+typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);
+typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);
+typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#define GL_SGIX_async_pixel 1
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_SGIX_async_histogram 1
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#define GL_INTEL_parallel_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
+GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer);
+GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
+GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_HP_occlusion_test 1
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#define GL_EXT_pixel_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#define GL_EXT_pixel_transform_color_table 1
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_EXT_shared_texture_palette 1
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_EXT_separate_specular_color 1
+#endif
+
+#ifndef GL_EXT_secondary_color
+#define GL_EXT_secondary_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue);
+GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v);
+GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue);
+GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v);
+GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue);
+GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v);
+GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue);
+GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v);
+GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue);
+GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v);
+GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue);
+GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v);
+GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue);
+GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v);
+GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue);
+GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v);
+GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_EXT_texture_perturb_normal 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureNormalEXT (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_EXT_fog_coord
+#define GL_EXT_fog_coord 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord);
+GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord);
+GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord);
+GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord);
+GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_REND_screen_coordinates 1
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#define GL_EXT_coordinate_frame 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz);
+GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v);
+GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz);
+GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v);
+GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz);
+GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v);
+GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz);
+GLAPI void APIENTRY glTangent3ivEXT (const GLint *v);
+GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz);
+GLAPI void APIENTRY glTangent3svEXT (const GLshort *v);
+GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz);
+GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v);
+GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz);
+GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v);
+GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz);
+GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v);
+GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz);
+GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v);
+GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz);
+GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v);
+GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz);
+typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz);
+typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz);
+typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz);
+typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz);
+typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz);
+typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz);
+typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz);
+typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz);
+typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz);
+typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#define GL_EXT_texture_env_combine 1
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_APPLE_specular_vector 1
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_APPLE_transform_hint 1
+#endif
+
+#ifndef GL_SGIX_fog_scale
+#define GL_SGIX_fog_scale 1
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_SUNX_constant_data 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFinishTextureSUNX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void);
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_SUN_global_alpha 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor);
+GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor);
+GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor);
+GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor);
+GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor);
+GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor);
+GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor);
+GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_SUN_triangle_list 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code);
+GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code);
+GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code);
+GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code);
+GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code);
+GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code);
+GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_SUN_vertex
+#define GL_SUN_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v);
+GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#define GL_EXT_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_blend_func_separate
+#define GL_INGR_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_color_clamp
+#define GL_INGR_color_clamp 1
+#endif
+
+#ifndef GL_INGR_interlace_read
+#define GL_INGR_interlace_read 1
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_EXT_stencil_wrap 1
+#endif
+
+#ifndef GL_EXT_422_pixels
+#define GL_EXT_422_pixels 1
+#endif
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NV_texgen_reflection 1
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_SUN_convolution_border_modes 1
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#define GL_EXT_texture_env_add 1
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_EXT_texture_lod_bias 1
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_EXT_vertex_weighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight);
+GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight);
+GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_NV_light_max_exponent 1
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#define GL_NV_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushVertexArrayRangeNV (void);
+GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_register_combiners
+#define GL_NV_register_combiners 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params);
+GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param);
+GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_NV_fog_distance 1
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_NV_texgen_emboss 1
+#endif
+
+#ifndef GL_NV_blend_square
+#define GL_NV_blend_square 1
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#define GL_NV_texture_env_combine4 1
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#define GL_MESA_resize_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glResizeBuffersMESA (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void);
+#endif
+
+#ifndef GL_MESA_window_pos
+#define GL_MESA_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y);
+GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y);
+GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y);
+GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v);
+GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y);
+GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v);
+GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v);
+GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v);
+GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v);
+GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v);
+GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v);
+GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_IBM_cull_vertex
+#define GL_IBM_cull_vertex 1
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#define GL_IBM_multimode_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
+GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#define GL_IBM_vertex_array_lists 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_SGIX_subsample 1
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_SGIX_ycrcba 1
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#define GL_SGIX_ycrcb_subsample 1
+#endif
+
+#ifndef GL_SGIX_depth_pass_instrument
+#define GL_SGIX_depth_pass_instrument 1
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_3DFX_texture_compression_FXT1 1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_3DFX_multisample 1
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#define GL_3DFX_tbuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
+#endif
+
+#ifndef GL_EXT_multisample
+#define GL_EXT_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert);
+GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_SGIX_vertex_preclip 1
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_SGIX_convolution_accuracy 1
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_SGIX_resample 1
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_SGIS_point_line_texgen 1
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_SGIS_texture_color_mask 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+#endif
+
+#ifndef GL_SGIX_igloo_interface
+#define GL_SGIX_igloo_interface 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params);
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_EXT_texture_env_dot3 1
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_ATI_texture_mirror_once 1
+#endif
+
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);
+GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
+GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence);
+GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence);
+GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);
+GLAPI void APIENTRY glFinishFenceNV (GLuint fence);
+GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
+typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#endif
+
+#ifndef GL_NV_evaluators
+#define GL_NV_evaluators 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
+GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
+GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
+typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_NV_packed_depth_stencil 1
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_NV_register_combiners2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#define GL_NV_texture_compression_vtc 1
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#define GL_NV_texture_rectangle 1
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_NV_texture_shader 1
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_NV_texture_shader2 1
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_NV_vertex_array_range2 1
+#endif
+
+#ifndef GL_NV_vertex_program
+#define GL_NV_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences);
+GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id);
+GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs);
+GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params);
+GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs);
+GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program);
+GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer);
+GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id);
+GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
+GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs);
+GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform);
+GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x);
+GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x);
+GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v);
+GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program);
+typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v);
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_SGIX_texture_coordinate_clamp 1
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SGIX_scalebias_hint 1
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_OML_interlace 1
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_OML_subsample 1
+#endif
+
+#ifndef GL_OML_resample
+#define GL_OML_resample 1
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_NV_copy_depth_to_color 1
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#define GL_ATI_envmap_bumpmap 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param);
+GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param);
+GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param);
+GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#define GL_ATI_fragment_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range);
+GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id);
+GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id);
+GLAPI void APIENTRY glBeginFragmentShaderATI (void);
+GLAPI void APIENTRY glEndFragmentShaderATI (void);
+GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle);
+GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle);
+GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);
+typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value);
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#define GL_ATI_pn_triangles 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param);
+GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#define GL_ATI_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage);
+GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer);
+GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
+GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params);
+GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer);
+GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params);
+GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage);
+typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#define GL_EXT_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginVertexShaderEXT (void);
+GLAPI void APIENTRY glEndVertexShaderEXT (void);
+GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id);
+GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range);
+GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id);
+GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1);
+GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
+GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
+GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num);
+GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num);
+GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
+GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr);
+GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr);
+GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr);
+GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr);
+GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr);
+GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr);
+GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr);
+GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr);
+GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr);
+GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr);
+GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
+GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id);
+GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id);
+GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value);
+GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value);
+GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value);
+GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value);
+GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value);
+GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap);
+GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
+GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data);
+GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
+GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data);
+GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
+GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data);
+GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
+GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);
+GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data);
+GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);
+typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
+typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
+typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
+typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr);
+typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr);
+typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr);
+typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr);
+typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr);
+typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr);
+typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value);
+typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);
+typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_ATI_vertex_streams 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x);
+GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x);
+GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x);
+GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x);
+GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y);
+GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y);
+GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y);
+GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z);
+GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
+GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords);
+GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
+GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords);
+GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz);
+GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords);
+GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
+GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords);
+GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
+GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords);
+GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream);
+GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param);
+GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ATI_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer);
+GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count);
+GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_SUN_mesh_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width);
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SUN_slice_accum 1
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_NV_multisample_filter_hint 1
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_NV_depth_clamp 1
+#endif
+
+#ifndef GL_NV_occlusion_query
+#define GL_NV_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids);
+GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids);
+GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id);
+GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id);
+GLAPI void APIENTRY glEndOcclusionQueryNV (void);
+GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_NV_point_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param);
+GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_NV_texture_shader3
+#define GL_NV_texture_shader3 1
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#define GL_NV_vertex_program1_1 1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#define GL_EXT_shadow_funcs 1
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_EXT_stencil_two_side 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_ATI_text_fragment_shader 1
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 1
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_APPLE_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer);
+GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count);
+GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
+GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_APPLE_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences);
+GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences);
+GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence);
+GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence);
+GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence);
+GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence);
+GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name);
+GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences);
+typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);
+typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_APPLE_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array);
+GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays);
+GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays);
+GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#define GL_APPLE_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer);
+GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer);
+GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_APPLE_ycbcr_422 1
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_S3_s3tc 1
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#define GL_ATI_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_ATI_pixel_format_float 1
+/* This is really a WGL extension, but defines some associated GL enums.
+ * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string.
+ */
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_ATI_texture_env_combine3 1
+#endif
+
+#ifndef GL_ATI_texture_float
+#define GL_ATI_texture_float 1
+#endif
+
+#ifndef GL_NV_float_buffer
+#define GL_NV_float_buffer 1
+#endif
+
+#ifndef GL_NV_fragment_program
+#define GL_NV_fragment_program 1
+/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
+GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
+GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
+GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_NV_half_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y);
+GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z);
+GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s);
+GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t);
+GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r);
+GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s);
+GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t);
+GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v);
+GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog);
+GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog);
+GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v);
+GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight);
+GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight);
+GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x);
+GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y);
+GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s);
+typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog);
+typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#define GL_NV_pixel_data_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer);
+GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_NV_primitive_restart 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPrimitiveRestartNV (void);
+GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void);
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_NV_texture_expand_normal 1
+#endif
+
+#ifndef GL_NV_vertex_program2
+#define GL_NV_vertex_program2 1
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#define GL_ATI_map_object_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer);
+GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#define GL_ATI_separate_stencil 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#define GL_ATI_vertex_attrib_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_OES_read_format 1
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_EXT_depth_bounds_test 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_EXT_texture_mirror_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_EXT_blend_equation_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_MESA_pack_invert 1
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_MESA_ycbcr_texture 1
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_EXT_pixel_buffer_object 1
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#define GL_NV_fragment_program_option 1
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_NV_fragment_program2 1
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+#define GL_NV_vertex_program2_option 1
+#endif
+
+#ifndef GL_NV_vertex_program3
+#define GL_NV_vertex_program3 1
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_EXT_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer);
+GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers);
+GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers);
+GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer);
+GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer);
+GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers);
+GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers);
+GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target);
+GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#define GL_GREMEDY_string_marker 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
+#endif
+
+#ifndef GL_EXT_packed_depth_stencil
+#define GL_EXT_packed_depth_stencil 1
+#endif
+
+#ifndef GL_EXT_stencil_clear_tag
+#define GL_EXT_stencil_clear_tag 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag);
+#endif
+
+#ifndef GL_EXT_texture_sRGB
+#define GL_EXT_texture_sRGB 1
+#endif
+
+#ifndef GL_EXT_framebuffer_blit
+#define GL_EXT_framebuffer_blit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_EXT_framebuffer_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_MESAX_texture_stack
+#define GL_MESAX_texture_stack 1
+#endif
+
+#ifndef GL_EXT_timer_query
+#define GL_EXT_timer_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params);
+GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);
+#endif
+
+#ifndef GL_EXT_gpu_program_parameters
+#define GL_EXT_gpu_program_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+#endif
+
+#ifndef GL_APPLE_flush_buffer_range
+#define GL_APPLE_flush_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size);
+#endif
+
+#ifndef GL_NV_gpu_program4
+#define GL_NV_gpu_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params);
+GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);
+GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params);
+GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);
+GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params);
+GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params);
+GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params);
+GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
+#endif
+
+#ifndef GL_NV_geometry_program4
+#define GL_NV_geometry_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit);
+GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level);
+GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif
+
+#ifndef GL_EXT_geometry_shader4
+#define GL_EXT_geometry_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
+#endif
+
+#ifndef GL_NV_vertex_program4
+#define GL_NV_vertex_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x);
+GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y);
+GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z);
+GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x);
+GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y);
+GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z);
+GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v);
+GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v);
+GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v);
+GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v);
+GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v);
+GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v);
+GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_EXT_gpu_shader4
+#define GL_EXT_gpu_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params);
+GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name);
+GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0);
+GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+#endif
+
+#ifndef GL_EXT_draw_instanced
+#define GL_EXT_draw_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_EXT_packed_float
+#define GL_EXT_packed_float 1
+#endif
+
+#ifndef GL_EXT_texture_array
+#define GL_EXT_texture_array 1
+#endif
+
+#ifndef GL_EXT_texture_buffer_object
+#define GL_EXT_texture_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+#endif
+
+#ifndef GL_EXT_texture_compression_latc
+#define GL_EXT_texture_compression_latc 1
+#endif
+
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_EXT_texture_compression_rgtc 1
+#endif
+
+#ifndef GL_EXT_texture_shared_exponent
+#define GL_EXT_texture_shared_exponent 1
+#endif
+
+#ifndef GL_NV_depth_buffer_float
+#define GL_NV_depth_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar);
+GLAPI void APIENTRY glClearDepthdNV (GLdouble depth);
+GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth);
+typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax);
+#endif
+
+#ifndef GL_NV_fragment_program4
+#define GL_NV_fragment_program4 1
+#endif
+
+#ifndef GL_NV_framebuffer_multisample_coverage
+#define GL_NV_framebuffer_multisample_coverage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_EXT_framebuffer_sRGB
+#define GL_EXT_framebuffer_sRGB 1
+#endif
+
+#ifndef GL_NV_geometry_shader4
+#define GL_NV_geometry_shader4 1
+#endif
+
+#ifndef GL_NV_parameter_buffer_object
+#define GL_NV_parameter_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params);
+GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params);
+#endif
+
+#ifndef GL_EXT_draw_buffers2
+#define GL_EXT_draw_buffers2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data);
+GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data);
+GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index);
+GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index);
+GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data);
+typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
+typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index);
+#endif
+
+#ifndef GL_NV_transform_feedback
+#define GL_NV_transform_feedback 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode);
+GLAPI void APIENTRY glEndTransformFeedbackNV (void);
+GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode);
+GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer);
+GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
+GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name);
+GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name);
+GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location);
+GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);
+#endif
+
+#ifndef GL_EXT_bindable_uniform
+#define GL_EXT_bindable_uniform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer);
+GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location);
+GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location);
+typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location);
+#endif
+
+#ifndef GL_EXT_texture_integer
+#define GL_EXT_texture_integer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha);
+GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha);
+typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
+#endif
+
+#ifndef GL_GREMEDY_frame_terminator
+#define GL_GREMEDY_frame_terminator 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFrameTerminatorGREMEDY (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);
+#endif
+
+#ifndef GL_NV_conditional_render
+#define GL_NV_conditional_render 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode);
+GLAPI void APIENTRY glEndConditionalRenderNV (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void);
+#endif
+
+#ifndef GL_NV_present_video
+#define GL_NV_present_video 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
+GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
+GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params);
+GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
+typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
+typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params);
+#endif
+
+#ifndef GL_EXT_transform_feedback
+#define GL_EXT_transform_feedback 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode);
+GLAPI void APIENTRY glEndTransformFeedbackEXT (void);
+GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer);
+GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
+GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+#endif
+
+#ifndef GL_EXT_direct_state_access
+#define GL_EXT_direct_state_access 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask);
+GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask);
+GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode);
+GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+GLAPI void APIENTRY glMatrixPopEXT (GLenum mode);
+GLAPI void APIENTRY glMatrixPushEXT (GLenum mode);
+GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m);
+GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m);
+GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
+GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);
+GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture);
+GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index);
+GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index);
+GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);
+GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);
+GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);
+GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param);
+GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data);
+GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data);
+GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data);
+GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img);
+GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img);
+GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params);
+GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params);
+GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string);
+GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params);
+GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params);
+GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params);
+GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);
+GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params);
+GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0);
+GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0);
+GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1);
+GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0);
+GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1);
+GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage);
+GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access);
+GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer);
+GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length);
+GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params);
+GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data);
+GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);
+GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);
+GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params);
+GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target);
+GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target);
+GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target);
+GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode);
+GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs);
+GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode);
+GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params);
+GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
+GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);
+GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer);
+GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x);
+GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);
+typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data);
+typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
+typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);
+typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params);
+typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);
+typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);
+typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+#endif
+
+#ifndef GL_EXT_vertex_array_bgra
+#define GL_EXT_vertex_array_bgra 1
+#endif
+
+#ifndef GL_EXT_texture_swizzle
+#define GL_EXT_texture_swizzle 1
+#endif
+
+#ifndef GL_NV_explicit_multisample
+#define GL_NV_explicit_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val);
+GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask);
+GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val);
+typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask);
+typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer);
+#endif
+
+#ifndef GL_NV_transform_feedback2
+#define GL_NV_transform_feedback2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id);
+GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids);
+GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids);
+GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id);
+GLAPI void APIENTRY glPauseTransformFeedbackNV (void);
+GLAPI void APIENTRY glResumeTransformFeedbackNV (void);
+GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids);
+typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);
+#endif
+
+#ifndef GL_ATI_meminfo
+#define GL_ATI_meminfo 1
+#endif
+
+#ifndef GL_AMD_performance_monitor
+#define GL_AMD_performance_monitor 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
+GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
+GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
+GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
+GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor);
+GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
+typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+#endif
+
+#ifndef GL_AMD_texture_texture4
+#define GL_AMD_texture_texture4 1
+#endif
+
+#ifndef GL_AMD_vertex_shader_tesselator
+#define GL_AMD_vertex_shader_tesselator 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor);
+GLAPI void APIENTRY glTessellationModeAMD (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);
+typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_provoking_vertex
+#define GL_EXT_provoking_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_texture_snorm
+#define GL_EXT_texture_snorm 1
+#endif
+
+#ifndef GL_AMD_draw_buffers_blend
+#define GL_AMD_draw_buffers_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst);
+GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode);
+GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+#ifndef GL_APPLE_texture_range
+#define GL_APPLE_texture_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer);
+GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_APPLE_float_pixels
+#define GL_APPLE_float_pixels 1
+#endif
+
+#ifndef GL_APPLE_vertex_program_evaluators
+#define GL_APPLE_vertex_program_evaluators 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname);
+GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname);
+GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname);
+GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
+GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
+GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
+GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
+typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
+#endif
+
+#ifndef GL_APPLE_aux_depth_stencil
+#define GL_APPLE_aux_depth_stencil 1
+#endif
+
+#ifndef GL_APPLE_object_purgeable
+#define GL_APPLE_object_purgeable 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);
+GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);
+GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_APPLE_row_bytes
+#define GL_APPLE_row_bytes 1
+#endif
+
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+#endif
+
+#ifndef GL_NV_video_capture
+#define GL_NV_video_capture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot);
+GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
+GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
+GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot);
+GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
+GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
+GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
+GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
+GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
+GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
+typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
+typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
+typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
+#endif
+
+#ifndef GL_NV_copy_image
+#define GL_NV_copy_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+#ifndef GL_EXT_separate_shader_objects
+#define GL_EXT_separate_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program);
+GLAPI void APIENTRY glActiveProgramEXT (GLuint program);
+GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);
+typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string);
+#endif
+
+#ifndef GL_NV_parameter_buffer_object2
+#define GL_NV_parameter_buffer_object2 1
+#endif
+
+#ifndef GL_NV_shader_buffer_load
+#define GL_NV_shader_buffer_load 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access);
+GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target);
+GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target);
+GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access);
+GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer);
+GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer);
+GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params);
+GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params);
+GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result);
+GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value);
+GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params);
+GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value);
+GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);
+typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);
+typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer);
+typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result);
+typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);
+typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif
+
+#ifndef GL_NV_vertex_buffer_unified_memory
+#define GL_NV_vertex_buffer_unified_memory 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
+GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride);
+GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride);
+GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride);
+GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride);
+GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
+GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);
+GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
+typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
+typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
+#endif
+
+#ifndef GL_NV_texture_barrier
+#define GL_NV_texture_barrier 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureBarrierNV (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void);
+#endif
+
+#ifndef GL_AMD_shader_stencil_export
+#define GL_AMD_shader_stencil_export 1
+#endif
+
+#ifndef GL_AMD_seamless_cubemap_per_texture
+#define GL_AMD_seamless_cubemap_per_texture 1
+#endif
+
+#ifndef GL_AMD_conservative_depth
+#define GL_AMD_conservative_depth 1
+#endif
+
+#ifndef GL_EXT_shader_image_load_store
+#define GL_EXT_shader_image_load_store 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);
+GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);
+typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers);
+#endif
+
+#ifndef GL_EXT_vertex_attrib_64bit
+#define GL_EXT_vertex_attrib_64bit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x);
+GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y);
+GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v);
+GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params);
+GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
+#endif
+
+#ifndef GL_NV_gpu_program5
+#define GL_NV_gpu_program5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params);
+GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param);
+#endif
+
+#ifndef GL_NV_gpu_shader5
+#define GL_NV_gpu_shader5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x);
+GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y);
+GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x);
+GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y);
+GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params);
+GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x);
+GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);
+GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x);
+GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);
+GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x);
+typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y);
+typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x);
+typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y);
+typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
+#endif
+
+#ifndef GL_NV_shader_buffer_store
+#define GL_NV_shader_buffer_store 1
+#endif
+
+#ifndef GL_NV_tessellation_program5
+#define GL_NV_tessellation_program5 1
+#endif
+
+#ifndef GL_NV_vertex_attrib_integer_64bit
+#define GL_NV_vertex_attrib_integer_64bit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x);
+GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y);
+GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x);
+GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y);
+GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v);
+GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params);
+GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params);
+GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
+#endif
+
+#ifndef GL_NV_multisample_coverage
+#define GL_NV_multisample_coverage 1
+#endif
+
+#ifndef GL_AMD_name_gen_delete
+#define GL_AMD_name_gen_delete 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names);
+GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names);
+GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names);
+typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names);
+typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name);
+#endif
+
+#ifndef GL_AMD_debug_output
+#define GL_AMD_debug_output 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);
+GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam);
+GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam);
+typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);
+#endif
+
+#ifndef GL_NV_vdpau_interop
+#define GL_NV_vdpau_interop 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress);
+GLAPI void APIENTRY glVDPAUFiniNV (void);
+GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface);
+GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface);
+GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access);
+GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);
+GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress);
+typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void);
+typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
+typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface);
+typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface);
+typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access);
+typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);
+typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
+#endif
+
+#ifndef GL_AMD_transform_feedback3_lines_triangles
+#define GL_AMD_transform_feedback3_lines_triangles 1
+#endif
+
+#ifndef GL_AMD_depth_clamp_separate
+#define GL_AMD_depth_clamp_separate 1
+#endif
+
+#ifndef GL_EXT_texture_sRGB_decode
+#define GL_EXT_texture_sRGB_decode 1
+#endif
+
+#ifndef GL_NV_texture_multisample
+#define GL_NV_texture_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
+#endif
+
+#ifndef GL_AMD_blend_minmax_factor
+#define GL_AMD_blend_minmax_factor 1
+#endif
+
+#ifndef GL_AMD_sample_positions
+#define GL_AMD_sample_positions 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val);
+#endif
+
+#ifndef GL_EXT_x11_sync_object
+#define GL_EXT_x11_sync_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
+#endif
+
+#ifndef GL_AMD_multi_draw_indirect
+#define GL_AMD_multi_draw_indirect 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample_blit_scaled
+#define GL_EXT_framebuffer_multisample_blit_scaled 1
+#endif
+
+#ifndef GL_NV_path_rendering
+#define GL_NV_path_rendering 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range);
+GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range);
+GLAPI GLboolean APIENTRY glIsPathNV (GLuint path);
+GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString);
+GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);
+GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath);
+GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);
+GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value);
+GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value);
+GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value);
+GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value);
+GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray);
+GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask);
+GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units);
+GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask);
+GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask);
+GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func);
+GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs);
+GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs);
+GLAPI void APIENTRY glPathFogGenNV (GLenum genMode);
+GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode);
+GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode);
+GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value);
+GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value);
+GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands);
+GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords);
+GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray);
+GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);
+GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);
+GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);
+GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value);
+GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value);
+GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value);
+GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value);
+GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y);
+GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y);
+GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments);
+GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range);
+typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);
+typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path);
+typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords);
+typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString);
+typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);
+typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);
+typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath);
+typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);
+typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value);
+typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value);
+typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray);
+typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units);
+typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func);
+typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs);
+typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs);
+typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode);
+typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode);
+typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode);
+typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);
+typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value);
+typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value);
+typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands);
+typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords);
+typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray);
+typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);
+typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);
+typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);
+typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value);
+typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value);
+typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value);
+typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value);
+typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y);
+typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);
+typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);
+typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);
+#endif
+
+#ifndef GL_AMD_pinned_memory
+#define GL_AMD_pinned_memory 1
+#endif
+
+#ifndef GL_AMD_stencil_operation_extended
+#define GL_AMD_stencil_operation_extended 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value);
+#endif
+
+#ifndef GL_AMD_vertex_shader_viewport_index
+#define GL_AMD_vertex_shader_viewport_index 1
+#endif
+
+#ifndef GL_AMD_vertex_shader_layer
+#define GL_AMD_vertex_shader_layer 1
+#endif
+
+#ifndef GL_NV_bindless_texture
+#define GL_NV_bindless_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture);
+GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler);
+GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle);
+GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle);
+GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);
+GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access);
+GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle);
+GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value);
+GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value);
+GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value);
+GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values);
+GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle);
+GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture);
+typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler);
+typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);
+typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle);
+typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);
+typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access);
+typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle);
+typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value);
+typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values);
+typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);
+typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle);
+#endif
+
+#ifndef GL_NV_shader_atomic_float
+#define GL_NV_shader_atomic_float 1
+#endif
+
+#ifndef GL_AMD_query_buffer_object
+#define GL_AMD_query_buffer_object 1
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/thirdparty/khronos/GL/glext.patch b/thirdparty/khronos/GL/glext.patch
new file mode 100644 (file)
index 0000000..0ab1430
--- /dev/null
@@ -0,0 +1,22 @@
+# MacOSX doesn't follow the official glext.h definition for GLhandleARB, and
+# instead defines it as:
+#
+#   typedef void *GLhandleARB;
+#
+# But to avoid integer to pointer conversion issues, we simply use 'unsigned
+# long' which should be the same size on all supported architectures.
+--- glext.h.orig       2012-03-05 11:00:02.000000000 +0000
++++ glext.h    2012-03-14 08:56:54.199519853 +0000
+@@ -5484,8 +5484,12 @@
+ #ifndef GL_ARB_shader_objects
+ /* GL types for program/shader text and shader object handles */
+ typedef char GLcharARB;
++#ifdef __APPLE__
++typedef unsigned long GLhandleARB;
++#else
+ typedef unsigned int GLhandleARB;
+ #endif
++#endif
+ /* GL type for "half" precision (s10e5) float data in host memory */
+ #ifndef GL_ARB_half_float_pixel
diff --git a/thirdparty/khronos/GL/glx.h b/thirdparty/khronos/GL/glx.h
new file mode 100644 (file)
index 0000000..64b8071
--- /dev/null
@@ -0,0 +1,325 @@
+#ifndef __glx_h__
+#define __glx_h__
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/gl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GLX_VERSION_1_1 1
+#define GLX_VERSION_1_2 1
+#define GLX_VERSION_1_3 1
+
+/*
+** Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib)
+*/
+#define GLX_USE_GL             1       /* support GLX rendering */
+#define GLX_BUFFER_SIZE                2       /* depth of the color buffer */
+#define GLX_LEVEL              3       /* level in plane stacking */
+#define GLX_RGBA               4       /* true if RGBA mode */
+#define GLX_DOUBLEBUFFER       5       /* double buffering supported */
+#define GLX_STEREO             6       /* stereo buffering supported */
+#define GLX_AUX_BUFFERS                7       /* number of aux buffers */
+#define GLX_RED_SIZE           8       /* number of red component bits */
+#define GLX_GREEN_SIZE         9       /* number of green component bits */
+#define GLX_BLUE_SIZE          10      /* number of blue component bits */
+#define GLX_ALPHA_SIZE         11      /* number of alpha component bits */
+#define GLX_DEPTH_SIZE         12      /* number of depth bits */
+#define GLX_STENCIL_SIZE       13      /* number of stencil bits */
+#define GLX_ACCUM_RED_SIZE     14      /* number of red accum bits */
+#define GLX_ACCUM_GREEN_SIZE   15      /* number of green accum bits */
+#define GLX_ACCUM_BLUE_SIZE    16      /* number of blue accum bits */
+#define GLX_ACCUM_ALPHA_SIZE   17      /* number of alpha accum bits */
+/*
+** FBConfig-specific attributes
+*/
+#define GLX_X_VISUAL_TYPE              0x22
+#define GLX_CONFIG_CAVEAT              0x20    /* Like visual_info VISUAL_CAVEAT_EXT */
+#define GLX_TRANSPARENT_TYPE           0x23
+#define GLX_TRANSPARENT_INDEX_VALUE    0x24
+#define GLX_TRANSPARENT_RED_VALUE      0x25
+#define GLX_TRANSPARENT_GREEN_VALUE    0x26
+#define GLX_TRANSPARENT_BLUE_VALUE     0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE    0x28
+#define GLX_DRAWABLE_TYPE              0x8010
+#define GLX_RENDER_TYPE                        0x8011
+#define GLX_X_RENDERABLE               0x8012
+#define GLX_FBCONFIG_ID                        0x8013
+#define GLX_MAX_PBUFFER_WIDTH          0x8016
+#define GLX_MAX_PBUFFER_HEIGHT         0x8017
+#define GLX_MAX_PBUFFER_PIXELS         0x8018
+#define GLX_VISUAL_ID                  0x800B
+
+/*
+** Error return values from glXGetConfig.  Success is indicated by
+** a value of 0.
+*/
+#define GLX_BAD_SCREEN         1       /* screen # is bad */
+#define GLX_BAD_ATTRIBUTE      2       /* attribute to get is bad */
+#define GLX_NO_EXTENSION       3       /* no glx extension on server */
+#define GLX_BAD_VISUAL         4       /* visual # not known by GLX */
+#define GLX_BAD_CONTEXT                5       /* returned only by import_context EXT? */
+#define GLX_BAD_VALUE          6       /* returned only by glXSwapIntervalSGI? */
+#define GLX_BAD_ENUM           7       /* unused? */
+
+/* FBConfig attribute values */
+
+/*
+** Generic "don't care" value for glX ChooseFBConfig attributes (except
+** GLX_LEVEL)
+*/
+#define GLX_DONT_CARE                  0xFFFFFFFF
+
+/* GLX_RENDER_TYPE bits */
+#define GLX_RGBA_BIT                   0x00000001
+#define GLX_COLOR_INDEX_BIT            0x00000002
+
+/* GLX_DRAWABLE_TYPE bits */
+#define GLX_WINDOW_BIT                 0x00000001
+#define GLX_PIXMAP_BIT                 0x00000002
+#define GLX_PBUFFER_BIT                        0x00000004
+
+/* GLX_CONFIG_CAVEAT attribute values */
+#define GLX_NONE                       0x8000
+#define GLX_SLOW_CONFIG                        0x8001
+#define GLX_NON_CONFORMANT_CONFIG      0x800D
+
+/* GLX_X_VISUAL_TYPE attribute values */
+#define GLX_TRUE_COLOR                 0x8002
+#define GLX_DIRECT_COLOR               0x8003
+#define GLX_PSEUDO_COLOR               0x8004
+#define GLX_STATIC_COLOR               0x8005
+#define GLX_GRAY_SCALE                 0x8006
+#define GLX_STATIC_GRAY                        0x8007
+
+/* GLX_TRANSPARENT_TYPE attribute values */
+/* #define GLX_NONE                       0x8000 */
+#define GLX_TRANSPARENT_RGB            0x8008
+#define GLX_TRANSPARENT_INDEX          0x8009
+
+/* glXCreateGLXPbuffer attributes */
+#define GLX_PRESERVED_CONTENTS         0x801B
+#define GLX_LARGEST_PBUFFER            0x801C
+#define GLX_PBUFFER_HEIGHT             0x8040  /* New for GLX 1.3 */
+#define GLX_PBUFFER_WIDTH              0x8041  /* New for GLX 1.3 */
+
+/* glXQueryGLXPBuffer attributes */
+#define GLX_WIDTH                      0x801D
+#define GLX_HEIGHT                     0x801E
+#define GLX_EVENT_MASK                 0x801F
+
+/* glXCreateNewContext render_type attribute values */
+#define GLX_RGBA_TYPE                  0x8014
+#define GLX_COLOR_INDEX_TYPE           0x8015
+
+/* glXQueryContext attributes */
+/* #define GLX_FBCONFIG_ID               0x8013 */
+/* #define GLX_RENDER_TYPE               0x8011 */
+#define GLX_SCREEN                     0x800C
+
+/* glXSelectEvent event mask bits */
+#define GLX_PBUFFER_CLOBBER_MASK       0x08000000
+
+/* GLXPbufferClobberEvent event_type values */
+#define GLX_DAMAGED                    0x8020
+#define GLX_SAVED                      0x8021
+
+/* GLXPbufferClobberEvent draw_type values */
+#define GLX_WINDOW                     0x8022
+#define GLX_PBUFFER                    0x8023
+
+/* GLXPbufferClobberEvent buffer_mask bits */
+#define GLX_FRONT_LEFT_BUFFER_BIT      0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT     0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT       0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT      0x00000008
+#define GLX_AUX_BUFFERS_BIT            0x00000010
+#define GLX_DEPTH_BUFFER_BIT           0x00000020
+#define GLX_STENCIL_BUFFER_BIT         0x00000040
+#define GLX_ACCUM_BUFFER_BIT           0x00000080
+
+/*
+** Extension return values from glXGetConfig.  These are also
+** accepted as parameter values for glXChooseVisual.
+*/
+
+#define GLX_X_VISUAL_TYPE_EXT  0x22    /* visual_info extension type */
+#define GLX_TRANSPARENT_TYPE_EXT 0x23  /* visual_info extension */
+#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24   /* visual_info extension */
+#define GLX_TRANSPARENT_RED_VALUE_EXT  0x25    /* visual_info extension */
+#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26   /* visual_info extension */
+#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27    /* visual_info extension */
+#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28   /* visual_info extension */
+
+/* Property values for visual_type */
+#define GLX_TRUE_COLOR_EXT     0x8002
+#define GLX_DIRECT_COLOR_EXT   0x8003
+#define GLX_PSEUDO_COLOR_EXT   0x8004
+#define GLX_STATIC_COLOR_EXT   0x8005
+#define GLX_GRAY_SCALE_EXT     0x8006
+#define GLX_STATIC_GRAY_EXT    0x8007
+
+/* Property values for transparent pixel */
+#define GLX_NONE_EXT           0x8000
+#define GLX_TRANSPARENT_RGB_EXT                0x8008
+#define GLX_TRANSPARENT_INDEX_EXT      0x8009
+
+/* Property values for visual_rating */
+#define GLX_VISUAL_CAVEAT_EXT          0x20  /* visual_rating extension type */
+#define GLX_SLOW_VISUAL_EXT            0x8001
+#define GLX_NON_CONFORMANT_VISUAL_EXT  0x800D
+
+/*
+** Names for attributes to glXGetClientString.
+*/
+#define GLX_VENDOR             0x1
+#define GLX_VERSION            0x2
+#define GLX_EXTENSIONS         0x3
+
+/*
+** Names for attributes to glXQueryContextInfoEXT.
+*/
+#define GLX_SHARE_CONTEXT_EXT  0x800A  /* id of share context */
+#define GLX_VISUAL_ID_EXT      0x800B  /* id of context's visual */
+#define GLX_SCREEN_EXT         0x800C  /* screen number */
+
+/* GLX Extension Strings */
+#define GLX_EXT_import_context 1
+#define GLX_EXT_visual_info    1
+#define GLX_EXT_visual_rating  1
+
+/*
+** GLX resources.
+*/
+typedef XID GLXContextID;
+typedef XID GLXPixmap;
+typedef XID GLXDrawable;
+typedef XID GLXPbuffer;
+typedef XID GLXWindow;
+typedef XID GLXFBConfigID;
+
+/*
+** GLXContext is a pointer to opaque data.
+*/
+typedef struct __GLXcontextRec *GLXContext;
+
+/*
+** GLXFBConfig is a pointer to opaque data.
+*/
+typedef struct __GLXFBConfigRec *GLXFBConfig;
+
+/************************************************************************/
+
+extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList);
+extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
+extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
+extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap);
+extern void glXDestroyContext (Display *dpy, GLXContext ctx);
+extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix);
+extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value);
+extern GLXContext glXGetCurrentContext (void);
+extern GLXDrawable glXGetCurrentDrawable (void);
+extern Bool glXIsDirect (Display *dpy, GLXContext ctx);
+extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx);
+extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase);
+extern Bool glXQueryVersion (Display *dpy, int *major, int *minor);
+extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable);
+extern void glXUseXFont (Font font, int first, int count, int listBase);
+extern void glXWaitGL (void);
+extern void glXWaitX (void);
+extern const char * glXGetClientString (Display *dpy, int name );
+extern const char * glXQueryServerString (Display *dpy, int screen, int name );
+extern const char * glXQueryExtensionsString (Display *dpy, int screen );
+
+/* New for GLX 1.3 */
+extern GLXFBConfig * glXGetFBConfigs (Display *dpy, int screen, int *nelements);
+extern GLXFBConfig * glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements);
+extern int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value);
+extern XVisualInfo * glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config);
+extern GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
+extern void glXDestroyWindow (Display *dpy, GLXWindow win);
+extern GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
+extern void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap);
+extern GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list);
+extern void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf);
+extern void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
+extern GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
+extern Bool glXMakeContextCurrent (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+extern GLXDrawable glXGetCurrentReadDrawable (void);
+extern Display * glXGetCurrentDisplay (void);
+extern int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value);
+extern void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask);
+extern void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
+
+/*** SGI GLX extensions */
+extern GLXContextID glXGetContextIDEXT (const GLXContext ctx);
+extern GLXDrawable glXGetCurrentDrawableEXT (void);
+extern GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID);
+extern void glXFreeContextEXT (Display *dpy, GLXContext ctx);
+extern int glXQueryContextInfoEXT (Display *dpy, GLXContext ctx, int attribute, int *value);
+
+/*** Should these go here, or in another header? */
+/*
+** GLX Events
+*/
+typedef struct {
+    int event_type;            /* GLX_DAMAGED or GLX_SAVED */
+    int draw_type;             /* GLX_WINDOW or GLX_PBUFFER */
+    unsigned long serial;      /* # of last request processed by server */
+    Bool send_event;           /* true if this came for SendEvent request */
+    Display *display;          /* display the event was read from */
+    GLXDrawable drawable;      /* XID of Drawable */
+    unsigned int buffer_mask;  /* mask indicating which buffers are affected */
+    unsigned int aux_buffer;   /* which aux buffer was affected */
+    int x, y;
+    int width, height;
+    int count;                 /* if nonzero, at least this many more */
+} GLXPbufferClobberEvent;
+
+typedef union __GLXEvent {
+    GLXPbufferClobberEvent glxpbufferclobber;
+    long pad[24];
+} GLXEvent;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !__glx_h__ */
diff --git a/thirdparty/khronos/GL/glxext.h b/thirdparty/khronos/GL/glxext.h
new file mode 100644 (file)
index 0000000..e640ff7
--- /dev/null
@@ -0,0 +1,1001 @@
+#ifndef __glxext_h_
+#define __glxext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2012 The Khronos Group Inc.
+** 
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+** 
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+** 
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Function declaration macros - to move into glplatform.h */
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+/* Header file version number, required by OpenGL ABI for Linux */
+/* glxext.h last updated 2012/02/29 */
+/* Current version at http://www.opengl.org/registry/ */
+#define GLX_GLXEXT_VERSION 33
+
+#ifndef GLX_VERSION_1_3
+#define GLX_WINDOW_BIT                     0x00000001
+#define GLX_PIXMAP_BIT                     0x00000002
+#define GLX_PBUFFER_BIT                    0x00000004
+#define GLX_RGBA_BIT                       0x00000001
+#define GLX_COLOR_INDEX_BIT                0x00000002
+#define GLX_PBUFFER_CLOBBER_MASK           0x08000000
+#define GLX_FRONT_LEFT_BUFFER_BIT          0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT         0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT           0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT          0x00000008
+#define GLX_AUX_BUFFERS_BIT                0x00000010
+#define GLX_DEPTH_BUFFER_BIT               0x00000020
+#define GLX_STENCIL_BUFFER_BIT             0x00000040
+#define GLX_ACCUM_BUFFER_BIT               0x00000080
+#define GLX_CONFIG_CAVEAT                  0x20
+#define GLX_X_VISUAL_TYPE                  0x22
+#define GLX_TRANSPARENT_TYPE               0x23
+#define GLX_TRANSPARENT_INDEX_VALUE        0x24
+#define GLX_TRANSPARENT_RED_VALUE          0x25
+#define GLX_TRANSPARENT_GREEN_VALUE        0x26
+#define GLX_TRANSPARENT_BLUE_VALUE         0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE        0x28
+#define GLX_DONT_CARE                      0xFFFFFFFF
+#define GLX_NONE                           0x8000
+#define GLX_SLOW_CONFIG                    0x8001
+#define GLX_TRUE_COLOR                     0x8002
+#define GLX_DIRECT_COLOR                   0x8003
+#define GLX_PSEUDO_COLOR                   0x8004
+#define GLX_STATIC_COLOR                   0x8005
+#define GLX_GRAY_SCALE                     0x8006
+#define GLX_STATIC_GRAY                    0x8007
+#define GLX_TRANSPARENT_RGB                0x8008
+#define GLX_TRANSPARENT_INDEX              0x8009
+#define GLX_VISUAL_ID                      0x800B
+#define GLX_SCREEN                         0x800C
+#define GLX_NON_CONFORMANT_CONFIG          0x800D
+#define GLX_DRAWABLE_TYPE                  0x8010
+#define GLX_RENDER_TYPE                    0x8011
+#define GLX_X_RENDERABLE                   0x8012
+#define GLX_FBCONFIG_ID                    0x8013
+#define GLX_RGBA_TYPE                      0x8014
+#define GLX_COLOR_INDEX_TYPE               0x8015
+#define GLX_MAX_PBUFFER_WIDTH              0x8016
+#define GLX_MAX_PBUFFER_HEIGHT             0x8017
+#define GLX_MAX_PBUFFER_PIXELS             0x8018
+#define GLX_PRESERVED_CONTENTS             0x801B
+#define GLX_LARGEST_PBUFFER                0x801C
+#define GLX_WIDTH                          0x801D
+#define GLX_HEIGHT                         0x801E
+#define GLX_EVENT_MASK                     0x801F
+#define GLX_DAMAGED                        0x8020
+#define GLX_SAVED                          0x8021
+#define GLX_WINDOW                         0x8022
+#define GLX_PBUFFER                        0x8023
+#define GLX_PBUFFER_HEIGHT                 0x8040
+#define GLX_PBUFFER_WIDTH                  0x8041
+#endif
+
+#ifndef GLX_VERSION_1_4
+#define GLX_SAMPLE_BUFFERS                 100000
+#define GLX_SAMPLES                        100001
+#endif
+
+#ifndef GLX_ARB_get_proc_address
+#endif
+
+#ifndef GLX_ARB_multisample
+#define GLX_SAMPLE_BUFFERS_ARB             100000
+#define GLX_SAMPLES_ARB                    100001
+#endif
+
+#ifndef GLX_ARB_vertex_buffer_object
+#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095
+#endif
+
+#ifndef GLX_ARB_fbconfig_float
+#define GLX_RGBA_FLOAT_TYPE_ARB            0x20B9
+#define GLX_RGBA_FLOAT_BIT_ARB             0x00000004
+#endif
+
+#ifndef GLX_ARB_framebuffer_sRGB
+#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB   0x20B2
+#endif
+
+#ifndef GLX_ARB_create_context
+#define GLX_CONTEXT_DEBUG_BIT_ARB          0x00000001
+#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
+#define GLX_CONTEXT_MAJOR_VERSION_ARB      0x2091
+#define GLX_CONTEXT_MINOR_VERSION_ARB      0x2092
+#define GLX_CONTEXT_FLAGS_ARB              0x2094
+#endif
+
+#ifndef GLX_ARB_create_context_profile
+#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB   0x00000001
+#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#define GLX_CONTEXT_PROFILE_MASK_ARB       0x9126
+#endif
+
+#ifndef GLX_ARB_create_context_robustness
+#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB  0x00000004
+#define GLX_LOSE_CONTEXT_ON_RESET_ARB      0x8252
+#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define GLX_NO_RESET_NOTIFICATION_ARB      0x8261
+#endif
+
+#ifndef GLX_SGIS_multisample
+#define GLX_SAMPLE_BUFFERS_SGIS            100000
+#define GLX_SAMPLES_SGIS                   100001
+#endif
+
+#ifndef GLX_EXT_visual_info
+#define GLX_X_VISUAL_TYPE_EXT              0x22
+#define GLX_TRANSPARENT_TYPE_EXT           0x23
+#define GLX_TRANSPARENT_INDEX_VALUE_EXT    0x24
+#define GLX_TRANSPARENT_RED_VALUE_EXT      0x25
+#define GLX_TRANSPARENT_GREEN_VALUE_EXT    0x26
+#define GLX_TRANSPARENT_BLUE_VALUE_EXT     0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE_EXT    0x28
+#define GLX_NONE_EXT                       0x8000
+#define GLX_TRUE_COLOR_EXT                 0x8002
+#define GLX_DIRECT_COLOR_EXT               0x8003
+#define GLX_PSEUDO_COLOR_EXT               0x8004
+#define GLX_STATIC_COLOR_EXT               0x8005
+#define GLX_GRAY_SCALE_EXT                 0x8006
+#define GLX_STATIC_GRAY_EXT                0x8007
+#define GLX_TRANSPARENT_RGB_EXT            0x8008
+#define GLX_TRANSPARENT_INDEX_EXT          0x8009
+#endif
+
+#ifndef GLX_SGI_swap_control
+#endif
+
+#ifndef GLX_SGI_video_sync
+#endif
+
+#ifndef GLX_SGI_make_current_read
+#endif
+
+#ifndef GLX_SGIX_video_source
+#endif
+
+#ifndef GLX_EXT_visual_rating
+#define GLX_VISUAL_CAVEAT_EXT              0x20
+#define GLX_SLOW_VISUAL_EXT                0x8001
+#define GLX_NON_CONFORMANT_VISUAL_EXT      0x800D
+/* reuse GLX_NONE_EXT */
+#endif
+
+#ifndef GLX_EXT_import_context
+#define GLX_SHARE_CONTEXT_EXT              0x800A
+#define GLX_VISUAL_ID_EXT                  0x800B
+#define GLX_SCREEN_EXT                     0x800C
+#endif
+
+#ifndef GLX_SGIX_fbconfig
+#define GLX_WINDOW_BIT_SGIX                0x00000001
+#define GLX_PIXMAP_BIT_SGIX                0x00000002
+#define GLX_RGBA_BIT_SGIX                  0x00000001
+#define GLX_COLOR_INDEX_BIT_SGIX           0x00000002
+#define GLX_DRAWABLE_TYPE_SGIX             0x8010
+#define GLX_RENDER_TYPE_SGIX               0x8011
+#define GLX_X_RENDERABLE_SGIX              0x8012
+#define GLX_FBCONFIG_ID_SGIX               0x8013
+#define GLX_RGBA_TYPE_SGIX                 0x8014
+#define GLX_COLOR_INDEX_TYPE_SGIX          0x8015
+/* reuse GLX_SCREEN_EXT */
+#endif
+
+#ifndef GLX_SGIX_pbuffer
+#define GLX_PBUFFER_BIT_SGIX               0x00000004
+#define GLX_BUFFER_CLOBBER_MASK_SGIX       0x08000000
+#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX     0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX    0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT_SGIX      0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX     0x00000008
+#define GLX_AUX_BUFFERS_BIT_SGIX           0x00000010
+#define GLX_DEPTH_BUFFER_BIT_SGIX          0x00000020
+#define GLX_STENCIL_BUFFER_BIT_SGIX        0x00000040
+#define GLX_ACCUM_BUFFER_BIT_SGIX          0x00000080
+#define GLX_SAMPLE_BUFFERS_BIT_SGIX        0x00000100
+#define GLX_MAX_PBUFFER_WIDTH_SGIX         0x8016
+#define GLX_MAX_PBUFFER_HEIGHT_SGIX        0x8017
+#define GLX_MAX_PBUFFER_PIXELS_SGIX        0x8018
+#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX     0x8019
+#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX    0x801A
+#define GLX_PRESERVED_CONTENTS_SGIX        0x801B
+#define GLX_LARGEST_PBUFFER_SGIX           0x801C
+#define GLX_WIDTH_SGIX                     0x801D
+#define GLX_HEIGHT_SGIX                    0x801E
+#define GLX_EVENT_MASK_SGIX                0x801F
+#define GLX_DAMAGED_SGIX                   0x8020
+#define GLX_SAVED_SGIX                     0x8021
+#define GLX_WINDOW_SGIX                    0x8022
+#define GLX_PBUFFER_SGIX                   0x8023
+#endif
+
+#ifndef GLX_SGI_cushion
+#endif
+
+#ifndef GLX_SGIX_video_resize
+#define GLX_SYNC_FRAME_SGIX                0x00000000
+#define GLX_SYNC_SWAP_SGIX                 0x00000001
+#endif
+
+#ifndef GLX_SGIX_dmbuffer
+#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX     0x8024
+#endif
+
+#ifndef GLX_SGIX_swap_group
+#endif
+
+#ifndef GLX_SGIX_swap_barrier
+#endif
+
+#ifndef GLX_SGIS_blended_overlay
+#define GLX_BLENDED_RGBA_SGIS              0x8025
+#endif
+
+#ifndef GLX_SGIS_shared_multisample
+#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026
+#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027
+#endif
+
+#ifndef GLX_SUN_get_transparent_index
+#endif
+
+#ifndef GLX_3DFX_multisample
+#define GLX_SAMPLE_BUFFERS_3DFX            0x8050
+#define GLX_SAMPLES_3DFX                   0x8051
+#endif
+
+#ifndef GLX_MESA_copy_sub_buffer
+#endif
+
+#ifndef GLX_MESA_pixmap_colormap
+#endif
+
+#ifndef GLX_MESA_release_buffers
+#endif
+
+#ifndef GLX_MESA_set_3dfx_mode
+#define GLX_3DFX_WINDOW_MODE_MESA          0x1
+#define GLX_3DFX_FULLSCREEN_MODE_MESA      0x2
+#endif
+
+#ifndef GLX_SGIX_visual_select_group
+#define GLX_VISUAL_SELECT_GROUP_SGIX       0x8028
+#endif
+
+#ifndef GLX_OML_swap_method
+#define GLX_SWAP_METHOD_OML                0x8060
+#define GLX_SWAP_EXCHANGE_OML              0x8061
+#define GLX_SWAP_COPY_OML                  0x8062
+#define GLX_SWAP_UNDEFINED_OML             0x8063
+#endif
+
+#ifndef GLX_OML_sync_control
+#endif
+
+#ifndef GLX_NV_float_buffer
+#define GLX_FLOAT_COMPONENTS_NV            0x20B0
+#endif
+
+#ifndef GLX_SGIX_hyperpipe
+#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80
+#define GLX_BAD_HYPERPIPE_CONFIG_SGIX      91
+#define GLX_BAD_HYPERPIPE_SGIX             92
+#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX    0x00000001
+#define GLX_HYPERPIPE_RENDER_PIPE_SGIX     0x00000002
+#define GLX_PIPE_RECT_SGIX                 0x00000001
+#define GLX_PIPE_RECT_LIMITS_SGIX          0x00000002
+#define GLX_HYPERPIPE_STEREO_SGIX          0x00000003
+#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX   0x00000004
+#define GLX_HYPERPIPE_ID_SGIX              0x8030
+#endif
+
+#ifndef GLX_MESA_agp_offset
+#endif
+
+#ifndef GLX_EXT_fbconfig_packed_float
+#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT   0x20B1
+#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT    0x00000008
+#endif
+
+#ifndef GLX_EXT_framebuffer_sRGB
+#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT   0x20B2
+#endif
+
+#ifndef GLX_EXT_texture_from_pixmap
+#define GLX_TEXTURE_1D_BIT_EXT             0x00000001
+#define GLX_TEXTURE_2D_BIT_EXT             0x00000002
+#define GLX_TEXTURE_RECTANGLE_BIT_EXT      0x00000004
+#define GLX_BIND_TO_TEXTURE_RGB_EXT        0x20D0
+#define GLX_BIND_TO_TEXTURE_RGBA_EXT       0x20D1
+#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT     0x20D2
+#define GLX_BIND_TO_TEXTURE_TARGETS_EXT    0x20D3
+#define GLX_Y_INVERTED_EXT                 0x20D4
+#define GLX_TEXTURE_FORMAT_EXT             0x20D5
+#define GLX_TEXTURE_TARGET_EXT             0x20D6
+#define GLX_MIPMAP_TEXTURE_EXT             0x20D7
+#define GLX_TEXTURE_FORMAT_NONE_EXT        0x20D8
+#define GLX_TEXTURE_FORMAT_RGB_EXT         0x20D9
+#define GLX_TEXTURE_FORMAT_RGBA_EXT        0x20DA
+#define GLX_TEXTURE_1D_EXT                 0x20DB
+#define GLX_TEXTURE_2D_EXT                 0x20DC
+#define GLX_TEXTURE_RECTANGLE_EXT          0x20DD
+#define GLX_FRONT_LEFT_EXT                 0x20DE
+#define GLX_FRONT_RIGHT_EXT                0x20DF
+#define GLX_BACK_LEFT_EXT                  0x20E0
+#define GLX_BACK_RIGHT_EXT                 0x20E1
+#define GLX_FRONT_EXT                      GLX_FRONT_LEFT_EXT
+#define GLX_BACK_EXT                       GLX_BACK_LEFT_EXT
+#define GLX_AUX0_EXT                       0x20E2
+#define GLX_AUX1_EXT                       0x20E3
+#define GLX_AUX2_EXT                       0x20E4
+#define GLX_AUX3_EXT                       0x20E5
+#define GLX_AUX4_EXT                       0x20E6
+#define GLX_AUX5_EXT                       0x20E7
+#define GLX_AUX6_EXT                       0x20E8
+#define GLX_AUX7_EXT                       0x20E9
+#define GLX_AUX8_EXT                       0x20EA
+#define GLX_AUX9_EXT                       0x20EB
+#endif
+
+#ifndef GLX_NV_present_video
+#define GLX_NUM_VIDEO_SLOTS_NV             0x20F0
+#endif
+
+#ifndef GLX_NV_video_out
+#define GLX_VIDEO_OUT_COLOR_NV             0x20C3
+#define GLX_VIDEO_OUT_ALPHA_NV             0x20C4
+#define GLX_VIDEO_OUT_DEPTH_NV             0x20C5
+#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV   0x20C6
+#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV   0x20C7
+#define GLX_VIDEO_OUT_FRAME_NV             0x20C8
+#define GLX_VIDEO_OUT_FIELD_1_NV           0x20C9
+#define GLX_VIDEO_OUT_FIELD_2_NV           0x20CA
+#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB
+#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC
+#endif
+
+#ifndef GLX_NV_swap_group
+#endif
+
+#ifndef GLX_NV_video_capture
+#define GLX_DEVICE_ID_NV                   0x20CD
+#define GLX_UNIQUE_ID_NV                   0x20CE
+#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV     0x20CF
+#endif
+
+#ifndef GLX_EXT_swap_control
+#define GLX_SWAP_INTERVAL_EXT              0x20F1
+#define GLX_MAX_SWAP_INTERVAL_EXT          0x20F2
+#endif
+
+#ifndef GLX_NV_copy_image
+#endif
+
+#ifndef GLX_INTEL_swap_event
+#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000
+#define GLX_EXCHANGE_COMPLETE_INTEL        0x8180
+#define GLX_COPY_COMPLETE_INTEL            0x8181
+#define GLX_FLIP_COMPLETE_INTEL            0x8182
+#endif
+
+#ifndef GLX_NV_multisample_coverage
+#define GLX_COVERAGE_SAMPLES_NV            100001
+#define GLX_COLOR_SAMPLES_NV               0x20B3
+#endif
+
+#ifndef GLX_AMD_gpu_association
+#define GLX_GPU_VENDOR_AMD                 0x1F00
+#define GLX_GPU_RENDERER_STRING_AMD        0x1F01
+#define GLX_GPU_OPENGL_VERSION_STRING_AMD  0x1F02
+#define GLX_GPU_FASTEST_TARGET_GPUS_AMD    0x21A2
+#define GLX_GPU_RAM_AMD                    0x21A3
+#define GLX_GPU_CLOCK_AMD                  0x21A4
+#define GLX_GPU_NUM_PIPES_AMD              0x21A5
+#define GLX_GPU_NUM_SIMD_AMD               0x21A6
+#define GLX_GPU_NUM_RB_AMD                 0x21A7
+#define GLX_GPU_NUM_SPI_AMD                0x21A8
+#endif
+
+#ifndef GLX_EXT_create_context_es2_profile
+#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT    0x00000004
+#endif
+
+#ifndef GLX_EXT_swap_control_tear
+#define GLX_LATE_SWAPS_TEAR_EXT            0x20F3
+#endif
+
+
+/*************************************************************/
+
+#ifndef GLX_ARB_get_proc_address
+typedef void (*__GLXextFuncPtr)(void);
+#endif
+
+#ifndef GLX_SGIX_video_source
+typedef XID GLXVideoSourceSGIX;
+#endif
+
+#ifndef GLX_SGIX_fbconfig
+typedef XID GLXFBConfigIDSGIX;
+typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
+#endif
+
+#ifndef GLX_SGIX_pbuffer
+typedef XID GLXPbufferSGIX;
+typedef struct {
+    int type;
+    unsigned long serial;        /* # of last request processed by server */
+    Bool send_event;             /* true if this came for SendEvent request */
+    Display *display;            /* display the event was read from */
+    GLXDrawable drawable;        /* i.d. of Drawable */
+    int event_type;              /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */
+    int draw_type;               /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */
+    unsigned int mask;   /* mask indicating which buffers are affected*/
+    int x, y;
+    int width, height;
+    int count;           /* if nonzero, at least this many more */
+} GLXBufferClobberEventSGIX;
+#endif
+
+#ifndef GLX_NV_video_output
+typedef unsigned int GLXVideoDeviceNV;
+#endif
+
+#ifndef GLX_NV_video_capture
+typedef XID GLXVideoCaptureDeviceNV;
+#endif
+
+#ifndef GLEXT_64_TYPES_DEFINED
+/* This code block is duplicated in glext.h, so must be protected */
+#define GLEXT_64_TYPES_DEFINED
+/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
+/* (as used in the GLX_OML_sync_control extension). */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+#elif defined(__sun__) || defined(__digital__)
+#include <inttypes.h>
+#if defined(__STDC__)
+#if defined(__arch64__) || defined(_LP64)
+typedef long int int64_t;
+typedef unsigned long int uint64_t;
+#else
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#endif /* __arch64__ */
+#endif /* __STDC__ */
+#elif defined( __VMS ) || defined(__sgi)
+#include <inttypes.h>
+#elif defined(__SCO__) || defined(__USLC__)
+#include <stdint.h>
+#elif defined(__UNIXOS2__) || defined(__SOL64__)
+typedef long int int32_t;
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#elif defined(_WIN32) && defined(__GNUC__)
+#include <stdint.h>
+#elif defined(_WIN32)
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+#include <inttypes.h>     /* Fallback option */
+#endif
+#endif
+
+#ifndef GLX_VERSION_1_3
+#define GLX_VERSION_1_3 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXFBConfig * glXGetFBConfigs (Display *dpy, int screen, int *nelements);
+extern GLXFBConfig * glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements);
+extern int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value);
+extern XVisualInfo * glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config);
+extern GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
+extern void glXDestroyWindow (Display *dpy, GLXWindow win);
+extern GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
+extern void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap);
+extern GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list);
+extern void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf);
+extern void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
+extern GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
+extern Bool glXMakeContextCurrent (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+extern GLXDrawable glXGetCurrentReadDrawable (void);
+extern Display * glXGetCurrentDisplay (void);
+extern int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value);
+extern void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask);
+extern void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
+typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
+typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
+typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
+typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
+typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
+typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
+typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
+typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
+typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
+typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
+typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
+typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
+typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void);
+typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
+typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
+typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
+#endif
+
+#ifndef GLX_VERSION_1_4
+#define GLX_VERSION_1_4 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *procName);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
+#endif
+
+#ifndef GLX_ARB_get_proc_address
+#define GLX_ARB_get_proc_address 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);
+#endif
+
+#ifndef GLX_ARB_multisample
+#define GLX_ARB_multisample 1
+#endif
+
+#ifndef GLX_ARB_fbconfig_float
+#define GLX_ARB_fbconfig_float 1
+#endif
+
+#ifndef GLX_ARB_framebuffer_sRGB
+#define GLX_ARB_framebuffer_sRGB 1
+#endif
+
+#ifndef GLX_ARB_create_context
+#define GLX_ARB_create_context 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
+#endif
+
+#ifndef GLX_ARB_create_context_profile
+#define GLX_ARB_create_context_profile 1
+#endif
+
+#ifndef GLX_ARB_create_context_robustness
+#define GLX_ARB_create_context_robustness 1
+#endif
+
+#ifndef GLX_SGIS_multisample
+#define GLX_SGIS_multisample 1
+#endif
+
+#ifndef GLX_EXT_visual_info
+#define GLX_EXT_visual_info 1
+#endif
+
+#ifndef GLX_SGI_swap_control
+#define GLX_SGI_swap_control 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXSwapIntervalSGI (int interval);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
+#endif
+
+#ifndef GLX_SGI_video_sync
+#define GLX_SGI_video_sync 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXGetVideoSyncSGI (unsigned int *count);
+extern int glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count);
+typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count);
+#endif
+
+#ifndef GLX_SGI_make_current_read
+#define GLX_SGI_make_current_read 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXMakeCurrentReadSGI (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+extern GLXDrawable glXGetCurrentReadDrawableSGI (void);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);
+#endif
+
+#ifndef GLX_SGIX_video_source
+#define GLX_SGIX_video_source 1
+#ifdef _VL_H
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
+extern void glXDestroyGLXVideoSourceSGIX (Display *dpy, GLXVideoSourceSGIX glxvideosource);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
+typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource);
+#endif /* _VL_H */
+#endif
+
+#ifndef GLX_EXT_visual_rating
+#define GLX_EXT_visual_rating 1
+#endif
+
+#ifndef GLX_EXT_import_context
+#define GLX_EXT_import_context 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Display * glXGetCurrentDisplayEXT (void);
+extern int glXQueryContextInfoEXT (Display *dpy, GLXContext context, int attribute, int *value);
+extern GLXContextID glXGetContextIDEXT (const GLXContext context);
+extern GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID);
+extern void glXFreeContextEXT (Display *dpy, GLXContext context);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void);
+typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value);
+typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);
+typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID);
+typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context);
+#endif
+
+#ifndef GLX_SGIX_fbconfig
+#define GLX_SGIX_fbconfig 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXGetFBConfigAttribSGIX (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
+extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *dpy, int screen, int *attrib_list, int *nelements);
+extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
+extern GLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
+extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config);
+extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
+typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements);
+typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
+typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
+typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config);
+typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis);
+#endif
+
+#ifndef GLX_SGIX_pbuffer
+#define GLX_SGIX_pbuffer 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
+extern void glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf);
+extern int glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
+extern void glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask);
+extern void glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
+typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf);
+typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
+typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask);
+typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask);
+#endif
+
+#ifndef GLX_SGI_cushion
+#define GLX_SGI_cushion 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXCushionSGI (Display *dpy, Window window, float cushion);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion);
+#endif
+
+#ifndef GLX_SGIX_video_resize
+#define GLX_SGIX_video_resize 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXBindChannelToWindowSGIX (Display *display, int screen, int channel, Window window);
+extern int glXChannelRectSGIX (Display *display, int screen, int channel, int x, int y, int w, int h);
+extern int glXQueryChannelRectSGIX (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
+extern int glXQueryChannelDeltasSGIX (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
+extern int glXChannelRectSyncSGIX (Display *display, int screen, int channel, GLenum synctype);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window);
+typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h);
+typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
+typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
+typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype);
+#endif
+
+#ifndef GLX_SGIX_dmbuffer
+#define GLX_SGIX_dmbuffer 1
+#ifdef _DM_BUFFER_H_
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXAssociateDMPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
+#endif /* _DM_BUFFER_H_ */
+#endif
+
+#ifndef GLX_SGIX_swap_group
+#define GLX_SGIX_swap_group 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXJoinSwapGroupSGIX (Display *dpy, GLXDrawable drawable, GLXDrawable member);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);
+#endif
+
+#ifndef GLX_SGIX_swap_barrier
+#define GLX_SGIX_swap_barrier 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXBindSwapBarrierSGIX (Display *dpy, GLXDrawable drawable, int barrier);
+extern Bool glXQueryMaxSwapBarriersSGIX (Display *dpy, int screen, int *max);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);
+typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);
+#endif
+
+#ifndef GLX_SUN_get_transparent_index
+#define GLX_SUN_get_transparent_index 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
+#endif
+
+#ifndef GLX_MESA_copy_sub_buffer
+#define GLX_MESA_copy_sub_buffer 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXCopySubBufferMESA (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
+#endif
+
+#ifndef GLX_MESA_pixmap_colormap
+#define GLX_MESA_pixmap_colormap 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
+#endif
+
+#ifndef GLX_MESA_release_buffers
+#define GLX_MESA_release_buffers 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable);
+#endif
+
+#ifndef GLX_MESA_set_3dfx_mode
+#define GLX_MESA_set_3dfx_mode 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXSet3DfxModeMESA (int mode);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode);
+#endif
+
+#ifndef GLX_SGIX_visual_select_group
+#define GLX_SGIX_visual_select_group 1
+#endif
+
+#ifndef GLX_OML_swap_method
+#define GLX_OML_swap_method 1
+#endif
+
+#ifndef GLX_OML_sync_control
+#define GLX_OML_sync_control 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXGetSyncValuesOML (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
+extern Bool glXGetMscRateOML (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
+extern int64_t glXSwapBuffersMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
+extern Bool glXWaitForMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
+extern Bool glXWaitForSbcOML (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
+typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
+typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
+typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
+typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
+#endif
+
+#ifndef GLX_NV_float_buffer
+#define GLX_NV_float_buffer 1
+#endif
+
+#ifndef GLX_SGIX_hyperpipe
+#define GLX_SGIX_hyperpipe 1
+
+typedef struct {
+    char    pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+    int     networkId;
+} GLXHyperpipeNetworkSGIX;
+
+typedef struct {
+    char    pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+    int     channel;
+    unsigned int
+      participationType;
+    int     timeSlice;
+} GLXHyperpipeConfigSGIX;
+
+typedef struct {
+    char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+    int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
+    int destXOrigin, destYOrigin, destWidth, destHeight;
+} GLXPipeRect;
+
+typedef struct {
+    char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+    int XOrigin, YOrigin, maxHeight, maxWidth;
+} GLXPipeRectLimits;
+
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *dpy, int *npipes);
+extern int glXHyperpipeConfigSGIX (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
+extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *dpy, int hpId, int *npipes);
+extern int glXDestroyHyperpipeConfigSGIX (Display *dpy, int hpId);
+extern int glXBindHyperpipeSGIX (Display *dpy, int hpId);
+extern int glXQueryHyperpipeBestAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
+extern int glXHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
+extern int glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);
+typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
+typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);
+typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);
+typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);
+typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
+typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
+typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
+#endif
+
+#ifndef GLX_MESA_agp_offset
+#define GLX_MESA_agp_offset 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern unsigned int glXGetAGPOffsetMESA (const void *pointer);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer);
+#endif
+
+#ifndef GLX_EXT_fbconfig_packed_float
+#define GLX_EXT_fbconfig_packed_float 1
+#endif
+
+#ifndef GLX_EXT_framebuffer_sRGB
+#define GLX_EXT_framebuffer_sRGB 1
+#endif
+
+#ifndef GLX_EXT_texture_from_pixmap
+#define GLX_EXT_texture_from_pixmap 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXBindTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
+extern void glXReleaseTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
+typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer);
+#endif
+
+#ifndef GLX_NV_present_video
+#define GLX_NV_present_video 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern unsigned int * glXEnumerateVideoDevicesNV (Display *dpy, int screen, int *nelements);
+extern int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef unsigned int * ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);
+typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
+#endif
+
+#ifndef GLX_NV_video_output
+#define GLX_NV_video_output 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXGetVideoDeviceNV (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
+extern int glXReleaseVideoDeviceNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
+extern int glXBindVideoImageNV (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
+extern int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf);
+extern int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
+extern int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
+typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
+typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
+typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf);
+typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
+typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
+#endif
+
+#ifndef GLX_NV_swap_group
+#define GLX_NV_swap_group 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXJoinSwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint group);
+extern Bool glXBindSwapBarrierNV (Display *dpy, GLuint group, GLuint barrier);
+extern Bool glXQuerySwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
+extern Bool glXQueryMaxSwapGroupsNV (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
+extern Bool glXQueryFrameCountNV (Display *dpy, int screen, GLuint *count);
+extern Bool glXResetFrameCountNV (Display *dpy, int screen);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group);
+typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier);
+typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
+typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
+typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count);
+typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen);
+#endif
+
+#ifndef GLX_NV_video_capture
+#define GLX_NV_video_capture 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXBindVideoCaptureDeviceNV (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
+extern GLXVideoCaptureDeviceNV * glXEnumerateVideoCaptureDevicesNV (Display *dpy, int screen, int *nelements);
+extern void glXLockVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);
+extern int glXQueryVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
+extern void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
+typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements);
+typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
+typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
+typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
+#endif
+
+#ifndef GLX_EXT_swap_control
+#define GLX_EXT_swap_control 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
+#endif
+
+#ifndef GLX_NV_copy_image
+#define GLX_NV_copy_image 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+#ifndef GLX_INTEL_swap_event
+#define GLX_INTEL_swap_event 1
+#endif
+
+#ifndef GLX_NV_multisample_coverage
+#define GLX_NV_multisample_coverage 1
+#endif
+
+#ifndef GLX_EXT_swap_control_tear
+#define GLX_EXT_swap_control_tear 1
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/thirdparty/khronos/GL/wglext.h b/thirdparty/khronos/GL/wglext.h
new file mode 100644 (file)
index 0000000..b5dc7bf
--- /dev/null
@@ -0,0 +1,943 @@
+#ifndef __wglext_h_
+#define __wglext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2012 The Khronos Group Inc.
+** 
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+** 
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+** 
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Function declaration macros - to move into glplatform.h */
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+/* Header file version number */
+/* wglext.h last updated 2012/01/04 */
+/* Current version at http://www.opengl.org/registry/ */
+#define WGL_WGLEXT_VERSION 24
+
+#ifndef WGL_ARB_buffer_region
+#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
+#define WGL_BACK_COLOR_BUFFER_BIT_ARB  0x00000002
+#define WGL_DEPTH_BUFFER_BIT_ARB       0x00000004
+#define WGL_STENCIL_BUFFER_BIT_ARB     0x00000008
+#endif
+
+#ifndef WGL_ARB_multisample
+#define WGL_SAMPLE_BUFFERS_ARB         0x2041
+#define WGL_SAMPLES_ARB                0x2042
+#endif
+
+#ifndef WGL_ARB_extensions_string
+#endif
+
+#ifndef WGL_ARB_pixel_format
+#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_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_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
+#endif
+
+#ifndef WGL_ARB_make_current_read
+#define ERROR_INVALID_PIXEL_TYPE_ARB   0x2043
+#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
+#endif
+
+#ifndef WGL_ARB_pbuffer
+#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
+#endif
+
+#ifndef WGL_ARB_render_texture
+#define WGL_BIND_TO_TEXTURE_RGB_ARB    0x2070
+#define WGL_BIND_TO_TEXTURE_RGBA_ARB   0x2071
+#define WGL_TEXTURE_FORMAT_ARB         0x2072
+#define WGL_TEXTURE_TARGET_ARB         0x2073
+#define WGL_MIPMAP_TEXTURE_ARB         0x2074
+#define WGL_TEXTURE_RGB_ARB            0x2075
+#define WGL_TEXTURE_RGBA_ARB           0x2076
+#define WGL_NO_TEXTURE_ARB             0x2077
+#define WGL_TEXTURE_CUBE_MAP_ARB       0x2078
+#define WGL_TEXTURE_1D_ARB             0x2079
+#define WGL_TEXTURE_2D_ARB             0x207A
+#define WGL_MIPMAP_LEVEL_ARB           0x207B
+#define WGL_CUBE_MAP_FACE_ARB          0x207C
+#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
+#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
+#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
+#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
+#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
+#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
+#define WGL_FRONT_LEFT_ARB             0x2083
+#define WGL_FRONT_RIGHT_ARB            0x2084
+#define WGL_BACK_LEFT_ARB              0x2085
+#define WGL_BACK_RIGHT_ARB             0x2086
+#define WGL_AUX0_ARB                   0x2087
+#define WGL_AUX1_ARB                   0x2088
+#define WGL_AUX2_ARB                   0x2089
+#define WGL_AUX3_ARB                   0x208A
+#define WGL_AUX4_ARB                   0x208B
+#define WGL_AUX5_ARB                   0x208C
+#define WGL_AUX6_ARB                   0x208D
+#define WGL_AUX7_ARB                   0x208E
+#define WGL_AUX8_ARB                   0x208F
+#define WGL_AUX9_ARB                   0x2090
+#endif
+
+#ifndef WGL_ARB_pixel_format_float
+#define WGL_TYPE_RGBA_FLOAT_ARB        0x21A0
+#endif
+
+#ifndef WGL_ARB_framebuffer_sRGB
+#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
+#endif
+
+#ifndef WGL_ARB_create_context
+#define WGL_CONTEXT_DEBUG_BIT_ARB      0x00000001
+#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
+#define WGL_CONTEXT_MAJOR_VERSION_ARB  0x2091
+#define WGL_CONTEXT_MINOR_VERSION_ARB  0x2092
+#define WGL_CONTEXT_LAYER_PLANE_ARB    0x2093
+#define WGL_CONTEXT_FLAGS_ARB          0x2094
+#define ERROR_INVALID_VERSION_ARB      0x2095
+#endif
+
+#ifndef WGL_ARB_create_context_profile
+#define WGL_CONTEXT_PROFILE_MASK_ARB   0x9126
+#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
+#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
+#define ERROR_INVALID_PROFILE_ARB      0x2096
+#endif
+
+#ifndef WGL_ARB_create_context_robustness
+#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
+#define WGL_LOSE_CONTEXT_ON_RESET_ARB  0x8252
+#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
+#define WGL_NO_RESET_NOTIFICATION_ARB  0x8261
+#endif
+
+#ifndef WGL_EXT_make_current_read
+#define ERROR_INVALID_PIXEL_TYPE_EXT   0x2043
+#endif
+
+#ifndef WGL_EXT_pixel_format
+#define WGL_NUMBER_PIXEL_FORMATS_EXT   0x2000
+#define WGL_DRAW_TO_WINDOW_EXT         0x2001
+#define WGL_DRAW_TO_BITMAP_EXT         0x2002
+#define WGL_ACCELERATION_EXT           0x2003
+#define WGL_NEED_PALETTE_EXT           0x2004
+#define WGL_NEED_SYSTEM_PALETTE_EXT    0x2005
+#define WGL_SWAP_LAYER_BUFFERS_EXT     0x2006
+#define WGL_SWAP_METHOD_EXT            0x2007
+#define WGL_NUMBER_OVERLAYS_EXT        0x2008
+#define WGL_NUMBER_UNDERLAYS_EXT       0x2009
+#define WGL_TRANSPARENT_EXT            0x200A
+#define WGL_TRANSPARENT_VALUE_EXT      0x200B
+#define WGL_SHARE_DEPTH_EXT            0x200C
+#define WGL_SHARE_STENCIL_EXT          0x200D
+#define WGL_SHARE_ACCUM_EXT            0x200E
+#define WGL_SUPPORT_GDI_EXT            0x200F
+#define WGL_SUPPORT_OPENGL_EXT         0x2010
+#define WGL_DOUBLE_BUFFER_EXT          0x2011
+#define WGL_STEREO_EXT                 0x2012
+#define WGL_PIXEL_TYPE_EXT             0x2013
+#define WGL_COLOR_BITS_EXT             0x2014
+#define WGL_RED_BITS_EXT               0x2015
+#define WGL_RED_SHIFT_EXT              0x2016
+#define WGL_GREEN_BITS_EXT             0x2017
+#define WGL_GREEN_SHIFT_EXT            0x2018
+#define WGL_BLUE_BITS_EXT              0x2019
+#define WGL_BLUE_SHIFT_EXT             0x201A
+#define WGL_ALPHA_BITS_EXT             0x201B
+#define WGL_ALPHA_SHIFT_EXT            0x201C
+#define WGL_ACCUM_BITS_EXT             0x201D
+#define WGL_ACCUM_RED_BITS_EXT         0x201E
+#define WGL_ACCUM_GREEN_BITS_EXT       0x201F
+#define WGL_ACCUM_BLUE_BITS_EXT        0x2020
+#define WGL_ACCUM_ALPHA_BITS_EXT       0x2021
+#define WGL_DEPTH_BITS_EXT             0x2022
+#define WGL_STENCIL_BITS_EXT           0x2023
+#define WGL_AUX_BUFFERS_EXT            0x2024
+#define WGL_NO_ACCELERATION_EXT        0x2025
+#define WGL_GENERIC_ACCELERATION_EXT   0x2026
+#define WGL_FULL_ACCELERATION_EXT      0x2027
+#define WGL_SWAP_EXCHANGE_EXT          0x2028
+#define WGL_SWAP_COPY_EXT              0x2029
+#define WGL_SWAP_UNDEFINED_EXT         0x202A
+#define WGL_TYPE_RGBA_EXT              0x202B
+#define WGL_TYPE_COLORINDEX_EXT        0x202C
+#endif
+
+#ifndef WGL_EXT_pbuffer
+#define WGL_DRAW_TO_PBUFFER_EXT        0x202D
+#define WGL_MAX_PBUFFER_PIXELS_EXT     0x202E
+#define WGL_MAX_PBUFFER_WIDTH_EXT      0x202F
+#define WGL_MAX_PBUFFER_HEIGHT_EXT     0x2030
+#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT  0x2031
+#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
+#define WGL_PBUFFER_LARGEST_EXT        0x2033
+#define WGL_PBUFFER_WIDTH_EXT          0x2034
+#define WGL_PBUFFER_HEIGHT_EXT         0x2035
+#endif
+
+#ifndef WGL_EXT_depth_float
+#define WGL_DEPTH_FLOAT_EXT            0x2040
+#endif
+
+#ifndef WGL_3DFX_multisample
+#define WGL_SAMPLE_BUFFERS_3DFX        0x2060
+#define WGL_SAMPLES_3DFX               0x2061
+#endif
+
+#ifndef WGL_EXT_multisample
+#define WGL_SAMPLE_BUFFERS_EXT         0x2041
+#define WGL_SAMPLES_EXT                0x2042
+#endif
+
+#ifndef WGL_I3D_digital_video_control
+#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
+#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
+#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
+#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
+#endif
+
+#ifndef WGL_I3D_gamma
+#define WGL_GAMMA_TABLE_SIZE_I3D       0x204E
+#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D  0x204F
+#endif
+
+#ifndef WGL_I3D_genlock
+#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
+#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
+#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
+#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
+#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
+#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
+#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
+#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
+#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
+#endif
+
+#ifndef WGL_I3D_image_buffer
+#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
+#define WGL_IMAGE_BUFFER_LOCK_I3D      0x00000002
+#endif
+
+#ifndef WGL_I3D_swap_frame_lock
+#endif
+
+#ifndef WGL_NV_render_depth_texture
+#define WGL_BIND_TO_TEXTURE_DEPTH_NV   0x20A3
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
+#define WGL_DEPTH_TEXTURE_FORMAT_NV    0x20A5
+#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
+#define WGL_DEPTH_COMPONENT_NV         0x20A7
+#endif
+
+#ifndef WGL_NV_render_texture_rectangle
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
+#define WGL_TEXTURE_RECTANGLE_NV       0x20A2
+#endif
+
+#ifndef WGL_ATI_pixel_format_float
+#define WGL_TYPE_RGBA_FLOAT_ATI        0x21A0
+#endif
+
+#ifndef WGL_NV_float_buffer
+#define WGL_FLOAT_COMPONENTS_NV        0x20B0
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
+#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
+#define WGL_TEXTURE_FLOAT_R_NV         0x20B5
+#define WGL_TEXTURE_FLOAT_RG_NV        0x20B6
+#define WGL_TEXTURE_FLOAT_RGB_NV       0x20B7
+#define WGL_TEXTURE_FLOAT_RGBA_NV      0x20B8
+#endif
+
+#ifndef WGL_3DL_stereo_control
+#define WGL_STEREO_EMITTER_ENABLE_3DL  0x2055
+#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
+#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
+#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
+#endif
+
+#ifndef WGL_EXT_pixel_format_packed_float
+#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
+#endif
+
+#ifndef WGL_EXT_framebuffer_sRGB
+#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
+#endif
+
+#ifndef WGL_NV_present_video
+#define WGL_NUM_VIDEO_SLOTS_NV         0x20F0
+#endif
+
+#ifndef WGL_NV_video_out
+#define WGL_BIND_TO_VIDEO_RGB_NV       0x20C0
+#define WGL_BIND_TO_VIDEO_RGBA_NV      0x20C1
+#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
+#define WGL_VIDEO_OUT_COLOR_NV         0x20C3
+#define WGL_VIDEO_OUT_ALPHA_NV         0x20C4
+#define WGL_VIDEO_OUT_DEPTH_NV         0x20C5
+#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
+#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
+#define WGL_VIDEO_OUT_FRAME            0x20C8
+#define WGL_VIDEO_OUT_FIELD_1          0x20C9
+#define WGL_VIDEO_OUT_FIELD_2          0x20CA
+#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
+#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
+#endif
+
+#ifndef WGL_NV_swap_group
+#endif
+
+#ifndef WGL_NV_gpu_affinity
+#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
+#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
+#endif
+
+#ifndef WGL_AMD_gpu_association
+#define WGL_GPU_VENDOR_AMD             0x1F00
+#define WGL_GPU_RENDERER_STRING_AMD    0x1F01
+#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
+#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
+#define WGL_GPU_RAM_AMD                0x21A3
+#define WGL_GPU_CLOCK_AMD              0x21A4
+#define WGL_GPU_NUM_PIPES_AMD          0x21A5
+#define WGL_GPU_NUM_SIMD_AMD           0x21A6
+#define WGL_GPU_NUM_RB_AMD             0x21A7
+#define WGL_GPU_NUM_SPI_AMD            0x21A8
+#endif
+
+#ifndef WGL_NV_video_capture
+#define WGL_UNIQUE_ID_NV               0x20CE
+#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
+#endif
+
+#ifndef WGL_NV_copy_image
+#endif
+
+#ifndef WGL_NV_multisample_coverage
+#define WGL_COVERAGE_SAMPLES_NV        0x2042
+#define WGL_COLOR_SAMPLES_NV           0x20B9
+#endif
+
+#ifndef WGL_EXT_create_context_es2_profile
+#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
+#endif
+
+#ifndef WGL_NV_DX_interop
+#define WGL_ACCESS_READ_ONLY_NV        0x00000000
+#define WGL_ACCESS_READ_WRITE_NV       0x00000001
+#define WGL_ACCESS_WRITE_DISCARD_NV    0x00000002
+#endif
+
+#ifndef WGL_NV_DX_interop2
+#endif
+
+#ifndef WGL_EXT_swap_control_tear
+#endif
+
+
+/*************************************************************/
+
+#ifndef WGL_ARB_pbuffer
+DECLARE_HANDLE(HPBUFFERARB);
+#endif
+#ifndef WGL_EXT_pbuffer
+DECLARE_HANDLE(HPBUFFEREXT);
+#endif
+#ifndef WGL_NV_present_video
+DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
+#endif
+#ifndef WGL_NV_video_output
+DECLARE_HANDLE(HPVIDEODEV);
+#endif
+#ifndef WGL_NV_gpu_affinity
+DECLARE_HANDLE(HPGPUNV);
+DECLARE_HANDLE(HGPUNV);
+
+typedef struct _GPU_DEVICE {
+    DWORD  cb;
+    CHAR   DeviceName[32];
+    CHAR   DeviceString[128];
+    DWORD  Flags;
+    RECT   rcVirtualScreen;
+} GPU_DEVICE, *PGPU_DEVICE;
+#endif
+#ifndef WGL_NV_video_capture
+DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
+#endif
+
+#ifndef WGL_ARB_buffer_region
+#define WGL_ARB_buffer_region 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
+extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
+extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
+extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
+typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
+typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
+typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
+#endif
+
+#ifndef WGL_ARB_multisample
+#define WGL_ARB_multisample 1
+#endif
+
+#ifndef WGL_ARB_extensions_string
+#define WGL_ARB_extensions_string 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern const char * WINAPI wglGetExtensionsStringARB (HDC hdc);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
+#endif
+
+#ifndef WGL_ARB_pixel_format
+#define WGL_ARB_pixel_format 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
+extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
+extern BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
+typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+#endif
+
+#ifndef WGL_ARB_make_current_read
+#define WGL_ARB_make_current_read 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+extern HDC WINAPI wglGetCurrentReadDCARB (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
+#endif
+
+#ifndef WGL_ARB_pbuffer
+#define WGL_ARB_pbuffer 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
+extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
+extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
+extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
+extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
+typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
+typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
+typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
+typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
+#endif
+
+#ifndef WGL_ARB_render_texture
+#define WGL_ARB_render_texture 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
+extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
+extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
+typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
+typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
+#endif
+
+#ifndef WGL_ARB_pixel_format_float
+#define WGL_ARB_pixel_format_float 1
+#endif
+
+#ifndef WGL_ARB_framebuffer_sRGB
+#define WGL_ARB_framebuffer_sRGB 1
+#endif
+
+#ifndef WGL_ARB_create_context
+#define WGL_ARB_create_context 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
+#endif
+
+#ifndef WGL_ARB_create_context_profile
+#define WGL_ARB_create_context_profile 1
+#endif
+
+#ifndef WGL_ARB_create_context_robustness
+#define WGL_ARB_create_context_robustness 1
+#endif
+
+#ifndef WGL_EXT_display_color_table
+#define WGL_EXT_display_color_table 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
+extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
+extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
+extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
+typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
+typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
+typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
+#endif
+
+#ifndef WGL_EXT_extensions_string
+#define WGL_EXT_extensions_string 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern const char * WINAPI wglGetExtensionsStringEXT (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
+#endif
+
+#ifndef WGL_EXT_make_current_read
+#define WGL_EXT_make_current_read 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+extern HDC WINAPI wglGetCurrentReadDCEXT (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
+#endif
+
+#ifndef WGL_EXT_pbuffer
+#define WGL_EXT_pbuffer 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
+extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
+extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
+extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
+extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
+typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
+typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
+typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
+typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
+#endif
+
+#ifndef WGL_EXT_pixel_format
+#define WGL_EXT_pixel_format 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
+extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
+extern BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
+typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
+typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+#endif
+
+#ifndef WGL_EXT_swap_control
+#define WGL_EXT_swap_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglSwapIntervalEXT (int interval);
+extern int WINAPI wglGetSwapIntervalEXT (void);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
+typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
+#endif
+
+#ifndef WGL_EXT_depth_float
+#define WGL_EXT_depth_float 1
+#endif
+
+#ifndef WGL_NV_vertex_array_range
+#define WGL_NV_vertex_array_range 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern void* WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+extern void WINAPI wglFreeMemoryNV (void *pointer);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
+#endif
+
+#ifndef WGL_3DFX_multisample
+#define WGL_3DFX_multisample 1
+#endif
+
+#ifndef WGL_EXT_multisample
+#define WGL_EXT_multisample 1
+#endif
+
+#ifndef WGL_OML_sync_control
+#define WGL_OML_sync_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
+extern BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
+extern INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
+extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
+extern BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
+extern BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
+typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
+typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
+typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
+typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
+typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
+#endif
+
+#ifndef WGL_I3D_digital_video_control
+#define WGL_I3D_digital_video_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
+extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
+typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
+#endif
+
+#ifndef WGL_I3D_gamma
+#define WGL_I3D_gamma 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
+extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
+extern BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
+extern BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
+typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
+typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
+typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
+#endif
+
+#ifndef WGL_I3D_genlock
+#define WGL_I3D_genlock 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
+extern BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
+extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
+extern BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
+extern BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
+extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
+extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
+extern BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
+extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
+extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
+extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
+extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
+typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
+typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
+typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
+typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
+typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
+#endif
+
+#ifndef WGL_I3D_image_buffer
+#define WGL_I3D_image_buffer 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
+extern BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
+extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
+extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
+typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
+typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
+typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
+#endif
+
+#ifndef WGL_I3D_swap_frame_lock
+#define WGL_I3D_swap_frame_lock 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglEnableFrameLockI3D (void);
+extern BOOL WINAPI wglDisableFrameLockI3D (void);
+extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
+extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
+typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
+#endif
+
+#ifndef WGL_I3D_swap_frame_usage
+#define WGL_I3D_swap_frame_usage 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
+extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
+extern BOOL WINAPI wglEndFrameTrackingI3D (void);
+extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
+typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
+typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
+#endif
+
+#ifndef WGL_ATI_pixel_format_float
+#define WGL_ATI_pixel_format_float 1
+#endif
+
+#ifndef WGL_NV_float_buffer
+#define WGL_NV_float_buffer 1
+#endif
+
+#ifndef WGL_3DL_stereo_control
+#define WGL_3DL_stereo_control 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
+#endif
+
+#ifndef WGL_EXT_pixel_format_packed_float
+#define WGL_EXT_pixel_format_packed_float 1
+#endif
+
+#ifndef WGL_EXT_framebuffer_sRGB
+#define WGL_EXT_framebuffer_sRGB 1
+#endif
+
+#ifndef WGL_NV_present_video
+#define WGL_NV_present_video 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
+extern BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
+extern BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);
+typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
+typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
+#endif
+
+#ifndef WGL_NV_video_output
+#define WGL_NV_video_output 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
+extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
+extern BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
+extern BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
+extern BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
+extern BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
+typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
+typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
+typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
+typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
+typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
+#endif
+
+#ifndef WGL_NV_swap_group
+#define WGL_NV_swap_group 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
+extern BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
+extern BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
+extern BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
+extern BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
+extern BOOL WINAPI wglResetFrameCountNV (HDC hDC);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
+typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
+typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
+typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
+typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
+typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
+#endif
+
+#ifndef WGL_NV_gpu_affinity
+#define WGL_NV_gpu_affinity 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
+extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
+extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
+extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
+extern BOOL WINAPI wglDeleteDCNV (HDC hdc);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
+typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
+typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
+typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
+typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
+#endif
+
+#ifndef WGL_AMD_gpu_association
+#define WGL_AMD_gpu_association 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
+extern INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);
+extern UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
+extern HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
+extern HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
+extern BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
+extern BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
+extern HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
+extern VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
+typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);
+typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
+typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
+typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
+typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
+typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
+typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
+typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
+#ifndef WGL_NV_video_capture
+#define WGL_NV_video_capture 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
+extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
+extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
+extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
+extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
+typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
+typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
+typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
+typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
+#endif
+
+#ifndef WGL_NV_copy_image
+#define WGL_NV_copy_image 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+#ifndef WGL_NV_multisample_coverage
+#define WGL_NV_multisample_coverage 1
+#endif
+
+#ifndef WGL_NV_DX_interop
+#define WGL_NV_DX_interop 1
+#ifdef WGL_WGLEXT_PROTOTYPES
+extern BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
+extern HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
+extern BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
+extern HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
+extern BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
+extern BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
+extern BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
+extern BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
+#endif /* WGL_WGLEXT_PROTOTYPES */
+typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
+typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
+typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
+typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
+typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
+typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
+typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
+typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
+#endif
+
+#ifndef WGL_NV_DX_interop2
+#define WGL_NV_DX_interop2 1
+#endif
+
+#ifndef WGL_EXT_swap_control_tear
+#define WGL_EXT_swap_control_tear 1
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/thirdparty/khronos/GLES/gl.h b/thirdparty/khronos/GLES/gl.h
new file mode 100644 (file)
index 0000000..5b8d85a
--- /dev/null
@@ -0,0 +1,770 @@
+#ifndef __gl_h_
+#define __gl_h_
+
+/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
+
+#include <GLES/glplatform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+typedef void             GLvoid;
+typedef char             GLchar;
+typedef unsigned int     GLenum;
+typedef unsigned char    GLboolean;
+typedef unsigned int     GLbitfield;
+typedef khronos_int8_t   GLbyte;
+typedef short            GLshort;
+typedef int              GLint;
+typedef int              GLsizei;
+typedef khronos_uint8_t  GLubyte;
+typedef unsigned short   GLushort;
+typedef unsigned int     GLuint;
+typedef khronos_float_t  GLfloat;
+typedef khronos_float_t  GLclampf;
+typedef khronos_int32_t  GLfixed;
+typedef khronos_int32_t  GLclampx;
+
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t  GLsizeiptr;
+
+
+/*************************************************************/
+
+/* OpenGL ES core versions */
+#define GL_VERSION_ES_CM_1_0          1
+#define GL_VERSION_ES_CL_1_0          1
+#define GL_VERSION_ES_CM_1_1          1
+#define GL_VERSION_ES_CL_1_1          1
+
+/* ClearBufferMask */
+#define GL_DEPTH_BUFFER_BIT               0x00000100
+#define GL_STENCIL_BUFFER_BIT             0x00000400
+#define GL_COLOR_BUFFER_BIT               0x00004000
+
+/* Boolean */
+#define GL_FALSE                          0
+#define GL_TRUE                           1
+
+/* BeginMode */
+#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
+
+/* AlphaFunction */
+#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
+
+/* BlendingFactorDest */
+#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
+
+/* BlendingFactorSrc */
+/*      GL_ZERO */
+/*      GL_ONE */
+#define GL_DST_COLOR                      0x0306
+#define GL_ONE_MINUS_DST_COLOR            0x0307
+#define GL_SRC_ALPHA_SATURATE             0x0308
+/*      GL_SRC_ALPHA */
+/*      GL_ONE_MINUS_SRC_ALPHA */
+/*      GL_DST_ALPHA */
+/*      GL_ONE_MINUS_DST_ALPHA */
+
+/* ClipPlaneName */
+#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
+
+/* ColorMaterialFace */
+/*      GL_FRONT_AND_BACK */
+
+/* ColorMaterialParameter */
+/*      GL_AMBIENT_AND_DIFFUSE */
+
+/* ColorPointerType */
+/*      GL_UNSIGNED_BYTE */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+
+/* CullFaceMode */
+#define GL_FRONT                          0x0404
+#define GL_BACK                           0x0405
+#define GL_FRONT_AND_BACK                 0x0408
+
+/* DepthFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* EnableCap */
+#define GL_FOG                            0x0B60
+#define GL_LIGHTING                       0x0B50
+#define GL_TEXTURE_2D                     0x0DE1
+#define GL_CULL_FACE                      0x0B44
+#define GL_ALPHA_TEST                     0x0BC0
+#define GL_BLEND                          0x0BE2
+#define GL_COLOR_LOGIC_OP                 0x0BF2
+#define GL_DITHER                         0x0BD0
+#define GL_STENCIL_TEST                   0x0B90
+#define GL_DEPTH_TEST                     0x0B71
+/*      GL_LIGHT0 */
+/*      GL_LIGHT1 */
+/*      GL_LIGHT2 */
+/*      GL_LIGHT3 */
+/*      GL_LIGHT4 */
+/*      GL_LIGHT5 */
+/*      GL_LIGHT6 */
+/*      GL_LIGHT7 */
+#define GL_POINT_SMOOTH                   0x0B10
+#define GL_LINE_SMOOTH                    0x0B20
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_COLOR_MATERIAL                 0x0B57
+#define GL_NORMALIZE                      0x0BA1
+#define GL_RESCALE_NORMAL                 0x803A
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_VERTEX_ARRAY                   0x8074
+#define GL_NORMAL_ARRAY                   0x8075
+#define GL_COLOR_ARRAY                    0x8076
+#define GL_TEXTURE_COORD_ARRAY            0x8078
+#define GL_MULTISAMPLE                    0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE            0x809F
+#define GL_SAMPLE_COVERAGE                0x80A0
+
+/* ErrorCode */
+#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
+
+/* FogMode */
+/*      GL_LINEAR */
+#define GL_EXP                            0x0800
+#define GL_EXP2                           0x0801
+
+/* FogParameter */
+#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
+
+/* FrontFaceDirection */
+#define GL_CW                             0x0900
+#define GL_CCW                            0x0901
+
+/* GetPName */
+#define GL_CURRENT_COLOR                  0x0B00
+#define GL_CURRENT_NORMAL                 0x0B02
+#define GL_CURRENT_TEXTURE_COORDS         0x0B03
+#define GL_POINT_SIZE                     0x0B11
+#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_SMOOTH_POINT_SIZE_RANGE        0x0B12
+#define GL_LINE_WIDTH                     0x0B21
+#define GL_SMOOTH_LINE_WIDTH_RANGE        0x0B22
+#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
+#define GL_CULL_FACE_MODE                 0x0B45
+#define GL_FRONT_FACE                     0x0B46
+#define GL_SHADE_MODEL                    0x0B54
+#define GL_DEPTH_RANGE                    0x0B70
+#define GL_DEPTH_WRITEMASK                0x0B72
+#define GL_DEPTH_CLEAR_VALUE              0x0B73
+#define GL_DEPTH_FUNC                     0x0B74
+#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_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_ALPHA_TEST_FUNC                0x0BC1
+#define GL_ALPHA_TEST_REF                 0x0BC2
+#define GL_BLEND_DST                      0x0BE0
+#define GL_BLEND_SRC                      0x0BE1
+#define GL_LOGIC_OP_MODE                  0x0BF0
+#define GL_SCISSOR_BOX                    0x0C10
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_COLOR_CLEAR_VALUE              0x0C22
+#define GL_COLOR_WRITEMASK                0x0C23
+#define GL_UNPACK_ALIGNMENT               0x0CF5
+#define GL_PACK_ALIGNMENT                 0x0D05
+#define GL_MAX_LIGHTS                     0x0D31
+#define GL_MAX_CLIP_PLANES                0x0D32
+#define GL_MAX_TEXTURE_SIZE               0x0D33
+#define GL_MAX_MODELVIEW_STACK_DEPTH      0x0D36
+#define GL_MAX_PROJECTION_STACK_DEPTH     0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH        0x0D39
+#define GL_MAX_VIEWPORT_DIMS              0x0D3A
+#define GL_MAX_TEXTURE_UNITS              0x84E2
+#define GL_SUBPIXEL_BITS                  0x0D50
+#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_POLYGON_OFFSET_UNITS           0x2A00
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_POLYGON_OFFSET_FACTOR          0x8038
+#define GL_TEXTURE_BINDING_2D             0x8069
+#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_TEXTURE_COORD_ARRAY_SIZE       0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE       0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE     0x808A
+#define GL_VERTEX_ARRAY_POINTER           0x808E
+#define GL_NORMAL_ARRAY_POINTER           0x808F
+#define GL_COLOR_ARRAY_POINTER            0x8090
+#define GL_TEXTURE_COORD_ARRAY_POINTER    0x8092
+#define GL_SAMPLE_BUFFERS                 0x80A8
+#define GL_SAMPLES                        0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE          0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT         0x80AB
+
+/* GetTextureParameter */
+/*      GL_TEXTURE_MAG_FILTER */
+/*      GL_TEXTURE_MIN_FILTER */
+/*      GL_TEXTURE_WRAP_S */
+/*      GL_TEXTURE_WRAP_T */
+
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
+
+/* HintMode */
+#define GL_DONT_CARE                      0x1100
+#define GL_FASTEST                        0x1101
+#define GL_NICEST                         0x1102
+
+/* HintTarget */
+#define GL_PERSPECTIVE_CORRECTION_HINT    0x0C50
+#define GL_POINT_SMOOTH_HINT              0x0C51
+#define GL_LINE_SMOOTH_HINT               0x0C52
+#define GL_FOG_HINT                       0x0C54
+#define GL_GENERATE_MIPMAP_HINT           0x8192
+
+/* LightModelParameter */
+#define GL_LIGHT_MODEL_AMBIENT            0x0B53
+#define GL_LIGHT_MODEL_TWO_SIDE           0x0B52
+
+/* LightParameter */
+#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
+
+/* DataType */
+#define GL_BYTE                           0x1400
+#define GL_UNSIGNED_BYTE                  0x1401
+#define GL_SHORT                          0x1402
+#define GL_UNSIGNED_SHORT                 0x1403
+#define GL_FLOAT                          0x1406
+#define GL_FIXED                          0x140C
+
+/* LogicOp */
+#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
+
+/* MaterialFace */
+/*      GL_FRONT_AND_BACK */
+
+/* MaterialParameter */
+#define GL_EMISSION                       0x1600
+#define GL_SHININESS                      0x1601
+#define GL_AMBIENT_AND_DIFFUSE            0x1602
+/*      GL_AMBIENT */
+/*      GL_DIFFUSE */
+/*      GL_SPECULAR */
+
+/* MatrixMode */
+#define GL_MODELVIEW                      0x1700
+#define GL_PROJECTION                     0x1701
+#define GL_TEXTURE                        0x1702
+
+/* NormalPointerType */
+/*      GL_BYTE */
+/*      GL_SHORT */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+
+/* PixelFormat */
+#define GL_ALPHA                          0x1906
+#define GL_RGB                            0x1907
+#define GL_RGBA                           0x1908
+#define GL_LUMINANCE                      0x1909
+#define GL_LUMINANCE_ALPHA                0x190A
+
+/* PixelStoreParameter */
+#define GL_UNPACK_ALIGNMENT               0x0CF5
+#define GL_PACK_ALIGNMENT                 0x0D05
+
+/* PixelType */
+/*      GL_UNSIGNED_BYTE */
+#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
+#define GL_UNSIGNED_SHORT_5_6_5           0x8363
+
+/* ShadingModel */
+#define GL_FLAT                           0x1D00
+#define GL_SMOOTH                         0x1D01
+
+/* StencilFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* StencilOp */
+/*      GL_ZERO */
+#define GL_KEEP                           0x1E00
+#define GL_REPLACE                        0x1E01
+#define GL_INCR                           0x1E02
+#define GL_DECR                           0x1E03
+/*      GL_INVERT */
+
+/* StringName */
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+
+/* TexCoordPointerType */
+/*      GL_SHORT */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+/*      GL_BYTE */
+
+/* TextureEnvMode */
+#define GL_MODULATE                       0x2100
+#define GL_DECAL                          0x2101
+/*      GL_BLEND */
+#define GL_ADD                            0x0104
+/*      GL_REPLACE */
+
+/* TextureEnvParameter */
+#define GL_TEXTURE_ENV_MODE               0x2200
+#define GL_TEXTURE_ENV_COLOR              0x2201
+
+/* TextureEnvTarget */
+#define GL_TEXTURE_ENV                    0x2300
+
+/* TextureMagFilter */
+#define GL_NEAREST                        0x2600
+#define GL_LINEAR                         0x2601
+
+/* TextureMinFilter */
+/*      GL_NEAREST */
+/*      GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST         0x2700
+#define GL_LINEAR_MIPMAP_NEAREST          0x2701
+#define GL_NEAREST_MIPMAP_LINEAR          0x2702
+#define GL_LINEAR_MIPMAP_LINEAR           0x2703
+
+/* TextureParameterName */
+#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_GENERATE_MIPMAP                0x8191
+
+/* TextureTarget */
+/*      GL_TEXTURE_2D */
+
+/* TextureUnit */
+#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
+
+/* TextureWrapMode */
+#define GL_REPEAT                         0x2901
+#define GL_CLAMP_TO_EDGE                  0x812F
+
+/* VertexPointerType */
+/*      GL_SHORT */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+/*      GL_BYTE */
+
+/* LightName */
+#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
+
+/* Buffer Objects */
+#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_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
+
+#define GL_STATIC_DRAW                    0x88E4
+#define GL_DYNAMIC_DRAW                   0x88E8
+
+#define GL_BUFFER_SIZE                    0x8764
+#define GL_BUFFER_USAGE                   0x8765
+
+/* Texture combine + dot3 */
+#define GL_SUBTRACT                       0x84E7
+#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_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_ALPHA_SCALE                    0x0D1C
+
+#define GL_SRC0_RGB                       0x8580
+#define GL_SRC1_RGB                       0x8581
+#define GL_SRC2_RGB                       0x8582
+#define GL_SRC0_ALPHA                     0x8588
+#define GL_SRC1_ALPHA                     0x8589
+#define GL_SRC2_ALPHA                     0x858A
+
+#define GL_DOT3_RGB                       0x86AE
+#define GL_DOT3_RGBA                      0x86AF
+
+/*------------------------------------------------------------------------*
+ * required OES extension tokens
+ *------------------------------------------------------------------------*/
+
+/* OES_read_format */
+#ifndef GL_OES_read_format
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES                   0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES                 0x8B9B
+#endif
+
+/* GL_OES_compressed_paletted_texture */
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_PALETTE4_RGB8_OES                                    0x8B90
+#define GL_PALETTE4_RGBA8_OES                                   0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92
+#define GL_PALETTE4_RGBA4_OES                                   0x8B93
+#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94
+#define GL_PALETTE8_RGB8_OES                                    0x8B95
+#define GL_PALETTE8_RGBA8_OES                                   0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97
+#define GL_PALETTE8_RGBA4_OES                                   0x8B98
+#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99
+#endif
+
+/* OES_point_size_array */
+#ifndef GL_OES_point_size_array
+#define GL_POINT_SIZE_ARRAY_OES                                 0x8B9C
+#define GL_POINT_SIZE_ARRAY_TYPE_OES                            0x898A
+#define GL_POINT_SIZE_ARRAY_STRIDE_OES                          0x898B
+#define GL_POINT_SIZE_ARRAY_POINTER_OES                         0x898C
+#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES                  0x8B9F
+#endif
+
+/* GL_OES_point_sprite */
+#ifndef GL_OES_point_sprite
+#define GL_POINT_SPRITE_OES                                     0x8861
+#define GL_COORD_REPLACE_OES                                    0x8862
+#endif
+
+/*************************************************************/
+
+/* Available only in Common profile */
+GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref);
+GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
+GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
+GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
+GL_API void GL_APIENTRY glFogf (GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]);
+GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glLightModelf (GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glLightModelfv (GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glLineWidth (GLfloat width);
+GL_API void GL_APIENTRY glLoadMatrixf (const GLfloat *m);
+GL_API void GL_APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glMultMatrixf (const GLfloat *m);
+GL_API void GL_APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GL_API void GL_APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);
+GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glPointParameterf (GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glPointSize (GLfloat size);
+GL_API void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GL_API void GL_APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+GL_API void GL_APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);
+GL_API void GL_APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);
+
+/* Available in both Common and Common-Lite profiles */
+GL_API void GL_APIENTRY glActiveTexture (GLenum texture);
+GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
+GL_API void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GL_API void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
+GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GL_API void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+GL_API void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+GL_API void GL_APIENTRY glClear (GLbitfield mask);
+GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+GL_API void GL_APIENTRY glClearDepthx (GLclampx depth);
+GL_API void GL_APIENTRY glClearStencil (GLint s);
+GL_API void GL_APIENTRY glClientActiveTexture (GLenum texture);
+GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation);
+GL_API void GL_APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GL_API void GL_APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+GL_API void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+GL_API void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_API void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glCullFace (GLenum mode);
+GL_API void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
+GL_API void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
+GL_API void GL_APIENTRY glDepthFunc (GLenum func);
+GL_API void GL_APIENTRY glDepthMask (GLboolean flag);
+GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
+GL_API void GL_APIENTRY glDisable (GLenum cap);
+GL_API void GL_APIENTRY glDisableClientState (GLenum array);
+GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+GL_API void GL_APIENTRY glEnable (GLenum cap);
+GL_API void GL_APIENTRY glEnableClientState (GLenum array);
+GL_API void GL_APIENTRY glFinish (void);
+GL_API void GL_APIENTRY glFlush (void);
+GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glFrontFace (GLenum mode);
+GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params);
+GL_API void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed eqn[4]);
+GL_API void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
+GL_API void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
+GL_API GLenum GL_APIENTRY glGetError (void);
+GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetPointerv (GLenum pname, GLvoid **params);
+GL_API const GLubyte * GL_APIENTRY glGetString (GLenum name);
+GL_API void GL_APIENTRY glGetTexEnviv (GLenum env, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glHint (GLenum target, GLenum mode);
+GL_API GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
+GL_API GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
+GL_API GLboolean GL_APIENTRY glIsTexture (GLuint texture);
+GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLineWidthx (GLfixed width);
+GL_API void GL_APIENTRY glLoadIdentity (void);
+GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m);
+GL_API void GL_APIENTRY glLogicOp (GLenum opcode);
+GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glMatrixMode (GLenum mode);
+GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m);
+GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
+GL_API void GL_APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
+GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glPointSizex (GLfixed size);
+GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
+GL_API void GL_APIENTRY glPopMatrix (void);
+GL_API void GL_APIENTRY glPushMatrix (void);
+GL_API void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
+GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
+GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glShadeModel (GLenum mode);
+GL_API void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GL_API void GL_APIENTRY glStencilMask (GLuint mask);
+GL_API void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GL_API void GL_APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);
+GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);
+GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GL_API void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
+GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+
+/*------------------------------------------------------------------------*
+ * Required OES extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_read_format */
+#ifndef GL_OES_read_format
+#define GL_OES_read_format 1
+#endif
+
+/* GL_OES_compressed_paletted_texture */
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_OES_compressed_paletted_texture 1
+#endif
+
+/* GL_OES_point_size_array */
+#ifndef GL_OES_point_size_array
+#define GL_OES_point_size_array 1
+GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+/* GL_OES_point_sprite */
+#ifndef GL_OES_point_sprite
+#define GL_OES_point_sprite 1
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl_h_ */
+
diff --git a/thirdparty/khronos/GLES/glext.h b/thirdparty/khronos/GLES/glext.h
new file mode 100644 (file)
index 0000000..1b4cda6
--- /dev/null
@@ -0,0 +1,1192 @@
+#ifndef __gles_glext_h_
+#define __gles_glext_h_
+
+/* $Revision: 18482 $ on $Date:: 2012-07-11 18:08:18 -0700 #$ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+#ifndef GL_APIENTRYP
+#   define GL_APIENTRYP GL_APIENTRY*
+#endif
+
+/*------------------------------------------------------------------------*
+ * OES extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_blend_equation_separate */
+#ifndef GL_OES_blend_equation_separate
+/* BLEND_EQUATION_RGB_OES same as BLEND_EQUATION_OES */
+#define GL_BLEND_EQUATION_RGB_OES                               0x8009
+#define GL_BLEND_EQUATION_ALPHA_OES                             0x883D
+#endif
+
+/* GL_OES_blend_func_separate */
+#ifndef GL_OES_blend_func_separate
+#define GL_BLEND_DST_RGB_OES                                    0x80C8
+#define GL_BLEND_SRC_RGB_OES                                    0x80C9
+#define GL_BLEND_DST_ALPHA_OES                                  0x80CA
+#define GL_BLEND_SRC_ALPHA_OES                                  0x80CB
+#endif
+
+/* GL_OES_blend_subtract */
+#ifndef GL_OES_blend_subtract
+#define GL_BLEND_EQUATION_OES                                   0x8009
+#define GL_FUNC_ADD_OES                                         0x8006
+#define GL_FUNC_SUBTRACT_OES                                    0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_OES                            0x800B
+#endif
+
+/* GL_OES_compressed_ETC1_RGB8_texture */
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_ETC1_RGB8_OES                                        0x8D64
+#endif
+
+/* GL_OES_depth24 */
+#ifndef GL_OES_depth24
+#define GL_DEPTH_COMPONENT24_OES                                0x81A6
+#endif
+
+/* GL_OES_depth32 */
+#ifndef GL_OES_depth32
+#define GL_DEPTH_COMPONENT32_OES                                0x81A7
+#endif
+
+/* GL_OES_draw_texture */
+#ifndef GL_OES_draw_texture
+#define GL_TEXTURE_CROP_RECT_OES                                0x8B9D
+#endif
+
+/* GL_OES_EGL_image */
+#ifndef GL_OES_EGL_image
+typedef void* GLeglImageOES;
+#endif
+
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
+/* GLeglImageOES defined in GL_OES_EGL_image already. */
+#define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
+#define GL_TEXTURE_BINDING_EXTERNAL_OES                         0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES                     0x8D68
+#endif
+
+/* GL_OES_element_index_uint */
+#ifndef GL_OES_element_index_uint
+#define GL_UNSIGNED_INT                                         0x1405
+#endif
+
+/* GL_OES_fixed_point */
+#ifndef GL_OES_fixed_point
+#define GL_FIXED_OES                                            0x140C
+#endif
+
+/* GL_OES_framebuffer_object */
+#ifndef GL_OES_framebuffer_object
+#define GL_NONE_OES                                             0
+#define GL_FRAMEBUFFER_OES                                      0x8D40
+#define GL_RENDERBUFFER_OES                                     0x8D41
+#define GL_RGBA4_OES                                            0x8056
+#define GL_RGB5_A1_OES                                          0x8057
+#define GL_RGB565_OES                                           0x8D62
+#define GL_DEPTH_COMPONENT16_OES                                0x81A5
+#define GL_RENDERBUFFER_WIDTH_OES                               0x8D42
+#define GL_RENDERBUFFER_HEIGHT_OES                              0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES                     0x8D44
+#define GL_RENDERBUFFER_RED_SIZE_OES                            0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_OES                          0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_OES                           0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_OES                          0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_OES                          0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_OES                        0x8D55
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES               0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES               0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES             0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES     0x8CD3
+#define GL_COLOR_ATTACHMENT0_OES                                0x8CE0
+#define GL_DEPTH_ATTACHMENT_OES                                 0x8D00
+#define GL_STENCIL_ATTACHMENT_OES                               0x8D20
+#define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES                0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES        0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES                0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES                   0x8CDA
+#define GL_FRAMEBUFFER_UNSUPPORTED_OES                          0x8CDD
+#define GL_FRAMEBUFFER_BINDING_OES                              0x8CA6
+#define GL_RENDERBUFFER_BINDING_OES                             0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE_OES                            0x84E8
+#define GL_INVALID_FRAMEBUFFER_OPERATION_OES                    0x0506
+#endif
+
+/* GL_OES_mapbuffer */
+#ifndef GL_OES_mapbuffer
+#define GL_WRITE_ONLY_OES                                       0x88B9
+#define GL_BUFFER_ACCESS_OES                                    0x88BB
+#define GL_BUFFER_MAPPED_OES                                    0x88BC
+#define GL_BUFFER_MAP_POINTER_OES                               0x88BD
+#endif
+
+/* GL_OES_matrix_get */
+#ifndef GL_OES_matrix_get
+#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES               0x898D
+#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES              0x898E
+#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES                 0x898F
+#endif
+
+/* GL_OES_matrix_palette */
+#ifndef GL_OES_matrix_palette
+#define GL_MAX_VERTEX_UNITS_OES                                 0x86A4
+#define GL_MAX_PALETTE_MATRICES_OES                             0x8842
+#define GL_MATRIX_PALETTE_OES                                   0x8840
+#define GL_MATRIX_INDEX_ARRAY_OES                               0x8844
+#define GL_WEIGHT_ARRAY_OES                                     0x86AD
+#define GL_CURRENT_PALETTE_MATRIX_OES                           0x8843
+#define GL_MATRIX_INDEX_ARRAY_SIZE_OES                          0x8846
+#define GL_MATRIX_INDEX_ARRAY_TYPE_OES                          0x8847
+#define GL_MATRIX_INDEX_ARRAY_STRIDE_OES                        0x8848
+#define GL_MATRIX_INDEX_ARRAY_POINTER_OES                       0x8849
+#define GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES                0x8B9E
+#define GL_WEIGHT_ARRAY_SIZE_OES                                0x86AB
+#define GL_WEIGHT_ARRAY_TYPE_OES                                0x86A9
+#define GL_WEIGHT_ARRAY_STRIDE_OES                              0x86AA
+#define GL_WEIGHT_ARRAY_POINTER_OES                             0x86AC
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_OES                      0x889E
+#endif
+
+/* GL_OES_packed_depth_stencil */
+#ifndef GL_OES_packed_depth_stencil
+#define GL_DEPTH_STENCIL_OES                                    0x84F9
+#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
+#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
+#endif
+
+/* GL_OES_required_internalformat */
+/* No new tokens introduced by this extension. */
+
+/* GL_OES_rgb8_rgba8 */
+#ifndef GL_OES_rgb8_rgba8
+#define GL_RGB8_OES                                             0x8051
+#define GL_RGBA8_OES                                            0x8058
+#endif
+
+/* GL_OES_stencil1 */
+#ifndef GL_OES_stencil1
+#define GL_STENCIL_INDEX1_OES                                   0x8D46
+#endif
+
+/* GL_OES_stencil4 */
+#ifndef GL_OES_stencil4
+#define GL_STENCIL_INDEX4_OES                                   0x8D47
+#endif
+
+/* GL_OES_stencil8 */
+#ifndef GL_OES_stencil8
+#define GL_STENCIL_INDEX8_OES                                   0x8D48
+#endif
+
+/* GL_OES_stencil_wrap */
+#ifndef GL_OES_stencil_wrap
+#define GL_INCR_WRAP_OES                                        0x8507
+#define GL_DECR_WRAP_OES                                        0x8508
+#endif
+
+/* GL_OES_texture_cube_map */
+#ifndef GL_OES_texture_cube_map
+#define GL_NORMAL_MAP_OES                                       0x8511
+#define GL_REFLECTION_MAP_OES                                   0x8512
+#define GL_TEXTURE_CUBE_MAP_OES                                 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_OES                         0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES                      0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES                      0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES                      0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES                      0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES                      0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES                      0x851A
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES                        0x851C
+#define GL_TEXTURE_GEN_MODE_OES                                 0x2500
+#define GL_TEXTURE_GEN_STR_OES                                  0x8D60
+#endif
+
+/* GL_OES_texture_mirrored_repeat */
+#ifndef GL_OES_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_OES                                  0x8370
+#endif
+
+/* GL_OES_vertex_array_object */
+#ifndef GL_OES_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING_OES                             0x85B5
+#endif
+
+/*------------------------------------------------------------------------*
+ * AMD extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_AMD_compressed_3DC_texture */
+#ifndef GL_AMD_compressed_3DC_texture
+#define GL_3DC_X_AMD                                            0x87F9
+#define GL_3DC_XY_AMD                                           0x87FA
+#endif
+
+/* GL_AMD_compressed_ATC_texture */
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_ATC_RGB_AMD                                          0x8C92
+#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
+#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
+#endif
+
+/*------------------------------------------------------------------------*
+ * APPLE extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_APPLE_texture_2D_limited_npot */
+/* No new tokens introduced by this extension. */
+
+/* GL_APPLE_framebuffer_multisample */
+#ifndef GL_APPLE_framebuffer_multisample
+#define GL_RENDERBUFFER_SAMPLES_APPLE                           0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE             0x8D56
+#define GL_MAX_SAMPLES_APPLE                                    0x8D57
+#define GL_READ_FRAMEBUFFER_APPLE                               0x8CA8
+#define GL_DRAW_FRAMEBUFFER_APPLE                               0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE                       0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_APPLE                       0x8CAA
+#endif
+
+/* GL_APPLE_texture_format_BGRA8888 */
+#ifndef GL_APPLE_texture_format_BGRA8888
+#define GL_BGRA_EXT                                             0x80E1
+#endif
+
+/* GL_APPLE_texture_max_level */
+#ifndef GL_APPLE_texture_max_level
+#define GL_TEXTURE_MAX_LEVEL_APPLE                              0x813D
+#endif
+
+/*------------------------------------------------------------------------*
+ * ARM extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_ARM_rgba8 */
+/* No new tokens introduced by this extension. */
+
+/*------------------------------------------------------------------------*
+ * EXT extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_EXT_blend_minmax */
+#ifndef GL_EXT_blend_minmax
+#define GL_MIN_EXT                                              0x8007
+#define GL_MAX_EXT                                              0x8008
+#endif
+
+/* GL_EXT_discard_framebuffer */
+#ifndef GL_EXT_discard_framebuffer
+#define GL_COLOR_EXT                                            0x1800
+#define GL_DEPTH_EXT                                            0x1801
+#define GL_STENCIL_EXT                                          0x1802
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT           0x8D6C
+/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ 
+#define GL_RENDERBUFFER_SAMPLES_EXT                             0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT               0x8D56
+#define GL_MAX_SAMPLES_EXT                                      0x8D57
+#endif
+
+/* GL_EXT_multi_draw_arrays */
+/* No new tokens introduced by this extension. */
+
+/* GL_EXT_read_format_bgra */
+#ifndef GL_EXT_read_format_bgra
+#define GL_BGRA_EXT                                             0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT                       0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT                       0x8366
+#endif
+
+/* GL_EXT_robustness */
+#ifndef GL_EXT_robustness
+/* reuse GL_NO_ERROR */
+#define GL_GUILTY_CONTEXT_RESET_EXT                             0x8253
+#define GL_INNOCENT_CONTEXT_RESET_EXT                           0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_EXT                            0x8255
+#define GL_CONTEXT_ROBUST_ACCESS_EXT                            0x90F3
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT                      0x8256
+#define GL_LOSE_CONTEXT_ON_RESET_EXT                            0x8252
+#define GL_NO_RESET_NOTIFICATION_EXT                            0x8261
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_SRGB_EXT                                             0x8C40
+#define GL_SRGB_ALPHA_EXT                                       0x8C42
+#define GL_SRGB8_ALPHA8_EXT                                     0x8C43
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT            0x8210
+#endif
+
+/* GL_EXT_texture_compression_dxt1 */
+#ifndef GL_EXT_texture_compression_dxt1
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT                         0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT                        0x83F1
+#endif
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF
+#endif
+
+/* GL_EXT_texture_format_BGRA8888 */
+#ifndef GL_EXT_texture_format_BGRA8888
+#define GL_BGRA_EXT                                             0x80E1
+#endif
+
+/* GL_EXT_texture_lod_bias */
+#ifndef GL_EXT_texture_lod_bias
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT                             0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT                           0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT                                 0x8501
+#endif
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT                         0x912F
+#define GL_ALPHA8_EXT                                           0x803C  
+#define GL_LUMINANCE8_EXT                                       0x8040
+#define GL_LUMINANCE8_ALPHA8_EXT                                0x8045
+#define GL_RGBA32F_EXT                                          0x8814  
+#define GL_RGB32F_EXT                                           0x8815
+#define GL_ALPHA32F_EXT                                         0x8816
+#define GL_LUMINANCE32F_EXT                                     0x8818
+#define GL_LUMINANCE_ALPHA32F_EXT                               0x8819
+/* reuse GL_RGBA16F_EXT */
+#define GL_RGB16F_EXT                                           0x881B
+#define GL_ALPHA16F_EXT                                         0x881C
+#define GL_LUMINANCE16F_EXT                                     0x881E
+#define GL_LUMINANCE_ALPHA16F_EXT                               0x881F
+#define GL_RGB10_A2_EXT                                         0x8059  
+#define GL_RGB10_EXT                                            0x8052
+#define GL_BGRA8_EXT                                            0x93A1
+#endif
+
+/*------------------------------------------------------------------------*
+ * IMG extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_IMG_read_format */
+#ifndef GL_IMG_read_format
+#define GL_BGRA_IMG                                             0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG                       0x8365
+#endif
+
+/* GL_IMG_texture_compression_pvrtc */
+#ifndef GL_IMG_texture_compression_pvrtc
+#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
+#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
+#endif
+
+/* GL_IMG_texture_env_enhanced_fixed_function */
+#ifndef GL_IMG_texture_env_enhanced_fixed_function
+#define GL_MODULATE_COLOR_IMG                                   0x8C04
+#define GL_RECIP_ADD_SIGNED_ALPHA_IMG                           0x8C05
+#define GL_TEXTURE_ALPHA_MODULATE_IMG                           0x8C06
+#define GL_FACTOR_ALPHA_MODULATE_IMG                            0x8C07
+#define GL_FRAGMENT_ALPHA_MODULATE_IMG                          0x8C08
+#define GL_ADD_BLEND_IMG                                        0x8C09
+#define GL_DOT3_RGBA_IMG                                        0x86AF
+#endif
+
+/* GL_IMG_user_clip_plane */
+#ifndef GL_IMG_user_clip_plane
+#define GL_CLIP_PLANE0_IMG                                      0x3000
+#define GL_CLIP_PLANE1_IMG                                      0x3001
+#define GL_CLIP_PLANE2_IMG                                      0x3002
+#define GL_CLIP_PLANE3_IMG                                      0x3003
+#define GL_CLIP_PLANE4_IMG                                      0x3004
+#define GL_CLIP_PLANE5_IMG                                      0x3005
+#define GL_MAX_CLIP_PLANES_IMG                                  0x0D32
+#endif
+
+/* GL_IMG_multisampled_render_to_texture */
+#ifndef GL_IMG_multisampled_render_to_texture
+#define GL_RENDERBUFFER_SAMPLES_IMG                             0x9133
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG               0x9134
+#define GL_MAX_SAMPLES_IMG                                      0x9135
+#define GL_TEXTURE_SAMPLES_IMG                                  0x9136
+#endif
+
+/*------------------------------------------------------------------------*
+ * NV extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_NV_fence */
+#ifndef GL_NV_fence
+#define GL_ALL_COMPLETED_NV                                     0x84F2
+#define GL_FENCE_STATUS_NV                                      0x84F3
+#define GL_FENCE_CONDITION_NV                                   0x84F4
+#endif
+
+/*------------------------------------------------------------------------*
+ * QCOM extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_QCOM_driver_control */
+/* No new tokens introduced by this extension. */
+
+/* GL_QCOM_extended_get */
+#ifndef GL_QCOM_extended_get
+#define GL_TEXTURE_WIDTH_QCOM                                   0x8BD2
+#define GL_TEXTURE_HEIGHT_QCOM                                  0x8BD3
+#define GL_TEXTURE_DEPTH_QCOM                                   0x8BD4
+#define GL_TEXTURE_INTERNAL_FORMAT_QCOM                         0x8BD5
+#define GL_TEXTURE_FORMAT_QCOM                                  0x8BD6
+#define GL_TEXTURE_TYPE_QCOM                                    0x8BD7
+#define GL_TEXTURE_IMAGE_VALID_QCOM                             0x8BD8
+#define GL_TEXTURE_NUM_LEVELS_QCOM                              0x8BD9
+#define GL_TEXTURE_TARGET_QCOM                                  0x8BDA
+#define GL_TEXTURE_OBJECT_VALID_QCOM                            0x8BDB
+#define GL_STATE_RESTORE                                        0x8BDC
+#endif
+
+/* GL_QCOM_extended_get2 */
+/* No new tokens introduced by this extension. */
+
+/* GL_QCOM_perfmon_global_mode */
+#ifndef GL_QCOM_perfmon_global_mode
+#define GL_PERFMON_GLOBAL_MODE_QCOM                             0x8FA0
+#endif
+
+/* GL_QCOM_writeonly_rendering */
+#ifndef GL_QCOM_writeonly_rendering
+#define GL_WRITEONLY_RENDERING_QCOM                             0x8823
+#endif
+
+/* GL_QCOM_tiled_rendering */
+#ifndef GL_QCOM_tiled_rendering
+#define GL_COLOR_BUFFER_BIT0_QCOM                               0x00000001
+#define GL_COLOR_BUFFER_BIT1_QCOM                               0x00000002
+#define GL_COLOR_BUFFER_BIT2_QCOM                               0x00000004
+#define GL_COLOR_BUFFER_BIT3_QCOM                               0x00000008
+#define GL_COLOR_BUFFER_BIT4_QCOM                               0x00000010
+#define GL_COLOR_BUFFER_BIT5_QCOM                               0x00000020
+#define GL_COLOR_BUFFER_BIT6_QCOM                               0x00000040
+#define GL_COLOR_BUFFER_BIT7_QCOM                               0x00000080
+#define GL_DEPTH_BUFFER_BIT0_QCOM                               0x00000100
+#define GL_DEPTH_BUFFER_BIT1_QCOM                               0x00000200
+#define GL_DEPTH_BUFFER_BIT2_QCOM                               0x00000400
+#define GL_DEPTH_BUFFER_BIT3_QCOM                               0x00000800
+#define GL_DEPTH_BUFFER_BIT4_QCOM                               0x00001000
+#define GL_DEPTH_BUFFER_BIT5_QCOM                               0x00002000
+#define GL_DEPTH_BUFFER_BIT6_QCOM                               0x00004000
+#define GL_DEPTH_BUFFER_BIT7_QCOM                               0x00008000
+#define GL_STENCIL_BUFFER_BIT0_QCOM                             0x00010000
+#define GL_STENCIL_BUFFER_BIT1_QCOM                             0x00020000
+#define GL_STENCIL_BUFFER_BIT2_QCOM                             0x00040000
+#define GL_STENCIL_BUFFER_BIT3_QCOM                             0x00080000
+#define GL_STENCIL_BUFFER_BIT4_QCOM                             0x00100000
+#define GL_STENCIL_BUFFER_BIT5_QCOM                             0x00200000
+#define GL_STENCIL_BUFFER_BIT6_QCOM                             0x00400000
+#define GL_STENCIL_BUFFER_BIT7_QCOM                             0x00800000
+#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM                         0x01000000
+#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM                         0x02000000
+#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM                         0x04000000
+#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM                         0x08000000
+#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM                         0x10000000
+#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM                         0x20000000
+#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM                         0x40000000
+#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM                         0x80000000
+#endif
+
+/*------------------------------------------------------------------------*
+ * End of extension tokens, start of corresponding extension functions
+ *------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*
+ * OES extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_blend_equation_separate */
+#ifndef GL_OES_blend_equation_separate
+#define GL_OES_blend_equation_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha);
+#endif
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEOESPROC) (GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+/* GL_OES_blend_func_separate */
+#ifndef GL_OES_blend_func_separate
+#define GL_OES_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glBlendFuncSeparateOES (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+
+/* GL_OES_blend_subtract */
+#ifndef GL_OES_blend_subtract
+#define GL_OES_blend_subtract 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glBlendEquationOES (GLenum mode);
+#endif
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC) (GLenum mode);
+#endif
+
+/* GL_OES_byte_coordinates */
+#ifndef GL_OES_byte_coordinates
+#define GL_OES_byte_coordinates 1
+#endif
+
+/* GL_OES_compressed_ETC1_RGB8_texture */
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_OES_compressed_ETC1_RGB8_texture 1
+#endif
+
+/* GL_OES_depth24 */
+#ifndef GL_OES_depth24
+#define GL_OES_depth24 1
+#endif
+
+/* GL_OES_depth32 */
+#ifndef GL_OES_depth32
+#define GL_OES_depth32 1
+#endif
+
+/* GL_OES_draw_texture */
+#ifndef GL_OES_draw_texture
+#define GL_OES_draw_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
+GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height);
+GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
+GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords);
+GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords);
+GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords);
+GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
+GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords);
+#endif
+typedef void (GL_APIENTRYP PFNGLDRAWTEXSOESPROC) (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXIOESPROC) (GLint x, GLint y, GLint z, GLint width, GLint height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXXOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXSVOESPROC) (const GLshort *coords);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOESPROC) (const GLint *coords);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXXVOESPROC) (const GLfixed *coords);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXFOESPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOESPROC) (const GLfloat *coords);
+#endif
+
+/* GL_OES_EGL_image */
+#ifndef GL_OES_EGL_image
+#define GL_OES_EGL_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
+#endif
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
+#endif
+
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
+#define GL_OES_EGL_image_external 1
+/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */
+#endif
+
+/* GL_OES_element_index_uint */
+#ifndef GL_OES_element_index_uint
+#define GL_OES_element_index_uint 1
+#endif
+
+/* GL_OES_extended_matrix_palette */
+#ifndef GL_OES_extended_matrix_palette
+#define GL_OES_extended_matrix_palette 1
+#endif
+
+/* GL_OES_fbo_render_mipmap */
+#ifndef GL_OES_fbo_render_mipmap
+#define GL_OES_fbo_render_mipmap 1
+#endif
+
+/* GL_OES_fixed_point */
+#ifndef GL_OES_fixed_point
+#define GL_OES_fixed_point 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glAlphaFuncxOES (GLenum func, GLclampx ref);
+GL_API void GL_APIENTRY glClearColorxOES (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+GL_API void GL_APIENTRY glClearDepthxOES (GLclampx depth);
+GL_API void GL_APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation);
+GL_API void GL_APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GL_API void GL_APIENTRY glDepthRangexOES (GLclampx zNear, GLclampx zFar);
+GL_API void GL_APIENTRY glFogxOES (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glFogxvOES (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glFrustumxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glGetClipPlanexOES (GLenum pname, GLfixed eqn[4]);
+GL_API void GL_APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetLightxvOES (GLenum light, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetMaterialxvOES (GLenum face, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetTexEnvxvOES (GLenum env, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glLightModelxOES (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLineWidthxOES (GLfixed width);
+GL_API void GL_APIENTRY glLoadMatrixxOES (const GLfixed *m);
+GL_API void GL_APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glMultMatrixxOES (const GLfixed *m);
+GL_API void GL_APIENTRY glMultiTexCoord4xOES (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+GL_API void GL_APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz);
+GL_API void GL_APIENTRY glOrthoxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glPointParameterxOES (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glPointSizexOES (GLfixed size);
+GL_API void GL_APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units);
+GL_API void GL_APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glSampleCoveragexOES (GLclampx value, GLboolean invert);
+GL_API void GL_APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z);
+#endif
+typedef void (GL_APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLclampx ref);
+typedef void (GL_APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+typedef void (GL_APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLclampx depth);
+typedef void (GL_APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation);
+typedef void (GL_APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+typedef void (GL_APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLclampx zNear, GLclampx zFar);
+typedef void (GL_APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum pname, GLfixed eqn[4]);
+typedef void (GL_APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETLIGHTXVOESPROC) (GLenum light, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETMATERIALXVOESPROC) (GLenum face, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum env, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width);
+typedef void (GL_APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m);
+typedef void (GL_APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m);
+typedef void (GL_APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+typedef void (GL_APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz);
+typedef void (GL_APIENTRYP PFNGLORTHOXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXOESPROC) (GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size);
+typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units);
+typedef void (GL_APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEXOESPROC) (GLclampx value, GLboolean invert);
+typedef void (GL_APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+typedef void (GL_APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+#endif
+
+/* GL_OES_framebuffer_object */
+#ifndef GL_OES_framebuffer_object
+#define GL_OES_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLboolean GL_APIENTRY glIsRenderbufferOES (GLuint renderbuffer);
+GL_API void GL_APIENTRY glBindRenderbufferOES (GLenum target, GLuint renderbuffer);
+GL_API void GL_APIENTRY glDeleteRenderbuffersOES (GLsizei n, const GLuint* renderbuffers);
+GL_API void GL_APIENTRY glGenRenderbuffersOES (GLsizei n, GLuint* renderbuffers);
+GL_API void GL_APIENTRY glRenderbufferStorageOES (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glGetRenderbufferParameterivOES (GLenum target, GLenum pname, GLint* params);
+GL_API GLboolean GL_APIENTRY glIsFramebufferOES (GLuint framebuffer);
+GL_API void GL_APIENTRY glBindFramebufferOES (GLenum target, GLuint framebuffer);
+GL_API void GL_APIENTRY glDeleteFramebuffersOES (GLsizei n, const GLuint* framebuffers);
+GL_API void GL_APIENTRY glGenFramebuffersOES (GLsizei n, GLuint* framebuffers);
+GL_API GLenum GL_APIENTRY glCheckFramebufferStatusOES (GLenum target);
+GL_API void GL_APIENTRY glFramebufferRenderbufferOES (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GL_API void GL_APIENTRY glFramebufferTexture2DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GL_API void GL_APIENTRY glGetFramebufferAttachmentParameterivOES (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+GL_API void GL_APIENTRY glGenerateMipmapOES (GLenum target);
+#endif
+typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer);
+typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer);
+typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers);
+typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers);
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params);
+typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer);
+typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer);
+typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers);
+typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers);
+typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOESPROC) (GLenum target);
+#endif
+
+/* GL_OES_mapbuffer */
+#ifndef GL_OES_mapbuffer
+#define GL_OES_mapbuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
+GL_API GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
+GL_API void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid ** params);
+#endif
+typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
+typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid ** params);
+#endif
+
+/* GL_OES_matrix_get */
+#ifndef GL_OES_matrix_get
+#define GL_OES_matrix_get 1
+#endif
+
+/* GL_OES_matrix_palette */
+#ifndef GL_OES_matrix_palette
+#define GL_OES_matrix_palette 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glCurrentPaletteMatrixOES (GLuint matrixpaletteindex);
+GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES (void);
+GL_API void GL_APIENTRY glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+typedef void (GL_APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC) (GLuint matrixpaletteindex);
+typedef void (GL_APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC) (void);
+typedef void (GL_APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+/* GL_OES_packed_depth_stencil */
+#ifndef GL_OES_packed_depth_stencil
+#define GL_OES_packed_depth_stencil 1
+#endif
+
+/* GL_OES_required_internalformat */
+#ifndef GL_OES_required_internalformat
+#define GL_OES_required_internalformat 1
+#endif
+
+/* GL_OES_query_matrix */
+#ifndef GL_OES_query_matrix
+#define GL_OES_query_matrix 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES (GLfixed mantissa[16], GLint exponent[16]);
+#endif
+typedef GLbitfield (GL_APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed mantissa[16], GLint exponent[16]);
+#endif
+
+/* GL_OES_rgb8_rgba8 */
+#ifndef GL_OES_rgb8_rgba8
+#define GL_OES_rgb8_rgba8 1
+#endif
+
+/* GL_OES_single_precision */
+#ifndef GL_OES_single_precision
+#define GL_OES_single_precision 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar);
+GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);
+GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]);
+GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth);
+#endif
+typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar);
+typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+typedef void (GL_APIENTRYP PFNGLORTHOFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+typedef void (GL_APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation);
+typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum pname, GLfloat eqn[4]);
+typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth);
+#endif
+
+/* GL_OES_stencil1 */
+#ifndef GL_OES_stencil1
+#define GL_OES_stencil1 1
+#endif
+
+/* GL_OES_stencil4 */
+#ifndef GL_OES_stencil4
+#define GL_OES_stencil4 1
+#endif
+
+/* GL_OES_stencil8 */
+#ifndef GL_OES_stencil8
+#define GL_OES_stencil8 1
+#endif
+
+/* GL_OES_stencil_wrap */
+#ifndef GL_OES_stencil_wrap
+#define GL_OES_stencil_wrap 1
+#endif
+
+/* GL_OES_texture_cube_map */
+#ifndef GL_OES_texture_cube_map
+#define GL_OES_texture_cube_map 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param);
+GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params);
+GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params);
+#endif
+typedef void (GL_APIENTRYP PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param);
+typedef void (GL_APIENTRYP PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param);
+typedef void (GL_APIENTRYP PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params);
+typedef void (GL_APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
+#endif
+
+/* GL_OES_texture_env_crossbar */
+#ifndef GL_OES_texture_env_crossbar
+#define GL_OES_texture_env_crossbar 1
+#endif
+
+/* GL_OES_texture_mirrored_repeat */
+#ifndef GL_OES_texture_mirrored_repeat
+#define GL_OES_texture_mirrored_repeat 1
+#endif
+
+/* GL_OES_vertex_array_object */
+#ifndef GL_OES_vertex_array_object
+#define GL_OES_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glBindVertexArrayOES (GLuint array);
+GL_API void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);
+GL_API void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);
+GL_API GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);
+#endif
+typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
+typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
+typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
+#endif
+
+/*------------------------------------------------------------------------*
+ * AMD extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_AMD_compressed_3DC_texture */
+#ifndef GL_AMD_compressed_3DC_texture
+#define GL_AMD_compressed_3DC_texture 1
+#endif
+
+/* GL_AMD_compressed_ATC_texture */
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_AMD_compressed_ATC_texture 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * APPLE extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_APPLE_texture_2D_limited_npot */
+#ifndef GL_APPLE_texture_2D_limited_npot
+#define GL_APPLE_texture_2D_limited_npot 1
+#endif
+
+/* GL_APPLE_framebuffer_multisample */
+#ifndef GL_APPLE_framebuffer_multisample
+#define GL_APPLE_framebuffer_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_API void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
+#endif
+
+/* GL_APPLE_texture_format_BGRA8888 */
+#ifndef GL_APPLE_texture_format_BGRA8888
+#define GL_APPLE_texture_format_BGRA8888 1
+#endif
+
+/* GL_APPLE_texture_max_level */
+#ifndef GL_APPLE_texture_max_level
+#define GL_APPLE_texture_max_level 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * ARM extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_ARM_rgba8 */
+#ifndef GL_ARM_rgba8
+#define GL_ARM_rgba8 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * EXT extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_EXT_blend_minmax */
+#ifndef GL_EXT_blend_minmax
+#define GL_EXT_blend_minmax 1
+#endif
+
+/* GL_EXT_discard_framebuffer */
+#ifndef GL_EXT_discard_framebuffer
+#define GL_EXT_discard_framebuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+#endif
+typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_EXT_multisampled_render_to_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+#endif
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+
+/* GL_EXT_multi_draw_arrays */
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
+GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif
+
+/* GL_EXT_read_format_bgra */
+#ifndef GL_EXT_read_format_bgra
+#define GL_EXT_read_format_bgra 1
+#endif
+
+/* GL_EXT_robustness */
+#ifndef GL_EXT_robustness
+#define GL_EXT_robustness 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void);
+GL_API void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+GL_API void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params);
+GL_API void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_EXT_sRGB 1
+#endif
+
+/* GL_EXT_texture_compression_dxt1 */
+#ifndef GL_EXT_texture_compression_dxt1
+#define GL_EXT_texture_compression_dxt1 1
+#endif
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#endif
+
+/* GL_EXT_texture_format_BGRA8888 */
+#ifndef GL_EXT_texture_format_BGRA8888
+#define GL_EXT_texture_format_BGRA8888 1
+#endif
+
+/* GL_EXT_texture_lod_bias */
+#ifndef GL_EXT_texture_lod_bias
+#define GL_EXT_texture_lod_bias 1
+#endif
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_EXT_texture_storage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_API void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GL_API void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_API void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+/*------------------------------------------------------------------------*
+ * IMG extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_IMG_read_format */
+#ifndef GL_IMG_read_format
+#define GL_IMG_read_format 1
+#endif
+
+/* GL_IMG_texture_compression_pvrtc */
+#ifndef GL_IMG_texture_compression_pvrtc
+#define GL_IMG_texture_compression_pvrtc 1
+#endif
+
+/* GL_IMG_texture_env_enhanced_fixed_function */
+#ifndef GL_IMG_texture_env_enhanced_fixed_function
+#define GL_IMG_texture_env_enhanced_fixed_function 1
+#endif
+
+/* GL_IMG_user_clip_plane */
+#ifndef GL_IMG_user_clip_plane
+#define GL_IMG_user_clip_plane 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glClipPlanefIMG (GLenum, const GLfloat *);
+GL_API void GL_APIENTRY glClipPlanexIMG (GLenum, const GLfixed *);
+#endif
+typedef void (GL_APIENTRYP PFNGLCLIPPLANEFIMGPROC) (GLenum p, const GLfloat *eqn);
+typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMGPROC) (GLenum p, const GLfixed *eqn);
+#endif
+
+/* GL_IMG_multisampled_render_to_texture */
+#ifndef GL_IMG_multisampled_render_to_texture
+#define GL_IMG_multisampled_render_to_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+#endif
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+
+/*------------------------------------------------------------------------*
+ * NV extension functions
+ *------------------------------------------------------------------------*/
+
+/* NV_fence */
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
+GL_API void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
+GL_API GLboolean GL_APIENTRY glIsFenceNV (GLuint);
+GL_API GLboolean GL_APIENTRY glTestFenceNV (GLuint);
+GL_API void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
+GL_API void GL_APIENTRY glFinishFenceNV (GLuint);
+GL_API void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
+#endif
+typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
+typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
+typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
+typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
+typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
+typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#endif
+
+/*------------------------------------------------------------------------*
+ * QCOM extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_QCOM_driver_control */
+#ifndef GL_QCOM_driver_control
+#define GL_QCOM_driver_control 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
+GL_API void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
+GL_API void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
+GL_API void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
+#endif
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
+typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
+typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
+#endif
+
+/* GL_QCOM_extended_get */
+#ifndef GL_QCOM_extended_get
+#define GL_QCOM_extended_get 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);
+GL_API void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
+GL_API void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
+GL_API void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
+GL_API void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);
+GL_API void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
+GL_API void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);
+#endif
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);
+#endif
+
+/* GL_QCOM_extended_get2 */
+#ifndef GL_QCOM_extended_get2
+#define GL_QCOM_extended_get2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);
+GL_API void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
+GL_API GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);
+GL_API void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
+#endif
+typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
+typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
+#endif
+
+/* GL_QCOM_perfmon_global_mode */
+#ifndef GL_QCOM_perfmon_global_mode
+#define GL_QCOM_perfmon_global_mode 1
+#endif
+
+/* GL_QCOM_writeonly_rendering */
+#ifndef GL_QCOM_writeonly_rendering
+#define GL_QCOM_writeonly_rendering 1
+#endif
+
+/* GL_QCOM_tiled_rendering */
+#ifndef GL_QCOM_tiled_rendering
+#define GL_QCOM_tiled_rendering 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+GL_API void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);
+#endif
+typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gles_glext_h_ */
+
diff --git a/thirdparty/khronos/GLES/glext.patch b/thirdparty/khronos/GLES/glext.patch
new file mode 100644 (file)
index 0000000..64ab153
--- /dev/null
@@ -0,0 +1,19 @@
+diff --git a/thirdparty/khronos/GLES/glext.h b/thirdparty/khronos/GLES/glext.h
+index d591832..90fd2c3 100644
+--- a/thirdparty/khronos/GLES/glext.h
++++ b/thirdparty/khronos/GLES/glext.h
+@@ -1,5 +1,5 @@
+-#ifndef __glext_h_
+-#define __glext_h_
++#ifndef __gles_glext_h_
++#define __gles_glext_h_
+ /* $Revision: 16481 $ on $Date:: 2012-01-04 10:43:56 -0800 #$ */
+@@ -1179,5 +1179,5 @@ typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
+ }
+ #endif
+-#endif /* __glext_h_ */
++#endif /* __gles_glext_h_ */
diff --git a/thirdparty/khronos/GLES/glplatform.h b/thirdparty/khronos/GLES/glplatform.h
new file mode 100644 (file)
index 0000000..2db6ee2
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __glplatform_h_
+#define __glplatform_h_
+
+/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/* Platform-specific types and definitions for OpenGL ES 1.X  gl.h
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product "OpenGL-ES" component "Registry".
+ */
+
+#include <KHR/khrplatform.h>
+
+#ifndef GL_API
+#define GL_API      KHRONOS_APICALL
+#endif
+
+#ifndef GL_APIENTRY
+#define GL_APIENTRY KHRONOS_APIENTRY
+#endif
+
+#endif /* __glplatform_h_ */
diff --git a/thirdparty/khronos/GLES2/gl2.h b/thirdparty/khronos/GLES2/gl2.h
new file mode 100644 (file)
index 0000000..b7fe76e
--- /dev/null
@@ -0,0 +1,620 @@
+#ifndef __gl2_h_
+#define __gl2_h_
+
+/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -0800 #$ */
+
+#include <GLES2/gl2platform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/*-------------------------------------------------------------------------
+ * Data type definitions
+ *-----------------------------------------------------------------------*/
+
+typedef void             GLvoid;
+typedef char             GLchar;
+typedef unsigned int     GLenum;
+typedef unsigned char    GLboolean;
+typedef unsigned int     GLbitfield;
+typedef khronos_int8_t   GLbyte;
+typedef short            GLshort;
+typedef int              GLint;
+typedef int              GLsizei;
+typedef khronos_uint8_t  GLubyte;
+typedef unsigned short   GLushort;
+typedef unsigned int     GLuint;
+typedef khronos_float_t  GLfloat;
+typedef khronos_float_t  GLclampf;
+typedef khronos_int32_t  GLfixed;
+
+/* GL types for handling large vertex buffer objects */
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t  GLsizeiptr;
+
+/* OpenGL ES core versions */
+#define GL_ES_VERSION_2_0                 1
+
+/* ClearBufferMask */
+#define GL_DEPTH_BUFFER_BIT               0x00000100
+#define GL_STENCIL_BUFFER_BIT             0x00000400
+#define GL_COLOR_BUFFER_BIT               0x00004000
+
+/* Boolean */
+#define GL_FALSE                          0
+#define GL_TRUE                           1
+
+/* BeginMode */
+#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
+
+/* AlphaFunction (not supported in ES20) */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* BlendingFactorDest */
+#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
+
+/* BlendingFactorSrc */
+/*      GL_ZERO */
+/*      GL_ONE */
+#define GL_DST_COLOR                      0x0306
+#define GL_ONE_MINUS_DST_COLOR            0x0307
+#define GL_SRC_ALPHA_SATURATE             0x0308
+/*      GL_SRC_ALPHA */
+/*      GL_ONE_MINUS_SRC_ALPHA */
+/*      GL_DST_ALPHA */
+/*      GL_ONE_MINUS_DST_ALPHA */
+
+/* BlendEquationSeparate */
+#define GL_FUNC_ADD                       0x8006
+#define GL_BLEND_EQUATION                 0x8009
+#define GL_BLEND_EQUATION_RGB             0x8009    /* same as BLEND_EQUATION */
+#define GL_BLEND_EQUATION_ALPHA           0x883D
+
+/* BlendSubtract */
+#define GL_FUNC_SUBTRACT                  0x800A
+#define GL_FUNC_REVERSE_SUBTRACT          0x800B
+
+/* Separate Blend Functions */
+#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_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
+
+/* Buffer Objects */
+#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_STREAM_DRAW                    0x88E0
+#define GL_STATIC_DRAW                    0x88E4
+#define GL_DYNAMIC_DRAW                   0x88E8
+
+#define GL_BUFFER_SIZE                    0x8764
+#define GL_BUFFER_USAGE                   0x8765
+
+#define GL_CURRENT_VERTEX_ATTRIB          0x8626
+
+/* CullFaceMode */
+#define GL_FRONT                          0x0404
+#define GL_BACK                           0x0405
+#define GL_FRONT_AND_BACK                 0x0408
+
+/* DepthFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* EnableCap */
+#define GL_TEXTURE_2D                     0x0DE1
+#define GL_CULL_FACE                      0x0B44
+#define GL_BLEND                          0x0BE2
+#define GL_DITHER                         0x0BD0
+#define GL_STENCIL_TEST                   0x0B90
+#define GL_DEPTH_TEST                     0x0B71
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
+#define GL_SAMPLE_COVERAGE                0x80A0
+
+/* ErrorCode */
+#define GL_NO_ERROR                       0
+#define GL_INVALID_ENUM                   0x0500
+#define GL_INVALID_VALUE                  0x0501
+#define GL_INVALID_OPERATION              0x0502
+#define GL_OUT_OF_MEMORY                  0x0505
+
+/* FrontFaceDirection */
+#define GL_CW                             0x0900
+#define GL_CCW                            0x0901
+
+/* GetPName */
+#define GL_LINE_WIDTH                     0x0B21
+#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
+#define GL_CULL_FACE_MODE                 0x0B45
+#define GL_FRONT_FACE                     0x0B46
+#define GL_DEPTH_RANGE                    0x0B70
+#define GL_DEPTH_WRITEMASK                0x0B72
+#define GL_DEPTH_CLEAR_VALUE              0x0B73
+#define GL_DEPTH_FUNC                     0x0B74
+#define GL_STENCIL_CLEAR_VALUE            0x0B91
+#define GL_STENCIL_FUNC                   0x0B92
+#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_VALUE_MASK             0x0B93
+#define GL_STENCIL_WRITEMASK              0x0B98
+#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_STENCIL_BACK_REF               0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK        0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK         0x8CA5
+#define GL_VIEWPORT                       0x0BA2
+#define GL_SCISSOR_BOX                    0x0C10
+/*      GL_SCISSOR_TEST */
+#define GL_COLOR_CLEAR_VALUE              0x0C22
+#define GL_COLOR_WRITEMASK                0x0C23
+#define GL_UNPACK_ALIGNMENT               0x0CF5
+#define GL_PACK_ALIGNMENT                 0x0D05
+#define GL_MAX_TEXTURE_SIZE               0x0D33
+#define GL_MAX_VIEWPORT_DIMS              0x0D3A
+#define GL_SUBPIXEL_BITS                  0x0D50
+#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_POLYGON_OFFSET_UNITS           0x2A00
+/*      GL_POLYGON_OFFSET_FILL */
+#define GL_POLYGON_OFFSET_FACTOR          0x8038
+#define GL_TEXTURE_BINDING_2D             0x8069
+#define GL_SAMPLE_BUFFERS                 0x80A8
+#define GL_SAMPLES                        0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE          0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT         0x80AB
+
+/* GetTextureParameter */
+/*      GL_TEXTURE_MAG_FILTER */
+/*      GL_TEXTURE_MIN_FILTER */
+/*      GL_TEXTURE_WRAP_S */
+/*      GL_TEXTURE_WRAP_T */
+
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
+
+/* HintMode */
+#define GL_DONT_CARE                      0x1100
+#define GL_FASTEST                        0x1101
+#define GL_NICEST                         0x1102
+
+/* HintTarget */
+#define GL_GENERATE_MIPMAP_HINT            0x8192
+
+/* DataType */
+#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_FIXED                          0x140C
+
+/* PixelFormat */
+#define GL_DEPTH_COMPONENT                0x1902
+#define GL_ALPHA                          0x1906
+#define GL_RGB                            0x1907
+#define GL_RGBA                           0x1908
+#define GL_LUMINANCE                      0x1909
+#define GL_LUMINANCE_ALPHA                0x190A
+
+/* PixelType */
+/*      GL_UNSIGNED_BYTE */
+#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
+#define GL_UNSIGNED_SHORT_5_6_5           0x8363
+
+/* Shaders */
+#define GL_FRAGMENT_SHADER                  0x8B30
+#define GL_VERTEX_SHADER                    0x8B31
+#define GL_MAX_VERTEX_ATTRIBS               0x8869
+#define GL_MAX_VERTEX_UNIFORM_VECTORS       0x8DFB
+#define GL_MAX_VARYING_VECTORS              0x8DFC
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS   0x8B4C
+#define GL_MAX_TEXTURE_IMAGE_UNITS          0x8872
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS     0x8DFD
+#define GL_SHADER_TYPE                      0x8B4F
+#define GL_DELETE_STATUS                    0x8B80
+#define GL_LINK_STATUS                      0x8B82
+#define GL_VALIDATE_STATUS                  0x8B83
+#define GL_ATTACHED_SHADERS                 0x8B85
+#define GL_ACTIVE_UNIFORMS                  0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH        0x8B87
+#define GL_ACTIVE_ATTRIBUTES                0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH      0x8B8A
+#define GL_SHADING_LANGUAGE_VERSION         0x8B8C
+#define GL_CURRENT_PROGRAM                  0x8B8D
+
+/* StencilFunction */
+#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
+
+/* StencilOp */
+/*      GL_ZERO */
+#define GL_KEEP                           0x1E00
+#define GL_REPLACE                        0x1E01
+#define GL_INCR                           0x1E02
+#define GL_DECR                           0x1E03
+#define GL_INVERT                         0x150A
+#define GL_INCR_WRAP                      0x8507
+#define GL_DECR_WRAP                      0x8508
+
+/* StringName */
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+
+/* TextureMagFilter */
+#define GL_NEAREST                        0x2600
+#define GL_LINEAR                         0x2601
+
+/* TextureMinFilter */
+/*      GL_NEAREST */
+/*      GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST         0x2700
+#define GL_LINEAR_MIPMAP_NEAREST          0x2701
+#define GL_NEAREST_MIPMAP_LINEAR          0x2702
+#define GL_LINEAR_MIPMAP_LINEAR           0x2703
+
+/* TextureParameterName */
+#define GL_TEXTURE_MAG_FILTER             0x2800
+#define GL_TEXTURE_MIN_FILTER             0x2801
+#define GL_TEXTURE_WRAP_S                 0x2802
+#define GL_TEXTURE_WRAP_T                 0x2803
+
+/* TextureTarget */
+/*      GL_TEXTURE_2D */
+#define GL_TEXTURE                        0x1702
+
+#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_MAX_CUBE_MAP_TEXTURE_SIZE      0x851C
+
+/* TextureUnit */
+#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
+
+/* TextureWrapMode */
+#define GL_REPEAT                         0x2901
+#define GL_CLAMP_TO_EDGE                  0x812F
+#define GL_MIRRORED_REPEAT                0x8370
+
+/* Uniform Types */
+#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_2D                     0x8B5E
+#define GL_SAMPLER_CUBE                   0x8B60
+
+/* Vertex Arrays */
+#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_VERTEX_ATTRIB_ARRAY_NORMALIZED     0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER        0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+
+/* Read Format */
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE   0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+
+/* Shader Source */
+#define GL_COMPILE_STATUS                 0x8B81
+#define GL_INFO_LOG_LENGTH                0x8B84
+#define GL_SHADER_SOURCE_LENGTH           0x8B88
+#define GL_SHADER_COMPILER                0x8DFA
+
+/* Shader Binary */
+#define GL_SHADER_BINARY_FORMATS          0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9
+
+/* Shader Precision-Specified Types */
+#define GL_LOW_FLOAT                      0x8DF0
+#define GL_MEDIUM_FLOAT                   0x8DF1
+#define GL_HIGH_FLOAT                     0x8DF2
+#define GL_LOW_INT                        0x8DF3
+#define GL_MEDIUM_INT                     0x8DF4
+#define GL_HIGH_INT                       0x8DF5
+
+/* Framebuffer Object. */
+#define GL_FRAMEBUFFER                    0x8D40
+#define GL_RENDERBUFFER                   0x8D41
+
+#define GL_RGBA4                          0x8056
+#define GL_RGB5_A1                        0x8057
+#define GL_RGB565                         0x8D62
+#define GL_DEPTH_COMPONENT16              0x81A5
+#define GL_STENCIL_INDEX8                 0x8D48
+
+#define GL_RENDERBUFFER_WIDTH             0x8D42
+#define GL_RENDERBUFFER_HEIGHT            0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT   0x8D44
+#define GL_RENDERBUFFER_RED_SIZE          0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE        0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE         0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE        0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE        0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE      0x8D55
+
+#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_COLOR_ATTACHMENT0              0x8CE0
+#define GL_DEPTH_ATTACHMENT               0x8D00
+#define GL_STENCIL_ATTACHMENT             0x8D20
+
+#define GL_NONE                           0
+
+#define GL_FRAMEBUFFER_COMPLETE                      0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT         0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS         0x8CD9
+#define GL_FRAMEBUFFER_UNSUPPORTED                   0x8CDD
+
+#define GL_FRAMEBUFFER_BINDING            0x8CA6
+#define GL_RENDERBUFFER_BINDING           0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE          0x84E8
+
+#define GL_INVALID_FRAMEBUFFER_OPERATION  0x0506
+
+/*-------------------------------------------------------------------------
+ * GL core functions.
+ *-----------------------------------------------------------------------*/
+
+GL_APICALL void         GL_APIENTRY glActiveTexture (GLenum texture);
+GL_APICALL void         GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
+GL_APICALL void         GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
+GL_APICALL void         GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GL_APICALL void         GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
+GL_APICALL void         GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
+GL_APICALL void         GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
+GL_APICALL void         GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GL_APICALL void         GL_APIENTRY glBlendEquation ( GLenum mode );
+GL_APICALL void         GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void         GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GL_APICALL void         GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GL_APICALL void         GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
+GL_APICALL void         GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
+GL_APICALL GLenum       GL_APIENTRY glCheckFramebufferStatus (GLenum target);
+GL_APICALL void         GL_APIENTRY glClear (GLbitfield mask);
+GL_APICALL void         GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GL_APICALL void         GL_APIENTRY glClearDepthf (GLclampf depth);
+GL_APICALL void         GL_APIENTRY glClearStencil (GLint s);
+GL_APICALL void         GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GL_APICALL void         GL_APIENTRY glCompileShader (GLuint shader);
+GL_APICALL void         GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void         GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void         GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_APICALL void         GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL GLuint       GL_APIENTRY glCreateProgram (void);
+GL_APICALL GLuint       GL_APIENTRY glCreateShader (GLenum type);
+GL_APICALL void         GL_APIENTRY glCullFace (GLenum mode);
+GL_APICALL void         GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
+GL_APICALL void         GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
+GL_APICALL void         GL_APIENTRY glDeleteProgram (GLuint program);
+GL_APICALL void         GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
+GL_APICALL void         GL_APIENTRY glDeleteShader (GLuint shader);
+GL_APICALL void         GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
+GL_APICALL void         GL_APIENTRY glDepthFunc (GLenum func);
+GL_APICALL void         GL_APIENTRY glDepthMask (GLboolean flag);
+GL_APICALL void         GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
+GL_APICALL void         GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
+GL_APICALL void         GL_APIENTRY glDisable (GLenum cap);
+GL_APICALL void         GL_APIENTRY glDisableVertexAttribArray (GLuint index);
+GL_APICALL void         GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GL_APICALL void         GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+GL_APICALL void         GL_APIENTRY glEnable (GLenum cap);
+GL_APICALL void         GL_APIENTRY glEnableVertexAttribArray (GLuint index);
+GL_APICALL void         GL_APIENTRY glFinish (void);
+GL_APICALL void         GL_APIENTRY glFlush (void);
+GL_APICALL void         GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GL_APICALL void         GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GL_APICALL void         GL_APIENTRY glFrontFace (GLenum mode);
+GL_APICALL void         GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
+GL_APICALL void         GL_APIENTRY glGenerateMipmap (GLenum target);
+GL_APICALL void         GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
+GL_APICALL void         GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
+GL_APICALL void         GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
+GL_APICALL void         GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+GL_APICALL void         GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+GL_APICALL void         GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+GL_APICALL int          GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
+GL_APICALL void         GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
+GL_APICALL void         GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL GLenum       GL_APIENTRY glGetError (void);
+GL_APICALL void         GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
+GL_APICALL void         GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+GL_APICALL void         GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
+GL_APICALL void         GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
+GL_APICALL void         GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+GL_APICALL void         GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void         GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
+GL_APICALL void         GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+GL_APICALL void         GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
+GL_APICALL void         GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
+GL_APICALL void         GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
+GL_APICALL void         GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
+GL_APICALL void         GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
+GL_APICALL void         GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
+GL_APICALL int          GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
+GL_APICALL void         GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
+GL_APICALL void         GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
+GL_APICALL void         GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
+GL_APICALL void         GL_APIENTRY glHint (GLenum target, GLenum mode);
+GL_APICALL GLboolean    GL_APIENTRY glIsBuffer (GLuint buffer);
+GL_APICALL GLboolean    GL_APIENTRY glIsEnabled (GLenum cap);
+GL_APICALL GLboolean    GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
+GL_APICALL GLboolean    GL_APIENTRY glIsProgram (GLuint program);
+GL_APICALL GLboolean    GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
+GL_APICALL GLboolean    GL_APIENTRY glIsShader (GLuint shader);
+GL_APICALL GLboolean    GL_APIENTRY glIsTexture (GLuint texture);
+GL_APICALL void         GL_APIENTRY glLineWidth (GLfloat width);
+GL_APICALL void         GL_APIENTRY glLinkProgram (GLuint program);
+GL_APICALL void         GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
+GL_APICALL void         GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GL_APICALL void         GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+GL_APICALL void         GL_APIENTRY glReleaseShaderCompiler (void);
+GL_APICALL void         GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void         GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
+GL_APICALL void         GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void         GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
+GL_APICALL void         GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
+GL_APICALL void         GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GL_APICALL void         GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
+GL_APICALL void         GL_APIENTRY glStencilMask (GLuint mask);
+GL_APICALL void         GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
+GL_APICALL void         GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void         GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void         GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void         GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GL_APICALL void         GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
+GL_APICALL void         GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GL_APICALL void         GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
+GL_APICALL void         GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void         GL_APIENTRY glUniform1f (GLint location, GLfloat x);
+GL_APICALL void         GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void         GL_APIENTRY glUniform1i (GLint location, GLint x);
+GL_APICALL void         GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void         GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
+GL_APICALL void         GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void         GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
+GL_APICALL void         GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void         GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void         GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void         GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
+GL_APICALL void         GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void         GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void         GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
+GL_APICALL void         GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void         GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
+GL_APICALL void         GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void         GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void         GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+GL_APICALL void         GL_APIENTRY glUseProgram (GLuint program);
+GL_APICALL void         GL_APIENTRY glValidateProgram (GLuint program);
+GL_APICALL void         GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
+GL_APICALL void         GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
+GL_APICALL void         GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
+GL_APICALL void         GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
+GL_APICALL void         GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void         GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
+GL_APICALL void         GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void         GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
+GL_APICALL void         GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
+GL_APICALL void         GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl2_h_ */
diff --git a/thirdparty/khronos/GLES2/gl2ext.h b/thirdparty/khronos/GLES2/gl2ext.h
new file mode 100644 (file)
index 0000000..206785c
--- /dev/null
@@ -0,0 +1,1525 @@
+#ifndef __gl2ext_h_
+#define __gl2ext_h_
+
+/* $Revision: 18481 $ on $Date:: 2012-07-11 18:07:26 -0700 #$ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+#ifndef GL_APIENTRYP
+#   define GL_APIENTRYP GL_APIENTRY*
+#endif
+
+/*------------------------------------------------------------------------*
+ * OES extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_compressed_ETC1_RGB8_texture */
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_ETC1_RGB8_OES                                        0x8D64
+#endif
+
+/* GL_OES_compressed_paletted_texture */
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_PALETTE4_RGB8_OES                                    0x8B90
+#define GL_PALETTE4_RGBA8_OES                                   0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92
+#define GL_PALETTE4_RGBA4_OES                                   0x8B93
+#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94
+#define GL_PALETTE8_RGB8_OES                                    0x8B95
+#define GL_PALETTE8_RGBA8_OES                                   0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97
+#define GL_PALETTE8_RGBA4_OES                                   0x8B98
+#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99
+#endif
+
+/* GL_OES_depth24 */
+#ifndef GL_OES_depth24
+#define GL_DEPTH_COMPONENT24_OES                                0x81A6
+#endif
+
+/* GL_OES_depth32 */
+#ifndef GL_OES_depth32
+#define GL_DEPTH_COMPONENT32_OES                                0x81A7
+#endif
+
+/* GL_OES_depth_texture */
+/* No new tokens introduced by this extension. */
+
+/* GL_OES_EGL_image */
+#ifndef GL_OES_EGL_image
+typedef void* GLeglImageOES;
+#endif
+
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
+/* GLeglImageOES defined in GL_OES_EGL_image already. */
+#define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
+#define GL_SAMPLER_EXTERNAL_OES                                 0x8D66
+#define GL_TEXTURE_BINDING_EXTERNAL_OES                         0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES                     0x8D68
+#endif
+
+/* GL_OES_element_index_uint */
+#ifndef GL_OES_element_index_uint
+#define GL_UNSIGNED_INT                                         0x1405
+#endif
+
+/* GL_OES_get_program_binary */
+#ifndef GL_OES_get_program_binary
+#define GL_PROGRAM_BINARY_LENGTH_OES                            0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS_OES                       0x87FE
+#define GL_PROGRAM_BINARY_FORMATS_OES                           0x87FF
+#endif
+
+/* GL_OES_mapbuffer */
+#ifndef GL_OES_mapbuffer
+#define GL_WRITE_ONLY_OES                                       0x88B9
+#define GL_BUFFER_ACCESS_OES                                    0x88BB
+#define GL_BUFFER_MAPPED_OES                                    0x88BC
+#define GL_BUFFER_MAP_POINTER_OES                               0x88BD
+#endif
+
+/* GL_OES_packed_depth_stencil */
+#ifndef GL_OES_packed_depth_stencil
+#define GL_DEPTH_STENCIL_OES                                    0x84F9
+#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
+#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
+#endif
+
+/* GL_OES_required_internalformat */
+/* No new tokens introduced by this extension. */
+
+/* GL_OES_rgb8_rgba8 */
+#ifndef GL_OES_rgb8_rgba8
+#define GL_RGB8_OES                                             0x8051
+#define GL_RGBA8_OES                                            0x8058
+#endif
+
+/* GL_OES_standard_derivatives */
+#ifndef GL_OES_standard_derivatives
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES                  0x8B8B
+#endif
+
+/* GL_OES_stencil1 */
+#ifndef GL_OES_stencil1
+#define GL_STENCIL_INDEX1_OES                                   0x8D46
+#endif
+
+/* GL_OES_stencil4 */
+#ifndef GL_OES_stencil4
+#define GL_STENCIL_INDEX4_OES                                   0x8D47
+#endif
+
+/* GL_OES_texture_3D */
+#ifndef GL_OES_texture_3D
+#define GL_TEXTURE_WRAP_R_OES                                   0x8072
+#define GL_TEXTURE_3D_OES                                       0x806F
+#define GL_TEXTURE_BINDING_3D_OES                               0x806A
+#define GL_MAX_3D_TEXTURE_SIZE_OES                              0x8073
+#define GL_SAMPLER_3D_OES                                       0x8B5F
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES        0x8CD4
+#endif
+
+/* GL_OES_texture_float */
+/* No new tokens introduced by this extension. */
+
+/* GL_OES_texture_float_linear */
+/* No new tokens introduced by this extension. */
+
+/* GL_OES_texture_half_float */
+#ifndef GL_OES_texture_half_float
+#define GL_HALF_FLOAT_OES                                       0x8D61
+#endif
+
+/* GL_OES_texture_half_float_linear */
+/* No new tokens introduced by this extension. */
+
+/* GL_OES_texture_npot */
+/* No new tokens introduced by this extension. */
+
+/* GL_OES_vertex_array_object */
+#ifndef GL_OES_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING_OES                             0x85B5
+#endif
+
+/* GL_OES_vertex_half_float */
+/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */
+
+/* GL_OES_vertex_type_10_10_10_2 */
+#ifndef GL_OES_vertex_type_10_10_10_2
+#define GL_UNSIGNED_INT_10_10_10_2_OES                          0x8DF6
+#define GL_INT_10_10_10_2_OES                                   0x8DF7
+#endif
+
+/*------------------------------------------------------------------------*
+ * AMD extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_AMD_compressed_3DC_texture */
+#ifndef GL_AMD_compressed_3DC_texture
+#define GL_3DC_X_AMD                                            0x87F9
+#define GL_3DC_XY_AMD                                           0x87FA
+#endif
+
+/* GL_AMD_compressed_ATC_texture */
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_ATC_RGB_AMD                                          0x8C92
+#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
+#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
+#endif
+
+/* GL_AMD_performance_monitor */
+#ifndef GL_AMD_performance_monitor
+#define GL_COUNTER_TYPE_AMD                                     0x8BC0
+#define GL_COUNTER_RANGE_AMD                                    0x8BC1
+#define GL_UNSIGNED_INT64_AMD                                   0x8BC2
+#define GL_PERCENTAGE_AMD                                       0x8BC3
+#define GL_PERFMON_RESULT_AVAILABLE_AMD                         0x8BC4
+#define GL_PERFMON_RESULT_SIZE_AMD                              0x8BC5
+#define GL_PERFMON_RESULT_AMD                                   0x8BC6
+#endif
+
+/* GL_AMD_program_binary_Z400 */
+#ifndef GL_AMD_program_binary_Z400
+#define GL_Z400_BINARY_AMD                                      0x8740
+#endif
+
+/*------------------------------------------------------------------------*
+ * ANGLE extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_ANGLE_framebuffer_blit */
+#ifndef GL_ANGLE_framebuffer_blit
+#define GL_READ_FRAMEBUFFER_ANGLE                               0x8CA8
+#define GL_DRAW_FRAMEBUFFER_ANGLE                               0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE                       0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_ANGLE                       0x8CAA
+#endif
+
+/* GL_ANGLE_framebuffer_multisample */
+#ifndef GL_ANGLE_framebuffer_multisample
+#define GL_RENDERBUFFER_SAMPLES_ANGLE                           0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE             0x8D56
+#define GL_MAX_SAMPLES_ANGLE                                    0x8D57
+#endif
+
+/* GL_ANGLE_instanced_arrays */
+#ifndef GL_ANGLE_instanced_arrays 
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE                    0x88FE
+#endif
+
+/* GL_ANGLE_pack_reverse_row_order */
+#ifndef GL_ANGLE_pack_reverse_row_order 
+#define GL_PACK_REVERSE_ROW_ORDER_ANGLE                         0x93A4
+#endif
+
+/* GL_ANGLE_texture_compression_dxt3 */
+#ifndef GL_ANGLE_texture_compression_dxt3 
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE                      0x83F2
+#endif
+
+/* GL_ANGLE_texture_compression_dxt5 */
+#ifndef GL_ANGLE_texture_compression_dxt5 
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE                      0x83F3
+#endif
+
+/* GL_ANGLE_texture_usage */
+#ifndef GL_ANGLE_texture_usage 
+#define GL_TEXTURE_USAGE_ANGLE                                  0x93A2
+#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE                         0x93A3
+#endif
+
+/* GL_ANGLE_translated_shader_source */
+#ifndef GL_ANGLE_translated_shader_source 
+#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE                0x93A0
+#endif
+
+/*------------------------------------------------------------------------*
+ * APPLE extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_APPLE_rgb_422 */
+#ifndef GL_APPLE_rgb_422
+#define GL_RGB_422_APPLE                                        0x8A1F
+#define GL_UNSIGNED_SHORT_8_8_APPLE                             0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE                         0x85BB
+#endif
+
+/* GL_APPLE_framebuffer_multisample */
+#ifndef GL_APPLE_framebuffer_multisample
+#define GL_RENDERBUFFER_SAMPLES_APPLE                           0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE             0x8D56
+#define GL_MAX_SAMPLES_APPLE                                    0x8D57
+#define GL_READ_FRAMEBUFFER_APPLE                               0x8CA8
+#define GL_DRAW_FRAMEBUFFER_APPLE                               0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE                       0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_APPLE                       0x8CAA
+#endif
+
+/* GL_APPLE_texture_format_BGRA8888 */
+#ifndef GL_APPLE_texture_format_BGRA8888
+#define GL_BGRA_EXT                                             0x80E1
+#endif
+
+/* GL_APPLE_texture_max_level */
+#ifndef GL_APPLE_texture_max_level
+#define GL_TEXTURE_MAX_LEVEL_APPLE                              0x813D
+#endif
+
+/*------------------------------------------------------------------------*
+ * ARM extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_ARM_mali_shader_binary */
+#ifndef GL_ARM_mali_shader_binary
+#define GL_MALI_SHADER_BINARY_ARM                               0x8F60
+#endif
+
+/* GL_ARM_rgba8 */
+/* No new tokens introduced by this extension. */
+
+/*------------------------------------------------------------------------*
+ * EXT extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_EXT_blend_minmax */
+#ifndef GL_EXT_blend_minmax
+#define GL_MIN_EXT                                              0x8007
+#define GL_MAX_EXT                                              0x8008
+#endif
+
+/* GL_EXT_color_buffer_half_float */
+#ifndef GL_EXT_color_buffer_half_float
+#define GL_RGBA16F_EXT                                          0x881A
+#define GL_RGB16F_EXT                                           0x881B
+#define GL_RG16F_EXT                                            0x822F
+#define GL_R16F_EXT                                             0x822D
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT            0x8211
+#define GL_UNSIGNED_NORMALIZED_EXT                              0x8C17
+#endif
+
+/* GL_EXT_debug_label */
+#ifndef GL_EXT_debug_label
+#define GL_PROGRAM_PIPELINE_OBJECT_EXT                          0x8A4F
+#define GL_PROGRAM_OBJECT_EXT                                   0x8B40
+#define GL_SHADER_OBJECT_EXT                                    0x8B48
+#define GL_BUFFER_OBJECT_EXT                                    0x9151
+#define GL_QUERY_OBJECT_EXT                                     0x9153
+#define GL_VERTEX_ARRAY_OBJECT_EXT                              0x9154
+#endif
+
+/* GL_EXT_debug_marker */
+/* No new tokens introduced by this extension. */
+
+/* GL_EXT_discard_framebuffer */
+#ifndef GL_EXT_discard_framebuffer
+#define GL_COLOR_EXT                                            0x1800
+#define GL_DEPTH_EXT                                            0x1801
+#define GL_STENCIL_EXT                                          0x1802
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT           0x8D6C
+/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ 
+#define GL_RENDERBUFFER_SAMPLES_EXT                             0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT               0x8D56
+#define GL_MAX_SAMPLES_EXT                                      0x8D57
+#endif
+
+/* GL_EXT_multi_draw_arrays */
+/* No new tokens introduced by this extension. */
+
+/* GL_EXT_occlusion_query_boolean */
+#ifndef GL_EXT_occlusion_query_boolean
+#define GL_ANY_SAMPLES_PASSED_EXT                               0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT                  0x8D6A
+#define GL_CURRENT_QUERY_EXT                                    0x8865
+#define GL_QUERY_RESULT_EXT                                     0x8866
+#define GL_QUERY_RESULT_AVAILABLE_EXT                           0x8867
+#endif
+
+/* GL_EXT_read_format_bgra */
+#ifndef GL_EXT_read_format_bgra
+#define GL_BGRA_EXT                                             0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT                       0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT                       0x8366
+#endif
+
+/* GL_EXT_robustness */
+#ifndef GL_EXT_robustness
+/* reuse GL_NO_ERROR */
+#define GL_GUILTY_CONTEXT_RESET_EXT                             0x8253
+#define GL_INNOCENT_CONTEXT_RESET_EXT                           0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_EXT                            0x8255
+#define GL_CONTEXT_ROBUST_ACCESS_EXT                            0x90F3
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT                      0x8256
+#define GL_LOSE_CONTEXT_ON_RESET_EXT                            0x8252
+#define GL_NO_RESET_NOTIFICATION_EXT                            0x8261
+#endif
+
+/* GL_EXT_separate_shader_objects */
+#ifndef GL_EXT_separate_shader_objects
+#define GL_VERTEX_SHADER_BIT_EXT                                0x00000001
+#define GL_FRAGMENT_SHADER_BIT_EXT                              0x00000002
+#define GL_ALL_SHADER_BITS_EXT                                  0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE_EXT                                0x8258
+#define GL_ACTIVE_PROGRAM_EXT                                   0x8259
+#define GL_PROGRAM_PIPELINE_BINDING_EXT                         0x825A
+#endif
+
+/* GL_EXT_shader_texture_lod */
+/* No new tokens introduced by this extension. */
+
+/* GL_EXT_shadow_samplers */
+#ifndef GL_EXT_shadow_samplers
+#define GL_TEXTURE_COMPARE_MODE_EXT                             0x884C
+#define GL_TEXTURE_COMPARE_FUNC_EXT                             0x884D
+#define GL_COMPARE_REF_TO_TEXTURE_EXT                           0x884E
+#define GL_SAMPLER_2D_SHADOW_EXT                                0x8B62
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_SRGB_EXT                                             0x8C40
+#define GL_SRGB_ALPHA_EXT                                       0x8C42
+#define GL_SRGB8_ALPHA8_EXT                                     0x8C43
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT            0x8210
+#endif
+
+/* GL_EXT_texture_compression_dxt1 */
+#ifndef GL_EXT_texture_compression_dxt1
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT                         0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT                        0x83F1
+#endif
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF
+#endif
+
+/* GL_EXT_texture_format_BGRA8888 */
+#ifndef GL_EXT_texture_format_BGRA8888
+#define GL_BGRA_EXT                                             0x80E1
+#endif
+
+/* GL_EXT_texture_rg */
+#ifndef GL_EXT_texture_rg
+#define GL_RED_EXT                                              0x1903
+#define GL_RG_EXT                                               0x8227
+#define GL_R8_EXT                                               0x8229
+#define GL_RG8_EXT                                              0x822B
+#endif
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT                         0x912F
+#define GL_ALPHA8_EXT                                           0x803C  
+#define GL_LUMINANCE8_EXT                                       0x8040
+#define GL_LUMINANCE8_ALPHA8_EXT                                0x8045
+#define GL_RGBA32F_EXT                                          0x8814  
+#define GL_RGB32F_EXT                                           0x8815
+#define GL_ALPHA32F_EXT                                         0x8816
+#define GL_LUMINANCE32F_EXT                                     0x8818
+#define GL_LUMINANCE_ALPHA32F_EXT                               0x8819
+/* reuse GL_RGBA16F_EXT */
+/* reuse GL_RGB16F_EXT */
+#define GL_ALPHA16F_EXT                                         0x881C
+#define GL_LUMINANCE16F_EXT                                     0x881E
+#define GL_LUMINANCE_ALPHA16F_EXT                               0x881F
+#define GL_RGB10_A2_EXT                                         0x8059  
+#define GL_RGB10_EXT                                            0x8052
+#define GL_BGRA8_EXT                                            0x93A1
+#define GL_R8_EXT                                               0x8229
+#define GL_RG8_EXT                                              0x822B
+#define GL_R32F_EXT                                             0x822E  
+#define GL_RG32F_EXT                                            0x8230
+#define GL_R16F_EXT                                             0x822D
+#define GL_RG16F_EXT                                            0x822F
+#endif
+
+/* GL_EXT_texture_type_2_10_10_10_REV */
+#ifndef GL_EXT_texture_type_2_10_10_10_REV
+#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT                      0x8368
+#endif
+
+/* GL_EXT_unpack_subimage */
+#ifndef GL_EXT_unpack_subimage
+#define GL_UNPACK_ROW_LENGTH                                    0x0CF2
+#define GL_UNPACK_SKIP_ROWS                                     0x0CF3
+#define GL_UNPACK_SKIP_PIXELS                                   0x0CF4
+#endif
+
+/*------------------------------------------------------------------------*
+ * DMP extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_DMP_shader_binary */
+#ifndef GL_DMP_shader_binary
+#define GL_SHADER_BINARY_DMP                                    0x9250
+#endif
+
+/*------------------------------------------------------------------------*
+ * FJ extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_FJ_shader_binary_GCCSO */
+#ifndef GL_FJ_shader_binary_GCCSO
+#define GCCSO_SHADER_BINARY_FJ                                  0x9260
+#endif
+
+/*------------------------------------------------------------------------*
+ * IMG extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_IMG_program_binary */
+#ifndef GL_IMG_program_binary
+#define GL_SGX_PROGRAM_BINARY_IMG                               0x9130
+#endif
+
+/* GL_IMG_read_format */
+#ifndef GL_IMG_read_format
+#define GL_BGRA_IMG                                             0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG                       0x8365
+#endif
+
+/* GL_IMG_shader_binary */
+#ifndef GL_IMG_shader_binary
+#define GL_SGX_BINARY_IMG                                       0x8C0A
+#endif
+
+/* GL_IMG_texture_compression_pvrtc */
+#ifndef GL_IMG_texture_compression_pvrtc
+#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
+#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
+#endif
+
+/* GL_IMG_multisampled_render_to_texture */
+#ifndef GL_IMG_multisampled_render_to_texture
+#define GL_RENDERBUFFER_SAMPLES_IMG                             0x9133
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG               0x9134
+#define GL_MAX_SAMPLES_IMG                                      0x9135
+#define GL_TEXTURE_SAMPLES_IMG                                  0x9136
+#endif
+
+/*------------------------------------------------------------------------*
+ * NV extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_NV_coverage_sample */
+#ifndef GL_NV_coverage_sample
+#define GL_COVERAGE_COMPONENT_NV                                0x8ED0
+#define GL_COVERAGE_COMPONENT4_NV                               0x8ED1
+#define GL_COVERAGE_ATTACHMENT_NV                               0x8ED2
+#define GL_COVERAGE_BUFFERS_NV                                  0x8ED3
+#define GL_COVERAGE_SAMPLES_NV                                  0x8ED4
+#define GL_COVERAGE_ALL_FRAGMENTS_NV                            0x8ED5
+#define GL_COVERAGE_EDGE_FRAGMENTS_NV                           0x8ED6
+#define GL_COVERAGE_AUTOMATIC_NV                                0x8ED7
+#define GL_COVERAGE_BUFFER_BIT_NV                               0x8000
+#endif
+
+/* GL_NV_depth_nonlinear */
+#ifndef GL_NV_depth_nonlinear
+#define GL_DEPTH_COMPONENT16_NONLINEAR_NV                       0x8E2C
+#endif
+
+/* GL_NV_draw_buffers */
+#ifndef GL_NV_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_NV                                  0x8824
+#define GL_DRAW_BUFFER0_NV                                      0x8825
+#define GL_DRAW_BUFFER1_NV                                      0x8826
+#define GL_DRAW_BUFFER2_NV                                      0x8827
+#define GL_DRAW_BUFFER3_NV                                      0x8828
+#define GL_DRAW_BUFFER4_NV                                      0x8829
+#define GL_DRAW_BUFFER5_NV                                      0x882A
+#define GL_DRAW_BUFFER6_NV                                      0x882B
+#define GL_DRAW_BUFFER7_NV                                      0x882C
+#define GL_DRAW_BUFFER8_NV                                      0x882D
+#define GL_DRAW_BUFFER9_NV                                      0x882E
+#define GL_DRAW_BUFFER10_NV                                     0x882F
+#define GL_DRAW_BUFFER11_NV                                     0x8830
+#define GL_DRAW_BUFFER12_NV                                     0x8831
+#define GL_DRAW_BUFFER13_NV                                     0x8832
+#define GL_DRAW_BUFFER14_NV                                     0x8833
+#define GL_DRAW_BUFFER15_NV                                     0x8834
+#define GL_COLOR_ATTACHMENT0_NV                                 0x8CE0
+#define GL_COLOR_ATTACHMENT1_NV                                 0x8CE1
+#define GL_COLOR_ATTACHMENT2_NV                                 0x8CE2
+#define GL_COLOR_ATTACHMENT3_NV                                 0x8CE3
+#define GL_COLOR_ATTACHMENT4_NV                                 0x8CE4
+#define GL_COLOR_ATTACHMENT5_NV                                 0x8CE5
+#define GL_COLOR_ATTACHMENT6_NV                                 0x8CE6
+#define GL_COLOR_ATTACHMENT7_NV                                 0x8CE7
+#define GL_COLOR_ATTACHMENT8_NV                                 0x8CE8
+#define GL_COLOR_ATTACHMENT9_NV                                 0x8CE9
+#define GL_COLOR_ATTACHMENT10_NV                                0x8CEA
+#define GL_COLOR_ATTACHMENT11_NV                                0x8CEB
+#define GL_COLOR_ATTACHMENT12_NV                                0x8CEC
+#define GL_COLOR_ATTACHMENT13_NV                                0x8CED
+#define GL_COLOR_ATTACHMENT14_NV                                0x8CEE
+#define GL_COLOR_ATTACHMENT15_NV                                0x8CEF
+#endif
+
+/* GL_NV_fbo_color_attachments */
+#ifndef GL_NV_fbo_color_attachments
+#define GL_MAX_COLOR_ATTACHMENTS_NV                             0x8CDF
+/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */
+#endif
+
+/* GL_NV_fence */
+#ifndef GL_NV_fence
+#define GL_ALL_COMPLETED_NV                                     0x84F2
+#define GL_FENCE_STATUS_NV                                      0x84F3
+#define GL_FENCE_CONDITION_NV                                   0x84F4
+#endif
+
+/* GL_NV_read_buffer */
+#ifndef GL_NV_read_buffer
+#define GL_READ_BUFFER_NV                                       0x0C02
+#endif
+
+/* GL_NV_read_buffer_front */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_read_depth */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_read_depth_stencil */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_read_stencil */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_texture_compression_s3tc_update */
+/* No new tokens introduced by this extension. */
+
+/* GL_NV_texture_npot_2D_mipmap */
+/* No new tokens introduced by this extension. */
+
+/*------------------------------------------------------------------------*
+ * QCOM extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_QCOM_alpha_test */
+#ifndef GL_QCOM_alpha_test
+#define GL_ALPHA_TEST_QCOM                                      0x0BC0
+#define GL_ALPHA_TEST_FUNC_QCOM                                 0x0BC1
+#define GL_ALPHA_TEST_REF_QCOM                                  0x0BC2
+#endif
+
+/* GL_QCOM_driver_control */
+/* No new tokens introduced by this extension. */
+
+/* GL_QCOM_extended_get */
+#ifndef GL_QCOM_extended_get
+#define GL_TEXTURE_WIDTH_QCOM                                   0x8BD2
+#define GL_TEXTURE_HEIGHT_QCOM                                  0x8BD3
+#define GL_TEXTURE_DEPTH_QCOM                                   0x8BD4
+#define GL_TEXTURE_INTERNAL_FORMAT_QCOM                         0x8BD5
+#define GL_TEXTURE_FORMAT_QCOM                                  0x8BD6
+#define GL_TEXTURE_TYPE_QCOM                                    0x8BD7
+#define GL_TEXTURE_IMAGE_VALID_QCOM                             0x8BD8
+#define GL_TEXTURE_NUM_LEVELS_QCOM                              0x8BD9
+#define GL_TEXTURE_TARGET_QCOM                                  0x8BDA
+#define GL_TEXTURE_OBJECT_VALID_QCOM                            0x8BDB
+#define GL_STATE_RESTORE                                        0x8BDC
+#endif
+
+/* GL_QCOM_extended_get2 */
+/* No new tokens introduced by this extension. */
+
+/* GL_QCOM_perfmon_global_mode */
+#ifndef GL_QCOM_perfmon_global_mode
+#define GL_PERFMON_GLOBAL_MODE_QCOM                             0x8FA0
+#endif
+
+/* GL_QCOM_writeonly_rendering */
+#ifndef GL_QCOM_writeonly_rendering
+#define GL_WRITEONLY_RENDERING_QCOM                             0x8823
+#endif
+
+/* GL_QCOM_tiled_rendering */
+#ifndef GL_QCOM_tiled_rendering
+#define GL_COLOR_BUFFER_BIT0_QCOM                               0x00000001
+#define GL_COLOR_BUFFER_BIT1_QCOM                               0x00000002
+#define GL_COLOR_BUFFER_BIT2_QCOM                               0x00000004
+#define GL_COLOR_BUFFER_BIT3_QCOM                               0x00000008
+#define GL_COLOR_BUFFER_BIT4_QCOM                               0x00000010
+#define GL_COLOR_BUFFER_BIT5_QCOM                               0x00000020
+#define GL_COLOR_BUFFER_BIT6_QCOM                               0x00000040
+#define GL_COLOR_BUFFER_BIT7_QCOM                               0x00000080
+#define GL_DEPTH_BUFFER_BIT0_QCOM                               0x00000100
+#define GL_DEPTH_BUFFER_BIT1_QCOM                               0x00000200
+#define GL_DEPTH_BUFFER_BIT2_QCOM                               0x00000400
+#define GL_DEPTH_BUFFER_BIT3_QCOM                               0x00000800
+#define GL_DEPTH_BUFFER_BIT4_QCOM                               0x00001000
+#define GL_DEPTH_BUFFER_BIT5_QCOM                               0x00002000
+#define GL_DEPTH_BUFFER_BIT6_QCOM                               0x00004000
+#define GL_DEPTH_BUFFER_BIT7_QCOM                               0x00008000
+#define GL_STENCIL_BUFFER_BIT0_QCOM                             0x00010000
+#define GL_STENCIL_BUFFER_BIT1_QCOM                             0x00020000
+#define GL_STENCIL_BUFFER_BIT2_QCOM                             0x00040000
+#define GL_STENCIL_BUFFER_BIT3_QCOM                             0x00080000
+#define GL_STENCIL_BUFFER_BIT4_QCOM                             0x00100000
+#define GL_STENCIL_BUFFER_BIT5_QCOM                             0x00200000
+#define GL_STENCIL_BUFFER_BIT6_QCOM                             0x00400000
+#define GL_STENCIL_BUFFER_BIT7_QCOM                             0x00800000
+#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM                         0x01000000
+#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM                         0x02000000
+#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM                         0x04000000
+#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM                         0x08000000
+#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM                         0x10000000
+#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM                         0x20000000
+#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM                         0x40000000
+#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM                         0x80000000
+#endif
+
+/*------------------------------------------------------------------------*
+ * VIV extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_VIV_shader_binary */
+#ifndef GL_VIV_shader_binary
+#define GL_SHADER_BINARY_VIV                                    0x8FC4
+#endif
+
+/*------------------------------------------------------------------------*
+ * End of extension tokens, start of corresponding extension functions
+ *------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*
+ * OES extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_compressed_ETC1_RGB8_texture */
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_OES_compressed_ETC1_RGB8_texture 1
+#endif
+
+/* GL_OES_compressed_paletted_texture */
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_OES_compressed_paletted_texture 1
+#endif
+
+/* GL_OES_depth24 */
+#ifndef GL_OES_depth24
+#define GL_OES_depth24 1
+#endif
+
+/* GL_OES_depth32 */
+#ifndef GL_OES_depth32
+#define GL_OES_depth32 1
+#endif
+
+/* GL_OES_depth_texture */
+#ifndef GL_OES_depth_texture
+#define GL_OES_depth_texture 1
+#endif
+
+/* GL_OES_EGL_image */
+#ifndef GL_OES_EGL_image
+#define GL_OES_EGL_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
+#endif
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
+#endif
+
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
+#define GL_OES_EGL_image_external 1
+/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */
+#endif
+
+/* GL_OES_element_index_uint */
+#ifndef GL_OES_element_index_uint
+#define GL_OES_element_index_uint 1
+#endif
+
+/* GL_OES_fbo_render_mipmap */
+#ifndef GL_OES_fbo_render_mipmap
+#define GL_OES_fbo_render_mipmap 1
+#endif
+
+/* GL_OES_fragment_precision_high */
+#ifndef GL_OES_fragment_precision_high
+#define GL_OES_fragment_precision_high 1
+#endif
+
+/* GL_OES_get_program_binary */
+#ifndef GL_OES_get_program_binary
+#define GL_OES_get_program_binary 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
+#endif
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
+#endif
+
+/* GL_OES_mapbuffer */
+#ifndef GL_OES_mapbuffer
+#define GL_OES_mapbuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
+GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
+GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params);
+#endif
+typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
+typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params);
+#endif
+
+/* GL_OES_packed_depth_stencil */
+#ifndef GL_OES_packed_depth_stencil
+#define GL_OES_packed_depth_stencil 1
+#endif
+
+/* GL_OES_required_internalformat */
+#ifndef GL_OES_required_internalformat
+#define GL_OES_required_internalformat 1
+#endif
+
+/* GL_OES_rgb8_rgba8 */
+#ifndef GL_OES_rgb8_rgba8
+#define GL_OES_rgb8_rgba8 1
+#endif
+
+/* GL_OES_standard_derivatives */
+#ifndef GL_OES_standard_derivatives
+#define GL_OES_standard_derivatives 1
+#endif
+
+/* GL_OES_stencil1 */
+#ifndef GL_OES_stencil1
+#define GL_OES_stencil1 1
+#endif
+
+/* GL_OES_stencil4 */
+#ifndef GL_OES_stencil4
+#define GL_OES_stencil4 1
+#endif
+
+/* GL_OES_texture_3D */
+#ifndef GL_OES_texture_3D
+#define GL_OES_texture_3D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+#endif
+typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
+typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+#endif
+
+/* GL_OES_texture_float */
+#ifndef GL_OES_texture_float
+#define GL_OES_texture_float 1
+#endif
+
+/* GL_OES_texture_float_linear */
+#ifndef GL_OES_texture_float_linear
+#define GL_OES_texture_float_linear 1
+#endif
+
+/* GL_OES_texture_half_float */
+#ifndef GL_OES_texture_half_float
+#define GL_OES_texture_half_float 1
+#endif
+
+/* GL_OES_texture_half_float_linear */
+#ifndef GL_OES_texture_half_float_linear
+#define GL_OES_texture_half_float_linear 1
+#endif
+
+/* GL_OES_texture_npot */
+#ifndef GL_OES_texture_npot
+#define GL_OES_texture_npot 1
+#endif
+
+/* GL_OES_vertex_array_object */
+#ifndef GL_OES_vertex_array_object
+#define GL_OES_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array);
+GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);
+GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);
+GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);
+#endif
+typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
+typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
+typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
+#endif
+
+/* GL_OES_vertex_half_float */
+#ifndef GL_OES_vertex_half_float
+#define GL_OES_vertex_half_float 1
+#endif
+
+/* GL_OES_vertex_type_10_10_10_2 */
+#ifndef GL_OES_vertex_type_10_10_10_2
+#define GL_OES_vertex_type_10_10_10_2 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * AMD extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_AMD_compressed_3DC_texture */
+#ifndef GL_AMD_compressed_3DC_texture
+#define GL_AMD_compressed_3DC_texture 1
+#endif
+
+/* GL_AMD_compressed_ATC_texture */
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_AMD_compressed_ATC_texture 1
+#endif
+
+/* AMD_performance_monitor */
+#ifndef GL_AMD_performance_monitor
+#define GL_AMD_performance_monitor 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
+GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
+GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
+GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
+GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor);
+GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+#endif
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
+typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+#endif
+
+/* GL_AMD_program_binary_Z400 */
+#ifndef GL_AMD_program_binary_Z400
+#define GL_AMD_program_binary_Z400 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * ANGLE extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_ANGLE_framebuffer_blit */
+#ifndef GL_ANGLE_framebuffer_blit
+#define GL_ANGLE_framebuffer_blit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
+/* GL_ANGLE_framebuffer_multisample */
+#ifndef GL_ANGLE_framebuffer_multisample
+#define GL_ANGLE_framebuffer_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_ANGLE_instanced_arrays 
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
+#endif
+typedef void (GL_APIENTRYP PFLGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFLGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+typedef void (GL_APIENTRYP PFLGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
+#endif
+
+/* GL_ANGLE_pack_reverse_row_order */
+#ifndef GL_ANGLE_pack_reverse_row_order 
+#define GL_ANGLE_pack_reverse_row_order 1
+#endif
+
+/* GL_ANGLE_texture_compression_dxt3 */
+#ifndef GL_ANGLE_texture_compression_dxt3 
+#define GL_ANGLE_texture_compression_dxt3 1
+#endif
+
+/* GL_ANGLE_texture_compression_dxt5 */
+#ifndef GL_ANGLE_texture_compression_dxt5 
+#define GL_ANGLE_texture_compression_dxt5 1
+#endif
+
+/* GL_ANGLE_texture_usage */
+#ifndef GL_ANGLE_texture_usage 
+#define GL_ANGLE_texture_usage 1
+#endif
+
+#ifndef GL_ANGLE_translated_shader_source 
+#define GL_ANGLE_translated_shader_source 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
+#endif
+typedef void (GL_APIENTRYP PFLGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
+#endif
+
+/*------------------------------------------------------------------------*
+ * APPLE extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_APPLE_rgb_422 */
+#ifndef GL_APPLE_rgb_422
+#define GL_APPLE_rgb_422 1
+#endif
+
+/* GL_APPLE_framebuffer_multisample */
+#ifndef GL_APPLE_framebuffer_multisample
+#define GL_APPLE_framebuffer_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
+#endif
+
+/* GL_APPLE_texture_format_BGRA8888 */
+#ifndef GL_APPLE_texture_format_BGRA8888
+#define GL_APPLE_texture_format_BGRA8888 1
+#endif
+
+/* GL_APPLE_texture_max_level */
+#ifndef GL_APPLE_texture_max_level
+#define GL_APPLE_texture_max_level 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * ARM extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_ARM_mali_shader_binary */
+#ifndef GL_ARM_mali_shader_binary
+#define GL_ARM_mali_shader_binary 1
+#endif
+
+/* GL_ARM_rgba8 */
+#ifndef GL_ARM_rgba8
+#define GL_ARM_rgba8 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * EXT extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_EXT_blend_minmax */
+#ifndef GL_EXT_blend_minmax
+#define GL_EXT_blend_minmax 1
+#endif
+
+/* GL_EXT_color_buffer_half_float */
+#ifndef GL_EXT_color_buffer_half_float
+#define GL_EXT_color_buffer_half_float 1
+#endif
+
+/* GL_EXT_debug_label */
+#ifndef GL_EXT_debug_label
+#define GL_EXT_debug_label 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif
+typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
+#endif
+
+/* GL_EXT_debug_marker */
+#ifndef GL_EXT_debug_marker
+#define GL_EXT_debug_marker 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker);
+GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker);
+GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void);
+#endif
+typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);
+#endif
+
+/* GL_EXT_discard_framebuffer */
+#ifndef GL_EXT_discard_framebuffer
+#define GL_EXT_discard_framebuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+#endif
+typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+#endif
+
+/* GL_EXT_multisampled_render_to_texture */
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_EXT_multisampled_render_to_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+#endif
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
+GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif
+
+/* GL_EXT_occlusion_query_boolean */
+#ifndef GL_EXT_occlusion_query_boolean
+#define GL_EXT_occlusion_query_boolean 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids);
+GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids);
+GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id);
+GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id);
+GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target);
+GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params);
+#endif
+typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
+typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
+typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
+typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+/* GL_EXT_read_format_bgra */
+#ifndef GL_EXT_read_format_bgra
+#define GL_EXT_read_format_bgra 1
+#endif
+
+/* GL_EXT_robustness */
+#ifndef GL_EXT_robustness
+#define GL_EXT_robustness 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void);
+GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params);
+GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
+#endif
+
+/* GL_EXT_separate_shader_objects */
+#ifndef GL_EXT_separate_shader_objects
+#define GL_EXT_separate_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program);
+GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program);
+GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings);
+GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines);
+GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x);
+GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y);
+GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z);
+GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x);
+GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif
+typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
+typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program);
+typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings);
+typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines);
+typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines);
+typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+#endif
+
+/* GL_EXT_shader_texture_lod */
+#ifndef GL_EXT_shader_texture_lod
+#define GL_EXT_shader_texture_lod 1
+#endif
+
+/* GL_EXT_shadow_samplers */
+#ifndef GL_EXT_shadow_samplers
+#define GL_EXT_shadow_samplers 1
+#endif
+
+/* GL_EXT_sRGB */
+#ifndef GL_EXT_sRGB
+#define GL_EXT_sRGB 1
+#endif
+
+/* GL_EXT_texture_compression_dxt1 */
+#ifndef GL_EXT_texture_compression_dxt1
+#define GL_EXT_texture_compression_dxt1 1
+#endif
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#endif
+
+/* GL_EXT_texture_format_BGRA8888 */
+#ifndef GL_EXT_texture_format_BGRA8888
+#define GL_EXT_texture_format_BGRA8888 1
+#endif
+
+/* GL_EXT_texture_rg */
+#ifndef GL_EXT_texture_rg
+#define GL_EXT_texture_rg 1
+#endif
+
+/* GL_EXT_texture_storage */
+#ifndef GL_EXT_texture_storage
+#define GL_EXT_texture_storage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+#endif
+
+/* GL_EXT_texture_type_2_10_10_10_REV */
+#ifndef GL_EXT_texture_type_2_10_10_10_REV
+#define GL_EXT_texture_type_2_10_10_10_REV 1
+#endif
+
+/* GL_EXT_unpack_subimage */
+#ifndef GL_EXT_unpack_subimage
+#define GL_EXT_unpack_subimage 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * DMP extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_DMP_shader_binary */
+#ifndef GL_DMP_shader_binary
+#define GL_DMP_shader_binary 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * FJ extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_FJ_shader_binary_GCCSO */
+#ifndef GL_FJ_shader_binary_GCCSO
+#define GL_FJ_shader_binary_GCCSO 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * IMG extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_IMG_program_binary */
+#ifndef GL_IMG_program_binary
+#define GL_IMG_program_binary 1
+#endif
+
+/* GL_IMG_read_format */
+#ifndef GL_IMG_read_format
+#define GL_IMG_read_format 1
+#endif
+
+/* GL_IMG_shader_binary */
+#ifndef GL_IMG_shader_binary
+#define GL_IMG_shader_binary 1
+#endif
+
+/* GL_IMG_texture_compression_pvrtc */
+#ifndef GL_IMG_texture_compression_pvrtc
+#define GL_IMG_texture_compression_pvrtc 1
+#endif
+
+/* GL_IMG_multisampled_render_to_texture */
+#ifndef GL_IMG_multisampled_render_to_texture
+#define GL_IMG_multisampled_render_to_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
+#endif
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+
+/*------------------------------------------------------------------------*
+ * NV extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_NV_coverage_sample */
+#ifndef GL_NV_coverage_sample
+#define GL_NV_coverage_sample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);
+GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);
+#endif
+typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
+typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
+#endif
+
+/* GL_NV_depth_nonlinear */
+#ifndef GL_NV_depth_nonlinear
+#define GL_NV_depth_nonlinear 1
+#endif
+
+/* GL_NV_draw_buffers */
+#ifndef GL_NV_draw_buffers
+#define GL_NV_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
+#endif
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+/* GL_NV_fbo_color_attachments */
+#ifndef GL_NV_fbo_color_attachments
+#define GL_NV_fbo_color_attachments 1
+#endif
+
+/* GL_NV_fence */
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
+GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
+GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint);
+GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint);
+GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
+GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint);
+GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
+#endif
+typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
+typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
+typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
+typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
+typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
+typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#endif
+
+/* GL_NV_read_buffer */
+#ifndef GL_NV_read_buffer
+#define GL_NV_read_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);
+#endif
+typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
+#endif
+
+/* GL_NV_read_buffer_front */
+#ifndef GL_NV_read_buffer_front
+#define GL_NV_read_buffer_front 1
+#endif
+
+/* GL_NV_read_depth */
+#ifndef GL_NV_read_depth
+#define GL_NV_read_depth 1
+#endif
+
+/* GL_NV_read_depth_stencil */
+#ifndef GL_NV_read_depth_stencil
+#define GL_NV_read_depth_stencil 1
+#endif
+
+/* GL_NV_read_stencil */
+#ifndef GL_NV_read_stencil
+#define GL_NV_read_stencil 1
+#endif
+
+/* GL_NV_texture_compression_s3tc_update */
+#ifndef GL_NV_texture_compression_s3tc_update
+#define GL_NV_texture_compression_s3tc_update 1
+#endif
+
+/* GL_NV_texture_npot_2D_mipmap */
+#ifndef GL_NV_texture_npot_2D_mipmap
+#define GL_NV_texture_npot_2D_mipmap 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * QCOM extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_QCOM_alpha_test */
+#ifndef GL_QCOM_alpha_test
+#define GL_QCOM_alpha_test 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
+#endif
+typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
+#endif
+
+/* GL_QCOM_driver_control */
+#ifndef GL_QCOM_driver_control
+#define GL_QCOM_driver_control 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
+GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
+GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
+GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
+#endif
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
+typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
+typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
+#endif
+
+/* GL_QCOM_extended_get */
+#ifndef GL_QCOM_extended_get
+#define GL_QCOM_extended_get 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);
+GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
+GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
+GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
+GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
+GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);
+#endif
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);
+#endif
+
+/* GL_QCOM_extended_get2 */
+#ifndef GL_QCOM_extended_get2
+#define GL_QCOM_extended_get2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);
+GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
+GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);
+GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
+#endif
+typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
+typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
+#endif
+
+/* GL_QCOM_perfmon_global_mode */
+#ifndef GL_QCOM_perfmon_global_mode
+#define GL_QCOM_perfmon_global_mode 1
+#endif
+
+/* GL_QCOM_writeonly_rendering */
+#ifndef GL_QCOM_writeonly_rendering
+#define GL_QCOM_writeonly_rendering 1
+#endif
+
+/* GL_QCOM_tiled_rendering */
+#ifndef GL_QCOM_tiled_rendering
+#define GL_QCOM_tiled_rendering 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);
+#endif
+typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
+#endif
+
+/*------------------------------------------------------------------------*
+ * VIV extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_VIV_shader_binary */
+#ifndef GL_VIV_shader_binary
+#define GL_VIV_shader_binary 1
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl2ext_h_ */
diff --git a/thirdparty/khronos/GLES2/gl2platform.h b/thirdparty/khronos/GLES2/gl2platform.h
new file mode 100644 (file)
index 0000000..c9fa3c4
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __gl2platform_h_
+#define __gl2platform_h_
+
+/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/* Platform-specific types and definitions for OpenGL ES 2.X  gl2.h
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product "OpenGL-ES" component "Registry".
+ */
+
+#include <KHR/khrplatform.h>
+
+#ifndef GL_APICALL
+#define GL_APICALL  KHRONOS_APICALL
+#endif
+
+#ifndef GL_APIENTRY
+#define GL_APIENTRY KHRONOS_APIENTRY
+#endif
+
+#endif /* __gl2platform_h_ */
diff --git a/thirdparty/khronos/KHR/khrplatform.h b/thirdparty/khronos/KHR/khrplatform.h
new file mode 100644 (file)
index 0000000..8ec0d19
--- /dev/null
@@ -0,0 +1,269 @@
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Khronos platform-specific types and definitions.
+ *
+ * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
+ *
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by sending them to the public Khronos Bugzilla
+ * (http://khronos.org/bugzilla) by filing a bug against product
+ * "Khronos (general)" component "Registry".
+ *
+ * A predefined template which fills in some of the bug fields can be
+ * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
+ * must create a Bugzilla login first.
+ *
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system and for more details of its use:
+ *    http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * This file should be included as
+ *        #include <KHR/khrplatform.h>
+ * by Khronos client API header files that use its types and defines.
+ *
+ * The types in khrplatform.h should only be used to define API-specific types.
+ *
+ * Types defined in khrplatform.h:
+ *    khronos_int8_t              signed   8  bit
+ *    khronos_uint8_t             unsigned 8  bit
+ *    khronos_int16_t             signed   16 bit
+ *    khronos_uint16_t            unsigned 16 bit
+ *    khronos_int32_t             signed   32 bit
+ *    khronos_uint32_t            unsigned 32 bit
+ *    khronos_int64_t             signed   64 bit
+ *    khronos_uint64_t            unsigned 64 bit
+ *    khronos_intptr_t            signed   same number of bits as a pointer
+ *    khronos_uintptr_t           unsigned same number of bits as a pointer
+ *    khronos_ssize_t             signed   size
+ *    khronos_usize_t             unsigned size
+ *    khronos_float_t             signed   32 bit floating point
+ *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
+ *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ *                                         nanoseconds
+ *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ *    khronos_boolean_enum_t      enumerated boolean type. This should
+ *      only be used as a base type when a client API's boolean type is
+ *      an enum. Client APIs which use an integer or other type for
+ *      booleans cannot use this as the base type for their boolean.
+ *
+ * Tokens defined in khrplatform.h:
+ *
+ *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
+ *
+ *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ *
+ * Calling convention macros defined in this file:
+ *    KHRONOS_APICALL
+ *    KHRONOS_APIENTRY
+ *    KHRONOS_APIATTRIBUTES
+ *
+ * These may be used in function prototypes as:
+ *
+ *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
+ *                                  int arg1,
+ *                                  int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
+#   define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+#   define KHRONOS_APICALL IMPORT_C
+#else
+#   define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIENTRY
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function  and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
+    /* Win32 but not WinCE */
+#   define KHRONOS_APIENTRY __stdcall
+#else
+#   define KHRONOS_APIENTRY
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using <stdint.h>
+ */
+#include <stdint.h>
+typedef int32_t                 khronos_int32_t;
+typedef uint32_t                khronos_uint32_t;
+typedef int64_t                 khronos_int64_t;
+typedef uint64_t                khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using <inttypes.h>
+ */
+#include <inttypes.h>
+typedef int32_t                 khronos_int32_t;
+typedef uint32_t                khronos_uint32_t;
+typedef int64_t                 khronos_int64_t;
+typedef uint64_t                khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32                 khronos_int32_t;
+typedef unsigned __int32        khronos_uint32_t;
+typedef __int64                 khronos_int64_t;
+typedef unsigned __int64        khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int                     khronos_int32_t;
+typedef unsigned int            khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int                khronos_int64_t;
+typedef unsigned long int       khronos_uint64_t;
+#else
+typedef long long int           khronos_int64_t;
+typedef unsigned long long int  khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int                     khronos_int32_t;
+typedef unsigned int            khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64   0
+#define KHRONOS_SUPPORT_FLOAT   0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include <stdint.h>
+typedef int32_t                 khronos_int32_t;
+typedef uint32_t                khronos_uint32_t;
+typedef int64_t                 khronos_int64_t;
+typedef uint64_t                khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed   char          khronos_int8_t;
+typedef unsigned char          khronos_uint8_t;
+typedef signed   short int     khronos_int16_t;
+typedef unsigned short int     khronos_uint16_t;
+typedef signed   long  int     khronos_intptr_t;
+typedef unsigned long  int     khronos_uintptr_t;
+typedef signed   long  int     khronos_ssize_t;
+typedef unsigned long  int     khronos_usize_t;
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef          float         khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or
+ * an absolute Unadjusted System Time.  Unadjusted System Time is the number
+ * of nanoseconds since some arbitrary system event (e.g. since the last
+ * time the system booted).  The Unadjusted System Time is an unsigned
+ * 64 bit value that wraps back to 0 every 584 years.  Time intervals
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t       khronos_utime_nanoseconds_t;
+typedef khronos_int64_t        khronos_stime_nanoseconds_t;
+#endif
+
+/*
+ * Dummy value used to pad enum types to 32 bits.
+ */
+#ifndef KHRONOS_MAX_ENUM
+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
+#endif
+
+/*
+ * Enumerated boolean type
+ *
+ * Values other than zero should be considered to be true.  Therefore
+ * comparisons should not be made against KHRONOS_TRUE.
+ */
+typedef enum {
+    KHRONOS_FALSE = 0,
+    KHRONOS_TRUE  = 1,
+    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
+} khronos_boolean_enum_t;
+
+#endif /* __khrplatform_h_ */
diff --git a/thirdparty/khronos/Makefile b/thirdparty/khronos/Makefile
new file mode 100644 (file)
index 0000000..9240ca8
--- /dev/null
@@ -0,0 +1,42 @@
+update: \
+       GL/glext.h \
+       GL/glxext.h \
+       GL/wglext.h \
+       EGL/egl.h \
+       EGL/eglext.h \
+       EGL/eglplatform.h \
+       KHR/khrplatform.h \
+       GLES/gl.h \
+       GLES/glext.h \
+       GLES/glplatform.h \
+       GLES2/gl2.h \
+       GLES2/gl2ext.h \
+       GLES2/gl2platform.h
+
+GL/wglext.h GL/glxext.h: FORCE
+       wget -O $@ "http://www.opengl.org/registry/api/$(@F)"
+
+GL/glext.h: GL/glext.patch FORCE
+       wget -O $@ "http://www.opengl.org/registry/api/$(@F)"
+       patch $@ $<
+
+EGL/egl.h EGL/eglext.h KHR/khrplatform.h: FORCE
+       wget -O $@ "http://www.khronos.org/registry/egl/api/$@"
+
+EGL/eglplatform.h: EGL/eglplatform.patch FORCE
+       wget -O $@ "http://www.khronos.org/registry/egl/api/$@"
+       patch $@ $<
+
+GLES/gl.h GLES/glplatform.h: FORCE
+       wget -O $@ "http://www.khronos.org/registry/gles/api/1.1/$(@F)"
+
+GLES/glext.h: GLES/glext.patch FORCE
+       wget -O $@ "http://www.khronos.org/registry/gles/api/1.1/$(@F)"
+       patch $@ $<
+
+GLES2/gl2.h GLES2/gl2ext.h GLES2/gl2platform.h: FORCE
+       wget -O $@ "http://www.khronos.org/registry/gles/api/2.0/$(@F)"
+
+.PHONY: update
+
+FORCE:
diff --git a/thirdparty/khronos/README.markdown b/thirdparty/khronos/README.markdown
new file mode 100644 (file)
index 0000000..3e4bddc
--- /dev/null
@@ -0,0 +1,12 @@
+This directory contains headers for all relevant Khronos APIs, based from:
+
+* http://www.khronos.org/
+
+* http://www.opengl.org/registry/
+
+* http://oss.sgi.com/projects/ogl-sample/
+
+
+To update simply run:
+
+    make
diff --git a/thirdparty/less.patch b/thirdparty/less.patch
new file mode 100644 (file)
index 0000000..f173f1e
--- /dev/null
@@ -0,0 +1,100 @@
+diff -du less.orig/defines.wn less/defines.wn
+--- less.orig/defines.wn       2011-04-10 06:59:14.000000000 +0100
++++ less/defines.wn    2012-03-15 08:32:53.848812020 +0000
+@@ -223,7 +223,11 @@
+ /* Define MUST_DEFINE_ERRNO if you have errno but it is not define 
+  * in errno.h */
+ #define HAVE_ERRNO 1
++#if defined(__MINGW32__) 
++#define MUST_DEFINE_ERRNO 0
++#else
+ #define MUST_DEFINE_ERRNO 1
++#endif
+ /* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+ #define HAVE_SYS_ERRLIST 1
+@@ -326,14 +330,18 @@
+ #define HAVE_UNISTD_H 0
+ /* Define if you have the <values.h> header file.  */
+-#ifdef _MSC_VER
++#if defined(_MSC_VER) || defined(__MINGW32__)
+ #define HAVE_VALUES_H 0
+ #else
+ #define HAVE_VALUES_H 1
+ #endif
++#if !defined(__MINGW32__)
+ #define       popen   _popen
+ #define       pclose  _pclose
+ #define snprintf      _snprintf
++#endif
++#if defined(_MSC_VER)
+ #pragma warning(disable:4996)
++#endif
+diff -du less.orig/filename.c less/filename.c
+--- less.orig/filename.c       2011-04-11 23:04:22.000000000 +0100
++++ less/filename.c    2012-03-15 08:23:13.949936491 +0000
+@@ -18,7 +18,7 @@
+ #include "lglob.h"
+ #if MSDOS_COMPILER
+ #include <dos.h>
+-#if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER)
++#if MSDOS_COMPILER==WIN32C && defined(__BORLANDC__)
+ #include <dir.h>
+ #endif
+ #if MSDOS_COMPILER==DJGPPC
+@@ -563,7 +563,9 @@
+ #if HAVE_POPEN
++#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
+ FILE *popen();
++#endif
+ /*
+  * Execute a shell command.
+diff -du less.orig/lglob.h less/lglob.h
+--- less.orig/lglob.h  2011-01-06 00:30:14.000000000 +0000
++++ less/lglob.h       2012-03-15 08:22:10.401621327 +0000
+@@ -57,7 +57,7 @@
+                                       char ext[_MAX_EXT];     \
+                                       int handle;
+ #else
+-#if MSDOS_COMPILER==WIN32C && defined(_MSC_VER)
++#if MSDOS_COMPILER==WIN32C && (defined(_MSC_VER) || defined(__MINGW2__))
+ #define       GLOB_FIRST_NAME(filename,fndp,h) h = _findfirst(filename, fndp)
+ #define       GLOB_FIRST_FAILED(handle)       ((handle) == -1)
+@@ -73,7 +73,7 @@
+                                       long handle;
+ #else
+-#if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER) /* Borland C for Windows */
++#if MSDOS_COMPILER==WIN32C && defined(__BORLANDC__) /* Borland C for Windows */
+ #define       GLOB_FIRST_NAME(filename,fndp,h) h = findfirst(filename, fndp, ~FA_LABEL)
+ #define       GLOB_FIRST_FAILED(handle)       ((handle) != 0)
+diff -du less.orig/lsystem.c less/lsystem.c
+--- less.orig/lsystem.c        2011-04-11 23:04:22.000000000 +0100
++++ less/lsystem.c     2012-03-15 08:23:56.518147471 +0000
+@@ -20,7 +20,7 @@
+ #if MSDOS_COMPILER
+ #include <dos.h>
+-#ifdef _MSC_VER
++#if defined(_MSC_VER) || defined(__MINGW32__)
+ #include <direct.h>
+ #define setdisk(n) _chdrive((n)+1)
+ #else
+@@ -292,7 +292,9 @@
+ {
+       register FILE *f;
+       register int c;
++#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
+       extern FILE *popen();
++#endif
+       /*
+        * This is structured much like lsystem().
diff --git a/thirdparty/less/CMakeLists.txt b/thirdparty/less/CMakeLists.txt
new file mode 100644 (file)
index 0000000..95e7175
--- /dev/null
@@ -0,0 +1,36 @@
+add_definitions (-DNDEBUG)
+if (WIN32)
+    add_definitions (-DWIN32 -D_CONSOLE)
+    configure_file (defines.wn ${CMAKE_CURRENT_BINARY_DIR}/defines.h COPYONLY)
+else ()
+    # XXX unsupported
+endif ()
+
+if (MSVC)
+    add_definitions (-wd4131) # uses old-style declarator
+endif ()
+
+include_directories (${CMAKE_CURRENT_BINARY_DIR})
+
+add_executable (less
+       main.c screen.c brac.c ch.c charset.c cmdbuf.c
+       command.c cvt.c decode.c edit.c filename.c forwback.c
+       help.c ifile.c input.c jump.c line.c linenum.c
+       lsystem.c mark.c optfunc.c option.c opttbl.c os.c
+       output.c pattern.c position.c prompt.c search.c signal.c
+       tags.c ttyin.c version.c regexp.c
+)
+
+add_executable (lesskey lesskey version)
+add_executable (lessecho lessecho version)
+
+install (
+    TARGETS less lesskey lessecho
+    RUNTIME DESTINATION bin
+)
+
+install (
+    FILES LICENSE
+    DESTINATION doc
+    RENAME LICENSE.less
+)
diff --git a/thirdparty/less/COPYING b/thirdparty/less/COPYING
new file mode 100644 (file)
index 0000000..94a9ed0
--- /dev/null
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/thirdparty/less/INSTALL b/thirdparty/less/INSTALL
new file mode 100644 (file)
index 0000000..c2ab230
--- /dev/null
@@ -0,0 +1,186 @@
+   This file describes how to build and install less using 
+the "configure" script.  This only works on Unix systems.  
+To install on other systems, read the README file.
+
+
+Basic Installation
+==================
+
+   These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+   The file `configure.in' is used to create `configure' by a program
+called `autoconf'.  You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  You can give `configure'
+initial values for variables by setting them in the environment.  Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory.  After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+   By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on.  Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+     CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+   If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+     Use and save the results of the tests in FILE instead of
+     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+     debugging `configure'.
+
+`--help'
+     Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--version'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
+
diff --git a/thirdparty/less/LICENSE b/thirdparty/less/LICENSE
new file mode 100644 (file)
index 0000000..c7168e7
--- /dev/null
@@ -0,0 +1,27 @@
+                          Less License
+                          ------------
+
+Less
+Copyright (C) 1984-2011  Mark Nudelman
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice in the documentation and/or other materials provided with 
+   the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/thirdparty/less/NEWS b/thirdparty/less/NEWS
new file mode 100644 (file)
index 0000000..eb38025
--- /dev/null
@@ -0,0 +1,820 @@
+
+                     NEWS about less
+
+======================================================================
+
+  For the latest news about less, see the "less" Web page:
+      http://www.greenwoodsoftware.com/less
+  You can also download the latest version of less from there.
+
+  To report bugs, suggestions or comments, send email to 
+  bug-less@gnu.org or markn@greenwoodsoftware.com.
+
+======================================================================
+
+       Major changes between "less" versions 443 and 444
+
+* Fix bug in unget handling that can cause strange effects on the
+  command line.
+
+* Remove vestiges of obsolete -l option that can cause a crash.
+
+======================================================================
+
+       Major changes between "less" versions 436 and 443
+
+* Change search behavior such that when a search is given an explicit 
+  pattern, the entire displayed screen is included in the search and 
+  not just the portion after the target line.
+
+* Add -A option to change search behavior to the old way: only
+  the portion of the screen after the target line is searched.
+
+* Add %F formatting to prompt strings, replaced by the last component
+  of the input file.
+
+* Control-G while editing a command exits the command.
+
+* Less now exits with status 2 if control-C is pressed and -K is in effect.
+
+* Fix "ungetc overflow" when passing long commands via the -p option.
+
+* Fix bug in using line filtering via the & command 
+  in combination with -i and -I.
+
+* Fix bug in handling negative arguments to the -j option.
+
+* Fix bug in handling %t in prompt strings.
+
+* Improve handling of long option names.
+
+* Improve percentage calculation for very large files.
+
+======================================================================
+
+       Major changes between "less" versions 429 and 436
+
+* Don't pass "-" to non-pipe LESSOPEN unless it starts with "-".
+
+* Allow a fraction as the argument to the -# (--shift) option.
+
+* Fix highlight bug when underlined/overstruck text matches at end of line.
+
+* Fix non-regex searches with ctrl-R.
+
+======================================================================
+
+       Major changes between "less" versions 424 and 429
+
+* LESSOPEN pipe will now be used on standard input, if the LESSOPEN
+  environment variable begins with "|-".
+
+* The -D option with one number now means use the normal background color.
+
+* Don't change permissions on history file if it is not a regular file.
+
+* Fix non-ANSI-compliant code that caused problems with some compilers.
+
+* Fix binary file detection in UTF-8 mode.
+
+* Fix display problems with long lines on "ignaw" terminals.
+
+* Fix problem interrupting the line number calculation for initial prompt.
+
+* Fix SGR emulation when dealing with multiple attributes (eg. bold+underline).
+
+* Fix highlight bug when searching for underlined/overstruck text.
+
+======================================================================
+
+       Major changes between "less" versions 418 and 424
+
+* New "&" command allows filtering of lines based on a pattern.
+
+* Status column now displays a search match, even if the matched
+  string is scrolled off screen because -S is in effect.
+
+* Improve behavior of -F option.
+
+* Allow CSI character (0x9B) to work in UTF-8 mode.
+
+* Output carriage return at startup in case terminal doesn't default
+  to column 1.
+
+* Fix bug in '' (quote, quote) command after G command.
+
+======================================================================
+
+       Major changes between "less" versions 416 and 418
+
+* Color escape sequences are now supported in WIN32 build.
+
+* Makefile now uses EXEEXT feature of autoconf.
+
+* Fix search bug when using -R and text contains ANSI color escape sequences.
+
+* Fix crash when using -r with UTF-8 text containing 0x9B bytes.
+
+* Fix display bug when using ' command to move less than one page forward.
+
+* Update GPL to version 3.
+
+======================================================================
+
+       Major changes between "less" versions 409 and 416
+
+* New --follow-name option makes F command follow the name of a file
+  rather than the file descriptor if an open file is renamed.
+
+* Make searching with -i/-I work correctly with non-ASCII text.
+
+* Fix DJGPP build.
+
+======================================================================
+
+       Major changes between "less" versions 406 and 409
+
+* Support CSI escape sequences, like SGR escape sequences.
+
+* Fix bug which caused screen to fail to repaint when window is resized.
+
+* Fix bug in using -i and -I flags with non-ASCII text.
+
+* Fix configure bug on systems which don't support langinfo.h.
+
+* Fix crash when searching text containing certain invalid UTF-8 sequences.
+
+======================================================================
+
+       Major changes between "less" versions 394 and 406
+
+* Allow decimal point in number for % (percent) command.
+
+* Allow decimal point in number for -j option (fraction of screen height).
+
+* Make n command fetch previous pattern from history file on first search.
+
+* Don't rewrite history file if it has not changed.
+
+* Don't move to bottom of screen on first page.
+
+* Don't output extraneous newlines, so copy & pasting lines from the
+  output works better.
+
+* The -c option has been made identical with the -C option.
+
+* Allow "/dev/null" as synomym for "-" in LESSHISTFILE to indicate
+  that no history file should be used.
+
+* Search can now find text which follows a null byte, if the PCRE
+  library is used, or if no-regex searching (ctrl-R) is used.
+
+* Better compatibility with POSIX more specification.
+
+* Make -f work for directories.
+
+* Make "t" cmd traverse tags in the correct order.
+
+* Allow a few binary characters in the input file before warning
+  that the file is binary.
+
+* Don't warn that file is binary if it merely contains ANSI color sequences
+  and -R is in effect.
+
+* Update Unicode character tables.
+
+* Support DESTDIR in Makefile.
+
+* Fix bug when filename contains certain shell metacharacters such as "$".
+
+* Fix bug when resizing the window while waiting for input from a pipe.
+
+* Fix configure bugs.
+
+======================================================================
+
+       Major changes between "less" versions 382 and 394
+
+* Add history file to save search and shell command history between
+  invocations of less.
+
+* Improve behavior of history list for search and shell commands.
+
+* Add -K (or --quit-on-intr) option to make less exit immediately on ctrl-C.
+
+* Improve handling of UTF-8 files and commands, including better
+  line wrapping and handling double-width chars.
+
+* Added LESSUTFBINFMT environment variable to control display of
+  non-printable characters in a UTF-8 file.
+
+* Add --with-secure option to configure, to make it easier to
+  build a secure version of less.
+
+* Show search matches in the status column even if search highlights
+  are disabled via the -G option or the ESC-u command.
+
+* Improve performance when the file contains very long lines.
+
+* Add "windows" charset.
+
+* Add man page for lessecho.
+
+* Add support for erase2 character, treated same as erase.
+
+* Use ASCII lowercase/uppercase logic when operating on the command line.
+
+* Update makefile for Borland C++ 5.5.1.
+
+* Fix bug in calculating number of pages for %D prompt.
+
+* Fix bug in handling tag file error.
+
+* Fix obscure bug if input file is deleted while viewing help.
+
+* Fix bug handling filenames which include square brackets.
+
+* Fix possible buffer overflow in "global" tag search.
+
+* Fix possible buffer overflow in usage of LESSOPEN and LESSCLOSE.
+
+* Fix buffer overflow in reverse search.
+
+======================================================================
+
+       Major changes between "less" versions 381 and 382
+
+* Removed some old copyrighted code.
+  This probably breaks OS/9 support.
+
+======================================================================
+
+       Major changes between "less" versions 378 and 381
+
+* New -L option to disable LESSOPEN processing.
+
+* Further support for large (64 bit) file addressing.
+  Large file support is now set up by the configure script.
+
+* Use autoconf 2.54.
+  Replace configure.in, acconfig.h, defines.h.top with configure.ac.
+
+* Overstriking underscore with underscore is now bold or underlined 
+  depending on context.
+
+* Use only 7 spaces for line numbers in -N mode, if possible.
+
+* Fix some bugs in handling overstriking in UTF-8 files.
+
+* Fix some nroff issues in the man page.
+
+======================================================================
+
+       Major changes between "less" versions 376 and 378
+
+* Bug fixes:
+  Default buffer space is now 64K as documented.
+  Search highlighting works properly when used with -R.
+  Windows version works properly when input file contains carriage returns.
+  Clean up some compiler warnings.
+
+======================================================================
+
+       Major changes between "less" versions 358 and 376
+
+* -x option can now specify multiple variable-width tab stops.
+
+* -X option no longer disables keypad initialization.
+  New option --no-keypad disables keypad initialization.
+
+* New commands t and T step through multiple tag matches.
+  Added support for "global(1)" tags
+  (see http://www.gnu.org/software/global/global.html).
+
+* New prompt style set by option -Pw defines the message printed 
+  while waiting for data in the F command.
+
+* System-wide lesskey file now defaults to sysless in etc directory 
+  instead of .sysless in bin directory.
+  Use "configure --sysconfdir=..." to change it.
+  (For backwards compatibility, .sysless in bin is still recognized.)
+
+* Pressing RightArrow or LeftArrow while entering a number now shifts
+  the display N columns rather than editing the number itself.
+
+* Status column (enabled with -J) now shows search results.
+
+* Windows version sets window title.
+
+* Default LESSCHARSET for MS-DOS versions is now "dos".
+
+* Searching works better with ANSI (SGR) escape sequences.
+  ANSI color escape sequences are now supported in the MS-DOS (DJGPP) version.
+
+* Improved performance in reading very large pipes.
+
+* Eliminated some dependencies on file offets being 32 bits.
+
+* Fixed problems when viewing files with very long lines.
+
+* Fixed overstriking in UTF-8 mode, and overstriking tabs.
+
+* Improved horizontal shifting of text using -R option with ANSI color.
+
+* Improved handling of filenames containing shell metacharacters.
+
+* Some fixes for EBCDIC systems.
+
+* Some fixes for OS/2 systems.
+
+======================================================================
+
+       Major changes between "less" versions 354 and 358
+
+* Add -J (--status-column) option to display a status column.
+
+* Add -# (--shift) option to set default horizontal shift distance.
+  Default horizontal shift distance is now one-half screen width.
+
+* Horizontal shifting does not shift line numbers if -N is in effect.
+
+* Horizontal shifting acts as though -S were set, to avoid confusion.
+
+======================================================================
+
+
+       Major changes between "less" versions 352 and 354
+
+* Allow space after numeric-valued command line options.
+
+* Fix problem with configuring terminal libraries on some systems.
+
+* Add support for PCRE regular expression library.
+
+* Add --with-regex option to configure to allow manually selecting
+  a regular expression library.
+
+* Fix bug compiling with SECURE = 1.
+
+======================================================================
+
+
+       Major changes between "less" versions 346 and 352
+
+* Enable UTF-8 if "UTF-8" appears in locale-related environment variables.
+
+* Add --with-editor option to configure script.
+
+* The -M prompt and = message now show the top and bottom line number.
+
+* Fix bug in running the editor on a file whose name contains quotes, etc.
+
+* Fix bug in horizontal scrolling of long lines.
+
+* Fix bug in doing :d on a file which contains marks.
+
+* Fix bug causing cleared lines to sometimes be filled with standout, 
+  bold, underline, etc. on certain terminals.
+
+* Fixes for MS-DOS (DJGPP) version.
+
+======================================================================
+
+
+       Major changes between "less" versions 340 and 346
+
+* The UTF-8 character set is now supported.
+
+* The default character set is now latin1 rather than ascii.
+
+* New option -R (--RAW-CONTROL-CHARS) is like -r but handles 
+  long (wrapped) lines correctly, as long as the input contains only 
+  normal text and ANSI color escape sequences.
+
+* New option -F (--quit-if-one-screen) quits if the text fits on
+  the first screen.
+
+* The -w option now highlights the target line of a g or p command.
+
+* A system-wide lesskey file is supported (LESSKEY_SYSTEM).
+
+* New escape for prompt strings: %c is replaced by column number.
+
+* New escape for prompt strings: %P is replaced by percentage into
+  file, based on line number rather than byte offset.
+
+* HOME and END keys now jump to beginning of file or end of file.
+
+======================================================================
+
+
+       Major changes between "less" versions 337 and 340
+
+* Command line options for less may now be given in either the old 
+  single-letter form, or a new long name form (--option-name).
+  See the less man page or "less --help" for the list of long option names.
+
+* Command line options for lesskey may now be given in a new long name
+  form.  See the lesskey man page for the list of long option names.
+
+* New command -- toggles an option using the long option name.
+
+* New command __ queries an option using the long option name.
+
+* The old -- command is renamed as -!.
+
+* If a ^P is entered between the dash and the option letter of the -
+  command, the message describing the new setting is suppressed.
+
+* Lesskey files may now contain \k escape sequences to represent the
+  "special" keys (arrows, PAGE-UP/PAGE-DOWN, HOME, END, INSERT, DELETE).
+
+* New command :d removes the current file from the list of files.
+
+* New option -~ (like -w before version 335)
+  suppresses tildes after end-of-file.
+
+* Less is now released under the GNU General Public License.
+
+======================================================================
+
+
+       Major changes between "less" versions 335 and 337
+
+* Fixed bugs in "make install".
+
+======================================================================
+
+
+       Major changes between "less" versions 332 and 335
+
+* The old -w flag (suppress tildes after end-of-file) has been removed.
+
+* New -w flag highlights the first new line after a forward-screen.
+
+* New -W flag highlights the first new line after any forward movement.
+
+* Window resize works even if LINES and/or COLUMNS environment 
+  variables are incorrect.
+
+* New percent escapes for prompt strings:
+  %d is replaced by the page number, and
+  %D is replaced by the number of pages in the file.
+
+* Added charsets "iso8859" and "ebcdic".
+
+* In Windows version, uses HOMEDRIVE and HOMEPATH if HOME is not defined.
+
+* Fixed some bugs causing incorrect display on DOS/Windows.
+
+======================================================================
+
+
+       Major changes between "less" versions 330 and 332
+
+* Filenames from the command line are entered into the command history,
+  so UPARROW/DOWNARROW can be used to retrieve them from the :e command.
+
+* Now works correctly on Windows when using a scrolling terminal
+  window (buffer larger than display window).
+
+* On Windows, now restores the console screen on exit.  
+  Use -X to get the old behavior.
+
+* Fixed bug on Windows when CAPS-LOCK or NUM-LOCK is pressed.
+
+* Fixed bug on Windows when piping output of an interactive program.
+
+* Fixed bug in tags file processing when tags file has DOS-style
+  line terminators (CR/LF).
+
+* Fixed compilation problem on OS/2.
+
+======================================================================
+
+
+       Major changes between "less" versions 321 and 330
+
+* Now supports filenames containing spaces (in double quotes).
+  New option -" can be used to change the quoting characters.
+
+* In filename completion, a slash is appended to a directory name.
+  If the environment variable LESSSEPARATOR is set, the value of
+  that variable, rather than a slash, is appended.
+
+* LeftArrow and RightArrow are same as ESC-[ and ESC-].
+
+* Added commands ESC-( and ESC-), same as ESC-[ and ESC-].
+
+* A "quit" command defined in a lesskey file may now have an "extra" 
+  string, which is used to return an exit code from less when it quits.
+
+* New environment variables LESSMETACHARS and LESSMETAESCAPE provide
+  more control over how less interfaces to the shell.
+
+* Ported to Microsoft Visual C compiler for Windows.
+
+* Ported to DJGPP compiler for MS-DOS.
+
+* Bug fixes.
+
+======================================================================
+
+
+       Major changes between "less" versions 291 and 321
+
+* Command line at bottom of screen now scrolls, so it can be longer 
+  than the screen width.
+
+* New commands ESC-] and ESC-[ scroll the display horizontally.
+
+* New command ESC-SPACE scrolls forward a full screen, even if it
+  hits end-of-file.
+
+* Alternate modifiers for search commands: ^N is same as !,
+  ^F is same as @, and ^E is same as *.
+
+* New modifier for search commands: ^K means highlight the matches
+  currently on-screen, but don't move to the first match.
+
+* New modifier for search commands: ^R means don't use regular
+  expressions in the search.
+
+* Environment variable LESSKEY gives name of default lesskey file.
+
+* Environment variable LESSSECURE will force less to run in
+  "secure" mode.
+
+* Command line argument "--" signals that the rest of the arguments
+  are files (not option flags).
+
+* Help file (less.hlp) is no longer installed.  Help text is now 
+  embedded in the less executable itself.
+
+* Added -Ph to change the prompt for the help text.
+  Added -Ps to change the default short prompt (same as plain -P).
+
+* Ported to the Borland C compiler for MS-DOS.
+
+* Ported to Windows 95 & Windows NT.
+
+* Ported to OS-9.
+
+* Ported to GNU Hurd.
+
+======================================================================
+
+
+       Major changes between "less" versions 290 and 291
+
+* Less environment variables can be specified in lesskey files.
+
+* Fixed MS-DOS build.
+
+======================================================================
+
+
+       Major changes between "less" versions 278 and 290
+
+* Accepts GNU-style options "--help" and "--version".
+
+* OS/2 version looks for less.ini in $HOME before $INIT and $PATH.
+
+* Bug fixes
+
+======================================================================
+
+
+       Major changes between "less" versions 252 and 278
+
+* A LESSOPEN preprocessor may now pipe the converted file data to less,
+  rather than writing it to a temporary file.
+
+* Search pattern highlighting has been fixed.  It now highlights 
+  reliably, even if a string is split across two screen lines,
+  contains TABs, etc.
+
+* The -F flag (which suppress search highlighting) has been changed 
+  to -G.  A new flag, -g, changes search highlighting to highlight 
+  only the string found by the last search command, instead of all 
+  strings which match the last search command.
+
+* New flag -I acts like -i, but ignores case even if the search 
+  pattern contains uppercase letters.
+
+* Less now checks for the environment variable VISUAL before EDITOR.
+
+* Ported to OS/2.
+
+======================================================================
+
+
+       Major changes between "less" versions 237 and 252
+
+* Changes in line-editing keys:
+  The literal key is now ^V or ^A rather than \ (backslash).
+  Filename completion commands (TAB and ^L) are disabled 
+  when typing a search pattern.
+
+* Line-editing command keys can be redefined using lesskey.
+
+* Lesskey with no input file defaults to $HOME/.lesskey
+  rather than standard input.
+
+* New option -V displays version number of less.
+
+* New option -V displays version number of lesskey.
+
+* Help file less.hlp is now installed by default in /usr/local/share 
+  rather than /usr/local/lib.
+
+
+======================================================================
+
+
+       Major changes between "less" versions 170 and 237
+
+* By popular demand, text which matches the current search pattern
+  is highlighted.  New -F flag disables this feature.
+
+* Henry Spencer's regexp.c is now included, for systems which do not
+  have a regular expression library.
+  regexp.c is Copyright (c) 1986 by University of Toronto.
+
+* New line-editing keys, including command history (arrow keys) and 
+  filename completion (TAB).
+
+* Input preprocessor allows modification of input files (e.g. uncompress)
+  via LESSOPEN/LESSCLOSE environment variables.
+
+* New -X flag disables sending termcap "ti" and "te" (initialize and
+  deinitialize) strings to the terminal. 
+
+* Changing -i from within less now correctly affects a subsequent
+  repeated search.  
+
+* Searching for underlined or overstruck text now works when the -u
+  flag is in effect, rather than the -i flag.
+
+* Use setlocale (LANG and LC_CTYPE environment variables) to determine
+  the character set if LESSCHARSET/LESSCHARDEF are not set.
+
+* The default format for displaying binary characters is now standout
+  (reverse video) rather than blinking.  This can still be changed by
+  setting the LESSBINFMT environment variable.
+
+* Use autoconf installation technology.
+
+* Ported to MS-DOS.
+
+        ********************************
+          Things that may surprise you
+        ********************************
+
+* When you enter text at the bottom of the screen (search string, 
+  filename, etc.), some keys act different than previously.  
+  Specifically, \ (backslash), ESC, TAB, BACKTAB, and control-L 
+  now have line editing functions.
+
+* Some previous unofficial versions of less were able to display
+  compressed files.  The new LESSOPEN/LESSCLOSE feature now provides
+  this functionality in a different way.
+
+* Some previous unofficial versions of less provided a -Z flag to 
+  set the number of lines of text to retain between full screen scrolls.
+  The -z-n flag (that is, -z with a negative number) provides this 
+  functionality.
+
+
+======================================================================
+
+
+       Major changes between "less" versions 123 and 170
+
+* New option -j allows target lines to be positioned anywhere on screen.
+
+* New option -S truncates displayed line at the screen width,
+  rather than wrapping onto the next line.
+
+* New option -y limits amount of forward scroll.
+
+* New option -T specifies a "tags" file.
+
+* Non-printable, non-control characters are displayed in octal.
+  Such characters, as well as control characters, are displayed 
+  in blinking mode.
+
+* New command -+ sets an option to its default.
+* New command -- sets an option to the opposite of its default.
+
+* Lesskey file may have a string appended to a key's action,
+  which acts as though typed in after the command.
+
+* New commands ESC-^F and ESC-^B match arbitrary types of brackets.
+
+* New command F monitors a growing file (like "tail -f").
+
+* New command | pipes a section of the input file into a shell command.
+
+* New command :x directly jumps to a file in the command line list.
+
+* Search commands have been enhanced and reorganized:
+       n       Repeat search, same direction.
+       N       Repeat search, opposite direction.
+       ESC-/   Search forward thru file boundaries
+       ESC-?   Search backward thru file boundaries
+       ESC-n   Repeat search thru file boundaries, same direction.
+       ESC-N   Repeat search thru file boundaries, opposite direction.
+  Special character * causes search to search thru file boundaries.
+  Special character @ causes search to begin at start/end of file list.
+
+* Examining a new file adds it to the command line list.
+  A list of files, or an expression which matches more than one file,
+  may be examined; all of them are added to the command line list.
+
+* Environment variables LESSCHARSET and LESSCHARDEF can define
+  a non-ASCII character set.
+
+* Partial support for MSDOS, including options -R for repainting screen
+  on quit, -v/-V to select video mode, and -W to change window size.
+
+
+======================================================================
+
+
+       Major changes between "less" versions 97 and 123
+
+* New option (-N) causes line numbers to be displayed in the
+  text of the file (like vi "set nu").
+
+* New option (-?) prints help message immediately.
+
+* New option (-r) displays "raw" control characters, without
+  mapping them to ^X notation.
+
+* New option (-f) forces less to open non-regular files
+  (directories, etc).
+
+* New option (-k) can be used to specify lesskey files by name.
+
+* New option (-y) can be used to set a forward scroll limit
+  (like -h sets a backward scroll limit).
+
+* File marks (set by the m command) are now preserved when a new
+  file is edited.  The ' command can thus be used to switch files.
+
+* New command ESC-/ searches all files (on the command line) 
+  for a pattern.
+
+* New command ESC-n repeats previous search, spanning files.
+
+* The N command has been changed to repeat the previous search
+  in the reverse direction.  The old N command is still available 
+  via :n.
+
+* New command ESC-N repeats previous search in the reverse
+  direction and spanning files.
+
+* 8 bit characters are now supported.  A new option (-g) can be 
+  used to strip off the eighth bit (the previous behavior).
+
+* Options which take a following string (like -t) may now
+  optionally have a space between the option letter and the string.
+
+* Six new commands { } ( ) [ and ] can be used to match
+  brackets of specific types, similar to vi % command.
+
+* New commands z and w move forward/backward one window and
+  simultaneously set the window size.
+
+* Prompt string expansion now has %L for line number of the last
+  line in the file, and %E for the name of the editor.
+  Also, % escapes which refer to a line (b=bottom, t=top, etc.)
+  can use j for the jump target line.
+
+* New environment variable LESSEDIT can be used to tailor the
+  command string passed to the editor by the v command.
+
+* Examining a file which was previously examined will return
+  to the same position in the file.
+
+* A "%" is expanded to the current filename and a "#" to the 
+  previous filename, in both shell commands and the E command.
+  (Previously % worked only in shell commands and # worked 
+  only in the E command.)
+
+* New command ":ta" is equivalent to "-t".
+
+* New command "s" is equivalent to "-l".
+
+* The - command may be followed by "+X" to revert to the default
+  for option X, or "-X" to get the opposite of the default.
+
+* Lesskey files may now include characters after the action as
+  extra input to be parsed after the action; for example:
+  "toggle-option X" to toggle a specific option X.
+
+
+
+
+
diff --git a/thirdparty/less/README b/thirdparty/less/README
new file mode 100644 (file)
index 0000000..c4cfa63
--- /dev/null
@@ -0,0 +1,236 @@
+
+                            Less, version 444
+
+    This is the distribution of less, version 444, released 09 Jun 2011.
+    This program is part of the GNU project (http://www.gnu.org).
+
+    This program is free software.  You may redistribute it and/or
+    modify it under the terms of either:
+
+    1. The GNU General Public License, as published by the Free
+       Software Foundation; either version 3, or (at your option) any
+       later version.  A copy of this license is in the file COPYING.
+    or
+    2. The Less License, in the file LICENSE.
+
+    Please report any problems to bug-less@gnu.org or markn@greenwoodsoftware.com.
+    See http://www.greenwoodsoftware.com/less for the latest info.
+
+=========================================================================
+
+This is the distribution of "less", a paginator similar to "more" or "pg".
+
+The formatted manual page is in less.man.
+The manual page nroff source is in less.nro.
+Major changes made since the last posted version are in NEWS.
+
+=======================================================================
+INSTALLATION (Unix systems only):
+
+1. Move the distributed source to its own directory and unpack it,
+   if you have not already done so.  
+
+2. Type "sh configure".
+   This will generate a Makefile and a defines.h.
+   Warning: if you have a GNU sed, make sure it is version 2.05 or later.
+
+   The file INSTALL describes the usage of the configure program in
+   general.  In addition, these options to configure are supported:
+
+   --with-editor=program
+     Specifies the default editor program used by the "v" command.
+     The default is "vi".
+
+   --with-regex=lib
+     Specifies the regular expression library used by less for pattern
+     matching.  The default is "auto", which means the configure program 
+     finds a regular expression library automatically.  Other values are:
+        posix          Use the POSIX-compatible regcomp.
+        pcre           Use the PCRE library.
+        regcmp         Use the regcmp library.
+        re_comp        Use the re_comp library.
+        regcomp        Use the V8-compatible regcomp.
+        regcomp-local  Use Henry Spencer's V8-compatible regcomp
+                       (source is supplied with less).
+   --with-secure
+     Builds a "secure" version of less, with some features disabled
+        to prevent users from viewing other files, accessing shell
+        commands, etc.
+
+
+3. It is a good idea to look over the generated Makefile and defines.h
+   and make sure they look ok.  If you know of any peculiarities of
+   your system that configure might not have detected, you may fix the
+   Makefile now.  Take particular notice of the list of "terminal" 
+   libraries in the LIBS definition in the Makefile; these may need 
+   to be edited.  The terminal libraries will be some subset of
+       -lncurses  -lcurses  -ltermcap  -ltermlib
+
+   If you wish, you may edit defines.h to remove some optional features.
+   If you choose not to include some features in your version, you may
+   wish to edit the manual page "less.nro" and the help page "less.hlp" 
+   to remove the descriptions of the features which you are removing.
+   If you edit less.hlp, you should run "make -f Makefile.aut help.c".
+
+4. Type "make" and watch the fun.
+
+5. If the make succeeds, it will generate the programs "less",
+   "lesskey" and "lessecho" in your current directory.  Test the 
+   generated programs.
+
+6. When satisfied that it works, if you wish to install it
+   in a public place, type "make install".
+
+   The default install destinations are:
+        Executables (less, lesskey, lessecho) in /usr/local/bin
+        Documentation (less.nro, lesskey.nro) in /usr/local/man/man1
+   If you want to install any of these files elsewhere, define
+   bindir and/or mandir to the appropriate directories.
+
+If you have any problems building or running "less", suggestions, 
+complaints, etc., you may mail to the author at markn@greenwoodsoftware.com.
+
+Note to hackers: comments noting possible improvements are enclosed
+in double curly brackets {{ like this }}.
+
+(Note that the above note was originally written at a time when 
+"hackers" most commonly meant "enthusiastic and dedicated computer 
+programmers", not "persons who attempt to circumvent computer security".)
+
+
+
+=======================================================================
+INSTALLATION (MS-DOS systems only,
+              with Microsoft C, Borland C, or DJGPP)
+
+1. Move the distributed source to its own directory.
+   Depending on your compiler, you may need to convert the source 
+   to have CR-LF rather than LF as line terminators.
+
+2. If you are using Microsoft C, rename MAKEFILE.DSU to MAKEFILE.
+   If you are using Borland C, rename MAKEFILE.DSB to MAKEFILE.
+   If you are using DJGPP, rename MAKEFILE.DSG to MAKEFILE.
+
+3. Look at MAKEFILE to make sure that the definitions for CC and LIBDIR
+   are correct.  CC should be the name of your C compiler and
+   LIBDIR should be the directory where the C libraries reside (for
+   Microsoft C only).  If these definitions need to be changed, you can
+   either modify the definitions directly in MAKEFILE, or set your
+   environment variables CC and/or LIBDIR to override the definitions
+   in MAKEFILE.
+
+4. If you wish, you may edit DEFINES.DS to remove some optional features.
+   If you choose not to include some features in your version, you may
+   wish to edit the manual page LESS.MAN and the help page HELP.C
+   to remove the descriptions of the features which you are removing.
+
+5. Run your "make" program and watch the fun.
+   If your "make" requires a flag to import environment variables,
+   you should use that flag.
+   If your compiler runs out of memory, try running "make -n >cmds.bat" 
+   and then run cmds.bat.
+
+6. If the make succeeds, it will generate the programs "LESS.EXE" and
+   "LESSKEY.EXE" in your current directory.  Test the generated programs.
+
+7. When satisfied that it works, you may wish to install LESS.EXE and
+   LESSKEY.EXE in a directory which is included in your PATH.
+
+
+
+=======================================================================
+INSTALLATION (Windows-95, Windows-98 and Windows-NT systems only,
+              with Borland C or Microsoft Visual C++)
+
+1. Move the distributed source to its own directory.
+
+2. If you are using Borland C, rename Makefile.wnb to Makefile.
+   If you are using Microsoft Visual C++, rename Makefile.wnm to Makefile.
+
+3. Check the Makefile to make sure the definitions look ok.
+
+4. If you wish, you may edit defines.wn to remove some optional features.
+   If you choose not to include some features in your version, you may
+   wish to edit the manual page less.man and the help page help.c
+   to remove the descriptions of the features which you are removing.
+
+5. Type "make" and watch the fun.
+
+6. If the make succeeds, it will generate the programs "less.exe" and
+   "lesskey.exe" in your current directory.  Test the generated programs.
+
+7. When satisfied that it works, if you wish to install it
+   in a public place, type "make install".
+   See step 6 of the Unix installation instructions for details
+   on how to change the default installation directories.
+
+
+
+=======================================================================
+INSTALLATION (OS/2 systems only,
+              with EMX C)
+
+1. Move the distributed source to its own directory.
+
+2. Rename Makefile.o2e to Makefile.
+
+3. Check the Makefile to make sure the definitions look ok.
+
+4. If you wish, you may edit defines.o2 to remove some optional features.
+   If you choose not to include some features in your version, you may
+   wish to edit the manual page less.man and the help page help.c
+   to remove the descriptions of the features which you are removing.
+
+5. Type "make" and watch the fun.
+
+6. If the make succeeds, it will generate the programs "less.exe" and
+   "lesskey.exe" in your current directory.  Test the generated programs.
+
+7. Make sure you have the emx runtime installed. You need the emx DLLs
+   emx.dll and emxlibcs.dll and also the termcap database, termcap.dat.
+   Make sure you have termcap.dat either in the default location or
+   somewhere in a directory listed in the PATH or INIT environment 
+   variables.
+
+8. When satisfied that it works, you may wish to install less.exe,
+   lesskey.exe and scrsize.exe in a directory which is included in 
+   your PATH.  scrsize.exe is required only if you use a terminal
+   emulator such as xterm or rxvt.
+
+
+
+=======================================================================
+INSTALLATION (OS-9 systems only,
+              with Microware C or Ultra C)
+
+1. Move the distributed source to its own directory.
+
+2. If you are using Microware C, rename Makefile.o9c to Makefile.
+   If you are using Ultra C, rename Makefile.o9u to Makefile.
+
+3. Check the Makefile to make sure the definitions look ok.
+
+4. If you wish, you may edit defines.o9 to remove some optional features.
+   If you choose not to include some features in your version, you may
+   wish to edit the manual page less.man and the help page help.c
+   to remove the descriptions of the features which you are removing.
+
+5. Type "dmake" and watch the fun.
+   The standard OS-9 "make" will probably not work.  If you don't
+   have dmake, you can get a copy from os9archive.rtsi.com.
+
+6. If the make succeeds, it will generate the programs "less" and
+   "lesskey" in your current directory.  Test the generated programs.
+
+7. When satisfied that it works, if you wish to install it
+   in a public place, type "dmake install".
+   See step 6 of the Unix installation instructions for details
+   on how to change the default installation directories.
+
+=======================================================================
+ACKNOWLEDGMENTS:
+  Some versions of the less distribution are packaged using 
+  Info-ZIP's compression utility.
+  Info-ZIP's software is free and can be obtained as source 
+  code or executables from various anonymous-ftp sites,
+  including ftp.uu.net:/pub/archiving/zip.
diff --git a/thirdparty/less/brac.c b/thirdparty/less/brac.c
new file mode 100644 (file)
index 0000000..22c71eb
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to perform bracket matching functions.
+ */
+
+#include "less.h"
+#include "position.h"
+
+/*
+ * Try to match the n-th open bracket 
+ *  which appears in the top displayed line (forwdir),
+ * or the n-th close bracket 
+ *  which appears in the bottom displayed line (!forwdir).
+ * The characters which serve as "open bracket" and 
+ * "close bracket" are given.
+ */
+       public void
+match_brac(obrac, cbrac, forwdir, n)
+       register int obrac;
+       register int cbrac;
+       int forwdir;
+       int n;
+{
+       register int c;
+       register int nest;
+       POSITION pos;
+       int (*chget)();
+
+       extern int ch_forw_get(), ch_back_get();
+
+       /*
+        * Seek to the line containing the open bracket.
+        * This is either the top or bottom line on the screen,
+        * depending on the type of bracket.
+        */
+       pos = position((forwdir) ? TOP : BOTTOM);
+       if (pos == NULL_POSITION || ch_seek(pos))
+       {
+               if (forwdir)
+                       error("Nothing in top line", NULL_PARG);
+               else
+                       error("Nothing in bottom line", NULL_PARG);
+               return;
+       }
+
+       /*
+        * Look thru the line to find the open bracket to match.
+        */
+       do
+       {
+               if ((c = ch_forw_get()) == '\n' || c == EOI)
+               {
+                       if (forwdir)
+                               error("No bracket in top line", NULL_PARG);
+                       else
+                               error("No bracket in bottom line", NULL_PARG);
+                       return;
+               }
+       } while (c != obrac || --n > 0);
+
+       /*
+        * Position the file just "after" the open bracket
+        * (in the direction in which we will be searching).
+        * If searching forward, we are already after the bracket.
+        * If searching backward, skip back over the open bracket.
+        */
+       if (!forwdir)
+               (void) ch_back_get();
+
+       /*
+        * Search the file for the matching bracket.
+        */
+       chget = (forwdir) ? ch_forw_get : ch_back_get;
+       nest = 0;
+       while ((c = (*chget)()) != EOI)
+       {
+               if (c == obrac)
+                       nest++;
+               else if (c == cbrac && --nest < 0)
+               {
+                       /*
+                        * Found the matching bracket.
+                        * If searching backward, put it on the top line.
+                        * If searching forward, put it on the bottom line.
+                        */
+                       jump_line_loc(ch_tell(), forwdir ? -1 : 1);
+                       return;
+               }
+       }
+       error("No matching bracket", NULL_PARG);
+}
diff --git a/thirdparty/less/ch.c b/thirdparty/less/ch.c
new file mode 100644 (file)
index 0000000..1b84ec1
--- /dev/null
@@ -0,0 +1,933 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Low level character input from the input file.
+ * We use these special purpose routines which optimize moving
+ * both forward and backward from the current read pointer.
+ */
+
+#include "less.h"
+#if MSDOS_COMPILER==WIN32C
+#include <errno.h>
+#include <windows.h>
+#endif
+
+#if HAVE_STAT_INO
+#include <sys/stat.h>
+extern dev_t curr_dev;
+extern ino_t curr_ino;
+#endif
+
+typedef POSITION BLOCKNUM;
+
+public int ignore_eoi;
+
+/*
+ * Pool of buffers holding the most recently used blocks of the input file.
+ * The buffer pool is kept as a doubly-linked circular list,
+ * in order from most- to least-recently used.
+ * The circular list is anchored by the file state "thisfile".
+ */
+struct bufnode {
+       struct bufnode *next, *prev;
+       struct bufnode *hnext, *hprev;
+};
+
+#define        LBUFSIZE        8192
+struct buf {
+       struct bufnode node;
+       BLOCKNUM block;
+       unsigned int datasize;
+       unsigned char data[LBUFSIZE];
+};
+#define bufnode_buf(bn)  ((struct buf *) bn)
+
+/*
+ * The file state is maintained in a filestate structure.
+ * A pointer to the filestate is kept in the ifile structure.
+ */
+#define        BUFHASH_SIZE    64
+struct filestate {
+       struct bufnode buflist;
+       struct bufnode hashtbl[BUFHASH_SIZE];
+       int file;
+       int flags;
+       POSITION fpos;
+       int nbufs;
+       BLOCKNUM block;
+       unsigned int offset;
+       POSITION fsize;
+};
+
+#define        ch_bufhead      thisfile->buflist.next
+#define        ch_buftail      thisfile->buflist.prev
+#define        ch_nbufs        thisfile->nbufs
+#define        ch_block        thisfile->block
+#define        ch_offset       thisfile->offset
+#define        ch_fpos         thisfile->fpos
+#define        ch_fsize        thisfile->fsize
+#define        ch_flags        thisfile->flags
+#define        ch_file         thisfile->file
+
+#define        END_OF_CHAIN    (&thisfile->buflist)
+#define        END_OF_HCHAIN(h) (&thisfile->hashtbl[h])
+#define BUFHASH(blk)   ((blk) & (BUFHASH_SIZE-1))
+
+/*
+ * Macros to manipulate the list of buffers in thisfile->buflist.
+ */
+#define        FOR_BUFS(bn) \
+       for (bn = ch_bufhead;  bn != END_OF_CHAIN;  bn = bn->next)
+
+#define BUF_RM(bn) \
+       (bn)->next->prev = (bn)->prev; \
+       (bn)->prev->next = (bn)->next;
+
+#define BUF_INS_HEAD(bn) \
+       (bn)->next = ch_bufhead; \
+       (bn)->prev = END_OF_CHAIN; \
+       ch_bufhead->prev = (bn); \
+       ch_bufhead = (bn);
+
+#define BUF_INS_TAIL(bn) \
+       (bn)->next = END_OF_CHAIN; \
+       (bn)->prev = ch_buftail; \
+       ch_buftail->next = (bn); \
+       ch_buftail = (bn);
+
+/*
+ * Macros to manipulate the list of buffers in thisfile->hashtbl[n].
+ */
+#define        FOR_BUFS_IN_CHAIN(h,bn) \
+       for (bn = thisfile->hashtbl[h].hnext;  \
+            bn != END_OF_HCHAIN(h);  bn = bn->hnext)
+
+#define        BUF_HASH_RM(bn) \
+       (bn)->hnext->hprev = (bn)->hprev; \
+       (bn)->hprev->hnext = (bn)->hnext;
+
+#define        BUF_HASH_INS(bn,h) \
+       (bn)->hnext = thisfile->hashtbl[h].hnext; \
+       (bn)->hprev = END_OF_HCHAIN(h); \
+       thisfile->hashtbl[h].hnext->hprev = (bn); \
+       thisfile->hashtbl[h].hnext = (bn);
+
+static struct filestate *thisfile;
+static int ch_ungotchar = -1;
+static int maxbufs = -1;
+
+extern int autobuf;
+extern int sigs;
+extern int secure;
+extern int screen_trashed;
+extern int follow_mode;
+extern constant char helpdata[];
+extern constant int size_helpdata;
+extern IFILE curr_ifile;
+#if LOGFILE
+extern int logfile;
+extern char *namelogfile;
+#endif
+
+static int ch_addbuf();
+
+
+/*
+ * Get the character pointed to by the read pointer.
+ */
+       int
+ch_get()
+{
+       register struct buf *bp;
+       register struct bufnode *bn;
+       register int n;
+       register int slept;
+       register int h;
+       POSITION pos;
+       POSITION len;
+
+       if (thisfile == NULL)
+               return (EOI);
+
+       /*
+        * Quick check for the common case where 
+        * the desired char is in the head buffer.
+        */
+       if (ch_bufhead != END_OF_CHAIN)
+       {
+               bp = bufnode_buf(ch_bufhead);
+               if (ch_block == bp->block && ch_offset < bp->datasize)
+                       return bp->data[ch_offset];
+       }
+
+       slept = FALSE;
+
+       /*
+        * Look for a buffer holding the desired block.
+        */
+       h = BUFHASH(ch_block);
+       FOR_BUFS_IN_CHAIN(h, bn)
+       {
+               bp = bufnode_buf(bn);
+               if (bp->block == ch_block)
+               {
+                       if (ch_offset >= bp->datasize)
+                               /*
+                                * Need more data in this buffer.
+                                */
+                               break;
+                       goto found;
+               }
+       }
+       if (bn == END_OF_HCHAIN(h))
+       {
+               /*
+                * Block is not in a buffer.  
+                * Take the least recently used buffer 
+                * and read the desired block into it.
+                * If the LRU buffer has data in it, 
+                * then maybe allocate a new buffer.
+                */
+               if (ch_buftail == END_OF_CHAIN || 
+                       bufnode_buf(ch_buftail)->block != -1)
+               {
+                       /*
+                        * There is no empty buffer to use.
+                        * Allocate a new buffer if:
+                        * 1. We can't seek on this file and -b is not in effect; or
+                        * 2. We haven't allocated the max buffers for this file yet.
+                        */
+                       if ((autobuf && !(ch_flags & CH_CANSEEK)) ||
+                               (maxbufs < 0 || ch_nbufs < maxbufs))
+                               if (ch_addbuf())
+                                       /*
+                                        * Allocation failed: turn off autobuf.
+                                        */
+                                       autobuf = OPT_OFF;
+               }
+               bn = ch_buftail;
+               bp = bufnode_buf(bn);
+               BUF_HASH_RM(bn); /* Remove from old hash chain. */
+               bp->block = ch_block;
+               bp->datasize = 0;
+               BUF_HASH_INS(bn, h); /* Insert into new hash chain. */
+       }
+
+    read_more:
+       pos = (ch_block * LBUFSIZE) + bp->datasize;
+       if ((len = ch_length()) != NULL_POSITION && pos >= len)
+               /*
+                * At end of file.
+                */
+               return (EOI);
+
+       if (pos != ch_fpos)
+       {
+               /*
+                * Not at the correct position: must seek.
+                * If input is a pipe, we're in trouble (can't seek on a pipe).
+                * Some data has been lost: just return "?".
+                */
+               if (!(ch_flags & CH_CANSEEK))
+                       return ('?');
+               if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK)
+               {
+                       error("seek error", NULL_PARG);
+                       clear_eol();
+                       return (EOI);
+               }
+               ch_fpos = pos;
+       }
+
+       /*
+        * Read the block.
+        * If we read less than a full block, that's ok.
+        * We use partial block and pick up the rest next time.
+        */
+       if (ch_ungotchar != -1)
+       {
+               bp->data[bp->datasize] = ch_ungotchar;
+               n = 1;
+               ch_ungotchar = -1;
+       } else if (ch_flags & CH_HELPFILE)
+       {
+               bp->data[bp->datasize] = helpdata[ch_fpos];
+               n = 1;
+       } else
+       {
+               n = iread(ch_file, &bp->data[bp->datasize], 
+                       (unsigned int)(LBUFSIZE - bp->datasize));
+       }
+
+       if (n == READ_INTR)
+               return (EOI);
+       if (n < 0)
+       {
+#if MSDOS_COMPILER==WIN32C
+               if (errno != EPIPE)
+#endif
+               {
+                       error("read error", NULL_PARG);
+                       clear_eol();
+               }
+               n = 0;
+       }
+
+#if LOGFILE
+       /*
+        * If we have a log file, write the new data to it.
+        */
+       if (!secure && logfile >= 0 && n > 0)
+               write(logfile, (char *) &bp->data[bp->datasize], n);
+#endif
+
+       ch_fpos += n;
+       bp->datasize += n;
+
+       /*
+        * If we have read to end of file, set ch_fsize to indicate
+        * the position of the end of file.
+        */
+       if (n == 0)
+       {
+               ch_fsize = pos;
+               if (ignore_eoi)
+               {
+                       /*
+                        * We are ignoring EOF.
+                        * Wait a while, then try again.
+                        */
+                       if (!slept)
+                       {
+                               PARG parg;
+                               parg.p_string = wait_message();
+                               ierror("%s", &parg);
+                       }
+#if !MSDOS_COMPILER
+                       sleep(1);
+#else
+#if MSDOS_COMPILER==WIN32C
+                       Sleep(1000);
+#endif
+#endif
+                       slept = TRUE;
+
+#if HAVE_STAT_INO
+                       if (follow_mode == FOLLOW_NAME)
+                       {
+                               /* See whether the file's i-number has changed.
+                                * If so, force the file to be closed and
+                                * reopened. */
+                               struct stat st;
+                               int r = stat(get_filename(curr_ifile), &st);
+                               if (r == 0 && (st.st_ino != curr_ino ||
+                                       st.st_dev != curr_dev))
+                               {
+                                       /* screen_trashed=2 causes
+                                        * make_display to reopen the file. */
+                                       screen_trashed = 2;
+                                       return (EOI);
+                               }
+                       }
+#endif
+               }
+               if (sigs)
+                       return (EOI);
+       }
+
+    found:
+       if (ch_bufhead != bn)
+       {
+               /*
+                * Move the buffer to the head of the buffer chain.
+                * This orders the buffer chain, most- to least-recently used.
+                */
+               BUF_RM(bn);
+               BUF_INS_HEAD(bn);
+
+               /*
+                * Move to head of hash chain too.
+                */
+               BUF_HASH_RM(bn);
+               BUF_HASH_INS(bn, h);
+       }
+
+       if (ch_offset >= bp->datasize)
+               /*
+                * After all that, we still don't have enough data.
+                * Go back and try again.
+                */
+               goto read_more;
+
+       return (bp->data[ch_offset]);
+}
+
+/*
+ * ch_ungetchar is a rather kludgy and limited way to push 
+ * a single char onto an input file descriptor.
+ */
+       public void
+ch_ungetchar(c)
+       int c;
+{
+       if (c != -1 && ch_ungotchar != -1)
+               error("ch_ungetchar overrun", NULL_PARG);
+       ch_ungotchar = c;
+}
+
+#if LOGFILE
+/*
+ * Close the logfile.
+ * If we haven't read all of standard input into it, do that now.
+ */
+       public void
+end_logfile()
+{
+       static int tried = FALSE;
+
+       if (logfile < 0)
+               return;
+       if (!tried && ch_fsize == NULL_POSITION)
+       {
+               tried = TRUE;
+               ierror("Finishing logfile", NULL_PARG);
+               while (ch_forw_get() != EOI)
+                       if (ABORT_SIGS())
+                               break;
+       }
+       close(logfile);
+       logfile = -1;
+       namelogfile = NULL;
+}
+
+/*
+ * Start a log file AFTER less has already been running.
+ * Invoked from the - command; see toggle_option().
+ * Write all the existing buffered data to the log file.
+ */
+       public void
+sync_logfile()
+{
+       register struct buf *bp;
+       register struct bufnode *bn;
+       int warned = FALSE;
+       BLOCKNUM block;
+       BLOCKNUM nblocks;
+
+       nblocks = (ch_fpos + LBUFSIZE - 1) / LBUFSIZE;
+       for (block = 0;  block < nblocks;  block++)
+       {
+               int wrote = FALSE;
+               FOR_BUFS(bn)
+               {
+                       bp = bufnode_buf(bn);
+                       if (bp->block == block)
+                       {
+                               write(logfile, (char *) bp->data, bp->datasize);
+                               wrote = TRUE;
+                               break;
+                       }
+               }
+               if (!wrote && !warned)
+               {
+                       error("Warning: log file is incomplete",
+                               NULL_PARG);
+                       warned = TRUE;
+               }
+       }
+}
+
+#endif
+
+/*
+ * Determine if a specific block is currently in one of the buffers.
+ */
+       static int
+buffered(block)
+       BLOCKNUM block;
+{
+       register struct buf *bp;
+       register struct bufnode *bn;
+       register int h;
+
+       h = BUFHASH(block);
+       FOR_BUFS_IN_CHAIN(h, bn)
+       {
+               bp = bufnode_buf(bn);
+               if (bp->block == block)
+                       return (TRUE);
+       }
+       return (FALSE);
+}
+
+/*
+ * Seek to a specified position in the file.
+ * Return 0 if successful, non-zero if can't seek there.
+ */
+       public int
+ch_seek(pos)
+       register POSITION pos;
+{
+       BLOCKNUM new_block;
+       POSITION len;
+
+       if (thisfile == NULL)
+               return (0);
+
+       len = ch_length();
+       if (pos < ch_zero() || (len != NULL_POSITION && pos > len))
+               return (1);
+
+       new_block = pos / LBUFSIZE;
+       if (!(ch_flags & CH_CANSEEK) && pos != ch_fpos && !buffered(new_block))
+       {
+               if (ch_fpos > pos)
+                       return (1);
+               while (ch_fpos < pos)
+               {
+                       if (ch_forw_get() == EOI)
+                               return (1);
+                       if (ABORT_SIGS())
+                               return (1);
+               }
+               return (0);
+       }
+       /*
+        * Set read pointer.
+        */
+       ch_block = new_block;
+       ch_offset = pos % LBUFSIZE;
+       return (0);
+}
+
+/*
+ * Seek to the end of the file.
+ */
+       public int
+ch_end_seek()
+{
+       POSITION len;
+
+       if (thisfile == NULL)
+               return (0);
+
+       if (ch_flags & CH_CANSEEK)
+               ch_fsize = filesize(ch_file);
+
+       len = ch_length();
+       if (len != NULL_POSITION)
+               return (ch_seek(len));
+
+       /*
+        * Do it the slow way: read till end of data.
+        */
+       while (ch_forw_get() != EOI)
+               if (ABORT_SIGS())
+                       return (1);
+       return (0);
+}
+
+/*
+ * Seek to the beginning of the file, or as close to it as we can get.
+ * We may not be able to seek there if input is a pipe and the
+ * beginning of the pipe is no longer buffered.
+ */
+       public int
+ch_beg_seek()
+{
+       register struct bufnode *bn;
+       register struct bufnode *firstbn;
+
+       /*
+        * Try a plain ch_seek first.
+        */
+       if (ch_seek(ch_zero()) == 0)
+               return (0);
+
+       /*
+        * Can't get to position 0.
+        * Look thru the buffers for the one closest to position 0.
+        */
+       firstbn = ch_bufhead;
+       if (firstbn == END_OF_CHAIN)
+               return (1);
+       FOR_BUFS(bn)
+       {
+               if (bufnode_buf(bn)->block < bufnode_buf(firstbn)->block)
+                       firstbn = bn;
+       }
+       ch_block = bufnode_buf(firstbn)->block;
+       ch_offset = 0;
+       return (0);
+}
+
+/*
+ * Return the length of the file, if known.
+ */
+       public POSITION
+ch_length()
+{
+       if (thisfile == NULL)
+               return (NULL_POSITION);
+       if (ignore_eoi)
+               return (NULL_POSITION);
+       if (ch_flags & CH_HELPFILE)
+               return (size_helpdata);
+       return (ch_fsize);
+}
+
+/*
+ * Return the current position in the file.
+ */
+       public POSITION
+ch_tell()
+{
+       if (thisfile == NULL)
+               return (NULL_POSITION);
+       return (ch_block * LBUFSIZE) + ch_offset;
+}
+
+/*
+ * Get the current char and post-increment the read pointer.
+ */
+       public int
+ch_forw_get()
+{
+       register int c;
+
+       if (thisfile == NULL)
+               return (EOI);
+       c = ch_get();
+       if (c == EOI)
+               return (EOI);
+       if (ch_offset < LBUFSIZE-1)
+               ch_offset++;
+       else
+       {
+               ch_block ++;
+               ch_offset = 0;
+       }
+       return (c);
+}
+
+/*
+ * Pre-decrement the read pointer and get the new current char.
+ */
+       public int
+ch_back_get()
+{
+       if (thisfile == NULL)
+               return (EOI);
+       if (ch_offset > 0)
+               ch_offset --;
+       else
+       {
+               if (ch_block <= 0)
+                       return (EOI);
+               if (!(ch_flags & CH_CANSEEK) && !buffered(ch_block-1))
+                       return (EOI);
+               ch_block--;
+               ch_offset = LBUFSIZE-1;
+       }
+       return (ch_get());
+}
+
+/*
+ * Set max amount of buffer space.
+ * bufspace is in units of 1024 bytes.  -1 mean no limit.
+ */
+       public void
+ch_setbufspace(bufspace)
+       int bufspace;
+{
+       if (bufspace < 0)
+               maxbufs = -1;
+       else
+       {
+               maxbufs = ((bufspace * 1024) + LBUFSIZE-1) / LBUFSIZE;
+               if (maxbufs < 1)
+                       maxbufs = 1;
+       }
+}
+
+/*
+ * Flush (discard) any saved file state, including buffer contents.
+ */
+       public void
+ch_flush()
+{
+       register struct bufnode *bn;
+
+       if (thisfile == NULL)
+               return;
+
+       if (!(ch_flags & CH_CANSEEK))
+       {
+               /*
+                * If input is a pipe, we don't flush buffer contents,
+                * since the contents can't be recovered.
+                */
+               ch_fsize = NULL_POSITION;
+               return;
+       }
+
+       /*
+        * Initialize all the buffers.
+        */
+       FOR_BUFS(bn)
+       {
+               bufnode_buf(bn)->block = -1;
+       }
+
+       /*
+        * Figure out the size of the file, if we can.
+        */
+       ch_fsize = filesize(ch_file);
+
+       /*
+        * Seek to a known position: the beginning of the file.
+        */
+       ch_fpos = 0;
+       ch_block = 0; /* ch_fpos / LBUFSIZE; */
+       ch_offset = 0; /* ch_fpos % LBUFSIZE; */
+
+#if 1
+       /*
+        * This is a kludge to workaround a Linux kernel bug: files in
+        * /proc have a size of 0 according to fstat() but have readable 
+        * data.  They are sometimes, but not always, seekable.
+        * Force them to be non-seekable here.
+        */
+       if (ch_fsize == 0)
+       {
+               ch_fsize = NULL_POSITION;
+               ch_flags &= ~CH_CANSEEK;
+       }
+#endif
+
+       if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
+       {
+               /*
+                * Warning only; even if the seek fails for some reason,
+                * there's a good chance we're at the beginning anyway.
+                * {{ I think this is bogus reasoning. }}
+                */
+               error("seek error to 0", NULL_PARG);
+       }
+}
+
+/*
+ * Allocate a new buffer.
+ * The buffer is added to the tail of the buffer chain.
+ */
+       static int
+ch_addbuf()
+{
+       register struct buf *bp;
+       register struct bufnode *bn;
+
+       /*
+        * Allocate and initialize a new buffer and link it 
+        * onto the tail of the buffer list.
+        */
+       bp = (struct buf *) calloc(1, sizeof(struct buf));
+       if (bp == NULL)
+               return (1);
+       ch_nbufs++;
+       bp->block = -1;
+       bn = &bp->node;
+
+       BUF_INS_TAIL(bn);
+       BUF_HASH_INS(bn, 0);
+       return (0);
+}
+
+/*
+ *
+ */
+       static void
+init_hashtbl()
+{
+       register int h;
+
+       for (h = 0;  h < BUFHASH_SIZE;  h++)
+       {
+               thisfile->hashtbl[h].hnext = END_OF_HCHAIN(h);
+               thisfile->hashtbl[h].hprev = END_OF_HCHAIN(h);
+       }
+}
+
+/*
+ * Delete all buffers for this file.
+ */
+       static void
+ch_delbufs()
+{
+       register struct bufnode *bn;
+
+       while (ch_bufhead != END_OF_CHAIN)
+       {
+               bn = ch_bufhead;
+               BUF_RM(bn);
+               free(bufnode_buf(bn));
+       }
+       ch_nbufs = 0;
+       init_hashtbl();
+}
+
+/*
+ * Is it possible to seek on a file descriptor?
+ */
+       public int
+seekable(f)
+       int f;
+{
+#if MSDOS_COMPILER
+       extern int fd0;
+       if (f == fd0 && !isatty(fd0))
+       {
+               /*
+                * In MS-DOS, pipes are seekable.  Check for
+                * standard input, and pretend it is not seekable.
+                */
+               return (0);
+       }
+#endif
+       return (lseek(f, (off_t)1, SEEK_SET) != BAD_LSEEK);
+}
+
+/*
+ * Initialize file state for a new file.
+ */
+       public void
+ch_init(f, flags)
+       int f;
+       int flags;
+{
+       /*
+        * See if we already have a filestate for this file.
+        */
+       thisfile = (struct filestate *) get_filestate(curr_ifile);
+       if (thisfile == NULL)
+       {
+               /*
+                * Allocate and initialize a new filestate.
+                */
+               thisfile = (struct filestate *) 
+                               calloc(1, sizeof(struct filestate));
+               thisfile->buflist.next = thisfile->buflist.prev = END_OF_CHAIN;
+               thisfile->nbufs = 0;
+               thisfile->flags = 0;
+               thisfile->fpos = 0;
+               thisfile->block = 0;
+               thisfile->offset = 0;
+               thisfile->file = -1;
+               thisfile->fsize = NULL_POSITION;
+               ch_flags = flags;
+               init_hashtbl();
+               /*
+                * Try to seek; set CH_CANSEEK if it works.
+                */
+               if ((flags & CH_CANSEEK) && !seekable(f))
+                       ch_flags &= ~CH_CANSEEK;
+               set_filestate(curr_ifile, (void *) thisfile);
+       }
+       if (thisfile->file == -1)
+               thisfile->file = f;
+       ch_flush();
+}
+
+/*
+ * Close a filestate.
+ */
+       public void
+ch_close()
+{
+       int keepstate = FALSE;
+
+       if (thisfile == NULL)
+               return;
+
+       if (ch_flags & (CH_CANSEEK|CH_POPENED|CH_HELPFILE))
+       {
+               /*
+                * We can seek or re-open, so we don't need to keep buffers.
+                */
+               ch_delbufs();
+       } else
+               keepstate = TRUE;
+       if (!(ch_flags & CH_KEEPOPEN))
+       {
+               /*
+                * We don't need to keep the file descriptor open
+                * (because we can re-open it.)
+                * But don't really close it if it was opened via popen(),
+                * because pclose() wants to close it.
+                */
+               if (!(ch_flags & (CH_POPENED|CH_HELPFILE)))
+                       close(ch_file);
+               ch_file = -1;
+       } else
+               keepstate = TRUE;
+       if (!keepstate)
+       {
+               /*
+                * We don't even need to keep the filestate structure.
+                */
+               free(thisfile);
+               thisfile = NULL;
+               set_filestate(curr_ifile, (void *) NULL);
+       }
+}
+
+/*
+ * Return ch_flags for the current file.
+ */
+       public int
+ch_getflags()
+{
+       if (thisfile == NULL)
+               return (0);
+       return (ch_flags);
+}
+
+#if 0
+       public void
+ch_dump(struct filestate *fs)
+{
+       struct buf *bp;
+       struct bufnode *bn;
+       unsigned char *s;
+
+       if (fs == NULL)
+       {
+               printf(" --no filestate\n");
+               return;
+       }
+       printf(" file %d, flags %x, fpos %x, fsize %x, blk/off %x/%x\n",
+               fs->file, fs->flags, fs->fpos, 
+               fs->fsize, fs->block, fs->offset);
+       printf(" %d bufs:\n", fs->nbufs);
+       for (bn = fs->next; bn != &fs->buflist;  bn = bn->next)
+       {
+               bp = bufnode_buf(bn);
+               printf("%x: blk %x, size %x \"",
+                       bp, bp->block, bp->datasize);
+               for (s = bp->data;  s < bp->data + 30;  s++)
+                       if (*s >= ' ' && *s < 0x7F)
+                               printf("%c", *s);
+                       else
+                               printf(".");
+               printf("\"\n");
+       }
+}
+#endif
diff --git a/thirdparty/less/charset.c b/thirdparty/less/charset.c
new file mode 100644 (file)
index 0000000..12b59d6
--- /dev/null
@@ -0,0 +1,1173 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Functions to define the character set
+ * and do things specific to the character set.
+ */
+
+#include "less.h"
+#if HAVE_LOCALE
+#include <locale.h>
+#include <ctype.h>
+#include <langinfo.h>
+#endif
+
+#include "charset.h"
+
+public int utf_mode = 0;
+
+/*
+ * Predefined character sets,
+ * selected by the LESSCHARSET environment variable.
+ */
+struct charset {
+       char *name;
+       int *p_flag;
+       char *desc;
+} charsets[] = {
+       { "ascii",              NULL,       "8bcccbcc18b95.b" },
+       { "utf-8",              &utf_mode,  "8bcccbcc18b95.b126.bb" },
+       { "iso8859",            NULL,       "8bcccbcc18b95.33b." },
+       { "latin3",             NULL,       "8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
+       { "arabic",             NULL,       "8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
+       { "greek",              NULL,       "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
+       { "greek2005",          NULL,       "8bcccbcc18b95.33b14.b35.b44.b" },
+       { "hebrew",             NULL,       "8bcccbcc18b95.33b.b29.32b28.2b2.b" },
+       { "koi8-r",             NULL,       "8bcccbcc18b95.b." },
+       { "KOI8-T",             NULL,       "8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
+       { "georgianps",         NULL,       "8bcccbcc18b95.3b11.4b12.2b." },
+       { "tcvn",               NULL,       "b..b...bcccbccbbb7.8b95.b48.5b." },
+       { "TIS-620",            NULL,       "8bcccbcc18b95.b.4b.11b7.8b." },
+       { "next",               NULL,       "8bcccbcc18b95.bb125.bb" },
+       { "dos",                NULL,       "8bcccbcc12bc5b95.b." },
+       { "windows-1251",       NULL,       "8bcccbcc12bc5b95.b24.b." },
+       { "windows-1252",       NULL,       "8bcccbcc12bc5b95.b.b11.b.2b12.b." },
+       { "windows-1255",       NULL,       "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." },
+       { "ebcdic",             NULL,       "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
+       { "IBM-1047",           NULL,       "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
+       { NULL, NULL, NULL }
+};
+
+/*
+ * Support "locale charmap"/nl_langinfo(CODESET) values, as well as others.
+ */
+struct cs_alias {
+       char *name;
+       char *oname;
+} cs_aliases[] = {
+       { "UTF-8",              "utf-8" },
+       { "ANSI_X3.4-1968",     "ascii" },
+       { "US-ASCII",           "ascii" },
+       { "latin1",             "iso8859" },
+       { "ISO-8859-1",         "iso8859" },
+       { "latin9",             "iso8859" },
+       { "ISO-8859-15",        "iso8859" },
+       { "latin2",             "iso8859" },
+       { "ISO-8859-2",         "iso8859" },
+       { "ISO-8859-3",         "latin3" },
+       { "latin4",             "iso8859" },
+       { "ISO-8859-4",         "iso8859" },
+       { "cyrillic",           "iso8859" },
+       { "ISO-8859-5",         "iso8859" },
+       { "ISO-8859-6",         "arabic" },
+       { "ISO-8859-7",         "greek" },
+       { "IBM9005",            "greek2005" },
+       { "ISO-8859-8",         "hebrew" },
+       { "latin5",             "iso8859" },
+       { "ISO-8859-9",         "iso8859" },
+       { "latin6",             "iso8859" },
+       { "ISO-8859-10",        "iso8859" },
+       { "latin7",             "iso8859" },
+       { "ISO-8859-13",        "iso8859" },
+       { "latin8",             "iso8859" },
+       { "ISO-8859-14",        "iso8859" },
+       { "latin10",            "iso8859" },
+       { "ISO-8859-16",        "iso8859" },
+       { "IBM437",             "dos" },
+       { "EBCDIC-US",          "ebcdic" },
+       { "IBM1047",            "IBM-1047" },
+       { "KOI8-R",             "koi8-r" },
+       { "KOI8-U",             "koi8-r" },
+       { "GEORGIAN-PS",        "georgianps" },
+       { "TCVN5712-1",         "tcvn" },
+       { "NEXTSTEP",           "next" },
+       { "windows",            "windows-1252" }, /* backward compatibility */
+       { "CP1251",             "windows-1251" },
+       { "CP1252",             "windows-1252" },
+       { "CP1255",             "windows-1255" },
+       { NULL, NULL }
+};
+
+#define        IS_BINARY_CHAR  01
+#define        IS_CONTROL_CHAR 02
+
+static char chardef[256];
+static char *binfmt = NULL;
+static char *utfbinfmt = NULL;
+public int binattr = AT_STANDOUT;
+
+
+/*
+ * Define a charset, given a description string.
+ * The string consists of 256 letters,
+ * one for each character in the charset.
+ * If the string is shorter than 256 letters, missing letters
+ * are taken to be identical to the last one.
+ * A decimal number followed by a letter is taken to be a 
+ * repetition of the letter.
+ *
+ * Each letter is one of:
+ *     . normal character
+ *     b binary character
+ *     c control character
+ */
+       static void
+ichardef(s)
+       char *s;
+{
+       register char *cp;
+       register int n;
+       register char v;
+
+       n = 0;
+       v = 0;
+       cp = chardef;
+       while (*s != '\0')
+       {
+               switch (*s++)
+               {
+               case '.':
+                       v = 0;
+                       break;
+               case 'c':
+                       v = IS_CONTROL_CHAR;
+                       break;
+               case 'b':
+                       v = IS_BINARY_CHAR|IS_CONTROL_CHAR;
+                       break;
+
+               case '0': case '1': case '2': case '3': case '4':
+               case '5': case '6': case '7': case '8': case '9':
+                       n = (10 * n) + (s[-1] - '0');
+                       continue;
+
+               default:
+                       error("invalid chardef", NULL_PARG);
+                       quit(QUIT_ERROR);
+                       /*NOTREACHED*/
+               }
+
+               do
+               {
+                       if (cp >= chardef + sizeof(chardef))
+                       {
+                               error("chardef longer than 256", NULL_PARG);
+                               quit(QUIT_ERROR);
+                               /*NOTREACHED*/
+                       }
+                       *cp++ = v;
+               } while (--n > 0);
+               n = 0;
+       }
+
+       while (cp < chardef + sizeof(chardef))
+               *cp++ = v;
+}
+
+/*
+ * Define a charset, given a charset name.
+ * The valid charset names are listed in the "charsets" array.
+ */
+       static int
+icharset(name, no_error)
+       register char *name;
+       int no_error;
+{
+       register struct charset *p;
+       register struct cs_alias *a;
+
+       if (name == NULL || *name == '\0')
+               return (0);
+
+       /* First see if the name is an alias. */
+       for (a = cs_aliases;  a->name != NULL;  a++)
+       {
+               if (strcmp(name, a->name) == 0)
+               {
+                       name = a->oname;
+                       break;
+               }
+       }
+
+       for (p = charsets;  p->name != NULL;  p++)
+       {
+               if (strcmp(name, p->name) == 0)
+               {
+                       ichardef(p->desc);
+                       if (p->p_flag != NULL)
+                               *(p->p_flag) = 1;
+                       return (1);
+               }
+       }
+
+       if (!no_error) {
+               error("invalid charset name", NULL_PARG);
+               quit(QUIT_ERROR);
+       }
+       return (0);
+}
+
+#if HAVE_LOCALE
+/*
+ * Define a charset, given a locale name.
+ */
+       static void
+ilocale()
+{
+       register int c;
+
+       for (c = 0;  c < (int) sizeof(chardef);  c++)
+       {
+               if (isprint(c))
+                       chardef[c] = 0;
+               else if (iscntrl(c))
+                       chardef[c] = IS_CONTROL_CHAR;
+               else
+                       chardef[c] = IS_BINARY_CHAR|IS_CONTROL_CHAR;
+       }
+}
+#endif
+
+/*
+ * Define the printing format for control (or binary utf) chars.
+ */
+       static void
+setbinfmt(s, fmtvarptr, default_fmt)
+       char *s;
+       char **fmtvarptr;
+       char *default_fmt;
+{
+       if (s && utf_mode)
+       {
+               /* It would be too hard to account for width otherwise.  */
+               char *t = s;
+               while (*t)
+               {
+                       if (*t < ' ' || *t > '~')
+                       {
+                               s = default_fmt;
+                               goto attr;
+                       }
+                       t++;
+               }
+       }
+
+       /* %n is evil */
+       if (s == NULL || *s == '\0' ||
+           (*s == '*' && (s[1] == '\0' || s[2] == '\0' || strchr(s + 2, 'n'))) ||
+           (*s != '*' && strchr(s, 'n')))
+               s = default_fmt;
+
+       /*
+        * Select the attributes if it starts with "*".
+        */
+ attr:
+       if (*s == '*')
+       {
+               switch (s[1])
+               {
+               case 'd':  binattr = AT_BOLD;      break;
+               case 'k':  binattr = AT_BLINK;     break;
+               case 's':  binattr = AT_STANDOUT;  break;
+               case 'u':  binattr = AT_UNDERLINE; break;
+               default:   binattr = AT_NORMAL;    break;
+               }
+               s += 2;
+       }
+       *fmtvarptr = s;
+}
+
+/*
+ *
+ */
+       static void
+set_charset()
+{
+       char *s;
+
+       /*
+        * See if environment variable LESSCHARSET is defined.
+        */
+       s = lgetenv("LESSCHARSET");
+       if (icharset(s, 0))
+               return;
+
+       /*
+        * LESSCHARSET is not defined: try LESSCHARDEF.
+        */
+       s = lgetenv("LESSCHARDEF");
+       if (s != NULL && *s != '\0')
+       {
+               ichardef(s);
+               return;
+       }
+
+#if HAVE_LOCALE
+#ifdef CODESET
+       /*
+        * Try using the codeset name as the charset name.
+        */
+       s = nl_langinfo(CODESET);
+       if (icharset(s, 1))
+               return;
+#endif
+#endif
+
+#if HAVE_STRSTR
+       /*
+        * Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used.
+        */
+       if ((s = lgetenv("LC_ALL")) != NULL ||
+           (s = lgetenv("LC_CTYPE")) != NULL ||
+           (s = lgetenv("LANG")) != NULL)
+       {
+               if (   strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL
+                   || strstr(s, "UTF8")  != NULL || strstr(s, "utf8")  != NULL)
+                       if (icharset("utf-8", 1))
+                               return;
+       }
+#endif
+
+#if HAVE_LOCALE
+       /*
+        * Get character definitions from locale functions,
+        * rather than from predefined charset entry.
+        */
+       ilocale();
+#if MSDOS_COMPILER
+       /*
+        * Default to "dos".
+        */
+       (void) icharset("dos", 1);
+#else
+       /*
+        * Default to "latin1".
+        */
+       (void) icharset("latin1", 1);
+#endif
+#endif
+}
+
+/*
+ * Initialize charset data structures.
+ */
+       public void
+init_charset()
+{
+       char *s;
+
+#if HAVE_LOCALE
+       setlocale(LC_ALL, "");
+#endif
+
+       set_charset();
+
+       s = lgetenv("LESSBINFMT");
+       setbinfmt(s, &binfmt, "*s<%02X>");
+       
+       s = lgetenv("LESSUTFBINFMT");
+       setbinfmt(s, &utfbinfmt, "<U+%04lX>");
+}
+
+/*
+ * Is a given character a "binary" character?
+ */
+       public int
+binary_char(c)
+       LWCHAR c;
+{
+       if (utf_mode)
+               return (is_ubin_char(c));
+       c &= 0377;
+       return (chardef[c] & IS_BINARY_CHAR);
+}
+
+/*
+ * Is a given character a "control" character?
+ */
+       public int
+control_char(c)
+       LWCHAR c;
+{
+       c &= 0377;
+       return (chardef[c] & IS_CONTROL_CHAR);
+}
+
+/*
+ * Return the printable form of a character.
+ * For example, in the "ascii" charset '\3' is printed as "^C".
+ */
+       public char *
+prchar(c)
+       LWCHAR c;
+{
+       /* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
+       static char buf[32];
+
+       c &= 0377;
+       if ((c < 128 || !utf_mode) && !control_char(c))
+               SNPRINTF1(buf, sizeof(buf), "%c", (int) c);
+       else if (c == ESC)
+               strcpy(buf, "ESC");
+#if IS_EBCDIC_HOST
+       else if (!binary_char(c) && c < 64)
+               SNPRINTF1(buf, sizeof(buf), "^%c",
+               /*
+                * This array roughly inverts CONTROL() #defined in less.h,
+                * and should be kept in sync with CONTROL() and IBM-1047.
+                */
+               "@ABC.I.?...KLMNO"
+               "PQRS.JH.XY.."
+               "\\]^_"
+               "......W[.....EFG"
+               "..V....D....TU.Z"[c]);
+#else
+       else if (c < 128 && !control_char(c ^ 0100))
+               SNPRINTF1(buf, sizeof(buf), "^%c", (int) (c ^ 0100));
+#endif
+       else
+               SNPRINTF1(buf, sizeof(buf), binfmt, c);
+       return (buf);
+}
+
+/*
+ * Return the printable form of a UTF-8 character.
+ */
+       public char *
+prutfchar(ch)
+       LWCHAR ch;
+{
+       static char buf[32];
+
+       if (ch == ESC)
+               strcpy(buf, "ESC");
+       else if (ch < 128 && control_char(ch))
+       {
+               if (!control_char(ch ^ 0100))
+                       SNPRINTF1(buf, sizeof(buf), "^%c", ((char) ch) ^ 0100);
+               else
+                       SNPRINTF1(buf, sizeof(buf), binfmt, (char) ch);
+       } else if (is_ubin_char(ch))
+               SNPRINTF1(buf, sizeof(buf), utfbinfmt, ch);
+       else
+       {
+               int len;
+               if (ch >= 0x80000000)
+               {
+                       len = 3;
+                       ch = 0xFFFD;
+               } else
+               {
+                       len =   (ch < 0x80) ? 1
+                             : (ch < 0x800) ? 2
+                             : (ch < 0x10000) ? 3
+                             : (ch < 0x200000) ? 4
+                             : (ch < 0x4000000) ? 5
+                             : 6;
+               }
+               buf[len] = '\0';
+               if (len == 1)
+                       *buf = (char) ch;
+               else
+               {
+                       *buf = ((1 << len) - 1) << (8 - len);
+                       while (--len > 0)
+                       {
+                               buf[len] = (char) (0x80 | (ch & 0x3F));
+                               ch >>= 6;
+                       }
+                       *buf |= ch;
+               }
+       }
+       return (buf);
+}
+
+/*
+ * Get the length of a UTF-8 character in bytes.
+ */
+       public int
+utf_len(ch)
+       char ch;
+{
+       if ((ch & 0x80) == 0)
+               return 1;
+       if ((ch & 0xE0) == 0xC0)
+               return 2;
+       if ((ch & 0xF0) == 0xE0)
+               return 3;
+       if ((ch & 0xF8) == 0xF0)
+               return 4;
+       if ((ch & 0xFC) == 0xF8)
+               return 5;
+       if ((ch & 0xFE) == 0xFC)
+               return 6;
+       /* Invalid UTF-8 encoding. */
+       return 1;
+}
+
+/*
+ * Is a UTF-8 character well-formed?
+ */
+       public int
+is_utf8_well_formed(s)
+       unsigned char *s;
+{
+       int i;
+       int len;
+
+       if (IS_UTF8_INVALID(s[0]))
+               return (0);
+
+       len = utf_len((char) s[0]);
+       if (len == 1)
+               return (1);
+       if (len == 2)
+       {
+               if (s[0] < 0xC2)
+                   return (0);
+       } else
+       {
+               unsigned char mask;
+               mask = (~((1 << (8-len)) - 1)) & 0xFF;
+               if (s[0] == mask && (s[1] & mask) == 0x80)
+                       return (0);
+       }
+
+       for (i = 1;  i < len;  i++)
+               if (!IS_UTF8_TRAIL(s[i]))
+                       return (0);
+       return (1);
+}
+
+/*
+ * Get the value of a UTF-8 character.
+ */
+       public LWCHAR
+get_wchar(p)
+       char *p;
+{
+       switch (utf_len(p[0]))
+       {
+       case 1:
+       default:
+               /* 0xxxxxxx */
+               return (LWCHAR)
+                       (p[0] & 0xFF);
+       case 2:
+               /* 110xxxxx 10xxxxxx */
+               return (LWCHAR) (
+                       ((p[0] & 0x1F) << 6) |
+                       (p[1] & 0x3F));
+       case 3:
+               /* 1110xxxx 10xxxxxx 10xxxxxx */
+               return (LWCHAR) (
+                       ((p[0] & 0x0F) << 12) |
+                       ((p[1] & 0x3F) << 6) |
+                       (p[2] & 0x3F));
+       case 4:
+               /* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
+               return (LWCHAR) (
+                       ((p[0] & 0x07) << 18) |
+                       ((p[1] & 0x3F) << 12) | 
+                       ((p[2] & 0x3F) << 6) | 
+                       (p[3] & 0x3F));
+       case 5:
+               /* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+               return (LWCHAR) (
+                       ((p[0] & 0x03) << 24) |
+                       ((p[1] & 0x3F) << 18) | 
+                       ((p[2] & 0x3F) << 12) | 
+                       ((p[3] & 0x3F) << 6) | 
+                       (p[4] & 0x3F));
+       case 6:
+               /* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+               return (LWCHAR) (
+                       ((p[0] & 0x01) << 30) |
+                       ((p[1] & 0x3F) << 24) | 
+                       ((p[2] & 0x3F) << 18) | 
+                       ((p[3] & 0x3F) << 12) | 
+                       ((p[4] & 0x3F) << 6) | 
+                       (p[5] & 0x3F));
+       }
+}
+
+/*
+ * Store a character into a UTF-8 string.
+ */
+       public void
+put_wchar(pp, ch)
+       char **pp;
+       LWCHAR ch;
+{
+       if (!utf_mode || ch < 0x80) 
+       {
+               /* 0xxxxxxx */
+               *(*pp)++ = (char) ch;
+       } else if (ch < 0x800)
+       {
+               /* 110xxxxx 10xxxxxx */
+               *(*pp)++ = (char) (0xC0 | ((ch >> 6) & 0x1F));
+               *(*pp)++ = (char) (0x80 | (ch & 0x3F));
+       } else if (ch < 0x10000)
+       {
+               /* 1110xxxx 10xxxxxx 10xxxxxx */
+               *(*pp)++ = (char) (0xE0 | ((ch >> 12) & 0x0F));
+               *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
+               *(*pp)++ = (char) (0x80 | (ch & 0x3F));
+       } else if (ch < 0x200000)
+       {
+               /* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
+               *(*pp)++ = (char) (0xF0 | ((ch >> 18) & 0x07));
+               *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
+               *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
+               *(*pp)++ = (char) (0x80 | (ch & 0x3F));
+       } else if (ch < 0x4000000)
+       {
+               /* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+               *(*pp)++ = (char) (0xF0 | ((ch >> 24) & 0x03));
+               *(*pp)++ = (char) (0x80 | ((ch >> 18) & 0x3F));
+               *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
+               *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
+               *(*pp)++ = (char) (0x80 | (ch & 0x3F));
+       } else 
+       {
+               /* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx */
+               *(*pp)++ = (char) (0xF0 | ((ch >> 30) & 0x01));
+               *(*pp)++ = (char) (0x80 | ((ch >> 24) & 0x3F));
+               *(*pp)++ = (char) (0x80 | ((ch >> 18) & 0x3F));
+               *(*pp)++ = (char) (0x80 | ((ch >> 12) & 0x3F));
+               *(*pp)++ = (char) (0x80 | ((ch >> 6) & 0x3F));
+               *(*pp)++ = (char) (0x80 | (ch & 0x3F));
+       }
+}
+
+/*
+ * Step forward or backward one character in a string.
+ */
+       public LWCHAR
+step_char(pp, dir, limit)
+       char **pp;
+       signed int dir;
+       char *limit;
+{
+       LWCHAR ch;
+       int len;
+       char *p = *pp;
+
+       if (!utf_mode)
+       {
+               /* It's easy if chars are one byte. */
+               if (dir > 0)
+                       ch = (LWCHAR) ((p < limit) ? *p++ : 0);
+               else
+                       ch = (LWCHAR) ((p > limit) ? *--p : 0);
+       } else if (dir > 0)
+       {
+               len = utf_len(*p);
+               if (p + len > limit)
+               {
+                       ch = 0;
+                       p = limit;
+               } else
+               {
+                       ch = get_wchar(p);
+                       p += len;
+               }
+       } else
+       {
+               while (p > limit && IS_UTF8_TRAIL(p[-1]))
+                       p--;
+               if (p > limit)
+                       ch = get_wchar(--p);
+               else
+                       ch = 0;
+       }
+       *pp = p;
+       return ch;
+}
+
+/*
+ * Unicode characters data
+ */
+struct wchar_range { LWCHAR first, last; };
+
+/*
+ * Characters with general category values
+ *     Mn: Mark, Nonspacing
+ *     Me: Mark, Enclosing
+ * Last synched with
+ *     <http://www.unicode.org/Public/5.0.0/ucd/UnicodeData-5.0.0d7.txt>
+ *     dated 2005-11-30T00:58:48Z
+ */
+static struct wchar_range comp_table[] = {
+       {  0x0300,  0x036F} /* Mn */, {  0x0483,  0x0486} /* Mn */,
+       {  0x0488,  0x0489} /* Me */,
+       {  0x0591,  0x05BD} /* Mn */, {  0x05BF,  0x05BF} /* Mn */,
+       {  0x05C1,  0x05C2} /* Mn */, {  0x05C4,  0x05C5} /* Mn */,
+       {  0x05C7,  0x05C7} /* Mn */, {  0x0610,  0x0615} /* Mn */,
+       {  0x064B,  0x065E} /* Mn */, {  0x0670,  0x0670} /* Mn */,
+       {  0x06D6,  0x06DC} /* Mn */,
+       {  0x06DE,  0x06DE} /* Me */,
+       {  0x06DF,  0x06E4} /* Mn */, {  0x06E7,  0x06E8} /* Mn */,
+       {  0x06EA,  0x06ED} /* Mn */, {  0x0711,  0x0711} /* Mn */,
+       {  0x0730,  0x074A} /* Mn */, {  0x07A6,  0x07B0} /* Mn */,
+       {  0x07EB,  0x07F3} /* Mn */, {  0x0901,  0x0902} /* Mn */,
+       {  0x093C,  0x093C} /* Mn */, {  0x0941,  0x0948} /* Mn */,
+       {  0x094D,  0x094D} /* Mn */, {  0x0951,  0x0954} /* Mn */,
+       {  0x0962,  0x0963} /* Mn */, {  0x0981,  0x0981} /* Mn */,
+       {  0x09BC,  0x09BC} /* Mn */, {  0x09C1,  0x09C4} /* Mn */,
+       {  0x09CD,  0x09CD} /* Mn */, {  0x09E2,  0x09E3} /* Mn */,
+       {  0x0A01,  0x0A02} /* Mn */, {  0x0A3C,  0x0A3C} /* Mn */,
+       {  0x0A41,  0x0A42} /* Mn */, {  0x0A47,  0x0A48} /* Mn */,
+       {  0x0A4B,  0x0A4D} /* Mn */, {  0x0A70,  0x0A71} /* Mn */,
+       {  0x0A81,  0x0A82} /* Mn */, {  0x0ABC,  0x0ABC} /* Mn */,
+       {  0x0AC1,  0x0AC5} /* Mn */, {  0x0AC7,  0x0AC8} /* Mn */,
+       {  0x0ACD,  0x0ACD} /* Mn */, {  0x0AE2,  0x0AE3} /* Mn */,
+       {  0x0B01,  0x0B01} /* Mn */, {  0x0B3C,  0x0B3C} /* Mn */,
+       {  0x0B3F,  0x0B3F} /* Mn */, {  0x0B41,  0x0B43} /* Mn */,
+       {  0x0B4D,  0x0B4D} /* Mn */, {  0x0B56,  0x0B56} /* Mn */,
+       {  0x0B82,  0x0B82} /* Mn */, {  0x0BC0,  0x0BC0} /* Mn */,
+       {  0x0BCD,  0x0BCD} /* Mn */, {  0x0C3E,  0x0C40} /* Mn */,
+       {  0x0C46,  0x0C48} /* Mn */, {  0x0C4A,  0x0C4D} /* Mn */,
+       {  0x0C55,  0x0C56} /* Mn */, {  0x0CBC,  0x0CBC} /* Mn */,
+       {  0x0CBF,  0x0CBF} /* Mn */, {  0x0CC6,  0x0CC6} /* Mn */,
+       {  0x0CCC,  0x0CCD} /* Mn */, {  0x0CE2,  0x0CE3} /* Mn */,
+       {  0x0D41,  0x0D43} /* Mn */, {  0x0D4D,  0x0D4D} /* Mn */,
+       {  0x0DCA,  0x0DCA} /* Mn */, {  0x0DD2,  0x0DD4} /* Mn */,
+       {  0x0DD6,  0x0DD6} /* Mn */, {  0x0E31,  0x0E31} /* Mn */,
+       {  0x0E34,  0x0E3A} /* Mn */, {  0x0E47,  0x0E4E} /* Mn */,
+       {  0x0EB1,  0x0EB1} /* Mn */, {  0x0EB4,  0x0EB9} /* Mn */,
+       {  0x0EBB,  0x0EBC} /* Mn */, {  0x0EC8,  0x0ECD} /* Mn */,
+       {  0x0F18,  0x0F19} /* Mn */, {  0x0F35,  0x0F35} /* Mn */,
+       {  0x0F37,  0x0F37} /* Mn */, {  0x0F39,  0x0F39} /* Mn */,
+       {  0x0F71,  0x0F7E} /* Mn */, {  0x0F80,  0x0F84} /* Mn */,
+       {  0x0F86,  0x0F87} /* Mn */, {  0x0F90,  0x0F97} /* Mn */,
+       {  0x0F99,  0x0FBC} /* Mn */, {  0x0FC6,  0x0FC6} /* Mn */,
+       {  0x102D,  0x1030} /* Mn */, {  0x1032,  0x1032} /* Mn */,
+       {  0x1036,  0x1037} /* Mn */, {  0x1039,  0x1039} /* Mn */,
+       {  0x1058,  0x1059} /* Mn */, {  0x135F,  0x135F} /* Mn */,
+       {  0x1712,  0x1714} /* Mn */, {  0x1732,  0x1734} /* Mn */,
+       {  0x1752,  0x1753} /* Mn */, {  0x1772,  0x1773} /* Mn */,
+       {  0x17B7,  0x17BD} /* Mn */, {  0x17C6,  0x17C6} /* Mn */,
+       {  0x17C9,  0x17D3} /* Mn */, {  0x17DD,  0x17DD} /* Mn */,
+       {  0x180B,  0x180D} /* Mn */, {  0x18A9,  0x18A9} /* Mn */,
+       {  0x1920,  0x1922} /* Mn */, {  0x1927,  0x1928} /* Mn */,
+       {  0x1932,  0x1932} /* Mn */, {  0x1939,  0x193B} /* Mn */,
+       {  0x1A17,  0x1A18} /* Mn */, {  0x1B00,  0x1B03} /* Mn */,
+       {  0x1B34,  0x1B34} /* Mn */, {  0x1B36,  0x1B3A} /* Mn */,
+       {  0x1B3C,  0x1B3C} /* Mn */, {  0x1B42,  0x1B42} /* Mn */,
+       {  0x1B6B,  0x1B73} /* Mn */, {  0x1DC0,  0x1DCA} /* Mn */,
+       {  0x1DFE,  0x1DFF} /* Mn */, {  0x20D0,  0x20DC} /* Mn */,
+       {  0x20DD,  0x20E0} /* Me */,
+       {  0x20E1,  0x20E1} /* Mn */,
+       {  0x20E2,  0x20E4} /* Me */,
+       {  0x20E5,  0x20EF} /* Mn */, {  0x302A,  0x302F} /* Mn */,
+       {  0x3099,  0x309A} /* Mn */, {  0xA806,  0xA806} /* Mn */,
+       {  0xA80B,  0xA80B} /* Mn */, {  0xA825,  0xA826} /* Mn */,
+       {  0xFB1E,  0xFB1E} /* Mn */, {  0xFE00,  0xFE0F} /* Mn */,
+       {  0xFE20,  0xFE23} /* Mn */, { 0x10A01, 0x10A03} /* Mn */,
+       { 0x10A05, 0x10A06} /* Mn */, { 0x10A0C, 0x10A0F} /* Mn */,
+       { 0x10A38, 0x10A3A} /* Mn */, { 0x10A3F, 0x10A3F} /* Mn */,
+       { 0x1D167, 0x1D169} /* Mn */, { 0x1D17B, 0x1D182} /* Mn */,
+       { 0x1D185, 0x1D18B} /* Mn */, { 0x1D1AA, 0x1D1AD} /* Mn */,
+       { 0x1D242, 0x1D244} /* Mn */, { 0xE0100, 0xE01EF} /* Mn */,
+};
+
+/*
+ * Special pairs, not ranges.
+ */
+static struct wchar_range comb_table[] = {
+       {0x0644,0x0622}, {0x0644,0x0623}, {0x0644,0x0625}, {0x0644,0x0627},
+};
+
+/*
+ * Characters with general category values
+ *     Cc: Other, Control
+ *     Cf: Other, Format
+ *     Cs: Other, Surrogate
+ *     Co: Other, Private Use
+ *     Cn: Other, Not Assigned
+ *     Zl: Separator, Line
+ *     Zp: Separator, Paragraph
+ * Last synched with
+ *     <http://www.unicode.org/Public/5.0.0/ucd/UnicodeData-5.0.0d7.txt>
+ *     dated 2005-11-30T00:58:48Z
+ */
+static struct wchar_range ubin_table[] = {
+       {  0x0000,  0x0007} /* Cc */, 
+       {  0x000B,  0x000C} /* Cc */, 
+       {  0x000E,  0x001A} /* Cc */, 
+       {  0x001C,  0x001F} /* Cc */, 
+       {  0x007F,  0x009F} /* Cc */,
+#if 0
+       {  0x00AD,  0x00AD} /* Cf */,
+#endif
+       {  0x0370,  0x0373} /* Cn */, {  0x0376,  0x0379} /* Cn */,
+       {  0x037F,  0x0383} /* Cn */, {  0x038B,  0x038B} /* Cn */,
+       {  0x038D,  0x038D} /* Cn */, {  0x03A2,  0x03A2} /* Cn */,
+       {  0x03CF,  0x03CF} /* Cn */, {  0x0487,  0x0487} /* Cn */,
+       {  0x0514,  0x0530} /* Cn */, {  0x0557,  0x0558} /* Cn */,
+       {  0x0560,  0x0560} /* Cn */, {  0x0588,  0x0588} /* Cn */,
+       {  0x058B,  0x0590} /* Cn */, {  0x05C8,  0x05CF} /* Cn */,
+       {  0x05EB,  0x05EF} /* Cn */, {  0x05F5,  0x05FF} /* Cn */,
+#if 0
+       {  0x0600,  0x0603} /* Cf */,
+#endif
+       {  0x0604,  0x060A} /* Cn */, {  0x0616,  0x061A} /* Cn */,
+       {  0x061C,  0x061D} /* Cn */, {  0x0620,  0x0620} /* Cn */,
+       {  0x063B,  0x063F} /* Cn */, {  0x065F,  0x065F} /* Cn */,
+#if 0
+       {  0x06DD,  0x06DD} /* Cf */,
+#endif
+       {  0x070E,  0x070E} /* Cn */,
+#if 0
+       {  0x070F,  0x070F} /* Cf */,
+#endif
+       {  0x074B,  0x074C} /* Cn */, {  0x076E,  0x077F} /* Cn */,
+       {  0x07B2,  0x07BF} /* Cn */, {  0x07FB,  0x0900} /* Cn */,
+       {  0x093A,  0x093B} /* Cn */, {  0x094E,  0x094F} /* Cn */,
+       {  0x0955,  0x0957} /* Cn */, {  0x0971,  0x097A} /* Cn */,
+       {  0x0980,  0x0980} /* Cn */, {  0x0984,  0x0984} /* Cn */,
+       {  0x098D,  0x098E} /* Cn */, {  0x0991,  0x0992} /* Cn */,
+       {  0x09A9,  0x09A9} /* Cn */, {  0x09B1,  0x09B1} /* Cn */,
+       {  0x09B3,  0x09B5} /* Cn */, {  0x09BA,  0x09BB} /* Cn */,
+       {  0x09C5,  0x09C6} /* Cn */, {  0x09C9,  0x09CA} /* Cn */,
+       {  0x09CF,  0x09D6} /* Cn */, {  0x09D8,  0x09DB} /* Cn */,
+       {  0x09DE,  0x09DE} /* Cn */, {  0x09E4,  0x09E5} /* Cn */,
+       {  0x09FB,  0x0A00} /* Cn */, {  0x0A04,  0x0A04} /* Cn */,
+       {  0x0A0B,  0x0A0E} /* Cn */, {  0x0A11,  0x0A12} /* Cn */,
+       {  0x0A29,  0x0A29} /* Cn */, {  0x0A31,  0x0A31} /* Cn */,
+       {  0x0A34,  0x0A34} /* Cn */, {  0x0A37,  0x0A37} /* Cn */,
+       {  0x0A3A,  0x0A3B} /* Cn */, {  0x0A3D,  0x0A3D} /* Cn */,
+       {  0x0A43,  0x0A46} /* Cn */, {  0x0A49,  0x0A4A} /* Cn */,
+       {  0x0A4E,  0x0A58} /* Cn */, {  0x0A5D,  0x0A5D} /* Cn */,
+       {  0x0A5F,  0x0A65} /* Cn */, {  0x0A75,  0x0A80} /* Cn */,
+       {  0x0A84,  0x0A84} /* Cn */, {  0x0A8E,  0x0A8E} /* Cn */,
+       {  0x0A92,  0x0A92} /* Cn */, {  0x0AA9,  0x0AA9} /* Cn */,
+       {  0x0AB1,  0x0AB1} /* Cn */, {  0x0AB4,  0x0AB4} /* Cn */,
+       {  0x0ABA,  0x0ABB} /* Cn */, {  0x0AC6,  0x0AC6} /* Cn */,
+       {  0x0ACA,  0x0ACA} /* Cn */, {  0x0ACE,  0x0ACF} /* Cn */,
+       {  0x0AD1,  0x0ADF} /* Cn */, {  0x0AE4,  0x0AE5} /* Cn */,
+       {  0x0AF0,  0x0AF0} /* Cn */, {  0x0AF2,  0x0B00} /* Cn */,
+       {  0x0B04,  0x0B04} /* Cn */, {  0x0B0D,  0x0B0E} /* Cn */,
+       {  0x0B11,  0x0B12} /* Cn */, {  0x0B29,  0x0B29} /* Cn */,
+       {  0x0B31,  0x0B31} /* Cn */, {  0x0B34,  0x0B34} /* Cn */,
+       {  0x0B3A,  0x0B3B} /* Cn */, {  0x0B44,  0x0B46} /* Cn */,
+       {  0x0B49,  0x0B4A} /* Cn */, {  0x0B4E,  0x0B55} /* Cn */,
+       {  0x0B58,  0x0B5B} /* Cn */, {  0x0B5E,  0x0B5E} /* Cn */,
+       {  0x0B62,  0x0B65} /* Cn */, {  0x0B72,  0x0B81} /* Cn */,
+       {  0x0B84,  0x0B84} /* Cn */, {  0x0B8B,  0x0B8D} /* Cn */,
+       {  0x0B91,  0x0B91} /* Cn */, {  0x0B96,  0x0B98} /* Cn */,
+       {  0x0B9B,  0x0B9B} /* Cn */, {  0x0B9D,  0x0B9D} /* Cn */,
+       {  0x0BA0,  0x0BA2} /* Cn */, {  0x0BA5,  0x0BA7} /* Cn */,
+       {  0x0BAB,  0x0BAD} /* Cn */, {  0x0BBA,  0x0BBD} /* Cn */,
+       {  0x0BC3,  0x0BC5} /* Cn */, {  0x0BC9,  0x0BC9} /* Cn */,
+       {  0x0BCE,  0x0BD6} /* Cn */, {  0x0BD8,  0x0BE5} /* Cn */,
+       {  0x0BFB,  0x0C00} /* Cn */, {  0x0C04,  0x0C04} /* Cn */,
+       {  0x0C0D,  0x0C0D} /* Cn */, {  0x0C11,  0x0C11} /* Cn */,
+       {  0x0C29,  0x0C29} /* Cn */, {  0x0C34,  0x0C34} /* Cn */,
+       {  0x0C3A,  0x0C3D} /* Cn */, {  0x0C45,  0x0C45} /* Cn */,
+       {  0x0C49,  0x0C49} /* Cn */, {  0x0C4E,  0x0C54} /* Cn */,
+       {  0x0C57,  0x0C5F} /* Cn */, {  0x0C62,  0x0C65} /* Cn */,
+       {  0x0C70,  0x0C81} /* Cn */, {  0x0C84,  0x0C84} /* Cn */,
+       {  0x0C8D,  0x0C8D} /* Cn */, {  0x0C91,  0x0C91} /* Cn */,
+       {  0x0CA9,  0x0CA9} /* Cn */, {  0x0CB4,  0x0CB4} /* Cn */,
+       {  0x0CBA,  0x0CBB} /* Cn */, {  0x0CC5,  0x0CC5} /* Cn */,
+       {  0x0CC9,  0x0CC9} /* Cn */, {  0x0CCE,  0x0CD4} /* Cn */,
+       {  0x0CD7,  0x0CDD} /* Cn */, {  0x0CDF,  0x0CDF} /* Cn */,
+       {  0x0CE4,  0x0CE5} /* Cn */, {  0x0CF0,  0x0CF0} /* Cn */,
+       {  0x0CF3,  0x0D01} /* Cn */, {  0x0D04,  0x0D04} /* Cn */,
+       {  0x0D0D,  0x0D0D} /* Cn */, {  0x0D11,  0x0D11} /* Cn */,
+       {  0x0D29,  0x0D29} /* Cn */, {  0x0D3A,  0x0D3D} /* Cn */,
+       {  0x0D44,  0x0D45} /* Cn */, {  0x0D49,  0x0D49} /* Cn */,
+       {  0x0D4E,  0x0D56} /* Cn */, {  0x0D58,  0x0D5F} /* Cn */,
+       {  0x0D62,  0x0D65} /* Cn */, {  0x0D70,  0x0D81} /* Cn */,
+       {  0x0D84,  0x0D84} /* Cn */, {  0x0D97,  0x0D99} /* Cn */,
+       {  0x0DB2,  0x0DB2} /* Cn */, {  0x0DBC,  0x0DBC} /* Cn */,
+       {  0x0DBE,  0x0DBF} /* Cn */, {  0x0DC7,  0x0DC9} /* Cn */,
+       {  0x0DCB,  0x0DCE} /* Cn */, {  0x0DD5,  0x0DD5} /* Cn */,
+       {  0x0DD7,  0x0DD7} /* Cn */, {  0x0DE0,  0x0DF1} /* Cn */,
+       {  0x0DF5,  0x0E00} /* Cn */, {  0x0E3B,  0x0E3E} /* Cn */,
+       {  0x0E5C,  0x0E80} /* Cn */, {  0x0E83,  0x0E83} /* Cn */,
+       {  0x0E85,  0x0E86} /* Cn */, {  0x0E89,  0x0E89} /* Cn */,
+       {  0x0E8B,  0x0E8C} /* Cn */, {  0x0E8E,  0x0E93} /* Cn */,
+       {  0x0E98,  0x0E98} /* Cn */, {  0x0EA0,  0x0EA0} /* Cn */,
+       {  0x0EA4,  0x0EA4} /* Cn */, {  0x0EA6,  0x0EA6} /* Cn */,
+       {  0x0EA8,  0x0EA9} /* Cn */, {  0x0EAC,  0x0EAC} /* Cn */,
+       {  0x0EBA,  0x0EBA} /* Cn */, {  0x0EBE,  0x0EBF} /* Cn */,
+       {  0x0EC5,  0x0EC5} /* Cn */, {  0x0EC7,  0x0EC7} /* Cn */,
+       {  0x0ECE,  0x0ECF} /* Cn */, {  0x0EDA,  0x0EDB} /* Cn */,
+       {  0x0EDE,  0x0EFF} /* Cn */, {  0x0F48,  0x0F48} /* Cn */,
+       {  0x0F6B,  0x0F70} /* Cn */, {  0x0F8C,  0x0F8F} /* Cn */,
+       {  0x0F98,  0x0F98} /* Cn */, {  0x0FBD,  0x0FBD} /* Cn */,
+       {  0x0FCD,  0x0FCE} /* Cn */, {  0x0FD2,  0x0FFF} /* Cn */,
+       {  0x1022,  0x1022} /* Cn */, {  0x1028,  0x1028} /* Cn */,
+       {  0x102B,  0x102B} /* Cn */, {  0x1033,  0x1035} /* Cn */,
+       {  0x103A,  0x103F} /* Cn */, {  0x105A,  0x109F} /* Cn */,
+       {  0x10C6,  0x10CF} /* Cn */, {  0x10FD,  0x10FF} /* Cn */,
+       {  0x115A,  0x115E} /* Cn */, {  0x11A3,  0x11A7} /* Cn */,
+       {  0x11FA,  0x11FF} /* Cn */, {  0x1249,  0x1249} /* Cn */,
+       {  0x124E,  0x124F} /* Cn */, {  0x1257,  0x1257} /* Cn */,
+       {  0x1259,  0x1259} /* Cn */, {  0x125E,  0x125F} /* Cn */,
+       {  0x1289,  0x1289} /* Cn */, {  0x128E,  0x128F} /* Cn */,
+       {  0x12B1,  0x12B1} /* Cn */, {  0x12B6,  0x12B7} /* Cn */,
+       {  0x12BF,  0x12BF} /* Cn */, {  0x12C1,  0x12C1} /* Cn */,
+       {  0x12C6,  0x12C7} /* Cn */, {  0x12D7,  0x12D7} /* Cn */,
+       {  0x1311,  0x1311} /* Cn */, {  0x1316,  0x1317} /* Cn */,
+       {  0x135B,  0x135E} /* Cn */, {  0x137D,  0x137F} /* Cn */,
+       {  0x139A,  0x139F} /* Cn */, {  0x13F5,  0x1400} /* Cn */,
+       {  0x1677,  0x167F} /* Cn */, {  0x169D,  0x169F} /* Cn */,
+       {  0x16F1,  0x16FF} /* Cn */, {  0x170D,  0x170D} /* Cn */,
+       {  0x1715,  0x171F} /* Cn */, {  0x1737,  0x173F} /* Cn */,
+       {  0x1754,  0x175F} /* Cn */, {  0x176D,  0x176D} /* Cn */,
+       {  0x1771,  0x1771} /* Cn */, {  0x1774,  0x177F} /* Cn */,
+#if 0
+       {  0x17B4,  0x17B5} /* Cf */,
+#endif
+       {  0x17DE,  0x17DF} /* Cn */, {  0x17EA,  0x17EF} /* Cn */,
+       {  0x17FA,  0x17FF} /* Cn */, {  0x180F,  0x180F} /* Cn */,
+       {  0x181A,  0x181F} /* Cn */, {  0x1878,  0x187F} /* Cn */,
+       {  0x18AA,  0x18FF} /* Cn */, {  0x191D,  0x191F} /* Cn */,
+       {  0x192C,  0x192F} /* Cn */, {  0x193C,  0x193F} /* Cn */,
+       {  0x1941,  0x1943} /* Cn */, {  0x196E,  0x196F} /* Cn */,
+       {  0x1975,  0x197F} /* Cn */, {  0x19AA,  0x19AF} /* Cn */,
+       {  0x19CA,  0x19CF} /* Cn */, {  0x19DA,  0x19DD} /* Cn */,
+       {  0x1A1C,  0x1A1D} /* Cn */, {  0x1A20,  0x1AFF} /* Cn */,
+       {  0x1B4C,  0x1B4F} /* Cn */, {  0x1B7D,  0x1CFF} /* Cn */,
+       {  0x1DCB,  0x1DFD} /* Cn */, {  0x1E9C,  0x1E9F} /* Cn */,
+       {  0x1EFA,  0x1EFF} /* Cn */, {  0x1F16,  0x1F17} /* Cn */,
+       {  0x1F1E,  0x1F1F} /* Cn */, {  0x1F46,  0x1F47} /* Cn */,
+       {  0x1F4E,  0x1F4F} /* Cn */, {  0x1F58,  0x1F58} /* Cn */,
+       {  0x1F5A,  0x1F5A} /* Cn */, {  0x1F5C,  0x1F5C} /* Cn */,
+       {  0x1F5E,  0x1F5E} /* Cn */, {  0x1F7E,  0x1F7F} /* Cn */,
+       {  0x1FB5,  0x1FB5} /* Cn */, {  0x1FC5,  0x1FC5} /* Cn */,
+       {  0x1FD4,  0x1FD5} /* Cn */, {  0x1FDC,  0x1FDC} /* Cn */,
+       {  0x1FF0,  0x1FF1} /* Cn */, {  0x1FF5,  0x1FF5} /* Cn */,
+       {  0x1FFF,  0x1FFF} /* Cn */,
+       {  0x200B,  0x200F} /* Cf */,
+       {  0x2028,  0x2028} /* Zl */,
+       {  0x2029,  0x2029} /* Zp */,
+       {  0x202A,  0x202E} /* Cf */,
+       {  0x2060,  0x2063} /* Cf */,
+       {  0x2064,  0x2069} /* Cn */,
+       {  0x206A,  0x206F} /* Cf */,
+       {  0x2072,  0x2073} /* Cn */, {  0x208F,  0x208F} /* Cn */,
+       {  0x2095,  0x209F} /* Cn */, {  0x20B6,  0x20CF} /* Cn */,
+       {  0x20F0,  0x20FF} /* Cn */, {  0x214F,  0x2152} /* Cn */,
+       {  0x2185,  0x218F} /* Cn */, {  0x23E8,  0x23FF} /* Cn */,
+       {  0x2427,  0x243F} /* Cn */, {  0x244B,  0x245F} /* Cn */,
+       {  0x269D,  0x269F} /* Cn */, {  0x26B3,  0x2700} /* Cn */,
+       {  0x2705,  0x2705} /* Cn */, {  0x270A,  0x270B} /* Cn */,
+       {  0x2728,  0x2728} /* Cn */, {  0x274C,  0x274C} /* Cn */,
+       {  0x274E,  0x274E} /* Cn */, {  0x2753,  0x2755} /* Cn */,
+       {  0x2757,  0x2757} /* Cn */, {  0x275F,  0x2760} /* Cn */,
+       {  0x2795,  0x2797} /* Cn */, {  0x27B0,  0x27B0} /* Cn */,
+       {  0x27BF,  0x27BF} /* Cn */, {  0x27CB,  0x27CF} /* Cn */,
+       {  0x27EC,  0x27EF} /* Cn */, {  0x2B1B,  0x2B1F} /* Cn */,
+       {  0x2B24,  0x2BFF} /* Cn */, {  0x2C2F,  0x2C2F} /* Cn */,
+       {  0x2C5F,  0x2C5F} /* Cn */, {  0x2C6D,  0x2C73} /* Cn */,
+       {  0x2C78,  0x2C7F} /* Cn */, {  0x2CEB,  0x2CF8} /* Cn */,
+       {  0x2D26,  0x2D2F} /* Cn */, {  0x2D66,  0x2D6E} /* Cn */,
+       {  0x2D70,  0x2D7F} /* Cn */, {  0x2D97,  0x2D9F} /* Cn */,
+       {  0x2DA7,  0x2DA7} /* Cn */, {  0x2DAF,  0x2DAF} /* Cn */,
+       {  0x2DB7,  0x2DB7} /* Cn */, {  0x2DBF,  0x2DBF} /* Cn */,
+       {  0x2DC7,  0x2DC7} /* Cn */, {  0x2DCF,  0x2DCF} /* Cn */,
+       {  0x2DD7,  0x2DD7} /* Cn */, {  0x2DDF,  0x2DFF} /* Cn */,
+       {  0x2E18,  0x2E1B} /* Cn */, {  0x2E1E,  0x2E7F} /* Cn */,
+       {  0x2E9A,  0x2E9A} /* Cn */, {  0x2EF4,  0x2EFF} /* Cn */,
+       {  0x2FD6,  0x2FEF} /* Cn */, {  0x2FFC,  0x2FFF} /* Cn */,
+       {  0x3040,  0x3040} /* Cn */, {  0x3097,  0x3098} /* Cn */,
+       {  0x3100,  0x3104} /* Cn */, {  0x312D,  0x3130} /* Cn */,
+       {  0x318F,  0x318F} /* Cn */, {  0x31B8,  0x31BF} /* Cn */,
+       {  0x31D0,  0x31EF} /* Cn */, {  0x321F,  0x321F} /* Cn */,
+       {  0x3244,  0x324F} /* Cn */, {  0x32FF,  0x32FF} /* Cn */,
+       {  0x4DB6,  0x4DBF} /* Cn */, {  0x9FBC,  0x9FFF} /* Cn */,
+       {  0xA48D,  0xA48F} /* Cn */, {  0xA4C7,  0xA6FF} /* Cn */,
+       {  0xA71B,  0xA71F} /* Cn */, {  0xA722,  0xA7FF} /* Cn */,
+       {  0xA82C,  0xA83F} /* Cn */, {  0xA878,  0xABFF} /* Cn */,
+       {  0xD7A4,  0xD7FF} /* Cn */,
+       {  0xD800,  0xDFFF} /* Cs */,
+       {  0xE000,  0xF8FF} /* Co */,
+       {  0xFA2E,  0xFA2F} /* Cn */, {  0xFA6B,  0xFA6F} /* Cn */,
+       {  0xFADA,  0xFAFF} /* Cn */, {  0xFB07,  0xFB12} /* Cn */,
+       {  0xFB18,  0xFB1C} /* Cn */, {  0xFB37,  0xFB37} /* Cn */,
+       {  0xFB3D,  0xFB3D} /* Cn */, {  0xFB3F,  0xFB3F} /* Cn */,
+       {  0xFB42,  0xFB42} /* Cn */, {  0xFB45,  0xFB45} /* Cn */,
+       {  0xFBB2,  0xFBD2} /* Cn */, {  0xFD40,  0xFD4F} /* Cn */,
+       {  0xFD90,  0xFD91} /* Cn */, {  0xFDC8,  0xFDEF} /* Cn */,
+       {  0xFDFE,  0xFDFF} /* Cn */, {  0xFE1A,  0xFE1F} /* Cn */,
+       {  0xFE24,  0xFE2F} /* Cn */, {  0xFE53,  0xFE53} /* Cn */,
+       {  0xFE67,  0xFE67} /* Cn */, {  0xFE6C,  0xFE6F} /* Cn */,
+       {  0xFE75,  0xFE75} /* Cn */, {  0xFEFD,  0xFEFE} /* Cn */,
+       {  0xFEFF,  0xFEFF} /* Cf */,
+       {  0xFF00,  0xFF00} /* Cn */, {  0xFFBF,  0xFFC1} /* Cn */,
+       {  0xFFC8,  0xFFC9} /* Cn */, {  0xFFD0,  0xFFD1} /* Cn */,
+       {  0xFFD8,  0xFFD9} /* Cn */, {  0xFFDD,  0xFFDF} /* Cn */,
+       {  0xFFE7,  0xFFE7} /* Cn */, {  0xFFEF,  0xFFF8} /* Cn */,
+       {  0xFFF9,  0xFFFB} /* Cf */,
+       {  0xFFFE,  0xFFFF} /* Cn */, { 0x1000C, 0x1000C} /* Cn */,
+       { 0x10027, 0x10027} /* Cn */, { 0x1003B, 0x1003B} /* Cn */,
+       { 0x1003E, 0x1003E} /* Cn */, { 0x1004E, 0x1004F} /* Cn */,
+       { 0x1005E, 0x1007F} /* Cn */, { 0x100FB, 0x100FF} /* Cn */,
+       { 0x10103, 0x10106} /* Cn */, { 0x10134, 0x10136} /* Cn */,
+       { 0x1018B, 0x102FF} /* Cn */, { 0x1031F, 0x1031F} /* Cn */,
+       { 0x10324, 0x1032F} /* Cn */, { 0x1034B, 0x1037F} /* Cn */,
+       { 0x1039E, 0x1039E} /* Cn */, { 0x103C4, 0x103C7} /* Cn */,
+       { 0x103D6, 0x103FF} /* Cn */,
+       { 0x1049E, 0x1049F} /* Cn */, { 0x104AA, 0x107FF} /* Cn */,
+       { 0x10806, 0x10807} /* Cn */, { 0x10809, 0x10809} /* Cn */,
+       { 0x10836, 0x10836} /* Cn */, { 0x10839, 0x1083B} /* Cn */,
+       { 0x1083D, 0x1083E} /* Cn */, { 0x10840, 0x108FF} /* Cn */,
+       { 0x1091A, 0x1091E} /* Cn */, { 0x10920, 0x109FF} /* Cn */,
+       { 0x10A04, 0x10A04} /* Cn */, { 0x10A07, 0x10A0B} /* Cn */,
+       { 0x10A14, 0x10A14} /* Cn */, { 0x10A18, 0x10A18} /* Cn */,
+       { 0x10A34, 0x10A37} /* Cn */, { 0x10A3B, 0x10A3E} /* Cn */,
+       { 0x10A48, 0x10A4F} /* Cn */, { 0x10A59, 0x11FFF} /* Cn */,
+       { 0x1236F, 0x123FF} /* Cn */, { 0x12463, 0x1246F} /* Cn */,
+       { 0x12474, 0x1CFFF} /* Cn */, { 0x1D0F6, 0x1D0FF} /* Cn */,
+       { 0x1D127, 0x1D129} /* Cn */,
+       { 0x1D173, 0x1D17A} /* Cf */,
+       { 0x1D1DE, 0x1D1FF} /* Cn */, { 0x1D246, 0x1D2FF} /* Cn */,
+       { 0x1D357, 0x1D35F} /* Cn */, { 0x1D372, 0x1D3FF} /* Cn */,
+       { 0x1D455, 0x1D455} /* Cn */, { 0x1D49D, 0x1D49D} /* Cn */,
+       { 0x1D4A0, 0x1D4A1} /* Cn */, { 0x1D4A3, 0x1D4A4} /* Cn */,
+       { 0x1D4A7, 0x1D4A8} /* Cn */, { 0x1D4AD, 0x1D4AD} /* Cn */,
+       { 0x1D4BA, 0x1D4BA} /* Cn */, { 0x1D4BC, 0x1D4BC} /* Cn */,
+       { 0x1D4C4, 0x1D4C4} /* Cn */, { 0x1D506, 0x1D506} /* Cn */,
+       { 0x1D50B, 0x1D50C} /* Cn */, { 0x1D515, 0x1D515} /* Cn */,
+       { 0x1D51D, 0x1D51D} /* Cn */, { 0x1D53A, 0x1D53A} /* Cn */,
+       { 0x1D53F, 0x1D53F} /* Cn */, { 0x1D545, 0x1D545} /* Cn */,
+       { 0x1D547, 0x1D549} /* Cn */, { 0x1D551, 0x1D551} /* Cn */,
+       { 0x1D6A6, 0x1D6A7} /* Cn */, { 0x1D7CC, 0x1D7CD} /* Cn */,
+       { 0x1D800, 0x1FFFF} /* Cn */, { 0x2A6D7, 0x2F7FF} /* Cn */,
+       { 0x2FA1E, 0xE0000} /* Cn */,
+       { 0xE0001, 0xE0001} /* Cf */,
+       { 0xE0002, 0xE001F} /* Cn */,
+       { 0xE0020, 0xE007F} /* Cf */,
+       { 0xE0080, 0xE00FF} /* Cn */, { 0xE01F0, 0xEFFFF} /* Cn */,
+       { 0xF0000, 0xFFFFD} /* Co */,
+       { 0xFFFFE, 0xFFFFF} /* Cn */,
+       {0x100000,0x10FFFD} /* Co */,
+       {0x10FFFE,0x10FFFF} /* Cn */,
+       {0x110000,0x7FFFFFFF} /* ISO 10646?? */
+};
+
+/*
+ * Double width characters
+ *     W: East Asian Wide
+ *     F: East Asian Full-width
+ * Unassigned code points may be included when they allow ranges to be merged.
+ * Last synched with
+ *     <http://www.unicode.org/Public/5.0.0/ucd/EastAsianWidth-5.0.0d2.txt>
+ *     dated 2005-11-08T01:32:56Z
+ */
+static struct wchar_range wide_table[] = {
+       {  0x1100,  0x115F} /* W */, {  0x2329,  0x232A} /* W */,
+       {  0x2E80,  0x2FFB} /* W */,
+       {  0x3000,  0x3000} /* F */,
+       {  0x3001,  0x303E} /* W */, {  0x3041,  0x4DB5} /* W */,
+       {  0x4E00,  0x9FBB} /* W */, {  0xA000,  0xA4C6} /* W */,
+       {  0xAC00,  0xD7A3} /* W */, {  0xF900,  0xFAD9} /* W */,
+       {  0xFE10,  0xFE19} /* W */, {  0xFE30,  0xFE6B} /* W */,
+       {  0xFF01,  0xFF60} /* F */, {  0xFFE0,  0xFFE6} /* F */,
+       { 0x20000, 0x2FFFD} /* W */, { 0x30000, 0x3FFFD} /* W */,
+};
+
+       static int
+is_in_table(ch, table, tsize)
+       LWCHAR ch;
+       struct wchar_range table[];
+       int tsize;
+{
+       int hi;
+       int lo;
+
+       /* Binary search in the table. */
+       if (ch < table[0].first)
+               return 0;
+       lo = 0;
+       hi = tsize - 1;
+       while (lo <= hi)
+       {
+               int mid = (lo + hi) / 2;
+               if (ch > table[mid].last)
+                       lo = mid + 1;
+               else if (ch < table[mid].first)
+                       hi = mid - 1;
+               else
+                       return 1;
+       }
+       return 0;
+}
+
+/*
+ * Is a character a UTF-8 composing character?
+ * If a composing character follows any char, the two combine into one glyph.
+ */
+       public int
+is_composing_char(ch)
+       LWCHAR ch;
+{
+       return is_in_table(ch, comp_table, (sizeof(comp_table) / sizeof(*comp_table)));
+}
+
+/*
+ * Should this UTF-8 character be treated as binary?
+ */
+       public int
+is_ubin_char(ch)
+       LWCHAR ch;
+{
+       return is_in_table(ch, ubin_table, (sizeof(ubin_table) / sizeof(*ubin_table)));
+}
+
+/*
+ * Is this a double width UTF-8 character?
+ */
+       public int
+is_wide_char(ch)
+       LWCHAR ch;
+{
+       return is_in_table(ch, wide_table, (sizeof(wide_table) / sizeof(*wide_table)));
+}
+
+/*
+ * Is a character a UTF-8 combining character?
+ * A combining char acts like an ordinary char, but if it follows
+ * a specific char (not any char), the two combine into one glyph.
+ */
+       public int
+is_combining_char(ch1, ch2)
+       LWCHAR ch1;
+       LWCHAR ch2;
+{
+       /* The table is small; use linear search. */
+       int i;
+       for (i = 0;  i < sizeof(comb_table)/sizeof(*comb_table);  i++)
+       {
+               if (ch1 == comb_table[i].first &&
+                   ch2 == comb_table[i].last)
+                       return 1;
+       }
+       return 0;
+}
+
diff --git a/thirdparty/less/charset.h b/thirdparty/less/charset.h
new file mode 100644 (file)
index 0000000..8ccf748
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2005-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+#define IS_ASCII_OCTET(c)   (((c) & 0x80) == 0)
+#define IS_UTF8_TRAIL(c)    (((c) & 0xC0) == 0x80)
+#define IS_UTF8_LEAD2(c)    (((c) & 0xE0) == 0xC0)
+#define IS_UTF8_LEAD3(c)    (((c) & 0xF0) == 0xE0)
+#define IS_UTF8_LEAD4(c)    (((c) & 0xF8) == 0xF0)
+#define IS_UTF8_LEAD5(c)    (((c) & 0xFC) == 0xF8)
+#define IS_UTF8_LEAD6(c)    (((c) & 0xFE) == 0xFC)
+#define IS_UTF8_INVALID(c)  (((c) & 0xFE) == 0xFE)
+#define IS_UTF8_LEAD(c)     (((c) & 0xC0) == 0xC0 && !IS_UTF8_INVALID(c))
diff --git a/thirdparty/less/cmd.h b/thirdparty/less/cmd.h
new file mode 100644 (file)
index 0000000..3176b91
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+#define        MAX_USERCMD             500
+#define        MAX_CMDLEN              16
+
+#define        A_B_LINE                2
+#define        A_B_SCREEN              3
+#define        A_B_SCROLL              4
+#define        A_B_SEARCH              5
+#define        A_DIGIT                 6
+#define        A_DISP_OPTION           7
+#define        A_DEBUG                 8
+#define        A_EXAMINE               9
+#define        A_FIRSTCMD              10
+#define        A_FREPAINT              11
+#define        A_F_LINE                12
+#define        A_F_SCREEN              13
+#define        A_F_SCROLL              14
+#define        A_F_SEARCH              15
+#define        A_GOEND                 16
+#define        A_GOLINE                17
+#define        A_GOMARK                18
+#define        A_HELP                  19
+#define        A_NEXT_FILE             20
+#define        A_PERCENT               21
+#define        A_PREFIX                22
+#define        A_PREV_FILE             23
+#define        A_QUIT                  24
+#define        A_REPAINT               25
+#define        A_SETMARK               26
+#define        A_SHELL                 27
+#define        A_STAT                  28
+#define        A_FF_LINE               29
+#define        A_BF_LINE               30
+#define        A_VERSION               31
+#define        A_VISUAL                32
+#define        A_F_WINDOW              33
+#define        A_B_WINDOW              34
+#define        A_F_BRACKET             35
+#define        A_B_BRACKET             36
+#define        A_PIPE                  37
+#define        A_INDEX_FILE            38
+#define        A_UNDO_SEARCH           39
+#define        A_FF_SCREEN             40
+#define        A_LSHIFT                41
+#define        A_RSHIFT                42
+#define        A_AGAIN_SEARCH          43
+#define        A_T_AGAIN_SEARCH        44
+#define        A_REVERSE_SEARCH        45
+#define        A_T_REVERSE_SEARCH      46
+#define        A_OPT_TOGGLE            47
+#define        A_OPT_SET               48
+#define        A_OPT_UNSET             49
+#define        A_F_FOREVER             50
+#define        A_GOPOS                 51
+#define        A_REMOVE_FILE           52
+#define        A_NEXT_TAG              53
+#define        A_PREV_TAG              54
+#define        A_FILTER                55
+
+#define        A_INVALID               100
+#define        A_NOACTION              101
+#define        A_UINVALID              102
+#define        A_END_LIST              103
+#define        A_SPECIAL_KEY           104
+
+#define A_SKIP                 127
+
+#define        A_EXTRA                 0200
+
+
+/* Line editting characters */
+
+#define        EC_BACKSPACE    1
+#define        EC_LINEKILL     2
+#define        EC_RIGHT        3
+#define        EC_LEFT         4
+#define        EC_W_LEFT       5
+#define        EC_W_RIGHT      6
+#define        EC_INSERT       7
+#define        EC_DELETE       8
+#define        EC_HOME         9
+#define        EC_END          10
+#define        EC_W_BACKSPACE  11
+#define        EC_W_DELETE     12
+#define        EC_UP           13
+#define        EC_DOWN         14
+#define        EC_EXPAND       15
+#define        EC_F_COMPLETE   17
+#define        EC_B_COMPLETE   18
+#define        EC_LITERAL      19
+#define        EC_ABORT        20
+
+#define        EC_NOACTION     101
+#define        EC_UINVALID     102
+
+/* Flags for editchar() */
+#define        EC_PEEK         01
+#define        EC_NOHISTORY    02
+#define        EC_NOCOMPLETE   04
+#define        EC_NORIGHTLEFT  010
+
+/* Environment variable stuff */
+#define        EV_OK           01
+
+/* Special keys (keys which output different strings on different terminals) */
+#define SK_SPECIAL_KEY         CONTROL('K')
+#define SK_RIGHT_ARROW         1
+#define SK_LEFT_ARROW          2
+#define SK_UP_ARROW            3
+#define SK_DOWN_ARROW          4
+#define SK_PAGE_UP             5
+#define SK_PAGE_DOWN           6
+#define SK_HOME                        7
+#define SK_END                 8
+#define SK_DELETE              9
+#define SK_INSERT              10
+#define SK_CTL_LEFT_ARROW      11
+#define SK_CTL_RIGHT_ARROW     12
+#define SK_CTL_DELETE          13
+#define SK_F1                  14
+#define SK_BACKTAB             15
+#define SK_CTL_BACKSPACE       16
+#define SK_CONTROL_K           40
diff --git a/thirdparty/less/cmdbuf.c b/thirdparty/less/cmdbuf.c
new file mode 100644 (file)
index 0000000..74a74ff
--- /dev/null
@@ -0,0 +1,1503 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Functions which manipulate the command buffer.
+ * Used only by command() and related functions.
+ */
+
+#include "less.h"
+#include "cmd.h"
+#include "charset.h"
+#if HAVE_STAT
+#include <sys/stat.h>
+#endif
+
+extern int sc_width;
+extern int utf_mode;
+
+static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */
+static int cmd_col;            /* Current column of the cursor */
+static int prompt_col;         /* Column of cursor just after prompt */
+static char *cp;               /* Pointer into cmdbuf */
+static int cmd_offset;         /* Index into cmdbuf of first displayed char */
+static int literal;            /* Next input char should not be interpreted */
+
+#if TAB_COMPLETE_FILENAME
+static int cmd_complete();
+/*
+ * These variables are statics used by cmd_complete.
+ */
+static int in_completion = 0;
+static char *tk_text;
+static char *tk_original;
+static char *tk_ipoint;
+static char *tk_trial;
+static struct textlist tk_tlist;
+#endif
+
+static int cmd_left();
+static int cmd_right();
+
+#if SPACES_IN_FILENAMES
+public char openquote = '"';
+public char closequote = '"';
+#endif
+
+#if CMD_HISTORY
+
+/* History file */
+#define HISTFILE_FIRST_LINE      ".less-history-file:"
+#define HISTFILE_SEARCH_SECTION  ".search"
+#define HISTFILE_SHELL_SECTION   ".shell"
+
+/*
+ * A mlist structure represents a command history.
+ */
+struct mlist
+{
+       struct mlist *next;
+       struct mlist *prev;
+       struct mlist *curr_mp;
+       char *string;
+       int modified;
+};
+
+/*
+ * These are the various command histories that exist.
+ */
+struct mlist mlist_search =  
+       { &mlist_search,  &mlist_search,  &mlist_search,  NULL, 0 };
+public void * constant ml_search = (void *) &mlist_search;
+
+struct mlist mlist_examine = 
+       { &mlist_examine, &mlist_examine, &mlist_examine, NULL, 0 };
+public void * constant ml_examine = (void *) &mlist_examine;
+
+#if SHELL_ESCAPE || PIPEC
+struct mlist mlist_shell =   
+       { &mlist_shell,   &mlist_shell,   &mlist_shell,   NULL, 0 };
+public void * constant ml_shell = (void *) &mlist_shell;
+#endif
+
+#else /* CMD_HISTORY */
+
+/* If CMD_HISTORY is off, these are just flags. */
+public void * constant ml_search = (void *)1;
+public void * constant ml_examine = (void *)2;
+#if SHELL_ESCAPE || PIPEC
+public void * constant ml_shell = (void *)3;
+#endif
+
+#endif /* CMD_HISTORY */
+
+/*
+ * History for the current command.
+ */
+static struct mlist *curr_mlist = NULL;
+static int curr_cmdflags;
+
+static char cmd_mbc_buf[MAX_UTF_CHAR_LEN];
+static int cmd_mbc_buf_len;
+static int cmd_mbc_buf_index;
+
+
+/*
+ * Reset command buffer (to empty).
+ */
+       public void
+cmd_reset()
+{
+       cp = cmdbuf;
+       *cp = '\0';
+       cmd_col = 0;
+       cmd_offset = 0;
+       literal = 0;
+       cmd_mbc_buf_len = 0;
+}
+
+/*
+ * Clear command line.
+ */
+       public void
+clear_cmd()
+{
+       cmd_col = prompt_col = 0;
+       cmd_mbc_buf_len = 0;
+}
+
+/*
+ * Display a string, usually as a prompt for input into the command buffer.
+ */
+       public void
+cmd_putstr(s)
+       char *s;
+{
+       LWCHAR prev_ch = 0;
+       LWCHAR ch;
+       char *endline = s + strlen(s);
+       while (*s != '\0')
+       {
+               char *ns = s;
+               ch = step_char(&ns, +1, endline);
+               while (s < ns)
+                       putchr(*s++);
+               if (!utf_mode)
+               {
+                       cmd_col++;
+                       prompt_col++;
+               } else if (!is_composing_char(ch) &&
+                          !is_combining_char(prev_ch, ch))
+               {
+                       int width = is_wide_char(ch) ? 2 : 1;
+                       cmd_col += width;
+                       prompt_col += width;
+               }
+               prev_ch = ch;
+       }
+}
+
+/*
+ * How many characters are in the command buffer?
+ */
+       public int
+len_cmdbuf()
+{
+       char *s = cmdbuf;
+       char *endline = s + strlen(s);
+       int len = 0;
+
+       while (*s != '\0')
+       {
+               step_char(&s, +1, endline);
+               len++;
+       }
+       return (len);
+}
+
+/*
+ * Common part of cmd_step_right() and cmd_step_left().
+ */
+       static char *
+cmd_step_common(p, ch, len, pwidth, bswidth)
+       char *p;
+       LWCHAR ch;
+       int len;
+       int *pwidth;
+       int *bswidth;
+{
+       char *pr;
+
+       if (len == 1)
+       {
+               pr = prchar((int) ch);
+               if (pwidth != NULL || bswidth != NULL)
+               {
+                       int len = strlen(pr);
+                       if (pwidth != NULL)
+                               *pwidth = len;
+                       if (bswidth != NULL)
+                               *bswidth = len;
+               }
+       } else
+       {
+               pr = prutfchar(ch);
+               if (pwidth != NULL || bswidth != NULL)
+               {
+                       if (is_composing_char(ch))
+                       {
+                               if (pwidth != NULL)
+                                       *pwidth = 0;
+                               if (bswidth != NULL)
+                                       *bswidth = 0;
+                       } else if (is_ubin_char(ch))
+                       {
+                               int len = strlen(pr);
+                               if (pwidth != NULL)
+                                       *pwidth = len;
+                               if (bswidth != NULL)
+                                       *bswidth = len;
+                       } else
+                       {
+                               LWCHAR prev_ch = step_char(&p, -1, cmdbuf);
+                               if (is_combining_char(prev_ch, ch))
+                               {
+                                       if (pwidth != NULL)
+                                               *pwidth = 0;
+                                       if (bswidth != NULL)
+                                               *bswidth = 0;
+                               } else
+                               {
+                                       if (pwidth != NULL)
+                                               *pwidth = is_wide_char(ch)
+                                                       ?       2
+                                                       :       1;
+                                       if (bswidth != NULL)
+                                               *bswidth = 1;
+                               }
+                       }
+               }
+       }
+
+       return (pr);
+}
+
+/*
+ * Step a pointer one character right in the command buffer.
+ */
+       static char *
+cmd_step_right(pp, pwidth, bswidth)
+       char **pp;
+       int *pwidth;
+       int *bswidth;
+{
+       char *p = *pp;
+       LWCHAR ch = step_char(pp, +1, p + strlen(p));
+
+       return cmd_step_common(p, ch, *pp - p, pwidth, bswidth);
+}
+
+/*
+ * Step a pointer one character left in the command buffer.
+ */
+       static char *
+cmd_step_left(pp, pwidth, bswidth)
+       char **pp;
+       int *pwidth;
+       int *bswidth;
+{
+       char *p = *pp;
+       LWCHAR ch = step_char(pp, -1, cmdbuf);
+
+       return cmd_step_common(*pp, ch, p - *pp, pwidth, bswidth);
+}
+
+/*
+ * Repaint the line from cp onwards.
+ * Then position the cursor just after the char old_cp (a pointer into cmdbuf).
+ */
+       static void
+cmd_repaint(old_cp)
+       char *old_cp;
+{
+       /*
+        * Repaint the line from the current position.
+        */
+       clear_eol();
+       while (*cp != '\0')
+       {
+               char *np = cp;
+               int width;
+               char *pr = cmd_step_right(&np, &width, NULL);
+               if (cmd_col + width >= sc_width)
+                       break;
+               cp = np;
+               putstr(pr);
+               cmd_col += width;
+       }
+       while (*cp != '\0')
+       {
+               char *np = cp;
+               int width;
+               char *pr = cmd_step_right(&np, &width, NULL);
+               if (width > 0)
+                       break;
+               cp = np;
+               putstr(pr);
+       }
+
+       /*
+        * Back up the cursor to the correct position.
+        */
+       while (cp > old_cp)
+               cmd_left();
+}
+
+/*
+ * Put the cursor at "home" (just after the prompt),
+ * and set cp to the corresponding char in cmdbuf.
+ */
+       static void
+cmd_home()
+{
+       while (cmd_col > prompt_col)
+       {
+               int width, bswidth;
+
+               cmd_step_left(&cp, &width, &bswidth);
+               while (bswidth-- > 0)
+                       putbs();
+               cmd_col -= width;
+       }
+
+       cp = &cmdbuf[cmd_offset];
+}
+
+/*
+ * Shift the cmdbuf display left a half-screen.
+ */
+       static void
+cmd_lshift()
+{
+       char *s;
+       char *save_cp;
+       int cols;
+
+       /*
+        * Start at the first displayed char, count how far to the
+        * right we'd have to move to reach the center of the screen.
+        */
+       s = cmdbuf + cmd_offset;
+       cols = 0;
+       while (cols < (sc_width - prompt_col) / 2 && *s != '\0')
+       {
+               int width;
+               cmd_step_right(&s, &width, NULL);
+               cols += width;
+       }
+       while (*s != '\0')
+       {
+               int width;
+               char *ns = s;
+               cmd_step_right(&ns, &width, NULL);
+               if (width > 0)
+                       break;
+               s = ns;
+       }
+
+       cmd_offset = s - cmdbuf;
+       save_cp = cp;
+       cmd_home();
+       cmd_repaint(save_cp);
+}
+
+/*
+ * Shift the cmdbuf display right a half-screen.
+ */
+       static void
+cmd_rshift()
+{
+       char *s;
+       char *save_cp;
+       int cols;
+
+       /*
+        * Start at the first displayed char, count how far to the
+        * left we'd have to move to traverse a half-screen width
+        * of displayed characters.
+        */
+       s = cmdbuf + cmd_offset;
+       cols = 0;
+       while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf)
+       {
+               int width;
+               cmd_step_left(&s, &width, NULL);
+               cols += width;
+       }
+
+       cmd_offset = s - cmdbuf;
+       save_cp = cp;
+       cmd_home();
+       cmd_repaint(save_cp);
+}
+
+/*
+ * Move cursor right one character.
+ */
+       static int
+cmd_right()
+{
+       char *pr;
+       char *ncp;
+       int width;
+       
+       if (*cp == '\0')
+       {
+               /* Already at the end of the line. */
+               return (CC_OK);
+       }
+       ncp = cp;
+       pr = cmd_step_right(&ncp, &width, NULL);
+       if (cmd_col + width >= sc_width)
+               cmd_lshift();
+       else if (cmd_col + width == sc_width - 1 && cp[1] != '\0')
+               cmd_lshift();
+       cp = ncp;
+       cmd_col += width;
+       putstr(pr);
+       while (*cp != '\0')
+       {
+               pr = cmd_step_right(&ncp, &width, NULL);
+               if (width > 0)
+                       break;
+               putstr(pr);
+               cp = ncp;
+       }
+       return (CC_OK);
+}
+
+/*
+ * Move cursor left one character.
+ */
+       static int
+cmd_left()
+{
+       char *ncp;
+       int width, bswidth;
+       
+       if (cp <= cmdbuf)
+       {
+               /* Already at the beginning of the line */
+               return (CC_OK);
+       }
+       ncp = cp;
+       while (ncp > cmdbuf)
+       {
+               cmd_step_left(&ncp, &width, &bswidth);
+               if (width > 0)
+                       break;
+       }
+       if (cmd_col < prompt_col + width)
+               cmd_rshift();
+       cp = ncp;
+       cmd_col -= width;
+       while (bswidth-- > 0)
+               putbs();
+       return (CC_OK);
+}
+
+/*
+ * Insert a char into the command buffer, at the current position.
+ */
+       static int
+cmd_ichar(cs, clen)
+       char *cs;
+       int clen;
+{
+       char *s;
+       
+       if (strlen(cmdbuf) + clen >= sizeof(cmdbuf)-1)
+       {
+               /* No room in the command buffer for another char. */
+               bell();
+               return (CC_ERROR);
+       }
+               
+       /*
+        * Make room for the new character (shift the tail of the buffer right).
+        */
+       for (s = &cmdbuf[strlen(cmdbuf)];  s >= cp;  s--)
+               s[clen] = s[0];
+       /*
+        * Insert the character into the buffer.
+        */
+       for (s = cp;  s < cp + clen;  s++)
+               *s = *cs++;
+       /*
+        * Reprint the tail of the line from the inserted char.
+        */
+       cmd_repaint(cp);
+       cmd_right();
+       return (CC_OK);
+}
+
+/*
+ * Backspace in the command buffer.
+ * Delete the char to the left of the cursor.
+ */
+       static int
+cmd_erase()
+{
+       register char *s;
+       int clen;
+
+       if (cp == cmdbuf)
+       {
+               /*
+                * Backspace past beginning of the buffer:
+                * this usually means abort the command.
+                */
+               return (CC_QUIT);
+       }
+       /*
+        * Move cursor left (to the char being erased).
+        */
+       s = cp;
+       cmd_left();
+       clen = s - cp;
+
+       /*
+        * Remove the char from the buffer (shift the buffer left).
+        */
+       for (s = cp;  ;  s++)
+       {
+               s[0] = s[clen];
+               if (s[0] == '\0')
+                       break;
+       }
+
+       /*
+        * Repaint the buffer after the erased char.
+        */
+       cmd_repaint(cp);
+       
+       /*
+        * We say that erasing the entire command string causes us
+        * to abort the current command, if CF_QUIT_ON_ERASE is set.
+        */
+       if ((curr_cmdflags & CF_QUIT_ON_ERASE) && cp == cmdbuf && *cp == '\0')
+               return (CC_QUIT);
+       return (CC_OK);
+}
+
+/*
+ * Delete the char under the cursor.
+ */
+       static int
+cmd_delete()
+{
+       if (*cp == '\0')
+       {
+               /* At end of string; there is no char under the cursor. */
+               return (CC_OK);
+       }
+       /*
+        * Move right, then use cmd_erase.
+        */
+       cmd_right();
+       cmd_erase();
+       return (CC_OK);
+}
+
+/*
+ * Delete the "word" to the left of the cursor.
+ */
+       static int
+cmd_werase()
+{
+       if (cp > cmdbuf && cp[-1] == ' ')
+       {
+               /*
+                * If the char left of cursor is a space,
+                * erase all the spaces left of cursor (to the first non-space).
+                */
+               while (cp > cmdbuf && cp[-1] == ' ')
+                       (void) cmd_erase();
+       } else
+       {
+               /*
+                * If the char left of cursor is not a space,
+                * erase all the nonspaces left of cursor (the whole "word").
+                */
+               while (cp > cmdbuf && cp[-1] != ' ')
+                       (void) cmd_erase();
+       }
+       return (CC_OK);
+}
+
+/*
+ * Delete the "word" under the cursor.
+ */
+       static int
+cmd_wdelete()
+{
+       if (*cp == ' ')
+       {
+               /*
+                * If the char under the cursor is a space,
+                * delete it and all the spaces right of cursor.
+                */
+               while (*cp == ' ')
+                       (void) cmd_delete();
+       } else
+       {
+               /*
+                * If the char under the cursor is not a space,
+                * delete it and all nonspaces right of cursor (the whole word).
+                */
+               while (*cp != ' ' && *cp != '\0')
+                       (void) cmd_delete();
+       }
+       return (CC_OK);
+}
+
+/*
+ * Delete all chars in the command buffer.
+ */
+       static int
+cmd_kill()
+{
+       if (cmdbuf[0] == '\0')
+       {
+               /* Buffer is already empty; abort the current command. */
+               return (CC_QUIT);
+       }
+       cmd_offset = 0;
+       cmd_home();
+       *cp = '\0';
+       cmd_repaint(cp);
+
+       /*
+        * We say that erasing the entire command string causes us
+        * to abort the current command, if CF_QUIT_ON_ERASE is set.
+        */
+       if (curr_cmdflags & CF_QUIT_ON_ERASE)
+               return (CC_QUIT);
+       return (CC_OK);
+}
+
+/*
+ * Select an mlist structure to be the current command history.
+ */
+       public void
+set_mlist(mlist, cmdflags)
+       void *mlist;
+       int cmdflags;
+{
+#if CMD_HISTORY
+       curr_mlist = (struct mlist *) mlist;
+       curr_cmdflags = cmdflags;
+
+       /* Make sure the next up-arrow moves to the last string in the mlist. */
+       if (curr_mlist != NULL)
+               curr_mlist->curr_mp = curr_mlist;
+#endif
+}
+
+#if CMD_HISTORY
+/*
+ * Move up or down in the currently selected command history list.
+ */
+       static int
+cmd_updown(action)
+       int action;
+{
+       char *s;
+       
+       if (curr_mlist == NULL)
+       {
+               /*
+                * The current command has no history list.
+                */
+               bell();
+               return (CC_OK);
+       }
+       cmd_home();
+       clear_eol();
+       /*
+        * Move curr_mp to the next/prev entry.
+        */
+       if (action == EC_UP)
+               curr_mlist->curr_mp = curr_mlist->curr_mp->prev;
+       else
+               curr_mlist->curr_mp = curr_mlist->curr_mp->next;
+       /*
+        * Copy the entry into cmdbuf and echo it on the screen.
+        */
+       s = curr_mlist->curr_mp->string;
+       if (s == NULL)
+               s = "";
+       strcpy(cmdbuf, s);
+       for (cp = cmdbuf;  *cp != '\0';  )
+               cmd_right();
+       return (CC_OK);
+}
+#endif
+
+/*
+ * Add a string to a history list.
+ */
+       public void
+cmd_addhist(mlist, cmd)
+       struct mlist *mlist;
+       char *cmd;
+{
+#if CMD_HISTORY
+       struct mlist *ml;
+       
+       /*
+        * Don't save a trivial command.
+        */
+       if (strlen(cmd) == 0)
+               return;
+
+       /*
+        * Save the command unless it's a duplicate of the
+        * last command in the history.
+        */
+       ml = mlist->prev;
+       if (ml == mlist || strcmp(ml->string, cmd) != 0)
+       {
+               /*
+                * Did not find command in history.
+                * Save the command and put it at the end of the history list.
+                */
+               ml = (struct mlist *) ecalloc(1, sizeof(struct mlist));
+               ml->string = save(cmd);
+               ml->next = mlist;
+               ml->prev = mlist->prev;
+               mlist->prev->next = ml;
+               mlist->prev = ml;
+       }
+       /*
+        * Point to the cmd just after the just-accepted command.
+        * Thus, an UPARROW will always retrieve the previous command.
+        */
+       mlist->curr_mp = ml->next;
+#endif
+}
+
+/*
+ * Accept the command in the command buffer.
+ * Add it to the currently selected history list.
+ */
+       public void
+cmd_accept()
+{
+#if CMD_HISTORY
+       /*
+        * Nothing to do if there is no currently selected history list.
+        */
+       if (curr_mlist == NULL)
+               return;
+       cmd_addhist(curr_mlist, cmdbuf);
+       curr_mlist->modified = 1;
+#endif
+}
+
+/*
+ * Try to perform a line-edit function on the command buffer,
+ * using a specified char as a line-editing command.
+ * Returns:
+ *     CC_PASS The char does not invoke a line edit function.
+ *     CC_OK   Line edit function done.
+ *     CC_QUIT The char requests the current command to be aborted.
+ */
+       static int
+cmd_edit(c)
+       int c;
+{
+       int action;
+       int flags;
+
+#if TAB_COMPLETE_FILENAME
+#define        not_in_completion()     in_completion = 0
+#else
+#define        not_in_completion()
+#endif
+       
+       /*
+        * See if the char is indeed a line-editing command.
+        */
+       flags = 0;
+#if CMD_HISTORY
+       if (curr_mlist == NULL)
+               /*
+                * No current history; don't accept history manipulation cmds.
+                */
+               flags |= EC_NOHISTORY;
+#endif
+#if TAB_COMPLETE_FILENAME
+       if (curr_mlist == ml_search)
+               /*
+                * In a search command; don't accept file-completion cmds.
+                */
+               flags |= EC_NOCOMPLETE;
+#endif
+
+       action = editchar(c, flags);
+
+       switch (action)
+       {
+       case EC_RIGHT:
+               not_in_completion();
+               return (cmd_right());
+       case EC_LEFT:
+               not_in_completion();
+               return (cmd_left());
+       case EC_W_RIGHT:
+               not_in_completion();
+               while (*cp != '\0' && *cp != ' ')
+                       cmd_right();
+               while (*cp == ' ')
+                       cmd_right();
+               return (CC_OK);
+       case EC_W_LEFT:
+               not_in_completion();
+               while (cp > cmdbuf && cp[-1] == ' ')
+                       cmd_left();
+               while (cp > cmdbuf && cp[-1] != ' ')
+                       cmd_left();
+               return (CC_OK);
+       case EC_HOME:
+               not_in_completion();
+               cmd_offset = 0;
+               cmd_home();
+               cmd_repaint(cp);
+               return (CC_OK);
+       case EC_END:
+               not_in_completion();
+               while (*cp != '\0')
+                       cmd_right();
+               return (CC_OK);
+       case EC_INSERT:
+               not_in_completion();
+               return (CC_OK);
+       case EC_BACKSPACE:
+               not_in_completion();
+               return (cmd_erase());
+       case EC_LINEKILL:
+               not_in_completion();
+               return (cmd_kill());
+       case EC_ABORT:
+               not_in_completion();
+               (void) cmd_kill();
+               return (CC_QUIT);
+       case EC_W_BACKSPACE:
+               not_in_completion();
+               return (cmd_werase());
+       case EC_DELETE:
+               not_in_completion();
+               return (cmd_delete());
+       case EC_W_DELETE:
+               not_in_completion();
+               return (cmd_wdelete());
+       case EC_LITERAL:
+               literal = 1;
+               return (CC_OK);
+#if CMD_HISTORY
+       case EC_UP:
+       case EC_DOWN:
+               not_in_completion();
+               return (cmd_updown(action));
+#endif
+#if TAB_COMPLETE_FILENAME
+       case EC_F_COMPLETE:
+       case EC_B_COMPLETE:
+       case EC_EXPAND:
+               return (cmd_complete(action));
+#endif
+       case EC_NOACTION:
+               return (CC_OK);
+       default:
+               not_in_completion();
+               return (CC_PASS);
+       }
+}
+
+#if TAB_COMPLETE_FILENAME
+/*
+ * Insert a string into the command buffer, at the current position.
+ */
+       static int
+cmd_istr(str)
+       char *str;
+{
+       char *s;
+       int action;
+       char *endline = str + strlen(str);
+       
+       for (s = str;  *s != '\0';  )
+       {
+               char *os = s;
+               step_char(&s, +1, endline);
+               action = cmd_ichar(os, s - os);
+               if (action != CC_OK)
+               {
+                       bell();
+                       return (action);
+               }
+       }
+       return (CC_OK);
+}
+
+/*
+ * Find the beginning and end of the "current" word.
+ * This is the word which the cursor (cp) is inside or at the end of.
+ * Return pointer to the beginning of the word and put the
+ * cursor at the end of the word.
+ */
+       static char *
+delimit_word()
+{
+       char *word;
+#if SPACES_IN_FILENAMES
+       char *p;
+       int delim_quoted = 0;
+       int meta_quoted = 0;
+       char *esc = get_meta_escape();
+       int esclen = strlen(esc);
+#endif
+       
+       /*
+        * Move cursor to end of word.
+        */
+       if (*cp != ' ' && *cp != '\0')
+       {
+               /*
+                * Cursor is on a nonspace.
+                * Move cursor right to the next space.
+                */
+               while (*cp != ' ' && *cp != '\0')
+                       cmd_right();
+       } else if (cp > cmdbuf && cp[-1] != ' ')
+       {
+               /*
+                * Cursor is on a space, and char to the left is a nonspace.
+                * We're already at the end of the word.
+                */
+               ;
+#if 0
+       } else
+       {
+               /*
+                * Cursor is on a space and char to the left is a space.
+                * Huh? There's no word here.
+                */
+               return (NULL);
+#endif
+       }
+       /*
+        * Find the beginning of the word which the cursor is in.
+        */
+       if (cp == cmdbuf)
+               return (NULL);
+#if SPACES_IN_FILENAMES
+       /*
+        * If we have an unbalanced quote (that is, an open quote
+        * without a corresponding close quote), we return everything
+        * from the open quote, including spaces.
+        */
+       for (word = cmdbuf;  word < cp;  word++)
+               if (*word != ' ')
+                       break;
+       if (word >= cp)
+               return (cp);
+       for (p = cmdbuf;  p < cp;  p++)
+       {
+               if (meta_quoted)
+               {
+                       meta_quoted = 0;
+               } else if (esclen > 0 && p + esclen < cp &&
+                          strncmp(p, esc, esclen) == 0)
+               {
+                       meta_quoted = 1;
+                       p += esclen - 1;
+               } else if (delim_quoted)
+               {
+                       if (*p == closequote)
+                               delim_quoted = 0;
+               } else /* (!delim_quoted) */
+               {
+                       if (*p == openquote)
+                               delim_quoted = 1;
+                       else if (*p == ' ')
+                               word = p+1;
+               }
+       }
+#endif
+       return (word);
+}
+
+/*
+ * Set things up to enter completion mode.
+ * Expand the word under the cursor into a list of filenames 
+ * which start with that word, and set tk_text to that list.
+ */
+       static void
+init_compl()
+{
+       char *word;
+       char c;
+       
+       /*
+        * Get rid of any previous tk_text.
+        */
+       if (tk_text != NULL)
+       {
+               free(tk_text);
+               tk_text = NULL;
+       }
+       /*
+        * Find the original (uncompleted) word in the command buffer.
+        */
+       word = delimit_word();
+       if (word == NULL)
+               return;
+       /*
+        * Set the insertion point to the point in the command buffer
+        * where the original (uncompleted) word now sits.
+        */
+       tk_ipoint = word;
+       /*
+        * Save the original (uncompleted) word
+        */
+       if (tk_original != NULL)
+               free(tk_original);
+       tk_original = (char *) ecalloc(cp-word+1, sizeof(char));
+       strncpy(tk_original, word, cp-word);
+       /*
+        * Get the expanded filename.
+        * This may result in a single filename, or
+        * a blank-separated list of filenames.
+        */
+       c = *cp;
+       *cp = '\0';
+       if (*word != openquote)
+       {
+               tk_text = fcomplete(word);
+       } else
+       {
+               char *qword = shell_quote(word+1);
+               if (qword == NULL)
+                       tk_text = fcomplete(word+1);
+               else
+               {
+                       tk_text = fcomplete(qword);
+                       free(qword);
+               }
+       }
+       *cp = c;
+}
+
+/*
+ * Return the next word in the current completion list.
+ */
+       static char *
+next_compl(action, prev)
+       int action;
+       char *prev;
+{
+       switch (action)
+       {
+       case EC_F_COMPLETE:
+               return (forw_textlist(&tk_tlist, prev));
+       case EC_B_COMPLETE:
+               return (back_textlist(&tk_tlist, prev));
+       }
+       /* Cannot happen */
+       return ("?");
+}
+
+/*
+ * Complete the filename before (or under) the cursor.
+ * cmd_complete may be called multiple times.  The global in_completion
+ * remembers whether this call is the first time (create the list),
+ * or a subsequent time (step thru the list).
+ */
+       static int
+cmd_complete(action)
+       int action;
+{
+       char *s;
+
+       if (!in_completion || action == EC_EXPAND)
+       {
+               /*
+                * Expand the word under the cursor and 
+                * use the first word in the expansion 
+                * (or the entire expansion if we're doing EC_EXPAND).
+                */
+               init_compl();
+               if (tk_text == NULL)
+               {
+                       bell();
+                       return (CC_OK);
+               }
+               if (action == EC_EXPAND)
+               {
+                       /*
+                        * Use the whole list.
+                        */
+                       tk_trial = tk_text;
+               } else
+               {
+                       /*
+                        * Use the first filename in the list.
+                        */
+                       in_completion = 1;
+                       init_textlist(&tk_tlist, tk_text);
+                       tk_trial = next_compl(action, (char*)NULL);
+               }
+       } else
+       {
+               /*
+                * We already have a completion list.
+                * Use the next/previous filename from the list.
+                */
+               tk_trial = next_compl(action, tk_trial);
+       }
+       
+       /*
+        * Remove the original word, or the previous trial completion.
+        */
+       while (cp > tk_ipoint)
+               (void) cmd_erase();
+       
+       if (tk_trial == NULL)
+       {
+               /*
+                * There are no more trial completions.
+                * Insert the original (uncompleted) filename.
+                */
+               in_completion = 0;
+               if (cmd_istr(tk_original) != CC_OK)
+                       goto fail;
+       } else
+       {
+               /*
+                * Insert trial completion.
+                */
+               if (cmd_istr(tk_trial) != CC_OK)
+                       goto fail;
+               /*
+                * If it is a directory, append a slash.
+                */
+               if (is_dir(tk_trial))
+               {
+                       if (cp > cmdbuf && cp[-1] == closequote)
+                               (void) cmd_erase();
+                       s = lgetenv("LESSSEPARATOR");
+                       if (s == NULL)
+                               s = PATHNAME_SEP;
+                       if (cmd_istr(s) != CC_OK)
+                               goto fail;
+               }
+       }
+       
+       return (CC_OK);
+       
+fail:
+       in_completion = 0;
+       bell();
+       return (CC_OK);
+}
+
+#endif /* TAB_COMPLETE_FILENAME */
+
+/*
+ * Process a single character of a multi-character command, such as
+ * a number, or the pattern of a search command.
+ * Returns:
+ *     CC_OK           The char was accepted.
+ *     CC_QUIT         The char requests the command to be aborted.
+ *     CC_ERROR        The char could not be accepted due to an error.
+ */
+       public int
+cmd_char(c)
+       int c;
+{
+       int action;
+       int len;
+
+       if (!utf_mode)
+       {
+               cmd_mbc_buf[0] = c;
+               len = 1;
+       } else
+       {
+               /* Perform strict validation in all possible cases.  */
+               if (cmd_mbc_buf_len == 0)
+               {
+                retry:
+                       cmd_mbc_buf_index = 1;
+                       *cmd_mbc_buf = c;
+                       if (IS_ASCII_OCTET(c))
+                               cmd_mbc_buf_len = 1;
+                       else if (IS_UTF8_LEAD(c))
+                       {
+                               cmd_mbc_buf_len = utf_len(c);
+                               return (CC_OK);
+                       } else
+                       {
+                               /* UTF8_INVALID or stray UTF8_TRAIL */
+                               bell();
+                               return (CC_ERROR);
+                       }
+               } else if (IS_UTF8_TRAIL(c))
+               {
+                       cmd_mbc_buf[cmd_mbc_buf_index++] = c;
+                       if (cmd_mbc_buf_index < cmd_mbc_buf_len)
+                               return (CC_OK);
+                       if (!is_utf8_well_formed(cmd_mbc_buf))
+                       {
+                               /* complete, but not well formed (non-shortest form), sequence */
+                               cmd_mbc_buf_len = 0;
+                               bell();
+                               return (CC_ERROR);
+                       }
+               } else
+               {
+                       /* Flush incomplete (truncated) sequence.  */
+                       cmd_mbc_buf_len = 0;
+                       bell();
+                       /* Handle new char.  */
+                       goto retry;
+               }
+
+               len = cmd_mbc_buf_len;
+               cmd_mbc_buf_len = 0;
+       }
+
+       if (literal)
+       {
+               /*
+                * Insert the char, even if it is a line-editing char.
+                */
+               literal = 0;
+               return (cmd_ichar(cmd_mbc_buf, len));
+       }
+               
+       /*
+        * See if it is a line-editing character.
+        */
+       if (in_mca() && len == 1)
+       {
+               action = cmd_edit(c);
+               switch (action)
+               {
+               case CC_OK:
+               case CC_QUIT:
+                       return (action);
+               case CC_PASS:
+                       break;
+               }
+       }
+       
+       /*
+        * Insert the char into the command buffer.
+        */
+       return (cmd_ichar(cmd_mbc_buf, len));
+}
+
+/*
+ * Return the number currently in the command buffer.
+ */
+       public LINENUM
+cmd_int(frac)
+       long *frac;
+{
+       char *p;
+       LINENUM n = 0;
+       int err;
+
+       for (p = cmdbuf;  *p >= '0' && *p <= '9';  p++)
+               n = (n * 10) + (*p - '0');
+       *frac = 0;
+       if (*p++ == '.')
+       {
+               *frac = getfraction(&p, NULL, &err);
+               /* {{ do something if err is set? }} */
+       }
+       return (n);
+}
+
+/*
+ * Return a pointer to the command buffer.
+ */
+       public char *
+get_cmdbuf()
+{
+       return (cmdbuf);
+}
+
+#if CMD_HISTORY
+/*
+ * Return the last (most recent) string in the current command history.
+ */
+       public char *
+cmd_lastpattern()
+{
+       if (curr_mlist == NULL)
+               return (NULL);
+       return (curr_mlist->curr_mp->prev->string);
+}
+#endif
+
+#if CMD_HISTORY
+/*
+ * Get the name of the history file.
+ */
+       static char *
+histfile_name()
+{
+       char *home;
+       char *name;
+       int len;
+       
+       /* See if filename is explicitly specified by $LESSHISTFILE. */
+       name = lgetenv("LESSHISTFILE");
+       if (name != NULL && *name != '\0')
+       {
+               if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0)
+                       /* $LESSHISTFILE == "-" means don't use a history file. */
+                       return (NULL);
+               return (save(name));
+       }
+
+       /* Otherwise, file is in $HOME. */
+       home = lgetenv("HOME");
+       if (home == NULL || *home == '\0')
+       {
+#if OS2
+               home = lgetenv("INIT");
+               if (home == NULL || *home == '\0')
+#endif
+                       return (NULL);
+       }
+       len = strlen(home) + strlen(LESSHISTFILE) + 2;
+       name = (char *) ecalloc(len, sizeof(char));
+       SNPRINTF2(name, len, "%s/%s", home, LESSHISTFILE);
+       return (name);
+}
+#endif /* CMD_HISTORY */
+
+/*
+ * Initialize history from a .lesshist file.
+ */
+       public void
+init_cmdhist()
+{
+#if CMD_HISTORY
+       struct mlist *ml = NULL;
+       char line[CMDBUF_SIZE];
+       char *filename;
+       FILE *f;
+       char *p;
+
+       filename = histfile_name();
+       if (filename == NULL)
+               return;
+       f = fopen(filename, "r");
+       free(filename);
+       if (f == NULL)
+               return;
+       if (fgets(line, sizeof(line), f) == NULL ||
+           strncmp(line, HISTFILE_FIRST_LINE, strlen(HISTFILE_FIRST_LINE)) != 0)
+       {
+               fclose(f);
+               return;
+       }
+       while (fgets(line, sizeof(line), f) != NULL)
+       {
+               for (p = line;  *p != '\0';  p++)
+               {
+                       if (*p == '\n' || *p == '\r')
+                       {
+                               *p = '\0';
+                               break;
+                       }
+               }
+               if (strcmp(line, HISTFILE_SEARCH_SECTION) == 0)
+                       ml = &mlist_search;
+               else if (strcmp(line, HISTFILE_SHELL_SECTION) == 0)
+               {
+#if SHELL_ESCAPE || PIPEC
+                       ml = &mlist_shell;
+#else
+                       ml = NULL;
+#endif
+               } else if (*line == '"')
+               {
+                       if (ml != NULL)
+                               cmd_addhist(ml, line+1);
+               }
+       }
+       fclose(f);
+#endif /* CMD_HISTORY */
+}
+
+/*
+ *
+ */
+#if CMD_HISTORY
+       static void
+save_mlist(ml, f)
+       struct mlist *ml;
+       FILE *f;
+{
+       int histsize = 0;
+       int n;
+       char *s;
+
+       s = lgetenv("LESSHISTSIZE");
+       if (s != NULL)
+               histsize = atoi(s);
+       if (histsize == 0)
+               histsize = 100;
+
+       ml = ml->prev;
+       for (n = 0;  n < histsize;  n++)
+       {
+               if (ml->string == NULL)
+                       break;
+               ml = ml->prev;
+       }
+       for (ml = ml->next;  ml->string != NULL;  ml = ml->next)
+               fprintf(f, "\"%s\n", ml->string);
+}
+#endif /* CMD_HISTORY */
+
+/*
+ *
+ */
+       public void
+save_cmdhist()
+{
+#if CMD_HISTORY
+       char *filename;
+       FILE *f;
+       int modified = 0;
+
+       filename = histfile_name();
+       if (filename == NULL)
+               return;
+       if (mlist_search.modified)
+               modified = 1;
+#if SHELL_ESCAPE || PIPEC
+       if (mlist_shell.modified)
+               modified = 1;
+#endif
+       if (!modified)
+               return;
+       f = fopen(filename, "w");
+       free(filename);
+       if (f == NULL)
+               return;
+#if HAVE_FCHMOD
+{
+       /* Make history file readable only by owner. */
+       int do_chmod = 1;
+#if HAVE_STAT
+       struct stat statbuf;
+       int r = fstat(fileno(f), &statbuf);
+       if (r < 0 || !S_ISREG(statbuf.st_mode))
+               /* Don't chmod if not a regular file. */
+               do_chmod = 0;
+#endif
+       if (do_chmod)
+               fchmod(fileno(f), 0600);
+}
+#endif
+
+       fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
+
+       fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
+       save_mlist(&mlist_search, f);
+
+#if SHELL_ESCAPE || PIPEC
+       fprintf(f, "%s\n", HISTFILE_SHELL_SECTION);
+       save_mlist(&mlist_shell, f);
+#endif
+
+       fclose(f);
+#endif /* CMD_HISTORY */
+}
diff --git a/thirdparty/less/command.c b/thirdparty/less/command.c
new file mode 100644 (file)
index 0000000..bacb058
--- /dev/null
@@ -0,0 +1,1763 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * User-level command processor.
+ */
+
+#include "less.h"
+#if MSDOS_COMPILER==WIN32C
+#include <windows.h>
+#endif
+#include "position.h"
+#include "option.h"
+#include "cmd.h"
+
+extern int erase_char, erase2_char, kill_char;
+extern int sigs;
+extern int quit_if_one_screen;
+extern int squished;
+extern int sc_width;
+extern int sc_height;
+extern int swindow;
+extern int jump_sline;
+extern int quitting;
+extern int wscroll;
+extern int top_scroll;
+extern int ignore_eoi;
+extern int secure;
+extern int hshift;
+extern int show_attn;
+extern char *every_first_cmd;
+extern char *curr_altfilename;
+extern char version[];
+extern struct scrpos initial_scrpos;
+extern IFILE curr_ifile;
+extern void constant *ml_search;
+extern void constant *ml_examine;
+#if SHELL_ESCAPE || PIPEC
+extern void constant *ml_shell;
+#endif
+#if EDITOR
+extern char *editor;
+extern char *editproto;
+#endif
+extern int screen_trashed;     /* The screen has been overwritten */
+extern int shift_count;
+extern int oldbot;
+extern int forw_prompt;
+
+#if SHELL_ESCAPE
+static char *shellcmd = NULL;  /* For holding last shell command for "!!" */
+#endif
+static int mca;                        /* The multicharacter command (action) */
+static int search_type;                /* The previous type of search */
+static LINENUM number;         /* The number typed by the user */
+static long fraction;          /* The fractional part of the number */
+static struct loption *curropt;
+static int opt_lower;
+static int optflag;
+static int optgetname;
+static POSITION bottompos;
+static int save_hshift;
+#if PIPEC
+static char pipec;
+#endif
+
+struct ungot {
+       struct ungot *ug_next;
+       char ug_char;
+};
+static struct ungot* ungot = NULL;
+static int unget_end = 0;
+
+static void multi_search();
+
+/*
+ * Move the cursor to start of prompt line before executing a command.
+ * This looks nicer if the command takes a long time before
+ * updating the screen.
+ */
+       static void
+cmd_exec()
+{
+#if HILITE_SEARCH
+       clear_attn();
+#endif
+       clear_bot();
+       flush();
+}
+
+/*
+ * Set up the display to start a new multi-character command.
+ */
+       static void
+start_mca(action, prompt, mlist, cmdflags)
+       int action;
+       char *prompt;
+       void *mlist;
+       int cmdflags;
+{
+       mca = action;
+       clear_bot();
+       clear_cmd();
+       cmd_putstr(prompt);
+       set_mlist(mlist, cmdflags);
+}
+
+       public int
+in_mca()
+{
+       return (mca != 0 && mca != A_PREFIX);
+}
+
+/*
+ * Set up the display to start a new search command.
+ */
+       static void
+mca_search()
+{
+#if HILITE_SEARCH
+       if (search_type & SRCH_FILTER)
+               mca = A_FILTER;
+       else 
+#endif
+       if (search_type & SRCH_FORW)
+               mca = A_F_SEARCH;
+       else
+               mca = A_B_SEARCH;
+
+       clear_bot();
+       clear_cmd();
+
+       if (search_type & SRCH_NO_MATCH)
+               cmd_putstr("Non-match ");
+       if (search_type & SRCH_FIRST_FILE)
+               cmd_putstr("First-file ");
+       if (search_type & SRCH_PAST_EOF)
+               cmd_putstr("EOF-ignore ");
+       if (search_type & SRCH_NO_MOVE)
+               cmd_putstr("Keep-pos ");
+       if (search_type & SRCH_NO_REGEX)
+               cmd_putstr("Regex-off ");
+
+#if HILITE_SEARCH
+       if (search_type & SRCH_FILTER)
+               cmd_putstr("&/");
+       else 
+#endif
+       if (search_type & SRCH_FORW)
+               cmd_putstr("/");
+       else
+               cmd_putstr("?");
+       set_mlist(ml_search, 0);
+}
+
+/*
+ * Set up the display to start a new toggle-option command.
+ */
+       static void
+mca_opt_toggle()
+{
+       int no_prompt;
+       int flag;
+       char *dash;
+       
+       no_prompt = (optflag & OPT_NO_PROMPT);
+       flag = (optflag & ~OPT_NO_PROMPT);
+       dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";
+
+       mca = A_OPT_TOGGLE;
+       clear_bot();
+       clear_cmd();
+       cmd_putstr(dash);
+       if (optgetname)
+               cmd_putstr(dash);
+       if (no_prompt)
+               cmd_putstr("(P)");
+       switch (flag)
+       {
+       case OPT_UNSET:
+               cmd_putstr("+");
+               break;
+       case OPT_SET:
+               cmd_putstr("!");
+               break;
+       }
+       set_mlist(NULL, 0);
+}
+
+/*
+ * Execute a multicharacter command.
+ */
+       static void
+exec_mca()
+{
+       register char *cbuf;
+
+       cmd_exec();
+       cbuf = get_cmdbuf();
+
+       switch (mca)
+       {
+       case A_F_SEARCH:
+       case A_B_SEARCH:
+               multi_search(cbuf, (int) number);
+               break;
+#if HILITE_SEARCH
+       case A_FILTER:
+               search_type ^= SRCH_NO_MATCH;
+               set_filter_pattern(cbuf, search_type);
+               break;
+#endif
+       case A_FIRSTCMD:
+               /*
+                * Skip leading spaces or + signs in the string.
+                */
+               while (*cbuf == '+' || *cbuf == ' ')
+                       cbuf++;
+               if (every_first_cmd != NULL)
+                       free(every_first_cmd);
+               if (*cbuf == '\0')
+                       every_first_cmd = NULL;
+               else
+                       every_first_cmd = save(cbuf);
+               break;
+       case A_OPT_TOGGLE:
+               toggle_option(curropt, opt_lower, cbuf, optflag);
+               curropt = NULL;
+               break;
+       case A_F_BRACKET:
+               match_brac(cbuf[0], cbuf[1], 1, (int) number);
+               break;
+       case A_B_BRACKET:
+               match_brac(cbuf[1], cbuf[0], 0, (int) number);
+               break;
+#if EXAMINE
+       case A_EXAMINE:
+               if (secure)
+                       break;
+               edit_list(cbuf);
+#if TAGS
+               /* If tag structure is loaded then clean it up. */
+               cleantags();
+#endif
+               break;
+#endif
+#if SHELL_ESCAPE
+       case A_SHELL:
+               /*
+                * !! just uses whatever is in shellcmd.
+                * Otherwise, copy cmdbuf to shellcmd,
+                * expanding any special characters ("%" or "#").
+                */
+               if (*cbuf != '!')
+               {
+                       if (shellcmd != NULL)
+                               free(shellcmd);
+                       shellcmd = fexpand(cbuf);
+               }
+
+               if (secure)
+                       break;
+               if (shellcmd == NULL)
+                       lsystem("", "!done");
+               else
+                       lsystem(shellcmd, "!done");
+               break;
+#endif
+#if PIPEC
+       case A_PIPE:
+               if (secure)
+                       break;
+               (void) pipe_mark(pipec, cbuf);
+               error("|done", NULL_PARG);
+               break;
+#endif
+       }
+}
+
+/*
+ * Is a character an erase or kill char?
+ */
+       static int
+is_erase_char(c)
+       int c;
+{
+       return (c == erase_char || c == erase2_char || c == kill_char);
+}
+
+/*
+ * Handle the first char of an option (after the initial dash).
+ */
+       static int
+mca_opt_first_char(c)
+    int c;
+{
+       int flag = (optflag & ~OPT_NO_PROMPT);
+       if (flag == OPT_NO_TOGGLE)
+       {
+               switch (c)
+               {
+               case '_':
+                       /* "__" = long option name. */
+                       optgetname = TRUE;
+                       mca_opt_toggle();
+                       return (MCA_MORE);
+               }
+       } else
+       {
+               switch (c)
+               {
+               case '+':
+                       /* "-+" = UNSET. */
+                       optflag = (flag == OPT_UNSET) ?
+                               OPT_TOGGLE : OPT_UNSET;
+                       mca_opt_toggle();
+                       return (MCA_MORE);
+               case '!':
+                       /* "-!" = SET */
+                       optflag = (flag == OPT_SET) ?
+                               OPT_TOGGLE : OPT_SET;
+                       mca_opt_toggle();
+                       return (MCA_MORE);
+               case CONTROL('P'):
+                       optflag ^= OPT_NO_PROMPT;
+                       mca_opt_toggle();
+                       return (MCA_MORE);
+               case '-':
+                       /* "--" = long option name. */
+                       optgetname = TRUE;
+                       mca_opt_toggle();
+                       return (MCA_MORE);
+               }
+       }
+       /* Char was not handled here. */
+       return (NO_MCA);
+}
+
+/*
+ * Add a char to a long option name.
+ * See if we've got a match for an option name yet.
+ * If so, display the complete name and stop 
+ * accepting chars until user hits RETURN.
+ */
+       static int
+mca_opt_nonfirst_char(c)
+       int c;
+{
+       char *p;
+       char *oname;
+
+       if (curropt != NULL)
+       {
+               /*
+                * Already have a match for the name.
+                * Don't accept anything but erase/kill.
+                */
+               if (is_erase_char(c))
+                       return (MCA_DONE);
+               return (MCA_MORE);
+       }
+       /*
+        * Add char to cmd buffer and try to match
+        * the option name.
+        */
+       if (cmd_char(c) == CC_QUIT)
+               return (MCA_DONE);
+       p = get_cmdbuf();
+       opt_lower = ASCII_IS_LOWER(p[0]);
+       curropt = findopt_name(&p, &oname, NULL);
+       if (curropt != NULL)
+       {
+               /*
+                * Got a match.
+                * Remember the option and
+                * display the full option name.
+                */
+               cmd_reset();
+               mca_opt_toggle();
+               for (p = oname;  *p != '\0';  p++)
+               {
+                       c = *p;
+                       if (!opt_lower && ASCII_IS_LOWER(c))
+                               c = ASCII_TO_UPPER(c);
+                       if (cmd_char(c) != CC_OK)
+                               return (MCA_DONE);
+               }
+       }
+       return (MCA_MORE);
+}
+
+/*
+ * Handle a char of an option toggle command.
+ */
+       static int
+mca_opt_char(c)
+       int c;
+{
+       PARG parg;
+
+       /*
+        * This may be a short option (single char),
+        * or one char of a long option name,
+        * or one char of the option parameter.
+        */
+       if (curropt == NULL && len_cmdbuf() == 0)
+       {
+               int ret = mca_opt_first_char(c);
+               if (ret != NO_MCA)
+                       return (ret);
+       }
+       if (optgetname)
+       {
+               /* We're getting a long option name.  */
+               if (c != '\n' && c != '\r')
+                       return (mca_opt_nonfirst_char(c));
+               if (curropt == NULL)
+               {
+                       parg.p_string = get_cmdbuf();
+                       error("There is no --%s option", &parg);
+                       return (MCA_DONE);
+               }
+               optgetname = FALSE;
+               cmd_reset();
+       } else
+       {
+               if (is_erase_char(c))
+                       return (NO_MCA);
+               if (curropt != NULL)
+                       /* We're getting the option parameter. */
+                       return (NO_MCA);
+               curropt = findopt(c);
+               if (curropt == NULL)
+               {
+                       parg.p_string = propt(c);
+                       error("There is no %s option", &parg);
+                       return (MCA_DONE);
+               }
+       }
+       /*
+        * If the option which was entered does not take a 
+        * parameter, toggle the option immediately,
+        * so user doesn't have to hit RETURN.
+        */
+       if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE ||
+           !opt_has_param(curropt))
+       {
+               toggle_option(curropt, ASCII_IS_LOWER(c), "", optflag);
+               return (MCA_DONE);
+       }
+       /*
+        * Display a prompt appropriate for the option parameter.
+        */
+       start_mca(A_OPT_TOGGLE, opt_prompt(curropt), (void*)NULL, 0);
+       return (MCA_MORE);
+}
+
+/*
+ * Handle a char of a search command.
+ */
+       static int
+mca_search_char(c)
+       int c;
+{
+       int flag = 0;
+
+       /*
+        * Certain characters as the first char of 
+        * the pattern have special meaning:
+        *      !  Toggle the NO_MATCH flag
+        *      *  Toggle the PAST_EOF flag
+        *      @  Toggle the FIRST_FILE flag
+        */
+       if (len_cmdbuf() > 0)
+               return (NO_MCA);
+
+       switch (c)
+       {
+       case CONTROL('E'): /* ignore END of file */
+       case '*':
+               if (mca != A_FILTER)
+                       flag = SRCH_PAST_EOF;
+               break;
+       case CONTROL('F'): /* FIRST file */
+       case '@':
+               if (mca != A_FILTER)
+                       flag = SRCH_FIRST_FILE;
+               break;
+       case CONTROL('K'): /* KEEP position */
+               if (mca != A_FILTER)
+                       flag = SRCH_NO_MOVE;
+               break;
+       case CONTROL('R'): /* Don't use REGULAR EXPRESSIONS */
+               flag = SRCH_NO_REGEX;
+               break;
+       case CONTROL('N'): /* NOT match */
+       case '!':
+               flag = SRCH_NO_MATCH;
+               break;
+       }
+
+       if (flag != 0)
+       {
+               search_type ^= flag;
+               mca_search();
+               return (MCA_MORE);
+       }
+       return (NO_MCA);
+}
+
+/*
+ * Handle a character of a multi-character command.
+ */
+       static int
+mca_char(c)
+       int c;
+{
+       int ret;
+
+       switch (mca)
+       {
+       case 0:
+               /*
+                * We're not in a multicharacter command.
+                */
+               return (NO_MCA);
+
+       case A_PREFIX:
+               /*
+                * In the prefix of a command.
+                * This not considered a multichar command
+                * (even tho it uses cmdbuf, etc.).
+                * It is handled in the commands() switch.
+                */
+               return (NO_MCA);
+
+       case A_DIGIT:
+               /*
+                * Entering digits of a number.
+                * Terminated by a non-digit.
+                */
+               if (!((c >= '0' && c <= '9') || c == '.') && 
+                 editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE|EC_NORIGHTLEFT) == A_INVALID)
+               {
+                       /*
+                        * Not part of the number.
+                        * End the number and treat this char 
+                        * as a normal command character.
+                        */
+                       number = cmd_int(&fraction);
+                       mca = 0;
+                       cmd_accept();
+                       return (NO_MCA);
+               }
+               break;
+
+       case A_OPT_TOGGLE:
+               ret = mca_opt_char(c);
+               if (ret != NO_MCA)
+                       return (ret);
+               break;
+
+       case A_F_SEARCH:
+       case A_B_SEARCH:
+       case A_FILTER:
+               ret = mca_search_char(c);
+               if (ret != NO_MCA)
+                       return (ret);
+               break;
+
+       default:
+               /* Other multicharacter command. */
+               break;
+       }
+
+       /*
+        * The multichar command is terminated by a newline.
+        */
+       if (c == '\n' || c == '\r')
+       {
+               /*
+                * Execute the command.
+                */
+               exec_mca();
+               return (MCA_DONE);
+       }
+
+       /*
+        * Append the char to the command buffer.
+        */
+       if (cmd_char(c) == CC_QUIT)
+               /*
+                * Abort the multi-char command.
+                */
+               return (MCA_DONE);
+
+       if ((mca == A_F_BRACKET || mca == A_B_BRACKET) && len_cmdbuf() >= 2)
+       {
+               /*
+                * Special case for the bracket-matching commands.
+                * Execute the command after getting exactly two
+                * characters from the user.
+                */
+               exec_mca();
+               return (MCA_DONE);
+       }
+
+       /*
+        * Need another character.
+        */
+       return (MCA_MORE);
+}
+
+/*
+ * Discard any buffered file data.
+ */
+       static void
+clear_buffers()
+{
+       if (!(ch_getflags() & CH_CANSEEK))
+               return;
+       ch_flush();
+       clr_linenum();
+#if HILITE_SEARCH
+       clr_hilite();
+#endif
+}
+
+/*
+ * Make sure the screen is displayed.
+ */
+       static void
+make_display()
+{
+       /*
+        * If nothing is displayed yet, display starting from initial_scrpos.
+        */
+       if (empty_screen())
+       {
+               if (initial_scrpos.pos == NULL_POSITION)
+                       /*
+                        * {{ Maybe this should be:
+                        *    jump_loc(ch_zero(), jump_sline);
+                        *    but this behavior seems rather unexpected 
+                        *    on the first screen. }}
+                        */
+                       jump_loc(ch_zero(), 1);
+               else
+                       jump_loc(initial_scrpos.pos, initial_scrpos.ln);
+       } else if (screen_trashed)
+       {
+               int save_top_scroll = top_scroll;
+               int save_ignore_eoi = ignore_eoi;
+               top_scroll = 1;
+               ignore_eoi = 0;
+               if (screen_trashed == 2)
+               {
+                       /* Special case used by ignore_eoi: re-open the input file
+                        * and jump to the end of the file. */
+                       reopen_curr_ifile();
+                       jump_forw();
+               }
+               repaint();
+               top_scroll = save_top_scroll;
+               ignore_eoi = save_ignore_eoi;
+       }
+}
+
+/*
+ * Display the appropriate prompt.
+ */
+       static void
+prompt()
+{
+       register char *p;
+
+       if (ungot != NULL)
+       {
+               /*
+                * No prompt necessary if commands are from 
+                * ungotten chars rather than from the user.
+                */
+               return;
+       }
+
+       /*
+        * Make sure the screen is displayed.
+        */
+       make_display();
+       bottompos = position(BOTTOM_PLUS_ONE);
+
+       /*
+        * If we've hit EOF on the last file and the -E flag is set, quit.
+        */
+       if (get_quit_at_eof() == OPT_ONPLUS &&
+           eof_displayed() && !(ch_getflags() & CH_HELPFILE) && 
+           next_ifile(curr_ifile) == NULL_IFILE)
+               quit(QUIT_OK);
+
+       /*
+        * If the entire file is displayed and the -F flag is set, quit.
+        */
+       if (quit_if_one_screen &&
+           entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) && 
+           next_ifile(curr_ifile) == NULL_IFILE)
+               quit(QUIT_OK);
+
+#if MSDOS_COMPILER==WIN32C
+       /* 
+        * In Win32, display the file name in the window title.
+        */
+       if (!(ch_getflags() & CH_HELPFILE))
+               SetConsoleTitle(pr_expand("Less?f - %f.", 0));
+#endif
+       /*
+        * Select the proper prompt and display it.
+        */
+       /*
+        * If the previous action was a forward movement, 
+        * don't clear the bottom line of the display;
+        * just print the prompt since the forward movement guarantees 
+        * that we're in the right position to display the prompt.
+        * Clearing the line could cause a problem: for example, if the last
+        * line displayed ended at the right screen edge without a newline,
+        * then clearing would clear the last displayed line rather than
+        * the prompt line.
+        */
+       if (!forw_prompt)
+               clear_bot();
+       clear_cmd();
+       forw_prompt = 0;
+       p = pr_string();
+       if (is_filtering())
+               putstr("& ");
+       if (p == NULL || *p == '\0')
+               putchr(':');
+       else
+       {
+               at_enter(AT_STANDOUT);
+               putstr(p);
+               at_exit();
+       }
+       clear_eol();
+}
+
+/*
+ * Display the less version message.
+ */
+       public void
+dispversion()
+{
+       PARG parg;
+
+       parg.p_string = version;
+       error("less %s", &parg);
+}
+
+/*
+ * Get command character.
+ * The character normally comes from the keyboard,
+ * but may come from ungotten characters
+ * (characters previously given to ungetcc or ungetsc).
+ */
+       public int
+getcc()
+{
+       if (unget_end) 
+       {
+               /*
+                * We have just run out of ungotten chars.
+                */
+               unget_end = 0;
+               if (len_cmdbuf() == 0 || !empty_screen())
+                       return (getchr());
+               /*
+                * Command is incomplete, so try to complete it.
+                */
+               switch (mca)
+               {
+               case A_DIGIT:
+                       /*
+                        * We have a number but no command.  Treat as #g.
+                        */
+                       return ('g');
+
+               case A_F_SEARCH:
+               case A_B_SEARCH:
+                       /*
+                        * We have "/string" but no newline.  Add the \n.
+                        */
+                       return ('\n'); 
+
+               default:
+                       /*
+                        * Some other incomplete command.  Let user complete it.
+                        */
+                       return (getchr());
+               }
+       }
+
+       if (ungot == NULL)
+       {
+               /*
+                * Normal case: no ungotten chars, so get one from the user.
+                */
+               return (getchr());
+       }
+
+       /*
+        * Return the next ungotten char.
+        */
+       {
+               struct ungot *ug = ungot;
+               char c = ug->ug_char;
+               ungot = ug->ug_next;
+               free(ug);
+               unget_end = (ungot == NULL);
+               return (c);
+       }
+}
+
+/*
+ * "Unget" a command character.
+ * The next getcc() will return this character.
+ */
+       public void
+ungetcc(c)
+       int c;
+{
+       struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot));
+
+       ug->ug_char = c;
+       ug->ug_next = ungot;
+       ungot = ug;
+       unget_end = 0;
+}
+
+/*
+ * Unget a whole string of command characters.
+ * The next sequence of getcc()'s will return this string.
+ */
+       public void
+ungetsc(s)
+       char *s;
+{
+       register char *p;
+
+       for (p = s + strlen(s) - 1;  p >= s;  p--)
+               ungetcc(*p);
+}
+
+/*
+ * Search for a pattern, possibly in multiple files.
+ * If SRCH_FIRST_FILE is set, begin searching at the first file.
+ * If SRCH_PAST_EOF is set, continue the search thru multiple files.
+ */
+       static void
+multi_search(pattern, n)
+       char *pattern;
+       int n;
+{
+       register int nomore;
+       IFILE save_ifile;
+       int changed_file;
+
+       changed_file = 0;
+       save_ifile = save_curr_ifile();
+
+       if (search_type & SRCH_FIRST_FILE)
+       {
+               /*
+                * Start at the first (or last) file 
+                * in the command line list.
+                */
+               if (search_type & SRCH_FORW)
+                       nomore = edit_first();
+               else
+                       nomore = edit_last();
+               if (nomore)
+               {
+                       unsave_ifile(save_ifile);
+                       return;
+               }
+               changed_file = 1;
+               search_type &= ~SRCH_FIRST_FILE;
+       }
+
+       for (;;)
+       {
+               n = search(search_type, pattern, n);
+               /*
+                * The SRCH_NO_MOVE flag doesn't "stick": it gets cleared
+                * after being used once.  This allows "n" to work after
+                * using a /@@ search.
+                */
+               search_type &= ~SRCH_NO_MOVE;
+               if (n == 0)
+               {
+                       /*
+                        * Found it.
+                        */
+                       unsave_ifile(save_ifile);
+                       return;
+               }
+
+               if (n < 0)
+                       /*
+                        * Some kind of error in the search.
+                        * Error message has been printed by search().
+                        */
+                       break;
+
+               if ((search_type & SRCH_PAST_EOF) == 0)
+                       /*
+                        * We didn't find a match, but we're
+                        * supposed to search only one file.
+                        */
+                       break;
+               /*
+                * Move on to the next file.
+                */
+               if (search_type & SRCH_FORW)
+                       nomore = edit_next(1);
+               else
+                       nomore = edit_prev(1);
+               if (nomore)
+                       break;
+               changed_file = 1;
+       }
+
+       /*
+        * Didn't find it.
+        * Print an error message if we haven't already.
+        */
+       if (n > 0)
+               error("Pattern not found", NULL_PARG);
+
+       if (changed_file)
+       {
+               /*
+                * Restore the file we were originally viewing.
+                */
+               reedit_ifile(save_ifile);
+       } else
+       {
+               unsave_ifile(save_ifile);
+       }
+}
+
+/*
+ * Main command processor.
+ * Accept and execute commands until a quit command.
+ */
+       public void
+commands()
+{
+       register int c;
+       register int action;
+       register char *cbuf;
+       int newaction;
+       int save_search_type;
+       char *extra;
+       char tbuf[2];
+       PARG parg;
+       IFILE old_ifile;
+       IFILE new_ifile;
+       char *tagfile;
+
+       search_type = SRCH_FORW;
+       wscroll = (sc_height + 1) / 2;
+       newaction = A_NOACTION;
+
+       for (;;)
+       {
+               mca = 0;
+               cmd_accept();
+               number = 0;
+               curropt = NULL;
+
+               /*
+                * See if any signals need processing.
+                */
+               if (sigs)
+               {
+                       psignals();
+                       if (quitting)
+                               quit(QUIT_SAVED_STATUS);
+               }
+
+               /*
+                * See if window size changed, for systems that don't
+                * generate SIGWINCH.
+                */
+               check_winch();
+
+               /*
+                * Display prompt and accept a character.
+                */
+               cmd_reset();
+               prompt();
+               if (sigs)
+                       continue;
+               if (newaction == A_NOACTION)
+                       c = getcc();
+
+       again:
+               if (sigs)
+                       continue;
+
+               if (newaction != A_NOACTION)
+               {
+                       action = newaction;
+                       newaction = A_NOACTION;
+               } else
+               {
+                       /*
+                        * If we are in a multicharacter command, call mca_char.
+                        * Otherwise we call fcmd_decode to determine the
+                        * action to be performed.
+                        */
+                       if (mca)
+                               switch (mca_char(c))
+                               {
+                               case MCA_MORE:
+                                       /*
+                                        * Need another character.
+                                        */
+                                       c = getcc();
+                                       goto again;
+                               case MCA_DONE:
+                                       /*
+                                        * Command has been handled by mca_char.
+                                        * Start clean with a prompt.
+                                        */
+                                       continue;
+                               case NO_MCA:
+                                       /*
+                                        * Not a multi-char command
+                                        * (at least, not anymore).
+                                        */
+                                       break;
+                               }
+
+                       /*
+                        * Decode the command character and decide what to do.
+                        */
+                       if (mca)
+                       {
+                               /*
+                                * We're in a multichar command.
+                                * Add the character to the command buffer
+                                * and display it on the screen.
+                                * If the user backspaces past the start 
+                                * of the line, abort the command.
+                                */
+                               if (cmd_char(c) == CC_QUIT || len_cmdbuf() == 0)
+                                       continue;
+                               cbuf = get_cmdbuf();
+                       } else
+                       {
+                               /*
+                                * Don't use cmd_char if we're starting fresh
+                                * at the beginning of a command, because we
+                                * don't want to echo the command until we know
+                                * it is a multichar command.  We also don't
+                                * want erase_char/kill_char to be treated
+                                * as line editing characters.
+                                */
+                               tbuf[0] = c;
+                               tbuf[1] = '\0';
+                               cbuf = tbuf;
+                       }
+                       extra = NULL;
+                       action = fcmd_decode(cbuf, &extra);
+                       /*
+                        * If an "extra" string was returned,
+                        * process it as a string of command characters.
+                        */
+                       if (extra != NULL)
+                               ungetsc(extra);
+               }
+               /*
+                * Clear the cmdbuf string.
+                * (But not if we're in the prefix of a command,
+                * because the partial command string is kept there.)
+                */
+               if (action != A_PREFIX)
+                       cmd_reset();
+
+               switch (action)
+               {
+               case A_DIGIT:
+                       /*
+                        * First digit of a number.
+                        */
+                       start_mca(A_DIGIT, ":", (void*)NULL, CF_QUIT_ON_ERASE);
+                       goto again;
+
+               case A_F_WINDOW:
+                       /*
+                        * Forward one window (and set the window size).
+                        */
+                       if (number > 0)
+                               swindow = (int) number;
+                       /* FALLTHRU */
+               case A_F_SCREEN:
+                       /*
+                        * Forward one screen.
+                        */
+                       if (number <= 0)
+                               number = get_swindow();
+                       cmd_exec();
+                       if (show_attn)
+                               set_attnpos(bottompos);
+                       forward((int) number, 0, 1);
+                       break;
+
+               case A_B_WINDOW:
+                       /*
+                        * Backward one window (and set the window size).
+                        */
+                       if (number > 0)
+                               swindow = (int) number;
+                       /* FALLTHRU */
+               case A_B_SCREEN:
+                       /*
+                        * Backward one screen.
+                        */
+                       if (number <= 0)
+                               number = get_swindow();
+                       cmd_exec();
+                       backward((int) number, 0, 1);
+                       break;
+
+               case A_F_LINE:
+                       /*
+                        * Forward N (default 1) line.
+                        */
+                       if (number <= 0)
+                               number = 1;
+                       cmd_exec();
+                       if (show_attn == OPT_ONPLUS && number > 1)
+                               set_attnpos(bottompos);
+                       forward((int) number, 0, 0);
+                       break;
+
+               case A_B_LINE:
+                       /*
+                        * Backward N (default 1) line.
+                        */
+                       if (number <= 0)
+                               number = 1;
+                       cmd_exec();
+                       backward((int) number, 0, 0);
+                       break;
+
+               case A_FF_LINE:
+                       /*
+                        * Force forward N (default 1) line.
+                        */
+                       if (number <= 0)
+                               number = 1;
+                       cmd_exec();
+                       if (show_attn == OPT_ONPLUS && number > 1)
+                               set_attnpos(bottompos);
+                       forward((int) number, 1, 0);
+                       break;
+
+               case A_BF_LINE:
+                       /*
+                        * Force backward N (default 1) line.
+                        */
+                       if (number <= 0)
+                               number = 1;
+                       cmd_exec();
+                       backward((int) number, 1, 0);
+                       break;
+               
+               case A_FF_SCREEN:
+                       /*
+                        * Force forward one screen.
+                        */
+                       if (number <= 0)
+                               number = get_swindow();
+                       cmd_exec();
+                       if (show_attn == OPT_ONPLUS)
+                               set_attnpos(bottompos);
+                       forward((int) number, 1, 0);
+                       break;
+
+               case A_F_FOREVER:
+                       /*
+                        * Forward forever, ignoring EOF.
+                        */
+                       if (ch_getflags() & CH_HELPFILE)
+                               break;
+                       cmd_exec();
+                       jump_forw();
+                       ignore_eoi = 1;
+                       while (!sigs)
+                       {
+                               make_display();
+                               forward(1, 0, 0);
+                       }
+                       ignore_eoi = 0;
+                       /*
+                        * This gets us back in "F mode" after processing 
+                        * a non-abort signal (e.g. window-change).  
+                        */
+                       if (sigs && !ABORT_SIGS())
+                               newaction = A_F_FOREVER;
+                       break;
+
+               case A_F_SCROLL:
+                       /*
+                        * Forward N lines 
+                        * (default same as last 'd' or 'u' command).
+                        */
+                       if (number > 0)
+                               wscroll = (int) number;
+                       cmd_exec();
+                       if (show_attn == OPT_ONPLUS)
+                               set_attnpos(bottompos);
+                       forward(wscroll, 0, 0);
+                       break;
+
+               case A_B_SCROLL:
+                       /*
+                        * Forward N lines 
+                        * (default same as last 'd' or 'u' command).
+                        */
+                       if (number > 0)
+                               wscroll = (int) number;
+                       cmd_exec();
+                       backward(wscroll, 0, 0);
+                       break;
+
+               case A_FREPAINT:
+                       /*
+                        * Flush buffers, then repaint screen.
+                        * Don't flush the buffers on a pipe!
+                        */
+                       clear_buffers();
+                       /* FALLTHRU */
+               case A_REPAINT:
+                       /*
+                        * Repaint screen.
+                        */
+                       cmd_exec();
+                       repaint();
+                       break;
+
+               case A_GOLINE:
+                       /*
+                        * Go to line N, default beginning of file.
+                        */
+                       if (number <= 0)
+                               number = 1;
+                       cmd_exec();
+                       jump_back(number);
+                       break;
+
+               case A_PERCENT:
+                       /*
+                        * Go to a specified percentage into the file.
+                        */
+                       if (number < 0)
+                       {
+                               number = 0;
+                               fraction = 0;
+                       }
+                       if (number > 100)
+                       {
+                               number = 100;
+                               fraction = 0;
+                       }
+                       cmd_exec();
+                       jump_percent((int) number, fraction);
+                       break;
+
+               case A_GOEND:
+                       /*
+                        * Go to line N, default end of file.
+                        */
+                       cmd_exec();
+                       if (number <= 0)
+                               jump_forw();
+                       else
+                               jump_back(number);
+                       break;
+
+               case A_GOPOS:
+                       /*
+                        * Go to a specified byte position in the file.
+                        */
+                       cmd_exec();
+                       if (number < 0)
+                               number = 0;
+                       jump_line_loc((POSITION) number, jump_sline);
+                       break;
+
+               case A_STAT:
+                       /*
+                        * Print file name, etc.
+                        */
+                       if (ch_getflags() & CH_HELPFILE)
+                               break;
+                       cmd_exec();
+                       parg.p_string = eq_message();
+                       error("%s", &parg);
+                       break;
+
+               case A_VERSION:
+                       /*
+                        * Print version number, without the "@(#)".
+                        */
+                       cmd_exec();
+                       dispversion();
+                       break;
+
+               case A_QUIT:
+                       /*
+                        * Exit.
+                        */
+                       if (curr_ifile != NULL_IFILE && 
+                           ch_getflags() & CH_HELPFILE)
+                       {
+                               /*
+                                * Quit while viewing the help file
+                                * just means return to viewing the
+                                * previous file.
+                                */
+                               hshift = save_hshift;
+                               if (edit_prev(1) == 0)
+                                       break;
+                       }
+                       if (extra != NULL)
+                               quit(*extra);
+                       quit(QUIT_OK);
+                       break;
+
+/*
+ * Define abbreviation for a commonly used sequence below.
+ */
+#define        DO_SEARCH() \
+                       if (number <= 0) number = 1;    \
+                       mca_search();                   \
+                       cmd_exec();                     \
+                       multi_search((char *)NULL, (int) number);
+
+
+               case A_F_SEARCH:
+                       /*
+                        * Search forward for a pattern.
+                        * Get the first char of the pattern.
+                        */
+                       search_type = SRCH_FORW;
+                       if (number <= 0)
+                               number = 1;
+                       mca_search();
+                       c = getcc();
+                       goto again;
+
+               case A_B_SEARCH:
+                       /*
+                        * Search backward for a pattern.
+                        * Get the first char of the pattern.
+                        */
+                       search_type = SRCH_BACK;
+                       if (number <= 0)
+                               number = 1;
+                       mca_search();
+                       c = getcc();
+                       goto again;
+
+               case A_FILTER:
+#if HILITE_SEARCH
+                       search_type = SRCH_FORW | SRCH_FILTER;
+                       mca_search();
+                       c = getcc();
+                       goto again;
+#else
+                       error("Command not available", NULL_PARG);
+                       break;
+#endif
+
+               case A_AGAIN_SEARCH:
+                       /*
+                        * Repeat previous search.
+                        */
+                       DO_SEARCH();
+                       break;
+               
+               case A_T_AGAIN_SEARCH:
+                       /*
+                        * Repeat previous search, multiple files.
+                        */
+                       search_type |= SRCH_PAST_EOF;
+                       DO_SEARCH();
+                       break;
+
+               case A_REVERSE_SEARCH:
+                       /*
+                        * Repeat previous search, in reverse direction.
+                        */
+                       save_search_type = search_type;
+                       search_type = SRCH_REVERSE(search_type);
+                       DO_SEARCH();
+                       search_type = save_search_type;
+                       break;
+
+               case A_T_REVERSE_SEARCH:
+                       /* 
+                        * Repeat previous search, 
+                        * multiple files in reverse direction.
+                        */
+                       save_search_type = search_type;
+                       search_type = SRCH_REVERSE(search_type);
+                       search_type |= SRCH_PAST_EOF;
+                       DO_SEARCH();
+                       search_type = save_search_type;
+                       break;
+
+               case A_UNDO_SEARCH:
+                       undo_search();
+                       break;
+
+               case A_HELP:
+                       /*
+                        * Help.
+                        */
+                       if (ch_getflags() & CH_HELPFILE)
+                               break;
+                       cmd_exec();
+                       save_hshift = hshift;
+                       hshift = 0;
+                       (void) edit(FAKE_HELPFILE);
+                       break;
+
+               case A_EXAMINE:
+#if EXAMINE
+                       /*
+                        * Edit a new file.  Get the filename.
+                        */
+                       if (secure)
+                       {
+                               error("Command not available", NULL_PARG);
+                               break;
+                       }
+                       start_mca(A_EXAMINE, "Examine: ", ml_examine, 0);
+                       c = getcc();
+                       goto again;
+#else
+                       error("Command not available", NULL_PARG);
+                       break;
+#endif
+                       
+               case A_VISUAL:
+                       /*
+                        * Invoke an editor on the input file.
+                        */
+#if EDITOR
+                       if (secure)
+                       {
+                               error("Command not available", NULL_PARG);
+                               break;
+                       }
+                       if (ch_getflags() & CH_HELPFILE)
+                               break;
+                       if (strcmp(get_filename(curr_ifile), "-") == 0)
+                       {
+                               error("Cannot edit standard input", NULL_PARG);
+                               break;
+                       }
+                       if (curr_altfilename != NULL)
+                       {
+                               error("WARNING: This file was viewed via LESSOPEN",
+                                       NULL_PARG);
+                       }
+                       start_mca(A_SHELL, "!", ml_shell, 0);
+                       /*
+                        * Expand the editor prototype string
+                        * and pass it to the system to execute.
+                        * (Make sure the screen is displayed so the
+                        * expansion of "+%lm" works.)
+                        */
+                       make_display();
+                       cmd_exec();
+                       lsystem(pr_expand(editproto, 0), (char*)NULL);
+                       break;
+#else
+                       error("Command not available", NULL_PARG);
+                       break;
+#endif
+
+               case A_NEXT_FILE:
+                       /*
+                        * Examine next file.
+                        */
+#if TAGS
+                       if (ntags())
+                       {
+                               error("No next file", NULL_PARG);
+                               break;
+                       }
+#endif
+                       if (number <= 0)
+                               number = 1;
+                       if (edit_next((int) number))
+                       {
+                               if (get_quit_at_eof() && eof_displayed() && 
+                                   !(ch_getflags() & CH_HELPFILE))
+                                       quit(QUIT_OK);
+                               parg.p_string = (number > 1) ? "(N-th) " : "";
+                               error("No %snext file", &parg);
+                       }
+                       break;
+
+               case A_PREV_FILE:
+                       /*
+                        * Examine previous file.
+                        */
+#if TAGS
+                       if (ntags())
+                       {
+                               error("No previous file", NULL_PARG);
+                               break;
+                       }
+#endif
+                       if (number <= 0)
+                               number = 1;
+                       if (edit_prev((int) number))
+                       {
+                               parg.p_string = (number > 1) ? "(N-th) " : "";
+                               error("No %sprevious file", &parg);
+                       }
+                       break;
+
+               case A_NEXT_TAG:
+#if TAGS
+                       if (number <= 0)
+                               number = 1;
+                       tagfile = nexttag((int) number);
+                       if (tagfile == NULL)
+                       {
+                               error("No next tag", NULL_PARG);
+                               break;
+                       }
+                       if (edit(tagfile) == 0)
+                       {
+                               POSITION pos = tagsearch();
+                               if (pos != NULL_POSITION)
+                                       jump_loc(pos, jump_sline);
+                       }
+#else
+                       error("Command not available", NULL_PARG);
+#endif
+                       break;
+
+               case A_PREV_TAG:
+#if TAGS
+                       if (number <= 0)
+                               number = 1;
+                       tagfile = prevtag((int) number);
+                       if (tagfile == NULL)
+                       {
+                               error("No previous tag", NULL_PARG);
+                               break;
+                       }
+                       if (edit(tagfile) == 0)
+                       {
+                               POSITION pos = tagsearch();
+                               if (pos != NULL_POSITION)
+                                       jump_loc(pos, jump_sline);
+                       }
+#else
+                       error("Command not available", NULL_PARG);
+#endif
+                       break;
+
+               case A_INDEX_FILE:
+                       /*
+                        * Examine a particular file.
+                        */
+                       if (number <= 0)
+                               number = 1;
+                       if (edit_index((int) number))
+                               error("No such file", NULL_PARG);
+                       break;
+
+               case A_REMOVE_FILE:
+                       if (ch_getflags() & CH_HELPFILE)
+                               break;
+                       old_ifile = curr_ifile;
+                       new_ifile = getoff_ifile(curr_ifile);
+                       if (new_ifile == NULL_IFILE)
+                       {
+                               bell();
+                               break;
+                       }
+                       if (edit_ifile(new_ifile) != 0)
+                       {
+                               reedit_ifile(old_ifile);
+                               break;
+                       }
+                       del_ifile(old_ifile);
+                       break;
+
+               case A_OPT_TOGGLE:
+                       optflag = OPT_TOGGLE;
+                       optgetname = FALSE;
+                       mca_opt_toggle();
+                       c = getcc();
+                       goto again;
+
+               case A_DISP_OPTION:
+                       /*
+                        * Report a flag setting.
+                        */
+                       optflag = OPT_NO_TOGGLE;
+                       optgetname = FALSE;
+                       mca_opt_toggle();
+                       c = getcc();
+                       goto again;
+
+               case A_FIRSTCMD:
+                       /*
+                        * Set an initial command for new files.
+                        */
+                       start_mca(A_FIRSTCMD, "+", (void*)NULL, 0);
+                       c = getcc();
+                       goto again;
+
+               case A_SHELL:
+                       /*
+                        * Shell escape.
+                        */
+#if SHELL_ESCAPE
+                       if (secure)
+                       {
+                               error("Command not available", NULL_PARG);
+                               break;
+                       }
+                       start_mca(A_SHELL, "!", ml_shell, 0);
+                       c = getcc();
+                       goto again;
+#else
+                       error("Command not available", NULL_PARG);
+                       break;
+#endif
+
+               case A_SETMARK:
+                       /*
+                        * Set a mark.
+                        */
+                       if (ch_getflags() & CH_HELPFILE)
+                               break;
+                       start_mca(A_SETMARK, "mark: ", (void*)NULL, 0);
+                       c = getcc();
+                       if (c == erase_char || c == erase2_char ||
+                           c == kill_char || c == '\n' || c == '\r')
+                               break;
+                       setmark(c);
+                       break;
+
+               case A_GOMARK:
+                       /*
+                        * Go to a mark.
+                        */
+                       start_mca(A_GOMARK, "goto mark: ", (void*)NULL, 0);
+                       c = getcc();
+                       if (c == erase_char || c == erase2_char ||
+                           c == kill_char || c == '\n' || c == '\r')
+                               break;
+                       cmd_exec();
+                       gomark(c);
+                       break;
+
+               case A_PIPE:
+#if PIPEC
+                       if (secure)
+                       {
+                               error("Command not available", NULL_PARG);
+                               break;
+                       }
+                       start_mca(A_PIPE, "|mark: ", (void*)NULL, 0);
+                       c = getcc();
+                       if (c == erase_char || c == erase2_char || c == kill_char)
+                               break;
+                       if (c == '\n' || c == '\r')
+                               c = '.';
+                       if (badmark(c))
+                               break;
+                       pipec = c;
+                       start_mca(A_PIPE, "!", ml_shell, 0);
+                       c = getcc();
+                       goto again;
+#else
+                       error("Command not available", NULL_PARG);
+                       break;
+#endif
+
+               case A_B_BRACKET:
+               case A_F_BRACKET:
+                       start_mca(action, "Brackets: ", (void*)NULL, 0);
+                       c = getcc();
+                       goto again;
+
+               case A_LSHIFT:
+                       if (number > 0)
+                               shift_count = number;
+                       else
+                               number = (shift_count > 0) ?
+                                       shift_count : sc_width / 2;
+                       if (number > hshift)
+                               number = hshift;
+                       hshift -= number;
+                       screen_trashed = 1;
+                       break;
+
+               case A_RSHIFT:
+                       if (number > 0)
+                               shift_count = number;
+                       else
+                               number = (shift_count > 0) ?
+                                       shift_count : sc_width / 2;
+                       hshift += number;
+                       screen_trashed = 1;
+                       break;
+
+               case A_PREFIX:
+                       /*
+                        * The command is incomplete (more chars are needed).
+                        * Display the current char, so the user knows
+                        * what's going on, and get another character.
+                        */
+                       if (mca != A_PREFIX)
+                       {
+                               cmd_reset();
+                               start_mca(A_PREFIX, " ", (void*)NULL,
+                                       CF_QUIT_ON_ERASE);
+                               (void) cmd_char(c);
+                       }
+                       c = getcc();
+                       goto again;
+
+               case A_NOACTION:
+                       break;
+
+               default:
+                       bell();
+                       break;
+               }
+       }
+}
diff --git a/thirdparty/less/cvt.c b/thirdparty/less/cvt.c
new file mode 100644 (file)
index 0000000..7443984
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+/*
+ * Routines to convert text in various ways.  Used by search.
+ */
+
+#include "less.h"
+#include "charset.h"
+
+extern int utf_mode;
+
+/*
+ * Get the length of a buffer needed to convert a string.
+ */
+       public int
+cvt_length(len, ops)
+       int len;
+       int ops;
+{
+       if (utf_mode)
+               /*
+                * Just copying a string in UTF-8 mode can cause it to grow 
+                * in length.
+                * Four output bytes for one input byte is the worst case.
+                */
+               len *= 4;
+       return (len + 1);
+}
+
+/*
+ * Allocate a chpos array for use by cvt_text.
+ */
+       public int *
+cvt_alloc_chpos(len)
+       int len;
+{
+       int i;
+       int *chpos = (int *) ecalloc(sizeof(int), len);
+       /* Initialize all entries to an invalid position. */
+       for (i = 0;  i < len;  i++)
+               chpos[i] = -1;
+       return (chpos);
+}
+
+/*
+ * Convert text.  Perform the transformations specified by ops.
+ * Returns converted text in odst.  The original offset of each
+ * odst character (when it was in osrc) is returned in the chpos array.
+ */
+       public void
+cvt_text(odst, osrc, chpos, lenp, ops)
+       char *odst;
+       char *osrc;
+       int *chpos;
+       int *lenp;
+       int ops;
+{
+       char *dst;
+       char *src;
+       register char *src_end;
+       LWCHAR ch;
+
+       if (lenp != NULL)
+               src_end = osrc + *lenp;
+       else
+               src_end = osrc + strlen(osrc);
+
+       for (src = osrc, dst = odst;  src < src_end;  )
+       {
+               int src_pos = src - osrc;
+               int dst_pos = dst - odst;
+               ch = step_char(&src, +1, src_end);
+               if ((ops & CVT_BS) && ch == '\b' && dst > odst)
+               {
+                       /* Delete backspace and preceding char. */
+                       do {
+                               dst--;
+                       } while (dst > odst &&
+                               !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst));
+               } else if ((ops & CVT_ANSI) && IS_CSI_START(ch))
+               {
+                       /* Skip to end of ANSI escape sequence. */
+                       src++;  /* skip the CSI start char */
+                       while (src < src_end)
+                               if (!is_ansi_middle(*src++))
+                                       break;
+               } else
+               {
+                       /* Just copy the char to the destination buffer. */
+                       if ((ops & CVT_TO_LC) && IS_UPPER(ch))
+                               ch = TO_LOWER(ch);
+                       put_wchar(&dst, ch);
+                       /*
+                        * Record the original position of the char.
+                        * But if we've already recorded a position
+                        * for this char (due to a backspace), leave
+                        * it alone; if multiple source chars map to
+                        * one destination char, we want the position
+                        * of the first one.
+                        */
+                       if (chpos != NULL && chpos[dst_pos] < 0)
+                               chpos[dst_pos] = src_pos;
+               }
+       }
+       if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r')
+               dst--;
+       *dst = '\0';
+       if (lenp != NULL)
+               *lenp = dst - odst;
+       if (chpos != NULL)
+               chpos[dst - odst] = src - osrc;
+}
diff --git a/thirdparty/less/decode.c b/thirdparty/less/decode.c
new file mode 100644 (file)
index 0000000..65d65bb
--- /dev/null
@@ -0,0 +1,841 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to decode user commands.
+ *
+ * This is all table driven.
+ * A command table is a sequence of command descriptors.
+ * Each command descriptor is a sequence of bytes with the following format:
+ *     <c1><c2>...<cN><0><action>
+ * The characters c1,c2,...,cN are the command string; that is,
+ * the characters which the user must type.
+ * It is terminated by a null <0> byte.
+ * The byte after the null byte is the action code associated
+ * with the command string.
+ * If an action byte is OR-ed with A_EXTRA, this indicates
+ * that the option byte is followed by an extra string.
+ *
+ * There may be many command tables.
+ * The first (default) table is built-in.
+ * Other tables are read in from "lesskey" files.
+ * All the tables are linked together and are searched in order.
+ */
+
+#include "less.h"
+#include "cmd.h"
+#include "lesskey.h"
+
+extern int erase_char, erase2_char, kill_char;
+extern int secure;
+
+#define SK(k) \
+       SK_SPECIAL_KEY, (k), 6, 1, 1, 1
+/*
+ * Command table is ordered roughly according to expected
+ * frequency of use, so the common commands are near the beginning.
+ */
+
+static unsigned char cmdtable[] =
+{
+       '\r',0,                         A_F_LINE,
+       '\n',0,                         A_F_LINE,
+       'e',0,                          A_F_LINE,
+       'j',0,                          A_F_LINE,
+       SK(SK_DOWN_ARROW),0,            A_F_LINE,
+       CONTROL('E'),0,                 A_F_LINE,
+       CONTROL('N'),0,                 A_F_LINE,
+       'k',0,                          A_B_LINE,
+       'y',0,                          A_B_LINE,
+       CONTROL('Y'),0,                 A_B_LINE,
+       SK(SK_CONTROL_K),0,             A_B_LINE,
+       CONTROL('P'),0,                 A_B_LINE,
+       SK(SK_UP_ARROW),0,              A_B_LINE,
+       'J',0,                          A_FF_LINE,
+       'K',0,                          A_BF_LINE,
+       'Y',0,                          A_BF_LINE,
+       'd',0,                          A_F_SCROLL,
+       CONTROL('D'),0,                 A_F_SCROLL,
+       'u',0,                          A_B_SCROLL,
+       CONTROL('U'),0,                 A_B_SCROLL,
+       ' ',0,                          A_F_SCREEN,
+       'f',0,                          A_F_SCREEN,
+       CONTROL('F'),0,                 A_F_SCREEN,
+       CONTROL('V'),0,                 A_F_SCREEN,
+       SK(SK_PAGE_DOWN),0,             A_F_SCREEN,
+       'b',0,                          A_B_SCREEN,
+       CONTROL('B'),0,                 A_B_SCREEN,
+       ESC,'v',0,                      A_B_SCREEN,
+       SK(SK_PAGE_UP),0,               A_B_SCREEN,
+       'z',0,                          A_F_WINDOW,
+       'w',0,                          A_B_WINDOW,
+       ESC,' ',0,                      A_FF_SCREEN,
+       'F',0,                          A_F_FOREVER,
+       'R',0,                          A_FREPAINT,
+       'r',0,                          A_REPAINT,
+       CONTROL('R'),0,                 A_REPAINT,
+       CONTROL('L'),0,                 A_REPAINT,
+       ESC,'u',0,                      A_UNDO_SEARCH,
+       'g',0,                          A_GOLINE,
+       SK(SK_HOME),0,                  A_GOLINE,
+       '<',0,                          A_GOLINE,
+       ESC,'<',0,                      A_GOLINE,
+       'p',0,                          A_PERCENT,
+       '%',0,                          A_PERCENT,
+       ESC,'[',0,                      A_LSHIFT,
+       ESC,']',0,                      A_RSHIFT,
+       ESC,'(',0,                      A_LSHIFT,
+       ESC,')',0,                      A_RSHIFT,
+       SK(SK_RIGHT_ARROW),0,           A_RSHIFT,
+       SK(SK_LEFT_ARROW),0,            A_LSHIFT,
+       '{',0,                          A_F_BRACKET|A_EXTRA,    '{','}',0,
+       '}',0,                          A_B_BRACKET|A_EXTRA,    '{','}',0,
+       '(',0,                          A_F_BRACKET|A_EXTRA,    '(',')',0,
+       ')',0,                          A_B_BRACKET|A_EXTRA,    '(',')',0,
+       '[',0,                          A_F_BRACKET|A_EXTRA,    '[',']',0,
+       ']',0,                          A_B_BRACKET|A_EXTRA,    '[',']',0,
+       ESC,CONTROL('F'),0,             A_F_BRACKET,
+       ESC,CONTROL('B'),0,             A_B_BRACKET,
+       'G',0,                          A_GOEND,
+       ESC,'>',0,                      A_GOEND,
+       '>',0,                          A_GOEND,
+       SK(SK_END),0,                   A_GOEND,
+       'P',0,                          A_GOPOS,
+
+       '0',0,                          A_DIGIT,
+       '1',0,                          A_DIGIT,
+       '2',0,                          A_DIGIT,
+       '3',0,                          A_DIGIT,
+       '4',0,                          A_DIGIT,
+       '5',0,                          A_DIGIT,
+       '6',0,                          A_DIGIT,
+       '7',0,                          A_DIGIT,
+       '8',0,                          A_DIGIT,
+       '9',0,                          A_DIGIT,
+       '.',0,                          A_DIGIT,
+
+       '=',0,                          A_STAT,
+       CONTROL('G'),0,                 A_STAT,
+       ':','f',0,                      A_STAT,
+       '/',0,                          A_F_SEARCH,
+       '?',0,                          A_B_SEARCH,
+       ESC,'/',0,                      A_F_SEARCH|A_EXTRA,     '*',0,
+       ESC,'?',0,                      A_B_SEARCH|A_EXTRA,     '*',0,
+       'n',0,                          A_AGAIN_SEARCH,
+       ESC,'n',0,                      A_T_AGAIN_SEARCH,
+       'N',0,                          A_REVERSE_SEARCH,
+       ESC,'N',0,                      A_T_REVERSE_SEARCH,
+       '&',0,                          A_FILTER,
+       'm',0,                          A_SETMARK,
+       '\'',0,                         A_GOMARK,
+       CONTROL('X'),CONTROL('X'),0,    A_GOMARK,
+       'E',0,                          A_EXAMINE,
+       ':','e',0,                      A_EXAMINE,
+       CONTROL('X'),CONTROL('V'),0,    A_EXAMINE,
+       ':','n',0,                      A_NEXT_FILE,
+       ':','p',0,                      A_PREV_FILE,
+       't',0,                          A_NEXT_TAG,
+       'T',0,                          A_PREV_TAG,
+       ':','x',0,                      A_INDEX_FILE,
+       ':','d',0,                      A_REMOVE_FILE,
+       '-',0,                          A_OPT_TOGGLE,
+       ':','t',0,                      A_OPT_TOGGLE|A_EXTRA,   't',0,
+       's',0,                          A_OPT_TOGGLE|A_EXTRA,   'o',0,
+       '_',0,                          A_DISP_OPTION,
+       '|',0,                          A_PIPE,
+       'v',0,                          A_VISUAL,
+       '!',0,                          A_SHELL,
+       '+',0,                          A_FIRSTCMD,
+
+       'H',0,                          A_HELP,
+       'h',0,                          A_HELP,
+       SK(SK_F1),0,                    A_HELP,
+       'V',0,                          A_VERSION,
+       'q',0,                          A_QUIT,
+       'Q',0,                          A_QUIT,
+       ':','q',0,                      A_QUIT,
+       ':','Q',0,                      A_QUIT,
+       'Z','Z',0,                      A_QUIT
+};
+
+static unsigned char edittable[] =
+{
+       '\t',0,                         EC_F_COMPLETE,  /* TAB */
+       '\17',0,                        EC_B_COMPLETE,  /* BACKTAB */
+       SK(SK_BACKTAB),0,               EC_B_COMPLETE,  /* BACKTAB */
+       ESC,'\t',0,                     EC_B_COMPLETE,  /* ESC TAB */
+       CONTROL('L'),0,                 EC_EXPAND,      /* CTRL-L */
+       CONTROL('V'),0,                 EC_LITERAL,     /* BACKSLASH */
+       CONTROL('A'),0,                 EC_LITERAL,     /* BACKSLASH */
+       ESC,'l',0,                      EC_RIGHT,       /* ESC l */
+       SK(SK_RIGHT_ARROW),0,           EC_RIGHT,       /* RIGHTARROW */
+       ESC,'h',0,                      EC_LEFT,        /* ESC h */
+       SK(SK_LEFT_ARROW),0,            EC_LEFT,        /* LEFTARROW */
+       ESC,'b',0,                      EC_W_LEFT,      /* ESC b */
+       ESC,SK(SK_LEFT_ARROW),0,        EC_W_LEFT,      /* ESC LEFTARROW */
+       SK(SK_CTL_LEFT_ARROW),0,        EC_W_LEFT,      /* CTRL-LEFTARROW */
+       ESC,'w',0,                      EC_W_RIGHT,     /* ESC w */
+       ESC,SK(SK_RIGHT_ARROW),0,       EC_W_RIGHT,     /* ESC RIGHTARROW */
+       SK(SK_CTL_RIGHT_ARROW),0,       EC_W_RIGHT,     /* CTRL-RIGHTARROW */
+       ESC,'i',0,                      EC_INSERT,      /* ESC i */
+       SK(SK_INSERT),0,                EC_INSERT,      /* INSERT */
+       ESC,'x',0,                      EC_DELETE,      /* ESC x */
+       SK(SK_DELETE),0,                EC_DELETE,      /* DELETE */
+       ESC,'X',0,                      EC_W_DELETE,    /* ESC X */
+       ESC,SK(SK_DELETE),0,            EC_W_DELETE,    /* ESC DELETE */
+       SK(SK_CTL_DELETE),0,            EC_W_DELETE,    /* CTRL-DELETE */
+       SK(SK_CTL_BACKSPACE),0,         EC_W_BACKSPACE, /* CTRL-BACKSPACE */
+       ESC,'\b',0,                     EC_W_BACKSPACE, /* ESC BACKSPACE */
+       ESC,'0',0,                      EC_HOME,        /* ESC 0 */
+       SK(SK_HOME),0,                  EC_HOME,        /* HOME */
+       ESC,'$',0,                      EC_END,         /* ESC $ */
+       SK(SK_END),0,                   EC_END,         /* END */
+       ESC,'k',0,                      EC_UP,          /* ESC k */
+       SK(SK_UP_ARROW),0,              EC_UP,          /* UPARROW */
+       ESC,'j',0,                      EC_DOWN,        /* ESC j */
+       SK(SK_DOWN_ARROW),0,            EC_DOWN,        /* DOWNARROW */
+       CONTROL('G'),0,                 EC_ABORT,       /* CTRL-G */
+};
+
+/*
+ * Structure to support a list of command tables.
+ */
+struct tablelist
+{
+       struct tablelist *t_next;
+       char *t_start;
+       char *t_end;
+};
+
+/*
+ * List of command tables and list of line-edit tables.
+ */
+static struct tablelist *list_fcmd_tables = NULL;
+static struct tablelist *list_ecmd_tables = NULL;
+static struct tablelist *list_var_tables = NULL;
+static struct tablelist *list_sysvar_tables = NULL;
+
+
+/*
+ * Expand special key abbreviations in a command table.
+ */
+       static void
+expand_special_keys(table, len)
+       char *table;
+       int len;
+{
+       register char *fm;
+       register char *to;
+       register int a;
+       char *repl;
+       int klen;
+
+       for (fm = table;  fm < table + len; )
+       {
+               /*
+                * Rewrite each command in the table with any
+                * special key abbreviations expanded.
+                */
+               for (to = fm;  *fm != '\0'; )
+               {
+                       if (*fm != SK_SPECIAL_KEY)
+                       {
+                               *to++ = *fm++;
+                               continue;
+                       }
+                       /*
+                        * After SK_SPECIAL_KEY, next byte is the type
+                        * of special key (one of the SK_* contants),
+                        * and the byte after that is the number of bytes,
+                        * N, reserved by the abbreviation (including the
+                        * SK_SPECIAL_KEY and key type bytes).
+                        * Replace all N bytes with the actual bytes
+                        * output by the special key on this terminal.
+                        */
+                       repl = special_key_str(fm[1]);
+                       klen = fm[2] & 0377;
+                       fm += klen;
+                       if (repl == NULL || (int) strlen(repl) > klen)
+                               repl = "\377";
+                       while (*repl != '\0')
+                               *to++ = *repl++;
+               }
+               *to++ = '\0';
+               /*
+                * Fill any unused bytes between end of command and 
+                * the action byte with A_SKIP.
+                */
+               while (to <= fm)
+                       *to++ = A_SKIP;
+               fm++;
+               a = *fm++ & 0377;
+               if (a & A_EXTRA)
+               {
+                       while (*fm++ != '\0')
+                               continue;
+               }
+       }
+}
+
+/*
+ * Initialize the command lists.
+ */
+       public void
+init_cmds()
+{
+       /*
+        * Add the default command tables.
+        */
+       add_fcmd_table((char*)cmdtable, sizeof(cmdtable));
+       add_ecmd_table((char*)edittable, sizeof(edittable));
+#if USERFILE
+       /*
+        * For backwards compatibility,
+        * try to add tables in the OLD system lesskey file.
+        */
+#ifdef BINDIR
+       add_hometable(NULL, BINDIR "/.sysless", 1);
+#endif
+       /*
+        * Try to add the tables in the system lesskey file.
+        */
+       add_hometable("LESSKEY_SYSTEM", LESSKEYFILE_SYS, 1);
+       /*
+        * Try to add the tables in the standard lesskey file "$HOME/.less".
+        */
+       add_hometable("LESSKEY", LESSKEYFILE, 0);
+#endif
+}
+
+/*
+ * Add a command table.
+ */
+       static int
+add_cmd_table(tlist, buf, len)
+       struct tablelist **tlist;
+       char *buf;
+       int len;
+{
+       register struct tablelist *t;
+
+       if (len == 0)
+               return (0);
+       /*
+        * Allocate a tablelist structure, initialize it, 
+        * and link it into the list of tables.
+        */
+       if ((t = (struct tablelist *) 
+                       calloc(1, sizeof(struct tablelist))) == NULL)
+       {
+               return (-1);
+       }
+       expand_special_keys(buf, len);
+       t->t_start = buf;
+       t->t_end = buf + len;
+       t->t_next = *tlist;
+       *tlist = t;
+       return (0);
+}
+
+/*
+ * Add a command table.
+ */
+       public void
+add_fcmd_table(buf, len)
+       char *buf;
+       int len;
+{
+       if (add_cmd_table(&list_fcmd_tables, buf, len) < 0)
+               error("Warning: some commands disabled", NULL_PARG);
+}
+
+/*
+ * Add an editing command table.
+ */
+       public void
+add_ecmd_table(buf, len)
+       char *buf;
+       int len;
+{
+       if (add_cmd_table(&list_ecmd_tables, buf, len) < 0)
+               error("Warning: some edit commands disabled", NULL_PARG);
+}
+
+/*
+ * Add an environment variable table.
+ */
+       static void
+add_var_table(tlist, buf, len)
+       struct tablelist **tlist;
+       char *buf;
+       int len;
+{
+       if (add_cmd_table(tlist, buf, len) < 0)
+               error("Warning: environment variables from lesskey file unavailable", NULL_PARG);
+}
+
+/*
+ * Search a single command table for the command string in cmd.
+ */
+       static int
+cmd_search(cmd, table, endtable, sp)
+       char *cmd;
+       char *table;
+       char *endtable;
+       char **sp;
+{
+       register char *p;
+       register char *q;
+       register int a;
+
+       *sp = NULL;
+       for (p = table, q = cmd;  p < endtable;  p++, q++)
+       {
+               if (*p == *q)
+               {
+                       /*
+                        * Current characters match.
+                        * If we're at the end of the string, we've found it.
+                        * Return the action code, which is the character
+                        * after the null at the end of the string
+                        * in the command table.
+                        */
+                       if (*p == '\0')
+                       {
+                               a = *++p & 0377;
+                               while (a == A_SKIP)
+                                       a = *++p & 0377;
+                               if (a == A_END_LIST)
+                               {
+                                       /*
+                                        * We get here only if the original
+                                        * cmd string passed in was empty ("").
+                                        * I don't think that can happen,
+                                        * but just in case ...
+                                        */
+                                       return (A_UINVALID);
+                               }
+                               /*
+                                * Check for an "extra" string.
+                                */
+                               if (a & A_EXTRA)
+                               {
+                                       *sp = ++p;
+                                       a &= ~A_EXTRA;
+                               }
+                               return (a);
+                       }
+               } else if (*q == '\0')
+               {
+                       /*
+                        * Hit the end of the user's command,
+                        * but not the end of the string in the command table.
+                        * The user's command is incomplete.
+                        */
+                       return (A_PREFIX);
+               } else
+               {
+                       /*
+                        * Not a match.
+                        * Skip ahead to the next command in the
+                        * command table, and reset the pointer
+                        * to the beginning of the user's command.
+                        */
+                       if (*p == '\0' && p[1] == A_END_LIST)
+                       {
+                               /*
+                                * A_END_LIST is a special marker that tells 
+                                * us to abort the cmd search.
+                                */
+                               return (A_UINVALID);
+                       }
+                       while (*p++ != '\0')
+                               continue;
+                       while (*p == A_SKIP)
+                               p++;
+                       if (*p & A_EXTRA)
+                               while (*++p != '\0')
+                                       continue;
+                       q = cmd-1;
+               }
+       }
+       /*
+        * No match found in the entire command table.
+        */
+       return (A_INVALID);
+}
+
+/*
+ * Decode a command character and return the associated action.
+ * The "extra" string, if any, is returned in sp.
+ */
+       static int
+cmd_decode(tlist, cmd, sp)
+       struct tablelist *tlist;
+       char *cmd;
+       char **sp;
+{
+       register struct tablelist *t;
+       register int action = A_INVALID;
+
+       /*
+        * Search thru all the command tables.
+        * Stop when we find an action which is not A_INVALID.
+        */
+       for (t = tlist;  t != NULL;  t = t->t_next)
+       {
+               action = cmd_search(cmd, t->t_start, t->t_end, sp);
+               if (action != A_INVALID)
+                       break;
+       }
+       if (action == A_UINVALID)
+               action = A_INVALID;
+       return (action);
+}
+
+/*
+ * Decode a command from the cmdtables list.
+ */
+       public int
+fcmd_decode(cmd, sp)
+       char *cmd;
+       char **sp;
+{
+       return (cmd_decode(list_fcmd_tables, cmd, sp));
+}
+
+/*
+ * Decode a command from the edittables list.
+ */
+       public int
+ecmd_decode(cmd, sp)
+       char *cmd;
+       char **sp;
+{
+       return (cmd_decode(list_ecmd_tables, cmd, sp));
+}
+
+/*
+ * Get the value of an environment variable.
+ * Looks first in the lesskey file, then in the real environment.
+ */
+       public char *
+lgetenv(var)
+       char *var;
+{
+       int a;
+       char *s;
+
+       a = cmd_decode(list_var_tables, var, &s);
+       if (a == EV_OK)
+               return (s);
+       s = getenv(var);
+       if (s != NULL && *s != '\0')
+               return (s);
+       a = cmd_decode(list_sysvar_tables, var, &s);
+       if (a == EV_OK)
+               return (s);
+       return (NULL);
+}
+
+#if USERFILE
+/*
+ * Get an "integer" from a lesskey file.
+ * Integers are stored in a funny format: 
+ * two bytes, low order first, in radix KRADIX.
+ */
+       static int
+gint(sp)
+       char **sp;
+{
+       int n;
+
+       n = *(*sp)++;
+       n += *(*sp)++ * KRADIX;
+       return (n);
+}
+
+/*
+ * Process an old (pre-v241) lesskey file.
+ */
+       static int
+old_lesskey(buf, len)
+       char *buf;
+       int len;
+{
+       /*
+        * Old-style lesskey file.
+        * The file must end with either 
+        *     ...,cmd,0,action
+        * or  ...,cmd,0,action|A_EXTRA,string,0
+        * So the last byte or the second to last byte must be zero.
+        */
+       if (buf[len-1] != '\0' && buf[len-2] != '\0')
+               return (-1);
+       add_fcmd_table(buf, len);
+       return (0);
+}
+
+/* 
+ * Process a new (post-v241) lesskey file.
+ */
+       static int
+new_lesskey(buf, len, sysvar)
+       char *buf;
+       int len;
+       int sysvar;
+{
+       char *p;
+       register int c;
+       register int n;
+
+       /*
+        * New-style lesskey file.
+        * Extract the pieces.
+        */
+       if (buf[len-3] != C0_END_LESSKEY_MAGIC ||
+           buf[len-2] != C1_END_LESSKEY_MAGIC ||
+           buf[len-1] != C2_END_LESSKEY_MAGIC)
+               return (-1);
+       p = buf + 4;
+       for (;;)
+       {
+               c = *p++;
+               switch (c)
+               {
+               case CMD_SECTION:
+                       n = gint(&p);
+                       add_fcmd_table(p, n);
+                       p += n;
+                       break;
+               case EDIT_SECTION:
+                       n = gint(&p);
+                       add_ecmd_table(p, n);
+                       p += n;
+                       break;
+               case VAR_SECTION:
+                       n = gint(&p);
+                       add_var_table((sysvar) ? 
+                               &list_sysvar_tables : &list_var_tables, p, n);
+                       p += n;
+                       break;
+               case END_SECTION:
+                       return (0);
+               default:
+                       /*
+                        * Unrecognized section type.
+                        */
+                       return (-1);
+               }
+       }
+}
+
+/*
+ * Set up a user command table, based on a "lesskey" file.
+ */
+       public int
+lesskey(filename, sysvar)
+       char *filename;
+       int sysvar;
+{
+       register char *buf;
+       register POSITION len;
+       register long n;
+       register int f;
+
+       if (secure)
+               return (1);
+       /*
+        * Try to open the lesskey file.
+        */
+       filename = shell_unquote(filename);
+       f = open(filename, OPEN_READ);
+       free(filename);
+       if (f < 0)
+               return (1);
+
+       /*
+        * Read the file into a buffer.
+        * We first figure out the size of the file and allocate space for it.
+        * {{ Minimal error checking is done here.
+        *    A garbage .less file will produce strange results.
+        *    To avoid a large amount of error checking code here, we
+        *    rely on the lesskey program to generate a good .less file. }}
+        */
+       len = filesize(f);
+       if (len == NULL_POSITION || len < 3)
+       {
+               /*
+                * Bad file (valid file must have at least 3 chars).
+                */
+               close(f);
+               return (-1);
+       }
+       if ((buf = (char *) calloc((int)len, sizeof(char))) == NULL)
+       {
+               close(f);
+               return (-1);
+       }
+       if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
+       {
+               free(buf);
+               close(f);
+               return (-1);
+       }
+       n = read(f, buf, (unsigned int) len);
+       close(f);
+       if (n != len)
+       {
+               free(buf);
+               return (-1);
+       }
+
+       /*
+        * Figure out if this is an old-style (before version 241)
+        * or new-style lesskey file format.
+        */
+       if (buf[0] != C0_LESSKEY_MAGIC || buf[1] != C1_LESSKEY_MAGIC ||
+           buf[2] != C2_LESSKEY_MAGIC || buf[3] != C3_LESSKEY_MAGIC)
+               return (old_lesskey(buf, (int)len));
+       return (new_lesskey(buf, (int)len, sysvar));
+}
+
+/*
+ * Add the standard lesskey file "$HOME/.less"
+ */
+       public void
+add_hometable(envname, def_filename, sysvar)
+       char *envname;
+       char *def_filename;
+       int sysvar;
+{
+       char *filename;
+       PARG parg;
+
+       if (envname != NULL && (filename = lgetenv(envname)) != NULL)
+               filename = save(filename);
+       else if (sysvar)
+               filename = save(def_filename);
+       else
+               filename = homefile(def_filename);
+       if (filename == NULL)
+               return;
+       if (lesskey(filename, sysvar) < 0)
+       {
+               parg.p_string = filename;
+               error("Cannot use lesskey file \"%s\"", &parg);
+       }
+       free(filename);
+}
+#endif
+
+/*
+ * See if a char is a special line-editing command.
+ */
+       public int
+editchar(c, flags)
+       int c;
+       int flags;
+{
+       int action;
+       int nch;
+       char *s;
+       char usercmd[MAX_CMDLEN+1];
+       
+       /*
+        * An editing character could actually be a sequence of characters;
+        * for example, an escape sequence sent by pressing the uparrow key.
+        * To match the editing string, we use the command decoder
+        * but give it the edit-commands command table
+        * This table is constructed to match the user's keyboard.
+        */
+       if (c == erase_char || c == erase2_char)
+               return (EC_BACKSPACE);
+       if (c == kill_char)
+               return (EC_LINEKILL);
+               
+       /*
+        * Collect characters in a buffer.
+        * Start with the one we have, and get more if we need them.
+        */
+       nch = 0;
+       do {
+               if (nch > 0)
+                       c = getcc();
+               usercmd[nch] = c;
+               usercmd[nch+1] = '\0';
+               nch++;
+               action = ecmd_decode(usercmd, &s);
+       } while (action == A_PREFIX);
+       
+       if (flags & EC_NORIGHTLEFT)
+       {
+               switch (action)
+               {
+               case EC_RIGHT:
+               case EC_LEFT:
+                       action = A_INVALID;
+                       break;
+               }
+       }
+#if CMD_HISTORY
+       if (flags & EC_NOHISTORY) 
+       {
+               /*
+                * The caller says there is no history list.
+                * Reject any history-manipulation action.
+                */
+               switch (action)
+               {
+               case EC_UP:
+               case EC_DOWN:
+                       action = A_INVALID;
+                       break;
+               }
+       }
+#endif
+#if TAB_COMPLETE_FILENAME
+       if (flags & EC_NOCOMPLETE) 
+       {
+               /*
+                * The caller says we don't want any filename completion cmds.
+                * Reject them.
+                */
+               switch (action)
+               {
+               case EC_F_COMPLETE:
+               case EC_B_COMPLETE:
+               case EC_EXPAND:
+                       action = A_INVALID;
+                       break;
+               }
+       }
+#endif
+       if ((flags & EC_PEEK) || action == A_INVALID)
+       {
+               /*
+                * We're just peeking, or we didn't understand the command.
+                * Unget all the characters we read in the loop above.
+                * This does NOT include the original character that was 
+                * passed in as a parameter.
+                */
+               while (nch > 1) 
+               {
+                       ungetcc(usercmd[--nch]);
+               }
+       } else
+       {
+               if (s != NULL)
+                       ungetsc(s);
+       }
+       return action;
+}
+
diff --git a/thirdparty/less/defines.h.in b/thirdparty/less/defines.h.in
new file mode 100644 (file)
index 0000000..8d45063
--- /dev/null
@@ -0,0 +1,426 @@
+/* defines.h.in.  Generated from configure.ac by autoheader.  */
+
+
+/* Unix definition file for less.  -*- C -*-
+ *
+ * This file has 3 sections:
+ * User preferences.
+ * Settings always true on Unix.
+ * Settings automatically determined by configure.
+ *
+ * * * * * *  WARNING  * * * * * *
+ * If you edit defines.h by hand, do "touch stamp-h" before you run make
+ * so config.status doesn't overwrite your changes.
+ */
+
+/* User preferences.  */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ * SECURE_COMPILE is set by the --with-secure configure option.
+ */
+#define        SECURE          SECURE_COMPILE
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define        SHELL_ESCAPE    (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define        EXAMINE         (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define        TAB_COMPLETE_FILENAME   (!SECURE)
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define        CMD_HISTORY     1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be 
+ * displayed in standout mode.
+ */
+#define        HILITE_SEARCH   1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define        EDITOR          (!SECURE)
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define        TAGS            (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify 
+ * user-defined key bindings.
+ */
+#define        USERFILE        (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#define        GLOB            (!SECURE)
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define        PIPEC           (!SECURE)
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define        LOGFILE         (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define        GNU_OPTIONS     1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define        ONLY_RETURN     0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file 
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input 
+ * (in the HOME directory).
+ * LESSHISTFILE is the filename of the history file
+ * (in the HOME directory).
+ */
+#define        LESSKEYFILE             ".less"
+#define        LESSKEYFILE_SYS         SYSDIR "/sysless"
+#define        DEF_LESSKEYINFILE       ".lesskey"
+#define LESSHISTFILE           ".lesshst"
+
+
+/* Settings always true on Unix.  */
+
+/*
+ * Define MSDOS_COMPILER if compiling under Microsoft C.
+ */
+#define        MSDOS_COMPILER  0
+
+/*
+ * Pathname separator character.
+ */
+#define        PATHNAME_SEP    "/"
+
+/*
+ * The value returned from tgetent on success.
+ * Some HP-UX systems return 0 on success.
+ */
+#define TGETENT_OK  1
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H       1
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#undef HAVE_SGSTAT_H
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#define        HAVE_PERROR     1
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define        HAVE_TIME       1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define        HAVE_SHELL      1
+
+/*
+ * Default shell metacharacters and meta-escape character.
+ */
+#define        DEF_METACHARS   "; *?\t\n'\"()<>[]|&^`#\\$%=~"
+#define        DEF_METAESCAPE  "\\"
+
+/* 
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define        HAVE_DUP        1
+
+/* Define to 1 if you have the memcpy() function. */
+#define HAVE_MEMCPY 1
+
+/* Define to 1 if you have the strchr() function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the strstr() function. */
+#define HAVE_STRSTR 1
+
+/*
+ * Sizes of various buffers.
+ */
+#define        CMDBUF_SIZE     512     /* Buffer for multichar commands */
+#define        UNGOT_SIZE      100     /* Max chars to unget() */
+#define        LINEBUF_SIZE    1024    /* Max size of line in input file */
+#define        OUTBUF_SIZE     1024    /* Output buffer */
+#define        PROMPT_SIZE     200     /* Max size of prompt string */
+#define        TERMBUF_SIZE    2048    /* Termcap buffer for tgetent */
+#define        TERMSBUF_SIZE   1024    /* Buffer to hold termcap strings */
+#define        TAGLINE_SIZE    512     /* Max size of line in tags file */
+#define        TABSTOP_MAX     32      /* Max number of custom tab stops */
+
+/* Settings automatically determined by configure.  */
+
+
+/* Define EDIT_PGM to your editor. */
+#undef EDIT_PGM
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#undef HAVE_CONST
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
+/* Define HAVE_ERRNO if you have the errno variable. */
+#undef HAVE_ERRNO
+
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define to 1 if you have the `fchmod' function. */
+#undef HAVE_FCHMOD
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#undef HAVE_FILENO
+
+/* Define HAVE_FLOAT if your compiler supports the "double" type. */
+#undef HAVE_FLOAT
+
+/* Define to 1 if you have the `fsync' function. */
+#undef HAVE_FSYNC
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `gen' library (-lgen). */
+#undef HAVE_LIBGEN
+
+/* Define to 1 if you have the `intl' library (-lintl). */
+#undef HAVE_LIBINTL
+
+/* Define to 1 if you have the `PW' library (-lPW). */
+#undef HAVE_LIBPW
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#undef HAVE_LOCALE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable. */
+#undef HAVE_OSPEED
+
+/* PCRE (Perl-compatible regular expression) library */
+#undef HAVE_PCRE
+
+/* Define to 1 if you have the `popen' function. */
+#undef HAVE_POPEN
+
+/* POSIX regcomp() and regex.h */
+#undef HAVE_POSIX_REGCOMP
+
+/* System V regcmp() */
+#undef HAVE_REGCMP
+
+/* */
+#undef HAVE_REGEXEC2
+
+/* BSD re_comp() */
+#undef HAVE_RE_COMP
+
+/* Define HAVE_SIGEMPTYSET if you have the sigemptyset macro. */
+#undef HAVE_SIGEMPTYSET
+
+/* Define to 1 if you have the `sigprocmask' function. */
+#undef HAVE_SIGPROCMASK
+
+/* Define to 1 if you have the `sigsetmask' function. */
+#undef HAVE_SIGSETMASK
+
+/* Define to 1 if the system has the type `sigset_t'. */
+#undef HAVE_SIGSET_T
+
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
+/* Define to 1 if you have the `stat' function. */
+#undef HAVE_STAT
+
+/* Define HAVE_STAT_INO if your struct stat has st_ino and st_dev. */
+#undef HAVE_STAT_INO
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `system' function. */
+#undef HAVE_SYSTEM
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable. */
+#undef HAVE_SYS_ERRLIST
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/stream.h> header file. */
+#undef HAVE_SYS_STREAM_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <termcap.h> header file. */
+#undef HAVE_TERMCAP_H
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr. */
+#undef HAVE_TERMIOS_FUNCS
+
+/* Define to 1 if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
+/* Define to 1 if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Define to 1 if you have the <time.h> header file. */
+#undef HAVE_TIME_H
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#undef HAVE_TIME_T
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower. */
+#undef HAVE_UPPER_LOWER
+
+/* Henry Spencer V8 regcomp() and regexp.h */
+#undef HAVE_V8_REGCOMP
+
+/* Define to 1 if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#undef HAVE_VOID
+
+/* Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower. */
+#undef HAVE_WCTYPE
+
+/* Define to 1 if you have the <wctype.h> header file. */
+#undef HAVE_WCTYPE_H
+
+/* Define to 1 if you have the `_setjmp' function. */
+#undef HAVE__SETJMP
+
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.
+   */
+#undef MUST_DEFINE_ERRNO
+
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in
+   termcap.h. */
+#undef MUST_DEFINE_OSPEED
+
+/* pattern matching is supported, but without metacharacters. */
+#undef NO_REGEX
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#undef RETSIGTYPE
+
+/* Define SECURE_COMPILE=1 to build a secure version of less. */
+#undef SECURE_COMPILE
+
+/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+#undef STAT_MACROS_BROKEN
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `long int' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
diff --git a/thirdparty/less/defines.wn b/thirdparty/less/defines.wn
new file mode 100644 (file)
index 0000000..d0c1927
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/* Windows definition file for less.  */
+/*
+ * This file has 2 sections:
+ * User preferences.
+ * Settings always true for Windows systems. 
+ */
+
+\f
+/* User preferences.  */
+
+/*
+ * SECURE is 1 if you wish to disable a bunch of features in order to
+ * be safe to run by unprivileged users.
+ */
+#define        SECURE          0
+
+/*
+ * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
+ * (This is possible only if your system supplies the system() function.)
+ */
+#define        SHELL_ESCAPE    (!SECURE)
+
+/*
+ * EXAMINE is 1 if you wish to allow examining files by name from within less.
+ */
+#define        EXAMINE         (!SECURE)
+
+/*
+ * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
+ * to complete filenames at prompts.
+ */
+#define        TAB_COMPLETE_FILENAME   (!SECURE)
+
+/*
+ * CMD_HISTORY is 1 if you wish to allow keys to cycle through
+ * previous commands at prompts.
+ */
+#define        CMD_HISTORY     1
+
+/*
+ * HILITE_SEARCH is 1 if you wish to have search targets to be 
+ * displayed in standout mode.
+ */
+#define        HILITE_SEARCH   1
+
+/*
+ * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
+ * (This is possible only if your system supplies the system() function.)
+ * EDIT_PGM is the name of the (default) editor to be invoked.
+ */
+#define        EDITOR          (!SECURE)
+#define        EDIT_PGM        "edit"
+
+/*
+ * TAGS is 1 if you wish to support tag files.
+ */
+#define        TAGS            (!SECURE)
+
+/*
+ * USERFILE is 1 if you wish to allow a .less file to specify 
+ * user-defined key bindings.
+ */
+#define        USERFILE        (!SECURE)
+
+/*
+ * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
+ * This will generally work if your system provides the "popen" function
+ * and the "echo" shell command.
+ */
+#define        GLOB            0
+
+/*
+ * PIPEC is 1 if you wish to have the "|" command
+ * which allows the user to pipe data into a shell command.
+ */
+#define        PIPEC           1
+
+/*
+ * LOGFILE is 1 if you wish to allow the -l option (to create log files).
+ */
+#define        LOGFILE         (!SECURE)
+
+/*
+ * GNU_OPTIONS is 1 if you wish to support the GNU-style command
+ * line options --help and --version.
+ */
+#define        GNU_OPTIONS     1
+
+/*
+ * ONLY_RETURN is 1 if you want RETURN to be the only input which
+ * will continue past an error message.
+ * Otherwise, any key will continue past an error message.
+ */
+#define        ONLY_RETURN     0
+
+/*
+ * LESSKEYFILE is the filename of the default lesskey output file 
+ * (in the HOME directory).
+ * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
+ * DEF_LESSKEYINFILE is the filename of the default lesskey input 
+ * (in the HOME directory).
+ * LESSHISTFILE is the filename of the history file
+ * (in the HOME directory).
+ */
+#define        LESSKEYFILE             "_less"
+#define        LESSKEYFILE_SYS         "c:\\_sysless"
+#define        DEF_LESSKEYINFILE       "_lesskey"
+#define LESSHISTFILE           "_lesshst"
+
+\f
+/* Settings always true for Windows systems.  */
+
+#define MSDOS_COMPILER WIN32C
+
+/*
+ * Pathname separator character.
+ */
+#define        PATHNAME_SEP    "\\"
+
+/*
+ * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
+ */
+#define HAVE_SYS_TYPES_H       1
+
+/*
+ * Define if you have the <sgstat.h> header file.
+ */
+#define HAVE_SGSTAT_H  0
+
+/*
+ * HAVE_PERROR is 1 if your system has the perror() call.
+ * (Actually, if it has sys_errlist, sys_nerr and errno.)
+ */
+#define        HAVE_PERROR     1
+
+/*
+ * HAVE_TIME is 1 if your system has the time() call.
+ */
+#define        HAVE_TIME       1
+
+/*
+ * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
+ */
+#define        HAVE_SHELL      0
+
+/*
+ * Default shell metacharacters and meta-escape character.
+ */
+#define        DEF_METACHARS   "; *?\t\n'\"()<>|&"
+#define        DEF_METAESCAPE  ""
+
+/* 
+ * HAVE_DUP is 1 if your system has the dup() call.
+ */
+#define        HAVE_DUP        1
+
+/*
+ * Sizes of various buffers.
+ */
+#define        CMDBUF_SIZE     512     /* Buffer for multichar commands */
+#define        UNGOT_SIZE      100     /* Max chars to unget() */
+#define        LINEBUF_SIZE    1024    /* Max size of line in input file */
+#define        OUTBUF_SIZE     1024    /* Output buffer */
+#define        PROMPT_SIZE     200     /* Max size of prompt string */
+#define        TERMBUF_SIZE    2048    /* Termcap buffer for tgetent */
+#define        TERMSBUF_SIZE   1024    /* Buffer to hold termcap strings */
+#define        TAGLINE_SIZE    512     /* Max size of line in tags file */
+#define        TABSTOP_MAX     32      /* Max number of custom tab stops */
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+/* #define     off_t   long */
+
+/* Define if you need to in order for stat and other things to work.  */
+/* #undef _POSIX_SOURCE */
+
+/* Define as the return type of signal handlers (int or void).  */
+#define RETSIGTYPE void
+
+
+/*
+ * Regular expression library.
+ * Define exactly one of the following to be 1:
+ * HAVE_POSIX_REGCOMP: POSIX regcomp() and regex.h
+ * HAVE_RE_COMP: BSD re_comp()
+ * HAVE_REGCMP: System V regcmp()
+ * HAVE_V8_REGCOMP: Henry Spencer V8 regcomp() and regexp.h
+ * NO_REGEX: pattern matching is supported, but without metacharacters.
+ */
+/* #undef HAVE_POSIX_REGCOMP */
+/* #undef HAVE_RE_COMP */
+/* #undef HAVE_REGCMP */
+#define HAVE_V8_REGCOMP 1
+/* #undef NO_REGEX */
+#define HAVE_REGEXEC2 1
+
+/* Define HAVE_VOID if your compiler supports the "void" type. */
+#define HAVE_VOID 1
+
+/* Define HAVE_CONST if your compiler supports the "const" modifier. */
+#define HAVE_CONST 1
+
+/* Define HAVE_TIME_T if your system supports the "time_t" type. */
+#define HAVE_TIME_T 1
+
+/* Define HAVE_STRERROR if you have the strerror() function. */
+#define HAVE_STRERROR 1
+
+/* Define HAVE_FILENO if you have the fileno() macro. */
+#define HAVE_FILENO 1
+
+/* Define HAVE_ERRNO if you have the errno variable */
+/* Define MUST_DEFINE_ERRNO if you have errno but it is not define 
+ * in errno.h */
+#define HAVE_ERRNO 1
+#if defined(__MINGW32__) 
+#define MUST_DEFINE_ERRNO 0
+#else
+#define MUST_DEFINE_ERRNO 1
+#endif
+
+/* Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define HAVE_OSPEED if your termcap library has the ospeed variable */
+#define HAVE_OSPEED 0
+/* Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined
+ * in termcap.h. */
+#define MUST_DEFINE_OSPEED 0
+
+/* Define HAVE_LOCALE if you have locale.h and setlocale. */
+#define HAVE_LOCALE 0
+
+/* Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr */
+#define HAVE_TERMIOS_FUNCS 0
+
+/* Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower */
+#define HAVE_UPPER_LOWER 1
+
+/* Define if you have the _setjmp function.  */
+#define HAVE__SETJMP   1
+
+/* Define if you have the memcpy function.  */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the popen function.  */
+#define HAVE_POPEN 1
+
+/* Define if you have the sigsetmask function.  */
+#define HAVE_SIGSETMASK        0
+
+/* Define if you have the sigprocmask function.  */
+#define HAVE_SIGPROCMASK       0
+
+/* Define if you have the sigset_t type and sigemptyset macro */
+#define HAVE_SIGSET_T  0
+#define HAVE_SIGEMPTYSET       0
+
+/* Define if you have the stat function.  */
+#define HAVE_STAT 1
+
+/* Define if you have the strchr function.  */
+#define HAVE_STRCHR 1
+
+/* Define if you have the system function.  */
+#define HAVE_SYSTEM    1
+
+/* Define if you have the snprintf function.  */
+#define HAVE_SNPRINTF  1
+
+/* Define if you have the <ctype.h> header file.  */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <wctype.h> header file.  */
+#define HAVE_WCTYPE_H 1
+
+/* Define if you have the <errno.h> header file.  */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define HAVE_FCNTL_H 1
+
+/* Define HAVE_FLOAT if your compiler supports the "double" type. */
+#define HAVE_FLOAT 1
+
+/* Define if you have the <limits.h> header file.  */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <stdio.h> header file.  */
+#define HAVE_STDIO_H 1
+
+/* Define if you have the <string.h> header file.  */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <stdlib> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <sys/ioctl.h> header file.  */
+#define HAVE_SYS_IOCTL_H 0
+
+/* Define if you have the <sys/ptem.h> header file.  */
+#define HAVE_SYS_PTEM_H        0
+
+/* Define if you have the <sys/stream.h> header file.  */
+#define HAVE_SYS_STREAM_H      0
+
+/* Define if you have the <termcap.h> header file.  */
+#define HAVE_TERMCAP_H 0
+
+/* Define if you have the <termio.h> header file.  */
+#define HAVE_TERMIO_H  0
+
+/* Define if you have the <termios.h> header file.  */
+#define HAVE_TERMIOS_H 0
+
+/* Define if you have the <time.h> header file.  */
+#define HAVE_TIME_H 1
+
+/* Define if you have the <unistd.h> header file.  */
+#define HAVE_UNISTD_H 0
+
+/* Define if you have the <values.h> header file.  */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#define HAVE_VALUES_H 0
+#else
+#define HAVE_VALUES_H 1
+#endif
+
+#if !defined(__MINGW32__)
+#define        popen   _popen
+#define        pclose  _pclose
+#define snprintf       _snprintf
+#endif
+
+#if defined(_MSC_VER)
+#pragma warning(disable:4996)
+#endif
diff --git a/thirdparty/less/edit.c b/thirdparty/less/edit.c
new file mode 100644 (file)
index 0000000..4781d95
--- /dev/null
@@ -0,0 +1,818 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+#include "less.h"
+#if HAVE_STAT
+#include <sys/stat.h>
+#endif
+
+public int fd0 = 0;
+
+extern int new_file;
+extern int errmsgs;
+extern int cbufs;
+extern char *every_first_cmd;
+extern int any_display;
+extern int force_open;
+extern int is_tty;
+extern int sigs;
+extern IFILE curr_ifile;
+extern IFILE old_ifile;
+extern struct scrpos initial_scrpos;
+extern void constant *ml_examine;
+#if SPACES_IN_FILENAMES
+extern char openquote;
+extern char closequote;
+#endif
+
+#if LOGFILE
+extern int logfile;
+extern int force_logfile;
+extern char *namelogfile;
+#endif
+
+#if HAVE_STAT_INO
+public dev_t curr_dev;
+public ino_t curr_ino;
+#endif
+
+char *curr_altfilename = NULL;
+static void *curr_altpipe;
+
+
+/*
+ * Textlist functions deal with a list of words separated by spaces.
+ * init_textlist sets up a textlist structure.
+ * forw_textlist uses that structure to iterate thru the list of
+ * words, returning each one as a standard null-terminated string.
+ * back_textlist does the same, but runs thru the list backwards.
+ */
+       public void
+init_textlist(tlist, str)
+       struct textlist *tlist;
+       char *str;
+{
+       char *s;
+#if SPACES_IN_FILENAMES
+       int meta_quoted = 0;
+       int delim_quoted = 0;
+       char *esc = get_meta_escape();
+       int esclen = strlen(esc);
+#endif
+       
+       tlist->string = skipsp(str);
+       tlist->endstring = tlist->string + strlen(tlist->string);
+       for (s = str;  s < tlist->endstring;  s++)
+       {
+#if SPACES_IN_FILENAMES
+               if (meta_quoted)
+               {
+                       meta_quoted = 0;
+               } else if (esclen > 0 && s + esclen < tlist->endstring &&
+                          strncmp(s, esc, esclen) == 0)
+               {
+                       meta_quoted = 1;
+                       s += esclen - 1;
+               } else if (delim_quoted)
+               {
+                       if (*s == closequote)
+                               delim_quoted = 0;
+               } else /* (!delim_quoted) */
+               {
+                       if (*s == openquote)
+                               delim_quoted = 1;
+                       else if (*s == ' ')
+                               *s = '\0';
+               }
+#else
+               if (*s == ' ')
+                       *s = '\0';
+#endif
+       }
+}
+
+       public char *
+forw_textlist(tlist, prev)
+       struct textlist *tlist;
+       char *prev;
+{
+       char *s;
+       
+       /*
+        * prev == NULL means return the first word in the list.
+        * Otherwise, return the word after "prev".
+        */
+       if (prev == NULL)
+               s = tlist->string;
+       else
+               s = prev + strlen(prev);
+       if (s >= tlist->endstring)
+               return (NULL);
+       while (*s == '\0')
+               s++;
+       if (s >= tlist->endstring)
+               return (NULL);
+       return (s);
+}
+
+       public char *
+back_textlist(tlist, prev)
+       struct textlist *tlist;
+       char *prev;
+{
+       char *s;
+       
+       /*
+        * prev == NULL means return the last word in the list.
+        * Otherwise, return the word before "prev".
+        */
+       if (prev == NULL)
+               s = tlist->endstring;
+       else if (prev <= tlist->string)
+               return (NULL);
+       else
+               s = prev - 1;
+       while (*s == '\0')
+               s--;
+       if (s <= tlist->string)
+               return (NULL);
+       while (s[-1] != '\0' && s > tlist->string)
+               s--;
+       return (s);
+}
+
+/*
+ * Close the current input file.
+ */
+       static void
+close_file()
+{
+       struct scrpos scrpos;
+       
+       if (curr_ifile == NULL_IFILE)
+               return;
+
+       /*
+        * Save the current position so that we can return to
+        * the same position if we edit this file again.
+        */
+       get_scrpos(&scrpos);
+       if (scrpos.pos != NULL_POSITION)
+       {
+               store_pos(curr_ifile, &scrpos);
+               lastmark();
+       }
+       /*
+        * Close the file descriptor, unless it is a pipe.
+        */
+       ch_close();
+       /*
+        * If we opened a file using an alternate name,
+        * do special stuff to close it.
+        */
+       if (curr_altfilename != NULL)
+       {
+               close_altfile(curr_altfilename, get_filename(curr_ifile),
+                               curr_altpipe);
+               free(curr_altfilename);
+               curr_altfilename = NULL;
+       }
+       curr_ifile = NULL_IFILE;
+#if HAVE_STAT_INO
+       curr_ino = curr_dev = 0;
+#endif
+}
+
+/*
+ * Edit a new file (given its name).
+ * Filename == "-" means standard input.
+ * Filename == NULL means just close the current file.
+ */
+       public int
+edit(filename)
+       char *filename;
+{
+       if (filename == NULL)
+               return (edit_ifile(NULL_IFILE));
+       return (edit_ifile(get_ifile(filename, curr_ifile)));
+}
+       
+/*
+ * Edit a new file (given its IFILE).
+ * ifile == NULL means just close the current file.
+ */
+       public int
+edit_ifile(ifile)
+       IFILE ifile;
+{
+       int f;
+       int answer;
+       int no_display;
+       int chflags;
+       char *filename;
+       char *open_filename;
+       char *qopen_filename;
+       char *alt_filename;
+       void *alt_pipe;
+       IFILE was_curr_ifile;
+       PARG parg;
+               
+       if (ifile == curr_ifile)
+       {
+               /*
+                * Already have the correct file open.
+                */
+               return (0);
+       }
+
+       /*
+        * We must close the currently open file now.
+        * This is necessary to make the open_altfile/close_altfile pairs
+        * nest properly (or rather to avoid nesting at all).
+        * {{ Some stupid implementations of popen() mess up if you do:
+        *    fA = popen("A"); fB = popen("B"); pclose(fA); pclose(fB); }}
+        */
+#if LOGFILE
+       end_logfile();
+#endif
+       was_curr_ifile = save_curr_ifile();
+       if (curr_ifile != NULL_IFILE)
+       {
+               chflags = ch_getflags();
+               close_file();
+               if ((chflags & CH_HELPFILE) && held_ifile(was_curr_ifile) <= 1)
+               {
+                       /*
+                        * Don't keep the help file in the ifile list.
+                        */
+                       del_ifile(was_curr_ifile);
+                       was_curr_ifile = old_ifile;
+               }
+       }
+
+       if (ifile == NULL_IFILE)
+       {
+               /*
+                * No new file to open.
+                * (Don't set old_ifile, because if you call edit_ifile(NULL),
+                *  you're supposed to have saved curr_ifile yourself,
+                *  and you'll restore it if necessary.)
+                */
+               unsave_ifile(was_curr_ifile);
+               return (0);
+       }
+
+       filename = save(get_filename(ifile));
+       /*
+        * See if LESSOPEN specifies an "alternate" file to open.
+        */
+       alt_pipe = NULL;
+       alt_filename = open_altfile(filename, &f, &alt_pipe);
+       open_filename = (alt_filename != NULL) ? alt_filename : filename;
+       qopen_filename = shell_unquote(open_filename);
+
+       chflags = 0;
+       if (alt_pipe != NULL)
+       {
+               /*
+                * The alternate "file" is actually a pipe.
+                * f has already been set to the file descriptor of the pipe
+                * in the call to open_altfile above.
+                * Keep the file descriptor open because it was opened 
+                * via popen(), and pclose() wants to close it.
+                */
+               chflags |= CH_POPENED;
+       } else if (strcmp(open_filename, "-") == 0)
+       {
+               /* 
+                * Use standard input.
+                * Keep the file descriptor open because we can't reopen it.
+                */
+               f = fd0;
+               chflags |= CH_KEEPOPEN;
+               /*
+                * Must switch stdin to BINARY mode.
+                */
+               SET_BINARY(f);
+#if MSDOS_COMPILER==DJGPPC
+               /*
+                * Setting stdin to binary by default causes
+                * Ctrl-C to not raise SIGINT.  We must undo
+                * that side-effect.
+                */
+               __djgpp_set_ctrl_c(1);
+#endif
+       } else if (strcmp(open_filename, FAKE_HELPFILE) == 0)
+       {
+               f = -1;
+               chflags |= CH_HELPFILE;
+       } else if ((parg.p_string = bad_file(open_filename)) != NULL)
+       {
+               /*
+                * It looks like a bad file.  Don't try to open it.
+                */
+               error("%s", &parg);
+               free(parg.p_string);
+           err1:
+               if (alt_filename != NULL)
+               {
+                       close_altfile(alt_filename, filename, alt_pipe);
+                       free(alt_filename);
+               }
+               del_ifile(ifile);
+               free(qopen_filename);
+               free(filename);
+               /*
+                * Re-open the current file.
+                */
+               if (was_curr_ifile == ifile)
+               {
+                       /*
+                        * Whoops.  The "current" ifile is the one we just deleted.
+                        * Just give up.
+                        */
+                       quit(QUIT_ERROR);
+               }
+               reedit_ifile(was_curr_ifile);
+               return (1);
+       } else if ((f = open(qopen_filename, OPEN_READ)) < 0)
+       {
+               /*
+                * Got an error trying to open it.
+                */
+               parg.p_string = errno_message(filename);
+               error("%s", &parg);
+               free(parg.p_string);
+               goto err1;
+       } else 
+       {
+               chflags |= CH_CANSEEK;
+               if (!force_open && !opened(ifile) && bin_file(f))
+               {
+                       /*
+                        * Looks like a binary file.  
+                        * Ask user if we should proceed.
+                        */
+                       parg.p_string = filename;
+                       answer = query("\"%s\" may be a binary file.  See it anyway? ",
+                               &parg);
+                       if (answer != 'y' && answer != 'Y')
+                       {
+                               close(f);
+                               goto err1;
+                       }
+               }
+       }
+
+       /*
+        * Get the new ifile.
+        * Get the saved position for the file.
+        */
+       if (was_curr_ifile != NULL_IFILE)
+       {
+               old_ifile = was_curr_ifile;
+               unsave_ifile(was_curr_ifile);
+       }
+       curr_ifile = ifile;
+       curr_altfilename = alt_filename;
+       curr_altpipe = alt_pipe;
+       set_open(curr_ifile); /* File has been opened */
+       get_pos(curr_ifile, &initial_scrpos);
+       new_file = TRUE;
+       ch_init(f, chflags);
+
+       if (!(chflags & CH_HELPFILE))
+       {
+#if LOGFILE
+               if (namelogfile != NULL && is_tty)
+                       use_logfile(namelogfile);
+#endif
+#if HAVE_STAT_INO
+               /* Remember the i-number and device of the opened file. */
+               {
+                       struct stat statbuf;
+                       int r = stat(qopen_filename, &statbuf);
+                       if (r == 0)
+                       {
+                               curr_ino = statbuf.st_ino;
+                               curr_dev = statbuf.st_dev;
+                       }
+               }
+#endif
+               if (every_first_cmd != NULL)
+                       ungetsc(every_first_cmd);
+       }
+
+       free(qopen_filename);
+       no_display = !any_display;
+       flush();
+       any_display = TRUE;
+
+       if (is_tty)
+       {
+               /*
+                * Output is to a real tty.
+                */
+
+               /*
+                * Indicate there is nothing displayed yet.
+                */
+               pos_clear();
+               clr_linenum();
+#if HILITE_SEARCH
+               clr_hilite();
+#endif
+               cmd_addhist(ml_examine, filename);
+               if (no_display && errmsgs > 0)
+               {
+                       /*
+                        * We displayed some messages on error output
+                        * (file descriptor 2; see error() function).
+                        * Before erasing the screen contents,
+                        * display the file name and wait for a keystroke.
+                        */
+                       parg.p_string = filename;
+                       error("%s", &parg);
+               }
+       }
+       free(filename);
+       return (0);
+}
+
+/*
+ * Edit a space-separated list of files.
+ * For each filename in the list, enter it into the ifile list.
+ * Then edit the first one.
+ */
+       public int
+edit_list(filelist)
+       char *filelist;
+{
+       IFILE save_ifile;
+       char *good_filename;
+       char *filename;
+       char *gfilelist;
+       char *gfilename;
+       struct textlist tl_files;
+       struct textlist tl_gfiles;
+
+       save_ifile = save_curr_ifile();
+       good_filename = NULL;
+       
+       /*
+        * Run thru each filename in the list.
+        * Try to glob the filename.  
+        * If it doesn't expand, just try to open the filename.
+        * If it does expand, try to open each name in that list.
+        */
+       init_textlist(&tl_files, filelist);
+       filename = NULL;
+       while ((filename = forw_textlist(&tl_files, filename)) != NULL)
+       {
+               gfilelist = lglob(filename);
+               init_textlist(&tl_gfiles, gfilelist);
+               gfilename = NULL;
+               while ((gfilename = forw_textlist(&tl_gfiles, gfilename)) != NULL)
+               {
+                       if (edit(gfilename) == 0 && good_filename == NULL)
+                               good_filename = get_filename(curr_ifile);
+               }
+               free(gfilelist);
+       }
+       /*
+        * Edit the first valid filename in the list.
+        */
+       if (good_filename == NULL)
+       {
+               unsave_ifile(save_ifile);
+               return (1);
+       }
+       if (get_ifile(good_filename, curr_ifile) == curr_ifile)
+       {
+               /*
+                * Trying to edit the current file; don't reopen it.
+                */
+               unsave_ifile(save_ifile);
+               return (0);
+       }
+       reedit_ifile(save_ifile);
+       return (edit(good_filename));
+}
+
+/*
+ * Edit the first file in the command line (ifile) list.
+ */
+       public int
+edit_first()
+{
+       curr_ifile = NULL_IFILE;
+       return (edit_next(1));
+}
+
+/*
+ * Edit the last file in the command line (ifile) list.
+ */
+       public int
+edit_last()
+{
+       curr_ifile = NULL_IFILE;
+       return (edit_prev(1));
+}
+
+
+/*
+ * Edit the n-th next or previous file in the command line (ifile) list.
+ */
+       static int
+edit_istep(h, n, dir)
+       IFILE h;
+       int n;
+       int dir;
+{
+       IFILE next;
+
+       /*
+        * Skip n filenames, then try to edit each filename.
+        */
+       for (;;)
+       {
+               next = (dir > 0) ? next_ifile(h) : prev_ifile(h);
+               if (--n < 0)
+               {
+                       if (edit_ifile(h) == 0)
+                               break;
+               }
+               if (next == NULL_IFILE)
+               {
+                       /*
+                        * Reached end of the ifile list.
+                        */
+                       return (1);
+               }
+               if (ABORT_SIGS())
+               {
+                       /*
+                        * Interrupt breaks out, if we're in a long
+                        * list of files that can't be opened.
+                        */
+                       return (1);
+               }
+               h = next;
+       } 
+       /*
+        * Found a file that we can edit.
+        */
+       return (0);
+}
+
+       static int
+edit_inext(h, n)
+       IFILE h;
+       int n;
+{
+       return (edit_istep(h, n, +1));
+}
+
+       public int
+edit_next(n)
+       int n;
+{
+       return edit_istep(curr_ifile, n, +1);
+}
+
+       static int
+edit_iprev(h, n)
+       IFILE h;
+       int n;
+{
+       return (edit_istep(h, n, -1));
+}
+
+       public int
+edit_prev(n)
+       int n;
+{
+       return edit_istep(curr_ifile, n, -1);
+}
+
+/*
+ * Edit a specific file in the command line (ifile) list.
+ */
+       public int
+edit_index(n)
+       int n;
+{
+       IFILE h;
+
+       h = NULL_IFILE;
+       do
+       {
+               if ((h = next_ifile(h)) == NULL_IFILE)
+               {
+                       /*
+                        * Reached end of the list without finding it.
+                        */
+                       return (1);
+               }
+       } while (get_index(h) != n);
+
+       return (edit_ifile(h));
+}
+
+       public IFILE
+save_curr_ifile()
+{
+       if (curr_ifile != NULL_IFILE)
+               hold_ifile(curr_ifile, 1);
+       return (curr_ifile);
+}
+
+       public void
+unsave_ifile(save_ifile)
+       IFILE save_ifile;
+{
+       if (save_ifile != NULL_IFILE)
+               hold_ifile(save_ifile, -1);
+}
+
+/*
+ * Reedit the ifile which was previously open.
+ */
+       public void
+reedit_ifile(save_ifile)
+       IFILE save_ifile;
+{
+       IFILE next;
+       IFILE prev;
+
+       /*
+        * Try to reopen the ifile.
+        * Note that opening it may fail (maybe the file was removed),
+        * in which case the ifile will be deleted from the list.
+        * So save the next and prev ifiles first.
+        */
+       unsave_ifile(save_ifile);
+       next = next_ifile(save_ifile);
+       prev = prev_ifile(save_ifile);
+       if (edit_ifile(save_ifile) == 0)
+               return;
+       /*
+        * If can't reopen it, open the next input file in the list.
+        */
+       if (next != NULL_IFILE && edit_inext(next, 0) == 0)
+               return;
+       /*
+        * If can't open THAT one, open the previous input file in the list.
+        */
+       if (prev != NULL_IFILE && edit_iprev(prev, 0) == 0)
+               return;
+       /*
+        * If can't even open that, we're stuck.  Just quit.
+        */
+       quit(QUIT_ERROR);
+}
+
+       public void
+reopen_curr_ifile()
+{
+       IFILE save_ifile = save_curr_ifile();
+       close_file();
+       reedit_ifile(save_ifile);
+}
+
+/*
+ * Edit standard input.
+ */
+       public int
+edit_stdin()
+{
+       if (isatty(fd0))
+       {
+               error("Missing filename (\"less --help\" for help)", NULL_PARG);
+               quit(QUIT_OK);
+       }
+       return (edit("-"));
+}
+
+/*
+ * Copy a file directly to standard output.
+ * Used if standard output is not a tty.
+ */
+       public void
+cat_file()
+{
+       register int c;
+
+       while ((c = ch_forw_get()) != EOI)
+               putchr(c);
+       flush();
+}
+
+#if LOGFILE
+
+/*
+ * If the user asked for a log file and our input file
+ * is standard input, create the log file.  
+ * We take care not to blindly overwrite an existing file.
+ */
+       public void
+use_logfile(filename)
+       char *filename;
+{
+       register int exists;
+       register int answer;
+       PARG parg;
+
+       if (ch_getflags() & CH_CANSEEK)
+               /*
+                * Can't currently use a log file on a file that can seek.
+                */
+               return;
+
+       /*
+        * {{ We could use access() here. }}
+        */
+       filename = shell_unquote(filename);
+       exists = open(filename, OPEN_READ);
+       close(exists);
+       exists = (exists >= 0);
+
+       /*
+        * Decide whether to overwrite the log file or append to it.
+        * If it doesn't exist we "overwrite" it.
+        */
+       if (!exists || force_logfile)
+       {
+               /*
+                * Overwrite (or create) the log file.
+                */
+               answer = 'O';
+       } else
+       {
+               /*
+                * Ask user what to do.
+                */
+               parg.p_string = filename;
+               answer = query("Warning: \"%s\" exists; Overwrite, Append or Don't log? ", &parg);
+       }
+
+loop:
+       switch (answer)
+       {
+       case 'O': case 'o':
+               /*
+                * Overwrite: create the file.
+                */
+               logfile = creat(filename, 0644);
+               break;
+       case 'A': case 'a':
+               /*
+                * Append: open the file and seek to the end.
+                */
+               logfile = open(filename, OPEN_APPEND);
+               if (lseek(logfile, (off_t)0, SEEK_END) == BAD_LSEEK)
+               {
+                       close(logfile);
+                       logfile = -1;
+               }
+               break;
+       case 'D': case 'd':
+               /*
+                * Don't do anything.
+                */
+               free(filename);
+               return;
+       case 'q':
+               quit(QUIT_OK);
+               /*NOTREACHED*/
+       default:
+               /*
+                * Eh?
+                */
+               answer = query("Overwrite, Append, or Don't log? (Type \"O\", \"A\", \"D\" or \"q\") ", NULL_PARG);
+               goto loop;
+       }
+
+       if (logfile < 0)
+       {
+               /*
+                * Error in opening logfile.
+                */
+               parg.p_string = filename;
+               error("Cannot write to \"%s\"", &parg);
+               free(filename);
+               return;
+       }
+       free(filename);
+       SET_BINARY(logfile);
+}
+
+#endif
diff --git a/thirdparty/less/filename.c b/thirdparty/less/filename.c
new file mode 100644 (file)
index 0000000..ed6dcc7
--- /dev/null
@@ -0,0 +1,1081 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to mess around with filenames (and files).
+ * Much of this is very OS dependent.
+ */
+
+#include "less.h"
+#include "lglob.h"
+#if MSDOS_COMPILER
+#include <dos.h>
+#if MSDOS_COMPILER==WIN32C && defined(__BORLANDC__)
+#include <dir.h>
+#endif
+#if MSDOS_COMPILER==DJGPPC
+#include <glob.h>
+#include <dir.h>
+#define _MAX_PATH      PATH_MAX
+#endif
+#endif
+#ifdef _OSK
+#include <rbf.h>
+#ifndef _OSK_MWC32
+#include <modes.h>
+#endif
+#endif
+#if OS2
+#include <signal.h>
+#endif
+
+#if HAVE_STAT
+#include <sys/stat.h>
+#ifndef S_ISDIR
+#define        S_ISDIR(m)      (((m) & S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define        S_ISREG(m)      (((m) & S_IFMT) == S_IFREG)
+#endif
+#endif
+
+
+extern int force_open;
+extern int secure;
+extern int use_lessopen;
+extern int ctldisp;
+extern int utf_mode;
+extern IFILE curr_ifile;
+extern IFILE old_ifile;
+#if SPACES_IN_FILENAMES
+extern char openquote;
+extern char closequote;
+#endif
+
+/*
+ * Remove quotes around a filename.
+ */
+       public char *
+shell_unquote(str)
+       char *str;
+{
+       char *name;
+       char *p;
+
+       name = p = (char *) ecalloc(strlen(str)+1, sizeof(char));
+       if (*str == openquote)
+       {
+               str++;
+               while (*str != '\0')
+               {
+                       if (*str == closequote)
+                       {
+                               if (str[1] != closequote)
+                                       break;
+                               str++;
+                       }
+                       *p++ = *str++;
+               }
+       } else
+       {
+               char *esc = get_meta_escape();
+               int esclen = strlen(esc);
+               while (*str != '\0')
+               {
+                       if (esclen > 0 && strncmp(str, esc, esclen) == 0)
+                               str += esclen;
+                       *p++ = *str++;
+               }
+       }
+       *p = '\0';
+       return (name);
+}
+
+/*
+ * Get the shell's escape character.
+ */
+       public char *
+get_meta_escape()
+{
+       char *s;
+
+       s = lgetenv("LESSMETAESCAPE");
+       if (s == NULL)
+               s = DEF_METAESCAPE;
+       return (s);
+}
+
+/*
+ * Get the characters which the shell considers to be "metacharacters".
+ */
+       static char *
+metachars()
+{
+       static char *mchars = NULL;
+
+       if (mchars == NULL)
+       {
+               mchars = lgetenv("LESSMETACHARS");
+               if (mchars == NULL)
+                       mchars = DEF_METACHARS;
+       }
+       return (mchars);
+}
+
+/*
+ * Is this a shell metacharacter?
+ */
+       static int
+metachar(c)
+       char c;
+{
+       return (strchr(metachars(), c) != NULL);
+}
+
+/*
+ * Insert a backslash before each metacharacter in a string.
+ */
+       public char *
+shell_quote(s)
+       char *s;
+{
+       char *p;
+       char *newstr;
+       int len;
+       char *esc = get_meta_escape();
+       int esclen = strlen(esc);
+       int use_quotes = 0;
+       int have_quotes = 0;
+
+       /*
+        * Determine how big a string we need to allocate.
+        */
+       len = 1; /* Trailing null byte */
+       for (p = s;  *p != '\0';  p++)
+       {
+               len++;
+               if (*p == openquote || *p == closequote)
+                       have_quotes = 1;
+               if (metachar(*p))
+               {
+                       if (esclen == 0)
+                       {
+                               /*
+                                * We've got a metachar, but this shell 
+                                * doesn't support escape chars.  Use quotes.
+                                */
+                               use_quotes = 1;
+                       } else
+                       {
+                               /*
+                                * Allow space for the escape char.
+                                */
+                               len += esclen;
+                       }
+               }
+       }
+       if (use_quotes)
+       {
+               if (have_quotes)
+                       /*
+                        * We can't quote a string that contains quotes.
+                        */
+                       return (NULL);
+               len = strlen(s) + 3;
+       }
+       /*
+        * Allocate and construct the new string.
+        */
+       newstr = p = (char *) ecalloc(len, sizeof(char));
+       if (use_quotes)
+       {
+               SNPRINTF3(newstr, len, "%c%s%c", openquote, s, closequote);
+       } else
+       {
+               while (*s != '\0')
+               {
+                       if (metachar(*s))
+                       {
+                               /*
+                                * Add the escape char.
+                                */
+                               strcpy(p, esc);
+                               p += esclen;
+                       }
+                       *p++ = *s++;
+               }
+               *p = '\0';
+       }
+       return (newstr);
+}
+
+/*
+ * Return a pathname that points to a specified file in a specified directory.
+ * Return NULL if the file does not exist in the directory.
+ */
+       static char *
+dirfile(dirname, filename)
+       char *dirname;
+       char *filename;
+{
+       char *pathname;
+       char *qpathname;
+       int len;
+       int f;
+
+       if (dirname == NULL || *dirname == '\0')
+               return (NULL);
+       /*
+        * Construct the full pathname.
+        */
+       len= strlen(dirname) + strlen(filename) + 2;
+       pathname = (char *) calloc(len, sizeof(char));
+       if (pathname == NULL)
+               return (NULL);
+       SNPRINTF3(pathname, len, "%s%s%s", dirname, PATHNAME_SEP, filename);
+       /*
+        * Make sure the file exists.
+        */
+       qpathname = shell_unquote(pathname);
+       f = open(qpathname, OPEN_READ);
+       if (f < 0)
+       {
+               free(pathname);
+               pathname = NULL;
+       } else
+       {
+               close(f);
+       }
+       free(qpathname);
+       return (pathname);
+}
+
+/*
+ * Return the full pathname of the given file in the "home directory".
+ */
+       public char *
+homefile(filename)
+       char *filename;
+{
+       register char *pathname;
+
+       /*
+        * Try $HOME/filename.
+        */
+       pathname = dirfile(lgetenv("HOME"), filename);
+       if (pathname != NULL)
+               return (pathname);
+#if OS2
+       /*
+        * Try $INIT/filename.
+        */
+       pathname = dirfile(lgetenv("INIT"), filename);
+       if (pathname != NULL)
+               return (pathname);
+#endif
+#if MSDOS_COMPILER || OS2
+       /*
+        * Look for the file anywhere on search path.
+        */
+       pathname = (char *) calloc(_MAX_PATH, sizeof(char));
+#if MSDOS_COMPILER==DJGPPC
+       {
+               char *res = searchpath(filename);
+               if (res == 0)
+                       *pathname = '\0';
+               else
+                       strcpy(pathname, res);
+       }
+#else
+       _searchenv(filename, "PATH", pathname);
+#endif
+       if (*pathname != '\0')
+               return (pathname);
+       free(pathname);
+#endif
+       return (NULL);
+}
+
+/*
+ * Expand a string, substituting any "%" with the current filename,
+ * and any "#" with the previous filename.
+ * But a string of N "%"s is just replaced with N-1 "%"s.
+ * Likewise for a string of N "#"s.
+ * {{ This is a lot of work just to support % and #. }}
+ */
+       public char *
+fexpand(s)
+       char *s;
+{
+       register char *fr, *to;
+       register int n;
+       register char *e;
+       IFILE ifile;
+
+#define        fchar_ifile(c) \
+       ((c) == '%' ? curr_ifile : \
+        (c) == '#' ? old_ifile : NULL_IFILE)
+
+       /*
+        * Make one pass to see how big a buffer we 
+        * need to allocate for the expanded string.
+        */
+       n = 0;
+       for (fr = s;  *fr != '\0';  fr++)
+       {
+               switch (*fr)
+               {
+               case '%':
+               case '#':
+                       if (fr > s && fr[-1] == *fr)
+                       {
+                               /*
+                                * Second (or later) char in a string
+                                * of identical chars.  Treat as normal.
+                                */
+                               n++;
+                       } else if (fr[1] != *fr)
+                       {
+                               /*
+                                * Single char (not repeated).  Treat specially.
+                                */
+                               ifile = fchar_ifile(*fr);
+                               if (ifile == NULL_IFILE)
+                                       n++;
+                               else
+                                       n += strlen(get_filename(ifile));
+                       }
+                       /*
+                        * Else it is the first char in a string of
+                        * identical chars.  Just discard it.
+                        */
+                       break;
+               default:
+                       n++;
+                       break;
+               }
+       }
+
+       e = (char *) ecalloc(n+1, sizeof(char));
+
+       /*
+        * Now copy the string, expanding any "%" or "#".
+        */
+       to = e;
+       for (fr = s;  *fr != '\0';  fr++)
+       {
+               switch (*fr)
+               {
+               case '%':
+               case '#':
+                       if (fr > s && fr[-1] == *fr)
+                       {
+                               *to++ = *fr;
+                       } else if (fr[1] != *fr)
+                       {
+                               ifile = fchar_ifile(*fr);
+                               if (ifile == NULL_IFILE)
+                                       *to++ = *fr;
+                               else
+                               {
+                                       strcpy(to, get_filename(ifile));
+                                       to += strlen(to);
+                               }
+                       }
+                       break;
+               default:
+                       *to++ = *fr;
+                       break;
+               }
+       }
+       *to = '\0';
+       return (e);
+}
+
+
+#if TAB_COMPLETE_FILENAME
+
+/*
+ * Return a blank-separated list of filenames which "complete"
+ * the given string.
+ */
+       public char *
+fcomplete(s)
+       char *s;
+{
+       char *fpat;
+       char *qs;
+
+       if (secure)
+               return (NULL);
+       /*
+        * Complete the filename "s" by globbing "s*".
+        */
+#if MSDOS_COMPILER && (MSDOS_COMPILER == MSOFTC || MSDOS_COMPILER == BORLANDC)
+       /*
+        * But in DOS, we have to glob "s*.*".
+        * But if the final component of the filename already has
+        * a dot in it, just do "s*".  
+        * (Thus, "FILE" is globbed as "FILE*.*", 
+        *  but "FILE.A" is globbed as "FILE.A*").
+        */
+       {
+               char *slash;
+               int len;
+               for (slash = s+strlen(s)-1;  slash > s;  slash--)
+                       if (*slash == *PATHNAME_SEP || *slash == '/')
+                               break;
+               len = strlen(s) + 4;
+               fpat = (char *) ecalloc(len, sizeof(char));
+               if (strchr(slash, '.') == NULL)
+                       SNPRINTF1(fpat, len, "%s*.*", s);
+               else
+                       SNPRINTF1(fpat, len, "%s*", s);
+       }
+#else
+       {
+       int len = strlen(s) + 2;
+       fpat = (char *) ecalloc(len, sizeof(char));
+       SNPRINTF1(fpat, len, "%s*", s);
+       }
+#endif
+       qs = lglob(fpat);
+       s = shell_unquote(qs);
+       if (strcmp(s,fpat) == 0)
+       {
+               /*
+                * The filename didn't expand.
+                */
+               free(qs);
+               qs = NULL;
+       }
+       free(s);
+       free(fpat);
+       return (qs);
+}
+#endif
+
+/*
+ * Try to determine if a file is "binary".
+ * This is just a guess, and we need not try too hard to make it accurate.
+ */
+       public int
+bin_file(f)
+       int f;
+{
+       int n;
+       int bin_count = 0;
+       char data[256];
+       char* p;
+       char* pend;
+
+       if (!seekable(f))
+               return (0);
+       if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
+               return (0);
+       n = read(f, data, sizeof(data));
+       pend = &data[n];
+       for (p = data;  p < pend;  )
+       {
+               LWCHAR c = step_char(&p, +1, pend);
+               if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
+               {
+                       do {
+                               c = step_char(&p, +1, pend);
+                       } while (p < pend && is_ansi_middle(c));
+               } else if (binary_char(c))
+                       bin_count++;
+       }
+       /*
+        * Call it a binary file if there are more than 5 binary characters
+        * in the first 256 bytes of the file.
+        */
+       return (bin_count > 5);
+}
+
+/*
+ * Try to determine the size of a file by seeking to the end.
+ */
+       static POSITION
+seek_filesize(f)
+       int f;
+{
+       off_t spos;
+
+       spos = lseek(f, (off_t)0, SEEK_END);
+       if (spos == BAD_LSEEK)
+               return (NULL_POSITION);
+       return ((POSITION) spos);
+}
+
+/*
+ * Read a string from a file.
+ * Return a pointer to the string in memory.
+ */
+       static char *
+readfd(fd)
+       FILE *fd;
+{
+       int len;
+       int ch;
+       char *buf;
+       char *p;
+       
+       /* 
+        * Make a guess about how many chars in the string
+        * and allocate a buffer to hold it.
+        */
+       len = 100;
+       buf = (char *) ecalloc(len, sizeof(char));
+       for (p = buf;  ;  p++)
+       {
+               if ((ch = getc(fd)) == '\n' || ch == EOF)
+                       break;
+               if (p - buf >= len-1)
+               {
+                       /*
+                        * The string is too big to fit in the buffer we have.
+                        * Allocate a new buffer, twice as big.
+                        */
+                       len *= 2;
+                       *p = '\0';
+                       p = (char *) ecalloc(len, sizeof(char));
+                       strcpy(p, buf);
+                       free(buf);
+                       buf = p;
+                       p = buf + strlen(buf);
+               }
+               *p = ch;
+       }
+       *p = '\0';
+       return (buf);
+}
+
+
+
+#if HAVE_POPEN
+
+#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
+FILE *popen();
+#endif
+
+/*
+ * Execute a shell command.
+ * Return a pointer to a pipe connected to the shell command's standard output.
+ */
+       static FILE *
+shellcmd(cmd)
+       char *cmd;
+{
+       FILE *fd;
+
+#if HAVE_SHELL
+       char *shell;
+
+       shell = lgetenv("SHELL");
+       if (shell != NULL && *shell != '\0')
+       {
+               char *scmd;
+               char *esccmd;
+
+               /*
+                * Read the output of <$SHELL -c cmd>.  
+                * Escape any metacharacters in the command.
+                */
+               esccmd = shell_quote(cmd);
+               if (esccmd == NULL)
+               {
+                       fd = popen(cmd, "r");
+               } else
+               {
+                       int len = strlen(shell) + strlen(esccmd) + 5;
+                       scmd = (char *) ecalloc(len, sizeof(char));
+                       SNPRINTF3(scmd, len, "%s %s %s", shell, shell_coption(), esccmd);
+                       free(esccmd);
+                       fd = popen(scmd, "r");
+                       free(scmd);
+               }
+       } else
+#endif
+       {
+               fd = popen(cmd, "r");
+       }
+       /*
+        * Redirection in `popen' might have messed with the
+        * standard devices.  Restore binary input mode.
+        */
+       SET_BINARY(0);
+       return (fd);
+}
+
+#endif /* HAVE_POPEN */
+
+
+/*
+ * Expand a filename, doing any system-specific metacharacter substitutions.
+ */
+       public char *
+lglob(filename)
+       char *filename;
+{
+       char *gfilename;
+       char *ofilename;
+
+       ofilename = fexpand(filename);
+       if (secure)
+               return (ofilename);
+       filename = shell_unquote(ofilename);
+
+#ifdef DECL_GLOB_LIST
+{
+       /*
+        * The globbing function returns a list of names.
+        */
+       int length;
+       char *p;
+       char *qfilename;
+       DECL_GLOB_LIST(list)
+
+       GLOB_LIST(filename, list);
+       if (GLOB_LIST_FAILED(list))
+       {
+               free(filename);
+               return (ofilename);
+       }
+       length = 1; /* Room for trailing null byte */
+       for (SCAN_GLOB_LIST(list, p))
+       {
+               INIT_GLOB_LIST(list, p);
+               qfilename = shell_quote(p);
+               if (qfilename != NULL)
+               {
+                       length += strlen(qfilename) + 1;
+                       free(qfilename);
+               }
+       }
+       gfilename = (char *) ecalloc(length, sizeof(char));
+       for (SCAN_GLOB_LIST(list, p))
+       {
+               INIT_GLOB_LIST(list, p);
+               qfilename = shell_quote(p);
+               if (qfilename != NULL)
+               {
+                       sprintf(gfilename + strlen(gfilename), "%s ", qfilename);
+                       free(qfilename);
+               }
+       }
+       /*
+        * Overwrite the final trailing space with a null terminator.
+        */
+       *--p = '\0';
+       GLOB_LIST_DONE(list);
+}
+#else
+#ifdef DECL_GLOB_NAME
+{
+       /*
+        * The globbing function returns a single name, and
+        * is called multiple times to walk thru all names.
+        */
+       register char *p;
+       register int len;
+       register int n;
+       char *pathname;
+       char *qpathname;
+       DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle)
+       
+       GLOB_FIRST_NAME(filename, &fnd, handle);
+       if (GLOB_FIRST_FAILED(handle))
+       {
+               free(filename);
+               return (ofilename);
+       }
+
+       _splitpath(filename, drive, dir, fname, ext);
+       len = 100;
+       gfilename = (char *) ecalloc(len, sizeof(char));
+       p = gfilename;
+       do {
+               n = strlen(drive) + strlen(dir) + strlen(fnd.GLOB_NAME) + 1;
+               pathname = (char *) ecalloc(n, sizeof(char));
+               SNPRINTF3(pathname, n, "%s%s%s", drive, dir, fnd.GLOB_NAME);
+               qpathname = shell_quote(pathname);
+               free(pathname);
+               if (qpathname != NULL)
+               {
+                       n = strlen(qpathname);
+                       while (p - gfilename + n + 2 >= len)
+                       {
+                               /*
+                                * No room in current buffer.
+                                * Allocate a bigger one.
+                                */
+                               len *= 2;
+                               *p = '\0';
+                               p = (char *) ecalloc(len, sizeof(char));
+                               strcpy(p, gfilename);
+                               free(gfilename);
+                               gfilename = p;
+                               p = gfilename + strlen(gfilename);
+                       }
+                       strcpy(p, qpathname);
+                       free(qpathname);
+                       p += n;
+                       *p++ = ' ';
+               }
+       } while (GLOB_NEXT_NAME(handle, &fnd) == 0);
+
+       /*
+        * Overwrite the final trailing space with a null terminator.
+        */
+       *--p = '\0';
+       GLOB_NAME_DONE(handle);
+}
+#else
+#if HAVE_POPEN
+{
+       /*
+        * We get the shell to glob the filename for us by passing
+        * an "echo" command to the shell and reading its output.
+        */
+       FILE *fd;
+       char *s;
+       char *lessecho;
+       char *cmd;
+       char *esc;
+       int len;
+
+       esc = get_meta_escape();
+       if (strlen(esc) == 0)
+               esc = "-";
+       esc = shell_quote(esc);
+       if (esc == NULL)
+       {
+               free(filename);
+               return (ofilename);
+       }
+       lessecho = lgetenv("LESSECHO");
+       if (lessecho == NULL || *lessecho == '\0')
+               lessecho = "lessecho";
+       /*
+        * Invoke lessecho, and read its output (a globbed list of filenames).
+        */
+       len = strlen(lessecho) + strlen(ofilename) + (7*strlen(metachars())) + 24;
+       cmd = (char *) ecalloc(len, sizeof(char));
+       SNPRINTF4(cmd, len, "%s -p0x%x -d0x%x -e%s ", lessecho, openquote, closequote, esc);
+       free(esc);
+       for (s = metachars();  *s != '\0';  s++)
+               sprintf(cmd + strlen(cmd), "-n0x%x ", *s);
+       sprintf(cmd + strlen(cmd), "-- %s", ofilename);
+       fd = shellcmd(cmd);
+       free(cmd);
+       if (fd == NULL)
+       {
+               /*
+                * Cannot create the pipe.
+                * Just return the original (fexpanded) filename.
+                */
+               free(filename);
+               return (ofilename);
+       }
+       gfilename = readfd(fd);
+       pclose(fd);
+       if (*gfilename == '\0')
+       {
+               free(gfilename);
+               free(filename);
+               return (ofilename);
+       }
+}
+#else
+       /*
+        * No globbing functions at all.  Just use the fexpanded filename.
+        */
+       gfilename = save(filename);
+#endif
+#endif
+#endif
+       free(filename);
+       free(ofilename);
+       return (gfilename);
+}
+
+/*
+ * See if we should open a "replacement file" 
+ * instead of the file we're about to open.
+ */
+       public char *
+open_altfile(filename, pf, pfd)
+       char *filename;
+       int *pf;
+       void **pfd;
+{
+#if !HAVE_POPEN
+       return (NULL);
+#else
+       char *lessopen;
+       char *cmd;
+       int len;
+       FILE *fd;
+#if HAVE_FILENO
+       int returnfd = 0;
+#endif
+       
+       if (!use_lessopen || secure)
+               return (NULL);
+       ch_ungetchar(-1);
+       if ((lessopen = lgetenv("LESSOPEN")) == NULL)
+               return (NULL);
+       if (*lessopen == '|')
+       {
+               /*
+                * If LESSOPEN starts with a |, it indicates 
+                * a "pipe preprocessor".
+                */
+#if !HAVE_FILENO
+               error("LESSOPEN pipe is not supported", NULL_PARG);
+               return (NULL);
+#else
+               lessopen++;
+               returnfd = 1;
+#endif
+       }
+       if (*lessopen == '-') {
+               /*
+                * Lessopen preprocessor will accept "-" as a filename.
+                */
+               lessopen++;
+       } else {
+               if (strcmp(filename, "-") == 0)
+                       return (NULL);
+       }
+
+       len = strlen(lessopen) + strlen(filename) + 2;
+       cmd = (char *) ecalloc(len, sizeof(char));
+       SNPRINTF1(cmd, len, lessopen, filename);
+       fd = shellcmd(cmd);
+       free(cmd);
+       if (fd == NULL)
+       {
+               /*
+                * Cannot create the pipe.
+                */
+               return (NULL);
+       }
+#if HAVE_FILENO
+       if (returnfd)
+       {
+               int f;
+               char c;
+
+               /*
+                * Read one char to see if the pipe will produce any data.
+                * If it does, push the char back on the pipe.
+                */
+               f = fileno(fd);
+               SET_BINARY(f);
+               if (read(f, &c, 1) != 1)
+               {
+                       /*
+                        * Pipe is empty.  This means there is no alt file.
+                        */
+                       pclose(fd);
+                       return (NULL);
+               }
+               ch_ungetchar(c);
+               *pfd = (void *) fd;
+               *pf = f;
+               return (save("-"));
+       }
+#endif
+       cmd = readfd(fd);
+       pclose(fd);
+       if (*cmd == '\0')
+               /*
+                * Pipe is empty.  This means there is no alt file.
+                */
+               return (NULL);
+       return (cmd);
+#endif /* HAVE_POPEN */
+}
+
+/*
+ * Close a replacement file.
+ */
+       public void
+close_altfile(altfilename, filename, pipefd)
+       char *altfilename;
+       char *filename;
+       void *pipefd;
+{
+#if HAVE_POPEN
+       char *lessclose;
+       FILE *fd;
+       char *cmd;
+       int len;
+       
+       if (secure)
+               return;
+       if (pipefd != NULL)
+       {
+#if OS2
+               /*
+                * The pclose function of OS/2 emx sometimes fails.
+                * Send SIGINT to the piped process before closing it.
+                */
+               kill(((FILE*)pipefd)->_pid, SIGINT);
+#endif
+               pclose((FILE*) pipefd);
+       }
+       if ((lessclose = lgetenv("LESSCLOSE")) == NULL)
+               return;
+       len = strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2;
+       cmd = (char *) ecalloc(len, sizeof(char));
+       SNPRINTF2(cmd, len, lessclose, filename, altfilename);
+       fd = shellcmd(cmd);
+       free(cmd);
+       if (fd != NULL)
+               pclose(fd);
+#endif
+}
+               
+/*
+ * Is the specified file a directory?
+ */
+       public int
+is_dir(filename)
+       char *filename;
+{
+       int isdir = 0;
+
+       filename = shell_unquote(filename);
+#if HAVE_STAT
+{
+       int r;
+       struct stat statbuf;
+
+       r = stat(filename, &statbuf);
+       isdir = (r >= 0 && S_ISDIR(statbuf.st_mode));
+}
+#else
+#ifdef _OSK
+{
+       register int f;
+
+       f = open(filename, S_IREAD | S_IFDIR);
+       if (f >= 0)
+               close(f);
+       isdir = (f >= 0);
+}
+#endif
+#endif
+       free(filename);
+       return (isdir);
+}
+
+/*
+ * Returns NULL if the file can be opened and
+ * is an ordinary file, otherwise an error message
+ * (if it cannot be opened or is a directory, etc.)
+ */
+       public char *
+bad_file(filename)
+       char *filename;
+{
+       register char *m = NULL;
+
+       filename = shell_unquote(filename);
+       if (!force_open && is_dir(filename))
+       {
+               static char is_a_dir[] = " is a directory";
+
+               m = (char *) ecalloc(strlen(filename) + sizeof(is_a_dir), 
+                       sizeof(char));
+               strcpy(m, filename);
+               strcat(m, is_a_dir);
+       } else
+       {
+#if HAVE_STAT
+               int r;
+               struct stat statbuf;
+
+               r = stat(filename, &statbuf);
+               if (r < 0)
+               {
+                       m = errno_message(filename);
+               } else if (force_open)
+               {
+                       m = NULL;
+               } else if (!S_ISREG(statbuf.st_mode))
+               {
+                       static char not_reg[] = " is not a regular file (use -f to see it)";
+                       m = (char *) ecalloc(strlen(filename) + sizeof(not_reg),
+                               sizeof(char));
+                       strcpy(m, filename);
+                       strcat(m, not_reg);
+               }
+#endif
+       }
+       free(filename);
+       return (m);
+}
+
+/*
+ * Return the size of a file, as cheaply as possible.
+ * In Unix, we can stat the file.
+ */
+       public POSITION
+filesize(f)
+       int f;
+{
+#if HAVE_STAT
+       struct stat statbuf;
+
+       if (fstat(f, &statbuf) >= 0)
+               return ((POSITION) statbuf.st_size);
+#else
+#ifdef _OSK
+       long size;
+
+       if ((size = (long) _gs_size(f)) >= 0)
+               return ((POSITION) size);
+#endif
+#endif
+       return (seek_filesize(f));
+}
+
+/*
+ * 
+ */
+       public char *
+shell_coption()
+{
+       return ("-c");
+}
+
+/*
+ * Return last component of a pathname.
+ */
+       public char *
+last_component(name)
+       char *name;
+{
+       char *slash;
+
+       for (slash = name + strlen(name);  slash > name; )
+       {
+               --slash;
+               if (*slash == *PATHNAME_SEP || *slash == '/')
+                       return (slash + 1);
+       }
+       return (name);
+}
+
diff --git a/thirdparty/less/forwback.c b/thirdparty/less/forwback.c
new file mode 100644 (file)
index 0000000..ebe422d
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Primitives for displaying the file on the screen,
+ * scrolling either forward or backward.
+ */
+
+#include "less.h"
+#include "position.h"
+
+public int screen_trashed;
+public int squished;
+public int no_back_scroll = 0;
+public int forw_prompt;
+
+extern int sigs;
+extern int top_scroll;
+extern int quiet;
+extern int sc_width, sc_height;
+extern int plusoption;
+extern int forw_scroll;
+extern int back_scroll;
+extern int ignore_eoi;
+extern int clear_bg;
+extern int final_attr;
+extern int oldbot;
+#if TAGS
+extern char *tagoption;
+#endif
+
+/*
+ * Sound the bell to indicate user is trying to move past end of file.
+ */
+       static void
+eof_bell()
+{
+       if (quiet == NOT_QUIET)
+               bell();
+       else
+               vbell();
+}
+
+/*
+ * Check to see if the end of file is currently displayed.
+ */
+       public int
+eof_displayed()
+{
+       POSITION pos;
+
+       if (ignore_eoi)
+               return (0);
+
+       if (ch_length() == NULL_POSITION)
+               /*
+                * If the file length is not known,
+                * we can't possibly be displaying EOF.
+                */
+               return (0);
+
+       /*
+        * If the bottom line is empty, we are at EOF.
+        * If the bottom line ends at the file length,
+        * we must be just at EOF.
+        */
+       pos = position(BOTTOM_PLUS_ONE);
+       return (pos == NULL_POSITION || pos == ch_length());
+}
+
+/*
+ * Check to see if the entire file is currently displayed.
+ */
+       public int
+entire_file_displayed()
+{
+       POSITION pos;
+
+       /* Make sure last line of file is displayed. */
+       if (!eof_displayed())
+               return (0);
+
+       /* Make sure first line of file is displayed. */
+       pos = position(0);
+       return (pos == NULL_POSITION || pos == 0);
+}
+
+/*
+ * If the screen is "squished", repaint it.
+ * "Squished" means the first displayed line is not at the top
+ * of the screen; this can happen when we display a short file
+ * for the first time.
+ */
+       public void
+squish_check()
+{
+       if (!squished)
+               return;
+       squished = 0;
+       repaint();
+}
+
+/*
+ * Display n lines, scrolling forward, 
+ * starting at position pos in the input file.
+ * "force" means display the n lines even if we hit end of file.
+ * "only_last" means display only the last screenful if n > screen size.
+ * "nblank" is the number of blank lines to draw before the first
+ *   real line.  If nblank > 0, the pos must be NULL_POSITION.
+ *   The first real line after the blanks will start at ch_zero().
+ */
+       public void
+forw(n, pos, force, only_last, nblank)
+       register int n;
+       POSITION pos;
+       int force;
+       int only_last;
+       int nblank;
+{
+       int eof = 0;
+       int nlines = 0;
+       int do_repaint;
+       static int first_time = 1;
+
+       squish_check();
+
+       /*
+        * do_repaint tells us not to display anything till the end, 
+        * then just repaint the entire screen.
+        * We repaint if we are supposed to display only the last 
+        * screenful and the request is for more than a screenful.
+        * Also if the request exceeds the forward scroll limit
+        * (but not if the request is for exactly a screenful, since
+        * repainting itself involves scrolling forward a screenful).
+        */
+       do_repaint = (only_last && n > sc_height-1) || 
+               (forw_scroll >= 0 && n > forw_scroll && n != sc_height-1);
+
+       if (!do_repaint)
+       {
+               if (top_scroll && n >= sc_height - 1 && pos != ch_length())
+               {
+                       /*
+                        * Start a new screen.
+                        * {{ This is not really desirable if we happen
+                        *    to hit eof in the middle of this screen,
+                        *    but we don't yet know if that will happen. }}
+                        */
+                       pos_clear();
+                       add_forw_pos(pos);
+                       force = 1;
+                       clear();
+                       home();
+               }
+
+               if (pos != position(BOTTOM_PLUS_ONE) || empty_screen())
+               {
+                       /*
+                        * This is not contiguous with what is
+                        * currently displayed.  Clear the screen image 
+                        * (position table) and start a new screen.
+                        */
+                       pos_clear();
+                       add_forw_pos(pos);
+                       force = 1;
+                       if (top_scroll)
+                       {
+                               clear();
+                               home();
+                       } else if (!first_time)
+                       {
+                               putstr("...skipping...\n");
+                       }
+               }
+       }
+
+       while (--n >= 0)
+       {
+               /*
+                * Read the next line of input.
+                */
+               if (nblank > 0)
+               {
+                       /*
+                        * Still drawing blanks; don't get a line 
+                        * from the file yet.
+                        * If this is the last blank line, get ready to
+                        * read a line starting at ch_zero() next time.
+                        */
+                       if (--nblank == 0)
+                               pos = ch_zero();
+               } else
+               {
+                       /* 
+                        * Get the next line from the file.
+                        */
+                       pos = forw_line(pos);
+                       if (pos == NULL_POSITION)
+                       {
+                               /*
+                                * End of file: stop here unless the top line 
+                                * is still empty, or "force" is true.
+                                * Even if force is true, stop when the last
+                                * line in the file reaches the top of screen.
+                                */
+                               eof = 1;
+                               if (!force && position(TOP) != NULL_POSITION)
+                                       break;
+                               if (!empty_lines(0, 0) && 
+                                   !empty_lines(1, 1) &&
+                                    empty_lines(2, sc_height-1))
+                                       break;
+                       }
+               }
+               /*
+                * Add the position of the next line to the position table.
+                * Display the current line on the screen.
+                */
+               add_forw_pos(pos);
+               nlines++;
+               if (do_repaint)
+                       continue;
+               /*
+                * If this is the first screen displayed and
+                * we hit an early EOF (i.e. before the requested
+                * number of lines), we "squish" the display down
+                * at the bottom of the screen.
+                * But don't do this if a + option or a -t option
+                * was given.  These options can cause us to
+                * start the display after the beginning of the file,
+                * and it is not appropriate to squish in that case.
+                */
+               if (first_time && pos == NULL_POSITION && !top_scroll && 
+#if TAGS
+                   tagoption == NULL &&
+#endif
+                   !plusoption)
+               {
+                       squished = 1;
+                       continue;
+               }
+               put_line();
+#if 0
+               /* {{ 
+                * Can't call clear_eol here.  The cursor might be at end of line
+                * on an ignaw terminal, so clear_eol would clear the last char
+                * of the current line instead of all of the next line.
+                * If we really need to do this on clear_bg terminals, we need
+                * to find a better way.
+                * }}
+                */
+               if (clear_bg && apply_at_specials(final_attr) != AT_NORMAL)
+               {
+                       /*
+                        * Writing the last character on the last line
+                        * of the display may have scrolled the screen.
+                        * If we were in standout mode, clear_bg terminals 
+                        * will fill the new line with the standout color.
+                        * Now we're in normal mode again, so clear the line.
+                        */
+                       clear_eol();
+               }
+#endif
+               forw_prompt = 1;
+       }
+
+       if (nlines == 0)
+               eof_bell();
+       else if (do_repaint)
+               repaint();
+       first_time = 0;
+       (void) currline(BOTTOM);
+}
+
+/*
+ * Display n lines, scrolling backward.
+ */
+       public void
+back(n, pos, force, only_last)
+       register int n;
+       POSITION pos;
+       int force;
+       int only_last;
+{
+       int nlines = 0;
+       int do_repaint;
+
+       squish_check();
+       do_repaint = (n > get_back_scroll() || (only_last && n > sc_height-1));
+       while (--n >= 0)
+       {
+               /*
+                * Get the previous line of input.
+                */
+               pos = back_line(pos);
+               if (pos == NULL_POSITION)
+               {
+                       /*
+                        * Beginning of file: stop here unless "force" is true.
+                        */
+                       if (!force)
+                               break;
+               }
+               /*
+                * Add the position of the previous line to the position table.
+                * Display the line on the screen.
+                */
+               add_back_pos(pos);
+               nlines++;
+               if (!do_repaint)
+               {
+                       home();
+                       add_line();
+                       put_line();
+               }
+       }
+
+       if (nlines == 0)
+               eof_bell();
+       else if (do_repaint)
+               repaint();
+       else if (!oldbot)
+               lower_left();
+       (void) currline(BOTTOM);
+}
+
+/*
+ * Display n more lines, forward.
+ * Start just after the line currently displayed at the bottom of the screen.
+ */
+       public void
+forward(n, force, only_last)
+       int n;
+       int force;
+       int only_last;
+{
+       POSITION pos;
+
+       if (get_quit_at_eof() && eof_displayed() && !(ch_getflags() & CH_HELPFILE))
+       {
+               /*
+                * If the -e flag is set and we're trying to go
+                * forward from end-of-file, go on to the next file.
+                */
+               if (edit_next(1))
+                       quit(QUIT_OK);
+               return;
+       }
+
+       pos = position(BOTTOM_PLUS_ONE);
+       if (pos == NULL_POSITION && (!force || empty_lines(2, sc_height-1)))
+       {
+               if (ignore_eoi)
+               {
+                       /*
+                        * ignore_eoi is to support A_F_FOREVER.
+                        * Back up until there is a line at the bottom
+                        * of the screen.
+                        */
+                       if (empty_screen())
+                               pos = ch_zero();
+                       else
+                       {
+                               do
+                               {
+                                       back(1, position(TOP), 1, 0);
+                                       pos = position(BOTTOM_PLUS_ONE);
+                               } while (pos == NULL_POSITION);
+                       }
+               } else
+               {
+                       eof_bell();
+                       return;
+               }
+       }
+       forw(n, pos, force, only_last, 0);
+}
+
+/*
+ * Display n more lines, backward.
+ * Start just before the line currently displayed at the top of the screen.
+ */
+       public void
+backward(n, force, only_last)
+       int n;
+       int force;
+       int only_last;
+{
+       POSITION pos;
+
+       pos = position(TOP);
+       if (pos == NULL_POSITION && (!force || position(BOTTOM) == 0))
+       {
+               eof_bell();
+               return;   
+       }
+       back(n, pos, force, only_last);
+}
+
+/*
+ * Get the backwards scroll limit.
+ * Must call this function instead of just using the value of
+ * back_scroll, because the default case depends on sc_height and
+ * top_scroll, as well as back_scroll.
+ */
+       public int
+get_back_scroll()
+{
+       if (no_back_scroll)
+               return (0);
+       if (back_scroll >= 0)
+               return (back_scroll);
+       if (top_scroll)
+               return (sc_height - 2);
+       return (10000); /* infinity */
+}
diff --git a/thirdparty/less/funcs.h b/thirdparty/less/funcs.h
new file mode 100644 (file)
index 0000000..6595232
--- /dev/null
@@ -0,0 +1,291 @@
+       public char * save ();
+       public VOID_POINTER ecalloc ();
+       public char * skipsp ();
+       public int sprefix ();
+       public void quit ();
+       public void raw_mode ();
+       public void scrsize ();
+       public char * special_key_str ();
+       public void get_term ();
+       public void init ();
+       public void deinit ();
+       public void home ();
+       public void add_line ();
+       public void remove_top ();
+       public void win32_scroll_up ();
+       public void lower_left ();
+       public void line_left ();
+       public void check_winch ();
+       public void goto_line ();
+       public void vbell ();
+       public void bell ();
+       public void clear ();
+       public void clear_eol ();
+       public void clear_bot ();
+       public void at_enter ();
+       public void at_exit ();
+       public void at_switch ();
+       public int is_at_equiv ();
+       public int apply_at_specials ();
+       public void backspace ();
+       public void putbs ();
+       public char WIN32getch ();
+       public void WIN32setcolors ();
+       public void WIN32textout ();
+       public void match_brac ();
+       public void ch_ungetchar ();
+       public void end_logfile ();
+       public void sync_logfile ();
+       public int ch_seek ();
+       public int ch_end_seek ();
+       public int ch_beg_seek ();
+       public POSITION ch_length ();
+       public POSITION ch_tell ();
+       public int ch_forw_get ();
+       public int ch_back_get ();
+       public void ch_setbufspace ();
+       public void ch_flush ();
+       public int seekable ();
+       public void ch_init ();
+       public void ch_close ();
+       public int ch_getflags ();
+       public void ch_dump ();
+       public void init_charset ();
+       public int binary_char ();
+       public int control_char ();
+       public char * prchar ();
+       public char * prutfchar ();
+       public int utf_len ();
+       public int is_utf8_well_formed ();
+       public LWCHAR get_wchar ();
+       public void put_wchar ();
+       public LWCHAR step_char ();
+       public int is_composing_char ();
+       public int is_ubin_char ();
+       public int is_wide_char ();
+       public int is_combining_char ();
+       public void cmd_reset ();
+       public void clear_cmd ();
+       public void cmd_putstr ();
+       public int len_cmdbuf ();
+       public void set_mlist ();
+       public void cmd_addhist ();
+       public void cmd_accept ();
+       public int cmd_char ();
+       public LINENUM cmd_int ();
+       public char * get_cmdbuf ();
+       public char * cmd_lastpattern ();
+       public void init_cmdhist ();
+       public void save_cmdhist ();
+       public int in_mca ();
+       public void dispversion ();
+       public int getcc ();
+       public void ungetcc ();
+       public void ungetsc ();
+       public void commands ();
+       public int cvt_length ();
+       public int * cvt_alloc_chpos ();
+       public void cvt_text ();
+       public void init_cmds ();
+       public void add_fcmd_table ();
+       public void add_ecmd_table ();
+       public int fcmd_decode ();
+       public int ecmd_decode ();
+       public char * lgetenv ();
+       public int lesskey ();
+       public void add_hometable ();
+       public int editchar ();
+       public void init_textlist ();
+       public char * forw_textlist ();
+       public char * back_textlist ();
+       public int edit ();
+       public int edit_ifile ();
+       public int edit_list ();
+       public int edit_first ();
+       public int edit_last ();
+       public int edit_next ();
+       public int edit_prev ();
+       public int edit_index ();
+       public IFILE save_curr_ifile ();
+       public void unsave_ifile ();
+       public void reedit_ifile ();
+       public void reopen_curr_ifile ();
+       public int edit_stdin ();
+       public void cat_file ();
+       public void use_logfile ();
+       public char * shell_unquote ();
+       public char * get_meta_escape ();
+       public char * shell_quote ();
+       public char * homefile ();
+       public char * fexpand ();
+       public char * fcomplete ();
+       public int bin_file ();
+       public char * lglob ();
+       public char * open_altfile ();
+       public void close_altfile ();
+       public int is_dir ();
+       public char * bad_file ();
+       public POSITION filesize ();
+       public char * shell_coption ();
+       public char * last_component ();
+       public int eof_displayed ();
+       public int entire_file_displayed ();
+       public void squish_check ();
+       public void forw ();
+       public void back ();
+       public void forward ();
+       public void backward ();
+       public int get_back_scroll ();
+       public void del_ifile ();
+       public IFILE next_ifile ();
+       public IFILE prev_ifile ();
+       public IFILE getoff_ifile ();
+       public int nifile ();
+       public IFILE get_ifile ();
+       public char * get_filename ();
+       public int get_index ();
+       public void store_pos ();
+       public void get_pos ();
+       public void set_open ();
+       public int opened ();
+       public void hold_ifile ();
+       public int held_ifile ();
+       public void * get_filestate ();
+       public void set_filestate ();
+       public void if_dump ();
+       public POSITION forw_line ();
+       public POSITION back_line ();
+       public void set_attnpos ();
+       public void jump_forw ();
+       public void jump_back ();
+       public void repaint ();
+       public void jump_percent ();
+       public void jump_line_loc ();
+       public void jump_loc ();
+       public void init_line ();
+       public int is_ascii_char ();
+       public void prewind ();
+       public void plinenum ();
+       public void pshift_all ();
+       public int is_ansi_end ();
+       public int is_ansi_middle ();
+       public int pappend ();
+       public int pflushmbc ();
+       public void pdone ();
+       public void set_status_col ();
+       public int gline ();
+       public void null_line ();
+       public POSITION forw_raw_line ();
+       public POSITION back_raw_line ();
+       public void clr_linenum ();
+       public void add_lnum ();
+       public LINENUM find_linenum ();
+       public POSITION find_pos ();
+       public LINENUM currline ();
+       public void lsystem ();
+       public int pipe_mark ();
+       public int pipe_data ();
+       public void init_mark ();
+       public int badmark ();
+       public void setmark ();
+       public void lastmark ();
+       public void gomark ();
+       public POSITION markpos ();
+       public void unmark ();
+       public void opt_o ();
+       public void opt__O ();
+       public void opt_j ();
+       public void calc_jump_sline ();
+       public void opt_shift ();
+       public void calc_shift_count ();
+       public void opt_k ();
+       public void opt_t ();
+       public void opt__T ();
+       public void opt_p ();
+       public void opt__P ();
+       public void opt_b ();
+       public void opt_i ();
+       public void opt__V ();
+       public void opt_D ();
+       public void opt_x ();
+       public void opt_quote ();
+       public void opt_query ();
+       public int get_swindow ();
+       public char * propt ();
+       public void scan_option ();
+       public void toggle_option ();
+       public int opt_has_param ();
+       public char * opt_prompt ();
+       public int isoptpending ();
+       public void nopendopt ();
+       public int getnum ();
+       public long getfraction ();
+       public int get_quit_at_eof ();
+       public void init_option ();
+       public struct loption * findopt ();
+       public struct loption * findopt_name ();
+       public int iread ();
+       public void intread ();
+       public long get_time ();
+       public char * errno_message ();
+       public int percentage ();
+       public POSITION percent_pos ();
+       public int  os9_signal ();
+       public void put_line ();
+       public void flush ();
+       public int putchr ();
+       public void putstr ();
+       public void get_return ();
+       public void error ();
+       public void ierror ();
+       public int query ();
+       public int compile_pattern ();
+       public void uncompile_pattern ();
+       public int is_null_pattern ();
+       public int match_pattern ();
+       public POSITION position ();
+       public void add_forw_pos ();
+       public void add_back_pos ();
+       public void pos_clear ();
+       public void pos_init ();
+       public int onscreen ();
+       public int empty_screen ();
+       public int empty_lines ();
+       public void get_scrpos ();
+       public int adjsline ();
+       public void init_prompt ();
+       public char * pr_expand ();
+       public char * eq_message ();
+       public char * pr_string ();
+       public char * wait_message ();
+       public void init_search ();
+       public void repaint_hilite ();
+       public void clear_attn ();
+       public void undo_search ();
+       public void clr_hlist ();
+       public void clr_hilite ();
+       public void clr_filter ();
+       public int is_filtered ();
+       public int is_hilited ();
+       public void chg_caseless ();
+       public void chg_hilite ();
+       public int search ();
+       public void prep_hilite ();
+       public void set_filter_pattern ();
+       public int is_filtering ();
+       public RETSIGTYPE winch ();
+       public RETSIGTYPE winch ();
+       public void init_signals ();
+       public void psignals ();
+       public void cleantags ();
+       public int gettagtype ();
+       public void findtag ();
+       public POSITION tagsearch ();
+       public char * nexttag ();
+       public char * prevtag ();
+       public int ntags ();
+       public int curr_tag ();
+       public int edit_tagfile ();
+       public void open_getchr ();
+       public void close_getchr ();
+       public int getchr ();
diff --git a/thirdparty/less/help.c b/thirdparty/less/help.c
new file mode 100644 (file)
index 0000000..85b0a4a
--- /dev/null
@@ -0,0 +1,236 @@
+/* This file was generated by mkhelp from less.hlp */
+#include "less.h"
+constant char helpdata[] = {
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','\b','S','U','\b','U','M','\b','M','M','\b','M','A','\b','A','R','\b','R','Y','\b','Y',' ','O','\b','O','F','\b','F',' ','L','\b','L','E','\b','E','S','\b','S','S','\b','S',' ','C','\b','C','O','\b','O','M','\b','M','M','\b','M','A','\b','A','N','\b','N','D','\b','D','S','\b','S','\n',
+'\n',
+' ',' ',' ',' ',' ',' ','C','o','m','m','a','n','d','s',' ','m','a','r','k','e','d',' ','w','i','t','h',' ','*',' ','m','a','y',' ','b','e',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','n','u','m','b','e','r',',',' ','_','\b','N','.','\n',
+' ',' ',' ',' ',' ',' ','N','o','t','e','s',' ','i','n',' ','p','a','r','e','n','t','h','e','s','e','s',' ','i','n','d','i','c','a','t','e',' ','t','h','e',' ','b','e','h','a','v','i','o','r',' ','i','f',' ','_','\b','N',' ','i','s',' ','g','i','v','e','n','.','\n',
+'\n',
+' ',' ','h',' ',' ','H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','i','s',' ','h','e','l','p','.','\n',
+' ',' ','q',' ',' ',':','q',' ',' ','Q',' ',' ',':','Q',' ',' ','Z','Z',' ',' ',' ',' ',' ','E','x','i','t','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','M','\b','M','O','\b','O','V','\b','V','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ','e',' ',' ','^','E',' ',' ','j',' ',' ','^','N',' ',' ','C','R',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','l','i','n','e',' ',' ',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','y',' ',' ','^','Y',' ',' ','k',' ',' ','^','K',' ',' ','^','P',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','l','i','n','e',' ',' ',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','f',' ',' ','^','F',' ',' ','^','V',' ',' ','S','P','A','C','E',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','b',' ',' ','^','B',' ',' ','E','S','C','-','v',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','o','r',' ','_','\b','N',' ','l','i','n','e','s',')','.','\n',
+' ',' ','z',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','E','S','C','-','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','w','i','n','d','o','w',',',' ','b','u','t',' ','d','o','n','\'','t',' ','s','t','o','p',' ','a','t',' ','e','n','d','-','o','f','-','f','i','l','e','.','\n',
+' ',' ','d',' ',' ','^','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','o','r','w','a','r','d',' ',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','u',' ',' ','^','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','B','a','c','k','w','a','r','d',' ','o','n','e',' ','h','a','l','f','-','w','i','n','d','o','w',' ','(','a','n','d',' ','s','e','t',' ','h','a','l','f','-','w','i','n','d','o','w',' ','t','o',' ','_','\b','N',')','.','\n',
+' ',' ','E','S','C','-',')',' ',' ','R','i','g','h','t','A','r','r','o','w',' ','*',' ',' ','L','e','f','t',' ',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
+' ',' ','E','S','C','-','(',' ',' ','L','e','f','t','A','r','r','o','w',' ',' ','*',' ',' ','R','i','g','h','t',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',' ','(','o','r',' ','_','\b','N',' ','p','o','s','i','t','i','o','n','s',')','.','\n',
+' ',' ','F',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','f','o','r','e','v','e','r',';',' ','l','i','k','e',' ','"','t','a','i','l',' ','-','f','"','.','\n',
+' ',' ','r',' ',' ','^','R',' ',' ','^','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n','.','\n',
+' ',' ','R',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','s','c','r','e','e','n',',',' ','d','i','s','c','a','r','d','i','n','g',' ','b','u','f','f','e','r','e','d',' ','i','n','p','u','t','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','D','e','f','a','u','l','t',' ','"','w','i','n','d','o','w','"',' ','i','s',' ','t','h','e',' ','s','c','r','e','e','n',' ','h','e','i','g','h','t','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','D','e','f','a','u','l','t',' ','"','h','a','l','f','-','w','i','n','d','o','w','"',' ','i','s',' ','h','a','l','f',' ','o','f',' ','t','h','e',' ','s','c','r','e','e','n',' ','h','e','i','g','h','t','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','\b','S','E','\b','E','A','\b','A','R','\b','R','C','\b','C','H','\b','H','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ','/','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','S','e','a','r','c','h',' ','f','o','r','w','a','r','d',' ','f','o','r',' ','(','_','\b','N','-','t','h',')',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','.','\n',
+' ',' ','?','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','S','e','a','r','c','h',' ','b','a','c','k','w','a','r','d',' ','f','o','r',' ','(','_','\b','N','-','t','h',')',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','.','\n',
+' ',' ','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',' ','(','f','o','r',' ','_','\b','N','-','t','h',' ','o','c','c','u','r','r','e','n','c','e',')','.','\n',
+' ',' ','N',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',' ','i','n',' ','r','e','v','e','r','s','e',' ','d','i','r','e','c','t','i','o','n','.','\n',
+' ',' ','E','S','C','-','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',',',' ','s','p','a','n','n','i','n','g',' ','f','i','l','e','s','.','\n',
+' ',' ','E','S','C','-','N',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','R','e','p','e','a','t',' ','p','r','e','v','i','o','u','s',' ','s','e','a','r','c','h',',',' ','r','e','v','e','r','s','e',' ','d','i','r','.',' ','&',' ','s','p','a','n','n','i','n','g',' ','f','i','l','e','s','.','\n',
+' ',' ','E','S','C','-','u',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','n','d','o',' ','(','t','o','g','g','l','e',')',' ','s','e','a','r','c','h',' ','h','i','g','h','l','i','g','h','t','i','n','g','.','\n',
+' ',' ','&','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','D','i','s','p','l','a','y',' ','o','n','l','y',' ','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','S','e','a','r','c','h',' ','p','a','t','t','e','r','n','s',' ','m','a','y',' ','b','e',' ','m','o','d','i','f','i','e','d',' ','b','y',' ','o','n','e',' ','o','r',' ','m','o','r','e',' ','o','f',':','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','N',' ','o','r',' ','!',' ',' ','S','e','a','r','c','h',' ','f','o','r',' ','N','O','N','-','m','a','t','c','h','i','n','g',' ','l','i','n','e','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','E',' ','o','r',' ','*',' ',' ','S','e','a','r','c','h',' ','m','u','l','t','i','p','l','e',' ','f','i','l','e','s',' ','(','p','a','s','s',' ','t','h','r','u',' ','E','N','D',' ','O','F',' ','F','I','L','E',')','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','F',' ','o','r',' ','@',' ',' ','S','t','a','r','t',' ','s','e','a','r','c','h',' ','a','t',' ','F','I','R','S','T',' ','f','i','l','e',' ','(','f','o','r',' ','/',')',' ','o','r',' ','l','a','s','t',' ','f','i','l','e',' ','(','f','o','r',' ','?',')','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','K',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','m','a','t','c','h','e','s',',',' ','b','u','t',' ','d','o','n','\'','t',' ','m','o','v','e',' ','(','K','E','E','P',' ','p','o','s','i','t','i','o','n',')','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','^','R',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','R','E','G','U','L','A','R',' ','E','X','P','R','E','S','S','I','O','N','S','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','J','\b','J','U','\b','U','M','\b','M','P','\b','P','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ','g',' ',' ','<',' ',' ','E','S','C','-','<',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','f','i','r','s','t',' ','l','i','n','e',' ','i','n',' ','f','i','l','e',' ','(','o','r',' ','l','i','n','e',' ','_','\b','N',')','.','\n',
+' ',' ','G',' ',' ','>',' ',' ','E','S','C','-','>',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','l','a','s','t',' ','l','i','n','e',' ','i','n',' ','f','i','l','e',' ','(','o','r',' ','l','i','n','e',' ','_','\b','N',')','.','\n',
+' ',' ','p',' ',' ','%',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','b','e','g','i','n','n','i','n','g',' ','o','f',' ','f','i','l','e',' ','(','o','r',' ','_','\b','N',' ','p','e','r','c','e','n','t',' ','i','n','t','o',' ','f','i','l','e',')','.','\n',
+' ',' ','t',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','n','e','x','t',' ','t','a','g','.','\n',
+' ',' ','T',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','G','o',' ','t','o',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','p','r','e','v','i','o','u','s',' ','t','a','g','.','\n',
+' ',' ','{',' ',' ','(',' ',' ','[',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','i','n','d',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','}',' ',')',' ',']','.','\n',
+' ',' ','}',' ',' ',')',' ',' ',']',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','F','i','n','d',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','{',' ','(',' ','[','.','\n',
+' ',' ','E','S','C','-','^','F',' ','_','\b','<','_','\b','c','_','\b','1','_','\b','>',' ','_','\b','<','_','\b','c','_','\b','2','_','\b','>',' ',' ','*',' ',' ','F','i','n','d',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','_','\b','<','_','\b','c','_','\b','2','_','\b','>','.','\n',
+' ',' ','E','S','C','-','^','B',' ','_','\b','<','_','\b','c','_','\b','1','_','\b','>',' ','_','\b','<','_','\b','c','_','\b','2','_','\b','>',' ',' ','*',' ',' ','F','i','n','d',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','_','\b','<','_','\b','c','_','\b','1','_','\b','>',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','E','a','c','h',' ','"','f','i','n','d',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t','"',' ','c','o','m','m','a','n','d',' ','g','o','e','s',' ','f','o','r','w','a','r','d',' ','t','o',' ','t','h','e',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','m','a','t','c','h','i','n','g',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','i','n',' ','t','h','e',' ','t','o','p',' ','l','i','n','e','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','E','a','c','h',' ','"','f','i','n','d',' ','o','p','e','n',' ','b','r','a','c','k','e','t','"',' ','c','o','m','m','a','n','d',' ','g','o','e','s',' ','b','a','c','k','w','a','r','d',' ','t','o',' ','t','h','e',' ','o','p','e','n',' ','b','r','a','c','k','e','t',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','m','a','t','c','h','i','n','g',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','c','l','o','s','e',' ','b','r','a','c','k','e','t',' ','i','n',' ','t','h','e',' ','b','o','t','t','o','m',' ','l','i','n','e','.','\n',
+'\n',
+' ',' ','m','_','\b','<','_','\b','l','_','\b','e','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','M','a','r','k',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','p','o','s','i','t','i','o','n',' ','w','i','t','h',' ','<','l','e','t','t','e','r','>','.','\n',
+' ',' ','\'','_','\b','<','_','\b','l','_','\b','e','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','G','o',' ','t','o',' ','a',' ','p','r','e','v','i','o','u','s','l','y',' ','m','a','r','k','e','d',' ','p','o','s','i','t','i','o','n','.','\n',
+' ',' ','\'','\'',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','G','o',' ','t','o',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','o','s','i','t','i','o','n','.','\n',
+' ',' ','^','X','^','X',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','a','m','e',' ','a','s',' ','\'','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','A',' ','m','a','r','k',' ','i','s',' ','a','n','y',' ','u','p','p','e','r','-','c','a','s','e',' ','o','r',' ','l','o','w','e','r','-','c','a','s','e',' ','l','e','t','t','e','r','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','C','e','r','t','a','i','n',' ','m','a','r','k','s',' ','a','r','e',' ','p','r','e','d','e','f','i','n','e','d',':','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','^',' ',' ','m','e','a','n','s',' ',' ','b','e','g','i','n','n','i','n','g',' ','o','f',' ','t','h','e',' ','f','i','l','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','$',' ',' ','m','e','a','n','s',' ',' ','e','n','d',' ','o','f',' ','t','h','e',' ','f','i','l','e','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','\b','C','H','\b','H','A','\b','A','N','\b','N','G','\b','G','I','\b','I','N','\b','N','G','\b','G',' ','F','\b','F','I','\b','I','L','\b','L','E','\b','E','S','\b','S','\n',
+'\n',
+' ',' ',':','e',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','a','m','i','n','e',' ','a',' ','n','e','w',' ','f','i','l','e','.','\n',
+' ',' ','^','X','^','V',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','a','m','e',' ','a','s',' ',':','e','.','\n',
+' ',' ',':','n',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','E','x','a','m','i','n','e',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','n','e','x','t',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ',' ',':','p',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','E','x','a','m','i','n','e',' ','t','h','e',' ','(','_','\b','N','-','t','h',')',' ','p','r','e','v','i','o','u','s',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ',' ',':','x',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*',' ',' ','E','x','a','m','i','n','e',' ','t','h','e',' ','f','i','r','s','t',' ','(','o','r',' ','_','\b','N','-','t','h',')',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ',' ',':','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','f','r','o','m',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','l','i','s','t','.','\n',
+' ',' ','=',' ',' ','^','G',' ',' ',':','f',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','r','i','n','t',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','n','a','m','e','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','M','\b','M','I','\b','I','S','\b','S','C','\b','C','E','\b','E','L','\b','L','L','\b','L','A','\b','A','N','\b','N','E','\b','E','O','\b','O','U','\b','U','S','\b','S',' ','C','\b','C','O','\b','O','M','\b','M','M','\b','M','A','\b','A','N','\b','N','D','\b','D','S','\b','S','\n',
+'\n',
+' ',' ','-','_','\b','<','_','\b','f','_','\b','l','_','\b','a','_','\b','g','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','o','g','g','l','e',' ','a',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','o','p','t','i','o','n',' ','[','s','e','e',' ','O','P','T','I','O','N','S',' ','b','e','l','o','w',']','.','\n',
+' ',' ','-','-','_','\b','<','_','\b','n','_','\b','a','_','\b','m','_','\b','e','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','o','g','g','l','e',' ','a',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','o','p','t','i','o','n',',',' ','b','y',' ','n','a','m','e','.','\n',
+' ',' ','_','_','\b','<','_','\b','f','_','\b','l','_','\b','a','_','\b','g','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','s','e','t','t','i','n','g',' ','o','f',' ','a',' ','c','o','m','m','a','n','d',' ','l','i','n','e',' ','o','p','t','i','o','n','.','\n',
+' ',' ','_','_','_','\b','<','_','\b','n','_','\b','a','_','\b','m','_','\b','e','_','\b','>',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','s','e','t','t','i','n','g',' ','o','f',' ','a','n',' ','o','p','t','i','o','n',',',' ','b','y',' ','n','a','m','e','.','\n',
+' ',' ','+','_','\b','c','_','\b','m','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','l','e','s','s',' ','c','m','d',' ','e','a','c','h',' ','t','i','m','e',' ','a',' ','n','e','w',' ','f','i','l','e',' ','i','s',' ','e','x','a','m','i','n','e','d','.','\n',
+'\n',
+' ',' ','!','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','e','c','u','t','e',' ','t','h','e',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d',' ','w','i','t','h',' ','$','S','H','E','L','L','.','\n',
+' ',' ','|','X','\b','X','_','\b','c','_','\b','o','_','\b','m','_','\b','m','_','\b','a','_','\b','n','_','\b','d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','i','p','e',' ','f','i','l','e',' ','b','e','t','w','e','e','n',' ','c','u','r','r','e','n','t',' ','p','o','s',' ','&',' ','m','a','r','k',' ','X','\b','X',' ','t','o',' ','s','h','e','l','l',' ','c','o','m','m','a','n','d','.','\n',
+' ',' ','v',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','d','i','t',' ','t','h','e',' ','c','u','r','r','e','n','t',' ','f','i','l','e',' ','w','i','t','h',' ','$','V','I','S','U','A','L',' ','o','r',' ','$','E','D','I','T','O','R','.','\n',
+' ',' ','V',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','P','r','i','n','t',' ','v','e','r','s','i','o','n',' ','n','u','m','b','e','r',' ','o','f',' ','"','l','e','s','s','"','.','\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','O','\b','O','P','\b','P','T','\b','T','I','\b','I','O','\b','O','N','\b','N','S','\b','S','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ','M','o','s','t',' ','o','p','t','i','o','n','s',' ','m','a','y',' ','b','e',' ','c','h','a','n','g','e','d',' ','e','i','t','h','e','r',' ','o','n',' ','t','h','e',' ','c','o','m','m','a','n','d',' ','l','i','n','e',',','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','o','r',' ','f','r','o','m',' ','w','i','t','h','i','n',' ','l','e','s','s',' ','b','y',' ','u','s','i','n','g',' ','t','h','e',' ','-',' ','o','r',' ','-','-',' ','c','o','m','m','a','n','d','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','O','p','t','i','o','n','s',' ','m','a','y',' ','b','e',' ','g','i','v','e','n',' ','i','n',' ','o','n','e',' ','o','f',' ','t','w','o',' ','f','o','r','m','s',':',' ','e','i','t','h','e','r',' ','a',' ','s','i','n','g','l','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','c','h','a','r','a','c','t','e','r',' ','p','r','e','c','e','d','e','d',' ','b','y',' ','a',' ','-',',',' ','o','r',' ','a',' ','n','a','m','e',' ','p','r','e','c','e','e','d','e','d',' ','b','y',' ','-','-','.','\n',
+'\n',
+' ',' ','-','?',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','e','l','p','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','h','e','l','p',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n',
+' ',' ','-','a',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','e','a','r','c','h','-','s','k','i','p','-','s','c','r','e','e','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','s','k','i','p','s',' ','c','u','r','r','e','n','t',' ','s','c','r','e','e','n','.','\n',
+' ',' ','-','A',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','S','E','A','R','C','H','-','S','K','I','P','-','S','C','R','E','E','N','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','a','l','w','a','y','s',' ','s','k','i','p','s',' ','t','a','r','g','e','t',' ','l','i','n','e','.','\n',
+' ',' ','-','b',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','b','u','f','f','e','r','s','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','N','u','m','b','e','r',' ','o','f',' ','b','u','f','f','e','r','s','.','\n',
+' ',' ','-','B',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','a','u','t','o','-','b','u','f','f','e','r','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','a','u','t','o','m','a','t','i','c','a','l','l','y',' ','a','l','l','o','c','a','t','e',' ','b','u','f','f','e','r','s',' ','f','o','r',' ','p','i','p','e','s','.','\n',
+' ',' ','-','c',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','c','l','e','a','r','-','s','c','r','e','e','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','R','e','p','a','i','n','t',' ','b','y',' ','c','l','e','a','r','i','n','g',' ','r','a','t','h','e','r',' ','t','h','a','n',' ','s','c','r','o','l','l','i','n','g','.','\n',
+' ',' ','-','d',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','d','u','m','b','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','u','m','b',' ','t','e','r','m','i','n','a','l','.','\n',
+' ',' ','-','D',' ','[','_','\b','x','_','\b','n','_','\b','.','_','\b','n',']',' ',' ','.',' ',' ','-','-','c','o','l','o','r','=','_','\b','x','_','\b','n','_','\b','.','_','\b','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','s','c','r','e','e','n',' ','c','o','l','o','r','s','.',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')','\n',
+' ',' ','-','e',' ',' ','-','E',' ',' ','.','.','.','.',' ',' ','-','-','q','u','i','t','-','a','t','-','e','o','f',' ',' ','-','-','Q','U','I','T','-','A','T','-','E','O','F','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','t',' ','a','t',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n',
+' ',' ','-','f',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','r','c','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','c','e',' ','o','p','e','n',' ','n','o','n','-','r','e','g','u','l','a','r',' ','f','i','l','e','s','.','\n',
+' ',' ','-','F',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','q','u','i','t','-','i','f','-','o','n','e','-','s','c','r','e','e','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','t',' ','i','f',' ','e','n','t','i','r','e',' ','f','i','l','e',' ','f','i','t','s',' ','o','n',' ','f','i','r','s','t',' ','s','c','r','e','e','n','.','\n',
+' ',' ','-','g',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','i','l','i','t','e','-','s','e','a','r','c','h','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','o','n','l','y',' ','l','a','s','t',' ','m','a','t','c','h',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n',
+' ',' ','-','G',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','H','I','L','I','T','E','-','S','E','A','R','C','H','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','h','i','g','h','l','i','g','h','t',' ','a','n','y',' ','m','a','t','c','h','e','s',' ','f','o','r',' ','s','e','a','r','c','h','e','s','.','\n',
+' ',' ','-','h',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','m','a','x','-','b','a','c','k','-','s','c','r','o','l','l','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','B','a','c','k','w','a','r','d',' ','s','c','r','o','l','l',' ','l','i','m','i','t','.','\n',
+' ',' ','-','i',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','i','g','n','o','r','e','-','c','a','s','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','c','a','s','e',' ','i','n',' ','s','e','a','r','c','h','e','s',' ','t','h','a','t',' ','d','o',' ','n','o','t',' ','c','o','n','t','a','i','n',' ','u','p','p','e','r','c','a','s','e','.','\n',
+' ',' ','-','I',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','I','G','N','O','R','E','-','C','A','S','E','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','c','a','s','e',' ','i','n',' ','a','l','l',' ','s','e','a','r','c','h','e','s','.','\n',
+' ',' ','-','j',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','j','u','m','p','-','t','a','r','g','e','t','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','c','r','e','e','n',' ','p','o','s','i','t','i','o','n',' ','o','f',' ','t','a','r','g','e','t',' ','l','i','n','e','s','.','\n',
+' ',' ','-','J',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','t','a','t','u','s','-','c','o','l','u','m','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','a',' ','s','t','a','t','u','s',' ','c','o','l','u','m','n',' ','a','t',' ','l','e','f','t',' ','e','d','g','e',' ','o','f',' ','s','c','r','e','e','n','.','\n',
+' ',' ','-','k',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','e','s','s','k','e','y','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a',' ','l','e','s','s','k','e','y',' ','f','i','l','e','.','\n',
+' ',' ','-','K',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','q','u','i','t','-','o','n','-','i','n','t','r','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','i','t',' ','l','e','s','s',' ','i','n',' ','r','e','s','p','o','n','s','e',' ','t','o',' ','c','t','r','l','-','C','.','\n',
+' ',' ','-','L',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','l','e','s','s','o','p','e','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','t','h','e',' ','L','E','S','S','O','P','E','N',' ','e','n','v','i','r','o','n','m','e','n','t',' ','v','a','r','i','a','b','l','e','.','\n',
+' ',' ','-','m',' ',' ','-','M',' ',' ','.','.','.','.',' ',' ','-','-','l','o','n','g','-','p','r','o','m','p','t',' ',' ','-','-','L','O','N','G','-','P','R','O','M','P','T','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','p','r','o','m','p','t',' ','s','t','y','l','e','.','\n',
+' ',' ','-','n',' ',' ','-','N',' ',' ','.','.','.','.',' ',' ','-','-','l','i','n','e','-','n','u','m','b','e','r','s',' ',' ','-','-','L','I','N','E','-','N','U','M','B','E','R','S','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','l','i','n','e',' ','n','u','m','b','e','r','s','.','\n',
+' ',' ','-','o',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','o','g','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','s','t','a','n','d','a','r','d',' ','i','n','p','u','t',' ','o','n','l','y',')','.','\n',
+' ',' ','-','O',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','L','O','G','-','F','I','L','E','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','p','y',' ','t','o',' ','l','o','g',' ','f','i','l','e',' ','(','u','n','c','o','n','d','i','t','i','o','n','a','l','l','y',' ','o','v','e','r','w','r','i','t','e',')','.','\n',
+' ',' ','-','p',' ','[','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',']',' ',' ','-','-','p','a','t','t','e','r','n','=','[','_','\b','p','_','\b','a','_','\b','t','_','\b','t','_','\b','e','_','\b','r','_','\b','n',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','t','a','r','t',' ','a','t',' ','p','a','t','t','e','r','n',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n',
+' ',' ','-','P',' ','[','_','\b','p','_','\b','r','_','\b','o','_','\b','m','_','\b','p','_','\b','t',']',' ',' ',' ','-','-','p','r','o','m','p','t','=','[','_','\b','p','_','\b','r','_','\b','o','_','\b','m','_','\b','p','_','\b','t',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','f','i','n','e',' ','n','e','w',' ','p','r','o','m','p','t','.','\n',
+' ',' ','-','q',' ',' ','-','Q',' ',' ','.','.','.','.',' ',' ','-','-','q','u','i','e','t',' ',' ','-','-','Q','U','I','E','T',' ',' ','-','-','s','i','l','e','n','t',' ','-','-','S','I','L','E','N','T','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Q','u','i','e','t',' ','t','h','e',' ','t','e','r','m','i','n','a','l',' ','b','e','l','l','.','\n',
+' ',' ','-','r',' ',' ','-','R',' ',' ','.','.','.','.',' ',' ','-','-','r','a','w','-','c','o','n','t','r','o','l','-','c','h','a','r','s',' ',' ','-','-','R','A','W','-','C','O','N','T','R','O','L','-','C','H','A','R','S','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','O','u','t','p','u','t',' ','"','r','a','w','"',' ','c','o','n','t','r','o','l',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ','-','s',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','q','u','e','e','z','e','-','b','l','a','n','k','-','l','i','n','e','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','q','u','e','e','z','e',' ','m','u','l','t','i','p','l','e',' ','b','l','a','n','k',' ','l','i','n','e','s','.','\n',
+' ',' ','-','S',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','c','h','o','p','-','l','o','n','g','-','l','i','n','e','s','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','o','p',' ','l','o','n','g',' ','l','i','n','e','s','.','\n',
+' ',' ','-','t',' ','[','_','\b','t','_','\b','a','_','\b','g',']',' ',' ','.','.',' ',' ','-','-','t','a','g','=','[','_','\b','t','_','\b','a','_','\b','g',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','i','n','d',' ','a',' ','t','a','g','.','\n',
+' ',' ','-','T',' ','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ','-','-','t','a','g','-','f','i','l','e','=','[','_','\b','t','_','\b','a','_','\b','g','_','\b','s','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a','n',' ','a','l','t','e','r','n','a','t','e',' ','t','a','g','s',' ','f','i','l','e','.','\n',
+' ',' ','-','u',' ',' ','-','U',' ',' ','.','.','.','.',' ',' ','-','-','u','n','d','e','r','l','i','n','e','-','s','p','e','c','i','a','l',' ',' ','-','-','U','N','D','E','R','L','I','N','E','-','S','P','E','C','I','A','L','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','h','a','n','g','e',' ','h','a','n','d','l','i','n','g',' ','o','f',' ','b','a','c','k','s','p','a','c','e','s','.','\n',
+' ',' ','-','V',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','v','e','r','s','i','o','n','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','t','h','e',' ','v','e','r','s','i','o','n',' ','n','u','m','b','e','r',' ','o','f',' ','"','l','e','s','s','"','.','\n',
+' ',' ','-','w',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','h','i','l','i','t','e','-','u','n','r','e','a','d','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','f','i','r','s','t',' ','n','e','w',' ','l','i','n','e',' ','a','f','t','e','r',' ','f','o','r','w','a','r','d','-','s','c','r','e','e','n','.','\n',
+' ',' ','-','W',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','H','I','L','I','T','E','-','U','N','R','E','A','D','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','i','g','h','l','i','g','h','t',' ','f','i','r','s','t',' ','n','e','w',' ','l','i','n','e',' ','a','f','t','e','r',' ','a','n','y',' ','f','o','r','w','a','r','d',' ','m','o','v','e','m','e','n','t','.','\n',
+' ',' ','-','x',' ','[','_','\b','N','[',',','.','.','.',']',']',' ',' ','-','-','t','a','b','s','=','[','_','\b','N','[',',','.','.','.',']',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','t','a','b',' ','s','t','o','p','s','.','\n',
+' ',' ','-','X',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','i','n','i','t','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','t','e','r','m','c','a','p',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','u','s','e',' ','t','e','r','m','c','a','p',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','t','r','i','n','g','s','.','\n',
+' ',' ','-','y',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','m','a','x','-','f','o','r','w','-','s','c','r','o','l','l','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','c','r','o','l','l',' ','l','i','m','i','t','.','\n',
+' ',' ','-','z',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','w','i','n','d','o','w','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','s','i','z','e',' ','o','f',' ','w','i','n','d','o','w','.','\n',
+' ',' ','-','"',' ','[','_','\b','c','[','_','\b','c',']',']',' ',' ','.',' ',' ','-','-','q','u','o','t','e','s','=','[','_','\b','c','[','_','\b','c',']',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','e','t',' ','s','h','e','l','l',' ','q','u','o','t','e',' ','c','h','a','r','a','c','t','e','r','s','.','\n',
+' ',' ','-','~',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','t','i','l','d','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','d','i','s','p','l','a','y',' ','t','i','l','d','e','s',' ','a','f','t','e','r',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n',
+' ',' ','-','#',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','s','h','i','f','t','=','[','_','\b','N',']','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','o','r','i','z','o','n','t','a','l',' ','s','c','r','o','l','l',' ','a','m','o','u','n','t',' ','(','0',' ','=',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',')','\n',
+' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','n','d',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','e','q','u','e','n','c','e','.','\n',
+' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','l','l','o','w','-','n','a','m','e','\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','h','e',' ','F',' ','c','o','m','m','a','n','d',' ','c','h','a','n','g','e','s',' ','f','i','l','e','s',' ','i','f',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e',' ','i','s',' ','r','e','n','a','m','e','d','.','\n',
+'\n',
+'\n',
+' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','L','\b','L','I','\b','I','N','\b','N','E','\b','E',' ','E','\b','E','D','\b','D','I','\b','I','T','\b','T','I','\b','I','N','\b','N','G','\b','G','\n',
+'\n',
+' ',' ',' ',' ',' ',' ',' ',' ','T','h','e','s','e',' ','k','e','y','s',' ','c','a','n',' ','b','e',' ','u','s','e','d',' ','t','o',' ','e','d','i','t',' ','t','e','x','t',' ','b','e','i','n','g',' ','e','n','t','e','r','e','d',' ','\n',
+' ',' ',' ',' ',' ',' ',' ',' ','o','n',' ','t','h','e',' ','"','c','o','m','m','a','n','d',' ','l','i','n','e','"',' ','a','t',' ','t','h','e',' ','b','o','t','t','o','m',' ','o','f',' ','t','h','e',' ','s','c','r','e','e','n','.','\n',
+'\n',
+' ','R','i','g','h','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','l',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
+' ','L','e','f','t','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','h',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','c','h','a','r','a','c','t','e','r','.','\n',
+' ','C','N','T','L','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','R','i','g','h','t','A','r','r','o','w',' ',' ','E','S','C','-','w',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','r','i','g','h','t',' ','o','n','e',' ','w','o','r','d','.','\n',
+' ','C','N','T','L','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','L','e','f','t','A','r','r','o','w',' ',' ',' ','E','S','C','-','b',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','l','e','f','t',' ','o','n','e',' ','w','o','r','d','.','\n',
+' ','H','O','M','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','0',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','s','t','a','r','t',' ','o','f',' ','l','i','n','e','.','\n',
+' ','E','N','D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','$',' ',' ',' ',' ',' ','M','o','v','e',' ','c','u','r','s','o','r',' ','t','o',' ','e','n','d',' ','o','f',' ','l','i','n','e','.','\n',
+' ','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
+' ','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','x',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','c','h','a','r',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
+' ','C','N','T','L','-','B','A','C','K','S','P','A','C','E',' ',' ',' ','E','S','C','-','B','A','C','K','S','P','A','C','E',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','t','o',' ','l','e','f','t',' ','o','f',' ','c','u','r','s','o','r','.','\n',
+' ','C','N','T','L','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','D','E','L','E','T','E',' ',' ',' ',' ',' ',' ','E','S','C','-','X',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','w','o','r','d',' ','u','n','d','e','r',' ','c','u','r','s','o','r','.','\n',
+' ','C','N','T','L','-','U',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C',' ','(','M','S','-','D','O','S',' ','o','n','l','y',')',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','e','l','e','t','e',' ','e','n','t','i','r','e',' ','l','i','n','e','.','\n',
+' ','U','p','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','k',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','p','r','e','v','i','o','u','s',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ','D','o','w','n','A','r','r','o','w',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','j',' ',' ',' ',' ',' ','R','e','t','r','i','e','v','e',' ','n','e','x','t',' ','c','o','m','m','a','n','d',' ','l','i','n','e','.','\n',
+' ','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','c','y','c','l','e','.','\n',
+' ','S','H','I','F','T','-','T','A','B',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','S','C','-','T','A','B',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',' ','&',' ','r','e','v','e','r','s','e',' ','c','y','c','l','e','.','\n',
+' ','C','N','T','L','-','L',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','C','o','m','p','l','e','t','e',' ','f','i','l','e','n','a','m','e',',',' ','l','i','s','t',' ','a','l','l','.','\n',
+'\n',
+'\n',
+ 0 };
+constant int size_helpdata = sizeof(helpdata) - 1;
diff --git a/thirdparty/less/ifile.c b/thirdparty/less/ifile.c
new file mode 100644 (file)
index 0000000..971e3b5
--- /dev/null
@@ -0,0 +1,346 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * An IFILE represents an input file.
+ *
+ * It is actually a pointer to an ifile structure,
+ * but is opaque outside this module.
+ * Ifile structures are kept in a linked list in the order they 
+ * appear on the command line.
+ * Any new file which does not already appear in the list is
+ * inserted after the current file.
+ */
+
+#include "less.h"
+
+extern IFILE   curr_ifile;
+
+struct ifile {
+       struct ifile *h_next;           /* Links for command line list */
+       struct ifile *h_prev;
+       char *h_filename;               /* Name of the file */
+       void *h_filestate;              /* File state (used in ch.c) */
+       int h_index;                    /* Index within command line list */
+       int h_hold;                     /* Hold count */
+       char h_opened;                  /* Has this ifile been opened? */
+       struct scrpos h_scrpos;         /* Saved position within the file */
+};
+
+/*
+ * Convert an IFILE (external representation)
+ * to a struct file (internal representation), and vice versa.
+ */
+#define int_ifile(h)   ((struct ifile *)(h))
+#define ext_ifile(h)   ((IFILE)(h))
+
+/*
+ * Anchor for linked list.
+ */
+static struct ifile anchor = { &anchor, &anchor, NULL, NULL, 0, 0, '\0',
+                               { NULL_POSITION, 0 } };
+static int ifiles = 0;
+
+       static void
+incr_index(p, incr)
+       register struct ifile *p;
+       int incr;
+{
+       for (;  p != &anchor;  p = p->h_next)
+               p->h_index += incr;
+}
+
+/*
+ * Link an ifile into the ifile list.
+ */
+       static void
+link_ifile(p, prev)
+       struct ifile *p;
+       struct ifile *prev;
+{
+       /*
+        * Link into list.
+        */
+       if (prev == NULL)
+               prev = &anchor;
+       p->h_next = prev->h_next;
+       p->h_prev = prev;
+       prev->h_next->h_prev = p;
+       prev->h_next = p;
+       /*
+        * Calculate index for the new one,
+        * and adjust the indexes for subsequent ifiles in the list.
+        */
+       p->h_index = prev->h_index + 1;
+       incr_index(p->h_next, 1);
+       ifiles++;
+}
+       
+/*
+ * Unlink an ifile from the ifile list.
+ */
+       static void
+unlink_ifile(p)
+       struct ifile *p;
+{
+       p->h_next->h_prev = p->h_prev;
+       p->h_prev->h_next = p->h_next;
+       incr_index(p->h_next, -1);
+       ifiles--;
+}
+
+/*
+ * Allocate a new ifile structure and stick a filename in it.
+ * It should go after "prev" in the list
+ * (or at the beginning of the list if "prev" is NULL).
+ * Return a pointer to the new ifile structure.
+ */
+       static struct ifile *
+new_ifile(filename, prev)
+       char *filename;
+       struct ifile *prev;
+{
+       register struct ifile *p;
+
+       /*
+        * Allocate and initialize structure.
+        */
+       p = (struct ifile *) ecalloc(1, sizeof(struct ifile));
+       p->h_filename = save(filename);
+       p->h_scrpos.pos = NULL_POSITION;
+       p->h_opened = 0;
+       p->h_hold = 0;
+       p->h_filestate = NULL;
+       link_ifile(p, prev);
+       return (p);
+}
+
+/*
+ * Delete an existing ifile structure.
+ */
+       public void
+del_ifile(h)
+       IFILE h;
+{
+       register struct ifile *p;
+
+       if (h == NULL_IFILE)
+               return;
+       /*
+        * If the ifile we're deleting is the currently open ifile,
+        * move off it.
+        */
+       unmark(h);
+       if (h == curr_ifile)
+               curr_ifile = getoff_ifile(curr_ifile);
+       p = int_ifile(h);
+       unlink_ifile(p);
+       free(p->h_filename);
+       free(p);
+}
+
+/*
+ * Get the ifile after a given one in the list.
+ */
+       public IFILE
+next_ifile(h)
+       IFILE h;
+{
+       register struct ifile *p;
+
+       p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
+       if (p->h_next == &anchor)
+               return (NULL_IFILE);
+       return (ext_ifile(p->h_next));
+}
+
+/*
+ * Get the ifile before a given one in the list.
+ */
+       public IFILE
+prev_ifile(h)
+       IFILE h;
+{
+       register struct ifile *p;
+
+       p = (h == NULL_IFILE) ? &anchor : int_ifile(h);
+       if (p->h_prev == &anchor)
+               return (NULL_IFILE);
+       return (ext_ifile(p->h_prev));
+}
+
+/*
+ * Return a different ifile from the given one.
+ */
+       public IFILE
+getoff_ifile(ifile)
+       IFILE ifile;
+{
+       IFILE newifile;
+       
+       if ((newifile = prev_ifile(ifile)) != NULL_IFILE)
+               return (newifile);
+       if ((newifile = next_ifile(ifile)) != NULL_IFILE)
+               return (newifile);
+       return (NULL_IFILE);
+}
+
+/*
+ * Return the number of ifiles.
+ */
+       public int
+nifile()
+{
+       return (ifiles);
+}
+
+/*
+ * Find an ifile structure, given a filename.
+ */
+       static struct ifile *
+find_ifile(filename)
+       char *filename;
+{
+       register struct ifile *p;
+
+       for (p = anchor.h_next;  p != &anchor;  p = p->h_next)
+               if (strcmp(filename, p->h_filename) == 0)
+                       return (p);
+       return (NULL);
+}
+
+/*
+ * Get the ifile associated with a filename.
+ * If the filename has not been seen before,
+ * insert the new ifile after "prev" in the list.
+ */
+       public IFILE
+get_ifile(filename, prev)
+       char *filename;
+       IFILE prev;
+{
+       register struct ifile *p;
+
+       if ((p = find_ifile(filename)) == NULL)
+               p = new_ifile(filename, int_ifile(prev));
+       return (ext_ifile(p));
+}
+
+/*
+ * Get the filename associated with a ifile.
+ */
+       public char *
+get_filename(ifile)
+       IFILE ifile;
+{
+       if (ifile == NULL)
+               return (NULL);
+       return (int_ifile(ifile)->h_filename);
+}
+
+/*
+ * Get the index of the file associated with a ifile.
+ */
+       public int
+get_index(ifile)
+       IFILE ifile;
+{
+       return (int_ifile(ifile)->h_index); 
+}
+
+/*
+ * Save the file position to be associated with a given file.
+ */
+       public void
+store_pos(ifile, scrpos)
+       IFILE ifile;
+       struct scrpos *scrpos;
+{
+       int_ifile(ifile)->h_scrpos = *scrpos;
+}
+
+/*
+ * Recall the file position associated with a file.
+ * If no position has been associated with the file, return NULL_POSITION.
+ */
+       public void
+get_pos(ifile, scrpos)
+       IFILE ifile;
+       struct scrpos *scrpos;
+{
+       *scrpos = int_ifile(ifile)->h_scrpos;
+}
+
+/*
+ * Mark the ifile as "opened".
+ */
+       public void
+set_open(ifile)
+       IFILE ifile;
+{
+       int_ifile(ifile)->h_opened = 1;
+}
+
+/*
+ * Return whether the ifile has been opened previously.
+ */
+       public int
+opened(ifile)
+       IFILE ifile;
+{
+       return (int_ifile(ifile)->h_opened);
+}
+
+       public void
+hold_ifile(ifile, incr)
+       IFILE ifile;
+       int incr;
+{
+       int_ifile(ifile)->h_hold += incr;
+}
+
+       public int
+held_ifile(ifile)
+       IFILE ifile;
+{
+       return (int_ifile(ifile)->h_hold);
+}
+
+       public void *
+get_filestate(ifile)
+       IFILE ifile;
+{
+       return (int_ifile(ifile)->h_filestate);
+}
+
+       public void
+set_filestate(ifile, filestate)
+       IFILE ifile;
+       void *filestate;
+{
+       int_ifile(ifile)->h_filestate = filestate;
+}
+
+#if 0
+       public void
+if_dump()
+{
+       register struct ifile *p;
+
+       for (p = anchor.h_next;  p != &anchor;  p = p->h_next)
+       {
+               printf("%x: %d. <%s> pos %d,%x\n", 
+                       p, p->h_index, p->h_filename, 
+                       p->h_scrpos.ln, p->h_scrpos.pos);
+               ch_dump(p->h_filestate);
+       }
+}
+#endif
diff --git a/thirdparty/less/input.c b/thirdparty/less/input.c
new file mode 100644 (file)
index 0000000..b82868b
--- /dev/null
@@ -0,0 +1,458 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * High level routines dealing with getting lines of input 
+ * from the file being viewed.
+ *
+ * When we speak of "lines" here, we mean PRINTABLE lines;
+ * lines processed with respect to the screen width.
+ * We use the term "raw line" to refer to lines simply
+ * delimited by newlines; not processed with respect to screen width.
+ */
+
+#include "less.h"
+
+extern int squeeze;
+extern int chopline;
+extern int hshift;
+extern int quit_if_one_screen;
+extern int sigs;
+extern int ignore_eoi;
+extern int status_col;
+extern POSITION start_attnpos;
+extern POSITION end_attnpos;
+#if HILITE_SEARCH
+extern int hilite_search;
+extern int size_linebuf;
+#endif
+
+/*
+ * Get the next line.
+ * A "current" position is passed and a "new" position is returned.
+ * The current position is the position of the first character of
+ * a line.  The new position is the position of the first character
+ * of the NEXT line.  The line obtained is the line starting at curr_pos.
+ */
+       public POSITION
+forw_line(curr_pos)
+       POSITION curr_pos;
+{
+       POSITION base_pos;
+       POSITION new_pos;
+       register int c;
+       int blankline;
+       int endline;
+       int backchars;
+
+get_forw_line:
+       if (curr_pos == NULL_POSITION)
+       {
+               null_line();
+               return (NULL_POSITION);
+       }
+#if HILITE_SEARCH
+       if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
+               /*
+                * If we are ignoring EOI (command F), only prepare
+                * one line ahead, to avoid getting stuck waiting for
+                * slow data without displaying the data we already have.
+                * If we're not ignoring EOI, we *could* do the same, but
+                * for efficiency we prepare several lines ahead at once.
+                */
+               prep_hilite(curr_pos, curr_pos + 3*size_linebuf, 
+                               ignore_eoi ? 1 : -1);
+#endif
+       if (ch_seek(curr_pos))
+       {
+               null_line();
+               return (NULL_POSITION);
+       }
+
+       /*
+        * Step back to the beginning of the line.
+        */
+       base_pos = curr_pos;
+       for (;;)
+       {
+               if (ABORT_SIGS())
+               {
+                       null_line();
+                       return (NULL_POSITION);
+               }
+               c = ch_back_get();
+               if (c == EOI)
+                       break;
+               if (c == '\n')
+               {
+                       (void) ch_forw_get();
+                       break;
+               }
+               --base_pos;
+       }
+
+       /*
+        * Read forward again to the position we should start at.
+        */
+       prewind();
+       plinenum(base_pos);
+       (void) ch_seek(base_pos);
+       new_pos = base_pos;
+       while (new_pos < curr_pos)
+       {
+               if (ABORT_SIGS())
+               {
+                       null_line();
+                       return (NULL_POSITION);
+               }
+               c = ch_forw_get();
+               backchars = pappend(c, new_pos);
+               new_pos++;
+               if (backchars > 0)
+               {
+                       pshift_all();
+                       new_pos -= backchars;
+                       while (--backchars >= 0)
+                               (void) ch_back_get();
+               }
+       }
+       (void) pflushmbc();
+       pshift_all();
+
+       /*
+        * Read the first character to display.
+        */
+       c = ch_forw_get();
+       if (c == EOI)
+       {
+               null_line();
+               return (NULL_POSITION);
+       }
+       blankline = (c == '\n' || c == '\r');
+
+       /*
+        * Read each character in the line and append to the line buffer.
+        */
+       for (;;)
+       {
+               if (ABORT_SIGS())
+               {
+                       null_line();
+                       return (NULL_POSITION);
+               }
+               if (c == '\n' || c == EOI)
+               {
+                       /*
+                        * End of the line.
+                        */
+                       backchars = pflushmbc();
+                       new_pos = ch_tell();
+                       if (backchars > 0 && !chopline && hshift == 0)
+                       {
+                               new_pos -= backchars + 1;
+                               endline = FALSE;
+                       } else
+                               endline = TRUE;
+                       break;
+               }
+               if (c != '\r')
+                       blankline = 0;
+
+               /*
+                * Append the char to the line and get the next char.
+                */
+               backchars = pappend(c, ch_tell()-1);
+               if (backchars > 0)
+               {
+                       /*
+                        * The char won't fit in the line; the line
+                        * is too long to print in the screen width.
+                        * End the line here.
+                        */
+                       if (chopline || hshift > 0)
+                       {
+                               do
+                               {
+                                       if (ABORT_SIGS())
+                                       {
+                                               null_line();
+                                               return (NULL_POSITION);
+                                       }
+                                       c = ch_forw_get();
+                               } while (c != '\n' && c != EOI);
+                               new_pos = ch_tell();
+                               endline = TRUE;
+                               quit_if_one_screen = FALSE;
+                       } else
+                       {
+                               new_pos = ch_tell() - backchars;
+                               endline = FALSE;
+                       }
+                       break;
+               }
+               c = ch_forw_get();
+       }
+
+       pdone(endline, 1);
+
+#if HILITE_SEARCH
+       if (is_filtered(base_pos))
+       {
+               /*
+                * We don't want to display this line.
+                * Get the next line.
+                */
+               curr_pos = new_pos;
+               goto get_forw_line;
+       }
+
+       if (status_col && is_hilited(base_pos, ch_tell()-1, 1, NULL))
+               set_status_col('*');
+#endif
+
+       if (squeeze && blankline)
+       {
+               /*
+                * This line is blank.
+                * Skip down to the last contiguous blank line
+                * and pretend it is the one which we are returning.
+                */
+               while ((c = ch_forw_get()) == '\n' || c == '\r')
+                       if (ABORT_SIGS())
+                       {
+                               null_line();
+                               return (NULL_POSITION);
+                       }
+               if (c != EOI)
+                       (void) ch_back_get();
+               new_pos = ch_tell();
+       }
+
+       return (new_pos);
+}
+
+/*
+ * Get the previous line.
+ * A "current" position is passed and a "new" position is returned.
+ * The current position is the position of the first character of
+ * a line.  The new position is the position of the first character
+ * of the PREVIOUS line.  The line obtained is the one starting at new_pos.
+ */
+       public POSITION
+back_line(curr_pos)
+       POSITION curr_pos;
+{
+       POSITION new_pos, begin_new_pos, base_pos;
+       int c;
+       int endline;
+       int backchars;
+
+get_back_line:
+       if (curr_pos == NULL_POSITION || curr_pos <= ch_zero())
+       {
+               null_line();
+               return (NULL_POSITION);
+       }
+#if HILITE_SEARCH
+       if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
+               prep_hilite((curr_pos < 3*size_linebuf) ? 
+                               0 : curr_pos - 3*size_linebuf, curr_pos, -1);
+#endif
+       if (ch_seek(curr_pos-1))
+       {
+               null_line();
+               return (NULL_POSITION);
+       }
+
+       if (squeeze)
+       {
+               /*
+                * Find out if the "current" line was blank.
+                */
+               (void) ch_forw_get();    /* Skip the newline */
+               c = ch_forw_get();       /* First char of "current" line */
+               (void) ch_back_get();    /* Restore our position */
+               (void) ch_back_get();
+
+               if (c == '\n' || c == '\r')
+               {
+                       /*
+                        * The "current" line was blank.
+                        * Skip over any preceding blank lines,
+                        * since we skipped them in forw_line().
+                        */
+                       while ((c = ch_back_get()) == '\n' || c == '\r')
+                               if (ABORT_SIGS())
+                               {
+                                       null_line();
+                                       return (NULL_POSITION);
+                               }
+                       if (c == EOI)
+                       {
+                               null_line();
+                               return (NULL_POSITION);
+                       }
+                       (void) ch_forw_get();
+               }
+       }
+
+       /*
+        * Scan backwards until we hit the beginning of the line.
+        */
+       for (;;)
+       {
+               if (ABORT_SIGS())
+               {
+                       null_line();
+                       return (NULL_POSITION);
+               }
+               c = ch_back_get();
+               if (c == '\n')
+               {
+                       /*
+                        * This is the newline ending the previous line.
+                        * We have hit the beginning of the line.
+                        */
+                       base_pos = ch_tell() + 1;
+                       break;
+               }
+               if (c == EOI)
+               {
+                       /*
+                        * We have hit the beginning of the file.
+                        * This must be the first line in the file.
+                        * This must, of course, be the beginning of the line.
+                        */
+                       base_pos = ch_tell();
+                       break;
+               }
+       }
+
+       /*
+        * Now scan forwards from the beginning of this line.
+        * We keep discarding "printable lines" (based on screen width)
+        * until we reach the curr_pos.
+        *
+        * {{ This algorithm is pretty inefficient if the lines
+        *    are much longer than the screen width, 
+        *    but I don't know of any better way. }}
+        */
+       new_pos = base_pos;
+       if (ch_seek(new_pos))
+       {
+               null_line();
+               return (NULL_POSITION);
+       }
+       endline = FALSE;
+       prewind();
+       plinenum(new_pos);
+    loop:
+       begin_new_pos = new_pos;
+       (void) ch_seek(new_pos);
+
+       do
+       {
+               c = ch_forw_get();
+               if (c == EOI || ABORT_SIGS())
+               {
+                       null_line();
+                       return (NULL_POSITION);
+               }
+               new_pos++;
+               if (c == '\n')
+               {
+                       backchars = pflushmbc();
+                       if (backchars > 0 && !chopline && hshift == 0)
+                       {
+                               backchars++;
+                               goto shift;
+                       }
+                       endline = TRUE;
+                       break;
+               }
+               backchars = pappend(c, ch_tell()-1);
+               if (backchars > 0)
+               {
+                       /*
+                        * Got a full printable line, but we haven't
+                        * reached our curr_pos yet.  Discard the line
+                        * and start a new one.
+                        */
+                       if (chopline || hshift > 0)
+                       {
+                               endline = TRUE;
+                               quit_if_one_screen = FALSE;
+                               break;
+                       }
+               shift:
+                       pshift_all();
+                       while (backchars-- > 0)
+                       {
+                               (void) ch_back_get();
+                               new_pos--;
+                       }
+                       goto loop;
+               }
+       } while (new_pos < curr_pos);
+
+       pdone(endline, 0);
+
+#if HILITE_SEARCH
+       if (is_filtered(base_pos))
+       {
+               /*
+                * We don't want to display this line.
+                * Get the previous line.
+                */
+               curr_pos = begin_new_pos;
+               goto get_back_line;
+       }
+
+       if (status_col && is_hilited(base_pos, ch_tell()-1, 1, NULL))
+               set_status_col('*');
+#endif
+
+       return (begin_new_pos);
+}
+
+/*
+ * Set attnpos.
+ */
+       public void
+set_attnpos(pos)
+       POSITION pos;
+{
+       int c;
+
+       if (pos != NULL_POSITION)
+       {
+               if (ch_seek(pos))
+                       return;
+               for (;;)
+               {
+                       c = ch_forw_get();
+                       if (c == EOI)
+                               return;
+                       if (c != '\n' && c != '\r')
+                               break;
+                       pos++;
+               }
+       }
+       start_attnpos = pos;
+       for (;;)
+       {
+               c = ch_forw_get();
+               pos++;
+               if (c == EOI || c == '\n' || c == '\r')
+                       break;
+       }
+       end_attnpos = pos;
+}
diff --git a/thirdparty/less/jump.c b/thirdparty/less/jump.c
new file mode 100644 (file)
index 0000000..d7ec770
--- /dev/null
@@ -0,0 +1,309 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines which jump to a new location in the file.
+ */
+
+#include "less.h"
+#include "position.h"
+
+extern int jump_sline;
+extern int squished;
+extern int screen_trashed;
+extern int sc_width, sc_height;
+extern int show_attn;
+extern int top_scroll;
+
+/*
+ * Jump to the end of the file.
+ */
+       public void
+jump_forw()
+{
+       POSITION pos;
+       POSITION end_pos;
+
+       if (ch_end_seek())
+       {
+               error("Cannot seek to end of file", NULL_PARG);
+               return;
+       }
+       /* 
+        * Note; lastmark will be called later by jump_loc, but it fails
+        * because the position table has been cleared by pos_clear below.
+        * So call it here before calling pos_clear.
+        */
+       lastmark();
+       /*
+        * Position the last line in the file at the last screen line.
+        * Go back one line from the end of the file
+        * to get to the beginning of the last line.
+        */
+       pos_clear();
+       end_pos = ch_tell();
+       pos = back_line(end_pos);
+       if (pos == NULL_POSITION)
+               jump_loc((POSITION)0, sc_height-1);
+       else
+       {
+               jump_loc(pos, sc_height-1);
+               if (position(sc_height-1) != end_pos)
+                       repaint();
+       }
+}
+
+/*
+ * Jump to line n in the file.
+ */
+       public void
+jump_back(linenum)
+       LINENUM linenum;
+{
+       POSITION pos;
+       PARG parg;
+
+       /*
+        * Find the position of the specified line.
+        * If we can seek there, just jump to it.
+        * If we can't seek, but we're trying to go to line number 1,
+        * use ch_beg_seek() to get as close as we can.
+        */
+       pos = find_pos(linenum);
+       if (pos != NULL_POSITION && ch_seek(pos) == 0)
+       {
+               if (show_attn)
+                       set_attnpos(pos);
+               jump_loc(pos, jump_sline);
+       } else if (linenum <= 1 && ch_beg_seek() == 0)
+       {
+               jump_loc(ch_tell(), jump_sline);
+               error("Cannot seek to beginning of file", NULL_PARG);
+       } else
+       {
+               parg.p_linenum = linenum;
+               error("Cannot seek to line number %n", &parg);
+       }
+}
+
+/*
+ * Repaint the screen.
+ */
+       public void
+repaint()
+{
+       struct scrpos scrpos;
+       /*
+        * Start at the line currently at the top of the screen
+        * and redisplay the screen.
+        */
+       get_scrpos(&scrpos);
+       pos_clear();
+       jump_loc(scrpos.pos, scrpos.ln);
+}
+
+/*
+ * Jump to a specified percentage into the file.
+ */
+       public void
+jump_percent(percent, fraction)
+       int percent;
+       long fraction;
+{
+       POSITION pos, len;
+
+       /*
+        * Determine the position in the file
+        * (the specified percentage of the file's length).
+        */
+       if ((len = ch_length()) == NULL_POSITION)
+       {
+               ierror("Determining length of file", NULL_PARG);
+               ch_end_seek();
+       }
+       if ((len = ch_length()) == NULL_POSITION)
+       {
+               error("Don't know length of file", NULL_PARG);
+               return;
+       }
+       pos = percent_pos(len, percent, fraction);
+       if (pos >= len)
+               pos = len-1;
+
+       jump_line_loc(pos, jump_sline);
+}
+
+/*
+ * Jump to a specified position in the file.
+ * Like jump_loc, but the position need not be 
+ * the first character in a line.
+ */
+       public void
+jump_line_loc(pos, sline)
+       POSITION pos;
+       int sline;
+{
+       int c;
+
+       if (ch_seek(pos) == 0)
+       {
+               /*
+                * Back up to the beginning of the line.
+                */
+               while ((c = ch_back_get()) != '\n' && c != EOI)
+                       ;
+               if (c == '\n')
+                       (void) ch_forw_get();
+               pos = ch_tell();
+       }
+       if (show_attn)
+               set_attnpos(pos);
+       jump_loc(pos, sline);
+}
+
+/*
+ * Jump to a specified position in the file.
+ * The position must be the first character in a line.
+ * Place the target line on a specified line on the screen.
+ */
+       public void
+jump_loc(pos, sline)
+       POSITION pos;
+       int sline;
+{
+       register int nline;
+       POSITION tpos;
+       POSITION bpos;
+
+       /*
+        * Normalize sline.
+        */
+       sline = adjsline(sline);
+
+       if ((nline = onscreen(pos)) >= 0)
+       {
+               /*
+                * The line is currently displayed.  
+                * Just scroll there.
+                */
+               nline -= sline;
+               if (nline > 0)
+                       forw(nline, position(BOTTOM_PLUS_ONE), 1, 0, 0);
+               else
+                       back(-nline, position(TOP), 1, 0);
+#if HILITE_SEARCH
+               if (show_attn)
+                       repaint_hilite(1);
+#endif
+               return;
+       }
+
+       /*
+        * Line is not on screen.
+        * Seek to the desired location.
+        */
+       if (ch_seek(pos))
+       {
+               error("Cannot seek to that file position", NULL_PARG);
+               return;
+       }
+
+       /*
+        * See if the desired line is before or after 
+        * the currently displayed screen.
+        */
+       tpos = position(TOP);
+       bpos = position(BOTTOM_PLUS_ONE);
+       if (tpos == NULL_POSITION || pos >= tpos)
+       {
+               /*
+                * The desired line is after the current screen.
+                * Move back in the file far enough so that we can
+                * call forw() and put the desired line at the 
+                * sline-th line on the screen.
+                */
+               for (nline = 0;  nline < sline;  nline++)
+               {
+                       if (bpos != NULL_POSITION && pos <= bpos)
+                       {
+                               /*
+                                * Surprise!  The desired line is
+                                * close enough to the current screen
+                                * that we can just scroll there after all.
+                                */
+                               forw(sc_height-sline+nline-1, bpos, 1, 0, 0);
+#if HILITE_SEARCH
+                               if (show_attn)
+                                       repaint_hilite(1);
+#endif
+                               return;
+                       }
+                       pos = back_line(pos);
+                       if (pos == NULL_POSITION)
+                       {
+                               /*
+                                * Oops.  Ran into the beginning of the file.
+                                * Exit the loop here and rely on forw()
+                                * below to draw the required number of
+                                * blank lines at the top of the screen.
+                                */
+                               break;
+                       }
+               }
+               lastmark();
+               squished = 0;
+               screen_trashed = 0;
+               forw(sc_height-1, pos, 1, 0, sline-nline);
+       } else
+       {
+               /*
+                * The desired line is before the current screen.
+                * Move forward in the file far enough so that we
+                * can call back() and put the desired line at the 
+                * sline-th line on the screen.
+                */
+               for (nline = sline;  nline < sc_height - 1;  nline++)
+               {
+                       pos = forw_line(pos);
+                       if (pos == NULL_POSITION)
+                       {
+                               /*
+                                * Ran into end of file.
+                                * This shouldn't normally happen, 
+                                * but may if there is some kind of read error.
+                                */
+                               break;
+                       }
+                       if (pos >= tpos)
+                       {
+                               /* 
+                                * Surprise!  The desired line is
+                                * close enough to the current screen
+                                * that we can just scroll there after all.
+                                */
+                               back(nline+1, tpos, 1, 0);
+#if HILITE_SEARCH
+                               if (show_attn)
+                                       repaint_hilite(1);
+#endif
+                               return;
+                       }
+               }
+               lastmark();
+               if (!top_scroll)
+                       clear();
+               else
+                       home();
+               screen_trashed = 0;
+               add_back_pos(pos);
+               back(sc_height-1, pos, 1, 0);
+       }
+}
diff --git a/thirdparty/less/less.h b/thirdparty/less/less.h
new file mode 100644 (file)
index 0000000..d013345
--- /dev/null
@@ -0,0 +1,504 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+#define NEWBOT 1
+
+/*
+ * Standard include file for "less".
+ */
+
+/*
+ * Defines for MSDOS_COMPILER.
+ */
+#define        MSOFTC          1       /* Microsoft C */
+#define        BORLANDC        2       /* Borland C */
+#define        WIN32C          3       /* Windows (Borland C or Microsoft C) */
+#define        DJGPPC          4       /* DJGPP C */
+
+/*
+ * Include the file of compile-time options.
+ * The <> make cc search for it in -I., not srcdir.
+ */
+#include <defines.h>
+
+#ifdef _SEQUENT_
+/*
+ * Kludge for Sequent Dynix systems that have sigsetmask, but
+ * it's not compatible with the way less calls it.
+ * {{ Do other systems need this? }}
+ */
+#undef HAVE_SIGSETMASK
+#endif
+
+/*
+ * Language details.
+ */
+#if HAVE_VOID
+#define        VOID_POINTER    void *
+#else
+#define        VOID_POINTER    char *
+#define        void  int
+#endif
+#if HAVE_CONST
+#define        constant        const
+#else
+#define        constant
+#endif
+
+#define        public          /* PUBLIC FUNCTION */
+
+/* Library function declarations */
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+
+/* OS-specific includes */
+#ifdef _OSK
+#include <modes.h>
+#include <strings.h>
+#endif
+
+#ifdef __TANDEM
+#include <floss.h>
+#endif
+
+#if MSDOS_COMPILER==WIN32C || OS2
+#include <io.h>
+#endif
+
+#if MSDOS_COMPILER==DJGPPC
+#include <io.h>
+#include <sys/exceptn.h>
+#include <conio.h>
+#include <pc.h>
+#endif
+
+#if !HAVE_STDLIB_H
+char *getenv();
+off_t lseek();
+VOID_POINTER calloc();
+void free();
+#endif
+
+/*
+ * Simple lowercase test which can be used during option processing
+ * (before options are parsed which might tell us what charset to use).
+ */
+#define ASCII_IS_UPPER(c)      ((c) >= 'A' && (c) <= 'Z')
+#define ASCII_IS_LOWER(c)      ((c) >= 'a' && (c) <= 'z')
+#define        ASCII_TO_UPPER(c)       ((c) - 'a' + 'A')
+#define        ASCII_TO_LOWER(c)       ((c) - 'A' + 'a')
+
+#undef IS_UPPER
+#undef IS_LOWER
+#undef TO_UPPER
+#undef TO_LOWER
+#undef IS_SPACE
+#undef IS_DIGIT
+
+#if HAVE_WCTYPE
+#define        IS_UPPER(c)     iswupper(c)
+#define        IS_LOWER(c)     iswlower(c)
+#define        TO_UPPER(c)     towupper(c)
+#define        TO_LOWER(c)     towlower(c)
+#else
+#if HAVE_UPPER_LOWER
+#define        IS_UPPER(c)     isupper((unsigned char) (c))
+#define        IS_LOWER(c)     islower((unsigned char) (c))
+#define        TO_UPPER(c)     toupper((unsigned char) (c))
+#define        TO_LOWER(c)     tolower((unsigned char) (c))
+#else
+#define        IS_UPPER(c)     ASCII_IS_UPPER(c)
+#define        IS_LOWER(c)     ASCII_IS_LOWER(c)
+#define        TO_UPPER(c)     ASCII_TO_UPPER(c)
+#define        TO_LOWER(c)     ASCII_TO_LOWER(c)
+#endif
+#endif
+
+#ifdef isspace
+#define IS_SPACE(c)    isspace((unsigned char)(c))
+#else
+#define IS_SPACE(c)    ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f')
+#endif
+
+#ifdef isdigit
+#define IS_DIGIT(c)    isdigit((unsigned char)(c))
+#else
+#define IS_DIGIT(c)    ((c) >= '0' && (c) <= '9')
+#endif
+
+#define IS_CSI_START(c)        (((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI))
+
+#ifndef NULL
+#define        NULL    0
+#endif
+
+#ifndef TRUE
+#define        TRUE            1
+#endif
+#ifndef FALSE
+#define        FALSE           0
+#endif
+
+#define        OPT_OFF         0
+#define        OPT_ON          1
+#define        OPT_ONPLUS      2
+
+#if !HAVE_MEMCPY
+#ifndef memcpy
+#define        memcpy(to,from,len)     bcopy((from),(to),(len))
+#endif
+#endif
+
+#if HAVE_SNPRINTF
+#define SNPRINTF1(str, size, fmt, v1)             snprintf((str), (size), (fmt), (v1))
+#define SNPRINTF2(str, size, fmt, v1, v2)         snprintf((str), (size), (fmt), (v1), (v2))
+#define SNPRINTF3(str, size, fmt, v1, v2, v3)     snprintf((str), (size), (fmt), (v1), (v2), (v3))
+#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) snprintf((str), (size), (fmt), (v1), (v2), (v3), (v4))
+#else
+/* Use unsafe sprintf if we don't have snprintf. */
+#define SNPRINTF1(str, size, fmt, v1)             sprintf((str), (fmt), (v1))
+#define SNPRINTF2(str, size, fmt, v1, v2)         sprintf((str), (fmt), (v1), (v2))
+#define SNPRINTF3(str, size, fmt, v1, v2, v3)     sprintf((str), (fmt), (v1), (v2), (v3))
+#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) sprintf((str), (fmt), (v1), (v2), (v3), (v4))
+#endif
+
+#define        BAD_LSEEK       ((off_t)-1)
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+#ifndef SEEK_END
+#define SEEK_END 2
+#endif
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
+/*
+ * Upper bound on the string length of an integer converted to string.
+ * 302 / 1000 is ceil (log10 (2.0)).  Subtract 1 for the sign bit;
+ * add 1 for integer division truncation; add 1 more for a minus sign.
+ */
+#define INT_STRLEN_BOUND(t) ((sizeof(t) * CHAR_BIT - 1) * 302 / 1000 + 1 + 1)
+
+/*
+ * Special types and constants.
+ */
+typedef unsigned long LWCHAR;
+typedef off_t          POSITION;
+typedef off_t          LINENUM;
+#define MIN_LINENUM_WIDTH  7   /* Min printing width of a line number */
+#define MAX_UTF_CHAR_LEN   6   /* Max bytes in one UTF-8 char */
+
+#define        NULL_POSITION   ((POSITION)(-1))
+
+/*
+ * Flags for open()
+ */
+#if MSDOS_COMPILER || OS2
+#define        OPEN_READ       (O_RDONLY|O_BINARY)
+#else
+#ifdef _OSK
+#define        OPEN_READ       (S_IREAD)
+#else
+#ifdef O_RDONLY
+#define        OPEN_READ       (O_RDONLY)
+#else
+#define        OPEN_READ       (0)
+#endif
+#endif
+#endif
+
+#if defined(O_WRONLY) && defined(O_APPEND)
+#define        OPEN_APPEND     (O_APPEND|O_WRONLY)
+#else
+#ifdef _OSK
+#define OPEN_APPEND    (S_IWRITE)
+#else
+#define        OPEN_APPEND     (1)
+#endif
+#endif
+
+/*
+ * Set a file descriptor to binary mode.
+ */
+#if MSDOS_COMPILER==MSOFTC
+#define        SET_BINARY(f)   _setmode(f, _O_BINARY);
+#else
+#if MSDOS_COMPILER || OS2
+#define        SET_BINARY(f)   setmode(f, O_BINARY)
+#else
+#define        SET_BINARY(f)
+#endif
+#endif
+
+/*
+ * Does the shell treat "?" as a metacharacter?
+ */
+#if MSDOS_COMPILER || OS2 || _OSK
+#define        SHELL_META_QUEST 0
+#else
+#define        SHELL_META_QUEST 1
+#endif
+
+#define        SPACES_IN_FILENAMES 1
+
+/*
+ * An IFILE represents an input file.
+ */
+#define        IFILE           VOID_POINTER
+#define        NULL_IFILE      ((IFILE)NULL)
+
+/*
+ * The structure used to represent a "screen position".
+ * This consists of a file position, and a screen line number.
+ * The meaning is that the line starting at the given file
+ * position is displayed on the ln-th line of the screen.
+ * (Screen lines before ln are empty.)
+ */
+struct scrpos
+{
+       POSITION pos;
+       int ln;
+};
+
+typedef union parg
+{
+       char *p_string;
+       int p_int;
+       LINENUM p_linenum;
+} PARG;
+
+#define        NULL_PARG       ((PARG *)NULL)
+
+struct textlist
+{
+       char *string;
+       char *endstring;
+};
+
+#define        EOI             (-1)
+
+#define        READ_INTR       (-2)
+
+/* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */
+#define NUM_FRAC_DENOM                 1000000
+#define NUM_LOG_FRAC_DENOM             6
+
+/* How quiet should we be? */
+#define        NOT_QUIET       0       /* Ring bell at eof and for errors */
+#define        LITTLE_QUIET    1       /* Ring bell only for errors */
+#define        VERY_QUIET      2       /* Never ring bell */
+
+/* How should we prompt? */
+#define        PR_SHORT        0       /* Prompt with colon */
+#define        PR_MEDIUM       1       /* Prompt with message */
+#define        PR_LONG         2       /* Prompt with longer message */
+
+/* How should we handle backspaces? */
+#define        BS_SPECIAL      0       /* Do special things for underlining and bold */
+#define        BS_NORMAL       1       /* \b treated as normal char; actually output */
+#define        BS_CONTROL      2       /* \b treated as control char; prints as ^H */
+
+/* How should we search? */
+#define        SRCH_FORW       (1 << 0)  /* Search forward from current position */
+#define        SRCH_BACK       (1 << 1)  /* Search backward from current position */
+#define SRCH_NO_MOVE    (1 << 2)  /* Highlight, but don't move */
+#define SRCH_FIND_ALL   (1 << 4)  /* Find and highlight all matches */
+#define SRCH_NO_MATCH   (1 << 8)  /* Search for non-matching lines */
+#define SRCH_PAST_EOF   (1 << 9)  /* Search past end-of-file, into next file */
+#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */
+#define SRCH_NO_REGEX   (1 << 12) /* Don't use regular expressions */
+#define SRCH_FILTER     (1 << 13) /* Search is for '&' (filter) command */
+#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */
+
+#define        SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \
+                               (((t) & ~SRCH_FORW) | SRCH_BACK) : \
+                               (((t) & ~SRCH_BACK) | SRCH_FORW))
+
+/* */
+#define        NO_MCA          0
+#define        MCA_DONE        1
+#define        MCA_MORE        2
+
+#define        CC_OK           0       /* Char was accepted & processed */
+#define        CC_QUIT         1       /* Char was a request to abort current cmd */
+#define        CC_ERROR        2       /* Char could not be accepted due to error */
+#define        CC_PASS         3       /* Char was rejected (internal) */
+
+#define CF_QUIT_ON_ERASE 0001   /* Abort cmd if its entirely erased */
+
+/* Special char bit-flags used to tell put_line() to do something special */
+#define        AT_NORMAL       (0)
+#define        AT_UNDERLINE    (1 << 0)
+#define        AT_BOLD         (1 << 1)
+#define        AT_BLINK        (1 << 2)
+#define        AT_STANDOUT     (1 << 3)
+#define        AT_ANSI         (1 << 4)  /* Content-supplied "ANSI" escape sequence */
+#define        AT_BINARY       (1 << 5)  /* LESS*BINFMT representation */
+#define        AT_HILITE       (1 << 6)  /* Internal highlights (e.g., for search) */
+
+#if '0' == 240
+#define IS_EBCDIC_HOST 1
+#endif
+
+#if IS_EBCDIC_HOST
+/*
+ * Long definition for EBCDIC.
+ * Since the argument is usually a constant, this macro normally compiles
+ * into a constant.
+ */
+#define CONTROL(c) ( \
+       (c)=='[' ? '\047' : \
+       (c)=='a' ? '\001' : \
+       (c)=='b' ? '\002' : \
+       (c)=='c' ? '\003' : \
+       (c)=='d' ? '\067' : \
+       (c)=='e' ? '\055' : \
+       (c)=='f' ? '\056' : \
+       (c)=='g' ? '\057' : \
+       (c)=='h' ? '\026' : \
+       (c)=='i' ? '\005' : \
+       (c)=='j' ? '\025' : \
+       (c)=='k' ? '\013' : \
+       (c)=='l' ? '\014' : \
+       (c)=='m' ? '\015' : \
+       (c)=='n' ? '\016' : \
+       (c)=='o' ? '\017' : \
+       (c)=='p' ? '\020' : \
+       (c)=='q' ? '\021' : \
+       (c)=='r' ? '\022' : \
+       (c)=='s' ? '\023' : \
+       (c)=='t' ? '\074' : \
+       (c)=='u' ? '\075' : \
+       (c)=='v' ? '\062' : \
+       (c)=='w' ? '\046' : \
+       (c)=='x' ? '\030' : \
+       (c)=='y' ? '\031' : \
+       (c)=='z' ? '\077' : \
+       (c)=='A' ? '\001' : \
+       (c)=='B' ? '\002' : \
+       (c)=='C' ? '\003' : \
+       (c)=='D' ? '\067' : \
+       (c)=='E' ? '\055' : \
+       (c)=='F' ? '\056' : \
+       (c)=='G' ? '\057' : \
+       (c)=='H' ? '\026' : \
+       (c)=='I' ? '\005' : \
+       (c)=='J' ? '\025' : \
+       (c)=='K' ? '\013' : \
+       (c)=='L' ? '\014' : \
+       (c)=='M' ? '\015' : \
+       (c)=='N' ? '\016' : \
+       (c)=='O' ? '\017' : \
+       (c)=='P' ? '\020' : \
+       (c)=='Q' ? '\021' : \
+       (c)=='R' ? '\022' : \
+       (c)=='S' ? '\023' : \
+       (c)=='T' ? '\074' : \
+       (c)=='U' ? '\075' : \
+       (c)=='V' ? '\062' : \
+       (c)=='W' ? '\046' : \
+       (c)=='X' ? '\030' : \
+       (c)=='Y' ? '\031' : \
+       (c)=='Z' ? '\077' : \
+       (c)=='|' ? '\031' : \
+       (c)=='\\' ? '\034' : \
+       (c)=='^' ? '\036' : \
+       (c)&077)
+#else
+#define        CONTROL(c)      ((c)&037)
+#endif /* IS_EBCDIC_HOST */
+
+#define        ESC             CONTROL('[')
+#define        CSI             ((unsigned char)'\233')
+
+#if _OSK_MWC32
+#define        LSIGNAL(sig,func)       os9_signal(sig,func)
+#else
+#define        LSIGNAL(sig,func)       signal(sig,func)
+#endif
+
+#if HAVE_SIGPROCMASK
+#if HAVE_SIGSET_T
+#else
+#undef HAVE_SIGPROCMASK
+#endif
+#endif
+#if HAVE_SIGPROCMASK
+#if HAVE_SIGEMPTYSET
+#else
+#undef  sigemptyset
+#define sigemptyset(mp) *(mp) = 0
+#endif
+#endif
+
+#define        S_INTERRUPT     01
+#define        S_STOP          02
+#define S_WINCH                04
+#define        ABORT_SIGS()    (sigs & (S_INTERRUPT|S_STOP))
+
+#define        QUIT_OK         0
+#define        QUIT_ERROR      1
+#define        QUIT_INTERRUPT  2
+#define        QUIT_SAVED_STATUS (-1)
+
+#define FOLLOW_DESC     0
+#define FOLLOW_NAME     1
+
+/* filestate flags */
+#define        CH_CANSEEK      001
+#define        CH_KEEPOPEN     002
+#define        CH_POPENED      004
+#define        CH_HELPFILE     010
+
+#define        ch_zero()       ((POSITION)0)
+
+#define        FAKE_HELPFILE   "@/\\less/\\help/\\file/\\@"
+
+/* Flags for cvt_text */
+#define        CVT_TO_LC       01      /* Convert upper-case to lower-case */
+#define        CVT_BS          02      /* Do backspace processing */
+#define        CVT_CRLF        04      /* Remove CR after LF */
+#define        CVT_ANSI        010     /* Remove ANSI escape sequences */
+
+#include "funcs.h"
+
+/* Functions not included in funcs.h */
+void postoa();
+void linenumtoa();
+void inttoa();
diff --git a/thirdparty/less/less.hlp b/thirdparty/less/less.hlp
new file mode 100644 (file)
index 0000000..84d951f
--- /dev/null
@@ -0,0 +1,231 @@
+
+                   S\bSU\bUM\bMM\bMA\bAR\bRY\bY O\bOF\bF L\bLE\bES\bSS\bS C\bCO\bOM\bMM\bMA\bAN\bND\bDS\bS
+
+      Commands marked with * may be preceded by a number, _\bN.
+      Notes in parentheses indicate the behavior if _\bN is given.
+
+  h  H                 Display this help.
+  q  :q  Q  :Q  ZZ     Exit.
+ ---------------------------------------------------------------------------
+
+                           M\bMO\bOV\bVI\bIN\bNG\bG
+
+  e  ^E  j  ^N  CR  *  Forward  one line   (or _\bN lines).
+  y  ^Y  k  ^K  ^P  *  Backward one line   (or _\bN lines).
+  f  ^F  ^V  SPACE  *  Forward  one window (or _\bN lines).
+  b  ^B  ESC-v      *  Backward one window (or _\bN lines).
+  z                 *  Forward  one window (and set window to _\bN).
+  w                 *  Backward one window (and set window to _\bN).
+  ESC-SPACE         *  Forward  one window, but don't stop at end-of-file.
+  d  ^D             *  Forward  one half-window (and set half-window to _\bN).
+  u  ^U             *  Backward one half-window (and set half-window to _\bN).
+  ESC-)  RightArrow *  Left  one half screen width (or _\bN positions).
+  ESC-(  LeftArrow  *  Right one half screen width (or _\bN positions).
+  F                    Forward forever; like "tail -f".
+  r  ^R  ^L            Repaint screen.
+  R                    Repaint screen, discarding buffered input.
+        ---------------------------------------------------
+        Default "window" is the screen height.
+        Default "half-window" is half of the screen height.
+ ---------------------------------------------------------------------------
+
+                          S\bSE\bEA\bAR\bRC\bCH\bHI\bIN\bNG\bG
+
+  /_\bp_\ba_\bt_\bt_\be_\br_\bn          *  Search forward for (_\bN-th) matching line.
+  ?_\bp_\ba_\bt_\bt_\be_\br_\bn          *  Search backward for (_\bN-th) matching line.
+  n                 *  Repeat previous search (for _\bN-th occurrence).
+  N                 *  Repeat previous search in reverse direction.
+  ESC-n             *  Repeat previous search, spanning files.
+  ESC-N             *  Repeat previous search, reverse dir. & spanning files.
+  ESC-u                Undo (toggle) search highlighting.
+  &_\bp_\ba_\bt_\bt_\be_\br_\bn          *  Display only matching lines
+        ---------------------------------------------------
+        Search patterns may be modified by one or more of:
+        ^N or !  Search for NON-matching lines.
+        ^E or *  Search multiple files (pass thru END OF FILE).
+        ^F or @  Start search at FIRST file (for /) or last file (for ?).
+        ^K       Highlight matches, but don't move (KEEP position).
+        ^R       Don't use REGULAR EXPRESSIONS.
+ ---------------------------------------------------------------------------
+
+                           J\bJU\bUM\bMP\bPI\bIN\bNG\bG
+
+  g  <  ESC-<       *  Go to first line in file (or line _\bN).
+  G  >  ESC->       *  Go to last line in file (or line _\bN).
+  p  %              *  Go to beginning of file (or _\bN percent into file).
+  t                 *  Go to the (_\bN-th) next tag.
+  T                 *  Go to the (_\bN-th) previous tag.
+  {  (  [           *  Find close bracket } ) ].
+  }  )  ]           *  Find open bracket { ( [.
+  ESC-^F _\b<_\bc_\b1_\b> _\b<_\bc_\b2_\b>  *  Find close bracket _\b<_\bc_\b2_\b>.
+  ESC-^B _\b<_\bc_\b1_\b> _\b<_\bc_\b2_\b>  *  Find open bracket _\b<_\bc_\b1_\b
+        ---------------------------------------------------
+        Each "find close bracket" command goes forward to the close bracket 
+          matching the (_\bN-th) open bracket in the top line.
+        Each "find open bracket" command goes backward to the open bracket 
+          matching the (_\bN-th) close bracket in the bottom line.
+
+  m_\b<_\bl_\be_\bt_\bt_\be_\br_\b>            Mark the current position with <letter>.
+  '_\b<_\bl_\be_\bt_\bt_\be_\br_\b>            Go to a previously marked position.
+  ''                   Go to the previous position.
+  ^X^X                 Same as '.
+        ---------------------------------------------------
+        A mark is any upper-case or lower-case letter.
+        Certain marks are predefined:
+             ^  means  beginning of the file
+             $  means  end of the file
+ ---------------------------------------------------------------------------
+
+                        C\bCH\bHA\bAN\bNG\bGI\bIN\bNG\bG F\bFI\bIL\bLE\bES\bS
+
+  :e [_\bf_\bi_\bl_\be]            Examine a new file.
+  ^X^V                 Same as :e.
+  :n                *  Examine the (_\bN-th) next file from the command line.
+  :p                *  Examine the (_\bN-th) previous file from the command line.
+  :x                *  Examine the first (or _\bN-th) file from the command line.
+  :d                   Delete the current file from the command line list.
+  =  ^G  :f            Print current file name.
+ ---------------------------------------------------------------------------
+
+                    M\bMI\bIS\bSC\bCE\bEL\bLL\bLA\bAN\bNE\bEO\bOU\bUS\bS C\bCO\bOM\bMM\bMA\bAN\bND\bDS\bS
+
+  -_\b<_\bf_\bl_\ba_\bg_\b>              Toggle a command line option [see OPTIONS below].
+  --_\b<_\bn_\ba_\bm_\be_\b>             Toggle a command line option, by name.
+  __\b<_\bf_\bl_\ba_\bg_\b>              Display the setting of a command line option.
+  ___\b<_\bn_\ba_\bm_\be_\b>             Display the setting of an option, by name.
+  +_\bc_\bm_\bd                 Execute the less cmd each time a new file is examined.
+
+  !_\bc_\bo_\bm_\bm_\ba_\bn_\bd             Execute the shell command with $SHELL.
+  |X\bX_\bc_\bo_\bm_\bm_\ba_\bn_\bd            Pipe file between current pos & mark X\bX to shell command.
+  v                    Edit the current file with $VISUAL or $EDITOR.
+  V                    Print version number of "less".
+ ---------------------------------------------------------------------------
+
+                           O\bOP\bPT\bTI\bIO\bON\bNS\bS
+
+        Most options may be changed either on the command line,
+        or from within less by using the - or -- command.
+        Options may be given in one of two forms: either a single
+        character preceded by a -, or a name preceeded by --.
+
+  -?  ........  --help
+                  Display help (from command line).
+  -a  ........  --search-skip-screen
+                  Forward search skips current screen.
+  -A  ........  --SEARCH-SKIP-SCREEN
+                  Forward search always skips target line.
+  -b [_\bN]  ....  --buffers=[_\bN]
+                  Number of buffers.
+  -B  ........  --auto-buffers
+                  Don't automatically allocate buffers for pipes.
+  -c  ........  --clear-screen
+                  Repaint by clearing rather than scrolling.
+  -d  ........  --dumb
+                  Dumb terminal.
+  -D [_\bx_\bn_\b._\bn]  .  --color=_\bx_\bn_\b._\bn
+                  Set screen colors. (MS-DOS only)
+  -e  -E  ....  --quit-at-eof  --QUIT-AT-EOF
+                  Quit at end of file.
+  -f  ........  --force
+                  Force open non-regular files.
+  -F  ........  --quit-if-one-screen
+                  Quit if entire file fits on first screen.
+  -g  ........  --hilite-search
+                  Highlight only last match for searches.
+  -G  ........  --HILITE-SEARCH
+                  Don't highlight any matches for searches.
+  -h [_\bN]  ....  --max-back-scroll=[_\bN]
+                  Backward scroll limit.
+  -i  ........  --ignore-case
+                  Ignore case in searches that do not contain uppercase.
+  -I  ........  --IGNORE-CASE
+                  Ignore case in all searches.
+  -j [_\bN]  ....  --jump-target=[_\bN]
+                  Screen position of target lines.
+  -J  ........  --status-column
+                  Display a status column at left edge of screen.
+  -k [_\bf_\bi_\bl_\be]  .  --lesskey-file=[_\bf_\bi_\bl_\be]
+                  Use a lesskey file.
+  -K            --quit-on-intr
+                  Exit less in response to ctrl-C.
+  -L  ........  --no-lessopen
+                  Ignore the LESSOPEN environment variable.
+  -m  -M  ....  --long-prompt  --LONG-PROMPT
+                  Set prompt style.
+  -n  -N  ....  --line-numbers  --LINE-NUMBERS
+                  Don't use line numbers.
+  -o [_\bf_\bi_\bl_\be]  .  --log-file=[_\bf_\bi_\bl_\be]
+                  Copy to log file (standard input only).
+  -O [_\bf_\bi_\bl_\be]  .  --LOG-FILE=[_\bf_\bi_\bl_\be]
+                  Copy to log file (unconditionally overwrite).
+  -p [_\bp_\ba_\bt_\bt_\be_\br_\bn]  --pattern=[_\bp_\ba_\bt_\bt_\be_\br_\bn]
+                  Start at pattern (from command line).
+  -P [_\bp_\br_\bo_\bm_\bp_\bt]   --prompt=[_\bp_\br_\bo_\bm_\bp_\bt]
+                  Define new prompt.
+  -q  -Q  ....  --quiet  --QUIET  --silent --SILENT
+                  Quiet the terminal bell.
+  -r  -R  ....  --raw-control-chars  --RAW-CONTROL-CHARS
+                  Output "raw" control characters.
+  -s  ........  --squeeze-blank-lines
+                  Squeeze multiple blank lines.
+  -S  ........  --chop-long-lines
+                  Chop long lines.
+  -t [_\bt_\ba_\bg]  ..  --tag=[_\bt_\ba_\bg]
+                  Find a tag.
+  -T [_\bt_\ba_\bg_\bs_\bf_\bi_\bl_\be] --tag-file=[_\bt_\ba_\bg_\bs_\bf_\bi_\bl_\be]
+                  Use an alternate tags file.
+  -u  -U  ....  --underline-special  --UNDERLINE-SPECIAL
+                  Change handling of backspaces.
+  -V  ........  --version
+                  Display the version number of "less".
+  -w  ........  --hilite-unread
+                  Highlight first new line after forward-screen.
+  -W  ........  --HILITE-UNREAD
+                  Highlight first new line after any forward movement.
+  -x [_\bN[,...]]  --tabs=[_\bN[,...]]
+                  Set tab stops.
+  -X  ........  --no-init
+                  Don't use termcap init/deinit strings.
+                --no-keypad
+                  Don't use termcap keypad init/deinit strings.
+  -y [_\bN]  ....  --max-forw-scroll=[_\bN]
+                  Forward scroll limit.
+  -z [_\bN]  ....  --window=[_\bN]
+                  Set size of window.
+  -" [_\bc[_\bc]]  .  --quotes=[_\bc[_\bc]]
+                  Set shell quote characters.
+  -~  ........  --tilde
+                  Don't display tildes after end of file.
+  -# [_\bN]  ....  --shift=[_\bN]
+                  Horizontal scroll amount (0 = one half screen width)
+      ........  --no-keypad
+                  Don't send keypad init/deinit sequence.
+      ........  --follow-name
+                  The F command changes files if the input file is renamed.
+
+
+ ---------------------------------------------------------------------------
+
+                          L\bLI\bIN\bNE\bE E\bED\bDI\bIT\bTI\bIN\bNG\bG
+
+        These keys can be used to edit text being entered 
+        on the "command line" at the bottom of the screen.
+
+ RightArrow                       ESC-l     Move cursor right one character.
+ LeftArrow                        ESC-h     Move cursor left one character.
+ CNTL-RightArrow  ESC-RightArrow  ESC-w     Move cursor right one word.
+ CNTL-LeftArrow   ESC-LeftArrow   ESC-b     Move cursor left one word.
+ HOME                             ESC-0     Move cursor to start of line.
+ END                              ESC-$     Move cursor to end of line.
+ BACKSPACE                                  Delete char to left of cursor.
+ DELETE                           ESC-x     Delete char under cursor.
+ CNTL-BACKSPACE   ESC-BACKSPACE             Delete word to left of cursor.
+ CNTL-DELETE      ESC-DELETE      ESC-X     Delete word under cursor.
+ CNTL-U           ESC (MS-DOS only)         Delete entire line.
+ UpArrow                          ESC-k     Retrieve previous command line.
+ DownArrow                        ESC-j     Retrieve next command line.
+ TAB                                        Complete filename & cycle.
+ SHIFT-TAB                        ESC-TAB   Complete filename & reverse cycle.
+ CNTL-L                                     Complete filename, list all.
+
+
diff --git a/thirdparty/less/lessecho.c b/thirdparty/less/lessecho.c
new file mode 100644 (file)
index 0000000..6dcaf6c
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * lessecho [-ox] [-cx] [-pn] [-dn] [-a] file ...
+ * Simply echos its filename arguments on standard output.
+ * But any argument containing spaces is enclosed in quotes.
+ *
+ * -ox Specifies "x" to be the open quote character.
+ * -cx Specifies "x" to be the close quote character.
+ * -pn Specifies "n" to be the open quote character, as an integer.
+ * -dn Specifies "n" to be the close quote character, as an integer.
+ * -mx  Specifies "x" to be a metachar.
+ * -nn  Specifies "n" to be a metachar, as an integer.
+ * -ex  Specifies "x" to be the escape char for metachars.
+ * -fn  Specifies "x" to be the escape char for metachars, as an integer.
+ * -a  Specifies that all arguments are to be quoted.
+ *     The default is that only arguments containing spaces are quoted.
+ */
+
+#include "less.h"
+
+static char *version = "$Revision: 1.14 $";
+
+static int quote_all = 0;
+static char openquote = '"';
+static char closequote = '"';
+static char *meta_escape = "\\";
+static char meta_escape_buf[2];
+static char metachars[64] = "";
+static int num_metachars = 0;
+
+       static void
+pr_usage()
+{
+       fprintf(stderr,
+               "usage: lessecho [-ox] [-cx] [-pn] [-dn] [-mx] [-nn] [-ex] [-fn] [-a] file ...\n");
+}
+
+       static void
+pr_version()
+{
+       char *p;
+       char buf[10];
+       char *pbuf = buf;
+
+       for (p = version;  *p != ' ';  p++)
+               if (*p == '\0')
+                       return;
+       for (p++;  *p != '$' && *p != ' ' && *p != '\0';  p++)
+               *pbuf++ = *p;
+       *pbuf = '\0';
+       printf("%s\n", buf);
+}
+
+       static void
+pr_error(s)
+       char *s;
+{
+       fprintf(stderr, "%s\n", s);
+       exit(1);
+}
+
+       static long
+lstrtol(s, radix, pend)
+       char *s;
+       int radix;
+       char **pend;
+{
+       int v;
+       int neg = 0;
+       long n = 0;
+
+       /* Skip leading white space. */
+       while (*s == ' ' || *s == '\t')
+               s++;
+
+       /* Check for a leading + or -. */
+       if (*s == '-')
+       {
+               neg = 1;
+               s++;
+       } else if (*s == '+')
+       {
+               s++;
+       }
+
+       /* Determine radix if caller does not specify. */
+       if (radix == 0)
+       {
+               radix = 10;
+               if (*s == '0')
+               {
+                       switch (*++s)
+                       {
+                       case 'x':
+                               radix = 16;
+                               s++;
+                               break;
+                       default:
+                               radix = 8;
+                               break;
+                       }
+               }
+       }
+
+       /* Parse the digits of the number. */
+       for (;;)
+       {
+               if (*s >= '0' && *s <= '9')
+                       v = *s - '0';
+               else if (*s >= 'a' && *s <= 'f')
+                       v = *s - 'a' + 10;
+               else if (*s >= 'A' && *s <= 'F')
+                       v = *s - 'A' + 10;
+               else
+                       break;
+               if (v >= radix)
+                       break;
+               n = n * radix + v;
+               s++;
+       }
+
+       if (pend != NULL)
+       {
+               /* Skip trailing white space. */
+               while (*s == ' ' || *s == '\t')
+                       s++;
+               *pend = s;
+       }
+       if (neg)
+               return (-n);
+       return (n);
+}
+
+
+#if !HAVE_STRCHR
+       char *
+strchr(s, c)
+       char *s;
+       int c;
+{
+       for ( ;  *s != '\0';  s++)
+               if (*s == c)
+                       return (s);
+       if (c == '\0')
+               return (s);
+       return (NULL);
+}
+#endif
+
+       int
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       char *arg;
+       char *s;
+       int no_more_options;
+
+       no_more_options = 0;
+       while (--argc > 0)
+       {
+               arg = *++argv;
+               if (*arg != '-' || no_more_options)
+                       break;
+               switch (*++arg)
+               {
+               case 'a':
+                       quote_all = 1;
+                       break;
+               case 'c':
+                       closequote = *++arg;
+                       break;
+               case 'd':
+                       closequote = lstrtol(++arg, 0, &s);
+                       if (s == arg)
+                               pr_error("Missing number after -d");
+                       break;
+               case 'e':
+                       if (strcmp(++arg, "-") == 0)
+                               meta_escape = "";
+                       else
+                               meta_escape = arg;
+                       break;
+               case 'f':
+                       meta_escape_buf[0] = lstrtol(++arg, 0, &s);
+                       meta_escape = meta_escape_buf;
+                       if (s == arg)
+                               pr_error("Missing number after -f");
+                       break;
+               case 'o':
+                       openquote = *++arg;
+                       break;
+               case 'p':
+                       openquote = lstrtol(++arg, 0, &s);
+                       if (s == arg)
+                               pr_error("Missing number after -p");
+                       break;
+               case 'm':
+                       metachars[num_metachars++] = *++arg;
+                       metachars[num_metachars] = '\0';
+                       break;
+               case 'n':
+                       metachars[num_metachars++] = lstrtol(++arg, 0, &s);
+                       if (s == arg)
+                               pr_error("Missing number after -n");
+                       metachars[num_metachars] = '\0';
+                       break;
+               case '?':
+                       pr_usage();
+                       return (0);
+               case '-':
+                       if (*++arg == '\0')
+                       {
+                               no_more_options = 1;
+                               break;
+                       }
+                       if (strcmp(arg, "version") == 0)
+                       {
+                               pr_version();
+                               return (0);
+                       }
+                       if (strcmp(arg, "help") == 0)
+                       {
+                               pr_usage();
+                               return (0);
+                       }
+                       pr_error("Invalid option after --");
+               default:
+                       pr_error("Invalid option letter");
+               }
+       }
+
+       while (argc-- > 0)
+       {
+               int has_meta = 0;
+               arg = *argv++;
+               for (s = arg;  *s != '\0';  s++)
+               {
+                       if (strchr(metachars, *s) != NULL)
+                       {
+                               has_meta = 1;
+                               break;
+                       }
+               }
+               if (quote_all || (has_meta && strlen(meta_escape) == 0))
+                       printf("%c%s%c", openquote, arg, closequote);
+               else 
+               {
+                       for (s = arg;  *s != '\0';  s++)
+                       {
+                               if (strchr(metachars, *s) != NULL)
+                                       printf("%s", meta_escape);
+                               printf("%c", *s);
+                       }
+               }
+               if (argc > 0)
+                       printf(" ");
+               else
+                       printf("\n");
+       }
+       return (0);
+}
diff --git a/thirdparty/less/lesskey.c b/thirdparty/less/lesskey.c
new file mode 100644 (file)
index 0000000..1ee2c40
--- /dev/null
@@ -0,0 +1,873 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ *     lesskey [-o output] [input]
+ *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
+ *
+ *     Make a .less file.
+ *     If no input file is specified, standard input is used.
+ *     If no output file is specified, $HOME/.less is used.
+ *
+ *     The .less file is used to specify (to "less") user-defined
+ *     key bindings.  Basically any sequence of 1 to MAX_CMDLEN
+ *     keystrokes may be bound to an existing less function.
+ *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
+ *
+ *     The input file is an ascii file consisting of a 
+ *     sequence of lines of the form:
+ *             string <whitespace> action [chars] <newline>
+ *
+ *     "string" is a sequence of command characters which form
+ *             the new user-defined command.  The command
+ *             characters may be:
+ *             1. The actual character itself.
+ *             2. A character preceded by ^ to specify a
+ *                control character (e.g. ^X means control-X).
+ *             3. A backslash followed by one to three octal digits
+ *                to specify a character by its octal value.
+ *             4. A backslash followed by b, e, n, r or t
+ *                to specify \b, ESC, \n, \r or \t, respectively.
+ *             5. Any character (other than those mentioned above) preceded 
+ *                by a \ to specify the character itself (characters which
+ *                must be preceded by \ include ^, \, and whitespace.
+ *     "action" is the name of a "less" action, from the table below.
+ *     "chars" is an optional sequence of characters which is treated
+ *             as keyboard input after the command is executed.
+ *
+ *     Blank lines and lines which start with # are ignored, 
+ *     except for the special control lines:
+ *             #command        Signals the beginning of the command
+ *                             keys section.
+ *             #line-edit      Signals the beginning of the line-editing
+ *                             keys section.
+ *             #env            Signals the beginning of the environment
+ *                             variable section.
+ *             #stop           Stops command parsing in less;
+ *                             causes all default keys to be disabled.
+ *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
+ *
+ *     The output file is a non-ascii file, consisting of a header,
+ *     one or more sections, and a trailer.
+ *     Each section begins with a section header, a section length word
+ *     and the section data.  Normally there are three sections:
+ *             CMD_SECTION     Definition of command keys.
+ *             EDIT_SECTION    Definition of editing keys.
+ *             END_SECTION     A special section header, with no 
+ *                             length word or section data.
+ *
+ *     Section data consists of zero or more byte sequences of the form:
+ *             string <0> <action>
+ *     or
+ *             string <0> <action|A_EXTRA> chars <0>
+ *
+ *     "string" is the command string.
+ *     "<0>" is one null byte.
+ *     "<action>" is one byte containing the action code (the A_xxx value).
+ *     If action is ORed with A_EXTRA, the action byte is followed
+ *             by the null-terminated "chars" string.
+ *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
+ */
+
+#include "less.h"
+#include "lesskey.h"
+#include "cmd.h"
+
+struct cmdname
+{
+       char *cn_name;
+       int cn_action;
+};
+
+struct cmdname cmdnames[] = 
+{
+       { "back-bracket",         A_B_BRACKET },
+       { "back-line",            A_B_LINE },
+       { "back-line-force",      A_BF_LINE },
+       { "back-screen",          A_B_SCREEN },
+       { "back-scroll",          A_B_SCROLL },
+       { "back-search",          A_B_SEARCH },
+       { "back-window",          A_B_WINDOW },
+       { "debug",                A_DEBUG },
+       { "digit",                A_DIGIT },
+       { "display-flag",         A_DISP_OPTION },
+       { "display-option",       A_DISP_OPTION },
+       { "end",                  A_GOEND },
+       { "examine",              A_EXAMINE },
+       { "filter",               A_FILTER },
+       { "first-cmd",            A_FIRSTCMD },
+       { "firstcmd",             A_FIRSTCMD },
+       { "flush-repaint",        A_FREPAINT },
+       { "forw-bracket",         A_F_BRACKET },
+       { "forw-forever",         A_F_FOREVER },
+       { "forw-line",            A_F_LINE },
+       { "forw-line-force",      A_FF_LINE },
+       { "forw-screen",          A_F_SCREEN },
+       { "forw-screen-force",    A_FF_SCREEN },
+       { "forw-scroll",          A_F_SCROLL },
+       { "forw-search",          A_F_SEARCH },
+       { "forw-window",          A_F_WINDOW },
+       { "goto-end",             A_GOEND },
+       { "goto-line",            A_GOLINE },
+       { "goto-mark",            A_GOMARK },
+       { "help",                 A_HELP },
+       { "index-file",           A_INDEX_FILE },
+       { "invalid",              A_UINVALID },
+       { "left-scroll",          A_LSHIFT },
+       { "next-file",            A_NEXT_FILE },
+       { "next-tag",             A_NEXT_TAG },
+       { "noaction",             A_NOACTION },
+       { "percent",              A_PERCENT },
+       { "pipe",                 A_PIPE },
+       { "prev-file",            A_PREV_FILE },
+       { "prev-tag",             A_PREV_TAG },
+       { "quit",                 A_QUIT },
+       { "remove-file",          A_REMOVE_FILE },
+       { "repaint",              A_REPAINT },
+       { "repaint-flush",        A_FREPAINT },
+       { "repeat-search",        A_AGAIN_SEARCH },
+       { "repeat-search-all",    A_T_AGAIN_SEARCH },
+       { "reverse-search",       A_REVERSE_SEARCH },
+       { "reverse-search-all",   A_T_REVERSE_SEARCH },
+       { "right-scroll",         A_RSHIFT },
+       { "set-mark",             A_SETMARK },
+       { "shell",                A_SHELL },
+       { "status",               A_STAT },
+       { "toggle-flag",          A_OPT_TOGGLE },
+       { "toggle-option",        A_OPT_TOGGLE },
+       { "undo-hilite",          A_UNDO_SEARCH },
+       { "version",              A_VERSION },
+       { "visual",               A_VISUAL },
+       { NULL,   0 }
+};
+
+struct cmdname editnames[] = 
+{
+       { "back-complete",      EC_B_COMPLETE },
+       { "backspace",          EC_BACKSPACE },
+       { "delete",             EC_DELETE },
+       { "down",               EC_DOWN },
+       { "end",                EC_END },
+       { "expand",             EC_EXPAND },
+       { "forw-complete",      EC_F_COMPLETE },
+       { "home",               EC_HOME },
+       { "insert",             EC_INSERT },
+       { "invalid",            EC_UINVALID },
+       { "kill-line",          EC_LINEKILL },
+       { "abort",              EC_ABORT },
+       { "left",               EC_LEFT },
+       { "literal",            EC_LITERAL },
+       { "right",              EC_RIGHT },
+       { "up",                 EC_UP },
+       { "word-backspace",     EC_W_BACKSPACE },
+       { "word-delete",        EC_W_DELETE },
+       { "word-left",          EC_W_LEFT },
+       { "word-right",         EC_W_RIGHT },
+       { NULL, 0 }
+};
+
+struct table
+{
+       struct cmdname *names;
+       char *pbuffer;
+       char buffer[MAX_USERCMD];
+};
+
+struct table cmdtable;
+struct table edittable;
+struct table vartable;
+struct table *currtable = &cmdtable;
+
+char fileheader[] = {
+       C0_LESSKEY_MAGIC, 
+       C1_LESSKEY_MAGIC, 
+       C2_LESSKEY_MAGIC, 
+       C3_LESSKEY_MAGIC
+};
+char filetrailer[] = {
+       C0_END_LESSKEY_MAGIC, 
+       C1_END_LESSKEY_MAGIC, 
+       C2_END_LESSKEY_MAGIC
+};
+char cmdsection[1] =   { CMD_SECTION };
+char editsection[1] =  { EDIT_SECTION };
+char varsection[1] =   { VAR_SECTION };
+char endsection[1] =   { END_SECTION };
+
+char *infile = NULL;
+char *outfile = NULL ;
+
+int linenum;
+int errors;
+
+extern char version[];
+
+       void
+usage()
+{
+       fprintf(stderr, "usage: lesskey [-o output] [input]\n");
+       exit(1);
+}
+
+       char *
+mkpathname(dirname, filename)
+       char *dirname;
+       char *filename;
+{
+       char *pathname;
+
+       pathname = calloc(strlen(dirname) + strlen(filename) + 2, sizeof(char));
+       strcpy(pathname, dirname);
+       strcat(pathname, PATHNAME_SEP);
+       strcat(pathname, filename);
+       return (pathname);
+}
+
+/*
+ * Figure out the name of a default file (in the user's HOME directory).
+ */
+       char *
+homefile(filename)
+       char *filename;
+{
+       char *p;
+       char *pathname;
+
+       if ((p = getenv("HOME")) != NULL && *p != '\0')
+               pathname = mkpathname(p, filename);
+#if OS2
+       else if ((p = getenv("INIT")) != NULL && *p != '\0')
+               pathname = mkpathname(p, filename);
+#endif
+       else
+       {
+               fprintf(stderr, "cannot find $HOME - using current directory\n");
+               pathname = mkpathname(".", filename);
+       }
+       return (pathname);
+}
+
+/*
+ * Parse command line arguments.
+ */
+       void
+parse_args(argc, argv)
+       int argc;
+       char **argv;
+{
+       char *arg;
+
+       outfile = NULL;
+       while (--argc > 0)
+       {
+               arg = *++argv;
+               if (arg[0] != '-')
+                       /* Arg does not start with "-"; it's not an option. */
+                       break;
+               if (arg[1] == '\0')
+                       /* "-" means standard input. */
+                       break;
+               if (arg[1] == '-' && arg[2] == '\0')
+               {
+                       /* "--" means end of options. */
+                       argc--;
+                       argv++;
+                       break;
+               }
+               switch (arg[1])
+               {
+               case '-':
+                       if (strncmp(arg, "--output", 8) == 0)
+                       {
+                               if (arg[8] == '\0')
+                                       outfile = &arg[8];
+                               else if (arg[8] == '=')
+                                       outfile = &arg[9];
+                               else
+                                       usage();
+                               goto opt_o;
+                       }
+                       if (strcmp(arg, "--version") == 0)
+                       {
+                               goto opt_V;
+                       }
+                       usage();
+                       break;
+               case 'o':
+                       outfile = &argv[0][2];
+               opt_o:
+                       if (*outfile == '\0')
+                       {
+                               if (--argc <= 0)
+                                       usage();
+                               outfile = *(++argv);
+                       }
+                       break;
+               case 'V':
+               opt_V:
+                       printf("lesskey  version %s\n", version);
+                       exit(0);
+               default:
+                       usage();
+               }
+       }
+       if (argc > 1)
+               usage();
+       /*
+        * Open the input file, or use DEF_LESSKEYINFILE if none specified.
+        */
+       if (argc > 0)
+               infile = *argv;
+       else
+               infile = homefile(DEF_LESSKEYINFILE);
+}
+
+/*
+ * Initialize data structures.
+ */
+       void
+init_tables()
+{
+       cmdtable.names = cmdnames;
+       cmdtable.pbuffer = cmdtable.buffer;
+
+       edittable.names = editnames;
+       edittable.pbuffer = edittable.buffer;
+
+       vartable.names = NULL;
+       vartable.pbuffer = vartable.buffer;
+}
+
+/*
+ * Parse one character of a string.
+ */
+       char *
+tstr(pp, xlate)
+       char **pp;
+       int xlate;
+{
+       register char *p;
+       register char ch;
+       register int i;
+       static char buf[10];
+       static char tstr_control_k[] =
+               { SK_SPECIAL_KEY, SK_CONTROL_K, 6, 1, 1, 1, '\0' };
+
+       p = *pp;
+       switch (*p)
+       {
+       case '\\':
+               ++p;
+               switch (*p)
+               {
+               case '0': case '1': case '2': case '3':
+               case '4': case '5': case '6': case '7':
+                       /*
+                        * Parse an octal number.
+                        */
+                       ch = 0;
+                       i = 0;
+                       do
+                               ch = 8*ch + (*p - '0');
+                       while (*++p >= '0' && *p <= '7' && ++i < 3);
+                       *pp = p;
+                       if (xlate && ch == CONTROL('K'))
+                               return tstr_control_k;
+                       buf[0] = ch;
+                       buf[1] = '\0';
+                       return (buf);
+               case 'b':
+                       *pp = p+1;
+                       return ("\b");
+               case 'e':
+                       *pp = p+1;
+                       buf[0] = ESC;
+                       buf[1] = '\0';
+                       return (buf);
+               case 'n':
+                       *pp = p+1;
+                       return ("\n");
+               case 'r':
+                       *pp = p+1;
+                       return ("\r");
+               case 't':
+                       *pp = p+1;
+                       return ("\t");
+               case 'k':
+                       if (xlate)
+                       {
+                               switch (*++p)
+                               {
+                               case 'u': ch = SK_UP_ARROW; break;
+                               case 'd': ch = SK_DOWN_ARROW; break;
+                               case 'r': ch = SK_RIGHT_ARROW; break;
+                               case 'l': ch = SK_LEFT_ARROW; break;
+                               case 'U': ch = SK_PAGE_UP; break;
+                               case 'D': ch = SK_PAGE_DOWN; break;
+                               case 'h': ch = SK_HOME; break;
+                               case 'e': ch = SK_END; break;
+                               case 'x': ch = SK_DELETE; break;
+                               default:
+                                       error("illegal char after \\k");
+                                       *pp = p+1;
+                                       return ("");
+                               }
+                               *pp = p+1;
+                               buf[0] = SK_SPECIAL_KEY;
+                               buf[1] = ch;
+                               buf[2] = 6;
+                               buf[3] = 1;
+                               buf[4] = 1;
+                               buf[5] = 1;
+                               buf[6] = '\0';
+                               return (buf);
+                       }
+                       /* FALLTHRU */
+               default:
+                       /*
+                        * Backslash followed by any other char 
+                        * just means that char.
+                        */
+                       *pp = p+1;
+                       buf[0] = *p;
+                       buf[1] = '\0';
+                       if (xlate && buf[0] == CONTROL('K'))
+                               return tstr_control_k;
+                       return (buf);
+               }
+       case '^':
+               /*
+                * Carat means CONTROL.
+                */
+               *pp = p+2;
+               buf[0] = CONTROL(p[1]);
+               buf[1] = '\0';
+               if (buf[0] == CONTROL('K'))
+                       return tstr_control_k;
+               return (buf);
+       }
+       *pp = p+1;
+       buf[0] = *p;
+       buf[1] = '\0';
+       if (xlate && buf[0] == CONTROL('K'))
+               return tstr_control_k;
+       return (buf);
+}
+
+/*
+ * Skip leading spaces in a string.
+ */
+       public char *
+skipsp(s)
+       register char *s;
+{
+       while (*s == ' ' || *s == '\t') 
+               s++;
+       return (s);
+}
+
+/*
+ * Skip non-space characters in a string.
+ */
+       public char *
+skipnsp(s)
+       register char *s;
+{
+       while (*s != '\0' && *s != ' ' && *s != '\t')
+               s++;
+       return (s);
+}
+
+/*
+ * Clean up an input line:
+ * strip off the trailing newline & any trailing # comment.
+ */
+       char *
+clean_line(s)
+       char *s;
+{
+       register int i;
+
+       s = skipsp(s);
+       for (i = 0;  s[i] != '\n' && s[i] != '\r' && s[i] != '\0';  i++)
+               if (s[i] == '#' && (i == 0 || s[i-1] != '\\'))
+                       break;
+       s[i] = '\0';
+       return (s);
+}
+
+/*
+ * Add a byte to the output command table.
+ */
+       void
+add_cmd_char(c)
+       int c;
+{
+       if (currtable->pbuffer >= currtable->buffer + MAX_USERCMD)
+       {
+               error("too many commands");
+               exit(1);
+       }
+       *(currtable->pbuffer)++ = c;
+}
+
+/*
+ * Add a string to the output command table.
+ */
+       void
+add_cmd_str(s)
+       char *s;
+{
+       for ( ;  *s != '\0';  s++)
+               add_cmd_char(*s);
+}
+
+/*
+ * See if we have a special "control" line.
+ */
+       int
+control_line(s)
+       char *s;
+{
+#define        PREFIX(str,pat) (strncmp(str,pat,strlen(pat)) == 0)
+
+       if (PREFIX(s, "#line-edit"))
+       {
+               currtable = &edittable;
+               return (1);
+       }
+       if (PREFIX(s, "#command"))
+       {
+               currtable = &cmdtable;
+               return (1);
+       }
+       if (PREFIX(s, "#env"))
+       {
+               currtable = &vartable;
+               return (1);
+       }
+       if (PREFIX(s, "#stop"))
+       {
+               add_cmd_char('\0');
+               add_cmd_char(A_END_LIST);
+               return (1);
+       }
+       return (0);
+}
+
+/*
+ * Output some bytes.
+ */
+       void
+fputbytes(fd, buf, len)
+       FILE *fd;
+       char *buf;
+       int len;
+{
+       while (len-- > 0)
+       {
+               fwrite(buf, sizeof(char), 1, fd);
+               buf++;
+       }
+}
+
+/*
+ * Output an integer, in special KRADIX form.
+ */
+       void
+fputint(fd, val)
+       FILE *fd;
+       unsigned int val;
+{
+       char c;
+
+       if (val >= KRADIX*KRADIX)
+       {
+               fprintf(stderr, "error: integer too big (%d > %d)\n", 
+                       val, KRADIX*KRADIX);
+               exit(1);
+       }
+       c = val % KRADIX;
+       fwrite(&c, sizeof(char), 1, fd);
+       c = val / KRADIX;
+       fwrite(&c, sizeof(char), 1, fd);
+}
+
+/*
+ * Find an action, given the name of the action.
+ */
+       int
+findaction(actname)
+       char *actname;
+{
+       int i;
+
+       for (i = 0;  currtable->names[i].cn_name != NULL;  i++)
+               if (strcmp(currtable->names[i].cn_name, actname) == 0)
+                       return (currtable->names[i].cn_action);
+       error("unknown action");
+       return (A_INVALID);
+}
+
+       void
+error(s)
+       char *s;
+{
+       fprintf(stderr, "line %d: %s\n", linenum, s);
+       errors++;
+}
+
+
+       void
+parse_cmdline(p)
+       char *p;
+{
+       int cmdlen;
+       char *actname;
+       int action;
+       char *s;
+       char c;
+
+       /*
+        * Parse the command string and store it in the current table.
+        */
+       cmdlen = 0;
+       do
+       {
+               s = tstr(&p, 1);
+               cmdlen += strlen(s);
+               if (cmdlen > MAX_CMDLEN)
+                       error("command too long");
+               else
+                       add_cmd_str(s);
+       } while (*p != ' ' && *p != '\t' && *p != '\0');
+       /*
+        * Terminate the command string with a null byte.
+        */
+       add_cmd_char('\0');
+
+       /*
+        * Skip white space between the command string
+        * and the action name.
+        * Terminate the action name with a null byte.
+        */
+       p = skipsp(p);
+       if (*p == '\0')
+       {
+               error("missing action");
+               return;
+       }
+       actname = p;
+       p = skipnsp(p);
+       c = *p;
+       *p = '\0';
+
+       /*
+        * Parse the action name and store it in the current table.
+        */
+       action = findaction(actname);
+
+       /*
+        * See if an extra string follows the action name.
+        */
+       *p = c;
+       p = skipsp(p);
+       if (*p == '\0')
+       {
+               add_cmd_char(action);
+       } else
+       {
+               /*
+                * OR the special value A_EXTRA into the action byte.
+                * Put the extra string after the action byte.
+                */
+               add_cmd_char(action | A_EXTRA);
+               while (*p != '\0')
+                       add_cmd_str(tstr(&p, 0));
+               add_cmd_char('\0');
+       }
+}
+
+       void
+parse_varline(p)
+       char *p;
+{
+       char *s;
+
+       do
+       {
+               s = tstr(&p, 0);
+               add_cmd_str(s);
+       } while (*p != ' ' && *p != '\t' && *p != '=' && *p != '\0');
+       /*
+        * Terminate the variable name with a null byte.
+        */
+       add_cmd_char('\0');
+
+       p = skipsp(p);
+       if (*p++ != '=')
+       {
+               error("missing =");
+               return;
+       }
+
+       add_cmd_char(EV_OK|A_EXTRA);
+
+       p = skipsp(p);
+       while (*p != '\0')
+       {
+               s = tstr(&p, 0);
+               add_cmd_str(s);
+       }
+       add_cmd_char('\0');
+}
+
+/*
+ * Parse a line from the lesskey file.
+ */
+       void
+parse_line(line)
+       char *line;
+{
+       char *p;
+
+       /*
+        * See if it is a control line.
+        */
+       if (control_line(line))
+               return;
+       /*
+        * Skip leading white space.
+        * Replace the final newline with a null byte.
+        * Ignore blank lines and comments.
+        */
+       p = clean_line(line);
+       if (*p == '\0')
+               return;
+
+       if (currtable == &vartable)
+               parse_varline(p);
+       else
+               parse_cmdline(p);
+}
+
+       int
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       FILE *desc;
+       FILE *out;
+       char line[1024];
+
+#ifdef WIN32
+       if (getenv("HOME") == NULL)
+       {
+               /*
+                * If there is no HOME environment variable,
+                * try the concatenation of HOMEDRIVE + HOMEPATH.
+                */
+               char *drive = getenv("HOMEDRIVE");
+               char *path  = getenv("HOMEPATH");
+               if (drive != NULL && path != NULL)
+               {
+                       char *env = (char *) calloc(strlen(drive) + 
+                                       strlen(path) + 6, sizeof(char));
+                       strcpy(env, "HOME=");
+                       strcat(env, drive);
+                       strcat(env, path);
+                       putenv(env);
+               }
+       }
+#endif /* WIN32 */
+
+       /*
+        * Process command line arguments.
+        */
+       parse_args(argc, argv);
+       init_tables();
+
+       /*
+        * Open the input file.
+        */
+       if (strcmp(infile, "-") == 0)
+               desc = stdin;
+       else if ((desc = fopen(infile, "r")) == NULL)
+       {
+#if HAVE_PERROR
+               perror(infile);
+#else
+               fprintf(stderr, "Cannot open %s\n", infile);
+#endif
+               usage();
+       }
+
+       /*
+        * Read and parse the input file, one line at a time.
+        */
+       errors = 0;
+       linenum = 0;
+       while (fgets(line, sizeof(line), desc) != NULL)
+       {
+               ++linenum;
+               parse_line(line);
+       }
+
+       /*
+        * Write the output file.
+        * If no output file was specified, use "$HOME/.less"
+        */
+       if (errors > 0)
+       {
+               fprintf(stderr, "%d errors; no output produced\n", errors);
+               exit(1);
+       }
+
+       if (outfile == NULL)
+               outfile = getenv("LESSKEY");
+       if (outfile == NULL)
+               outfile = homefile(LESSKEYFILE);
+       if ((out = fopen(outfile, "wb")) == NULL)
+       {
+#if HAVE_PERROR
+               perror(outfile);
+#else
+               fprintf(stderr, "Cannot open %s\n", outfile);
+#endif
+               exit(1);
+       }
+
+       /* File header */
+       fputbytes(out, fileheader, sizeof(fileheader));
+
+       /* Command key section */
+       fputbytes(out, cmdsection, sizeof(cmdsection));
+       fputint(out, cmdtable.pbuffer - cmdtable.buffer);
+       fputbytes(out, (char *)cmdtable.buffer, cmdtable.pbuffer-cmdtable.buffer);
+       /* Edit key section */
+       fputbytes(out, editsection, sizeof(editsection));
+       fputint(out, edittable.pbuffer - edittable.buffer);
+       fputbytes(out, (char *)edittable.buffer, edittable.pbuffer-edittable.buffer);
+
+       /* Environment variable section */
+       fputbytes(out, varsection, sizeof(varsection)); 
+       fputint(out, vartable.pbuffer - vartable.buffer);
+       fputbytes(out, (char *)vartable.buffer, vartable.pbuffer-vartable.buffer);
+
+       /* File trailer */
+       fputbytes(out, endsection, sizeof(endsection));
+       fputbytes(out, filetrailer, sizeof(filetrailer));
+       return (0);
+}
diff --git a/thirdparty/less/lesskey.h b/thirdparty/less/lesskey.h
new file mode 100644 (file)
index 0000000..9a457a9
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Format of a lesskey file:
+ *
+ *     LESSKEY_MAGIC (4 bytes)
+ *      sections...
+ *     END_LESSKEY_MAGIC (4 bytes)
+ *
+ * Each section is:
+ *
+ *     section_MAGIC (1 byte)
+ *     section_length (2 bytes)
+ *     key table (section_length bytes)
+ */
+#define        C0_LESSKEY_MAGIC        '\0'
+#define        C1_LESSKEY_MAGIC        'M'
+#define        C2_LESSKEY_MAGIC        '+'
+#define        C3_LESSKEY_MAGIC        'G'
+
+#define        CMD_SECTION             'c'
+#define        EDIT_SECTION            'e'
+#define        VAR_SECTION             'v'
+#define        END_SECTION             'x'
+
+#define        C0_END_LESSKEY_MAGIC    'E'
+#define        C1_END_LESSKEY_MAGIC    'n'
+#define        C2_END_LESSKEY_MAGIC    'd'
+
+/* */
+#define        KRADIX          64
diff --git a/thirdparty/less/lglob.h b/thirdparty/less/lglob.h
new file mode 100644 (file)
index 0000000..82b9543
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Macros to define the method of doing filename "globbing".
+ * There are three possible mechanisms:
+ *   1.        GLOB_LIST
+ *     This defines a function that returns a list of matching filenames.
+ *   2. GLOB_NAME
+ *     This defines a function that steps thru the list of matching
+ *     filenames, returning one name each time it is called.
+ *   3. GLOB_STRING
+ *     This defines a function that returns the complete list of
+ *     matching filenames as a single space-separated string.
+ */
+
+#if OS2
+
+#define        DECL_GLOB_LIST(list)            char **list;  char **pp;
+#define        GLOB_LIST(filename,list)        list = _fnexplode(filename)
+#define        GLOB_LIST_FAILED(list)          list == NULL
+#define        SCAN_GLOB_LIST(list,p)          pp = list;  *pp != NULL;  pp++
+#define        INIT_GLOB_LIST(list,p)          p = *pp
+#define        GLOB_LIST_DONE(list)            _fnexplodefree(list)
+
+#else
+#if MSDOS_COMPILER==DJGPPC
+
+#define        DECL_GLOB_LIST(list)            glob_t list;  int i;
+#define        GLOB_LIST(filename,list)        glob(filename,GLOB_NOCHECK,0,&list)
+#define        GLOB_LIST_FAILED(list)          0
+#define        SCAN_GLOB_LIST(list,p)          i = 0;  i < list.gl_pathc;  i++
+#define        INIT_GLOB_LIST(list,p)          p = list.gl_pathv[i]
+#define        GLOB_LIST_DONE(list)            globfree(&list)
+
+#else
+#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==BORLANDC
+
+#define        GLOB_FIRST_NAME(filename,fndp,h) h = _dos_findfirst(filename, ~_A_VOLID, fndp)
+#define        GLOB_FIRST_FAILED(handle)       ((handle) != 0)
+#define        GLOB_NEXT_NAME(handle,fndp)             _dos_findnext(fndp)
+#define        GLOB_NAME_DONE(handle)
+#define        GLOB_NAME                       name
+#define        DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
+                                       struct find_t fnd;      \
+                                       char drive[_MAX_DRIVE]; \
+                                       char dir[_MAX_DIR];     \
+                                       char fname[_MAX_FNAME]; \
+                                       char ext[_MAX_EXT];     \
+                                       int handle;
+#else
+#if MSDOS_COMPILER==WIN32C && (defined(_MSC_VER) || defined(__MINGW2__))
+
+#define        GLOB_FIRST_NAME(filename,fndp,h) h = _findfirst(filename, fndp)
+#define        GLOB_FIRST_FAILED(handle)       ((handle) == -1)
+#define        GLOB_NEXT_NAME(handle,fndp)     _findnext(handle, fndp)
+#define        GLOB_NAME_DONE(handle)          _findclose(handle)
+#define        GLOB_NAME                       name
+#define        DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
+                                       struct _finddata_t fnd; \
+                                       char drive[_MAX_DRIVE]; \
+                                       char dir[_MAX_DIR];     \
+                                       char fname[_MAX_FNAME]; \
+                                       char ext[_MAX_EXT];     \
+                                       long handle;
+
+#else
+#if MSDOS_COMPILER==WIN32C && defined(__BORLANDC__) /* Borland C for Windows */
+
+#define        GLOB_FIRST_NAME(filename,fndp,h) h = findfirst(filename, fndp, ~FA_LABEL)
+#define        GLOB_FIRST_FAILED(handle)       ((handle) != 0)
+#define        GLOB_NEXT_NAME(handle,fndp)     findnext(fndp)
+#define        GLOB_NAME_DONE(handle)
+#define        GLOB_NAME                       ff_name
+#define        DECL_GLOB_NAME(fnd,drive,dir,fname,ext,handle) \
+                                       struct ffblk fnd;       \
+                                       char drive[MAXDRIVE];   \
+                                       char dir[MAXDIR];       \
+                                       char fname[MAXFILE];    \
+                                       char ext[MAXEXT];       \
+                                       int handle;
+
+#endif
+#endif
+#endif
+#endif
+#endif
diff --git a/thirdparty/less/line.c b/thirdparty/less/line.c
new file mode 100644 (file)
index 0000000..798d4f2
--- /dev/null
@@ -0,0 +1,1244 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to manipulate the "line buffer".
+ * The line buffer holds a line of output as it is being built
+ * in preparation for output to the screen.
+ */
+
+#include "less.h"
+#include "charset.h"
+
+static char *linebuf = NULL;   /* Buffer which holds the current output line */
+static char *attr = NULL;      /* Extension of linebuf to hold attributes */
+public int size_linebuf = 0;   /* Size of line buffer (and attr buffer) */
+
+static int cshift;             /* Current left-shift of output line buffer */
+public int hshift;             /* Desired left-shift of output line buffer */
+public int tabstops[TABSTOP_MAX] = { 0 }; /* Custom tabstops */
+public int ntabstops = 1;      /* Number of tabstops */
+public int tabdefault = 8;     /* Default repeated tabstops */
+
+static int curr;               /* Index into linebuf */
+static int column;             /* Printable length, accounting for
+                                  backspaces, etc. */
+static int overstrike;         /* Next char should overstrike previous char */
+static int last_overstrike = AT_NORMAL;
+static int is_null_line;       /* There is no current line */
+static int lmargin;            /* Left margin */
+static char pendc;
+static POSITION pendpos;
+static char *end_ansi_chars;
+static char *mid_ansi_chars;
+
+static int attr_swidth();
+static int attr_ewidth();
+static int do_append();
+
+extern int sigs;
+extern int bs_mode;
+extern int linenums;
+extern int ctldisp;
+extern int twiddle;
+extern int binattr;
+extern int status_col;
+extern int auto_wrap, ignaw;
+extern int bo_s_width, bo_e_width;
+extern int ul_s_width, ul_e_width;
+extern int bl_s_width, bl_e_width;
+extern int so_s_width, so_e_width;
+extern int sc_width, sc_height;
+extern int utf_mode;
+extern POSITION start_attnpos;
+extern POSITION end_attnpos;
+
+static char mbc_buf[MAX_UTF_CHAR_LEN];
+static int mbc_buf_len = 0;
+static int mbc_buf_index = 0;
+static POSITION mbc_pos;
+
+/*
+ * Initialize from environment variables.
+ */
+       public void
+init_line()
+{
+       end_ansi_chars = lgetenv("LESSANSIENDCHARS");
+       if (end_ansi_chars == NULL || *end_ansi_chars == '\0')
+               end_ansi_chars = "m";
+
+       mid_ansi_chars = lgetenv("LESSANSIMIDCHARS");
+       if (mid_ansi_chars == NULL || *mid_ansi_chars == '\0')
+               mid_ansi_chars = "0123456789;[?!\"'#%()*+ ";
+
+       linebuf = (char *) ecalloc(LINEBUF_SIZE, sizeof(char));
+       attr = (char *) ecalloc(LINEBUF_SIZE, sizeof(char));
+       size_linebuf = LINEBUF_SIZE;
+}
+
+/*
+ * Expand the line buffer.
+ */
+       static int
+expand_linebuf()
+{
+       /* Double the size of the line buffer. */
+       int new_size = size_linebuf * 2;
+
+       /* Just realloc to expand the buffer, if we can. */
+#if HAVE_REALLOC
+       char *new_buf = (char *) realloc(linebuf, new_size);
+       char *new_attr = (char *) realloc(attr, new_size);
+#else
+       char *new_buf = (char *) calloc(new_size, sizeof(char));
+       char *new_attr = (char *) calloc(new_size, sizeof(char));
+#endif
+       if (new_buf == NULL || new_attr == NULL)
+       {
+               if (new_attr != NULL)
+                       free(new_attr);
+               if (new_buf != NULL)
+                       free(new_buf);
+               return 1;
+       }
+#if HAVE_REALLOC
+       /*
+        * We realloc'd the buffers; they already have the old contents.
+        */
+       #if 0
+       memset(new_buf + size_linebuf, 0, new_size - size_linebuf);
+       memset(new_attr + size_linebuf, 0, new_size - size_linebuf);
+       #endif
+#else
+       /*
+        * We just calloc'd the buffers; copy the old contents.
+        */
+       memcpy(new_buf, linebuf, size_linebuf * sizeof(char));
+       memcpy(new_attr, attr, size_linebuf * sizeof(char));
+       free(attr);
+       free(linebuf);
+#endif
+       linebuf = new_buf;
+       attr = new_attr;
+       size_linebuf = new_size;
+       return 0;
+}
+
+/*
+ * Is a character ASCII?
+ */
+       public int
+is_ascii_char(ch)
+       LWCHAR ch;
+{
+       return (ch <= 0x7F);
+}
+
+/*
+ * Rewind the line buffer.
+ */
+       public void
+prewind()
+{
+       curr = 0;
+       column = 0;
+       cshift = 0;
+       overstrike = 0;
+       last_overstrike = AT_NORMAL;
+       mbc_buf_len = 0;
+       is_null_line = 0;
+       pendc = '\0';
+       lmargin = 0;
+       if (status_col)
+               lmargin += 1;
+}
+
+/*
+ * Insert the line number (of the given position) into the line buffer.
+ */
+       public void
+plinenum(pos)
+       POSITION pos;
+{
+       register LINENUM linenum = 0;
+       register int i;
+
+       if (linenums == OPT_ONPLUS)
+       {
+               /*
+                * Get the line number and put it in the current line.
+                * {{ Note: since find_linenum calls forw_raw_line,
+                *    it may seek in the input file, requiring the caller 
+                *    of plinenum to re-seek if necessary. }}
+                * {{ Since forw_raw_line modifies linebuf, we must
+                *    do this first, before storing anything in linebuf. }}
+                */
+               linenum = find_linenum(pos);
+       }
+
+       /*
+        * Display a status column if the -J option is set.
+        */
+       if (status_col)
+       {
+               linebuf[curr] = ' ';
+               if (start_attnpos != NULL_POSITION &&
+                   pos >= start_attnpos && pos < end_attnpos)
+                       attr[curr] = AT_NORMAL|AT_HILITE;
+               else
+                       attr[curr] = AT_NORMAL;
+               curr++;
+               column++;
+       }
+       /*
+        * Display the line number at the start of each line
+        * if the -N option is set.
+        */
+       if (linenums == OPT_ONPLUS)
+       {
+               char buf[INT_STRLEN_BOUND(pos) + 2];
+               int n;
+
+               linenumtoa(linenum, buf);
+               n = strlen(buf);
+               if (n < MIN_LINENUM_WIDTH)
+                       n = MIN_LINENUM_WIDTH;
+               sprintf(linebuf+curr, "%*s ", n, buf);
+               n++;  /* One space after the line number. */
+               for (i = 0; i < n; i++)
+                       attr[curr+i] = AT_NORMAL;
+               curr += n;
+               column += n;
+               lmargin += n;
+       }
+
+       /*
+        * Append enough spaces to bring us to the lmargin.
+        */
+       while (column < lmargin)
+       {
+               linebuf[curr] = ' ';
+               attr[curr++] = AT_NORMAL;
+               column++;
+       }
+}
+
+/*
+ * Shift the input line left.
+ * This means discarding N printable chars at the start of the buffer.
+ */
+       static void
+pshift(shift)
+       int shift;
+{
+       LWCHAR prev_ch = 0;
+       unsigned char c;
+       int shifted = 0;
+       int to;
+       int from;
+       int len;
+       int width;
+       int prev_attr;
+       int next_attr;
+
+       if (shift > column - lmargin)
+               shift = column - lmargin;
+       if (shift > curr - lmargin)
+               shift = curr - lmargin;
+
+       to = from = lmargin;
+       /*
+        * We keep on going when shifted == shift
+        * to get all combining chars.
+        */
+       while (shifted <= shift && from < curr)
+       {
+               c = linebuf[from];
+               if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
+               {
+                       /* Keep cumulative effect.  */
+                       linebuf[to] = c;
+                       attr[to++] = attr[from++];
+                       while (from < curr && linebuf[from])
+                       {
+                               linebuf[to] = linebuf[from];
+                               attr[to++] = attr[from];
+                               if (!is_ansi_middle(linebuf[from++]))
+                                       break;
+                       } 
+                       continue;
+               }
+
+               width = 0;
+
+               if (!IS_ASCII_OCTET(c) && utf_mode)
+               {
+                       /* Assumes well-formedness validation already done.  */
+                       LWCHAR ch;
+
+                       len = utf_len(c);
+                       if (from + len > curr)
+                               break;
+                       ch = get_wchar(linebuf + from);
+                       if (!is_composing_char(ch) && !is_combining_char(prev_ch, ch))
+                               width = is_wide_char(ch) ? 2 : 1;
+                       prev_ch = ch;
+               } else
+               {
+                       len = 1;
+                       if (c == '\b')
+                               /* XXX - Incorrect if several '\b' in a row.  */
+                               width = (utf_mode && is_wide_char(prev_ch)) ? -2 : -1;
+                       else if (!control_char(c))
+                               width = 1;
+                       prev_ch = 0;
+               }
+
+               if (width == 2 && shift - shifted == 1) {
+                       /* Should never happen when called by pshift_all().  */
+                       attr[to] = attr[from];
+                       /*
+                        * Assume a wide_char will never be the first half of a
+                        * combining_char pair, so reset prev_ch in case we're
+                        * followed by a '\b'.
+                        */
+                       prev_ch = linebuf[to++] = ' ';
+                       from += len;
+                       shifted++;
+                       continue;
+               }
+
+               /* Adjust width for magic cookies. */
+               prev_attr = (to > 0) ? attr[to-1] : AT_NORMAL;
+               next_attr = (from + len < curr) ? attr[from + len] : prev_attr;
+               if (!is_at_equiv(attr[from], prev_attr) && 
+                       !is_at_equiv(attr[from], next_attr))
+               {
+                       width += attr_swidth(attr[from]);
+                       if (from + len < curr)
+                               width += attr_ewidth(attr[from]);
+                       if (is_at_equiv(prev_attr, next_attr))
+                       {
+                               width += attr_ewidth(prev_attr);
+                               if (from + len < curr)
+                                       width += attr_swidth(next_attr);
+                       }
+               }
+
+               if (shift - shifted < width)
+                       break;
+               from += len;
+               shifted += width;
+               if (shifted < 0)
+                       shifted = 0;
+       }
+       while (from < curr)
+       {
+               linebuf[to] = linebuf[from];
+               attr[to++] = attr[from++];
+       }
+       curr = to;
+       column -= shifted;
+       cshift += shifted;
+}
+
+/*
+ *
+ */
+       public void
+pshift_all()
+{
+       pshift(column);
+}
+
+/*
+ * Return the printing width of the start (enter) sequence
+ * for a given character attribute.
+ */
+       static int
+attr_swidth(a)
+       int a;
+{
+       int w = 0;
+
+       a = apply_at_specials(a);
+
+       if (a & AT_UNDERLINE)
+               w += ul_s_width;
+       if (a & AT_BOLD)
+               w += bo_s_width;
+       if (a & AT_BLINK)
+               w += bl_s_width;
+       if (a & AT_STANDOUT)
+               w += so_s_width;
+
+       return w;
+}
+
+/*
+ * Return the printing width of the end (exit) sequence
+ * for a given character attribute.
+ */
+       static int
+attr_ewidth(a)
+       int a;
+{
+       int w = 0;
+
+       a = apply_at_specials(a);
+
+       if (a & AT_UNDERLINE)
+               w += ul_e_width;
+       if (a & AT_BOLD)
+               w += bo_e_width;
+       if (a & AT_BLINK)
+               w += bl_e_width;
+       if (a & AT_STANDOUT)
+               w += so_e_width;
+
+       return w;
+}
+
+/*
+ * Return the printing width of a given character and attribute,
+ * if the character were added to the current position in the line buffer.
+ * Adding a character with a given attribute may cause an enter or exit
+ * attribute sequence to be inserted, so this must be taken into account.
+ */
+       static int
+pwidth(ch, a, prev_ch)
+       LWCHAR ch;
+       int a;
+       LWCHAR prev_ch;
+{
+       int w;
+
+       if (ch == '\b')
+               /*
+                * Backspace moves backwards one or two positions.
+                * XXX - Incorrect if several '\b' in a row.
+                */
+               return (utf_mode && is_wide_char(prev_ch)) ? -2 : -1;
+
+       if (!utf_mode || is_ascii_char(ch))
+       {
+               if (control_char((char)ch))
+               {
+                       /*
+                        * Control characters do unpredictable things,
+                        * so we don't even try to guess; say it doesn't move.
+                        * This can only happen if the -r flag is in effect.
+                        */
+                       return (0);
+               }
+       } else
+       {
+               if (is_composing_char(ch) || is_combining_char(prev_ch, ch))
+               {
+                       /*
+                        * Composing and combining chars take up no space.
+                        *
+                        * Some terminals, upon failure to compose a
+                        * composing character with the character(s) that
+                        * precede(s) it will actually take up one column
+                        * for the composing character; there isn't much
+                        * we could do short of testing the (complex)
+                        * composition process ourselves and printing
+                        * a binary representation when it fails.
+                        */
+                       return (0);
+               }
+       }
+
+       /*
+        * Other characters take one or two columns,
+        * plus the width of any attribute enter/exit sequence.
+        */
+       w = 1;
+       if (is_wide_char(ch))
+               w++;
+       if (curr > 0 && !is_at_equiv(attr[curr-1], a))
+               w += attr_ewidth(attr[curr-1]);
+       if ((apply_at_specials(a) != AT_NORMAL) &&
+           (curr == 0 || !is_at_equiv(attr[curr-1], a)))
+               w += attr_swidth(a);
+       return (w);
+}
+
+/*
+ * Delete to the previous base character in the line buffer.
+ * Return 1 if one is found.
+ */
+       static int
+backc()
+{
+       LWCHAR prev_ch;
+       char *p = linebuf + curr;
+       LWCHAR ch = step_char(&p, -1, linebuf + lmargin);
+       int width;
+
+       /* This assumes that there is no '\b' in linebuf.  */
+       while (   curr > lmargin
+              && column > lmargin
+              && (!(attr[curr - 1] & (AT_ANSI|AT_BINARY))))
+       {
+               curr = p - linebuf;
+               prev_ch = step_char(&p, -1, linebuf + lmargin);
+               width = pwidth(ch, attr[curr], prev_ch);
+               column -= width;
+               if (width > 0)
+                       return 1;
+               ch = prev_ch;
+       }
+
+       return 0;
+}
+
+/*
+ * Are we currently within a recognized ANSI escape sequence?
+ */
+       static int
+in_ansi_esc_seq()
+{
+       char *p;
+
+       /*
+        * Search backwards for either an ESC (which means we ARE in a seq);
+        * or an end char (which means we're NOT in a seq).
+        */
+       for (p = &linebuf[curr];  p > linebuf; )
+       {
+               LWCHAR ch = step_char(&p, -1, linebuf);
+               if (IS_CSI_START(ch))
+                       return (1);
+               if (!is_ansi_middle(ch))
+                       return (0);
+       }
+       return (0);
+}
+
+/*
+ * Is a character the end of an ANSI escape sequence?
+ */
+       public int
+is_ansi_end(ch)
+       LWCHAR ch;
+{
+       if (!is_ascii_char(ch))
+               return (0);
+       return (strchr(end_ansi_chars, (char) ch) != NULL);
+}
+
+/*
+ *
+ */
+       public int
+is_ansi_middle(ch)
+       LWCHAR ch;
+{
+       if (!is_ascii_char(ch))
+               return (0);
+       if (is_ansi_end(ch))
+               return (0);
+       return (strchr(mid_ansi_chars, (char) ch) != NULL);
+}
+
+/*
+ * Append a character and attribute to the line buffer.
+ */
+#define        STORE_CHAR(ch,a,rep,pos) \
+       do { \
+               if (store_char((ch),(a),(rep),(pos))) return (1); \
+       } while (0)
+
+       static int
+store_char(ch, a, rep, pos)
+       LWCHAR ch;
+       int a;
+       char *rep;
+       POSITION pos;
+{
+       int w;
+       int replen;
+       char cs;
+
+       w = (a & (AT_UNDERLINE|AT_BOLD));       /* Pre-use w.  */
+       if (w != AT_NORMAL)
+               last_overstrike = w;
+
+#if HILITE_SEARCH
+       {
+               int matches;
+               if (is_hilited(pos, pos+1, 0, &matches))
+               {
+                       /*
+                        * This character should be highlighted.
+                        * Override the attribute passed in.
+                        */
+                       if (a != AT_ANSI)
+                               a |= AT_HILITE;
+               }
+       }
+#endif
+
+       if (ctldisp == OPT_ONPLUS && in_ansi_esc_seq())
+       {
+               if (!is_ansi_end(ch) && !is_ansi_middle(ch)) {
+                       /* Remove whole unrecognized sequence.  */
+                       char *p = &linebuf[curr];
+                       LWCHAR bch;
+                       do {
+                               bch = step_char(&p, -1, linebuf);
+                       } while (p > linebuf && !IS_CSI_START(bch));
+                       curr = p - linebuf;
+                       return 0;
+               }
+               a = AT_ANSI;    /* Will force re-AT_'ing around it.  */
+               w = 0;
+       }
+       else if (ctldisp == OPT_ONPLUS && IS_CSI_START(ch))
+       {
+               a = AT_ANSI;    /* Will force re-AT_'ing around it.  */
+               w = 0;
+       }
+       else
+       {
+               char *p = &linebuf[curr];
+               LWCHAR prev_ch = step_char(&p, -1, linebuf);
+               w = pwidth(ch, a, prev_ch);
+       }
+
+       if (ctldisp != OPT_ON && column + w + attr_ewidth(a) > sc_width)
+               /*
+                * Won't fit on screen.
+                */
+               return (1);
+
+       if (rep == NULL)
+       {
+               cs = (char) ch;
+               rep = &cs;
+               replen = 1;
+       } else
+       {
+               replen = utf_len(rep[0]);
+       }
+       if (curr + replen >= size_linebuf-6)
+       {
+               /*
+                * Won't fit in line buffer.
+                * Try to expand it.
+                */
+               if (expand_linebuf())
+                       return (1);
+       }
+
+       while (replen-- > 0)
+       {
+               linebuf[curr] = *rep++;
+               attr[curr] = a;
+               curr++;
+       }
+       column += w;
+       return (0);
+}
+
+/*
+ * Append a tab to the line buffer.
+ * Store spaces to represent the tab.
+ */
+#define        STORE_TAB(a,pos) \
+       do { if (store_tab((a),(pos))) return (1); } while (0)
+
+       static int
+store_tab(attr, pos)
+       int attr;
+       POSITION pos;
+{
+       int to_tab = column + cshift - lmargin;
+       int i;
+
+       if (ntabstops < 2 || to_tab >= tabstops[ntabstops-1])
+               to_tab = tabdefault -
+                    ((to_tab - tabstops[ntabstops-1]) % tabdefault);
+       else
+       {
+               for (i = ntabstops - 2;  i >= 0;  i--)
+                       if (to_tab >= tabstops[i])
+                               break;
+               to_tab = tabstops[i+1] - to_tab;
+       }
+
+       if (column + to_tab - 1 + pwidth(' ', attr, 0) + attr_ewidth(attr) > sc_width)
+               return 1;
+
+       do {
+               STORE_CHAR(' ', attr, " ", pos);
+       } while (--to_tab > 0);
+       return 0;
+}
+
+#define STORE_PRCHAR(c, pos) \
+       do { if (store_prchar((c), (pos))) return 1; } while (0)
+
+       static int
+store_prchar(c, pos)
+       char c;
+       POSITION pos;
+{
+       char *s;
+
+       /*
+        * Convert to printable representation.
+        */
+       s = prchar(c);
+
+       /*
+        * Make sure we can get the entire representation
+        * of the character on this line.
+        */
+       if (column + (int) strlen(s) - 1 +
+            pwidth(' ', binattr, 0) + attr_ewidth(binattr) > sc_width)
+               return 1;
+
+       for ( ;  *s != 0;  s++)
+               STORE_CHAR(*s, AT_BINARY, NULL, pos);
+
+       return 0;
+}
+
+       static int
+flush_mbc_buf(pos)
+       POSITION pos;
+{
+       int i;
+
+       for (i = 0; i < mbc_buf_index; i++)
+               if (store_prchar(mbc_buf[i], pos))
+                       return mbc_buf_index - i;
+
+       return 0;
+}
+
+/*
+ * Append a character to the line buffer.
+ * Expand tabs into spaces, handle underlining, boldfacing, etc.
+ * Returns 0 if ok, 1 if couldn't fit in buffer.
+ */
+       public int
+pappend(c, pos)
+       char c;
+       POSITION pos;
+{
+       int r;
+
+       if (pendc)
+       {
+               if (do_append(pendc, NULL, pendpos))
+                       /*
+                        * Oops.  We've probably lost the char which
+                        * was in pendc, since caller won't back up.
+                        */
+                       return (1);
+               pendc = '\0';
+       }
+
+       if (c == '\r' && bs_mode == BS_SPECIAL)
+       {
+               if (mbc_buf_len > 0)  /* utf_mode must be on. */
+               {
+                       /* Flush incomplete (truncated) sequence. */
+                       r = flush_mbc_buf(mbc_pos);
+                       mbc_buf_index = r + 1;
+                       mbc_buf_len = 0;
+                       if (r)
+                               return (mbc_buf_index);
+               }
+
+               /*
+                * Don't put the CR into the buffer until we see 
+                * the next char.  If the next char is a newline,
+                * discard the CR.
+                */
+               pendc = c;
+               pendpos = pos;
+               return (0);
+       }
+
+       if (!utf_mode)
+       {
+               r = do_append((LWCHAR) c, NULL, pos);
+       } else
+       {
+               /* Perform strict validation in all possible cases. */
+               if (mbc_buf_len == 0)
+               {
+               retry:
+                       mbc_buf_index = 1;
+                       *mbc_buf = c;
+                       if (IS_ASCII_OCTET(c))
+                               r = do_append((LWCHAR) c, NULL, pos);
+                       else if (IS_UTF8_LEAD(c))
+                       {
+                               mbc_buf_len = utf_len(c);
+                               mbc_pos = pos;
+                               return (0);
+                       } else
+                               /* UTF8_INVALID or stray UTF8_TRAIL */
+                               r = flush_mbc_buf(pos);
+               } else if (IS_UTF8_TRAIL(c))
+               {
+                       mbc_buf[mbc_buf_index++] = c;
+                       if (mbc_buf_index < mbc_buf_len)
+                               return (0);
+                       if (is_utf8_well_formed(mbc_buf))
+                               r = do_append(get_wchar(mbc_buf), mbc_buf, mbc_pos);
+                       else
+                               /* Complete, but not shortest form, sequence. */
+                               mbc_buf_index = r = flush_mbc_buf(mbc_pos);
+                       mbc_buf_len = 0;
+               } else
+               {
+                       /* Flush incomplete (truncated) sequence.  */
+                       r = flush_mbc_buf(mbc_pos);
+                       mbc_buf_index = r + 1;
+                       mbc_buf_len = 0;
+                       /* Handle new char.  */
+                       if (!r)
+                               goto retry;
+               }
+       }
+
+       /*
+        * If we need to shift the line, do it.
+        * But wait until we get to at least the middle of the screen,
+        * so shifting it doesn't affect the chars we're currently
+        * pappending.  (Bold & underline can get messed up otherwise.)
+        */
+       if (cshift < hshift && column > sc_width / 2)
+       {
+               linebuf[curr] = '\0';
+               pshift(hshift - cshift);
+       }
+       if (r)
+       {
+               /* How many chars should caller back up? */
+               r = (!utf_mode) ? 1 : mbc_buf_index;
+       }
+       return (r);
+}
+
+       static int
+do_append(ch, rep, pos)
+       LWCHAR ch;
+       char *rep;
+       POSITION pos;
+{
+       register int a;
+       LWCHAR prev_ch;
+
+       a = AT_NORMAL;
+
+       if (ch == '\b')
+       {
+               if (bs_mode == BS_CONTROL)
+                       goto do_control_char;
+
+               /*
+                * A better test is needed here so we don't
+                * backspace over part of the printed
+                * representation of a binary character.
+                */
+               if (   curr <= lmargin
+                   || column <= lmargin
+                   || (attr[curr - 1] & (AT_ANSI|AT_BINARY)))
+                       STORE_PRCHAR('\b', pos);
+               else if (bs_mode == BS_NORMAL)
+                       STORE_CHAR(ch, AT_NORMAL, NULL, pos);
+               else if (bs_mode == BS_SPECIAL)
+                       overstrike = backc();
+
+               return 0;
+       }
+
+       if (overstrike > 0)
+       {
+               /*
+                * Overstrike the character at the current position
+                * in the line buffer.  This will cause either 
+                * underline (if a "_" is overstruck), 
+                * bold (if an identical character is overstruck),
+                * or just deletion of the character in the buffer.
+                */
+               overstrike = utf_mode ? -1 : 0;
+               /* To be correct, this must be a base character.  */
+               prev_ch = get_wchar(linebuf + curr);
+               a = attr[curr];
+               if (ch == prev_ch)
+               {
+                       /*
+                        * Overstriking a char with itself means make it bold.
+                        * But overstriking an underscore with itself is
+                        * ambiguous.  It could mean make it bold, or
+                        * it could mean make it underlined.
+                        * Use the previous overstrike to resolve it.
+                        */
+                       if (ch == '_')
+                       {
+                               if ((a & (AT_BOLD|AT_UNDERLINE)) != AT_NORMAL)
+                                       a |= (AT_BOLD|AT_UNDERLINE);
+                               else if (last_overstrike != AT_NORMAL)
+                                       a |= last_overstrike;
+                               else
+                                       a |= AT_BOLD;
+                       } else
+                               a |= AT_BOLD;
+               } else if (ch == '_')
+               {
+                       a |= AT_UNDERLINE;
+                       ch = prev_ch;
+                       rep = linebuf + curr;
+               } else if (prev_ch == '_')
+               {
+                       a |= AT_UNDERLINE;
+               }
+               /* Else we replace prev_ch, but we keep its attributes.  */
+       } else if (overstrike < 0)
+       {
+               if (   is_composing_char(ch)
+                   || is_combining_char(get_wchar(linebuf + curr), ch))
+                       /* Continuation of the same overstrike.  */
+                       a = last_overstrike;
+               else
+                       overstrike = 0;
+       }
+
+       if (ch == '\t') 
+       {
+               /*
+                * Expand a tab into spaces.
+                */
+               switch (bs_mode)
+               {
+               case BS_CONTROL:
+                       goto do_control_char;
+               case BS_NORMAL:
+               case BS_SPECIAL:
+                       STORE_TAB(a, pos);
+                       break;
+               }
+       } else if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch))
+       {
+       do_control_char:
+               if (ctldisp == OPT_ON || (ctldisp == OPT_ONPLUS && IS_CSI_START(ch)))
+               {
+                       /*
+                        * Output as a normal character.
+                        */
+                       STORE_CHAR(ch, AT_NORMAL, rep, pos);
+               } else 
+               {
+                       STORE_PRCHAR((char) ch, pos);
+               }
+       } else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch))
+       {
+               char *s;
+
+               s = prutfchar(ch);
+
+               if (column + (int) strlen(s) - 1 +
+                   pwidth(' ', binattr, 0) + attr_ewidth(binattr) > sc_width)
+                       return (1);
+
+               for ( ;  *s != 0;  s++)
+                       STORE_CHAR(*s, AT_BINARY, NULL, pos);
+       } else
+       {
+               STORE_CHAR(ch, a, rep, pos);
+       }
+       return (0);
+}
+
+/*
+ *
+ */
+       public int
+pflushmbc()
+{
+       int r = 0;
+
+       if (mbc_buf_len > 0)
+       {
+               /* Flush incomplete (truncated) sequence.  */
+               r = flush_mbc_buf(mbc_pos);
+               mbc_buf_len = 0;
+       }
+       return r;
+}
+
+/*
+ * Terminate the line in the line buffer.
+ */
+       public void
+pdone(endline, forw)
+       int endline;
+       int forw;
+{
+       (void) pflushmbc();
+
+       if (pendc && (pendc != '\r' || !endline))
+               /*
+                * If we had a pending character, put it in the buffer.
+                * But discard a pending CR if we are at end of line
+                * (that is, discard the CR in a CR/LF sequence).
+                */
+               (void) do_append(pendc, NULL, pendpos);
+
+       /*
+        * Make sure we've shifted the line, if we need to.
+        */
+       if (cshift < hshift)
+               pshift(hshift - cshift);
+
+       if (ctldisp == OPT_ONPLUS && is_ansi_end('m'))
+       {
+               /* Switch to normal attribute at end of line. */
+               char *p = "\033[m";
+               for ( ;  *p != '\0';  p++)
+               {
+                       linebuf[curr] = *p;
+                       attr[curr++] = AT_ANSI;
+               }
+       }
+
+       /*
+        * Add a newline if necessary,
+        * and append a '\0' to the end of the line.
+        * We output a newline if we're not at the right edge of the screen,
+        * or if the terminal doesn't auto wrap,
+        * or if this is really the end of the line AND the terminal ignores
+        * a newline at the right edge.
+        * (In the last case we don't want to output a newline if the terminal 
+        * doesn't ignore it since that would produce an extra blank line.
+        * But we do want to output a newline if the terminal ignores it in case
+        * the next line is blank.  In that case the single newline output for
+        * that blank line would be ignored!)
+        */
+       if (column < sc_width || !auto_wrap || (endline && ignaw) || ctldisp == OPT_ON)
+       {
+               linebuf[curr] = '\n';
+               attr[curr] = AT_NORMAL;
+               curr++;
+       } 
+       else if (ignaw && column >= sc_width && forw)
+       {
+               /*
+                * Terminals with "ignaw" don't wrap until they *really* need
+                * to, i.e. when the character *after* the last one to fit on a
+                * line is output. But they are too hard to deal with when they
+                * get in the state where a full screen width of characters
+                * have been output but the cursor is sitting on the right edge
+                * instead of at the start of the next line.
+                * So we nudge them into wrapping by outputting a space 
+                * character plus a backspace.  But do this only if moving 
+                * forward; if we're moving backward and drawing this line at
+                * the top of the screen, the space would overwrite the first
+                * char on the next line.  We don't need to do this "nudge" 
+                * at the top of the screen anyway.
+                */
+               linebuf[curr] = ' ';
+               attr[curr++] = AT_NORMAL;
+               linebuf[curr] = '\b'; 
+               attr[curr++] = AT_NORMAL;
+       }
+       linebuf[curr] = '\0';
+       attr[curr] = AT_NORMAL;
+}
+
+/*
+ *
+ */
+       public void
+set_status_col(c)
+       char c;
+{
+       linebuf[0] = c;
+       attr[0] = AT_NORMAL|AT_HILITE;
+}
+
+/*
+ * Get a character from the current line.
+ * Return the character as the function return value,
+ * and the character attribute in *ap.
+ */
+       public int
+gline(i, ap)
+       register int i;
+       register int *ap;
+{
+       if (is_null_line)
+       {
+               /*
+                * If there is no current line, we pretend the line is
+                * either "~" or "", depending on the "twiddle" flag.
+                */
+               if (twiddle)
+               {
+                       if (i == 0)
+                       {
+                               *ap = AT_BOLD;
+                               return '~';
+                       }
+                       --i;
+               }
+               /* Make sure we're back to AT_NORMAL before the '\n'.  */
+               *ap = AT_NORMAL;
+               return i ? '\0' : '\n';
+       }
+
+       *ap = attr[i];
+       return (linebuf[i] & 0xFF);
+}
+
+/*
+ * Indicate that there is no current line.
+ */
+       public void
+null_line()
+{
+       is_null_line = 1;
+       cshift = 0;
+}
+
+/*
+ * Analogous to forw_line(), but deals with "raw lines":
+ * lines which are not split for screen width.
+ * {{ This is supposed to be more efficient than forw_line(). }}
+ */
+       public POSITION
+forw_raw_line(curr_pos, linep, line_lenp)
+       POSITION curr_pos;
+       char **linep;
+       int *line_lenp;
+{
+       register int n;
+       register int c;
+       POSITION new_pos;
+
+       if (curr_pos == NULL_POSITION || ch_seek(curr_pos) ||
+               (c = ch_forw_get()) == EOI)
+               return (NULL_POSITION);
+
+       n = 0;
+       for (;;)
+       {
+               if (c == '\n' || c == EOI || ABORT_SIGS())
+               {
+                       new_pos = ch_tell();
+                       break;
+               }
+               if (n >= size_linebuf-1)
+               {
+                       if (expand_linebuf())
+                       {
+                               /*
+                                * Overflowed the input buffer.
+                                * Pretend the line ended here.
+                                */
+                               new_pos = ch_tell() - 1;
+                               break;
+                       }
+               }
+               linebuf[n++] = c;
+               c = ch_forw_get();
+       }
+       linebuf[n] = '\0';
+       if (linep != NULL)
+               *linep = linebuf;
+       if (line_lenp != NULL)
+               *line_lenp = n;
+       return (new_pos);
+}
+
+/*
+ * Analogous to back_line(), but deals with "raw lines".
+ * {{ This is supposed to be more efficient than back_line(). }}
+ */
+       public POSITION
+back_raw_line(curr_pos, linep, line_lenp)
+       POSITION curr_pos;
+       char **linep;
+       int *line_lenp;
+{
+       register int n;
+       register int c;
+       POSITION new_pos;
+
+       if (curr_pos == NULL_POSITION || curr_pos <= ch_zero() ||
+               ch_seek(curr_pos-1))
+               return (NULL_POSITION);
+
+       n = size_linebuf;
+       linebuf[--n] = '\0';
+       for (;;)
+       {
+               c = ch_back_get();
+               if (c == '\n' || ABORT_SIGS())
+               {
+                       /*
+                        * This is the newline ending the previous line.
+                        * We have hit the beginning of the line.
+                        */
+                       new_pos = ch_tell() + 1;
+                       break;
+               }
+               if (c == EOI)
+               {
+                       /*
+                        * We have hit the beginning of the file.
+                        * This must be the first line in the file.
+                        * This must, of course, be the beginning of the line.
+                        */
+                       new_pos = ch_zero();
+                       break;
+               }
+               if (n <= 0)
+               {
+                       int old_size_linebuf = size_linebuf;
+                       char *fm;
+                       char *to;
+                       if (expand_linebuf())
+                       {
+                               /*
+                                * Overflowed the input buffer.
+                                * Pretend the line ended here.
+                                */
+                               new_pos = ch_tell() + 1;
+                               break;
+                       }
+                       /*
+                        * Shift the data to the end of the new linebuf.
+                        */
+                       for (fm = linebuf + old_size_linebuf - 1,
+                             to = linebuf + size_linebuf - 1;
+                            fm >= linebuf;  fm--, to--)
+                               *to = *fm;
+                       n = size_linebuf - old_size_linebuf;
+               }
+               linebuf[--n] = c;
+       }
+       if (linep != NULL)
+               *linep = &linebuf[n];
+       if (line_lenp != NULL)
+               *line_lenp = size_linebuf - 1 - n;
+       return (new_pos);
+}
diff --git a/thirdparty/less/linenum.c b/thirdparty/less/linenum.c
new file mode 100644 (file)
index 0000000..4369f87
--- /dev/null
@@ -0,0 +1,471 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Code to handle displaying line numbers.
+ *
+ * Finding the line number of a given file position is rather tricky.
+ * We don't want to just start at the beginning of the file and
+ * count newlines, because that is slow for large files (and also
+ * wouldn't work if we couldn't get to the start of the file; e.g.
+ * if input is a long pipe).
+ *
+ * So we use the function add_lnum to cache line numbers.
+ * We try to be very clever and keep only the more interesting
+ * line numbers when we run out of space in our table.  A line
+ * number is more interesting than another when it is far from
+ * other line numbers.   For example, we'd rather keep lines
+ * 100,200,300 than 100,101,300.  200 is more interesting than
+ * 101 because 101 can be derived very cheaply from 100, while
+ * 200 is more expensive to derive from 100.
+ *
+ * The function currline() returns the line number of a given
+ * position in the file.  As a side effect, it calls add_lnum
+ * to cache the line number.  Therefore currline is occasionally
+ * called to make sure we cache line numbers often enough.
+ */
+
+#include "less.h"
+
+/*
+ * Structure to keep track of a line number and the associated file position.
+ * A doubly-linked circular list of line numbers is kept ordered by line number.
+ */
+struct linenum_info
+{
+       struct linenum_info *next;      /* Link to next in the list */
+       struct linenum_info *prev;      /* Line to previous in the list */
+       POSITION pos;                   /* File position */
+       POSITION gap;                   /* Gap between prev and next */
+       LINENUM line;                   /* Line number */
+};
+/*
+ * "gap" needs some explanation: the gap of any particular line number
+ * is the distance between the previous one and the next one in the list.
+ * ("Distance" means difference in file position.)  In other words, the
+ * gap of a line number is the gap which would be introduced if this
+ * line number were deleted.  It is used to decide which one to replace
+ * when we have a new one to insert and the table is full.
+ */
+
+#define        NPOOL   200                     /* Size of line number pool */
+
+#define        LONGTIME        (2)             /* In seconds */
+
+static struct linenum_info anchor;     /* Anchor of the list */
+static struct linenum_info *freelist;  /* Anchor of the unused entries */
+static struct linenum_info pool[NPOOL];        /* The pool itself */
+static struct linenum_info *spare;             /* We always keep one spare entry */
+
+extern int linenums;
+extern int sigs;
+extern int sc_height;
+extern int screen_trashed;
+
+/*
+ * Initialize the line number structures.
+ */
+       public void
+clr_linenum()
+{
+       register struct linenum_info *p;
+
+       /*
+        * Put all the entries on the free list.
+        * Leave one for the "spare".
+        */
+       for (p = pool;  p < &pool[NPOOL-2];  p++)
+               p->next = p+1;
+       pool[NPOOL-2].next = NULL;
+       freelist = pool;
+
+       spare = &pool[NPOOL-1];
+
+       /*
+        * Initialize the anchor.
+        */
+       anchor.next = anchor.prev = &anchor;
+       anchor.gap = 0;
+       anchor.pos = (POSITION)0;
+       anchor.line = 1;
+}
+
+/*
+ * Calculate the gap for an entry.
+ */
+       static void
+calcgap(p)
+       register struct linenum_info *p;
+{
+       /*
+        * Don't bother to compute a gap for the anchor.
+        * Also don't compute a gap for the last one in the list.
+        * The gap for that last one should be considered infinite,
+        * but we never look at it anyway.
+        */
+       if (p == &anchor || p->next == &anchor)
+               return;
+       p->gap = p->next->pos - p->prev->pos;
+}
+
+/*
+ * Add a new line number to the cache.
+ * The specified position (pos) should be the file position of the
+ * FIRST character in the specified line.
+ */
+       public void
+add_lnum(linenum, pos)
+       LINENUM linenum;
+       POSITION pos;
+{
+       register struct linenum_info *p;
+       register struct linenum_info *new;
+       register struct linenum_info *nextp;
+       register struct linenum_info *prevp;
+       register POSITION mingap;
+
+       /*
+        * Find the proper place in the list for the new one.
+        * The entries are sorted by position.
+        */
+       for (p = anchor.next;  p != &anchor && p->pos < pos;  p = p->next)
+               if (p->line == linenum)
+                       /* We already have this one. */
+                       return;
+       nextp = p;
+       prevp = p->prev;
+
+       if (freelist != NULL)
+       {
+               /*
+                * We still have free (unused) entries.
+                * Use one of them.
+                */
+               new = freelist;
+               freelist = freelist->next;
+       } else
+       {
+               /*
+                * No free entries.
+                * Use the "spare" entry.
+                */
+               new = spare;
+               spare = NULL;
+       }
+
+       /*
+        * Fill in the fields of the new entry,
+        * and insert it into the proper place in the list.
+        */
+       new->next = nextp;
+       new->prev = prevp;
+       new->pos = pos;
+       new->line = linenum;
+
+       nextp->prev = new;
+       prevp->next = new;
+
+       /*
+        * Recalculate gaps for the new entry and the neighboring entries.
+        */
+       calcgap(new);
+       calcgap(nextp);
+       calcgap(prevp);
+
+       if (spare == NULL)
+       {
+               /*
+                * We have used the spare entry.
+                * Scan the list to find the one with the smallest
+                * gap, take it out and make it the spare.
+                * We should never remove the last one, so stop when
+                * we get to p->next == &anchor.  This also avoids
+                * looking at the gap of the last one, which is
+                * not computed by calcgap.
+                */
+               mingap = anchor.next->gap;
+               for (p = anchor.next;  p->next != &anchor;  p = p->next)
+               {
+                       if (p->gap <= mingap)
+                       {
+                               spare = p;
+                               mingap = p->gap;
+                       }
+               }
+               spare->next->prev = spare->prev;
+               spare->prev->next = spare->next;
+       }
+}
+
+/*
+ * If we get stuck in a long loop trying to figure out the
+ * line number, print a message to tell the user what we're doing.
+ */
+       static void
+longloopmessage()
+{
+       ierror("Calculating line numbers", NULL_PARG);
+}
+
+static int loopcount;
+#if HAVE_TIME
+static long startime;
+#endif
+
+       static void
+longish()
+{
+#if HAVE_TIME
+       if (loopcount >= 0 && ++loopcount > 100)
+       {
+               loopcount = 0;
+               if (get_time() >= startime + LONGTIME)
+               {
+                       longloopmessage();
+                       loopcount = -1;
+               }
+       }
+#else
+       if (loopcount >= 0 && ++loopcount > LONGLOOP)
+       {
+               longloopmessage();
+               loopcount = -1;
+       }
+#endif
+}
+
+/*
+ * Turn off line numbers because the user has interrupted
+ * a lengthy line number calculation.
+ */
+       static void
+abort_long()
+{
+       if (linenums == OPT_ONPLUS)
+               /*
+                * We were displaying line numbers, so need to repaint.
+                */
+               screen_trashed = 1;
+       linenums = 0;
+       error("Line numbers turned off", NULL_PARG);
+}
+
+/*
+ * Find the line number associated with a given position.
+ * Return 0 if we can't figure it out.
+ */
+       public LINENUM
+find_linenum(pos)
+       POSITION pos;
+{
+       register struct linenum_info *p;
+       register LINENUM linenum;
+       POSITION cpos;
+
+       if (!linenums)
+               /*
+                * We're not using line numbers.
+                */
+               return (0);
+       if (pos == NULL_POSITION)
+               /*
+                * Caller doesn't know what he's talking about.
+                */
+               return (0);
+       if (pos <= ch_zero())
+               /*
+                * Beginning of file is always line number 1.
+                */
+               return (1);
+
+       /*
+        * Find the entry nearest to the position we want.
+        */
+       for (p = anchor.next;  p != &anchor && p->pos < pos;  p = p->next)
+               continue;
+       if (p->pos == pos)
+               /* Found it exactly. */
+               return (p->line);
+
+       /*
+        * This is the (possibly) time-consuming part.
+        * We start at the line we just found and start
+        * reading the file forward or backward till we
+        * get to the place we want.
+        *
+        * First decide whether we should go forward from the 
+        * previous one or backwards from the next one.
+        * The decision is based on which way involves 
+        * traversing fewer bytes in the file.
+        */
+#if HAVE_TIME
+       startime = get_time();
+#endif
+       if (p == &anchor || pos - p->prev->pos < p->pos - pos)
+       {
+               /*
+                * Go forward.
+                */
+               p = p->prev;
+               if (ch_seek(p->pos))
+                       return (0);
+               loopcount = 0;
+               for (linenum = p->line, cpos = p->pos;  cpos < pos;  linenum++)
+               {
+                       /*
+                        * Allow a signal to abort this loop.
+                        */
+                       cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
+                       if (ABORT_SIGS()) {
+                               abort_long();
+                               return (0);
+                       }
+                       if (cpos == NULL_POSITION)
+                               return (0);
+                       longish();
+               }
+               /*
+                * We might as well cache it.
+                */
+               add_lnum(linenum, cpos);
+               /*
+                * If the given position is not at the start of a line,
+                * make sure we return the correct line number.
+                */
+               if (cpos > pos)
+                       linenum--;
+       } else
+       {
+               /*
+                * Go backward.
+                */
+               if (ch_seek(p->pos))
+                       return (0);
+               loopcount = 0;
+               for (linenum = p->line, cpos = p->pos;  cpos > pos;  linenum--)
+               {
+                       /*
+                        * Allow a signal to abort this loop.
+                        */
+                       cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
+                       if (ABORT_SIGS()) {
+                               abort_long();
+                               return (0);
+                       }
+                       if (cpos == NULL_POSITION)
+                               return (0);
+                       longish();
+               }
+               /*
+                * We might as well cache it.
+                */
+               add_lnum(linenum, cpos);
+       }
+
+       return (linenum);
+}
+
+/*
+ * Find the position of a given line number.
+ * Return NULL_POSITION if we can't figure it out.
+ */
+       public POSITION
+find_pos(linenum)
+       LINENUM linenum;
+{
+       register struct linenum_info *p;
+       POSITION cpos;
+       LINENUM clinenum;
+
+       if (linenum <= 1)
+               /*
+                * Line number 1 is beginning of file.
+                */
+               return (ch_zero());
+
+       /*
+        * Find the entry nearest to the line number we want.
+        */
+       for (p = anchor.next;  p != &anchor && p->line < linenum;  p = p->next)
+               continue;
+       if (p->line == linenum)
+               /* Found it exactly. */
+               return (p->pos);
+
+       if (p == &anchor || linenum - p->prev->line < p->line - linenum)
+       {
+               /*
+                * Go forward.
+                */
+               p = p->prev;
+               if (ch_seek(p->pos))
+                       return (NULL_POSITION);
+               for (clinenum = p->line, cpos = p->pos;  clinenum < linenum;  clinenum++)
+               {
+                       /*
+                        * Allow a signal to abort this loop.
+                        */
+                       cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
+                       if (ABORT_SIGS())
+                               return (NULL_POSITION);
+                       if (cpos == NULL_POSITION)
+                               return (NULL_POSITION);
+               }
+       } else
+       {
+               /*
+                * Go backward.
+                */
+               if (ch_seek(p->pos))
+                       return (NULL_POSITION);
+               for (clinenum = p->line, cpos = p->pos;  clinenum > linenum;  clinenum--)
+               {
+                       /*
+                        * Allow a signal to abort this loop.
+                        */
+                       cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
+                       if (ABORT_SIGS())
+                               return (NULL_POSITION);
+                       if (cpos == NULL_POSITION)
+                               return (NULL_POSITION);
+               }
+       }
+       /*
+        * We might as well cache it.
+        */
+       add_lnum(clinenum, cpos);
+       return (cpos);
+}
+
+/*
+ * Return the line number of the "current" line.
+ * The argument "where" tells which line is to be considered
+ * the "current" line (e.g. TOP, BOTTOM, MIDDLE, etc).
+ */
+       public LINENUM
+currline(where)
+       int where;
+{
+       POSITION pos;
+       POSITION len;
+       LINENUM linenum;
+
+       pos = position(where);
+       len = ch_length();
+       while (pos == NULL_POSITION && where >= 0 && where < sc_height)
+               pos = position(++where);
+       if (pos == NULL_POSITION)
+               pos = len;
+       linenum = find_linenum(pos);
+       if (pos == len)
+               linenum--;
+       return (linenum);
+}
diff --git a/thirdparty/less/lsystem.c b/thirdparty/less/lsystem.c
new file mode 100644 (file)
index 0000000..5ff0142
--- /dev/null
@@ -0,0 +1,376 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to execute other programs.
+ * Necessarily very OS dependent.
+ */
+
+#include "less.h"
+#include <signal.h>
+#include "position.h"
+
+#if MSDOS_COMPILER
+#include <dos.h>
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#include <direct.h>
+#define setdisk(n) _chdrive((n)+1)
+#else
+#include <dir.h>
+#endif
+#endif
+
+extern int screen_trashed;
+extern IFILE curr_ifile;
+
+
+#if HAVE_SYSTEM
+
+/*
+ * Pass the specified command to a shell to be executed.
+ * Like plain "system()", but handles resetting terminal modes, etc.
+ */
+       public void
+lsystem(cmd, donemsg)
+       char *cmd;
+       char *donemsg;
+{
+       register int inp;
+#if HAVE_SHELL
+       register char *shell;
+       register char *p;
+#endif
+       IFILE save_ifile;
+#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
+       char cwd[FILENAME_MAX+1];
+#endif
+
+       /*
+        * Print the command which is to be executed,
+        * unless the command starts with a "-".
+        */
+       if (cmd[0] == '-')
+               cmd++;
+       else
+       {
+               clear_bot();
+               putstr("!");
+               putstr(cmd);
+               putstr("\n");
+       }
+
+#if MSDOS_COMPILER
+#if MSDOS_COMPILER==WIN32C
+       if (*cmd == '\0')
+               cmd = getenv("COMSPEC");
+#else
+       /*
+        * Working directory is global on MSDOS.
+        * The child might change the working directory, so we
+        * must save and restore CWD across calls to "system",
+        * or else we won't find our file when we return and
+        * try to "reedit_ifile" it.
+        */
+       getcwd(cwd, FILENAME_MAX);
+#endif
+#endif
+
+       /*
+        * Close the current input file.
+        */
+       save_ifile = save_curr_ifile();
+       (void) edit_ifile(NULL_IFILE);
+
+       /*
+        * De-initialize the terminal and take out of raw mode.
+        */
+       deinit();
+       flush();        /* Make sure the deinit chars get out */
+       raw_mode(0);
+#if MSDOS_COMPILER==WIN32C
+       close_getchr();
+#endif
+
+       /*
+        * Restore signals to their defaults.
+        */
+       init_signals(0);
+
+#if HAVE_DUP
+       /*
+        * Force standard input to be the user's terminal
+        * (the normal standard input), even if less's standard input 
+        * is coming from a pipe.
+        */
+       inp = dup(0);
+       close(0);
+#if OS2
+       /* The __open() system call translates "/dev/tty" to "con". */
+       if (__open("/dev/tty", OPEN_READ) < 0)
+#else
+       if (open("/dev/tty", OPEN_READ) < 0)
+#endif
+               dup(inp);
+#endif
+
+       /*
+        * Pass the command to the system to be executed.
+        * If we have a SHELL environment variable, use
+        * <$SHELL -c "command"> instead of just <command>.
+        * If the command is empty, just invoke a shell.
+        */
+#if HAVE_SHELL
+       p = NULL;
+       if ((shell = lgetenv("SHELL")) != NULL && *shell != '\0')
+       {
+               if (*cmd == '\0')
+                       p = save(shell);
+               else
+               {
+                       char *esccmd = shell_quote(cmd);
+                       if (esccmd != NULL)
+                       {
+                               int len = strlen(shell) + strlen(esccmd) + 5;
+                               p = (char *) ecalloc(len, sizeof(char));
+                               SNPRINTF3(p, len, "%s %s %s", shell, shell_coption(), esccmd);
+                               free(esccmd);
+                       }
+               }
+       }
+       if (p == NULL)
+       {
+               if (*cmd == '\0')
+                       p = save("sh");
+               else
+                       p = save(cmd);
+       }
+       system(p);
+       free(p);
+#else
+#if MSDOS_COMPILER==DJGPPC
+       /*
+        * Make stdin of the child be in cooked mode.
+        */
+       setmode(0, O_TEXT);
+       /*
+        * We don't need to catch signals of the child (it
+        * also makes trouble with some DPMI servers).
+        */
+       __djgpp_exception_toggle();
+       system(cmd);
+       __djgpp_exception_toggle();
+#else
+       system(cmd);
+#endif
+#endif
+
+#if HAVE_DUP
+       /*
+        * Restore standard input, reset signals, raw mode, etc.
+        */
+       close(0);
+       dup(inp);
+       close(inp);
+#endif
+
+#if MSDOS_COMPILER==WIN32C
+       open_getchr();
+#endif
+       init_signals(1);
+       raw_mode(1);
+       if (donemsg != NULL)
+       {
+               putstr(donemsg);
+               putstr("  (press RETURN)");
+               get_return();
+               putchr('\n');
+               flush();
+       }
+       init();
+       screen_trashed = 1;
+
+#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
+       /*
+        * Restore the previous directory (possibly
+        * changed by the child program we just ran).
+        */
+       chdir(cwd);
+#if MSDOS_COMPILER != DJGPPC
+       /*
+        * Some versions of chdir() don't change to the drive
+        * which is part of CWD.  (DJGPP does this in chdir.)
+        */
+       if (cwd[1] == ':')
+       {
+               if (cwd[0] >= 'a' && cwd[0] <= 'z')
+                       setdisk(cwd[0] - 'a');
+               else if (cwd[0] >= 'A' && cwd[0] <= 'Z')
+                       setdisk(cwd[0] - 'A');
+       }
+#endif
+#endif
+
+       /*
+        * Reopen the current input file.
+        */
+       reedit_ifile(save_ifile);
+
+#if defined(SIGWINCH) || defined(SIGWIND)
+       /*
+        * Since we were ignoring window change signals while we executed
+        * the system command, we must assume the window changed.
+        * Warning: this leaves a signal pending (in "sigs"),
+        * so psignals() should be called soon after lsystem().
+        */
+       winch(0);
+#endif
+}
+
+#endif
+
+#if PIPEC
+
+/*
+ * Pipe a section of the input file into the given shell command.
+ * The section to be piped is the section "between" the current
+ * position and the position marked by the given letter.
+ *
+ * If the mark is after the current screen, the section between
+ * the top line displayed and the mark is piped.
+ * If the mark is before the current screen, the section between
+ * the mark and the bottom line displayed is piped.
+ * If the mark is on the current screen, or if the mark is ".",
+ * the whole current screen is piped.
+ */
+       public int
+pipe_mark(c, cmd)
+       int c;
+       char *cmd;
+{
+       POSITION mpos, tpos, bpos;
+
+       /*
+        * mpos = the marked position.
+        * tpos = top of screen.
+        * bpos = bottom of screen.
+        */
+       mpos = markpos(c);
+       if (mpos == NULL_POSITION)
+               return (-1);
+       tpos = position(TOP);
+       if (tpos == NULL_POSITION)
+               tpos = ch_zero();
+       bpos = position(BOTTOM);
+
+       if (c == '.') 
+               return (pipe_data(cmd, tpos, bpos));
+       else if (mpos <= tpos)
+               return (pipe_data(cmd, mpos, bpos));
+       else if (bpos == NULL_POSITION)
+               return (pipe_data(cmd, tpos, bpos));
+       else
+               return (pipe_data(cmd, tpos, mpos));
+}
+
+/*
+ * Create a pipe to the given shell command.
+ * Feed it the file contents between the positions spos and epos.
+ */
+       public int
+pipe_data(cmd, spos, epos)
+       char *cmd;
+       POSITION spos;
+       POSITION epos;
+{
+       register FILE *f;
+       register int c;
+#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C
+       extern FILE *popen();
+#endif
+
+       /*
+        * This is structured much like lsystem().
+        * Since we're running a shell program, we must be careful
+        * to perform the necessary deinitialization before running
+        * the command, and reinitialization after it.
+        */
+       if (ch_seek(spos) != 0)
+       {
+               error("Cannot seek to start position", NULL_PARG);
+               return (-1);
+       }
+
+       if ((f = popen(cmd, "w")) == NULL)
+       {
+               error("Cannot create pipe", NULL_PARG);
+               return (-1);
+       }
+       clear_bot();
+       putstr("!");
+       putstr(cmd);
+       putstr("\n");
+
+       deinit();
+       flush();
+       raw_mode(0);
+       init_signals(0);
+#if MSDOS_COMPILER==WIN32C
+       close_getchr();
+#endif
+#ifdef SIGPIPE
+       LSIGNAL(SIGPIPE, SIG_IGN);
+#endif
+
+       c = EOI;
+       while (epos == NULL_POSITION || spos++ <= epos)
+       {
+               /*
+                * Read a character from the file and give it to the pipe.
+                */
+               c = ch_forw_get();
+               if (c == EOI)
+                       break;
+               if (putc(c, f) == EOF)
+                       break;
+       }
+
+       /*
+        * Finish up the last line.
+        */
+       while (c != '\n' && c != EOI ) 
+       {
+               c = ch_forw_get();
+               if (c == EOI)
+                       break;
+               if (putc(c, f) == EOF)
+                       break;
+       }
+
+       pclose(f);
+
+#ifdef SIGPIPE
+       LSIGNAL(SIGPIPE, SIG_DFL);
+#endif
+#if MSDOS_COMPILER==WIN32C
+       open_getchr();
+#endif
+       init_signals(1);
+       raw_mode(1);
+       init();
+       screen_trashed = 1;
+#if defined(SIGWINCH) || defined(SIGWIND)
+       /* {{ Probably don't need this here. }} */
+       winch(0);
+#endif
+       return (0);
+}
+
+#endif
diff --git a/thirdparty/less/main.c b/thirdparty/less/main.c
new file mode 100644 (file)
index 0000000..0af1762
--- /dev/null
@@ -0,0 +1,414 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Entry point, initialization, miscellaneous routines.
+ */
+
+#include "less.h"
+#if MSDOS_COMPILER==WIN32C
+#include <windows.h>
+#endif
+
+public char *  every_first_cmd = NULL;
+public int     new_file;
+public int     is_tty;
+public IFILE   curr_ifile = NULL_IFILE;
+public IFILE   old_ifile = NULL_IFILE;
+public struct scrpos initial_scrpos;
+public int     any_display = FALSE;
+public POSITION        start_attnpos = NULL_POSITION;
+public POSITION        end_attnpos = NULL_POSITION;
+public int     wscroll;
+public char *  progname;
+public int     quitting;
+public int     secure;
+public int     dohelp;
+
+#if LOGFILE
+public int     logfile = -1;
+public int     force_logfile = FALSE;
+public char *  namelogfile = NULL;
+#endif
+
+#if EDITOR
+public char *  editor;
+public char *  editproto;
+#endif
+
+#if TAGS
+extern char *  tags;
+extern char *  tagoption;
+extern int     jump_sline;
+#endif
+
+#ifdef WIN32
+static char consoleTitle[256];
+#endif
+
+extern int     less_is_more;
+extern int     missing_cap;
+extern int     know_dumb;
+extern int     quit_if_one_screen;
+extern int     pr_type;
+
+
+/*
+ * Entry point.
+ */
+int
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       IFILE ifile;
+       char *s;
+
+#ifdef __EMX__
+       _response(&argc, &argv);
+       _wildcard(&argc, &argv);
+#endif
+
+       progname = *argv++;
+       argc--;
+
+       secure = 0;
+       s = lgetenv("LESSSECURE");
+       if (s != NULL && *s != '\0')
+               secure = 1;
+
+#ifdef WIN32
+       if (getenv("HOME") == NULL)
+       {
+               /*
+                * If there is no HOME environment variable,
+                * try the concatenation of HOMEDRIVE + HOMEPATH.
+                */
+               char *drive = getenv("HOMEDRIVE");
+               char *path  = getenv("HOMEPATH");
+               if (drive != NULL && path != NULL)
+               {
+                       char *env = (char *) ecalloc(strlen(drive) + 
+                                       strlen(path) + 6, sizeof(char));
+                       strcpy(env, "HOME=");
+                       strcat(env, drive);
+                       strcat(env, path);
+                       putenv(env);
+               }
+       }
+       GetConsoleTitle(consoleTitle, sizeof(consoleTitle)/sizeof(char));
+#endif /* WIN32 */
+
+       /*
+        * Process command line arguments and LESS environment arguments.
+        * Command line arguments override environment arguments.
+        */
+       is_tty = isatty(1);
+       get_term();
+       init_cmds();
+       init_charset();
+       init_line();
+       init_cmdhist();
+       init_option();
+       init_search();
+
+       /*
+        * If the name of the executable program is "more",
+        * act like LESS_IS_MORE is set.
+        */
+       for (s = progname + strlen(progname);  s > progname;  s--)
+       {
+               if (s[-1] == PATHNAME_SEP[0])
+                       break;
+       }
+       if (strcmp(s, "more") == 0)
+               less_is_more = 1;
+
+       init_prompt();
+
+       s = lgetenv(less_is_more ? "MORE" : "LESS");
+       if (s != NULL)
+               scan_option(save(s));
+
+#define        isoptstring(s)  (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\0')
+       while (argc > 0 && (isoptstring(*argv) || isoptpending()))
+       {
+               s = *argv++;
+               argc--;
+               if (strcmp(s, "--") == 0)
+                       break;
+               scan_option(s);
+       }
+#undef isoptstring
+
+       if (isoptpending())
+       {
+               /*
+                * Last command line option was a flag requiring a
+                * following string, but there was no following string.
+                */
+               nopendopt();
+               quit(QUIT_OK);
+       }
+
+       if (less_is_more && get_quit_at_eof())
+               quit_if_one_screen = TRUE;
+
+#if EDITOR
+       editor = lgetenv("VISUAL");
+       if (editor == NULL || *editor == '\0')
+       {
+               editor = lgetenv("EDITOR");
+               if (editor == NULL || *editor == '\0')
+                       editor = EDIT_PGM;
+       }
+       editproto = lgetenv("LESSEDIT");
+       if (editproto == NULL || *editproto == '\0')
+               editproto = "%E ?lm+%lm. %f";
+#endif
+
+       /*
+        * Call get_ifile with all the command line filenames
+        * to "register" them with the ifile system.
+        */
+       ifile = NULL_IFILE;
+       if (dohelp)
+               ifile = get_ifile(FAKE_HELPFILE, ifile);
+       while (argc-- > 0)
+       {
+               char *filename;
+#if (MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC)
+               /*
+                * Because the "shell" doesn't expand filename patterns,
+                * treat each argument as a filename pattern rather than
+                * a single filename.  
+                * Expand the pattern and iterate over the expanded list.
+                */
+               struct textlist tlist;
+               char *gfilename;
+               
+               gfilename = lglob(*argv++);
+               init_textlist(&tlist, gfilename);
+               filename = NULL;
+               while ((filename = forw_textlist(&tlist, filename)) != NULL)
+               {
+                       (void) get_ifile(filename, ifile);
+                       ifile = prev_ifile(NULL_IFILE);
+               }
+               free(gfilename);
+#else
+               filename = shell_quote(*argv);
+               if (filename == NULL)
+                       filename = *argv;
+               argv++;
+               (void) get_ifile(filename, ifile);
+               ifile = prev_ifile(NULL_IFILE);
+#endif
+       }
+       /*
+        * Set up terminal, etc.
+        */
+       if (!is_tty)
+       {
+               /*
+                * Output is not a tty.
+                * Just copy the input file(s) to output.
+                */
+               SET_BINARY(1);
+               if (nifile() == 0)
+               {
+                       if (edit_stdin() == 0)
+                               cat_file();
+               } else if (edit_first() == 0)
+               {
+                       do {
+                               cat_file();
+                       } while (edit_next(1) == 0);
+               }
+               quit(QUIT_OK);
+       }
+
+       if (missing_cap && !know_dumb)
+               error("WARNING: terminal is not fully functional", NULL_PARG);
+       init_mark();
+       open_getchr();
+       raw_mode(1);
+       init_signals(1);
+
+       /*
+        * Select the first file to examine.
+        */
+#if TAGS
+       if (tagoption != NULL || strcmp(tags, "-") == 0)
+       {
+               /*
+                * A -t option was given.
+                * Verify that no filenames were also given.
+                * Edit the file selected by the "tags" search,
+                * and search for the proper line in the file.
+                */
+               if (nifile() > 0)
+               {
+                       error("No filenames allowed with -t option", NULL_PARG);
+                       quit(QUIT_ERROR);
+               }
+               findtag(tagoption);
+               if (edit_tagfile())  /* Edit file which contains the tag */
+                       quit(QUIT_ERROR);
+               /*
+                * Search for the line which contains the tag.
+                * Set up initial_scrpos so we display that line.
+                */
+               initial_scrpos.pos = tagsearch();
+               if (initial_scrpos.pos == NULL_POSITION)
+                       quit(QUIT_ERROR);
+               initial_scrpos.ln = jump_sline;
+       } else
+#endif
+       if (nifile() == 0)
+       {
+               if (edit_stdin())  /* Edit standard input */
+                       quit(QUIT_ERROR);
+       } else 
+       {
+               if (edit_first())  /* Edit first valid file in cmd line */
+                       quit(QUIT_ERROR);
+       }
+
+       init();
+       commands();
+       quit(QUIT_OK);
+       /*NOTREACHED*/
+       return (0);
+}
+
+/*
+ * Copy a string to a "safe" place
+ * (that is, to a buffer allocated by calloc).
+ */
+       public char *
+save(s)
+       char *s;
+{
+       register char *p;
+
+       p = (char *) ecalloc(strlen(s)+1, sizeof(char));
+       strcpy(p, s);
+       return (p);
+}
+
+/*
+ * Allocate memory.
+ * Like calloc(), but never returns an error (NULL).
+ */
+       public VOID_POINTER
+ecalloc(count, size)
+       int count;
+       unsigned int size;
+{
+       register VOID_POINTER p;
+
+       p = (VOID_POINTER) calloc(count, size);
+       if (p != NULL)
+               return (p);
+       error("Cannot allocate memory", NULL_PARG);
+       quit(QUIT_ERROR);
+       /*NOTREACHED*/
+       return (NULL);
+}
+
+/*
+ * Skip leading spaces in a string.
+ */
+       public char *
+skipsp(s)
+       register char *s;
+{
+       while (*s == ' ' || *s == '\t') 
+               s++;
+       return (s);
+}
+
+/*
+ * See how many characters of two strings are identical.
+ * If uppercase is true, the first string must begin with an uppercase
+ * character; the remainder of the first string may be either case.
+ */
+       public int
+sprefix(ps, s, uppercase)
+       char *ps;
+       char *s;
+       int uppercase;
+{
+       register int c;
+       register int sc;
+       register int len = 0;
+
+       for ( ;  *s != '\0';  s++, ps++)
+       {
+               c = *ps;
+               if (uppercase)
+               {
+                       if (len == 0 && ASCII_IS_LOWER(c))
+                               return (-1);
+                       if (ASCII_IS_UPPER(c))
+                               c = ASCII_TO_LOWER(c);
+               }
+               sc = *s;
+               if (len > 0 && ASCII_IS_UPPER(sc))
+                       sc = ASCII_TO_LOWER(sc);
+               if (c != sc)
+                       break;
+               len++;
+       }
+       return (len);
+}
+
+/*
+ * Exit the program.
+ */
+       public void
+quit(status)
+       int status;
+{
+       static int save_status;
+
+       /*
+        * Put cursor at bottom left corner, clear the line,
+        * reset the terminal modes, and exit.
+        */
+       if (status < 0)
+               status = save_status;
+       else
+               save_status = status;
+       quitting = 1;
+       edit((char*)NULL);
+       save_cmdhist();
+       if (any_display && is_tty)
+               clear_bot();
+       deinit();
+       flush();
+       raw_mode(0);
+#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
+       /* 
+        * If we don't close 2, we get some garbage from
+        * 2's buffer when it flushes automatically.
+        * I cannot track this one down  RB
+        * The same bug shows up if we use ^C^C to abort.
+        */
+       close(2);
+#endif
+#ifdef WIN32
+       SetConsoleTitle(consoleTitle);
+#endif
+       close_getchr();
+       exit(status);
+}
diff --git a/thirdparty/less/mark.c b/thirdparty/less/mark.c
new file mode 100644 (file)
index 0000000..585b412
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+#include "less.h"
+
+extern IFILE curr_ifile;
+extern int sc_height;
+extern int jump_sline;
+
+/*
+ * A mark is an ifile (input file) plus a position within the file.
+ */
+struct mark {
+       IFILE m_ifile;
+       struct scrpos m_scrpos;
+};
+
+/*
+ * The table of marks.
+ * Each mark is identified by a lowercase or uppercase letter.
+ * The final one is lmark, for the "last mark"; addressed by the apostrophe.
+ */
+#define        NMARKS          ((2*26)+1)      /* a-z, A-Z, lastmark */
+#define        LASTMARK        (NMARKS-1)
+static struct mark marks[NMARKS];
+
+/*
+ * Initialize the mark table to show no marks are set.
+ */
+       public void
+init_mark()
+{
+       int i;
+
+       for (i = 0;  i < NMARKS;  i++)
+               marks[i].m_scrpos.pos = NULL_POSITION;
+}
+
+/*
+ * See if a mark letter is valid (between a and z).
+ */
+       static struct mark *
+getumark(c)
+       int c;
+{
+       if (c >= 'a' && c <= 'z')
+               return (&marks[c-'a']);
+
+       if (c >= 'A' && c <= 'Z')
+               return (&marks[c-'A'+26]);
+
+       error("Invalid mark letter", NULL_PARG);
+       return (NULL);
+}
+
+/*
+ * Get the mark structure identified by a character.
+ * The mark struct may come either from the mark table
+ * or may be constructed on the fly for certain characters like ^, $.
+ */
+       static struct mark *
+getmark(c)
+       int c;
+{
+       register struct mark *m;
+       static struct mark sm;
+
+       switch (c)
+       {
+       case '^':
+               /*
+                * Beginning of the current file.
+                */
+               m = &sm;
+               m->m_scrpos.pos = ch_zero();
+               m->m_scrpos.ln = 0;
+               m->m_ifile = curr_ifile;
+               break;
+       case '$':
+               /*
+                * End of the current file.
+                */
+               if (ch_end_seek())
+               {
+                       error("Cannot seek to end of file", NULL_PARG);
+                       return (NULL);
+               }
+               m = &sm;
+               m->m_scrpos.pos = ch_tell();
+               m->m_scrpos.ln = sc_height-1;
+               m->m_ifile = curr_ifile;
+               break;
+       case '.':
+               /*
+                * Current position in the current file.
+                */
+               m = &sm;
+               get_scrpos(&m->m_scrpos);
+               m->m_ifile = curr_ifile;
+               break;
+       case '\'':
+               /*
+                * The "last mark".
+                */
+               m = &marks[LASTMARK];
+               break;
+       default:
+               /*
+                * Must be a user-defined mark.
+                */
+               m = getumark(c);
+               if (m == NULL)
+                       break;
+               if (m->m_scrpos.pos == NULL_POSITION)
+               {
+                       error("Mark not set", NULL_PARG);
+                       return (NULL);
+               }
+               break;
+       }
+       return (m);
+}
+
+/*
+ * Is a mark letter is invalid?
+ */
+       public int
+badmark(c)
+       int c;
+{
+       return (getmark(c) == NULL);
+}
+
+/*
+ * Set a user-defined mark.
+ */
+       public void
+setmark(c)
+       int c;
+{
+       register struct mark *m;
+       struct scrpos scrpos;
+
+       m = getumark(c);
+       if (m == NULL)
+               return;
+       get_scrpos(&scrpos);
+       m->m_scrpos = scrpos;
+       m->m_ifile = curr_ifile;
+}
+
+/*
+ * Set lmark (the mark named by the apostrophe).
+ */
+       public void
+lastmark()
+{
+       struct scrpos scrpos;
+
+       if (ch_getflags() & CH_HELPFILE)
+               return;
+       get_scrpos(&scrpos);
+       if (scrpos.pos == NULL_POSITION)
+               return;
+       marks[LASTMARK].m_scrpos = scrpos;
+       marks[LASTMARK].m_ifile = curr_ifile;
+}
+
+/*
+ * Go to a mark.
+ */
+       public void
+gomark(c)
+       int c;
+{
+       register struct mark *m;
+       struct scrpos scrpos;
+
+       m = getmark(c);
+       if (m == NULL)
+               return;
+
+       /*
+        * If we're trying to go to the lastmark and 
+        * it has not been set to anything yet,
+        * set it to the beginning of the current file.
+        */
+       if (m == &marks[LASTMARK] && m->m_scrpos.pos == NULL_POSITION)
+       {
+               m->m_ifile = curr_ifile;
+               m->m_scrpos.pos = ch_zero();
+               m->m_scrpos.ln = jump_sline;
+       }
+
+       /*
+        * If we're using lmark, we must save the screen position now,
+        * because if we call edit_ifile() below, lmark will change.
+        * (We save the screen position even if we're not using lmark.)
+        */
+       scrpos = m->m_scrpos;
+       if (m->m_ifile != curr_ifile)
+       {
+               /*
+                * Not in the current file; edit the correct file.
+                */
+               if (edit_ifile(m->m_ifile))
+                       return;
+       }
+
+       jump_loc(scrpos.pos, scrpos.ln);
+}
+
+/*
+ * Return the position associated with a given mark letter.
+ *
+ * We don't return which screen line the position 
+ * is associated with, but this doesn't matter much,
+ * because it's always the first non-blank line on the screen.
+ */
+       public POSITION
+markpos(c)
+       int c;
+{
+       register struct mark *m;
+
+       m = getmark(c);
+       if (m == NULL)
+               return (NULL_POSITION);
+
+       if (m->m_ifile != curr_ifile)
+       {
+               error("Mark not in current file", NULL_PARG);
+               return (NULL_POSITION);
+       }
+       return (m->m_scrpos.pos);
+}
+
+/*
+ * Clear the marks associated with a specified ifile.
+ */
+       public void
+unmark(ifile)
+       IFILE ifile;
+{
+       int i;
+
+       for (i = 0;  i < NMARKS;  i++)
+               if (marks[i].m_ifile == ifile)
+                       marks[i].m_scrpos.pos = NULL_POSITION;
+}
diff --git a/thirdparty/less/mkhelp.c b/thirdparty/less/mkhelp.c
new file mode 100644 (file)
index 0000000..4aa8cbd
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Silly little program to generate the help.c source file
+ * from the less.hlp text file.
+ * help.c just contains a char array whose contents are 
+ * the contents of less.hlp.
+ */
+
+#include <stdio.h>
+
+       int
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       int ch;
+       int prevch;
+
+       printf("/* This file was generated by mkhelp from less.hlp */\n");
+       printf("#include \"less.h\"\n");
+       printf("constant char helpdata[] = {\n");
+       ch = 0;
+       while (prevch = ch, (ch = getchar()) != EOF)
+       {
+               switch (ch)
+               {
+               case '\'':
+                       printf("'\\'',");
+                       break;
+               case '\\':
+                       printf("'\\\\',");
+                       break;
+               case '\b':
+                       printf("'\\b',");
+                       break;
+               case '\t':
+                       printf("'\\t',");
+                       break;
+               case '\n':
+                       if (prevch != '\r') 
+                               printf("'\\n',\n");
+                       break;
+               case '\r':
+                       if (prevch != '\n') 
+                               printf("'\\n',\n");
+                       break;
+               default:
+                       if (ch >= ' ' && ch < 0x7f)
+                               printf("'%c',", ch);
+                       else
+                               printf("0x%02x,", ch);
+                       break;
+               }
+       }
+       /* Add an extra null char to avoid having a trailing comma. */
+       printf(" 0 };\n");
+       printf("constant int size_helpdata = sizeof(helpdata) - 1;\n");
+       return (0);
+}
diff --git a/thirdparty/less/optfunc.c b/thirdparty/less/optfunc.c
new file mode 100644 (file)
index 0000000..a0aa10a
--- /dev/null
@@ -0,0 +1,707 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Handling functions for command line options.
+ *
+ * Most options are handled by the generic code in option.c.
+ * But all string options, and a few non-string options, require
+ * special handling specific to the particular option.
+ * This special processing is done by the "handling functions" in this file.
+ *
+ * Each handling function is passed a "type" and, if it is a string
+ * option, the string which should be "assigned" to the option.
+ * The type may be one of:
+ *     INIT    The option is being initialized from the command line.
+ *     TOGGLE  The option is being changed from within the program.
+ *     QUERY   The setting of the option is merely being queried.
+ */
+
+#include "less.h"
+#include "option.h"
+
+extern int nbufs;
+extern int bufspace;
+extern int pr_type;
+extern int plusoption;
+extern int swindow;
+extern int sc_width;
+extern int sc_height;
+extern int secure;
+extern int dohelp;
+extern int any_display;
+extern char openquote;
+extern char closequote;
+extern char *prproto[];
+extern char *eqproto;
+extern char *hproto;
+extern char *wproto;
+extern IFILE curr_ifile;
+extern char version[];
+extern int jump_sline;
+extern int jump_sline_fraction;
+extern int shift_count;
+extern int shift_count_fraction;
+extern int less_is_more;
+#if LOGFILE
+extern char *namelogfile;
+extern int force_logfile;
+extern int logfile;
+#endif
+#if TAGS
+public char *tagoption = NULL;
+extern char *tags;
+#endif
+#if MSDOS_COMPILER
+extern int nm_fg_color, nm_bg_color;
+extern int bo_fg_color, bo_bg_color;
+extern int ul_fg_color, ul_bg_color;
+extern int so_fg_color, so_bg_color;
+extern int bl_fg_color, bl_bg_color;
+#endif
+
+
+#if LOGFILE
+/*
+ * Handler for -o option.
+ */
+       public void
+opt_o(type, s)
+       int type;
+       char *s;
+{
+       PARG parg;
+
+       if (secure)
+       {
+               error("log file support is not available", NULL_PARG);
+               return;
+       }
+       switch (type)
+       {
+       case INIT:
+               namelogfile = s;
+               break;
+       case TOGGLE:
+               if (ch_getflags() & CH_CANSEEK)
+               {
+                       error("Input is not a pipe", NULL_PARG);
+                       return;
+               }
+               if (logfile >= 0)
+               {
+                       error("Log file is already in use", NULL_PARG);
+                       return;
+               }
+               s = skipsp(s);
+               namelogfile = lglob(s);
+               use_logfile(namelogfile);
+               sync_logfile();
+               break;
+       case QUERY:
+               if (logfile < 0)
+                       error("No log file", NULL_PARG);
+               else
+               {
+                       parg.p_string = namelogfile;
+                       error("Log file \"%s\"", &parg);
+               }
+               break;
+       }
+}
+
+/*
+ * Handler for -O option.
+ */
+       public void
+opt__O(type, s)
+       int type;
+       char *s;
+{
+       force_logfile = TRUE;
+       opt_o(type, s);
+}
+#endif
+
+/*
+ * Handlers for -j option.
+ */
+       public void
+opt_j(type, s)
+       int type;
+       char *s;
+{
+       PARG parg;
+       char buf[16];
+       int len;
+       int err;
+
+       switch (type)
+       {
+       case INIT:
+       case TOGGLE:
+               if (*s == '.')
+               {
+                       s++;
+                       jump_sline_fraction = getfraction(&s, "j", &err);
+                       if (err)
+                               error("Invalid line fraction", NULL_PARG);
+                       else
+                               calc_jump_sline();
+               } else
+               {
+                       int sline = getnum(&s, "j", &err);
+                       if (err)
+                               error("Invalid line number", NULL_PARG);
+                       else
+                       {
+                               jump_sline = sline;
+                               jump_sline_fraction = -1;
+                       }
+               }
+               break;
+       case QUERY:
+               if (jump_sline_fraction < 0)
+               {
+                       parg.p_int =  jump_sline;
+                       error("Position target at screen line %d", &parg);
+               } else
+               {
+
+                       sprintf(buf, ".%06d", jump_sline_fraction);
+                       len = strlen(buf);
+                       while (len > 2 && buf[len-1] == '0')
+                               len--;
+                       buf[len] = '\0';
+                       parg.p_string = buf;
+                       error("Position target at screen position %s", &parg);
+               }
+               break;
+       }
+}
+
+       public void
+calc_jump_sline()
+{
+       if (jump_sline_fraction < 0)
+               return;
+       jump_sline = sc_height * jump_sline_fraction / NUM_FRAC_DENOM;
+}
+
+/*
+ * Handlers for -# option.
+ */
+       public void
+opt_shift(type, s)
+       int type;
+       char *s;
+{
+       PARG parg;
+       char buf[16];
+       int len;
+       int err;
+
+       switch (type)
+       {
+       case INIT:
+       case TOGGLE:
+               if (*s == '.')
+               {
+                       s++;
+                       shift_count_fraction = getfraction(&s, "#", &err);
+                       if (err)
+                               error("Invalid column fraction", NULL_PARG);
+                       else
+                               calc_shift_count();
+               } else
+               {
+                       int hs = getnum(&s, "#", &err);
+                       if (err)
+                               error("Invalid column number", NULL_PARG);
+                       else
+                       {
+                               shift_count = hs;
+                               shift_count_fraction = -1;
+                       }
+               }
+               break;
+       case QUERY:
+               if (shift_count_fraction < 0)
+               {
+                       parg.p_int = shift_count;
+                       error("Horizontal shift %d columns", &parg);
+               } else
+               {
+
+                       sprintf(buf, ".%06d", shift_count_fraction);
+                       len = strlen(buf);
+                       while (len > 2 && buf[len-1] == '0')
+                               len--;
+                       buf[len] = '\0';
+                       parg.p_string = buf;
+                       error("Horizontal shift %s of screen width", &parg);
+               }
+               break;
+       }
+}
+       public void
+calc_shift_count()
+{
+       if (shift_count_fraction < 0)
+               return;
+       shift_count = sc_width * shift_count_fraction / NUM_FRAC_DENOM;
+}
+
+#if USERFILE
+       public void
+opt_k(type, s)
+       int type;
+       char *s;
+{
+       PARG parg;
+
+       switch (type)
+       {
+       case INIT:
+               if (lesskey(s, 0))
+               {
+                       parg.p_string = s;
+                       error("Cannot use lesskey file \"%s\"", &parg);
+               }
+               break;
+       }
+}
+#endif
+
+#if TAGS
+/*
+ * Handler for -t option.
+ */
+       public void
+opt_t(type, s)
+       int type;
+       char *s;
+{
+       IFILE save_ifile;
+       POSITION pos;
+
+       switch (type)
+       {
+       case INIT:
+               tagoption = s;
+               /* Do the rest in main() */
+               break;
+       case TOGGLE:
+               if (secure)
+               {
+                       error("tags support is not available", NULL_PARG);
+                       break;
+               }
+               findtag(skipsp(s));
+               save_ifile = save_curr_ifile();
+               /*
+                * Try to open the file containing the tag
+                * and search for the tag in that file.
+                */
+               if (edit_tagfile() || (pos = tagsearch()) == NULL_POSITION)
+               {
+                       /* Failed: reopen the old file. */
+                       reedit_ifile(save_ifile);
+                       break;
+               }
+               unsave_ifile(save_ifile);
+               jump_loc(pos, jump_sline);
+               break;
+       }
+}
+
+/*
+ * Handler for -T option.
+ */
+       public void
+opt__T(type, s)
+       int type;
+       char *s;
+{
+       PARG parg;
+
+       switch (type)
+       {
+       case INIT:
+               tags = s;
+               break;
+       case TOGGLE:
+               s = skipsp(s);
+               tags = lglob(s);
+               break;
+       case QUERY:
+               parg.p_string = tags;
+               error("Tags file \"%s\"", &parg);
+               break;
+       }
+}
+#endif
+
+/*
+ * Handler for -p option.
+ */
+       public void
+opt_p(type, s)
+       int type;
+       register char *s;
+{
+       switch (type)
+       {
+       case INIT:
+               /*
+                * Unget a search command for the specified string.
+                * {{ This won't work if the "/" command is
+                *    changed or invalidated by a .lesskey file. }}
+                */
+               plusoption = TRUE;
+               ungetsc(s);
+               /*
+                * In "more" mode, the -p argument is a command,
+                * not a search string, so we don't need a slash.
+                */
+               if (!less_is_more)
+                       ungetsc("/");
+               break;
+       }
+}
+
+/*
+ * Handler for -P option.
+ */
+       public void
+opt__P(type, s)
+       int type;
+       register char *s;
+{
+       register char **proto;
+       PARG parg;
+
+       switch (type)
+       {
+       case INIT:
+       case TOGGLE:
+               /*
+                * Figure out which prototype string should be changed.
+                */
+               switch (*s)
+               {
+               case 's':  proto = &prproto[PR_SHORT];  s++;    break;
+               case 'm':  proto = &prproto[PR_MEDIUM]; s++;    break;
+               case 'M':  proto = &prproto[PR_LONG];   s++;    break;
+               case '=':  proto = &eqproto;            s++;    break;
+               case 'h':  proto = &hproto;             s++;    break;
+               case 'w':  proto = &wproto;             s++;    break;
+               default:   proto = &prproto[PR_SHORT];          break;
+               }
+               free(*proto);
+               *proto = save(s);
+               break;
+       case QUERY:
+               parg.p_string = prproto[pr_type];
+               error("%s", &parg);
+               break;
+       }
+}
+
+/*
+ * Handler for the -b option.
+ */
+       /*ARGSUSED*/
+       public void
+opt_b(type, s)
+       int type;
+       char *s;
+{
+       switch (type)
+       {
+       case INIT:
+       case TOGGLE:
+               /*
+                * Set the new number of buffers.
+                */
+               ch_setbufspace(bufspace);
+               break;
+       case QUERY:
+               break;
+       }
+}
+
+/*
+ * Handler for the -i option.
+ */
+       /*ARGSUSED*/
+       public void
+opt_i(type, s)
+       int type;
+       char *s;
+{
+       switch (type)
+       {
+       case TOGGLE:
+               chg_caseless();
+               break;
+       case QUERY:
+       case INIT:
+               break;
+       }
+}
+
+/*
+ * Handler for the -V option.
+ */
+       /*ARGSUSED*/
+       public void
+opt__V(type, s)
+       int type;
+       char *s;
+{
+       switch (type)
+       {
+       case TOGGLE:
+       case QUERY:
+               dispversion();
+               break;
+       case INIT:
+               /*
+                * Force output to stdout per GNU standard for --version output.
+                */
+               any_display = 1;
+               putstr("less ");
+               putstr(version);
+               putstr("\nCopyright (C) 1984-2009 Mark Nudelman\n\n");
+               putstr("less comes with NO WARRANTY, to the extent permitted by law.\n");
+               putstr("For information about the terms of redistribution,\n");
+               putstr("see the file named README in the less distribution.\n");
+               putstr("Homepage: http://www.greenwoodsoftware.com/less\n");
+               quit(QUIT_OK);
+               break;
+       }
+}
+
+#if MSDOS_COMPILER
+/*
+ * Parse an MSDOS color descriptor.
+ */
+       static void
+colordesc(s, fg_color, bg_color)
+       char *s;
+       int *fg_color;
+       int *bg_color;
+{
+       int fg, bg;
+       int err;
+       
+       fg = getnum(&s, "D", &err);
+       if (err)
+       {
+               error("Missing fg color in -D", NULL_PARG);
+               return;
+       }
+       if (*s != '.')
+               bg = nm_bg_color;
+       else
+       {
+               s++;
+               bg = getnum(&s, "D", &err);
+               if (err)
+               {
+                       error("Missing bg color in -D", NULL_PARG);
+                       return;
+               }
+       }
+       if (*s != '\0')
+               error("Extra characters at end of -D option", NULL_PARG);
+       *fg_color = fg;
+       *bg_color = bg;
+}
+
+/*
+ * Handler for the -D option.
+ */
+       /*ARGSUSED*/
+       public void
+opt_D(type, s)
+       int type;
+       char *s;
+{
+       switch (type)
+       {
+       case INIT:
+       case TOGGLE:
+               switch (*s++)
+               {
+               case 'n':
+                       colordesc(s, &nm_fg_color, &nm_bg_color);
+                       break;
+               case 'd':
+                       colordesc(s, &bo_fg_color, &bo_bg_color);
+                       break;
+               case 'u':
+                       colordesc(s, &ul_fg_color, &ul_bg_color);
+                       break;
+               case 'k':
+                       colordesc(s, &bl_fg_color, &bl_bg_color);
+                       break;
+               case 's':
+                       colordesc(s, &so_fg_color, &so_bg_color);
+                       break;
+               default:
+                       error("-D must be followed by n, d, u, k or s", NULL_PARG);
+                       break;
+               }
+               if (type == TOGGLE)
+               {
+                       at_enter(AT_STANDOUT);
+                       at_exit();
+               }
+               break;
+       case QUERY:
+               break;
+       }
+}
+#endif
+
+/*
+ * Handler for the -x option.
+ */
+       public void
+opt_x(type, s)
+       int type;
+       register char *s;
+{
+       extern int tabstops[];
+       extern int ntabstops;
+       extern int tabdefault;
+       char msg[60+(4*TABSTOP_MAX)];
+       int i;
+       PARG p;
+
+       switch (type)
+       {
+       case INIT:
+       case TOGGLE:
+               /* Start at 1 because tabstops[0] is always zero. */
+               for (i = 1;  i < TABSTOP_MAX;  )
+               {
+                       int n = 0;
+                       s = skipsp(s);
+                       while (*s >= '0' && *s <= '9')
+                               n = (10 * n) + (*s++ - '0');
+                       if (n > tabstops[i-1])
+                               tabstops[i++] = n;
+                       s = skipsp(s);
+                       if (*s++ != ',')
+                               break;
+               }
+               if (i < 2)
+                       return;
+               ntabstops = i;
+               tabdefault = tabstops[ntabstops-1] - tabstops[ntabstops-2];
+               break;
+       case QUERY:
+               strcpy(msg, "Tab stops ");
+               if (ntabstops > 2)
+               {
+                       for (i = 1;  i < ntabstops;  i++)
+                       {
+                               if (i > 1)
+                                       strcat(msg, ",");
+                               sprintf(msg+strlen(msg), "%d", tabstops[i]);
+                       }
+                       sprintf(msg+strlen(msg), " and then ");
+               }
+               sprintf(msg+strlen(msg), "every %d spaces",
+                       tabdefault);
+               p.p_string = msg;
+               error("%s", &p);
+               break;
+       }
+}
+
+
+/*
+ * Handler for the -" option.
+ */
+       public void
+opt_quote(type, s)
+       int type;
+       register char *s;
+{
+       char buf[3];
+       PARG parg;
+
+       switch (type)
+       {
+       case INIT:
+       case TOGGLE:
+               if (s[0] == '\0')
+               {
+                       openquote = closequote = '\0';
+                       break;
+               }
+               if (s[1] != '\0' && s[2] != '\0')
+               {
+                       error("-\" must be followed by 1 or 2 chars", NULL_PARG);
+                       return;
+               }
+               openquote = s[0];
+               if (s[1] == '\0')
+                       closequote = openquote;
+               else
+                       closequote = s[1];
+               break;
+       case QUERY:
+               buf[0] = openquote;
+               buf[1] = closequote;
+               buf[2] = '\0';
+               parg.p_string = buf;
+               error("quotes %s", &parg);
+               break;
+       }
+}
+
+/*
+ * "-?" means display a help message.
+ * If from the command line, exit immediately.
+ */
+       /*ARGSUSED*/
+       public void
+opt_query(type, s)
+       int type;
+       char *s;
+{
+       switch (type)
+       {
+       case QUERY:
+       case TOGGLE:
+               error("Use \"h\" for help", NULL_PARG);
+               break;
+       case INIT:
+               dohelp = 1;
+       }
+}
+
+/*
+ * Get the "screen window" size.
+ */
+       public int
+get_swindow()
+{
+       if (swindow > 0)
+               return (swindow);
+       return (sc_height + swindow);
+}
+
diff --git a/thirdparty/less/option.c b/thirdparty/less/option.c
new file mode 100644 (file)
index 0000000..acb8962
--- /dev/null
@@ -0,0 +1,702 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Process command line options.
+ *
+ * Each option is a single letter which controls a program variable.
+ * The options have defaults which may be changed via
+ * the command line option, toggled via the "-" command, 
+ * or queried via the "_" command.
+ */
+
+#include "less.h"
+#include "option.h"
+
+static struct loption *pendopt;
+public int plusoption = FALSE;
+
+static char *optstring();
+static int flip_triple();
+
+extern int screen_trashed;
+extern int less_is_more;
+extern int quit_at_eof;
+extern char *every_first_cmd;
+
+/*
+ * Return a printable description of an option.
+ */
+       static char *
+opt_desc(o)
+       struct loption *o;
+{
+       static char buf[OPTNAME_MAX + 10];
+       if (o->oletter == OLETTER_NONE)
+               SNPRINTF1(buf, sizeof(buf), "--%s", o->onames->oname);
+       else
+               SNPRINTF2(buf, sizeof(buf), "-%c (--%s)", o->oletter, o->onames->oname);
+       return (buf);
+}
+
+/*
+ * Return a string suitable for printing as the "name" of an option.
+ * For example, if the option letter is 'x', just return "-x".
+ */
+       public char *
+propt(c)
+       int c;
+{
+       static char buf[8];
+
+       sprintf(buf, "-%s", prchar(c));
+       return (buf);
+}
+
+/* 
+ * Scan an argument (either from the command line or from the 
+ * LESS environment variable) and process it.
+ */
+       public void
+scan_option(s)
+       char *s;
+{
+       register struct loption *o;
+       register int optc;
+       char *optname;
+       char *printopt;
+       char *str;
+       int set_default;
+       int lc;
+       int err;
+       PARG parg;
+
+       if (s == NULL)
+               return;
+
+       /*
+        * If we have a pending option which requires an argument,
+        * handle it now.
+        * This happens if the previous option was, for example, "-P"
+        * without a following string.  In that case, the current
+        * option is simply the argument for the previous option.
+        */
+       if (pendopt != NULL)
+       {
+               switch (pendopt->otype & OTYPE)
+               {
+               case STRING:
+                       (*pendopt->ofunc)(INIT, s);
+                       break;
+               case NUMBER:
+                       printopt = opt_desc(pendopt);
+                       *(pendopt->ovar) = getnum(&s, printopt, (int*)NULL);
+                       break;
+               }
+               pendopt = NULL;
+               return;
+       }
+
+       set_default = FALSE;
+       optname = NULL;
+
+       while (*s != '\0')
+       {
+               /*
+                * Check some special cases first.
+                */
+               switch (optc = *s++)
+               {
+               case ' ':
+               case '\t':
+               case END_OPTION_STRING:
+                       continue;
+               case '-':
+                       /*
+                        * "--" indicates an option name instead of a letter.
+                        */
+                       if (*s == '-')
+                       {
+                               optname = ++s;
+                               break;
+                       }
+                       /*
+                        * "-+" means set these options back to their defaults.
+                        * (They may have been set otherwise by previous 
+                        * options.)
+                        */
+                       set_default = (*s == '+');
+                       if (set_default)
+                               s++;
+                       continue;
+               case '+':
+                       /*
+                        * An option prefixed by a "+" is ungotten, so 
+                        * that it is interpreted as less commands 
+                        * processed at the start of the first input file.
+                        * "++" means process the commands at the start of
+                        * EVERY input file.
+                        */
+                       plusoption = TRUE;
+                       s = optstring(s, &str, propt('+'), NULL);
+                       if (*str == '+')
+                               every_first_cmd = save(++str);
+                       else
+                               ungetsc(str);
+                       continue;
+               case '0':  case '1':  case '2':  case '3':  case '4':
+               case '5':  case '6':  case '7':  case '8':  case '9':
+                       /*
+                        * Special "more" compatibility form "-<number>"
+                        * instead of -z<number> to set the scrolling 
+                        * window size.
+                        */
+                       s--;
+                       optc = 'z';
+                       break;
+               case 'n':
+                       if (less_is_more)
+                               optc = 'z';
+                       break;
+               }
+
+               /*
+                * Not a special case.
+                * Look up the option letter in the option table.
+                */
+               err = 0;
+               if (optname == NULL)
+               {
+                       printopt = propt(optc);
+                       lc = ASCII_IS_LOWER(optc);
+                       o = findopt(optc);
+               } else
+               {
+                       printopt = optname;
+                       lc = ASCII_IS_LOWER(optname[0]);
+                       o = findopt_name(&optname, NULL, &err);
+                       s = optname;
+                       optname = NULL;
+                       if (*s == '\0' || *s == ' ')
+                       {
+                               /*
+                                * The option name matches exactly.
+                                */
+                               ;
+                       } else if (*s == '=')
+                       {
+                               /*
+                                * The option name is followed by "=value".
+                                */
+                               if (o != NULL &&
+                                   (o->otype & OTYPE) != STRING &&
+                                   (o->otype & OTYPE) != NUMBER)
+                               {
+                                       parg.p_string = printopt;
+                                       error("The %s option should not be followed by =",
+                                               &parg);
+                                       quit(QUIT_ERROR);
+                               }
+                               s++;
+                       } else
+                       {
+                               /*
+                                * The specified name is longer than the
+                                * real option name.
+                                */
+                               o = NULL;
+                       }
+               }
+               if (o == NULL)
+               {
+                       parg.p_string = printopt;
+                       if (err == OPT_AMBIG)
+                               error("%s is an ambiguous abbreviation (\"less --help\" for help)",
+                                       &parg);
+                       else
+                               error("There is no %s option (\"less --help\" for help)",
+                                       &parg);
+                       quit(QUIT_ERROR);
+               }
+
+               str = NULL;
+               switch (o->otype & OTYPE)
+               {
+               case BOOL:
+                       if (set_default)
+                               *(o->ovar) = o->odefault;
+                       else
+                               *(o->ovar) = ! o->odefault;
+                       break;
+               case TRIPLE:
+                       if (set_default)
+                               *(o->ovar) = o->odefault;
+                       else
+                               *(o->ovar) = flip_triple(o->odefault, lc);
+                       break;
+               case STRING:
+                       if (*s == '\0')
+                       {
+                               /*
+                                * Set pendopt and return.
+                                * We will get the string next time
+                                * scan_option is called.
+                                */
+                               pendopt = o;
+                               return;
+                       }
+                       /*
+                        * Don't do anything here.
+                        * All processing of STRING options is done by 
+                        * the handling function.
+                        */
+                       while (*s == ' ')
+                               s++;
+                       s = optstring(s, &str, printopt, o->odesc[1]);
+                       break;
+               case NUMBER:
+                       if (*s == '\0')
+                       {
+                               pendopt = o;
+                               return;
+                       }
+                       *(o->ovar) = getnum(&s, printopt, (int*)NULL);
+                       break;
+               }
+               /*
+                * If the option has a handling function, call it.
+                */
+               if (o->ofunc != NULL)
+                       (*o->ofunc)(INIT, str);
+       }
+}
+
+/*
+ * Toggle command line flags from within the program.
+ * Used by the "-" and "_" commands.
+ * how_toggle may be:
+ *     OPT_NO_TOGGLE   just report the current setting, without changing it.
+ *     OPT_TOGGLE      invert the current setting
+ *     OPT_UNSET       set to the default value
+ *     OPT_SET         set to the inverse of the default value
+ */
+       public void
+toggle_option(o, lower, s, how_toggle)
+       struct loption *o;
+       int lower;
+       char *s;
+       int how_toggle;
+{
+       register int num;
+       int no_prompt;
+       int err;
+       PARG parg;
+
+       no_prompt = (how_toggle & OPT_NO_PROMPT);
+       how_toggle &= ~OPT_NO_PROMPT;
+
+       if (o == NULL)
+       {
+               error("No such option", NULL_PARG);
+               return;
+       }
+
+       if (how_toggle == OPT_TOGGLE && (o->otype & NO_TOGGLE))
+       {
+               parg.p_string = opt_desc(o);
+               error("Cannot change the %s option", &parg);
+               return;
+       }
+
+       if (how_toggle == OPT_NO_TOGGLE && (o->otype & NO_QUERY))
+       {
+               parg.p_string = opt_desc(o);
+               error("Cannot query the %s option", &parg);
+               return;
+       } 
+
+       /*
+        * Check for something which appears to be a do_toggle
+        * (because the "-" command was used), but really is not.
+        * This could be a string option with no string, or
+        * a number option with no number.
+        */
+       switch (o->otype & OTYPE)
+       {
+       case STRING:
+       case NUMBER:
+               if (how_toggle == OPT_TOGGLE && *s == '\0')
+                       how_toggle = OPT_NO_TOGGLE;
+               break;
+       }
+
+#if HILITE_SEARCH
+       if (how_toggle != OPT_NO_TOGGLE && (o->otype & HL_REPAINT))
+               repaint_hilite(0);
+#endif
+
+       /*
+        * Now actually toggle (change) the variable.
+        */
+       if (how_toggle != OPT_NO_TOGGLE)
+       {
+               switch (o->otype & OTYPE)
+               {
+               case BOOL:
+                       /*
+                        * Boolean.
+                        */
+                       switch (how_toggle)
+                       {
+                       case OPT_TOGGLE:
+                               *(o->ovar) = ! *(o->ovar);
+                               break;
+                       case OPT_UNSET:
+                               *(o->ovar) = o->odefault;
+                               break;
+                       case OPT_SET:
+                               *(o->ovar) = ! o->odefault;
+                               break;
+                       }
+                       break;
+               case TRIPLE:
+                       /*
+                        * Triple:
+                        *      If user gave the lower case letter, then switch 
+                        *      to 1 unless already 1, in which case make it 0.
+                        *      If user gave the upper case letter, then switch
+                        *      to 2 unless already 2, in which case make it 0.
+                        */
+                       switch (how_toggle)
+                       {
+                       case OPT_TOGGLE:
+                               *(o->ovar) = flip_triple(*(o->ovar), lower);
+                               break;
+                       case OPT_UNSET:
+                               *(o->ovar) = o->odefault;
+                               break;
+                       case OPT_SET:
+                               *(o->ovar) = flip_triple(o->odefault, lower);
+                               break;
+                       }
+                       break;
+               case STRING:
+                       /*
+                        * String: don't do anything here.
+                        *      The handling function will do everything.
+                        */
+                       switch (how_toggle)
+                       {
+                       case OPT_SET:
+                       case OPT_UNSET:
+                               error("Cannot use \"-+\" or \"--\" for a string option",
+                                       NULL_PARG);
+                               return;
+                       }
+                       break;
+               case NUMBER:
+                       /*
+                        * Number: set the variable to the given number.
+                        */
+                       switch (how_toggle)
+                       {
+                       case OPT_TOGGLE:
+                               num = getnum(&s, NULL, &err);
+                               if (!err)
+                                       *(o->ovar) = num;
+                               break;
+                       case OPT_UNSET:
+                               *(o->ovar) = o->odefault;
+                               break;
+                       case OPT_SET:
+                               error("Can't use \"-!\" for a numeric option",
+                                       NULL_PARG);
+                               return;
+                       }
+                       break;
+               }
+       }
+
+       /*
+        * Call the handling function for any special action 
+        * specific to this option.
+        */
+       if (o->ofunc != NULL)
+               (*o->ofunc)((how_toggle==OPT_NO_TOGGLE) ? QUERY : TOGGLE, s);
+
+#if HILITE_SEARCH
+       if (how_toggle != OPT_NO_TOGGLE && (o->otype & HL_REPAINT))
+               chg_hilite();
+#endif
+
+       if (!no_prompt)
+       {
+               /*
+                * Print a message describing the new setting.
+                */
+               switch (o->otype & OTYPE)
+               {
+               case BOOL:
+               case TRIPLE:
+                       /*
+                        * Print the odesc message.
+                        */
+                       error(o->odesc[*(o->ovar)], NULL_PARG);
+                       break;
+               case NUMBER:
+                       /*
+                        * The message is in odesc[1] and has a %d for 
+                        * the value of the variable.
+                        */
+                       parg.p_int = *(o->ovar);
+                       error(o->odesc[1], &parg);
+                       break;
+               case STRING:
+                       /*
+                        * Message was already printed by the handling function.
+                        */
+                       break;
+               }
+       }
+
+       if (how_toggle != OPT_NO_TOGGLE && (o->otype & REPAINT))
+               screen_trashed = TRUE;
+}
+
+/*
+ * "Toggle" a triple-valued option.
+ */
+       static int
+flip_triple(val, lc)
+       int val;
+       int lc;
+{
+       if (lc)
+               return ((val == OPT_ON) ? OPT_OFF : OPT_ON);
+       else
+               return ((val == OPT_ONPLUS) ? OPT_OFF : OPT_ONPLUS);
+}
+
+/*
+ * Determine if an option takes a parameter.
+ */
+       public int
+opt_has_param(o)
+       struct loption *o;
+{
+       if (o == NULL)
+               return (0);
+       if (o->otype & (BOOL|TRIPLE|NOVAR|NO_TOGGLE))
+               return (0);
+       return (1);
+}
+
+/*
+ * Return the prompt to be used for a given option letter.
+ * Only string and number valued options have prompts.
+ */
+       public char *
+opt_prompt(o)
+       struct loption *o;
+{
+       if (o == NULL || (o->otype & (STRING|NUMBER)) == 0)
+               return ("?");
+       return (o->odesc[0]);
+}
+
+/*
+ * Return whether or not there is a string option pending;
+ * that is, if the previous option was a string-valued option letter 
+ * (like -P) without a following string.
+ * In that case, the current option is taken to be the string for
+ * the previous option.
+ */
+       public int
+isoptpending()
+{
+       return (pendopt != NULL);
+}
+
+/*
+ * Print error message about missing string.
+ */
+       static void
+nostring(printopt)
+       char *printopt;
+{
+       PARG parg;
+       parg.p_string = printopt;
+       error("Value is required after %s", &parg);
+}
+
+/*
+ * Print error message if a STRING type option is not followed by a string.
+ */
+       public void
+nopendopt()
+{
+       nostring(opt_desc(pendopt));
+}
+
+/*
+ * Scan to end of string or to an END_OPTION_STRING character.
+ * In the latter case, replace the char with a null char.
+ * Return a pointer to the remainder of the string, if any.
+ */
+       static char *
+optstring(s, p_str, printopt, validchars)
+       char *s;
+       char **p_str;
+       char *printopt;
+       char *validchars;
+{
+       register char *p;
+
+       if (*s == '\0')
+       {
+               nostring(printopt);
+               quit(QUIT_ERROR);
+       }
+       *p_str = s;
+       for (p = s;  *p != '\0';  p++)
+       {
+               if (*p == END_OPTION_STRING ||
+                   (validchars != NULL && strchr(validchars, *p) == NULL))
+               {
+                       switch (*p)
+                       {
+                       case END_OPTION_STRING:
+                       case ' ':  case '\t':  case '-':
+                               /* Replace the char with a null to terminate string. */
+                               *p++ = '\0';
+                               break;
+                       default:
+                               /* Cannot replace char; make a copy of the string. */
+                               *p_str = (char *) ecalloc(p-s+1, sizeof(char));
+                               strncpy(*p_str, s, p-s);
+                               (*p_str)[p-s] = '\0';
+                               break;
+                       }
+                       break;
+               }
+       }
+       return (p);
+}
+
+/*
+ */
+       static int
+num_error(printopt, errp)
+       char *printopt;
+       int *errp;
+{
+       PARG parg;
+
+       if (errp != NULL)
+       {
+               *errp = TRUE;
+               return (-1);
+       }
+       if (printopt != NULL)
+       {
+               parg.p_string = printopt;
+               error("Number is required after %s", &parg);
+       }
+       quit(QUIT_ERROR);
+       /* NOTREACHED */
+       return (-1);
+}
+
+/*
+ * Translate a string into a number.
+ * Like atoi(), but takes a pointer to a char *, and updates
+ * the char * to point after the translated number.
+ */
+       public int
+getnum(sp, printopt, errp)
+       char **sp;
+       char *printopt;
+       int *errp;
+{
+       register char *s;
+       register int n;
+       register int neg;
+
+       s = skipsp(*sp);
+       neg = FALSE;
+       if (*s == '-')
+       {
+               neg = TRUE;
+               s++;
+       }
+       if (*s < '0' || *s > '9')
+               return (num_error(printopt, errp));
+
+       n = 0;
+       while (*s >= '0' && *s <= '9')
+               n = 10 * n + *s++ - '0';
+       *sp = s;
+       if (errp != NULL)
+               *errp = FALSE;
+       if (neg)
+               n = -n;
+       return (n);
+}
+
+/*
+ * Translate a string into a fraction, represented by the part of a
+ * number which would follow a decimal point.
+ * The value of the fraction is returned as parts per NUM_FRAC_DENOM.
+ * That is, if "n" is returned, the fraction intended is n/NUM_FRAC_DENOM.
+ */
+       public long
+getfraction(sp, printopt, errp)
+       char **sp;
+       char *printopt;
+       int *errp;
+{
+       register char *s;
+       long frac = 0;
+       int fraclen = 0;
+
+       s = skipsp(*sp);
+       if (*s < '0' || *s > '9')
+               return (num_error(printopt, errp));
+
+       for ( ;  *s >= '0' && *s <= '9';  s++)
+       {
+               frac = (frac * 10) + (*s - '0');
+               fraclen++;
+       }
+       if (fraclen > NUM_LOG_FRAC_DENOM)
+               while (fraclen-- > NUM_LOG_FRAC_DENOM)
+                       frac /= 10;
+       else
+               while (fraclen++ < NUM_LOG_FRAC_DENOM)
+                       frac *= 10;
+       *sp = s;
+       if (errp != NULL)
+               *errp = FALSE;
+       return (frac);
+}
+
+
+/*
+ * Get the value of the -e flag.
+ */
+       public int
+get_quit_at_eof()
+{
+       if (!less_is_more)
+               return quit_at_eof;
+       /* When less_is_more is set, the -e flag semantics are different. */
+       return quit_at_eof ? OPT_ON : OPT_ONPLUS;
+}
diff --git a/thirdparty/less/option.h b/thirdparty/less/option.h
new file mode 100644 (file)
index 0000000..a32139e
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+#define        END_OPTION_STRING       ('$')
+
+/*
+ * Types of options.
+ */
+#define        BOOL            01      /* Boolean option: 0 or 1 */
+#define        TRIPLE          02      /* Triple-valued option: 0, 1 or 2 */
+#define        NUMBER          04      /* Numeric option */
+#define        STRING          010     /* String-valued option */
+#define        NOVAR           020     /* No associated variable */
+#define        REPAINT         040     /* Repaint screen after toggling option */
+#define        NO_TOGGLE       0100    /* Option cannot be toggled with "-" cmd */
+#define        HL_REPAINT      0200    /* Repaint hilites after toggling option */
+#define        NO_QUERY        0400    /* Option cannot be queried with "_" cmd */
+#define        INIT_HANDLER    01000   /* Call option handler function at startup */
+
+#define        OTYPE           (BOOL|TRIPLE|NUMBER|STRING|NOVAR)
+
+#define OLETTER_NONE    '\1'     /* Invalid option letter */
+
+/*
+ * Argument to a handling function tells what type of activity:
+ */
+#define        INIT    0       /* Initialization (from command line) */
+#define        QUERY   1       /* Query (from _ or - command) */
+#define        TOGGLE  2       /* Change value (from - command) */
+
+/* Flag to toggle_option to specify how to "toggle" */
+#define        OPT_NO_TOGGLE   0
+#define        OPT_TOGGLE      1
+#define        OPT_UNSET       2
+#define        OPT_SET         3
+#define OPT_NO_PROMPT  0100
+
+/* Error code from findopt_name */
+#define OPT_AMBIG       1
+
+struct optname
+{
+       char *oname;            /* Long (GNU-style) option name */
+       struct optname *onext;  /* List of synonymous option names */
+};
+
+#define OPTNAME_MAX    32      /* Max length of long option name */
+
+struct loption
+{
+       char oletter;           /* The controlling letter (a-z) */
+       struct optname *onames; /* Long (GNU-style) option name */
+       int otype;              /* Type of the option */
+       int odefault;           /* Default value */
+       int *ovar;              /* Pointer to the associated variable */
+       void (*ofunc)();        /* Pointer to special handling function */
+       char *odesc[3];         /* Description of each value */
+};
+
diff --git a/thirdparty/less/opttbl.c b/thirdparty/less/opttbl.c
new file mode 100644 (file)
index 0000000..63f6889
--- /dev/null
@@ -0,0 +1,599 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * The option table.
+ */
+
+#include "less.h"
+#include "option.h"
+
+/*
+ * Variables controlled by command line options.
+ */
+public int quiet;              /* Should we suppress the audible bell? */
+public int how_search;         /* Where should forward searches start? */
+public int top_scroll;         /* Repaint screen from top?
+                                  (alternative is scroll from bottom) */
+public int pr_type;            /* Type of prompt (short, medium, long) */
+public int bs_mode;            /* How to process backspaces */
+public int know_dumb;          /* Don't complain about dumb terminals */
+public int quit_at_eof;                /* Quit after hitting end of file twice */
+public int quit_if_one_screen; /* Quit if EOF on first screen */
+public int squeeze;            /* Squeeze multiple blank lines into one */
+public int tabstop;            /* Tab settings */
+public int back_scroll;                /* Repaint screen on backwards movement */
+public int forw_scroll;                /* Repaint screen on forward movement */
+public int caseless;           /* Do "caseless" searches */
+public int linenums;           /* Use line numbers */
+public int autobuf;            /* Automatically allocate buffers as needed */
+public int bufspace;           /* Max buffer space per file (K) */
+public int ctldisp;            /* Send control chars to screen untranslated */
+public int force_open;         /* Open the file even if not regular file */
+public int swindow;            /* Size of scrolling window */
+public int jump_sline;         /* Screen line of "jump target" */
+public long jump_sline_fraction = -1;
+public long shift_count_fraction = -1;
+public int chopline;           /* Truncate displayed lines at screen width */
+public int no_init;            /* Disable sending ti/te termcap strings */
+public int no_keypad;          /* Disable sending ks/ke termcap strings */
+public int twiddle;             /* Show tildes after EOF */
+public int show_attn;          /* Hilite first unread line */
+public int shift_count;                /* Number of positions to shift horizontally */
+public int status_col;         /* Display a status column */
+public int use_lessopen;       /* Use the LESSOPEN filter */
+public int quit_on_intr;       /* Quit on interrupt */
+public int follow_mode;                /* F cmd Follows file desc or file name? */
+public int oldbot;             /* Old bottom of screen behavior {{REMOVE}} */
+#if HILITE_SEARCH
+public int hilite_search;      /* Highlight matched search patterns? */
+#endif
+
+public int less_is_more = 0;   /* Make compatible with POSIX more */
+
+/*
+ * Long option names.
+ */
+static struct optname a_optname      = { "search-skip-screen",   NULL };
+static struct optname b_optname      = { "buffers",              NULL };
+static struct optname B__optname     = { "auto-buffers",         NULL };
+static struct optname c_optname      = { "clear-screen",         NULL };
+static struct optname d_optname      = { "dumb",                 NULL };
+#if MSDOS_COMPILER
+static struct optname D__optname     = { "color",                NULL };
+#endif
+static struct optname e_optname      = { "quit-at-eof",          NULL };
+static struct optname f_optname      = { "force",                NULL };
+static struct optname F__optname     = { "quit-if-one-screen",   NULL };
+#if HILITE_SEARCH
+static struct optname g_optname      = { "hilite-search",        NULL };
+#endif
+static struct optname h_optname      = { "max-back-scroll",      NULL };
+static struct optname i_optname      = { "ignore-case",          NULL };
+static struct optname j_optname      = { "jump-target",          NULL };
+static struct optname J__optname     = { "status-column",        NULL };
+#if USERFILE
+static struct optname k_optname      = { "lesskey-file",         NULL };
+#endif
+static struct optname K__optname     = { "quit-on-intr",         NULL };
+static struct optname L__optname     = { "no-lessopen",          NULL };
+static struct optname m_optname      = { "long-prompt",          NULL };
+static struct optname n_optname      = { "line-numbers",         NULL };
+#if LOGFILE
+static struct optname o_optname      = { "log-file",             NULL };
+static struct optname O__optname     = { "LOG-FILE",             NULL };
+#endif
+static struct optname p_optname      = { "pattern",              NULL };
+static struct optname P__optname     = { "prompt",               NULL };
+static struct optname q2_optname     = { "silent",               NULL };
+static struct optname q_optname      = { "quiet",                &q2_optname };
+static struct optname r_optname      = { "raw-control-chars",    NULL };
+static struct optname s_optname      = { "squeeze-blank-lines",  NULL };
+static struct optname S__optname     = { "chop-long-lines",      NULL };
+#if TAGS
+static struct optname t_optname      = { "tag",                  NULL };
+static struct optname T__optname     = { "tag-file",             NULL };
+#endif
+static struct optname u_optname      = { "underline-special",    NULL };
+static struct optname V__optname     = { "version",              NULL };
+static struct optname w_optname      = { "hilite-unread",        NULL };
+static struct optname x_optname      = { "tabs",                 NULL };
+static struct optname X__optname     = { "no-init",              NULL };
+static struct optname y_optname      = { "max-forw-scroll",      NULL };
+static struct optname z_optname      = { "window",               NULL };
+static struct optname quote_optname  = { "quotes",               NULL };
+static struct optname tilde_optname  = { "tilde",                NULL };
+static struct optname query_optname  = { "help",                 NULL };
+static struct optname pound_optname  = { "shift",                NULL };
+static struct optname keypad_optname = { "no-keypad",            NULL };
+static struct optname oldbot_optname = { "old-bot",              NULL };
+static struct optname follow_optname = { "follow-name",          NULL };
+
+
+/*
+ * Table of all options and their semantics.
+ *
+ * For BOOL and TRIPLE options, odesc[0], odesc[1], odesc[2] are
+ * the description of the option when set to 0, 1 or 2, respectively.
+ * For NUMBER options, odesc[0] is the prompt to use when entering
+ * a new value, and odesc[1] is the description, which should contain 
+ * one %d which is replaced by the value of the number.
+ * For STRING options, odesc[0] is the prompt to use when entering
+ * a new value, and odesc[1], if not NULL, is the set of characters
+ * that are valid in the string.
+ */
+static struct loption option[] =
+{
+       { 'a', &a_optname,
+               TRIPLE, OPT_ONPLUS, &how_search, NULL,
+               {
+                       "Search includes displayed screen",
+                       "Search skips displayed screen",
+                       "Search includes all of displayed screen"
+               }
+       },
+
+       { 'b', &b_optname,
+               NUMBER|INIT_HANDLER, 64, &bufspace, opt_b, 
+               {
+                       "Max buffer space per file (K): ",
+                       "Max buffer space per file: %dK",
+                       NULL
+               }
+       },
+       { 'B', &B__optname,
+               BOOL, OPT_ON, &autobuf, NULL,
+               {
+                       "Don't automatically allocate buffers",
+                       "Automatically allocate buffers when needed",
+                       NULL
+               }
+       },
+       { 'c', &c_optname,
+               TRIPLE, OPT_OFF, &top_scroll, NULL,
+               {
+                       "Repaint by scrolling from bottom of screen",
+                       "Repaint by painting from top of screen",
+                       "Repaint by painting from top of screen"
+               }
+       },
+       { 'd', &d_optname,
+               BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL,
+               {
+                       "Assume intelligent terminal",
+                       "Assume dumb terminal",
+                       NULL
+               }
+       },
+#if MSDOS_COMPILER
+       { 'D', &D__optname,
+               STRING|REPAINT|NO_QUERY, 0, NULL, opt_D,
+               {
+                       "color desc: ", 
+                       "Ddknsu0123456789.",
+                       NULL
+               }
+       },
+#endif
+       { 'e', &e_optname,
+               TRIPLE, OPT_OFF, &quit_at_eof, NULL,
+               {
+                       "Don't quit at end-of-file",
+                       "Quit at end-of-file",
+                       "Quit immediately at end-of-file"
+               }
+       },
+       { 'f', &f_optname,
+               BOOL, OPT_OFF, &force_open, NULL,
+               {
+                       "Open only regular files",
+                       "Open even non-regular files",
+                       NULL
+               }
+       },
+       { 'F', &F__optname,
+               BOOL, OPT_OFF, &quit_if_one_screen, NULL,
+               {
+                       "Don't quit if end-of-file on first screen",
+                       "Quit if end-of-file on first screen",
+                       NULL
+               }
+       },
+#if HILITE_SEARCH
+       { 'g', &g_optname,
+               TRIPLE|HL_REPAINT, OPT_ONPLUS, &hilite_search, NULL,
+               {
+                       "Don't highlight search matches",
+                       "Highlight matches for previous search only",
+                       "Highlight all matches for previous search pattern",
+               }
+       },
+#endif
+       { 'h', &h_optname,
+               NUMBER, -1, &back_scroll, NULL,
+               {
+                       "Backwards scroll limit: ",
+                       "Backwards scroll limit is %d lines",
+                       NULL
+               }
+       },
+       { 'i', &i_optname,
+               TRIPLE|HL_REPAINT, OPT_OFF, &caseless, opt_i,
+               {
+                       "Case is significant in searches",
+                       "Ignore case in searches",
+                       "Ignore case in searches and in patterns"
+               }
+       },
+       { 'j', &j_optname,
+               STRING, 0, NULL, opt_j,
+               {
+                       "Target line: ",
+                       "0123456789.-",
+                       NULL
+               }
+       },
+       { 'J', &J__optname,
+               BOOL|REPAINT, OPT_OFF, &status_col, NULL,
+               {
+                       "Don't display a status column",
+                       "Display a status column",
+                       NULL
+               }
+       },
+#if USERFILE
+       { 'k', &k_optname,
+               STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_k,
+               { NULL, NULL, NULL }
+       },
+#endif
+       { 'K', &K__optname,
+               BOOL, OPT_OFF, &quit_on_intr, NULL,
+               {
+                       "Interrupt (ctrl-C) returns to prompt",
+                       "Interrupt (ctrl-C) exits less",
+                       NULL
+               }
+       },
+       { 'L', &L__optname,
+               BOOL, OPT_ON, &use_lessopen, NULL,
+               {
+                       "Don't use the LESSOPEN filter",
+                       "Use the LESSOPEN filter",
+                       NULL
+               }
+       },
+       { 'm', &m_optname,
+               TRIPLE, OPT_OFF, &pr_type, NULL,
+               {
+                       "Short prompt",
+                       "Medium prompt",
+                       "Long prompt"
+               }
+       },
+       { 'n', &n_optname,
+               TRIPLE|REPAINT, OPT_ON, &linenums, NULL,
+               {
+                       "Don't use line numbers",
+                       "Use line numbers",
+                       "Constantly display line numbers"
+               }
+       },
+#if LOGFILE
+       { 'o', &o_optname,
+               STRING, 0, NULL, opt_o,
+               { "log file: ", NULL, NULL }
+       },
+       { 'O', &O__optname,
+               STRING, 0, NULL, opt__O,
+               { "Log file: ", NULL, NULL }
+       },
+#endif
+       { 'p', &p_optname,
+               STRING|NO_TOGGLE|NO_QUERY, 0, NULL, opt_p,
+               { NULL, NULL, NULL }
+       },
+       { 'P', &P__optname,
+               STRING, 0, NULL, opt__P,
+               { "prompt: ", NULL, NULL }
+       },
+       { 'q', &q_optname,
+               TRIPLE, OPT_OFF, &quiet, NULL,
+               {
+                       "Ring the bell for errors AND at eof/bof",
+                       "Ring the bell for errors but not at eof/bof",
+                       "Never ring the bell"
+               }
+       },
+       { 'r', &r_optname,
+               TRIPLE|REPAINT, OPT_OFF, &ctldisp, NULL,
+               {
+                       "Display control characters as ^X",
+                       "Display control characters directly",
+                       "Display control characters directly, processing ANSI sequences"
+               }
+       },
+       { 's', &s_optname,
+               BOOL|REPAINT, OPT_OFF, &squeeze, NULL,
+               {
+                       "Display all blank lines",
+                       "Squeeze multiple blank lines",
+                       NULL
+               }
+       },
+       { 'S', &S__optname,
+               BOOL|REPAINT, OPT_OFF, &chopline, NULL,
+               {
+                       "Fold long lines",
+                       "Chop long lines",
+                       NULL
+               }
+       },
+#if TAGS
+       { 't', &t_optname,
+               STRING|NO_QUERY, 0, NULL, opt_t,
+               { "tag: ", NULL, NULL }
+       },
+       { 'T', &T__optname,
+               STRING, 0, NULL, opt__T,
+               { "tags file: ", NULL, NULL }
+       },
+#endif
+       { 'u', &u_optname,
+               TRIPLE|REPAINT, OPT_OFF, &bs_mode, NULL,
+               {
+                       "Display underlined text in underline mode",
+                       "Backspaces cause overstrike",
+                       "Print backspace as ^H"
+               }
+       },
+       { 'V', &V__optname,
+               NOVAR, 0, NULL, opt__V,
+               { NULL, NULL, NULL }
+       },
+       { 'w', &w_optname,
+               TRIPLE|REPAINT, OPT_OFF, &show_attn, NULL,
+               {
+                       "Don't highlight first unread line",
+                       "Highlight first unread line after forward-screen",
+                       "Highlight first unread line after any forward movement",
+               }
+       },
+       { 'x', &x_optname,
+               STRING|REPAINT, 0, NULL, opt_x,
+               {
+                       "Tab stops: ",
+                       "0123456789,",
+                       NULL
+               }
+       },
+       { 'X', &X__optname,
+               BOOL|NO_TOGGLE, OPT_OFF, &no_init, NULL,
+               {
+                       "Send init/deinit strings to terminal",
+                       "Don't use init/deinit strings",
+                       NULL
+               }
+       },
+       { 'y', &y_optname,
+               NUMBER, -1, &forw_scroll, NULL,
+               {
+                       "Forward scroll limit: ",
+                       "Forward scroll limit is %d lines",
+                       NULL
+               }
+       },
+       { 'z', &z_optname,
+               NUMBER, -1, &swindow, NULL,
+               {
+                       "Scroll window size: ",
+                       "Scroll window size is %d lines",
+                       NULL
+               }
+       },
+       { '"', &quote_optname,
+               STRING, 0, NULL, opt_quote,
+               { "quotes: ", NULL, NULL }
+       },
+       { '~', &tilde_optname,
+               BOOL|REPAINT, OPT_ON, &twiddle, NULL,
+               {
+                       "Don't show tildes after end of file",
+                       "Show tildes after end of file",
+                       NULL
+               }
+       },
+       { '?', &query_optname,
+               NOVAR, 0, NULL, opt_query,
+               { NULL, NULL, NULL }
+       },
+       { '#', &pound_optname,
+               STRING, 0, NULL, opt_shift,
+               {
+                       "Horizontal shift: ",
+                       "0123456789.",
+                       NULL
+               }
+       },
+       { OLETTER_NONE, &keypad_optname,
+               BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL,
+               {
+                       "Use keypad mode",
+                       "Don't use keypad mode",
+                       NULL
+               }
+       },
+       { OLETTER_NONE, &oldbot_optname,
+               BOOL, OPT_OFF, &oldbot, NULL,
+               {
+                       "Use new bottom of screen behavior",
+                       "Use old bottom of screen behavior",
+                       NULL
+               }
+       },
+       { OLETTER_NONE, &follow_optname,
+               BOOL, FOLLOW_DESC, &follow_mode, NULL,
+               {
+                       "F command follows file descriptor",
+                       "F command follows file name",
+                       NULL
+               }
+       },
+       { '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } }
+};
+
+
+/*
+ * Initialize each option to its default value.
+ */
+       public void
+init_option()
+{
+       register struct loption *o;
+       char *p;
+
+       p = lgetenv("LESS_IS_MORE");
+       if (p != NULL && *p != '\0')
+               less_is_more = 1;
+
+       for (o = option;  o->oletter != '\0';  o++)
+       {
+               /*
+                * Set each variable to its default.
+                */
+               if (o->ovar != NULL)
+                       *(o->ovar) = o->odefault;
+               if (o->otype & INIT_HANDLER)
+                       (*(o->ofunc))(INIT, (char *) NULL);
+       }
+}
+
+/*
+ * Find an option in the option table, given its option letter.
+ */
+       public struct loption *
+findopt(c)
+       int c;
+{
+       register struct loption *o;
+
+       for (o = option;  o->oletter != '\0';  o++)
+       {
+               if (o->oletter == c)
+                       return (o);
+               if ((o->otype & TRIPLE) && ASCII_TO_UPPER(o->oletter) == c)
+                       return (o);
+       }
+       return (NULL);
+}
+
+/*
+ *
+ */
+       static int
+is_optchar(c)
+       char c;
+{
+       if (ASCII_IS_UPPER(c))
+               return 1;
+       if (ASCII_IS_LOWER(c))
+               return 1;
+       if (c == '-')
+               return 1;
+       return 0;
+}
+
+/*
+ * Find an option in the option table, given its option name.
+ * p_optname is the (possibly partial) name to look for, and
+ * is updated to point after the matched name.
+ * p_oname if non-NULL is set to point to the full option name.
+ */
+       public struct loption *
+findopt_name(p_optname, p_oname, p_err)
+       char **p_optname;
+       char **p_oname;
+       int *p_err;
+{
+       char *optname = *p_optname;
+       register struct loption *o;
+       register struct optname *oname;
+       register int len;
+       int uppercase;
+       struct loption *maxo = NULL;
+       struct optname *maxoname = NULL;
+       int maxlen = 0;
+       int ambig = 0;
+       int exact = 0;
+
+       /*
+        * Check all options.
+        */
+       for (o = option;  o->oletter != '\0';  o++)
+       {
+               /*
+                * Check all names for this option.
+                */
+               for (oname = o->onames;  oname != NULL;  oname = oname->onext)
+               {
+                       /* 
+                        * Try normal match first (uppercase == 0),
+                        * then, then if it's a TRIPLE option,
+                        * try uppercase match (uppercase == 1).
+                        */
+                       for (uppercase = 0;  uppercase <= 1;  uppercase++)
+                       {
+                               len = sprefix(optname, oname->oname, uppercase);
+                               if (len <= 0 || is_optchar(optname[len]))
+                               {
+                                       /*
+                                        * We didn't use all of the option name.
+                                        */
+                                       continue;
+                               }
+                               if (!exact && len == maxlen)
+                                       /*
+                                        * Already had a partial match,
+                                        * and now there's another one that
+                                        * matches the same length.
+                                        */
+                                       ambig = 1;
+                               else if (len > maxlen)
+                               {
+                                       /*
+                                        * Found a better match than
+                                        * the one we had.
+                                        */
+                                       maxo = o;
+                                       maxoname = oname;
+                                       maxlen = len;
+                                       ambig = 0;
+                                       exact = (len == (int)strlen(oname->oname));
+                               }
+                               if (!(o->otype & TRIPLE))
+                                       break;
+                       }
+               }
+       }
+       if (ambig)
+       {
+               /*
+                * Name matched more than one option.
+                */
+               if (p_err != NULL)
+                       *p_err = OPT_AMBIG;
+               return (NULL);
+       }
+       *p_optname = optname + maxlen;
+       if (p_oname != NULL)
+               *p_oname = maxoname == NULL ? NULL : maxoname->oname;
+       return (maxo);
+}
diff --git a/thirdparty/less/os.c b/thirdparty/less/os.c
new file mode 100644 (file)
index 0000000..dbb52fe
--- /dev/null
@@ -0,0 +1,364 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Operating system dependent routines.
+ *
+ * Most of the stuff in here is based on Unix, but an attempt
+ * has been made to make things work on other operating systems.
+ * This will sometimes result in a loss of functionality, unless
+ * someone rewrites code specifically for the new operating system.
+ *
+ * The makefile provides defines to decide whether various
+ * Unix features are present.
+ */
+
+#include "less.h"
+#include <signal.h>
+#include <setjmp.h>
+#if HAVE_TIME_H
+#include <time.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#if HAVE_VALUES_H
+#include <values.h>
+#endif
+
+#if HAVE_TIME_T
+#define time_type      time_t
+#else
+#define        time_type       long
+#endif
+
+/*
+ * BSD setjmp() saves (and longjmp() restores) the signal mask.
+ * This costs a system call or two per setjmp(), so if possible we clear the
+ * signal mask with sigsetmask(), and use _setjmp()/_longjmp() instead.
+ * On other systems, setjmp() doesn't affect the signal mask and so
+ * _setjmp() does not exist; we just use setjmp().
+ */
+#if HAVE__SETJMP && HAVE_SIGSETMASK
+#define SET_JUMP       _setjmp
+#define LONG_JUMP      _longjmp
+#else
+#define SET_JUMP       setjmp
+#define LONG_JUMP      longjmp
+#endif
+
+public int reading;
+
+static jmp_buf read_label;
+
+extern int sigs;
+
+/*
+ * Like read() system call, but is deliberately interruptible.
+ * A call to intread() from a signal handler will interrupt
+ * any pending iread().
+ */
+       public int
+iread(fd, buf, len)
+       int fd;
+       char *buf;
+       unsigned int len;
+{
+       register int n;
+
+start:
+#if MSDOS_COMPILER==WIN32C
+       if (ABORT_SIGS())
+               return (READ_INTR);
+#else
+#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
+       if (kbhit())
+       {
+               int c;
+               
+               c = getch();
+               if (c == '\003')
+                       return (READ_INTR);
+               ungetch(c);
+       }
+#endif
+#endif
+       if (SET_JUMP(read_label))
+       {
+               /*
+                * We jumped here from intread.
+                */
+               reading = 0;
+#if HAVE_SIGPROCMASK
+               {
+                 sigset_t mask;
+                 sigemptyset(&mask);
+                 sigprocmask(SIG_SETMASK, &mask, NULL);
+               }
+#else
+#if HAVE_SIGSETMASK
+               sigsetmask(0);
+#else
+#ifdef _OSK
+               sigmask(~0);
+#endif
+#endif
+#endif
+               return (READ_INTR);
+       }
+
+       flush();
+       reading = 1;
+#if MSDOS_COMPILER==DJGPPC
+       if (isatty(fd))
+       {
+               /*
+                * Don't try reading from a TTY until a character is
+                * available, because that makes some background programs
+                * believe DOS is busy in a way that prevents those
+                * programs from working while "less" waits.
+                */
+               fd_set readfds;
+
+               FD_ZERO(&readfds);
+               FD_SET(fd, &readfds);
+               if (select(fd+1, &readfds, 0, 0, 0) == -1)
+                       return (-1);
+       }
+#endif
+       n = read(fd, buf, len);
+#if 1
+       /*
+        * This is a kludge to workaround a problem on some systems
+        * where terminating a remote tty connection causes read() to
+        * start returning 0 forever, instead of -1.
+        */
+       {
+               extern int ignore_eoi;
+               if (!ignore_eoi)
+               {
+                       static int consecutive_nulls = 0;
+                       if (n == 0)
+                               consecutive_nulls++;
+                       else
+                               consecutive_nulls = 0;
+                       if (consecutive_nulls > 20)
+                               quit(QUIT_ERROR);
+               }
+       }
+#endif
+       reading = 0;
+       if (n < 0)
+       {
+#if HAVE_ERRNO
+               /*
+                * Certain values of errno indicate we should just retry the read.
+                */
+#if MUST_DEFINE_ERRNO
+               extern int errno;
+#endif
+#ifdef EINTR
+               if (errno == EINTR)
+                       goto start;
+#endif
+#ifdef EAGAIN
+               if (errno == EAGAIN)
+                       goto start;
+#endif
+#endif
+               return (-1);
+       }
+       return (n);
+}
+
+/*
+ * Interrupt a pending iread().
+ */
+       public void
+intread()
+{
+       LONG_JUMP(read_label, 1);
+}
+
+/*
+ * Return the current time.
+ */
+#if HAVE_TIME
+       public long
+get_time()
+{
+       time_type t;
+
+       time(&t);
+       return (t);
+}
+#endif
+
+
+#if !HAVE_STRERROR
+/*
+ * Local version of strerror, if not available from the system.
+ */
+       static char *
+strerror(err)
+       int err;
+{
+#if HAVE_SYS_ERRLIST
+       static char buf[16];
+       extern char *sys_errlist[];
+       extern int sys_nerr;
+  
+       if (err < sys_nerr)
+               return sys_errlist[err];
+       sprintf(buf, "Error %d", err);
+       return buf;
+#else
+       return ("cannot open");
+#endif
+}
+#endif
+
+/*
+ * errno_message: Return an error message based on the value of "errno".
+ */
+       public char *
+errno_message(filename)
+       char *filename;
+{
+       register char *p;
+       register char *m;
+       int len;
+#if HAVE_ERRNO
+#if MUST_DEFINE_ERRNO
+       extern int errno;
+#endif
+       p = strerror(errno);
+#else
+       p = "cannot open";
+#endif
+       len = strlen(filename) + strlen(p) + 3;
+       m = (char *) ecalloc(len, sizeof(char));
+       SNPRINTF2(m, len, "%s: %s", filename, p);
+       return (m);
+}
+
+/* #define HAVE_FLOAT 0 */
+
+       static POSITION
+muldiv(val, num, den)
+       POSITION val, num, den;
+{
+#if HAVE_FLOAT
+       double v = (((double) val) * num) / den;
+       return ((POSITION) (v + 0.5));
+#else
+       POSITION v = ((POSITION) val) * num;
+
+       if (v / num == val)
+               /* No overflow */
+               return (POSITION) (v / den);
+       else
+               /* Above calculation overflows; 
+                * use a method that is less precise but won't overflow. */
+               return (POSITION) (val / (den / num));
+#endif
+}
+
+/*
+ * Return the ratio of two POSITIONS, as a percentage.
+ * {{ Assumes a POSITION is a long int. }}
+ */
+       public int
+percentage(num, den)
+       POSITION num, den;
+{
+       return (int) muldiv(num,  (POSITION) 100, den);
+}
+
+/*
+ * Return the specified percentage of a POSITION.
+ */
+       public POSITION
+percent_pos(pos, percent, fraction)
+       POSITION pos;
+       int percent;
+       long fraction;
+{
+       /* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */
+       POSITION perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100);
+
+       if (perden == 0)
+               return (0);
+       return (POSITION) muldiv(pos, perden, (POSITION) NUM_FRAC_DENOM);
+}
+
+#if !HAVE_STRCHR
+/*
+ * strchr is used by regexp.c.
+ */
+       char *
+strchr(s, c)
+       char *s;
+       int c;
+{
+       for ( ;  *s != '\0';  s++)
+               if (*s == c)
+                       return (s);
+       if (c == '\0')
+               return (s);
+       return (NULL);
+}
+#endif
+
+#if !HAVE_MEMCPY
+       VOID_POINTER
+memcpy(dst, src, len)
+       VOID_POINTER dst;
+       VOID_POINTER src;
+       int len;
+{
+       char *dstp = (char *) dst;
+       char *srcp = (char *) src;
+       int i;
+
+       for (i = 0;  i < len;  i++)
+               dstp[i] = srcp[i];
+       return (dst);
+}
+#endif
+
+#ifdef _OSK_MWC32
+
+/*
+ * This implements an ANSI-style intercept setup for Microware C 3.2
+ */
+       public int 
+os9_signal(type, handler)
+       int type;
+       RETSIGTYPE (*handler)();
+{
+       intercept(handler);
+}
+
+#include <sgstat.h>
+
+       int 
+isatty(f)
+       int f;
+{
+       struct sgbuf sgbuf;
+
+       if (_gs_opt(f, &sgbuf) < 0)
+               return -1;
+       return (sgbuf.sg_class == 0);
+}
+       
+#endif
diff --git a/thirdparty/less/output.c b/thirdparty/less/output.c
new file mode 100644 (file)
index 0000000..a4fdada
--- /dev/null
@@ -0,0 +1,601 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * High level routines dealing with the output to the screen.
+ */
+
+#include "less.h"
+#if MSDOS_COMPILER==WIN32C
+#include "windows.h"
+#endif
+
+public int errmsgs;    /* Count of messages displayed by error() */
+public int need_clr;
+public int final_attr;
+public int at_prompt;
+
+extern int sigs;
+extern int sc_width;
+extern int so_s_width, so_e_width;
+extern int screen_trashed;
+extern int any_display;
+extern int is_tty;
+extern int oldbot;
+
+#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+extern int ctldisp;
+extern int nm_fg_color, nm_bg_color;
+extern int bo_fg_color, bo_bg_color;
+extern int ul_fg_color, ul_bg_color;
+extern int so_fg_color, so_bg_color;
+extern int bl_fg_color, bl_bg_color;
+#endif
+
+/*
+ * Display the line which is in the line buffer.
+ */
+       public void
+put_line()
+{
+       register int c;
+       register int i;
+       int a;
+
+       if (ABORT_SIGS())
+       {
+               /*
+                * Don't output if a signal is pending.
+                */
+               screen_trashed = 1;
+               return;
+       }
+
+       final_attr = AT_NORMAL;
+
+       for (i = 0;  (c = gline(i, &a)) != '\0';  i++)
+       {
+               at_switch(a);
+               final_attr = a;
+               if (c == '\b')
+                       putbs();
+               else
+                       putchr(c);
+       }
+
+       at_exit();
+}
+
+static char obuf[OUTBUF_SIZE];
+static char *ob = obuf;
+
+/*
+ * Flush buffered output.
+ *
+ * If we haven't displayed any file data yet,
+ * output messages on error output (file descriptor 2),
+ * otherwise output on standard output (file descriptor 1).
+ *
+ * This has the desirable effect of producing all
+ * error messages on error output if standard output
+ * is directed to a file.  It also does the same if
+ * we never produce any real output; for example, if
+ * the input file(s) cannot be opened.  If we do
+ * eventually produce output, code in edit() makes
+ * sure these messages can be seen before they are
+ * overwritten or scrolled away.
+ */
+       public void
+flush()
+{
+       register int n;
+       register int fd;
+
+       n = ob - obuf;
+       if (n == 0)
+               return;
+
+#if MSDOS_COMPILER==MSOFTC
+       if (is_tty && any_display)
+       {
+               *ob = '\0';
+               _outtext(obuf);
+               ob = obuf;
+               return;
+       }
+#else
+#if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+       if (is_tty && any_display)
+       {
+               *ob = '\0';
+               if (ctldisp != OPT_ONPLUS)
+                       WIN32textout(obuf, ob - obuf);
+               else
+               {
+                       /*
+                        * Look for SGR escape sequences, and convert them
+                        * to color commands.  Replace bold, underline,
+                        * and italic escapes into colors specified via
+                        * the -D command-line option.
+                        */
+                       char *anchor, *p, *p_next;
+                       unsigned char fg, bg;
+                       static unsigned char at;
+#if MSDOS_COMPILER==WIN32C
+                       /* Screen colors used by 3x and 4x SGR commands. */
+                       static unsigned char screen_color[] = {
+                               0, /* BLACK */
+                               FOREGROUND_RED,
+                               FOREGROUND_GREEN,
+                               FOREGROUND_RED|FOREGROUND_GREEN,
+                               FOREGROUND_BLUE, 
+                               FOREGROUND_BLUE|FOREGROUND_RED,
+                               FOREGROUND_BLUE|FOREGROUND_GREEN,
+                               FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED
+                       };
+#else
+                       static enum COLORS screen_color[] = {
+                               BLACK, RED, GREEN, BROWN,
+                               BLUE, MAGENTA, CYAN, LIGHTGRAY
+                       };
+#endif
+
+                       for (anchor = p_next = obuf;
+                            (p_next = memchr(p_next, ESC, ob - p_next)) != NULL; )
+                       {
+                               p = p_next;
+                               if (p[1] == '[')  /* "ESC-[" sequence */
+                               {
+                                       if (p > anchor)
+                                       {
+                                               /*
+                                                * If some chars seen since
+                                                * the last escape sequence,
+                                                * write them out to the screen.
+                                                */
+                                               WIN32textout(anchor, p-anchor);
+                                               anchor = p;
+                                       }
+                                       p += 2;  /* Skip the "ESC-[" */
+                                       if (is_ansi_end(*p))
+                                       {
+                                               /*
+                                                * Handle null escape sequence
+                                                * "ESC[m", which restores
+                                                * the normal color.
+                                                */
+                                               p++;
+                                               anchor = p_next = p;
+                                               WIN32setcolors(nm_fg_color, nm_bg_color);
+                                               continue;
+                                       }
+                                       p_next = p;
+
+                                       /*
+                                        * Select foreground/background colors
+                                        * based on the escape sequence. 
+                                        */
+                                       fg = nm_fg_color;
+                                       bg = nm_bg_color;
+                                       while (!is_ansi_end(*p))
+                                       {
+                                               char *q;
+                                               long code = strtol(p, &q, 10);
+
+                                               if (*q == '\0')
+                                               {
+                                                       /*
+                                                        * Incomplete sequence.
+                                                        * Leave it unprocessed
+                                                        * in the buffer.
+                                                        */
+                                                       int slop = q - anchor;
+                                                       /* {{ strcpy args overlap! }} */
+                                                       strcpy(obuf, anchor);
+                                                       ob = &obuf[slop];
+                                                       return;
+                                               }
+
+                                               if (q == p ||
+                                                   code > 49 || code < 0 ||
+                                                   (!is_ansi_end(*q) && *q != ';'))
+                                               {
+                                                       p_next = q;
+                                                       break;
+                                               }
+                                               if (*q == ';')
+                                                       q++;
+
+                                               switch (code)
+                                               {
+                                               default:
+                                               /* case 0: all attrs off */
+                                                       fg = nm_fg_color;
+                                                       bg = nm_bg_color;
+                                                       at = 0;
+                                                       break;
+                                               case 1: /* bold on */
+                                                       at |= 1;
+                                                       break;
+                                               case 3: /* italic on */
+                                               case 7: /* inverse on */
+                                                       at |= 2;
+                                                       break;
+                                               case 4: /* underline on */
+                                                       at |= 4;
+                                                       break;
+                                               case 5: /* slow blink on */
+                                               case 6: /* fast blink on */
+                                                       at |= 8;
+                                                       break;
+                                               case 8: /* concealed on */
+                                                       fg = (bg & 7) | 8;
+                                                       break;
+                                               case 22: /* bold off */
+                                                       at &= ~1;
+                                                       break;
+                                               case 23: /* italic off */
+                                               case 27: /* inverse off */
+                                                       at &= ~2;
+                                                       break;
+                                               case 24: /* underline off */
+                                                       at &= ~4;
+                                                       break;
+                                               case 30: case 31: case 32:
+                                               case 33: case 34: case 35:
+                                               case 36: case 37:
+                                                       fg = (fg & 8) | (screen_color[code - 30]);
+                                                       break;
+                                               case 39: /* default fg */
+                                                       fg = nm_fg_color;
+                                                       break;
+                                               case 40: case 41: case 42:
+                                               case 43: case 44: case 45:
+                                               case 46: case 47:
+                                                       bg = (bg & 8) | (screen_color[code - 40]);
+                                                       break;
+                                               case 49: /* default fg */
+                                                       bg = nm_bg_color;
+                                                       break;
+                                               }
+                                               p = q;
+                                       }
+                                       if (!is_ansi_end(*p) || p == p_next)
+                                               break;
+                                       if (at & 1)
+                                       {
+                                                       fg = bo_fg_color;
+                                                       bg = bo_bg_color;
+                                       } else if (at & 2)
+                                       {
+                                                       fg = so_fg_color;
+                                                       bg = so_bg_color;
+                                       } else if (at & 4)
+                                       {
+                                                       fg = ul_fg_color;
+                                                       bg = ul_bg_color;
+                                       } else if (at & 8)
+                                       {
+                                                       fg = bl_fg_color;
+                                                       bg = bl_bg_color;
+                                       }
+                                       fg &= 0xf;
+                                       bg &= 0xf;
+                                       WIN32setcolors(fg, bg);
+                                       p_next = anchor = p + 1;
+                               } else
+                                       p_next++;
+                       }
+
+                       /* Output what's left in the buffer.  */
+                       WIN32textout(anchor, ob - anchor);
+               }
+               ob = obuf;
+               return;
+       }
+#endif
+#endif
+       fd = (any_display) ? 1 : 2;
+       if (write(fd, obuf, n) != n)
+               screen_trashed = 1;
+       ob = obuf;
+}
+
+/*
+ * Output a character.
+ */
+       public int
+putchr(c)
+       int c;
+{
+#if 0 /* fake UTF-8 output for testing */
+       extern int utf_mode;
+       if (utf_mode)
+       {
+               static char ubuf[MAX_UTF_CHAR_LEN];
+               static int ubuf_len = 0;
+               static int ubuf_index = 0;
+               if (ubuf_len == 0)
+               {
+                       ubuf_len = utf_len(c);
+                       ubuf_index = 0;
+               }
+               ubuf[ubuf_index++] = c;
+               if (ubuf_index < ubuf_len)
+                       return c;
+               c = get_wchar(ubuf) & 0xFF;
+               ubuf_len = 0;
+       }
+#endif
+       if (need_clr)
+       {
+               need_clr = 0;
+               clear_bot();
+       }
+#if MSDOS_COMPILER
+       if (c == '\n' && is_tty)
+       {
+               /* remove_top(1); */
+               putchr('\r');
+       }
+#else
+#ifdef _OSK
+       if (c == '\n' && is_tty)  /* In OS-9, '\n' == 0x0D */
+               putchr(0x0A);
+#endif
+#endif
+       /*
+        * Some versions of flush() write to *ob, so we must flush
+        * when we are still one char from the end of obuf.
+        */
+       if (ob >= &obuf[sizeof(obuf)-1])
+               flush();
+       *ob++ = c;
+       at_prompt = 0;
+       return (c);
+}
+
+/*
+ * Output a string.
+ */
+       public void
+putstr(s)
+       register char *s;
+{
+       while (*s != '\0')
+               putchr(*s++);
+}
+
+
+/*
+ * Convert an integral type to a string.
+ */
+#define TYPE_TO_A_FUNC(funcname, type) \
+void funcname(num, buf) \
+       type num; \
+       char *buf; \
+{ \
+       int neg = (num < 0); \
+       char tbuf[INT_STRLEN_BOUND(num)+2]; \
+       register char *s = tbuf + sizeof(tbuf); \
+       if (neg) num = -num; \
+       *--s = '\0'; \
+       do { \
+               *--s = (num % 10) + '0'; \
+       } while ((num /= 10) != 0); \
+       if (neg) *--s = '-'; \
+       strcpy(buf, s); \
+}
+
+TYPE_TO_A_FUNC(postoa, POSITION)
+TYPE_TO_A_FUNC(linenumtoa, LINENUM)
+TYPE_TO_A_FUNC(inttoa, int)
+
+/*
+ * Output an integer in a given radix.
+ */
+       static int
+iprint_int(num)
+       int num;
+{
+       char buf[INT_STRLEN_BOUND(num)];
+
+       inttoa(num, buf);
+       putstr(buf);
+       return (strlen(buf));
+}
+
+/*
+ * Output a line number in a given radix.
+ */
+       static int
+iprint_linenum(num)
+       LINENUM num;
+{
+       char buf[INT_STRLEN_BOUND(num)];
+
+       linenumtoa(num, buf);
+       putstr(buf);
+       return (strlen(buf));
+}
+
+/*
+ * This function implements printf-like functionality
+ * using a more portable argument list mechanism than printf's.
+ */
+       static int
+less_printf(fmt, parg)
+       register char *fmt;
+       PARG *parg;
+{
+       register char *s;
+       register int col;
+
+       col = 0;
+       while (*fmt != '\0')
+       {
+               if (*fmt != '%')
+               {
+                       putchr(*fmt++);
+                       col++;
+               } else
+               {
+                       ++fmt;
+                       switch (*fmt++)
+                       {
+                       case 's':
+                               s = parg->p_string;
+                               parg++;
+                               while (*s != '\0')
+                               {
+                                       putchr(*s++);
+                                       col++;
+                               }
+                               break;
+                       case 'd':
+                               col += iprint_int(parg->p_int);
+                               parg++;
+                               break;
+                       case 'n':
+                               col += iprint_linenum(parg->p_linenum);
+                               parg++;
+                               break;
+                       }
+               }
+       }
+       return (col);
+}
+
+/*
+ * Get a RETURN.
+ * If some other non-trivial char is pressed, unget it, so it will
+ * become the next command.
+ */
+       public void
+get_return()
+{
+       int c;
+
+#if ONLY_RETURN
+       while ((c = getchr()) != '\n' && c != '\r')
+               bell();
+#else
+       c = getchr();
+       if (c != '\n' && c != '\r' && c != ' ' && c != READ_INTR)
+               ungetcc(c);
+#endif
+}
+
+/*
+ * Output a message in the lower left corner of the screen
+ * and wait for carriage return.
+ */
+       public void
+error(fmt, parg)
+       char *fmt;
+       PARG *parg;
+{
+       int col = 0;
+       static char return_to_continue[] = "  (press RETURN)";
+
+       errmsgs++;
+
+       if (any_display && is_tty)
+       {
+               if (!oldbot)
+                       squish_check();
+               at_exit();
+               clear_bot();
+               at_enter(AT_STANDOUT);
+               col += so_s_width;
+       }
+
+       col += less_printf(fmt, parg);
+
+       if (!(any_display && is_tty))
+       {
+               putchr('\n');
+               return;
+       }
+
+       putstr(return_to_continue);
+       at_exit();
+       col += sizeof(return_to_continue) + so_e_width;
+
+       get_return();
+       lower_left();
+    clear_eol();
+
+       if (col >= sc_width)
+               /*
+                * Printing the message has probably scrolled the screen.
+                * {{ Unless the terminal doesn't have auto margins,
+                *    in which case we just hammered on the right margin. }}
+                */
+               screen_trashed = 1;
+
+       flush();
+}
+
+static char intr_to_abort[] = "... (interrupt to abort)";
+
+/*
+ * Output a message in the lower left corner of the screen
+ * and don't wait for carriage return.
+ * Usually used to warn that we are beginning a potentially
+ * time-consuming operation.
+ */
+       public void
+ierror(fmt, parg)
+       char *fmt;
+       PARG *parg;
+{
+       at_exit();
+       clear_bot();
+       at_enter(AT_STANDOUT);
+       (void) less_printf(fmt, parg);
+       putstr(intr_to_abort);
+       at_exit();
+       flush();
+       need_clr = 1;
+}
+
+/*
+ * Output a message in the lower left corner of the screen
+ * and return a single-character response.
+ */
+       public int
+query(fmt, parg)
+       char *fmt;
+       PARG *parg;
+{
+       register int c;
+       int col = 0;
+
+       if (any_display && is_tty)
+               clear_bot();
+
+       (void) less_printf(fmt, parg);
+       c = getchr();
+
+       if (!(any_display && is_tty))
+       {
+               putchr('\n');
+               return (c);
+       }
+
+       lower_left();
+       if (col >= sc_width)
+               screen_trashed = 1;
+       flush();
+
+       return (c);
+}
diff --git a/thirdparty/less/pattern.c b/thirdparty/less/pattern.c
new file mode 100644 (file)
index 0000000..ca349b6
--- /dev/null
@@ -0,0 +1,322 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+/*
+ * Routines to do pattern matching.
+ */
+
+#include "less.h"
+#include "pattern.h"
+
+extern int caseless;
+
+/*
+ * Compile a search pattern, for future use by match_pattern.
+ */
+       static int
+compile_pattern2(pattern, search_type, comp_pattern)
+       char *pattern;
+       int search_type;
+       void **comp_pattern;
+{
+       if ((search_type & SRCH_NO_REGEX) == 0)
+       {
+#if HAVE_POSIX_REGCOMP
+               regex_t *comp = (regex_t *) ecalloc(1, sizeof(regex_t));
+               regex_t **pcomp = (regex_t **) comp_pattern;
+               if (regcomp(comp, pattern, REGCOMP_FLAG))
+               {
+                       free(comp);
+                       error("Invalid pattern", NULL_PARG);
+                       return (-1);
+               }
+               if (*pcomp != NULL)
+                       regfree(*pcomp);
+               *pcomp = comp;
+#endif
+#if HAVE_PCRE
+               pcre *comp;
+               pcre **pcomp = (pcre **) comp_pattern;
+               const char *errstring;
+               int erroffset;
+               PARG parg;
+               comp = pcre_compile(pattern, 0,
+                               &errstring, &erroffset, NULL);
+               if (comp == NULL)
+               {
+                       parg.p_string = (char *) errstring;
+                       error("%s", &parg);
+                       return (-1);
+               }
+               *pcomp = comp;
+#endif
+#if HAVE_RE_COMP
+               PARG parg;
+               int *pcomp = (int *) comp_pattern;
+               if ((parg.p_string = re_comp(pattern)) != NULL)
+               {
+                       error("%s", &parg);
+                       return (-1);
+               }
+               *pcomp = 1;
+#endif
+#if HAVE_REGCMP
+               char *comp;
+               char **pcomp = (char **) comp_pattern;
+               if ((comp = regcmp(pattern, 0)) == NULL)
+               {
+                       error("Invalid pattern", NULL_PARG);
+                       return (-1);
+               }
+               if (pcomp != NULL)
+                       free(*pcomp);
+               *pcomp = comp;
+#endif
+#if HAVE_V8_REGCOMP
+               struct regexp *comp;
+               struct regexp **pcomp = (struct regexp **) comp_pattern;
+               if ((comp = regcomp(pattern)) == NULL)
+               {
+                       /*
+                        * regcomp has already printed an error message 
+                        * via regerror().
+                        */
+                       return (-1);
+               }
+               if (*pcomp != NULL)
+                       free(*pcomp);
+               *pcomp = comp;
+#endif
+       }
+       return (0);
+}
+
+/*
+ * Like compile_pattern2, but convert the pattern to lowercase if necessary.
+ */
+       public int
+compile_pattern(pattern, search_type, comp_pattern)
+       char *pattern;
+       int search_type;
+       void **comp_pattern;
+{
+       char *cvt_pattern;
+       int result;
+
+       if (caseless != OPT_ONPLUS)
+               cvt_pattern = pattern;
+       else
+       {
+               cvt_pattern = (char*) ecalloc(1, cvt_length(strlen(pattern), CVT_TO_LC));
+               cvt_text(cvt_pattern, pattern, (int *)NULL, (int *)NULL, CVT_TO_LC);
+       }
+       result = compile_pattern2(cvt_pattern, search_type, comp_pattern);
+       if (cvt_pattern != pattern)
+               free(cvt_pattern);
+       return (result);
+}
+
+/*
+ * Forget that we have a compiled pattern.
+ */
+       public void
+uncompile_pattern(pattern)
+       void **pattern;
+{
+#if HAVE_POSIX_REGCOMP
+       regex_t **pcomp = (regex_t **) pattern;
+       if (*pcomp != NULL)
+               regfree(*pcomp);
+       *pcomp = NULL;
+#endif
+#if HAVE_PCRE
+       pcre **pcomp = (pcre **) pattern;
+       if (*pcomp != NULL)
+               pcre_free(*pcomp);
+       *pcomp = NULL;
+#endif
+#if HAVE_RE_COMP
+       int *pcomp = (int *) pattern;
+       *pcomp = 0;
+#endif
+#if HAVE_REGCMP
+       char **pcomp = (char **) pattern;
+       if (*pcomp != NULL)
+               free(*pcomp);
+       *pcomp = NULL;
+#endif
+#if HAVE_V8_REGCOMP
+       struct regexp **pcomp = (struct regexp **) pattern;
+       if (*pcomp != NULL)
+               free(*pcomp);
+       *pcomp = NULL;
+#endif
+}
+
+/*
+ * Is a compiled pattern null?
+ */
+       public int
+is_null_pattern(pattern)
+       void *pattern;
+{
+#if HAVE_POSIX_REGCOMP
+       return (pattern == NULL);
+#endif
+#if HAVE_PCRE
+       return (pattern == NULL);
+#endif
+#if HAVE_RE_COMP
+       return (pattern == 0);
+#endif
+#if HAVE_REGCMP
+       return (pattern == NULL);
+#endif
+#if HAVE_V8_REGCOMP
+       return (pattern == NULL);
+#endif
+#if NO_REGEX
+       return (search_pattern != NULL);
+#endif
+}
+
+/*
+ * Simple pattern matching function.
+ * It supports no metacharacters like *, etc.
+ */
+       static int
+match(pattern, pattern_len, buf, buf_len, pfound, pend)
+       char *pattern;
+       int pattern_len;
+       char *buf;
+       int buf_len;
+       char **pfound, **pend;
+{
+       register char *pp, *lp;
+       register char *pattern_end = pattern + pattern_len;
+       register char *buf_end = buf + buf_len;
+
+       for ( ;  buf < buf_end;  buf++)
+       {
+               for (pp = pattern, lp = buf;  *pp == *lp;  pp++, lp++)
+                       if (pp == pattern_end || lp == buf_end)
+                               break;
+               if (pp == pattern_end)
+               {
+                       if (pfound != NULL)
+                               *pfound = buf;
+                       if (pend != NULL)
+                               *pend = lp;
+                       return (1);
+               }
+       }
+       return (0);
+}
+
+/*
+ * Perform a pattern match with the previously compiled pattern.
+ * Set sp and ep to the start and end of the matched string.
+ */
+       public int
+match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type)
+       void *pattern;
+       char *tpattern;
+       char *line;
+       int line_len;
+       char **sp;
+       char **ep;
+       int notbol;
+       int search_type;
+{
+       int matched;
+#if HAVE_POSIX_REGCOMP
+       regex_t *spattern = (regex_t *) pattern;
+#endif
+#if HAVE_PCRE
+       pcre *spattern = (pcre *) pattern;
+#endif
+#if HAVE_RE_COMP
+       int spattern = (int) pattern;
+#endif
+#if HAVE_REGCMP
+       char *spattern = (char *) pattern;
+#endif
+#if HAVE_V8_REGCOMP
+       struct regexp *spattern = (struct regexp *) pattern;
+#endif
+
+       if (search_type & SRCH_NO_REGEX)
+               matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep);
+       else
+       {
+#if HAVE_POSIX_REGCOMP
+       {
+               regmatch_t rm;
+               int flags = (notbol) ? REG_NOTBOL : 0;
+               matched = !regexec(spattern, line, 1, &rm, flags);
+               if (matched)
+               {
+#ifndef __WATCOMC__
+                       *sp = line + rm.rm_so;
+                       *ep = line + rm.rm_eo;
+#else
+                       *sp = rm.rm_sp;
+                       *ep = rm.rm_ep;
+#endif
+               }
+       }
+#endif
+#if HAVE_PCRE
+       {
+               int flags = (notbol) ? PCRE_NOTBOL : 0;
+               int ovector[3];
+               matched = pcre_exec(spattern, NULL, line, line_len,
+                       0, flags, ovector, 3) >= 0;
+               if (matched)
+               {
+                       *sp = line + ovector[0];
+                       *ep = line + ovector[1];
+               }
+       }
+#endif
+#if HAVE_RE_COMP
+       matched = (re_exec(line) == 1);
+       /*
+        * re_exec doesn't seem to provide a way to get the matched string.
+        */
+       *sp = *ep = NULL;
+#endif
+#if HAVE_REGCMP
+       *ep = regex(spattern, line);
+       matched = (*ep != NULL);
+       if (matched)
+               *sp = __loc1;
+#endif
+#if HAVE_V8_REGCOMP
+#if HAVE_REGEXEC2
+       matched = regexec2(spattern, line, notbol);
+#else
+       matched = regexec(spattern, line);
+#endif
+       if (matched)
+       {
+               *sp = spattern->startp[0];
+               *ep = spattern->endp[0];
+       }
+#endif
+#if NO_REGEX
+       matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep);
+#endif
+       }
+       matched = (!(search_type & SRCH_NO_MATCH) && matched) ||
+                       ((search_type & SRCH_NO_MATCH) && !matched);
+       return (matched);
+}
+
diff --git a/thirdparty/less/pattern.h b/thirdparty/less/pattern.h
new file mode 100644 (file)
index 0000000..3b44e2d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+#if HAVE_POSIX_REGCOMP
+#include <regex.h>
+#ifdef REG_EXTENDED
+#define        REGCOMP_FLAG    REG_EXTENDED
+#else
+#define        REGCOMP_FLAG    0
+#endif
+#define DEFINE_PATTERN(name)  regex_t *name
+#define CLEAR_PATTERN(name)   name = NULL
+#endif
+
+#if HAVE_PCRE
+#include <pcre.h>
+#define DEFINE_PATTERN(name)  pcre *name
+#define CLEAR_PATTERN(name)   name = NULL
+#endif
+
+#if HAVE_RE_COMP
+char *re_comp();
+int re_exec();
+#define DEFINE_PATTERN(name)  int name
+#define CLEAR_PATTERN(name)   name = 0
+#endif
+
+#if HAVE_REGCMP
+char *regcmp();
+char *regex();
+extern char *__loc1;
+#define DEFINE_PATTERN(name)  char *name
+#define CLEAR_PATTERN(name)   name = NULL
+#endif
+
+#if HAVE_V8_REGCOMP
+#include "regexp.h"
+#define DEFINE_PATTERN(name)  struct regexp *name
+#define CLEAR_PATTERN(name)   name = NULL
+#endif
+
diff --git a/thirdparty/less/pckeys.h b/thirdparty/less/pckeys.h
new file mode 100644 (file)
index 0000000..3708d85
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Definitions of keys on the PC.
+ * Special (non-ASCII) keys on the PC send a two-byte sequence,
+ * where the first byte is 0 and the second is as defined below.
+ */
+#define        PCK_SHIFT_TAB           '\017'
+#define        PCK_ALT_E               '\022'
+#define        PCK_CAPS_LOCK           '\072'
+#define        PCK_F1                  '\073'
+#define        PCK_NUM_LOCK            '\105'
+#define        PCK_HOME                '\107'
+#define        PCK_UP                  '\110'
+#define        PCK_PAGEUP              '\111'
+#define        PCK_LEFT                '\113'
+#define        PCK_RIGHT               '\115'
+#define        PCK_END                 '\117'
+#define        PCK_DOWN                '\120'
+#define        PCK_PAGEDOWN            '\121'
+#define        PCK_INSERT              '\122'
+#define        PCK_DELETE              '\123'
+#define        PCK_CTL_LEFT            '\163'
+#define        PCK_CTL_RIGHT           '\164'
+#define        PCK_CTL_DELETE          '\223'
diff --git a/thirdparty/less/position.c b/thirdparty/less/position.c
new file mode 100644 (file)
index 0000000..8c05c5d
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines dealing with the "position" table.
+ * This is a table which tells the position (in the input file) of the
+ * first char on each currently displayed line.
+ *
+ * {{ The position table is scrolled by moving all the entries.
+ *    Would be better to have a circular table 
+ *    and just change a couple of pointers. }}
+ */
+
+#include "less.h"
+#include "position.h"
+
+static POSITION *table = NULL; /* The position table */
+static int table_size;
+
+extern int sc_width, sc_height;
+
+/*
+ * Return the starting file position of a line displayed on the screen.
+ * The line may be specified as a line number relative to the top
+ * of the screen, but is usually one of these special cases:
+ *     the top (first) line on the screen
+ *     the second line on the screen
+ *     the bottom line on the screen
+ *     the line after the bottom line on the screen
+ */
+       public POSITION
+position(where)
+       int where;
+{
+       switch (where)
+       {
+       case BOTTOM:
+               where = sc_height - 2;
+               break;
+       case BOTTOM_PLUS_ONE:
+               where = sc_height - 1;
+               break;
+       case MIDDLE:
+               where = (sc_height - 1) / 2;
+       }
+       return (table[where]);
+}
+
+/*
+ * Add a new file position to the bottom of the position table.
+ */
+       public void
+add_forw_pos(pos)
+       POSITION pos;
+{
+       register int i;
+
+       /*
+        * Scroll the position table up.
+        */
+       for (i = 1;  i < sc_height;  i++)
+               table[i-1] = table[i];
+       table[sc_height - 1] = pos;
+}
+
+/*
+ * Add a new file position to the top of the position table.
+ */
+       public void
+add_back_pos(pos)
+       POSITION pos;
+{
+       register int i;
+
+       /*
+        * Scroll the position table down.
+        */
+       for (i = sc_height - 1;  i > 0;  i--)
+               table[i] = table[i-1];
+       table[0] = pos;
+}
+
+/*
+ * Initialize the position table, done whenever we clear the screen.
+ */
+       public void
+pos_clear()
+{
+       register int i;
+
+       for (i = 0;  i < sc_height;  i++)
+               table[i] = NULL_POSITION;
+}
+
+/*
+ * Allocate or reallocate the position table.
+ */
+       public void
+pos_init()
+{
+       struct scrpos scrpos;
+
+       if (sc_height <= table_size)
+               return;
+       /*
+        * If we already have a table, remember the first line in it
+        * before we free it, so we can copy that line to the new table.
+        */
+       if (table != NULL)
+       {
+               get_scrpos(&scrpos);
+               free((char*)table);
+       } else
+               scrpos.pos = NULL_POSITION;
+       table = (POSITION *) ecalloc(sc_height, sizeof(POSITION));
+       table_size = sc_height;
+       pos_clear();
+       if (scrpos.pos != NULL_POSITION)
+               table[scrpos.ln-1] = scrpos.pos;
+}
+
+/*
+ * See if the byte at a specified position is currently on the screen.
+ * Check the position table to see if the position falls within its range.
+ * Return the position table entry if found, -1 if not.
+ */
+       public int
+onscreen(pos)
+       POSITION pos;
+{
+       register int i;
+
+       if (pos < table[0])
+               return (-1);
+       for (i = 1;  i < sc_height;  i++)
+               if (pos < table[i])
+                       return (i-1);
+       return (-1);
+}
+
+/*
+ * See if the entire screen is empty.
+ */
+       public int
+empty_screen()
+{
+       return (empty_lines(0, sc_height-1));
+}
+
+       public int
+empty_lines(s, e)
+       int s;
+       int e;
+{
+       register int i;
+
+       for (i = s;  i <= e;  i++)
+               if (table[i] != NULL_POSITION)
+                       return (0);
+       return (1);
+}
+
+/*
+ * Get the current screen position.
+ * The screen position consists of both a file position and
+ * a screen line number where the file position is placed on the screen.
+ * Normally the screen line number is 0, but if we are positioned
+ * such that the top few lines are empty, we may have to set
+ * the screen line to a number > 0.
+ */
+       public void
+get_scrpos(scrpos)
+       struct scrpos *scrpos;
+{
+       register int i;
+
+       /*
+        * Find the first line on the screen which has something on it,
+        * and return the screen line number and the file position.
+        */
+       for (i = 0; i < sc_height;  i++)
+               if (table[i] != NULL_POSITION)
+               {
+                       scrpos->ln = i+1;
+                       scrpos->pos = table[i];
+                       return;
+               }
+       /*
+        * The screen is empty.
+        */
+       scrpos->pos = NULL_POSITION;
+}
+
+/*
+ * Adjust a screen line number to be a simple positive integer
+ * in the range { 0 .. sc_height-2 }.
+ * (The bottom line, sc_height-1, is reserved for prompts, etc.)
+ * The given "sline" may be in the range { 1 .. sc_height-1 }
+ * to refer to lines relative to the top of the screen (starting from 1),
+ * or it may be in { -1 .. -(sc_height-1) } to refer to lines
+ * relative to the bottom of the screen.
+ */
+       public int
+adjsline(sline)
+       int sline;
+{
+       /*
+        * Negative screen line number means
+        * relative to the bottom of the screen.
+        */
+       if (sline < 0)
+               sline += sc_height;
+       /*
+        * Can't be less than 1 or greater than sc_height-1.
+        */
+       if (sline <= 0)
+               sline = 1;
+       if (sline >= sc_height)
+               sline = sc_height - 1;
+       /*
+        * Return zero-based line number, not one-based.
+        */
+       return (sline-1);
+}
diff --git a/thirdparty/less/position.h b/thirdparty/less/position.h
new file mode 100644 (file)
index 0000000..146972c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Include file for interfacing to position.c modules.
+ */
+#define        TOP             (0)
+#define        TOP_PLUS_ONE    (1)
+#define        BOTTOM          (-1)
+#define        BOTTOM_PLUS_ONE (-2)
+#define        MIDDLE          (-3)
diff --git a/thirdparty/less/prompt.c b/thirdparty/less/prompt.c
new file mode 100644 (file)
index 0000000..dce34f3
--- /dev/null
@@ -0,0 +1,587 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Prompting and other messages.
+ * There are three flavors of prompts, SHORT, MEDIUM and LONG,
+ * selected by the -m/-M options.
+ * There is also the "equals message", printed by the = command.
+ * A prompt is a message composed of various pieces, such as the 
+ * name of the file being viewed, the percentage into the file, etc.
+ */
+
+#include "less.h"
+#include "position.h"
+
+extern int pr_type;
+extern int new_file;
+extern int sc_width;
+extern int so_s_width, so_e_width;
+extern int linenums;
+extern int hshift;
+extern int sc_height;
+extern int jump_sline;
+extern int less_is_more;
+extern IFILE curr_ifile;
+#if EDITOR
+extern char *editor;
+extern char *editproto;
+#endif
+
+/*
+ * Prototypes for the three flavors of prompts.
+ * These strings are expanded by pr_expand().
+ */
+static constant char s_proto[] =
+  "?n?f%f .?m(%T %i of %m) ..?e(END) ?x- Next\\: %x..%t";
+static constant char m_proto[] =
+  "?n?f%f .?m(%T %i of %m) ..?e(END) ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t";
+static constant char M_proto[] =
+  "?f%f .?n?m(%T %i of %m) ..?ltlines %lt-%lb?L/%L. :byte %bB?s/%s. .?e(END) ?x- Next\\: %x.:?pB%pB\\%..%t";
+static constant char e_proto[] =
+  "?f%f .?m(%T %i of %m) .?ltlines %lt-%lb?L/%L. .byte %bB?s/%s. ?e(END) :?pB%pB\\%..%t";
+static constant char h_proto[] =
+  "HELP -- ?eEND -- Press g to see it again:Press RETURN for more., or q when done";
+static constant char w_proto[] =
+  "Waiting for data";
+static constant char more_proto[] =
+  "--More--(?eEND ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t)";
+
+public char *prproto[3];
+public char constant *eqproto = e_proto;
+public char constant *hproto = h_proto;
+public char constant *wproto = w_proto;
+
+static char message[PROMPT_SIZE];
+static char *mp;
+
+/*
+ * Initialize the prompt prototype strings.
+ */
+       public void
+init_prompt()
+{
+       prproto[0] = save(s_proto);
+       prproto[1] = save(less_is_more ? more_proto : m_proto);
+       prproto[2] = save(M_proto);
+       eqproto = save(e_proto);
+       hproto = save(h_proto);
+       wproto = save(w_proto);
+}
+
+/*
+ * Append a string to the end of the message.
+ */
+       static void
+ap_str(s)
+       char *s;
+{
+       int len;
+
+       len = strlen(s);
+       if (mp + len >= message + PROMPT_SIZE)
+               len = message + PROMPT_SIZE - mp - 1;
+       strncpy(mp, s, len);
+       mp += len;
+       *mp = '\0';
+}
+
+/*
+ * Append a character to the end of the message.
+ */
+       static void
+ap_char(c)
+       char c;
+{
+       char buf[2];
+
+       buf[0] = c;
+       buf[1] = '\0';
+       ap_str(buf);
+}
+
+/*
+ * Append a POSITION (as a decimal integer) to the end of the message.
+ */
+       static void
+ap_pos(pos)
+       POSITION pos;
+{
+       char buf[INT_STRLEN_BOUND(pos) + 2];
+
+       postoa(pos, buf);
+       ap_str(buf);
+}
+
+/*
+ * Append a line number to the end of the message.
+ */
+       static void
+ap_linenum(linenum)
+       LINENUM linenum;
+{
+       char buf[INT_STRLEN_BOUND(linenum) + 2];
+
+       linenumtoa(linenum, buf);
+       ap_str(buf);
+}
+
+/*
+ * Append an integer to the end of the message.
+ */
+       static void
+ap_int(num)
+       int num;
+{
+       char buf[INT_STRLEN_BOUND(num) + 2];
+
+       inttoa(num, buf);
+       ap_str(buf);
+}
+
+/*
+ * Append a question mark to the end of the message.
+ */
+       static void
+ap_quest()
+{
+       ap_str("?");
+}
+
+/*
+ * Return the "current" byte offset in the file.
+ */
+       static POSITION
+curr_byte(where)
+       int where;
+{
+       POSITION pos;
+
+       pos = position(where);
+       while (pos == NULL_POSITION && where >= 0 && where < sc_height-1)
+               pos = position(++where);
+       if (pos == NULL_POSITION)
+               pos = ch_length();
+       return (pos);
+}
+
+/*
+ * Return the value of a prototype conditional.
+ * A prototype string may include conditionals which consist of a 
+ * question mark followed by a single letter.
+ * Here we decode that letter and return the appropriate boolean value.
+ */
+       static int
+cond(c, where)
+       char c;
+       int where;
+{
+       POSITION len;
+
+       switch (c)
+       {
+       case 'a':       /* Anything in the message yet? */
+               return (mp > message);
+       case 'b':       /* Current byte offset known? */
+               return (curr_byte(where) != NULL_POSITION);
+       case 'c':
+               return (hshift != 0);
+       case 'e':       /* At end of file? */
+               return (eof_displayed());
+       case 'f':       /* Filename known? */
+               return (strcmp(get_filename(curr_ifile), "-") != 0);
+       case 'l':       /* Line number known? */
+       case 'd':       /* Same as l */
+               return (linenums);
+       case 'L':       /* Final line number known? */
+       case 'D':       /* Final page number known? */
+               return (linenums && ch_length() != NULL_POSITION);
+       case 'm':       /* More than one file? */
+#if TAGS
+               return (ntags() ? (ntags() > 1) : (nifile() > 1));
+#else
+               return (nifile() > 1);
+#endif
+       case 'n':       /* First prompt in a new file? */
+#if TAGS
+               return (ntags() ? 1 : new_file);
+#else
+               return (new_file);
+#endif
+       case 'p':       /* Percent into file (bytes) known? */
+               return (curr_byte(where) != NULL_POSITION && 
+                               ch_length() > 0);
+       case 'P':       /* Percent into file (lines) known? */
+               return (currline(where) != 0 &&
+                               (len = ch_length()) > 0 &&
+                               find_linenum(len) != 0);
+       case 's':       /* Size of file known? */
+       case 'B':
+               return (ch_length() != NULL_POSITION);
+       case 'x':       /* Is there a "next" file? */
+#if TAGS
+               if (ntags())
+                       return (0);
+#endif
+               return (next_ifile(curr_ifile) != NULL_IFILE);
+       }
+       return (0);
+}
+
+/*
+ * Decode a "percent" prototype character.
+ * A prototype string may include various "percent" escapes;
+ * that is, a percent sign followed by a single letter.
+ * Here we decode that letter and take the appropriate action,
+ * usually by appending something to the message being built.
+ */
+       static void
+protochar(c, where, iseditproto)
+       int c;
+       int where;
+       int iseditproto;
+{
+       POSITION pos;
+       POSITION len;
+       int n;
+       LINENUM linenum;
+       LINENUM last_linenum;
+       IFILE h;
+
+#undef  PAGE_NUM
+#define PAGE_NUM(linenum)  ((((linenum) - 1) / (sc_height - 1)) + 1)
+
+       switch (c)
+       {
+       case 'b':       /* Current byte offset */
+               pos = curr_byte(where);
+               if (pos != NULL_POSITION)
+                       ap_pos(pos);
+               else
+                       ap_quest();
+               break;
+       case 'c':
+               ap_int(hshift);
+               break;
+       case 'd':       /* Current page number */
+               linenum = currline(where);
+               if (linenum > 0 && sc_height > 1)
+                       ap_linenum(PAGE_NUM(linenum));
+               else
+                       ap_quest();
+               break;
+       case 'D':       /* Final page number */
+               /* Find the page number of the last byte in the file (len-1). */
+               len = ch_length();
+               if (len == NULL_POSITION)
+                       ap_quest();
+               else if (len == 0)
+                       /* An empty file has no pages. */
+                       ap_linenum(0);
+               else
+               {
+                       linenum = find_linenum(len - 1);
+                       if (linenum <= 0)
+                               ap_quest();
+                       else 
+                               ap_linenum(PAGE_NUM(linenum));
+               }
+               break;
+#if EDITOR
+       case 'E':       /* Editor name */
+               ap_str(editor);
+               break;
+#endif
+       case 'f':       /* File name */
+               ap_str(get_filename(curr_ifile));
+               break;
+       case 'F':       /* Last component of file name */
+               ap_str(last_component(get_filename(curr_ifile)));
+               break;
+       case 'i':       /* Index into list of files */
+#if TAGS
+               if (ntags())
+                       ap_int(curr_tag());
+               else
+#endif
+                       ap_int(get_index(curr_ifile));
+               break;
+       case 'l':       /* Current line number */
+               linenum = currline(where);
+               if (linenum != 0)
+                       ap_linenum(linenum);
+               else
+                       ap_quest();
+               break;
+       case 'L':       /* Final line number */
+               len = ch_length();
+               if (len == NULL_POSITION || len == ch_zero() ||
+                   (linenum = find_linenum(len)) <= 0)
+                       ap_quest();
+               else
+                       ap_linenum(linenum-1);
+               break;
+       case 'm':       /* Number of files */
+#if TAGS
+               n = ntags();
+               if (n)
+                       ap_int(n);
+               else
+#endif
+                       ap_int(nifile());
+               break;
+       case 'p':       /* Percent into file (bytes) */
+               pos = curr_byte(where);
+               len = ch_length();
+               if (pos != NULL_POSITION && len > 0)
+                       ap_int(percentage(pos,len));
+               else
+                       ap_quest();
+               break;
+       case 'P':       /* Percent into file (lines) */
+               linenum = currline(where);
+               if (linenum == 0 ||
+                   (len = ch_length()) == NULL_POSITION || len == ch_zero() ||
+                   (last_linenum = find_linenum(len)) <= 0)
+                       ap_quest();
+               else
+                       ap_int(percentage(linenum, last_linenum));
+               break;
+       case 's':       /* Size of file */
+       case 'B':
+               len = ch_length();
+               if (len != NULL_POSITION)
+                       ap_pos(len);
+               else
+                       ap_quest();
+               break;
+       case 't':       /* Truncate trailing spaces in the message */
+               while (mp > message && mp[-1] == ' ')
+                       mp--;
+               *mp = '\0';
+               break;
+       case 'T':       /* Type of list */
+#if TAGS
+               if (ntags())
+                       ap_str("tag");
+               else
+#endif
+                       ap_str("file");
+               break;
+       case 'x':       /* Name of next file */
+               h = next_ifile(curr_ifile);
+               if (h != NULL_IFILE)
+                       ap_str(get_filename(h));
+               else
+                       ap_quest();
+               break;
+       }
+}
+
+/*
+ * Skip a false conditional.
+ * When a false condition is found (either a false IF or the ELSE part 
+ * of a true IF), this routine scans the prototype string to decide
+ * where to resume parsing the string.
+ * We must keep track of nested IFs and skip them properly.
+ */
+       static char *
+skipcond(p)
+       register char *p;
+{
+       register int iflevel;
+
+       /*
+        * We came in here after processing a ? or :,
+        * so we start nested one level deep.
+        */
+       iflevel = 1;
+
+       for (;;) switch (*++p)
+       {
+       case '?':
+               /*
+                * Start of a nested IF.
+                */
+               iflevel++;
+               break;
+       case ':':
+               /*
+                * Else.
+                * If this matches the IF we came in here with,
+                * then we're done.
+                */
+               if (iflevel == 1)
+                       return (p);
+               break;
+       case '.':
+               /*
+                * Endif.
+                * If this matches the IF we came in here with,
+                * then we're done.
+                */
+               if (--iflevel == 0)
+                       return (p);
+               break;
+       case '\\':
+               /*
+                * Backslash escapes the next character.
+                */
+               ++p;
+               break;
+       case '\0':
+               /*
+                * Whoops.  Hit end of string.
+                * This is a malformed conditional, but just treat it
+                * as if all active conditionals ends here.
+                */
+               return (p-1);
+       }
+       /*NOTREACHED*/
+}
+
+/*
+ * Decode a char that represents a position on the screen.
+ */
+       static char *
+wherechar(p, wp)
+       char *p;
+       int *wp;
+{
+       switch (*p)
+       {
+       case 'b': case 'd': case 'l': case 'p': case 'P':
+               switch (*++p)
+               {
+               case 't':   *wp = TOP;                  break;
+               case 'm':   *wp = MIDDLE;               break;
+               case 'b':   *wp = BOTTOM;               break;
+               case 'B':   *wp = BOTTOM_PLUS_ONE;      break;
+               case 'j':   *wp = adjsline(jump_sline); break;
+               default:    *wp = TOP;  p--;            break;
+               }
+       }
+       return (p);
+}
+
+/*
+ * Construct a message based on a prototype string.
+ */
+       public char *
+pr_expand(proto, maxwidth)
+       char *proto;
+       int maxwidth;
+{
+       register char *p;
+       register int c;
+       int where;
+
+       mp = message;
+
+       if (*proto == '\0')
+               return ("");
+
+       for (p = proto;  *p != '\0';  p++)
+       {
+               switch (*p)
+               {
+               default:        /* Just put the character in the message */
+                       ap_char(*p);
+                       break;
+               case '\\':      /* Backslash escapes the next character */
+                       p++;
+                       ap_char(*p);
+                       break;
+               case '?':       /* Conditional (IF) */
+                       if ((c = *++p) == '\0')
+                               --p;
+                       else
+                       {
+                               where = 0;
+                               p = wherechar(p, &where);
+                               if (!cond(c, where))
+                                       p = skipcond(p);
+                       }
+                       break;
+               case ':':       /* ELSE */
+                       p = skipcond(p);
+                       break;
+               case '.':       /* ENDIF */
+                       break;
+               case '%':       /* Percent escape */
+                       if ((c = *++p) == '\0')
+                               --p;
+                       else
+                       {
+                               where = 0;
+                               p = wherechar(p, &where);
+                               protochar(c, where,
+#if EDITOR
+                                       (proto == editproto));
+#else
+                                       0);
+#endif
+
+                       }
+                       break;
+               }
+       }
+
+       if (mp == message)
+               return ("");
+       if (maxwidth > 0 && mp >= message + maxwidth)
+       {
+               /*
+                * Message is too long.
+                * Return just the final portion of it.
+                */
+               return (mp - maxwidth);
+       }
+       return (message);
+}
+
+/*
+ * Return a message suitable for printing by the "=" command.
+ */
+       public char *
+eq_message()
+{
+       return (pr_expand(eqproto, 0));
+}
+
+/*
+ * Return a prompt.
+ * This depends on the prompt type (SHORT, MEDIUM, LONG), etc.
+ * If we can't come up with an appropriate prompt, return NULL
+ * and the caller will prompt with a colon.
+ */
+       public char *
+pr_string()
+{
+       char *prompt;
+       int type;
+
+       type = (!less_is_more) ? pr_type : pr_type ? 0 : 1;
+       prompt = pr_expand((ch_getflags() & CH_HELPFILE) ?
+                               hproto : prproto[type],
+                       sc_width-so_s_width-so_e_width-2);
+       new_file = 0;
+       return (prompt);
+}
+
+/*
+ * Return a message suitable for printing while waiting in the F command.
+ */
+       public char *
+wait_message()
+{
+       return (pr_expand(wproto, sc_width-so_s_width-so_e_width-2));
+}
diff --git a/thirdparty/less/regexp.c b/thirdparty/less/regexp.c
new file mode 100644 (file)
index 0000000..77ab611
--- /dev/null
@@ -0,0 +1,1250 @@
+/*
+ * regcomp and regexec -- regsub and regerror are elsewhere
+ *
+ *     Copyright (c) 1986 by University of Toronto.
+ *     Written by Henry Spencer.  Not derived from licensed software.
+ *
+ *     Permission is granted to anyone to use this software for any
+ *     purpose on any computer system, and to redistribute it freely,
+ *     subject to the following restrictions:
+ *
+ *     1. The author is not responsible for the consequences of use of
+ *             this software, no matter how awful, even if they arise
+ *             from defects in it.
+ *
+ *     2. The origin of this software must not be misrepresented, either
+ *             by explicit claim or by omission.
+ *
+ *     3. Altered versions must be plainly marked as such, and must not
+ *             be misrepresented as being the original software.
+ *
+ * Beware that some of this code is subtly aware of the way operator
+ * precedence is structured in regular expressions.  Serious changes in
+ * regular-expression syntax might require a total rethink.
+ *
+ * *** NOTE: this code has been altered slightly for use in Tcl. ***
+ * Slightly modified by David MacKenzie to undo most of the changes for TCL.
+ * Added regexec2 with notbol parameter. -- 4/19/99 Mark Nudelman
+ */
+
+#include "less.h"
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_STRING_H
+#include <string.h>
+#endif
+#include "regexp.h"
+
+/*
+ * The "internal use only" fields in regexp.h are present to pass info from
+ * compile to execute that permits the execute phase to run lots faster on
+ * simple cases.  They are:
+ *
+ * regstart    char that must begin a match; '\0' if none obvious
+ * reganch     is the match anchored (at beginning-of-line only)?
+ * regmust     string (pointer into program) that match must include, or NULL
+ * regmlen     length of regmust string
+ *
+ * Regstart and reganch permit very fast decisions on suitable starting points
+ * for a match, cutting down the work a lot.  Regmust permits fast rejection
+ * of lines that cannot possibly match.  The regmust tests are costly enough
+ * that regcomp() supplies a regmust only if the r.e. contains something
+ * potentially expensive (at present, the only such thing detected is * or +
+ * at the start of the r.e., which can involve a lot of backup).  Regmlen is
+ * supplied because the test in regexec() needs it and regcomp() is
+ * computing it anyway.
+ */
+
+/*
+ * Structure for regexp "program".  This is essentially a linear encoding
+ * of a nondeterministic finite-state machine (aka syntax charts or
+ * "railroad normal form" in parsing technology).  Each node is an opcode
+ * plus a "next" pointer, possibly plus an operand.  "Next" pointers of
+ * all nodes except BRANCH implement concatenation; a "next" pointer with
+ * a BRANCH on both ends of it is connecting two alternatives.  (Here we
+ * have one of the subtle syntax dependencies:  an individual BRANCH (as
+ * opposed to a collection of them) is never concatenated with anything
+ * because of operator precedence.)  The operand of some types of node is
+ * a literal string; for others, it is a node leading into a sub-FSM.  In
+ * particular, the operand of a BRANCH node is the first node of the branch.
+ * (NB this is *not* a tree structure:  the tail of the branch connects
+ * to the thing following the set of BRANCHes.)  The opcodes are:
+ */
+
+/* definition  number  opnd?   meaning */
+#undef EOL
+#define        END     0       /* no   End of program. */
+#define        BOL     1       /* no   Match "" at beginning of line. */
+#define        EOL     2       /* no   Match "" at end of line. */
+#define        ANY     3       /* no   Match any one character. */
+#define        ANYOF   4       /* str  Match any character in this string. */
+#define        ANYBUT  5       /* str  Match any character not in this string. */
+#define        BRANCH  6       /* node Match this alternative, or the next... */
+#define        BACK    7       /* no   Match "", "next" ptr points backward. */
+#define        EXACTLY 8       /* str  Match this string. */
+#define        NOTHING 9       /* no   Match empty string. */
+#define        STAR    10      /* node Match this (simple) thing 0 or more times. */
+#define        PLUS    11      /* node Match this (simple) thing 1 or more times. */
+#define        OPEN    20      /* no   Mark this point in input as start of #n. */
+                       /*      OPEN+1 is number 1, etc. */
+#define        CLOSE   30      /* no   Analogous to OPEN. */
+
+/*
+ * Opcode notes:
+ *
+ * BRANCH      The set of branches constituting a single choice are hooked
+ *             together with their "next" pointers, since precedence prevents
+ *             anything being concatenated to any individual branch.  The
+ *             "next" pointer of the last BRANCH in a choice points to the
+ *             thing following the whole choice.  This is also where the
+ *             final "next" pointer of each individual branch points; each
+ *             branch starts with the operand node of a BRANCH node.
+ *
+ * BACK                Normal "next" pointers all implicitly point forward; BACK
+ *             exists to make loop structures possible.
+ *
+ * STAR,PLUS   '?', and complex '*' and '+', are implemented as circular
+ *             BRANCH structures using BACK.  Simple cases (one character
+ *             per match) are implemented with STAR and PLUS for speed
+ *             and to minimize recursive plunges.
+ *
+ * OPEN,CLOSE  ...are numbered at compile time.
+ */
+
+/*
+ * A node is one char of opcode followed by two chars of "next" pointer.
+ * "Next" pointers are stored as two 8-bit pieces, high order first.  The
+ * value is a positive offset from the opcode of the node containing it.
+ * An operand, if any, simply follows the node.  (Note that much of the
+ * code generation knows about this implicit relationship.)
+ *
+ * Using two bytes for the "next" pointer is vast overkill for most things,
+ * but allows patterns to get big without disasters.
+ */
+#define        OP(p)   (*(p))
+#define        NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
+#define        OPERAND(p)      ((p) + 3)
+
+/*
+ * See regmagic.h for one further detail of program structure.
+ */
+
+
+/*
+ * Utility definitions.
+ */
+#ifndef CHARBITS
+#define        UCHARAT(p)      ((int)*(unsigned char *)(p))
+#else
+#define        UCHARAT(p)      ((int)*(p)&CHARBITS)
+#endif
+
+#define        FAIL(m) { regerror(m); return(NULL); }
+#define        ISMULT(c)       ((c) == '*' || (c) == '+' || (c) == '?')
+#define        META    "^$.[()|?+*\\"
+
+/*
+ * Flags to be passed up and down.
+ */
+#define        HASWIDTH        01      /* Known never to match null string. */
+#define        SIMPLE          02      /* Simple enough to be STAR/PLUS operand. */
+#define        SPSTART         04      /* Starts with * or +. */
+#define        WORST           0       /* Worst case. */
+
+/*
+ * Global work variables for regcomp().
+ */
+static char *regparse;         /* Input-scan pointer. */
+static int regnpar;            /* () count. */
+static char regdummy;
+static char *regcode;          /* Code-emit pointer; &regdummy = don't. */
+static long regsize;           /* Code size. */
+
+/*
+ * The first byte of the regexp internal "program" is actually this magic
+ * number; the start node begins in the second byte.
+ */
+#define        MAGIC   0234
+
+
+/*
+ * Forward declarations for regcomp()'s friends.
+ */
+#ifndef STATIC
+#define        STATIC  static
+#endif
+STATIC char *reg();
+STATIC char *regbranch();
+STATIC char *regpiece();
+STATIC char *regatom();
+STATIC char *regnode();
+STATIC char *regnext();
+STATIC void regc();
+STATIC void reginsert();
+STATIC void regtail();
+STATIC void regoptail();
+#ifdef STRCSPN
+STATIC int strcspn();
+#endif
+
+/*
+ - regcomp - compile a regular expression into internal code
+ *
+ * We can't allocate space until we know how big the compiled form will be,
+ * but we can't compile it (and thus know how big it is) until we've got a
+ * place to put the code.  So we cheat:  we compile it twice, once with code
+ * generation turned off and size counting turned on, and once "for real".
+ * This also means that we don't allocate space until we are sure that the
+ * thing really will compile successfully, and we never have to move the
+ * code and thus invalidate pointers into it.  (Note that it has to be in
+ * one piece because free() must be able to free it all.)
+ *
+ * Beware that the optimization-preparation code in here knows about some
+ * of the structure of the compiled regexp.
+ */
+regexp *
+regcomp(exp)
+char *exp;
+{
+       register regexp *r;
+       register char *scan;
+       register char *longest;
+       register int len;
+       int flags;
+
+       if (exp == NULL)
+               FAIL("NULL argument");
+
+       /* First pass: determine size, legality. */
+       regparse = exp;
+       regnpar = 1;
+       regsize = 0L;
+       regcode = &regdummy;
+       regc(MAGIC);
+       if (reg(0, &flags) == NULL)
+               return(NULL);
+
+       /* Small enough for pointer-storage convention? */
+       if (regsize >= 32767L)          /* Probably could be 65535L. */
+               FAIL("regexp too big");
+
+       /* Allocate space. */
+       r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize);
+       if (r == NULL)
+               FAIL("out of space");
+
+       /* Second pass: emit code. */
+       regparse = exp;
+       regnpar = 1;
+       regcode = r->program;
+       regc(MAGIC);
+       if (reg(0, &flags) == NULL)
+               return(NULL);
+
+       /* Dig out information for optimizations. */
+       r->regstart = '\0';     /* Worst-case defaults. */
+       r->reganch = 0;
+       r->regmust = NULL;
+       r->regmlen = 0;
+       scan = r->program+1;                    /* First BRANCH. */
+       if (OP(regnext(scan)) == END) {         /* Only one top-level choice. */
+               scan = OPERAND(scan);
+
+               /* Starting-point info. */
+               if (OP(scan) == EXACTLY)
+                       r->regstart = *OPERAND(scan);
+               else if (OP(scan) == BOL)
+                       r->reganch++;
+
+               /*
+                * If there's something expensive in the r.e., find the
+                * longest literal string that must appear and make it the
+                * regmust.  Resolve ties in favor of later strings, since
+                * the regstart check works with the beginning of the r.e.
+                * and avoiding duplication strengthens checking.  Not a
+                * strong reason, but sufficient in the absence of others.
+                */
+               if (flags&SPSTART) {
+                       longest = NULL;
+                       len = 0;
+                       for (; scan != NULL; scan = regnext(scan))
+                               if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) {
+                                       longest = OPERAND(scan);
+                                       len = strlen(OPERAND(scan));
+                               }
+                       r->regmust = longest;
+                       r->regmlen = len;
+               }
+       }
+
+       return(r);
+}
+
+/*
+ - reg - regular expression, i.e. main body or parenthesized thing
+ *
+ * Caller must absorb opening parenthesis.
+ *
+ * Combining parenthesis handling with the base level of regular expression
+ * is a trifle forced, but the need to tie the tails of the branches to what
+ * follows makes it hard to avoid.
+ */
+static char *
+reg(paren, flagp)
+int paren;                     /* Parenthesized? */
+int *flagp;
+{
+       register char *ret;
+       register char *br;
+       register char *ender;
+       register int parno = 0;
+       int flags;
+
+       *flagp = HASWIDTH;      /* Tentatively. */
+
+       /* Make an OPEN node, if parenthesized. */
+       if (paren) {
+               if (regnpar >= NSUBEXP)
+                       FAIL("too many ()");
+               parno = regnpar;
+               regnpar++;
+               ret = regnode(OPEN+parno);
+       } else
+               ret = NULL;
+
+       /* Pick up the branches, linking them together. */
+       br = regbranch(&flags);
+       if (br == NULL)
+               return(NULL);
+       if (ret != NULL)
+               regtail(ret, br);       /* OPEN -> first. */
+       else
+               ret = br;
+       if (!(flags&HASWIDTH))
+               *flagp &= ~HASWIDTH;
+       *flagp |= flags&SPSTART;
+       while (*regparse == '|') {
+               regparse++;
+               br = regbranch(&flags);
+               if (br == NULL)
+                       return(NULL);
+               regtail(ret, br);       /* BRANCH -> BRANCH. */
+               if (!(flags&HASWIDTH))
+                       *flagp &= ~HASWIDTH;
+               *flagp |= flags&SPSTART;
+       }
+
+       /* Make a closing node, and hook it on the end. */
+       ender = regnode((paren) ? CLOSE+parno : END);   
+       regtail(ret, ender);
+
+       /* Hook the tails of the branches to the closing node. */
+       for (br = ret; br != NULL; br = regnext(br))
+               regoptail(br, ender);
+
+       /* Check for proper termination. */
+       if (paren && *regparse++ != ')') {
+               FAIL("unmatched ()");
+       } else if (!paren && *regparse != '\0') {
+               if (*regparse == ')') {
+                       FAIL("unmatched ()");
+               } else
+                       FAIL("junk on end");    /* "Can't happen". */
+               /* NOTREACHED */
+       }
+
+       return(ret);
+}
+
+/*
+ - regbranch - one alternative of an | operator
+ *
+ * Implements the concatenation operator.
+ */
+static char *
+regbranch(flagp)
+int *flagp;
+{
+       register char *ret;
+       register char *chain;
+       register char *latest;
+       int flags;
+
+       *flagp = WORST;         /* Tentatively. */
+
+       ret = regnode(BRANCH);
+       chain = NULL;
+       while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
+               latest = regpiece(&flags);
+               if (latest == NULL)
+                       return(NULL);
+               *flagp |= flags&HASWIDTH;
+               if (chain == NULL)      /* First piece. */
+                       *flagp |= flags&SPSTART;
+               else
+                       regtail(chain, latest);
+               chain = latest;
+       }
+       if (chain == NULL)      /* Loop ran zero times. */
+               (void) regnode(NOTHING);
+
+       return(ret);
+}
+
+/*
+ - regpiece - something followed by possible [*+?]
+ *
+ * Note that the branching code sequences used for ? and the general cases
+ * of * and + are somewhat optimized:  they use the same NOTHING node as
+ * both the endmarker for their branch list and the body of the last branch.
+ * It might seem that this node could be dispensed with entirely, but the
+ * endmarker role is not redundant.
+ */
+static char *
+regpiece(flagp)
+int *flagp;
+{
+       register char *ret;
+       register char op;
+       register char *next;
+       int flags;
+
+       ret = regatom(&flags);
+       if (ret == NULL)
+               return(NULL);
+
+       op = *regparse;
+       if (!ISMULT(op)) {
+               *flagp = flags;
+               return(ret);
+       }
+
+       if (!(flags&HASWIDTH) && op != '?')
+               FAIL("*+ operand could be empty");
+       *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
+
+       if (op == '*' && (flags&SIMPLE))
+               reginsert(STAR, ret);
+       else if (op == '*') {
+               /* Emit x* as (x&|), where & means "self". */
+               reginsert(BRANCH, ret);                 /* Either x */
+               regoptail(ret, regnode(BACK));          /* and loop */
+               regoptail(ret, ret);                    /* back */
+               regtail(ret, regnode(BRANCH));          /* or */
+               regtail(ret, regnode(NOTHING));         /* null. */
+       } else if (op == '+' && (flags&SIMPLE))
+               reginsert(PLUS, ret);
+       else if (op == '+') {
+               /* Emit x+ as x(&|), where & means "self". */
+               next = regnode(BRANCH);                 /* Either */
+               regtail(ret, next);
+               regtail(regnode(BACK), ret);            /* loop back */
+               regtail(next, regnode(BRANCH));         /* or */
+               regtail(ret, regnode(NOTHING));         /* null. */
+       } else if (op == '?') {
+               /* Emit x? as (x|) */
+               reginsert(BRANCH, ret);                 /* Either x */
+               regtail(ret, regnode(BRANCH));          /* or */
+               next = regnode(NOTHING);                /* null. */
+               regtail(ret, next);
+               regoptail(ret, next);
+       }
+       regparse++;
+       if (ISMULT(*regparse))
+               FAIL("nested *?+");
+
+       return(ret);
+}
+
+/*
+ - regatom - the lowest level
+ *
+ * Optimization:  gobbles an entire sequence of ordinary characters so that
+ * it can turn them into a single node, which is smaller to store and
+ * faster to run.  Backslashed characters are exceptions, each becoming a
+ * separate node; the code is simpler that way and it's not worth fixing.
+ */
+static char *
+regatom(flagp)
+int *flagp;
+{
+       register char *ret;
+       int flags;
+
+       *flagp = WORST;         /* Tentatively. */
+
+       switch (*regparse++) {
+       case '^':
+               ret = regnode(BOL);
+               break;
+       case '$':
+               ret = regnode(EOL);
+               break;
+       case '.':
+               ret = regnode(ANY);
+               *flagp |= HASWIDTH|SIMPLE;
+               break;
+       case '[': {
+                       register int clss;
+                       register int classend;
+
+                       if (*regparse == '^') { /* Complement of range. */
+                               ret = regnode(ANYBUT);
+                               regparse++;
+                       } else
+                               ret = regnode(ANYOF);
+                       if (*regparse == ']' || *regparse == '-')
+                               regc(*regparse++);
+                       while (*regparse != '\0' && *regparse != ']') {
+                               if (*regparse == '-') {
+                                       regparse++;
+                                       if (*regparse == ']' || *regparse == '\0')
+                                               regc('-');
+                                       else {
+                                               clss = UCHARAT(regparse-2)+1;
+                                               classend = UCHARAT(regparse);
+                                               if (clss > classend+1)
+                                                       FAIL("invalid [] range");
+                                               for (; clss <= classend; clss++)
+                                                       regc(clss);
+                                               regparse++;
+                                       }
+                               } else
+                                       regc(*regparse++);
+                       }
+                       regc('\0');
+                       if (*regparse != ']')
+                               FAIL("unmatched []");
+                       regparse++;
+                       *flagp |= HASWIDTH|SIMPLE;
+               }
+               break;
+       case '(':
+               ret = reg(1, &flags);
+               if (ret == NULL)
+                       return(NULL);
+               *flagp |= flags&(HASWIDTH|SPSTART);
+               break;
+       case '\0':
+       case '|':
+       case ')':
+               FAIL("internal urp");   /* Supposed to be caught earlier. */
+               /* NOTREACHED */
+               break;
+       case '?':
+       case '+':
+       case '*':
+               FAIL("?+* follows nothing");
+               /* NOTREACHED */
+               break;
+       case '\\':
+               if (*regparse == '\0')
+                       FAIL("trailing \\");
+               ret = regnode(EXACTLY);
+               regc(*regparse++);
+               regc('\0');
+               *flagp |= HASWIDTH|SIMPLE;
+               break;
+       default: {
+                       register int len;
+                       register char ender;
+
+                       regparse--;
+                       len = strcspn(regparse, META);
+                       if (len <= 0)
+                               FAIL("internal disaster");
+                       ender = *(regparse+len);
+                       if (len > 1 && ISMULT(ender))
+                               len--;          /* Back off clear of ?+* operand. */
+                       *flagp |= HASWIDTH;
+                       if (len == 1)
+                               *flagp |= SIMPLE;
+                       ret = regnode(EXACTLY);
+                       while (len > 0) {
+                               regc(*regparse++);
+                               len--;
+                       }
+                       regc('\0');
+               }
+               break;
+       }
+
+       return(ret);
+}
+
+/*
+ - regnode - emit a node
+ */
+static char *                  /* Location. */
+regnode(op)
+char op;
+{
+       register char *ret;
+       register char *ptr;
+
+       ret = regcode;
+       if (ret == &regdummy) {
+               regsize += 3;
+               return(ret);
+       }
+
+       ptr = ret;
+       *ptr++ = op;
+       *ptr++ = '\0';          /* Null "next" pointer. */
+       *ptr++ = '\0';
+       regcode = ptr;
+
+       return(ret);
+}
+
+/*
+ - regc - emit (if appropriate) a byte of code
+ */
+static void
+regc(b)
+char b;
+{
+       if (regcode != &regdummy)
+               *regcode++ = b;
+       else
+               regsize++;
+}
+
+/*
+ - reginsert - insert an operator in front of already-emitted operand
+ *
+ * Means relocating the operand.
+ */
+static void
+reginsert(op, opnd)
+char op;
+char *opnd;
+{
+       register char *src;
+       register char *dst;
+       register char *place;
+
+       if (regcode == &regdummy) {
+               regsize += 3;
+               return;
+       }
+
+       src = regcode;
+       regcode += 3;
+       dst = regcode;
+       while (src > opnd)
+               *--dst = *--src;
+
+       place = opnd;           /* Op node, where operand used to be. */
+       *place++ = op;
+       *place++ = '\0';
+       *place++ = '\0';
+}
+
+/*
+ - regtail - set the next-pointer at the end of a node chain
+ */
+static void
+regtail(p, val)
+char *p;
+char *val;
+{
+       register char *scan;
+       register char *temp;
+       register int offset;
+
+       if (p == &regdummy)
+               return;
+
+       /* Find last node. */
+       scan = p;
+       for (;;) {
+               temp = regnext(scan);
+               if (temp == NULL)
+                       break;
+               scan = temp;
+       }
+
+       if (OP(scan) == BACK)
+               offset = scan - val;
+       else
+               offset = val - scan;
+       *(scan+1) = (offset>>8)&0377;
+       *(scan+2) = offset&0377;
+}
+
+/*
+ - regoptail - regtail on operand of first argument; nop if operandless
+ */
+static void
+regoptail(p, val)
+char *p;
+char *val;
+{
+       /* "Operandless" and "op != BRANCH" are synonymous in practice. */
+       if (p == NULL || p == &regdummy || OP(p) != BRANCH)
+               return;
+       regtail(OPERAND(p), val);
+}
+
+/*
+ * regexec and friends
+ */
+
+/*
+ * Global work variables for regexec().
+ */
+static char *reginput;         /* String-input pointer. */
+static char *regbol;           /* Beginning of input, for ^ check. */
+static char **regstartp;       /* Pointer to startp array. */
+static char **regendp;         /* Ditto for endp. */
+
+/*
+ * Forwards.
+ */
+STATIC int regtry();
+STATIC int regmatch();
+STATIC int regrepeat();
+
+#ifdef DEBUG
+int regnarrate = 0;
+void regdump();
+STATIC char *regprop();
+#endif
+
+/*
+ - regexec - match a regexp against a string
+ */
+int
+regexec2(prog, string, notbol)
+register regexp *prog;
+register char *string;
+int notbol;
+{
+       register char *s;
+
+       /* Be paranoid... */
+       if (prog == NULL || string == NULL) {
+               regerror("NULL parameter");
+               return(0);
+       }
+
+       /* Check validity of program. */
+       if (UCHARAT(prog->program) != MAGIC) {
+               regerror("corrupted program");
+               return(0);
+       }
+
+       /* If there is a "must appear" string, look for it. */
+       if (prog->regmust != NULL) {
+               s = string;
+               while ((s = strchr(s, prog->regmust[0])) != NULL) {
+                       if (strncmp(s, prog->regmust, prog->regmlen) == 0)
+                               break;  /* Found it. */
+                       s++;
+               }
+               if (s == NULL)  /* Not present. */
+                       return(0);
+       }
+
+       /* Mark beginning of line for ^ . */
+       if (notbol)
+               regbol = NULL;
+       else
+               regbol = string;
+
+       /* Simplest case:  anchored match need be tried only once. */
+       if (prog->reganch)
+               return(regtry(prog, string));
+
+       /* Messy cases:  unanchored match. */
+       s = string;
+       if (prog->regstart != '\0')
+               /* We know what char it must start with. */
+               while ((s = strchr(s, prog->regstart)) != NULL) {
+                       if (regtry(prog, s))
+                               return(1);
+                       s++;
+               }
+       else
+               /* We don't -- general case. */
+               do {
+                       if (regtry(prog, s))
+                               return(1);
+               } while (*s++ != '\0');
+
+       /* Failure. */
+       return(0);
+}
+
+int
+regexec(prog, string)
+register regexp *prog;
+register char *string;
+{
+       return regexec2(prog, string, 0);
+}
+
+/*
+ - regtry - try match at specific point
+ */
+static int                     /* 0 failure, 1 success */
+regtry(prog, string)
+regexp *prog;
+char *string;
+{
+       register int i;
+       register char **sp;
+       register char **ep;
+
+       reginput = string;
+       regstartp = prog->startp;
+       regendp = prog->endp;
+
+       sp = prog->startp;
+       ep = prog->endp;
+       for (i = NSUBEXP; i > 0; i--) {
+               *sp++ = NULL;
+               *ep++ = NULL;
+       }
+       if (regmatch(prog->program + 1)) {
+               prog->startp[0] = string;
+               prog->endp[0] = reginput;
+               return(1);
+       } else
+               return(0);
+}
+
+/*
+ - regmatch - main matching routine
+ *
+ * Conceptually the strategy is simple:  check to see whether the current
+ * node matches, call self recursively to see whether the rest matches,
+ * and then act accordingly.  In practice we make some effort to avoid
+ * recursion, in particular by going through "ordinary" nodes (that don't
+ * need to know whether the rest of the match failed) by a loop instead of
+ * by recursion.
+ */
+static int                     /* 0 failure, 1 success */
+regmatch(prog)
+char *prog;
+{
+       register char *scan;    /* Current node. */
+       char *next;             /* Next node. */
+
+       scan = prog;
+#ifdef DEBUG
+       if (scan != NULL && regnarrate)
+               fprintf(stderr, "%s(\n", regprop(scan));
+#endif
+       while (scan != NULL) {
+#ifdef DEBUG
+               if (regnarrate)
+                       fprintf(stderr, "%s...\n", regprop(scan));
+#endif
+               next = regnext(scan);
+
+               switch (OP(scan)) {
+               case BOL:
+                       if (reginput != regbol)
+                               return(0);
+                       break;
+               case EOL:
+                       if (*reginput != '\0')
+                               return(0);
+                       break;
+               case ANY:
+                       if (*reginput == '\0')
+                               return(0);
+                       reginput++;
+                       break;
+               case EXACTLY: {
+                               register int len;
+                               register char *opnd;
+
+                               opnd = OPERAND(scan);
+                               /* Inline the first character, for speed. */
+                               if (*opnd != *reginput)
+                                       return(0);
+                               len = strlen(opnd);
+                               if (len > 1 && strncmp(opnd, reginput, len) != 0)
+                                       return(0);
+                               reginput += len;
+                       }
+                       break;
+               case ANYOF:
+                       if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
+                               return(0);
+                       reginput++;
+                       break;
+               case ANYBUT:
+                       if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
+                               return(0);
+                       reginput++;
+                       break;
+               case NOTHING:
+                       break;
+               case BACK:
+                       break;
+               case OPEN+1:
+               case OPEN+2:
+               case OPEN+3:
+               case OPEN+4:
+               case OPEN+5:
+               case OPEN+6:
+               case OPEN+7:
+               case OPEN+8:
+               case OPEN+9: {
+                               register int no;
+                               register char *save;
+
+                               no = OP(scan) - OPEN;
+                               save = reginput;
+
+                               if (regmatch(next)) {
+                                       /*
+                                        * Don't set startp if some later
+                                        * invocation of the same parentheses
+                                        * already has.
+                                        */
+                                       if (regstartp[no] == NULL)
+                                               regstartp[no] = save;
+                                       return(1);
+                               } else
+                                       return(0);
+                       }
+                       /* NOTREACHED */
+                       break;
+               case CLOSE+1:
+               case CLOSE+2:
+               case CLOSE+3:
+               case CLOSE+4:
+               case CLOSE+5:
+               case CLOSE+6:
+               case CLOSE+7:
+               case CLOSE+8:
+               case CLOSE+9: {
+                               register int no;
+                               register char *save;
+
+                               no = OP(scan) - CLOSE;
+                               save = reginput;
+
+                               if (regmatch(next)) {
+                                       /*
+                                        * Don't set endp if some later
+                                        * invocation of the same parentheses
+                                        * already has.
+                                        */
+                                       if (regendp[no] == NULL)
+                                               regendp[no] = save;
+                                       return(1);
+                               } else
+                                       return(0);
+                       }
+                       /* NOTREACHED */
+                       break;
+               case BRANCH: {
+                               register char *save;
+
+                               if (OP(next) != BRANCH)         /* No choice. */
+                                       next = OPERAND(scan);   /* Avoid recursion. */
+                               else {
+                                       do {
+                                               save = reginput;
+                                               if (regmatch(OPERAND(scan)))
+                                                       return(1);
+                                               reginput = save;
+                                               scan = regnext(scan);
+                                       } while (scan != NULL && OP(scan) == BRANCH);
+                                       return(0);
+                                       /* NOTREACHED */
+                               }
+                       }
+                       /* NOTREACHED */
+                       break;
+               case STAR:
+               case PLUS: {
+                               register char nextch;
+                               register int no;
+                               register char *save;
+                               register int min;
+
+                               /*
+                                * Lookahead to avoid useless match attempts
+                                * when we know what character comes next.
+                                */
+                               nextch = '\0';
+                               if (OP(next) == EXACTLY)
+                                       nextch = *OPERAND(next);
+                               min = (OP(scan) == STAR) ? 0 : 1;
+                               save = reginput;
+                               no = regrepeat(OPERAND(scan));
+                               while (no >= min) {
+                                       /* If it could work, try it. */
+                                       if (nextch == '\0' || *reginput == nextch)
+                                               if (regmatch(next))
+                                                       return(1);
+                                       /* Couldn't or didn't -- back up. */
+                                       no--;
+                                       reginput = save + no;
+                               }
+                               return(0);
+                       }
+                       /* NOTREACHED */
+                       break;
+               case END:
+                       return(1);      /* Success! */
+                       /* NOTREACHED */
+                       break;
+               default:
+                       regerror("memory corruption");
+                       return(0);
+                       /* NOTREACHED */
+                       break;
+               }
+
+               scan = next;
+       }
+
+       /*
+        * We get here only if there's trouble -- normally "case END" is
+        * the terminating point.
+        */
+       regerror("corrupted pointers");
+       return(0);
+}
+
+/*
+ - regrepeat - repeatedly match something simple, report how many
+ */
+static int
+regrepeat(p)
+char *p;
+{
+       register int count = 0;
+       register char *scan;
+       register char *opnd;
+
+       scan = reginput;
+       opnd = OPERAND(p);
+       switch (OP(p)) {
+       case ANY:
+               count = strlen(scan);
+               scan += count;
+               break;
+       case EXACTLY:
+               while (*opnd == *scan) {
+                       count++;
+                       scan++;
+               }
+               break;
+       case ANYOF:
+               while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
+                       count++;
+                       scan++;
+               }
+               break;
+       case ANYBUT:
+               while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
+                       count++;
+                       scan++;
+               }
+               break;
+       default:                /* Oh dear.  Called inappropriately. */
+               regerror("internal foulup");
+               count = 0;      /* Best compromise. */
+               break;
+       }
+       reginput = scan;
+
+       return(count);
+}
+
+/*
+ - regnext - dig the "next" pointer out of a node
+ */
+static char *
+regnext(p)
+register char *p;
+{
+       register int offset;
+
+       if (p == &regdummy)
+               return(NULL);
+
+       offset = NEXT(p);
+       if (offset == 0)
+               return(NULL);
+
+       if (OP(p) == BACK)
+               return(p-offset);
+       else
+               return(p+offset);
+}
+
+#ifdef DEBUG
+
+STATIC char *regprop();
+
+/*
+ - regdump - dump a regexp onto stdout in vaguely comprehensible form
+ */
+void
+regdump(r)
+regexp *r;
+{
+       register char *s;
+       register char op = EXACTLY;     /* Arbitrary non-END op. */
+       register char *next;
+
+
+       s = r->program + 1;
+       while (op != END) {     /* While that wasn't END last time... */
+               op = OP(s);
+               printf("%2d%s", s-r->program, regprop(s));      /* Where, what. */
+               next = regnext(s);
+               if (next == NULL)               /* Next ptr. */
+                       printf("(0)");
+               else 
+                       printf("(%d)", (s-r->program)+(next-s));
+               s += 3;
+               if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
+                       /* Literal string, where present. */
+                       while (*s != '\0') {
+                               putchar(*s);
+                               s++;
+                       }
+                       s++;
+               }
+               putchar('\n');
+       }
+
+       /* Header fields of interest. */
+       if (r->regstart != '\0')
+               printf("start `%c' ", r->regstart);
+       if (r->reganch)
+               printf("anchored ");
+       if (r->regmust != NULL)
+               printf("must have \"%s\"", r->regmust);
+       printf("\n");
+}
+
+/*
+ - regprop - printable representation of opcode
+ */
+static char *
+regprop(op)
+char *op;
+{
+       register char *p;
+       static char buf[50];
+
+       (void) strcpy(buf, ":");
+
+       switch (OP(op)) {
+       case BOL:
+               p = "BOL";
+               break;
+       case EOL:
+               p = "EOL";
+               break;
+       case ANY:
+               p = "ANY";
+               break;
+       case ANYOF:
+               p = "ANYOF";
+               break;
+       case ANYBUT:
+               p = "ANYBUT";
+               break;
+       case BRANCH:
+               p = "BRANCH";
+               break;
+       case EXACTLY:
+               p = "EXACTLY";
+               break;
+       case NOTHING:
+               p = "NOTHING";
+               break;
+       case BACK:
+               p = "BACK";
+               break;
+       case END:
+               p = "END";
+               break;
+       case OPEN+1:
+       case OPEN+2:
+       case OPEN+3:
+       case OPEN+4:
+       case OPEN+5:
+       case OPEN+6:
+       case OPEN+7:
+       case OPEN+8:
+       case OPEN+9:
+               sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
+               p = NULL;
+               break;
+       case CLOSE+1:
+       case CLOSE+2:
+       case CLOSE+3:
+       case CLOSE+4:
+       case CLOSE+5:
+       case CLOSE+6:
+       case CLOSE+7:
+       case CLOSE+8:
+       case CLOSE+9:
+               sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
+               p = NULL;
+               break;
+       case STAR:
+               p = "STAR";
+               break;
+       case PLUS:
+               p = "PLUS";
+               break;
+       default:
+               regerror("corrupted opcode");
+               break;
+       }
+       if (p != NULL)
+               (void) strcat(buf, p);
+       return(buf);
+}
+#endif
+
+/*
+ * The following is provided for those people who do not have strcspn() in
+ * their C libraries.  They should get off their butts and do something
+ * about it; at least one public-domain implementation of those (highly
+ * useful) string routines has been published on Usenet.
+ */
+#ifdef STRCSPN
+/*
+ * strcspn - find length of initial segment of s1 consisting entirely
+ * of characters not from s2
+ */
+
+static int
+strcspn(s1, s2)
+char *s1;
+char *s2;
+{
+       register char *scan1;
+       register char *scan2;
+       register int count;
+
+       count = 0;
+       for (scan1 = s1; *scan1 != '\0'; scan1++) {
+               for (scan2 = s2; *scan2 != '\0';)       /* ++ moved down. */
+                       if (*scan1 == *scan2++)
+                               return(count);
+               count++;
+       }
+       return(count);
+}
+#endif
diff --git a/thirdparty/less/regexp.h b/thirdparty/less/regexp.h
new file mode 100644 (file)
index 0000000..bcef6d1
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Definitions etc. for regexp(3) routines.
+ *
+ * Caveat:  this is V8 regexp(3) [actually, a reimplementation thereof],
+ * not the System V one.
+ */
+
+#ifndef _REGEXP
+#define _REGEXP 1
+
+#define NSUBEXP  10
+typedef struct regexp {
+       char *startp[NSUBEXP];
+       char *endp[NSUBEXP];
+       char regstart;          /* Internal use only. */
+       char reganch;           /* Internal use only. */
+       char *regmust;          /* Internal use only. */
+       int regmlen;            /* Internal use only. */
+       char program[1];        /* Unwarranted chumminess with compiler. */
+} regexp;
+
+#if defined(__STDC__) || defined(__cplusplus)
+#   define _ANSI_ARGS_(x)       x
+#else
+#   define _ANSI_ARGS_(x)       ()
+#endif
+
+extern regexp *regcomp _ANSI_ARGS_((char *exp));
+extern int regexec _ANSI_ARGS_((regexp *prog, char *string));
+extern int regexec2 _ANSI_ARGS_((regexp *prog, char *string, int notbol));
+extern void regsub _ANSI_ARGS_((regexp *prog, char *source, char *dest));
+extern void regerror _ANSI_ARGS_((char *msg));
+
+#endif /* REGEXP */
diff --git a/thirdparty/less/screen.c b/thirdparty/less/screen.c
new file mode 100644 (file)
index 0000000..b8bc666
--- /dev/null
@@ -0,0 +1,2502 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines which deal with the characteristics of the terminal.
+ * Uses termcap to be as terminal-independent as possible.
+ */
+
+#include "less.h"
+#include "cmd.h"
+
+#if MSDOS_COMPILER
+#include "pckeys.h"
+#if MSDOS_COMPILER==MSOFTC
+#include <graph.h>
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+#include <conio.h>
+#if MSDOS_COMPILER==DJGPPC
+#include <pc.h>
+extern int fd0;
+#endif
+#else
+#if MSDOS_COMPILER==WIN32C
+#include <windows.h>
+#endif
+#endif
+#endif
+#include <time.h>
+
+#else
+
+#if HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
+#include <termios.h>
+#else
+#if HAVE_TERMIO_H
+#include <termio.h>
+#else
+#if HAVE_SGSTAT_H
+#include <sgstat.h>
+#else
+#include <sgtty.h>
+#endif
+#endif
+#endif
+
+#if HAVE_TERMCAP_H
+#include <termcap.h>
+#endif
+#ifdef _OSK
+#include <signal.h>
+#endif
+#if OS2
+#include <sys/signal.h>
+#include "pckeys.h"
+#endif
+#if HAVE_SYS_STREAM_H
+#include <sys/stream.h>
+#endif
+#if HAVE_SYS_PTEM_H
+#include <sys/ptem.h>
+#endif
+
+#endif /* MSDOS_COMPILER */
+
+/*
+ * Check for broken termios package that forces you to manually
+ * set the line discipline.
+ */
+#ifdef __ultrix__
+#define MUST_SET_LINE_DISCIPLINE 1
+#else
+#define MUST_SET_LINE_DISCIPLINE 0
+#endif
+
+#if OS2
+#define        DEFAULT_TERM            "ansi"
+static char *windowid;
+#else
+#define        DEFAULT_TERM            "unknown"
+#endif
+
+#if MSDOS_COMPILER==MSOFTC
+static int videopages;
+static long msec_loops;
+static int flash_created = 0;
+#define        SETCOLORS(fg,bg)        { _settextcolor(fg); _setbkcolor(bg); }
+#endif
+
+#if MSDOS_COMPILER==BORLANDC
+static unsigned short *whitescreen;
+static int flash_created = 0;
+#endif
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+#define _settextposition(y,x)   gotoxy(x,y)
+#define _clearscreen(m)         clrscr()
+#define _outtext(s)             cputs(s)
+#define        SETCOLORS(fg,bg)        { textcolor(fg); textbackground(bg); }
+extern int sc_height;
+#endif
+
+#if MSDOS_COMPILER==WIN32C
+struct keyRecord
+{
+       int ascii;
+       int scan;
+} currentKey;
+
+static int keyCount = 0;
+static WORD curr_attr;
+static int pending_scancode = 0;
+static WORD *whitescreen;
+
+static HANDLE con_out_save = INVALID_HANDLE_VALUE; /* previous console */
+static HANDLE con_out_ours = INVALID_HANDLE_VALUE; /* our own */
+HANDLE con_out = INVALID_HANDLE_VALUE;             /* current console */
+
+extern int quitting;
+static void win32_init_term();
+static void win32_deinit_term();
+
+#define FG_COLORS       (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY)
+#define BG_COLORS       (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY)
+#define        MAKEATTR(fg,bg)         ((WORD)((fg)|((bg)<<4)))
+#define        SETCOLORS(fg,bg)        { curr_attr = MAKEATTR(fg,bg); \
+                               if (SetConsoleTextAttribute(con_out, curr_attr) == 0) \
+                               error("SETCOLORS failed"); }
+#endif
+
+#if MSDOS_COMPILER
+public int nm_fg_color;                /* Color of normal text */
+public int nm_bg_color;
+public int bo_fg_color;                /* Color of bold text */
+public int bo_bg_color;
+public int ul_fg_color;                /* Color of underlined text */
+public int ul_bg_color;
+public int so_fg_color;                /* Color of standout text */
+public int so_bg_color;
+public int bl_fg_color;                /* Color of blinking text */
+public int bl_bg_color;
+static int sy_fg_color;                /* Color of system text (before less) */
+static int sy_bg_color;
+
+#else
+
+/*
+ * Strings passed to tputs() to do various terminal functions.
+ */
+static char
+       *sc_pad,                /* Pad string */
+       *sc_home,               /* Cursor home */
+       *sc_addline,            /* Add line, scroll down following lines */
+       *sc_lower_left,         /* Cursor to last line, first column */
+       *sc_return,             /* Cursor to beginning of current line */
+       *sc_move,               /* General cursor positioning */
+       *sc_clear,              /* Clear screen */
+       *sc_eol_clear,          /* Clear to end of line */
+       *sc_eos_clear,          /* Clear to end of screen */
+       *sc_s_in,               /* Enter standout (highlighted) mode */
+       *sc_s_out,              /* Exit standout mode */
+       *sc_u_in,               /* Enter underline mode */
+       *sc_u_out,              /* Exit underline mode */
+       *sc_b_in,               /* Enter bold mode */
+       *sc_b_out,              /* Exit bold mode */
+       *sc_bl_in,              /* Enter blink mode */
+       *sc_bl_out,             /* Exit blink mode */
+       *sc_visual_bell,        /* Visual bell (flash screen) sequence */
+       *sc_backspace,          /* Backspace cursor */
+       *sc_s_keypad,           /* Start keypad mode */
+       *sc_e_keypad,           /* End keypad mode */
+       *sc_init,               /* Startup terminal initialization */
+       *sc_deinit;             /* Exit terminal de-initialization */
+#endif
+
+static int init_done = 0;
+
+public int auto_wrap;          /* Terminal does \r\n when write past margin */
+public int ignaw;              /* Terminal ignores \n immediately after wrap */
+public int erase_char;         /* The user's erase char */
+public int erase2_char;                /* The user's other erase char */
+public int kill_char;          /* The user's line-kill char */
+public int werase_char;                /* The user's word-erase char */
+public int sc_width, sc_height;        /* Height & width of screen */
+public int bo_s_width, bo_e_width;     /* Printing width of boldface seq */
+public int ul_s_width, ul_e_width;     /* Printing width of underline seq */
+public int so_s_width, so_e_width;     /* Printing width of standout seq */
+public int bl_s_width, bl_e_width;     /* Printing width of blink seq */
+public int above_mem, below_mem;       /* Memory retained above/below screen */
+public int can_goto_line;              /* Can move cursor to any line */
+public int clear_bg;           /* Clear fills with background color */
+public int missing_cap = 0;    /* Some capability is missing */
+
+static int attrmode = AT_NORMAL;
+extern int binattr;
+
+#if !MSDOS_COMPILER
+static char *cheaper();
+static void tmodes();
+#endif
+
+/*
+ * These two variables are sometimes defined in,
+ * and needed by, the termcap library.
+ */
+#if MUST_DEFINE_OSPEED
+extern short ospeed;   /* Terminal output baud rate */
+extern char PC;                /* Pad character */
+#endif
+#ifdef _OSK
+short ospeed;
+char PC_, *UP, *BC;
+#endif
+
+extern int quiet;              /* If VERY_QUIET, use visual bell for bell */
+extern int no_back_scroll;
+extern int swindow;
+extern int no_init;
+extern int no_keypad;
+extern int sigs;
+extern int wscroll;
+extern int screen_trashed;
+extern int tty;
+extern int top_scroll;
+extern int oldbot;
+#if HILITE_SEARCH
+extern int hilite_search;
+#endif
+
+extern char *tgetstr();
+extern char *tgoto();
+
+
+/*
+ * Change terminal to "raw mode", or restore to "normal" mode.
+ * "Raw mode" means 
+ *     1. An outstanding read will complete on receipt of a single keystroke.
+ *     2. Input is not echoed.  
+ *     3. On output, \n is mapped to \r\n.
+ *     4. \t is NOT expanded into spaces.
+ *     5. Signal-causing characters such as ctrl-C (interrupt),
+ *        etc. are NOT disabled.
+ * It doesn't matter whether an input \n is mapped to \r, or vice versa.
+ */
+       public void
+raw_mode(on)
+       int on;
+{
+       static int curr_on = 0;
+
+       if (on == curr_on)
+               return;
+       erase2_char = '\b'; /* in case OS doesn't know about erase2 */
+#if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS
+    {
+       struct termios s;
+       static struct termios save_term;
+       static int saved_term = 0;
+
+       if (on) 
+       {
+               /*
+                * Get terminal modes.
+                */
+               tcgetattr(tty, &s);
+
+               /*
+                * Save modes and set certain variables dependent on modes.
+                */
+               if (!saved_term)
+               {
+                       save_term = s;
+                       saved_term = 1;
+               }
+#if HAVE_OSPEED
+               switch (cfgetospeed(&s))
+               {
+#ifdef B0
+               case B0: ospeed = 0; break;
+#endif
+#ifdef B50
+               case B50: ospeed = 1; break;
+#endif
+#ifdef B75
+               case B75: ospeed = 2; break;
+#endif
+#ifdef B110
+               case B110: ospeed = 3; break;
+#endif
+#ifdef B134
+               case B134: ospeed = 4; break;
+#endif
+#ifdef B150
+               case B150: ospeed = 5; break;
+#endif
+#ifdef B200
+               case B200: ospeed = 6; break;
+#endif
+#ifdef B300
+               case B300: ospeed = 7; break;
+#endif
+#ifdef B600
+               case B600: ospeed = 8; break;
+#endif
+#ifdef B1200
+               case B1200: ospeed = 9; break;
+#endif
+#ifdef B1800
+               case B1800: ospeed = 10; break;
+#endif
+#ifdef B2400
+               case B2400: ospeed = 11; break;
+#endif
+#ifdef B4800
+               case B4800: ospeed = 12; break;
+#endif
+#ifdef B9600
+               case B9600: ospeed = 13; break;
+#endif
+#ifdef EXTA
+               case EXTA: ospeed = 14; break;
+#endif
+#ifdef EXTB
+               case EXTB: ospeed = 15; break;
+#endif
+#ifdef B57600
+               case B57600: ospeed = 16; break;
+#endif
+#ifdef B115200
+               case B115200: ospeed = 17; break;
+#endif
+               default: ;
+               }
+#endif
+               erase_char = s.c_cc[VERASE];
+#ifdef VERASE2
+               erase2_char = s.c_cc[VERASE2];
+#endif
+               kill_char = s.c_cc[VKILL];
+#ifdef VWERASE
+               werase_char = s.c_cc[VWERASE];
+#else
+               werase_char = CONTROL('W');
+#endif
+
+               /*
+                * Set the modes to the way we want them.
+                */
+               s.c_lflag &= ~(0
+#ifdef ICANON
+                       | ICANON
+#endif
+#ifdef ECHO
+                       | ECHO
+#endif
+#ifdef ECHOE
+                       | ECHOE
+#endif
+#ifdef ECHOK
+                       | ECHOK
+#endif
+#if ECHONL
+                       | ECHONL
+#endif
+               );
+
+               s.c_oflag |= (0
+#ifdef OXTABS
+                       | OXTABS
+#else
+#ifdef TAB3
+                       | TAB3
+#else
+#ifdef XTABS
+                       | XTABS
+#endif
+#endif
+#endif
+#ifdef OPOST
+                       | OPOST
+#endif
+#ifdef ONLCR
+                       | ONLCR
+#endif
+               );
+
+               s.c_oflag &= ~(0
+#ifdef ONOEOT
+                       | ONOEOT
+#endif
+#ifdef OCRNL
+                       | OCRNL
+#endif
+#ifdef ONOCR
+                       | ONOCR
+#endif
+#ifdef ONLRET
+                       | ONLRET
+#endif
+               );
+               s.c_cc[VMIN] = 1;
+               s.c_cc[VTIME] = 0;
+#ifdef VLNEXT
+               s.c_cc[VLNEXT] = 0;
+#endif
+#ifdef VDSUSP
+               s.c_cc[VDSUSP] = 0;
+#endif
+#if MUST_SET_LINE_DISCIPLINE
+               /*
+                * System's termios is broken; need to explicitly 
+                * request TERMIODISC line discipline.
+                */
+               s.c_line = TERMIODISC;
+#endif
+       } else
+       {
+               /*
+                * Restore saved modes.
+                */
+               s = save_term;
+       }
+#if HAVE_FSYNC
+       fsync(tty);
+#endif
+       tcsetattr(tty, TCSADRAIN, &s);
+#if MUST_SET_LINE_DISCIPLINE
+       if (!on)
+       {
+               /*
+                * Broken termios *ignores* any line discipline
+                * except TERMIODISC.  A different old line discipline
+                * is therefore not restored, yet.  Restore the old
+                * line discipline by hand.
+                */
+               ioctl(tty, TIOCSETD, &save_term.c_line);
+       }
+#endif
+    }
+#else
+#ifdef TCGETA
+    {
+       struct termio s;
+       static struct termio save_term;
+       static int saved_term = 0;
+
+       if (on)
+       {
+               /*
+                * Get terminal modes.
+                */
+               ioctl(tty, TCGETA, &s);
+
+               /*
+                * Save modes and set certain variables dependent on modes.
+                */
+               if (!saved_term)
+               {
+                       save_term = s;
+                       saved_term = 1;
+               }
+#if HAVE_OSPEED
+               ospeed = s.c_cflag & CBAUD;
+#endif
+               erase_char = s.c_cc[VERASE];
+               kill_char = s.c_cc[VKILL];
+#ifdef VWERASE
+               werase_char = s.c_cc[VWERASE];
+#else
+               werase_char = CONTROL('W');
+#endif
+
+               /*
+                * Set the modes to the way we want them.
+                */
+               s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL);
+               s.c_oflag |=  (OPOST|ONLCR|TAB3);
+               s.c_oflag &= ~(OCRNL|ONOCR|ONLRET);
+               s.c_cc[VMIN] = 1;
+               s.c_cc[VTIME] = 0;
+       } else
+       {
+               /*
+                * Restore saved modes.
+                */
+               s = save_term;
+       }
+       ioctl(tty, TCSETAW, &s);
+    }
+#else
+#ifdef TIOCGETP
+    {
+       struct sgttyb s;
+       static struct sgttyb save_term;
+       static int saved_term = 0;
+
+       if (on)
+       {
+               /*
+                * Get terminal modes.
+                */
+               ioctl(tty, TIOCGETP, &s);
+
+               /*
+                * Save modes and set certain variables dependent on modes.
+                */
+               if (!saved_term)
+               {
+                       save_term = s;
+                       saved_term = 1;
+               }
+#if HAVE_OSPEED
+               ospeed = s.sg_ospeed;
+#endif
+               erase_char = s.sg_erase;
+               kill_char = s.sg_kill;
+               werase_char = CONTROL('W');
+
+               /*
+                * Set the modes to the way we want them.
+                */
+               s.sg_flags |= CBREAK;
+               s.sg_flags &= ~(ECHO|XTABS);
+       } else
+       {
+               /*
+                * Restore saved modes.
+                */
+               s = save_term;
+       }
+       ioctl(tty, TIOCSETN, &s);
+    }
+#else
+#ifdef _OSK
+    {
+       struct sgbuf s;
+       static struct sgbuf save_term;
+       static int saved_term = 0;
+
+       if (on)
+       {
+               /*
+                * Get terminal modes.
+                */
+               _gs_opt(tty, &s);
+
+               /*
+                * Save modes and set certain variables dependent on modes.
+                */
+               if (!saved_term)
+               {
+                       save_term = s;
+                       saved_term = 1;
+               }
+               erase_char = s.sg_bspch;
+               kill_char = s.sg_dlnch;
+               werase_char = CONTROL('W');
+
+               /*
+                * Set the modes to the way we want them.
+                */
+               s.sg_echo = 0;
+               s.sg_eofch = 0;
+               s.sg_pause = 0;
+               s.sg_psch = 0;
+       } else
+       {
+               /*
+                * Restore saved modes.
+                */
+               s = save_term;
+       }
+       _ss_opt(tty, &s);
+    }
+#else
+       /* MS-DOS, Windows, or OS2 */
+#if OS2
+       /* OS2 */
+       LSIGNAL(SIGINT, SIG_IGN);
+#endif
+       erase_char = '\b';
+#if MSDOS_COMPILER==DJGPPC
+       kill_char = CONTROL('U');
+       /*
+        * So that when we shell out or run another program, its
+        * stdin is in cooked mode.  We do not switch stdin to binary 
+        * mode if fd0 is zero, since that means we were called before
+        * tty was reopened in open_getchr, in which case we would be
+        * changing the original stdin device outside less.
+        */
+       if (fd0 != 0)
+               setmode(0, on ? O_BINARY : O_TEXT);
+#else
+       kill_char = ESC;
+#endif
+       werase_char = CONTROL('W');
+#endif
+#endif
+#endif
+#endif
+       curr_on = on;
+}
+
+#if !MSDOS_COMPILER
+/*
+ * Some glue to prevent calling termcap functions if tgetent() failed.
+ */
+static int hardcopy;
+
+       static char *
+ltget_env(capname)
+       char *capname;
+{
+       char name[16];
+       char *s;
+
+       s = lgetenv("LESS_TERMCAP_DEBUG");
+       if (s != NULL && *s != '\0')
+       {
+               struct env { struct env *next; char *name; char *value; };
+               static struct env *envs = NULL;
+               struct env *p;
+               for (p = envs;  p != NULL;  p = p->next)
+                       if (strcmp(p->name, capname) == 0)
+                               return p->value;
+               p = (struct env *) ecalloc(1, sizeof(struct env));
+               p->name = save(capname);
+               p->value = (char *) ecalloc(strlen(capname)+3, sizeof(char));
+               sprintf(p->value, "<%s>", capname);
+               p->next = envs;
+               envs = p;
+               return p->value;
+       }
+       strcpy(name, "LESS_TERMCAP_");
+       strcat(name, capname);
+       return (lgetenv(name));
+}
+
+       static int
+ltgetflag(capname)
+       char *capname;
+{
+       char *s;
+
+       if ((s = ltget_env(capname)) != NULL)
+               return (*s != '\0' && *s != '0');
+       if (hardcopy)
+               return (0);
+       return (tgetflag(capname));
+}
+
+       static int
+ltgetnum(capname)
+       char *capname;
+{
+       char *s;
+
+       if ((s = ltget_env(capname)) != NULL)
+               return (atoi(s));
+       if (hardcopy)
+               return (-1);
+       return (tgetnum(capname));
+}
+
+       static char *
+ltgetstr(capname, pp)
+       char *capname;
+       char **pp;
+{
+       char *s;
+
+       if ((s = ltget_env(capname)) != NULL)
+               return (s);
+       if (hardcopy)
+               return (NULL);
+       return (tgetstr(capname, pp));
+}
+#endif /* MSDOS_COMPILER */
+
+/*
+ * Get size of the output screen.
+ */
+       public void
+scrsize()
+{
+       register char *s;
+       int sys_height;
+       int sys_width;
+#if !MSDOS_COMPILER
+       int n;
+#endif
+
+#define        DEF_SC_WIDTH    80
+#if MSDOS_COMPILER
+#define        DEF_SC_HEIGHT   25
+#else
+#define        DEF_SC_HEIGHT   24
+#endif
+
+
+       sys_width = sys_height = 0;
+
+#if MSDOS_COMPILER==MSOFTC
+       {
+               struct videoconfig w;
+               _getvideoconfig(&w);
+               sys_height = w.numtextrows;
+               sys_width = w.numtextcols;
+       }
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+       {
+               struct text_info w;
+               gettextinfo(&w);
+               sys_height = w.screenheight;
+               sys_width = w.screenwidth;
+       }
+#else
+#if MSDOS_COMPILER==WIN32C
+       {
+               CONSOLE_SCREEN_BUFFER_INFO scr;
+               GetConsoleScreenBufferInfo(con_out, &scr);
+               sys_height = scr.srWindow.Bottom - scr.srWindow.Top + 1;
+               sys_width = scr.srWindow.Right - scr.srWindow.Left + 1;
+       }
+#else
+#if OS2
+       {
+               int s[2];
+               _scrsize(s);
+               sys_width = s[0];
+               sys_height = s[1];
+               /*
+                * When using terminal emulators for XFree86/OS2, the
+                * _scrsize function does not work well.
+                * Call the scrsize.exe program to get the window size.
+                */
+               windowid = getenv("WINDOWID");
+               if (windowid != NULL)
+               {
+                       FILE *fd = popen("scrsize", "rt");
+                       if (fd != NULL)
+                       {
+                               int w, h;
+                               fscanf(fd, "%i %i", &w, &h);
+                               if (w > 0 && h > 0)
+                               {
+                                       sys_width = w;
+                                       sys_height = h;
+                               }
+                               pclose(fd);
+                       }
+               }
+       }
+#else
+#ifdef TIOCGWINSZ
+       {
+               struct winsize w;
+               if (ioctl(2, TIOCGWINSZ, &w) == 0)
+               {
+                       if (w.ws_row > 0)
+                               sys_height = w.ws_row;
+                       if (w.ws_col > 0)
+                               sys_width = w.ws_col;
+               }
+       }
+#else
+#ifdef WIOCGETD
+       {
+               struct uwdata w;
+               if (ioctl(2, WIOCGETD, &w) == 0)
+               {
+                       if (w.uw_height > 0)
+                               sys_height = w.uw_height / w.uw_vs;
+                       if (w.uw_width > 0)
+                               sys_width = w.uw_width / w.uw_hs;
+               }
+       }
+#endif
+#endif
+#endif
+#endif
+#endif
+#endif
+
+       if (sys_height > 0)
+               sc_height = sys_height;
+       else if ((s = lgetenv("LINES")) != NULL)
+               sc_height = atoi(s);
+#if !MSDOS_COMPILER
+       else if ((n = ltgetnum("li")) > 0)
+               sc_height = n;
+#endif
+       else
+               sc_height = DEF_SC_HEIGHT;
+
+       if (sys_width > 0)
+               sc_width = sys_width;
+       else if ((s = lgetenv("COLUMNS")) != NULL)
+               sc_width = atoi(s);
+#if !MSDOS_COMPILER
+       else if ((n = ltgetnum("co")) > 0)
+               sc_width = n;
+#endif
+       else
+               sc_width = DEF_SC_WIDTH;
+}
+
+#if MSDOS_COMPILER==MSOFTC
+/*
+ * Figure out how many empty loops it takes to delay a millisecond.
+ */
+       static void
+get_clock()
+{
+       clock_t start;
+       
+       /*
+        * Get synchronized at the start of a tick.
+        */
+       start = clock();
+       while (clock() == start)
+               ;
+       /*
+        * Now count loops till the next tick.
+        */
+       start = clock();
+       msec_loops = 0;
+       while (clock() == start)
+               msec_loops++;
+       /*
+        * Convert from (loops per clock) to (loops per millisecond).
+        */
+       msec_loops *= CLOCKS_PER_SEC;
+       msec_loops /= 1000;
+}
+
+/*
+ * Delay for a specified number of milliseconds.
+ */
+       static void
+dummy_func()
+{
+       static long delay_dummy = 0;
+       delay_dummy++;
+}
+
+       static void
+delay(msec)
+       int msec;
+{
+       long i;
+       
+       while (msec-- > 0)
+       {
+               for (i = 0;  i < msec_loops;  i++)
+               {
+                       /*
+                        * Make it look like we're doing something here,
+                        * so the optimizer doesn't remove the whole loop.
+                        */
+                       dummy_func();
+               }
+       }
+}
+#endif
+
+/*
+ * Return the characters actually input by a "special" key.
+ */
+       public char *
+special_key_str(key)
+       int key;
+{
+       static char tbuf[40];
+       char *s;
+#if MSDOS_COMPILER || OS2
+       static char k_right[]           = { '\340', PCK_RIGHT, 0 };
+       static char k_left[]            = { '\340', PCK_LEFT, 0  };
+       static char k_ctl_right[]       = { '\340', PCK_CTL_RIGHT, 0  };
+       static char k_ctl_left[]        = { '\340', PCK_CTL_LEFT, 0  };
+       static char k_insert[]          = { '\340', PCK_INSERT, 0  };
+       static char k_delete[]          = { '\340', PCK_DELETE, 0  };
+       static char k_ctl_delete[]      = { '\340', PCK_CTL_DELETE, 0  };
+       static char k_ctl_backspace[]   = { '\177', 0 };
+       static char k_home[]            = { '\340', PCK_HOME, 0 };
+       static char k_end[]             = { '\340', PCK_END, 0 };
+       static char k_up[]              = { '\340', PCK_UP, 0 };
+       static char k_down[]            = { '\340', PCK_DOWN, 0 };
+       static char k_backtab[]         = { '\340', PCK_SHIFT_TAB, 0 };
+       static char k_pagedown[]        = { '\340', PCK_PAGEDOWN, 0 };
+       static char k_pageup[]          = { '\340', PCK_PAGEUP, 0 };
+       static char k_f1[]              = { '\340', PCK_F1, 0 };
+#endif
+#if !MSDOS_COMPILER
+       char *sp = tbuf;
+#endif
+
+       switch (key)
+       {
+#if OS2
+       /*
+        * If windowid is not NULL, assume less is executed in 
+        * the XFree86 environment.
+        */
+       case SK_RIGHT_ARROW:
+               s = windowid ? ltgetstr("kr", &sp) : k_right;
+               break;
+       case SK_LEFT_ARROW:
+               s = windowid ? ltgetstr("kl", &sp) : k_left;
+               break;
+       case SK_UP_ARROW:
+               s = windowid ? ltgetstr("ku", &sp) : k_up;
+               break;
+       case SK_DOWN_ARROW:
+               s = windowid ? ltgetstr("kd", &sp) : k_down;
+               break;
+       case SK_PAGE_UP:
+               s = windowid ? ltgetstr("kP", &sp) : k_pageup;
+               break;
+       case SK_PAGE_DOWN:
+               s = windowid ? ltgetstr("kN", &sp) : k_pagedown;
+               break;
+       case SK_HOME:
+               s = windowid ? ltgetstr("kh", &sp) : k_home;
+               break;
+       case SK_END:
+               s = windowid ? ltgetstr("@7", &sp) : k_end;
+               break;
+       case SK_DELETE:
+               if (windowid)
+               {
+                       s = ltgetstr("kD", &sp);
+                       if (s == NULL)
+                       {
+                               tbuf[0] = '\177';
+                               tbuf[1] = '\0';
+                               s = tbuf;
+                       }
+               } else
+                       s = k_delete;
+               break;
+#endif
+#if MSDOS_COMPILER
+       case SK_RIGHT_ARROW:
+               s = k_right;
+               break;
+       case SK_LEFT_ARROW:
+               s = k_left;
+               break;
+       case SK_UP_ARROW:
+               s = k_up;
+               break;
+       case SK_DOWN_ARROW:
+               s = k_down;
+               break;
+       case SK_PAGE_UP:
+               s = k_pageup;
+               break;
+       case SK_PAGE_DOWN:
+               s = k_pagedown;
+               break;
+       case SK_HOME:
+               s = k_home;
+               break;
+       case SK_END:
+               s = k_end;
+               break;
+       case SK_DELETE:
+               s = k_delete;
+               break;
+#endif
+#if MSDOS_COMPILER || OS2
+       case SK_INSERT:
+               s = k_insert;
+               break;
+       case SK_CTL_LEFT_ARROW:
+               s = k_ctl_left;
+               break;
+       case SK_CTL_RIGHT_ARROW:
+               s = k_ctl_right;
+               break;
+       case SK_CTL_BACKSPACE:
+               s = k_ctl_backspace;
+               break;
+       case SK_CTL_DELETE:
+               s = k_ctl_delete;
+               break;
+       case SK_F1:
+               s = k_f1;
+               break;
+       case SK_BACKTAB:
+               s = k_backtab;
+               break;
+#else
+       case SK_RIGHT_ARROW:
+               s = ltgetstr("kr", &sp);
+               break;
+       case SK_LEFT_ARROW:
+               s = ltgetstr("kl", &sp);
+               break;
+       case SK_UP_ARROW:
+               s = ltgetstr("ku", &sp);
+               break;
+       case SK_DOWN_ARROW:
+               s = ltgetstr("kd", &sp);
+               break;
+       case SK_PAGE_UP:
+               s = ltgetstr("kP", &sp);
+               break;
+       case SK_PAGE_DOWN:
+               s = ltgetstr("kN", &sp);
+               break;
+       case SK_HOME:
+               s = ltgetstr("kh", &sp);
+               break;
+       case SK_END:
+               s = ltgetstr("@7", &sp);
+               break;
+       case SK_DELETE:
+               s = ltgetstr("kD", &sp);
+               if (s == NULL)
+               {
+                       tbuf[0] = '\177';
+                       tbuf[1] = '\0';
+                       s = tbuf;
+               }
+               break;
+#endif
+       case SK_CONTROL_K:
+               tbuf[0] = CONTROL('K');
+               tbuf[1] = '\0';
+               s = tbuf;
+               break;
+       default:
+               return (NULL);
+       }
+       return (s);
+}
+
+/*
+ * Get terminal capabilities via termcap.
+ */
+       public void
+get_term()
+{
+#if MSDOS_COMPILER
+       auto_wrap = 1;
+       ignaw = 0;
+       can_goto_line = 1;
+       clear_bg = 1;
+       /*
+        * Set up default colors.
+        * The xx_s_width and xx_e_width vars are already initialized to 0.
+        */
+#if MSDOS_COMPILER==MSOFTC
+       sy_bg_color = _getbkcolor();
+       sy_fg_color = _gettextcolor();
+       get_clock();
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+    {
+       struct text_info w;
+       gettextinfo(&w);
+       sy_bg_color = (w.attribute >> 4) & 0x0F;
+       sy_fg_color = (w.attribute >> 0) & 0x0F;
+    }
+#else
+#if MSDOS_COMPILER==WIN32C
+    {
+       DWORD nread;
+       CONSOLE_SCREEN_BUFFER_INFO scr;
+
+       con_out_save = con_out = GetStdHandle(STD_OUTPUT_HANDLE);
+       /*
+        * Always open stdin in binary. Note this *must* be done
+        * before any file operations have been done on fd0.
+        */
+       SET_BINARY(0);
+       GetConsoleScreenBufferInfo(con_out, &scr);
+       ReadConsoleOutputAttribute(con_out, &curr_attr, 
+                                       1, scr.dwCursorPosition, &nread);
+       sy_bg_color = (curr_attr & BG_COLORS) >> 4; /* normalize */
+       sy_fg_color = curr_attr & FG_COLORS;
+    }
+#endif
+#endif
+#endif
+       nm_fg_color = sy_fg_color;
+       nm_bg_color = sy_bg_color;
+       bo_fg_color = 11;
+       bo_bg_color = 0;
+       ul_fg_color = 9;
+       ul_bg_color = 0;
+       so_fg_color = 15;
+       so_bg_color = 9;
+       bl_fg_color = 15;
+       bl_bg_color = 0;
+
+       /*
+        * Get size of the screen.
+        */
+       scrsize();
+       pos_init();
+
+
+#else /* !MSDOS_COMPILER */
+
+       char *sp;
+       register char *t1, *t2;
+       char *term;
+       char termbuf[TERMBUF_SIZE];
+
+       static char sbuf[TERMSBUF_SIZE];
+
+#if OS2
+       /*
+        * Make sure the termcap database is available.
+        */
+       sp = lgetenv("TERMCAP");
+       if (sp == NULL || *sp == '\0')
+       {
+               char *termcap;
+               if ((sp = homefile("termcap.dat")) != NULL)
+               {
+                       termcap = (char *) ecalloc(strlen(sp)+9, sizeof(char));
+                       sprintf(termcap, "TERMCAP=%s", sp);
+                       free(sp);
+                       putenv(termcap);
+               }
+       }
+#endif
+       /*
+        * Find out what kind of terminal this is.
+        */
+       if ((term = lgetenv("TERM")) == NULL)
+               term = DEFAULT_TERM;
+       hardcopy = 0;
+       if (tgetent(termbuf, term) != TGETENT_OK)
+               hardcopy = 1;
+       if (ltgetflag("hc"))
+               hardcopy = 1;
+
+       /*
+        * Get size of the screen.
+        */
+       scrsize();
+       pos_init();
+
+       auto_wrap = ltgetflag("am");
+       ignaw = ltgetflag("xn");
+       above_mem = ltgetflag("da");
+       below_mem = ltgetflag("db");
+       clear_bg = ltgetflag("ut");
+
+       /*
+        * Assumes termcap variable "sg" is the printing width of:
+        * the standout sequence, the end standout sequence,
+        * the underline sequence, the end underline sequence,
+        * the boldface sequence, and the end boldface sequence.
+        */
+       if ((so_s_width = ltgetnum("sg")) < 0)
+               so_s_width = 0;
+       so_e_width = so_s_width;
+
+       bo_s_width = bo_e_width = so_s_width;
+       ul_s_width = ul_e_width = so_s_width;
+       bl_s_width = bl_e_width = so_s_width;
+
+#if HILITE_SEARCH
+       if (so_s_width > 0 || so_e_width > 0)
+               /*
+                * Disable highlighting by default on magic cookie terminals.
+                * Turning on highlighting might change the displayed width
+                * of a line, causing the display to get messed up.
+                * The user can turn it back on with -g, 
+                * but she won't like the results.
+                */
+               hilite_search = 0;
+#endif
+
+       /*
+        * Get various string-valued capabilities.
+        */
+       sp = sbuf;
+
+#if HAVE_OSPEED
+       sc_pad = ltgetstr("pc", &sp);
+       if (sc_pad != NULL)
+               PC = *sc_pad;
+#endif
+
+       sc_s_keypad = ltgetstr("ks", &sp);
+       if (sc_s_keypad == NULL)
+               sc_s_keypad = "";
+       sc_e_keypad = ltgetstr("ke", &sp);
+       if (sc_e_keypad == NULL)
+               sc_e_keypad = "";
+               
+       sc_init = ltgetstr("ti", &sp);
+       if (sc_init == NULL)
+               sc_init = "";
+
+       sc_deinit= ltgetstr("te", &sp);
+       if (sc_deinit == NULL)
+               sc_deinit = "";
+
+       sc_eol_clear = ltgetstr("ce", &sp);
+       if (sc_eol_clear == NULL || *sc_eol_clear == '\0')
+       {
+               missing_cap = 1;
+               sc_eol_clear = "";
+       }
+
+       sc_eos_clear = ltgetstr("cd", &sp);
+       if (below_mem && (sc_eos_clear == NULL || *sc_eos_clear == '\0'))
+       {
+               missing_cap = 1;
+               sc_eos_clear = "";
+       }
+
+       sc_clear = ltgetstr("cl", &sp);
+       if (sc_clear == NULL || *sc_clear == '\0')
+       {
+               missing_cap = 1;
+               sc_clear = "\n\n";
+       }
+
+       sc_move = ltgetstr("cm", &sp);
+       if (sc_move == NULL || *sc_move == '\0')
+       {
+               /*
+                * This is not an error here, because we don't 
+                * always need sc_move.
+                * We need it only if we don't have home or lower-left.
+                */
+               sc_move = "";
+               can_goto_line = 0;
+       } else
+               can_goto_line = 1;
+
+       tmodes("so", "se", &sc_s_in, &sc_s_out, "", "", &sp);
+       tmodes("us", "ue", &sc_u_in, &sc_u_out, sc_s_in, sc_s_out, &sp);
+       tmodes("md", "me", &sc_b_in, &sc_b_out, sc_s_in, sc_s_out, &sp);
+       tmodes("mb", "me", &sc_bl_in, &sc_bl_out, sc_s_in, sc_s_out, &sp);
+
+       sc_visual_bell = ltgetstr("vb", &sp);
+       if (sc_visual_bell == NULL)
+               sc_visual_bell = "";
+
+       if (ltgetflag("bs"))
+               sc_backspace = "\b";
+       else
+       {
+               sc_backspace = ltgetstr("bc", &sp);
+               if (sc_backspace == NULL || *sc_backspace == '\0')
+                       sc_backspace = "\b";
+       }
+
+       /*
+        * Choose between using "ho" and "cm" ("home" and "cursor move")
+        * to move the cursor to the upper left corner of the screen.
+        */
+       t1 = ltgetstr("ho", &sp);
+       if (t1 == NULL)
+               t1 = "";
+       if (*sc_move == '\0')
+               t2 = "";
+       else
+       {
+               strcpy(sp, tgoto(sc_move, 0, 0));
+               t2 = sp;
+               sp += strlen(sp) + 1;
+       }
+       sc_home = cheaper(t1, t2, "|\b^");
+
+       /*
+        * Choose between using "ll" and "cm"  ("lower left" and "cursor move")
+        * to move the cursor to the lower left corner of the screen.
+        */
+       t1 = ltgetstr("ll", &sp);
+       if (t1 == NULL)
+               t1 = "";
+       if (*sc_move == '\0')
+               t2 = "";
+       else
+       {
+               strcpy(sp, tgoto(sc_move, 0, sc_height-1));
+               t2 = sp;
+               sp += strlen(sp) + 1;
+       }
+       sc_lower_left = cheaper(t1, t2, "\r");
+
+       /*
+        * Get carriage return string.
+        */
+       sc_return = ltgetstr("cr", &sp);
+       if (sc_return == NULL)
+               sc_return = "\r";
+
+       /*
+        * Choose between using "al" or "sr" ("add line" or "scroll reverse")
+        * to add a line at the top of the screen.
+        */
+       t1 = ltgetstr("al", &sp);
+       if (t1 == NULL)
+               t1 = "";
+       t2 = ltgetstr("sr", &sp);
+       if (t2 == NULL)
+               t2 = "";
+#if OS2
+       if (*t1 == '\0' && *t2 == '\0')
+               sc_addline = "";
+       else
+#endif
+       if (above_mem)
+               sc_addline = t1;
+       else
+               sc_addline = cheaper(t1, t2, "");
+       if (*sc_addline == '\0')
+       {
+               /*
+                * Force repaint on any backward movement.
+                */
+               no_back_scroll = 1;
+       }
+#endif /* MSDOS_COMPILER */
+}
+
+#if !MSDOS_COMPILER
+/*
+ * Return the cost of displaying a termcap string.
+ * We use the trick of calling tputs, but as a char printing function
+ * we give it inc_costcount, which just increments "costcount".
+ * This tells us how many chars would be printed by using this string.
+ * {{ Couldn't we just use strlen? }}
+ */
+static int costcount;
+
+/*ARGSUSED*/
+       static int
+inc_costcount(c)
+       int c;
+{
+       costcount++;
+       return (c);
+}
+
+       static int
+cost(t)
+       char *t;
+{
+       costcount = 0;
+       tputs(t, sc_height, inc_costcount);
+       return (costcount);
+}
+
+/*
+ * Return the "best" of the two given termcap strings.
+ * The best, if both exist, is the one with the lower 
+ * cost (see cost() function).
+ */
+       static char *
+cheaper(t1, t2, def)
+       char *t1, *t2;
+       char *def;
+{
+       if (*t1 == '\0' && *t2 == '\0')
+       {
+               missing_cap = 1;
+               return (def);
+       }
+       if (*t1 == '\0')
+               return (t2);
+       if (*t2 == '\0')
+               return (t1);
+       if (cost(t1) < cost(t2))
+               return (t1);
+       return (t2);
+}
+
+       static void
+tmodes(incap, outcap, instr, outstr, def_instr, def_outstr, spp)
+       char *incap;
+       char *outcap;
+       char **instr;
+       char **outstr;
+       char *def_instr;
+       char *def_outstr;
+       char **spp;
+{
+       *instr = ltgetstr(incap, spp);
+       if (*instr == NULL)
+       {
+               /* Use defaults. */
+               *instr = def_instr;
+               *outstr = def_outstr;
+               return;
+       }
+
+       *outstr = ltgetstr(outcap, spp);
+       if (*outstr == NULL)
+               /* No specific out capability; use "me". */
+               *outstr = ltgetstr("me", spp);
+       if (*outstr == NULL)
+               /* Don't even have "me"; use a null string. */
+               *outstr = "";
+}
+
+#endif /* MSDOS_COMPILER */
+
+
+/*
+ * Below are the functions which perform all the 
+ * terminal-specific screen manipulation.
+ */
+
+
+#if MSDOS_COMPILER
+
+#if MSDOS_COMPILER==WIN32C
+       static void
+_settextposition(int row, int col)
+{
+       COORD cpos;
+       CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+       GetConsoleScreenBufferInfo(con_out, &csbi);
+       cpos.X = csbi.srWindow.Left + (col - 1);
+       cpos.Y = csbi.srWindow.Top + (row - 1);
+       SetConsoleCursorPosition(con_out, cpos);
+}
+#endif
+
+/*
+ * Initialize the screen to the correct color at startup.
+ */
+       static void
+initcolor()
+{
+       SETCOLORS(nm_fg_color, nm_bg_color);
+#if 0
+       /*
+        * This clears the screen at startup.  This is different from
+        * the behavior of other versions of less.  Disable it for now.
+        */
+       char *blanks;
+       int row;
+       int col;
+       
+       /*
+        * Create a complete, blank screen using "normal" colors.
+        */
+       SETCOLORS(nm_fg_color, nm_bg_color);
+       blanks = (char *) ecalloc(width+1, sizeof(char));
+       for (col = 0;  col < sc_width;  col++)
+               blanks[col] = ' ';
+       blanks[sc_width] = '\0';
+       for (row = 0;  row < sc_height;  row++)
+               _outtext(blanks);
+       free(blanks);
+#endif
+}
+#endif
+
+#if MSDOS_COMPILER==WIN32C
+
+/*
+ * Termcap-like init with a private win32 console.
+ */
+       static void
+win32_init_term()
+{
+       CONSOLE_SCREEN_BUFFER_INFO scr;
+       COORD size;
+
+       if (con_out_save == INVALID_HANDLE_VALUE)
+               return;
+
+       GetConsoleScreenBufferInfo(con_out_save, &scr);
+
+       if (con_out_ours == INVALID_HANDLE_VALUE)
+       {
+               /*
+                * Create our own screen buffer, so that we
+                * may restore the original when done.
+                */
+               con_out_ours = CreateConsoleScreenBuffer(
+                       GENERIC_WRITE | GENERIC_READ,
+                       FILE_SHARE_WRITE | FILE_SHARE_READ,
+                       (LPSECURITY_ATTRIBUTES) NULL,
+                       CONSOLE_TEXTMODE_BUFFER,
+                       (LPVOID) NULL);
+       }
+
+       size.X = scr.srWindow.Right - scr.srWindow.Left + 1;
+       size.Y = scr.srWindow.Bottom - scr.srWindow.Top + 1;
+       SetConsoleScreenBufferSize(con_out_ours, size);
+       SetConsoleActiveScreenBuffer(con_out_ours);
+       con_out = con_out_ours;
+}
+
+/*
+ * Restore the startup console.
+ */
+static void
+win32_deinit_term()
+{
+       if (con_out_save == INVALID_HANDLE_VALUE)
+               return;
+       if (quitting)
+               (void) CloseHandle(con_out_ours);
+       SetConsoleActiveScreenBuffer(con_out_save);
+       con_out = con_out_save;
+}
+
+#endif
+
+/*
+ * Initialize terminal
+ */
+       public void
+init()
+{
+#if !MSDOS_COMPILER
+       if (!no_init)
+               tputs(sc_init, sc_height, putchr);
+       if (!no_keypad)
+               tputs(sc_s_keypad, sc_height, putchr);
+       if (top_scroll) 
+       {
+               int i;
+
+               /*
+                * This is nice to terminals with no alternate screen,
+                * but with saved scrolled-off-the-top lines.  This way,
+                * no previous line is lost, but we start with a whole
+                * screen to ourself.
+                */
+               for (i = 1; i < sc_height; i++)
+                       putchr('\n');
+       } else
+               line_left();
+#else
+#if MSDOS_COMPILER==WIN32C
+       if (!no_init)
+               win32_init_term();
+#endif
+       initcolor();
+       flush();
+#endif
+       init_done = 1;
+}
+
+/*
+ * Deinitialize terminal
+ */
+       public void
+deinit()
+{
+       if (!init_done)
+               return;
+#if !MSDOS_COMPILER
+       if (!no_keypad)
+               tputs(sc_e_keypad, sc_height, putchr);
+       if (!no_init)
+               tputs(sc_deinit, sc_height, putchr);
+#else
+       /* Restore system colors. */
+       SETCOLORS(sy_fg_color, sy_bg_color);
+#if MSDOS_COMPILER==WIN32C
+       if (!no_init)
+               win32_deinit_term();
+#else
+       /* Need clreol to make SETCOLORS take effect. */
+       clreol();
+#endif
+#endif
+       init_done = 0;
+}
+
+/*
+ * Home cursor (move to upper left corner of screen).
+ */
+       public void
+home()
+{
+#if !MSDOS_COMPILER
+       tputs(sc_home, 1, putchr);
+#else
+       flush();
+       _settextposition(1,1);
+#endif
+}
+
+/*
+ * Add a blank line (called with cursor at home).
+ * Should scroll the display down.
+ */
+       public void
+add_line()
+{
+#if !MSDOS_COMPILER
+       tputs(sc_addline, sc_height, putchr);
+#else
+       flush();
+#if MSDOS_COMPILER==MSOFTC
+       _scrolltextwindow(_GSCROLLDOWN);
+       _settextposition(1,1);
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+       movetext(1,1, sc_width,sc_height-1, 1,2);
+       gotoxy(1,1);
+       clreol();
+#else
+#if MSDOS_COMPILER==WIN32C
+    {
+       CHAR_INFO fillchar;
+       SMALL_RECT rcSrc, rcClip;
+       COORD new_org;
+       CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+       GetConsoleScreenBufferInfo(con_out,&csbi);
+
+       /* The clip rectangle is the entire visible screen. */
+       rcClip.Left = csbi.srWindow.Left;
+       rcClip.Top = csbi.srWindow.Top;
+       rcClip.Right = csbi.srWindow.Right;
+       rcClip.Bottom = csbi.srWindow.Bottom;
+
+       /* The source rectangle is the visible screen minus the last line. */
+       rcSrc = rcClip;
+       rcSrc.Bottom--;
+
+       /* Move the top left corner of the source window down one row. */
+       new_org.X = rcSrc.Left;
+       new_org.Y = rcSrc.Top + 1;
+
+       /* Fill the right character and attributes. */
+       fillchar.Char.AsciiChar = ' ';
+       curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
+       fillchar.Attributes = curr_attr;
+       ScrollConsoleScreenBuffer(con_out, &rcSrc, &rcClip, new_org, &fillchar);
+       _settextposition(1,1);
+    }
+#endif
+#endif
+#endif
+#endif
+}
+
+#if 0
+/*
+ * Remove the n topmost lines and scroll everything below it in the 
+ * window upward.  This is needed to stop leaking the topmost line 
+ * into the scrollback buffer when we go down-one-line (in WIN32).
+ */
+       public void
+remove_top(n)
+       int n;
+{
+#if MSDOS_COMPILER==WIN32C
+       SMALL_RECT rcSrc, rcClip;
+       CHAR_INFO fillchar;
+       COORD new_org;
+       CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
+
+       if (n >= sc_height - 1)
+       {
+               clear();
+               home();
+               return;
+       }
+
+       flush();
+
+       GetConsoleScreenBufferInfo(con_out, &csbi);
+
+       /* Get the extent of all-visible-rows-but-the-last. */
+       rcSrc.Left    = csbi.srWindow.Left;
+       rcSrc.Top     = csbi.srWindow.Top + n;
+       rcSrc.Right   = csbi.srWindow.Right;
+       rcSrc.Bottom  = csbi.srWindow.Bottom;
+
+       /* Get the clip rectangle. */
+       rcClip.Left   = rcSrc.Left;
+       rcClip.Top    = csbi.srWindow.Top;
+       rcClip.Right  = rcSrc.Right;
+       rcClip.Bottom = rcSrc.Bottom ;
+
+       /* Move the source window up n rows. */
+       new_org.X = rcSrc.Left;
+       new_org.Y = rcSrc.Top - n;
+
+       /* Fill the right character and attributes. */
+       fillchar.Char.AsciiChar = ' ';
+       curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
+       fillchar.Attributes = curr_attr;
+
+       ScrollConsoleScreenBuffer(con_out, &rcSrc, &rcClip, new_org, &fillchar);
+
+       /* Position cursor on first blank line. */
+       goto_line(sc_height - n - 1);
+#endif
+}
+#endif
+
+#if MSDOS_COMPILER==WIN32C
+/*
+ * Clear the screen.
+ */
+       static void
+win32_clear()
+{
+       /*
+        * This will clear only the currently visible rows of the NT
+        * console buffer, which means none of the precious scrollback
+        * rows are touched making for faster scrolling.  Note that, if
+        * the window has fewer columns than the console buffer (i.e.
+        * there is a horizontal scrollbar as well), the entire width
+        * of the visible rows will be cleared.
+        */
+       COORD topleft;
+       DWORD nchars;
+       DWORD winsz;
+       CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+       /* get the number of cells in the current buffer */
+       GetConsoleScreenBufferInfo(con_out, &csbi);
+       winsz = csbi.dwSize.X * (csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
+       topleft.X = 0;
+       topleft.Y = csbi.srWindow.Top;
+
+       curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
+       FillConsoleOutputCharacter(con_out, ' ', winsz, topleft, &nchars);
+       FillConsoleOutputAttribute(con_out, curr_attr, winsz, topleft, &nchars);
+}
+
+/*
+ * Remove the n topmost lines and scroll everything below it in the 
+ * window upward.
+ */
+       public void
+win32_scroll_up(n)
+       int n;
+{
+       SMALL_RECT rcSrc, rcClip;
+       CHAR_INFO fillchar;
+       COORD topleft;
+       COORD new_org;
+       DWORD nchars;
+       DWORD size;
+       CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+       if (n <= 0)
+               return;
+
+       if (n >= sc_height - 1)
+       {
+               win32_clear();
+               _settextposition(1,1);
+               return;
+       }
+
+       /* Get the extent of what will remain visible after scrolling. */
+       GetConsoleScreenBufferInfo(con_out, &csbi);
+       rcSrc.Left    = csbi.srWindow.Left;
+       rcSrc.Top     = csbi.srWindow.Top + n;
+       rcSrc.Right   = csbi.srWindow.Right;
+       rcSrc.Bottom  = csbi.srWindow.Bottom;
+
+       /* Get the clip rectangle. */
+       rcClip.Left   = rcSrc.Left;
+       rcClip.Top    = csbi.srWindow.Top;
+       rcClip.Right  = rcSrc.Right;
+       rcClip.Bottom = rcSrc.Bottom ;
+
+       /* Move the source text to the top of the screen. */
+       new_org.X = rcSrc.Left;
+       new_org.Y = rcClip.Top;
+
+       /* Fill the right character and attributes. */
+       fillchar.Char.AsciiChar = ' ';
+       fillchar.Attributes = MAKEATTR(nm_fg_color, nm_bg_color);
+
+       /* Scroll the window. */
+       SetConsoleTextAttribute(con_out, fillchar.Attributes);
+       ScrollConsoleScreenBuffer(con_out, &rcSrc, &rcClip, new_org, &fillchar);
+
+       /* Clear remaining lines at bottom. */
+       topleft.X = csbi.dwCursorPosition.X;
+       topleft.Y = rcSrc.Bottom - n;
+       size = (n * csbi.dwSize.X) + (rcSrc.Right - topleft.X);
+       FillConsoleOutputCharacter(con_out, ' ', size, topleft,
+               &nchars);
+       FillConsoleOutputAttribute(con_out, fillchar.Attributes, size, topleft,
+               &nchars);
+       SetConsoleTextAttribute(con_out, curr_attr);
+
+       /* Move cursor n lines up from where it was. */
+       csbi.dwCursorPosition.Y -= n;
+       SetConsoleCursorPosition(con_out, csbi.dwCursorPosition);
+}
+#endif
+
+/*
+ * Move cursor to lower left corner of screen.
+ */
+       public void
+lower_left()
+{
+#if !MSDOS_COMPILER
+       tputs(sc_lower_left, 1, putchr);
+#else
+       flush();
+       _settextposition(sc_height, 1);
+#endif
+}
+
+/*
+ * Move cursor to left position of current line.
+ */
+       public void
+line_left()
+{
+#if !MSDOS_COMPILER
+       tputs(sc_return, 1, putchr);
+#else
+       int row;
+       flush();
+#if MSDOS_COMPILER==WIN32C
+       {
+               CONSOLE_SCREEN_BUFFER_INFO scr;
+               GetConsoleScreenBufferInfo(con_out, &scr);
+               row = scr.dwCursorPosition.Y - scr.srWindow.Top + 1;
+       }
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+               row = wherey();
+#else
+       {
+               struct rccoord tpos = _gettextposition();
+               row = tpos.row;
+       }
+#endif
+#endif
+       _settextposition(row, 1);
+#endif
+}
+
+/*
+ * Check if the console size has changed and reset internals 
+ * (in lieu of SIGWINCH for WIN32).
+ */
+       public void
+check_winch()
+{
+#if MSDOS_COMPILER==WIN32C
+       CONSOLE_SCREEN_BUFFER_INFO scr;
+       COORD size;
+
+       if (con_out == INVALID_HANDLE_VALUE)
+               return;
+       flush();
+       GetConsoleScreenBufferInfo(con_out, &scr);
+       size.Y = scr.srWindow.Bottom - scr.srWindow.Top + 1;
+       size.X = scr.srWindow.Right - scr.srWindow.Left + 1;
+       if (size.Y != sc_height || size.X != sc_width)
+       {
+               sc_height = size.Y;
+               sc_width = size.X;
+               if (!no_init && con_out_ours == con_out)
+                       SetConsoleScreenBufferSize(con_out, size);
+               pos_init();
+               wscroll = (sc_height + 1) / 2;
+               screen_trashed = 1;
+       }
+#endif
+}
+
+/*
+ * Goto a specific line on the screen.
+ */
+       public void
+goto_line(slinenum)
+       int slinenum;
+{
+#if !MSDOS_COMPILER
+       tputs(tgoto(sc_move, 0, slinenum), 1, putchr);
+#else
+       flush();
+       _settextposition(slinenum+1, 1);
+#endif
+}
+
+#if MSDOS_COMPILER==MSOFTC || MSDOS_COMPILER==BORLANDC
+/*
+ * Create an alternate screen which is all white.
+ * This screen is used to create a "flash" effect, by displaying it
+ * briefly and then switching back to the normal screen.
+ * {{ Yuck!  There must be a better way to get a visual bell. }}
+ */
+       static void
+create_flash()
+{
+#if MSDOS_COMPILER==MSOFTC
+       struct videoconfig w;
+       char *blanks;
+       int row, col;
+       
+       _getvideoconfig(&w);
+       videopages = w.numvideopages;
+       if (videopages < 2)
+       {
+               at_enter(AT_STANDOUT);
+               at_exit();
+       } else
+       {
+               _setactivepage(1);
+               at_enter(AT_STANDOUT);
+               blanks = (char *) ecalloc(w.numtextcols, sizeof(char));
+               for (col = 0;  col < w.numtextcols;  col++)
+                       blanks[col] = ' ';
+               for (row = w.numtextrows;  row > 0;  row--)
+                       _outmem(blanks, w.numtextcols);
+               _setactivepage(0);
+               _setvisualpage(0);
+               free(blanks);
+               at_exit();
+       }
+#else
+#if MSDOS_COMPILER==BORLANDC
+       register int n;
+
+       whitescreen = (unsigned short *) 
+               malloc(sc_width * sc_height * sizeof(short));
+       if (whitescreen == NULL)
+               return;
+       for (n = 0;  n < sc_width * sc_height;  n++)
+               whitescreen[n] = 0x7020;
+#else
+#if MSDOS_COMPILER==WIN32C
+       register int n;
+
+       whitescreen = (WORD *)
+               malloc(sc_height * sc_width * sizeof(WORD));
+       if (whitescreen == NULL)
+               return;
+       /* Invert the standard colors. */
+       for (n = 0;  n < sc_width * sc_height;  n++)
+               whitescreen[n] = (WORD)((nm_fg_color << 4) | nm_bg_color);
+#endif
+#endif
+#endif
+       flash_created = 1;
+}
+#endif /* MSDOS_COMPILER */
+
+/*
+ * Output the "visual bell", if there is one.
+ */
+       public void
+vbell()
+{
+#if !MSDOS_COMPILER
+       if (*sc_visual_bell == '\0')
+               return;
+       tputs(sc_visual_bell, sc_height, putchr);
+#else
+#if MSDOS_COMPILER==DJGPPC
+       ScreenVisualBell();
+#else
+#if MSDOS_COMPILER==MSOFTC
+       /*
+        * Create a flash screen on the second video page.
+        * Switch to that page, then switch back.
+        */
+       if (!flash_created)
+               create_flash();
+       if (videopages < 2)
+               return;
+       _setvisualpage(1);
+       delay(100);
+       _setvisualpage(0);
+#else
+#if MSDOS_COMPILER==BORLANDC
+       unsigned short *currscreen;
+
+       /*
+        * Get a copy of the current screen.
+        * Display the flash screen.
+        * Then restore the old screen.
+        */
+       if (!flash_created)
+               create_flash();
+       if (whitescreen == NULL)
+               return;
+       currscreen = (unsigned short *) 
+               malloc(sc_width * sc_height * sizeof(short));
+       if (currscreen == NULL) return;
+       gettext(1, 1, sc_width, sc_height, currscreen);
+       puttext(1, 1, sc_width, sc_height, whitescreen);
+       delay(100);
+       puttext(1, 1, sc_width, sc_height, currscreen);
+       free(currscreen);
+#else
+#if MSDOS_COMPILER==WIN32C
+       /* paint screen with an inverse color */
+       clear();
+
+       /* leave it displayed for 100 msec. */
+       Sleep(100);
+
+       /* restore with a redraw */
+       repaint();
+#endif
+#endif
+#endif
+#endif
+#endif
+}
+
+/*
+ * Make a noise.
+ */
+       static void
+beep()
+{
+#if !MSDOS_COMPILER
+       putchr(CONTROL('G'));
+#else
+#if MSDOS_COMPILER==WIN32C
+       MessageBeep(0);
+#else
+       write(1, "\7", 1);
+#endif
+#endif
+}
+
+/*
+ * Ring the terminal bell.
+ */
+       public void
+bell()
+{
+       if (quiet == VERY_QUIET)
+               vbell();
+       else
+               beep();
+}
+
+/*
+ * Clear the screen.
+ */
+       public void
+clear()
+{
+#if !MSDOS_COMPILER
+       tputs(sc_clear, sc_height, putchr);
+#else
+       flush();
+#if MSDOS_COMPILER==WIN32C
+       win32_clear();
+#else
+       _clearscreen(_GCLEARSCREEN);
+#endif
+#endif
+}
+
+/*
+ * Clear from the cursor to the end of the cursor's line.
+ * {{ This must not move the cursor. }}
+ */
+       public void
+clear_eol()
+{
+#if !MSDOS_COMPILER
+       tputs(sc_eol_clear, 1, putchr);
+#else
+#if MSDOS_COMPILER==MSOFTC
+       short top, left;
+       short bot, right;
+       struct rccoord tpos;
+       
+       flush();
+       /*
+        * Save current state.
+        */
+       tpos = _gettextposition();
+       _gettextwindow(&top, &left, &bot, &right);
+       /*
+        * Set a temporary window to the current line,
+        * from the cursor's position to the right edge of the screen.
+        * Then clear that window.
+        */
+       _settextwindow(tpos.row, tpos.col, tpos.row, sc_width);
+       _clearscreen(_GWINDOW);
+       /*
+        * Restore state.
+        */
+       _settextwindow(top, left, bot, right);
+       _settextposition(tpos.row, tpos.col);
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+       flush();
+       clreol();
+#else
+#if MSDOS_COMPILER==WIN32C
+       DWORD           nchars;
+       COORD           cpos;
+       CONSOLE_SCREEN_BUFFER_INFO scr;
+
+       flush();
+       memset(&scr, 0, sizeof(scr));
+       GetConsoleScreenBufferInfo(con_out, &scr);
+       cpos.X = scr.dwCursorPosition.X;
+       cpos.Y = scr.dwCursorPosition.Y;
+       curr_attr = MAKEATTR(nm_fg_color, nm_bg_color);
+       FillConsoleOutputAttribute(con_out, curr_attr,
+               scr.dwSize.X - cpos.X, cpos, &nchars);
+       FillConsoleOutputCharacter(con_out, ' ',
+               scr.dwSize.X - cpos.X, cpos, &nchars);
+#endif
+#endif
+#endif
+#endif
+}
+
+/*
+ * Clear the current line.
+ * Clear the screen if there's off-screen memory below the display.
+ */
+       static void
+clear_eol_bot()
+{
+#if MSDOS_COMPILER
+       clear_eol();
+#else
+       if (below_mem)
+               tputs(sc_eos_clear, 1, putchr);
+       else
+               tputs(sc_eol_clear, 1, putchr);
+#endif
+}
+
+/*
+ * Clear the bottom line of the display.
+ * Leave the cursor at the beginning of the bottom line.
+ */
+       public void
+clear_bot()
+{
+       /*
+        * If we're in a non-normal attribute mode, temporarily exit
+        * the mode while we do the clear.  Some terminals fill the
+        * cleared area with the current attribute.
+        */
+       if (oldbot)
+               lower_left();
+       else
+               line_left();
+
+       if (attrmode == AT_NORMAL)
+               clear_eol_bot();
+       else
+       {
+               int saved_attrmode = attrmode;
+
+               at_exit();
+               clear_eol_bot();
+               at_enter(saved_attrmode);
+       }
+}
+
+       public void
+at_enter(attr)
+       int attr;
+{
+       attr = apply_at_specials(attr);
+
+#if !MSDOS_COMPILER
+       /* The one with the most priority is last.  */
+       if (attr & AT_UNDERLINE)
+               tputs(sc_u_in, 1, putchr);
+       if (attr & AT_BOLD)
+               tputs(sc_b_in, 1, putchr);
+       if (attr & AT_BLINK)
+               tputs(sc_bl_in, 1, putchr);
+       if (attr & AT_STANDOUT)
+               tputs(sc_s_in, 1, putchr);
+#else
+       flush();
+       /* The one with the most priority is first.  */
+       if (attr & AT_STANDOUT)
+       {
+               SETCOLORS(so_fg_color, so_bg_color);
+       } else if (attr & AT_BLINK)
+       {
+               SETCOLORS(bl_fg_color, bl_bg_color);
+       }
+       else if (attr & AT_BOLD)
+       {
+               SETCOLORS(bo_fg_color, bo_bg_color);
+       }
+       else if (attr & AT_UNDERLINE)
+       {
+               SETCOLORS(ul_fg_color, ul_bg_color);
+       }
+#endif
+
+       attrmode = attr;
+}
+
+       public void
+at_exit()
+{
+#if !MSDOS_COMPILER
+       /* Undo things in the reverse order we did them.  */
+       if (attrmode & AT_STANDOUT)
+               tputs(sc_s_out, 1, putchr);
+       if (attrmode & AT_BLINK)
+               tputs(sc_bl_out, 1, putchr);
+       if (attrmode & AT_BOLD)
+               tputs(sc_b_out, 1, putchr);
+       if (attrmode & AT_UNDERLINE)
+               tputs(sc_u_out, 1, putchr);
+#else
+       flush();
+       SETCOLORS(nm_fg_color, nm_bg_color);
+#endif
+
+       attrmode = AT_NORMAL;
+}
+
+       public void
+at_switch(attr)
+       int attr;
+{
+       int new_attrmode = apply_at_specials(attr);
+       int ignore_modes = AT_ANSI;
+
+       if ((new_attrmode & ~ignore_modes) != (attrmode & ~ignore_modes))
+       {
+               at_exit();
+               at_enter(attr);
+       }
+}
+
+       public int
+is_at_equiv(attr1, attr2)
+       int attr1;
+       int attr2;
+{
+       attr1 = apply_at_specials(attr1);
+       attr2 = apply_at_specials(attr2);
+
+       return (attr1 == attr2);
+}
+
+       public int
+apply_at_specials(attr)
+       int attr;
+{
+       if (attr & AT_BINARY)
+               attr |= binattr;
+       if (attr & AT_HILITE)
+               attr |= AT_STANDOUT;
+       attr &= ~(AT_BINARY|AT_HILITE);
+
+       return attr;
+}
+
+#if 0 /* No longer used */
+/*
+ * Erase the character to the left of the cursor 
+ * and move the cursor left.
+ */
+       public void
+backspace()
+{
+#if !MSDOS_COMPILER
+       /* 
+        * Erase the previous character by overstriking with a space.
+        */
+       tputs(sc_backspace, 1, putchr);
+       putchr(' ');
+       tputs(sc_backspace, 1, putchr);
+#else
+#if MSDOS_COMPILER==MSOFTC
+       struct rccoord tpos;
+       
+       flush();
+       tpos = _gettextposition();
+       if (tpos.col <= 1)
+               return;
+       _settextposition(tpos.row, tpos.col-1);
+       _outtext(" ");
+       _settextposition(tpos.row, tpos.col-1);
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+       cputs("\b");
+#else
+#if MSDOS_COMPILER==WIN32C
+       COORD cpos;
+       DWORD cChars;
+       CONSOLE_SCREEN_BUFFER_INFO scr;
+
+       flush();
+       GetConsoleScreenBufferInfo(con_out, &scr);
+       cpos = scr.dwCursorPosition;
+       if (cpos.X <= 0)
+               return;
+       cpos.X--;
+       SetConsoleCursorPosition(con_out, cpos);
+       FillConsoleOutputCharacter(con_out, (TCHAR)' ', 1, cpos, &cChars);
+       SetConsoleCursorPosition(con_out, cpos);
+#endif
+#endif
+#endif
+#endif
+}
+#endif /* 0 */
+
+/*
+ * Output a plain backspace, without erasing the previous char.
+ */
+       public void
+putbs()
+{
+#if !MSDOS_COMPILER
+       tputs(sc_backspace, 1, putchr);
+#else
+       int row, col;
+
+       flush();
+       {
+#if MSDOS_COMPILER==MSOFTC
+               struct rccoord tpos;
+               tpos = _gettextposition();
+               row = tpos.row;
+               col = tpos.col;
+#else
+#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC
+               row = wherey();
+               col = wherex();
+#else
+#if MSDOS_COMPILER==WIN32C
+               CONSOLE_SCREEN_BUFFER_INFO scr;
+               GetConsoleScreenBufferInfo(con_out, &scr);
+               row = scr.dwCursorPosition.Y - scr.srWindow.Top + 1;
+               col = scr.dwCursorPosition.X - scr.srWindow.Left + 1;
+#endif
+#endif
+#endif
+       }
+       if (col <= 1)
+               return;
+       _settextposition(row, col-1);
+#endif /* MSDOS_COMPILER */
+}
+
+#if MSDOS_COMPILER==WIN32C
+/*
+ * Determine whether an input character is waiting to be read.
+ */
+       static int
+win32_kbhit(tty)
+       HANDLE tty;
+{
+       INPUT_RECORD ip;
+       DWORD read;
+
+       if (keyCount > 0)
+               return (TRUE);
+
+       currentKey.ascii = 0;
+       currentKey.scan = 0;
+
+       /*
+        * Wait for a real key-down event, but
+        * ignore SHIFT and CONTROL key events.
+        */
+       do
+       {
+               PeekConsoleInput(tty, &ip, 1, &read);
+               if (read == 0)
+                       return (FALSE);
+               ReadConsoleInput(tty, &ip, 1, &read);
+       } while (ip.EventType != KEY_EVENT ||
+               ip.Event.KeyEvent.bKeyDown != TRUE ||
+               ip.Event.KeyEvent.wVirtualScanCode == 0 ||
+               ip.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT ||
+               ip.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL ||
+               ip.Event.KeyEvent.wVirtualKeyCode == VK_MENU);
+               
+       currentKey.ascii = ip.Event.KeyEvent.uChar.AsciiChar;
+       currentKey.scan = ip.Event.KeyEvent.wVirtualScanCode;
+       keyCount = ip.Event.KeyEvent.wRepeatCount;
+
+       if (ip.Event.KeyEvent.dwControlKeyState & 
+               (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
+       {
+               switch (currentKey.scan)
+               {
+               case PCK_ALT_E:     /* letter 'E' */
+                       currentKey.ascii = 0;
+                       break;
+               }
+       } else if (ip.Event.KeyEvent.dwControlKeyState & 
+               (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
+       {
+               switch (currentKey.scan)
+               {
+               case PCK_RIGHT: /* right arrow */
+                       currentKey.scan = PCK_CTL_RIGHT;
+                       break;
+               case PCK_LEFT: /* left arrow */
+                       currentKey.scan = PCK_CTL_LEFT;
+                       break;
+               case PCK_DELETE: /* delete */
+                       currentKey.scan = PCK_CTL_DELETE;
+                       break;
+               }
+       }
+       return (TRUE);
+}
+
+/*
+ * Read a character from the keyboard.
+ */
+       public char
+WIN32getch(tty)
+       int tty;
+{
+       int ascii;
+
+       if (pending_scancode)
+       {
+               pending_scancode = 0;
+               return ((char)(currentKey.scan & 0x00FF));
+       }
+
+       while (win32_kbhit((HANDLE)tty) == FALSE)
+       {
+               Sleep(20);
+               if (ABORT_SIGS())
+                       return ('\003');
+               continue;
+       }
+       keyCount --;
+       ascii = currentKey.ascii;
+       /*
+        * On PC's, the extended keys return a 2 byte sequence beginning 
+        * with '00', so if the ascii code is 00, the next byte will be 
+        * the lsb of the scan code.
+        */
+       pending_scancode = (ascii == 0x00);
+       return ((char)ascii);
+}
+#endif
+
+#if MSDOS_COMPILER
+/*
+ */
+       public void
+WIN32setcolors(fg, bg)
+       int fg;
+       int bg;
+{
+       SETCOLORS(fg, bg);
+}
+
+/*
+ */
+       public void
+WIN32textout(text, len)
+       char *text;
+       int len;
+{
+#if MSDOS_COMPILER==WIN32C
+       DWORD written;
+       WriteConsole(con_out, text, len, &written, NULL);
+#else
+       char c = text[len];
+       text[len] = '\0';
+       cputs(text);
+       text[len] = c;
+#endif
+}
+#endif
diff --git a/thirdparty/less/scrsize.c b/thirdparty/less/scrsize.c
new file mode 100644 (file)
index 0000000..05d041e
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+/*
+ * This program is used to determine the screen dimensions on OS/2 systems.
+ * Adapted from code written by Kyosuke Tokoro (NBG01720@nifty.ne.jp).
+ */
+
+/*
+ * When I wrote this routine, I consulted some part of the source code 
+ * of the xwininfo utility by X Consortium.
+ *
+ * Copyright (c) 1987, X Consortium
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the X Consortium shall not
+ * be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the X
+ * Consortium.
+ */
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+static int get_winsize(dpy, window, p_width, p_height)
+       Display *dpy;
+       Window window;
+       int *p_width;
+       int *p_height;
+{
+       XWindowAttributes win_attributes;
+       XSizeHints hints;
+       long longjunk;
+
+       if (!XGetWindowAttributes(dpy, window, &win_attributes))
+               return 1;
+       if (!XGetWMNormalHints(dpy, window, &hints, &longjunk))
+               return 1;
+       if (!(hints.flags & PResizeInc))
+               return 1;
+       if (hints.width_inc == 0 || hints.height_inc == 0)
+               return 1;
+       if (!(hints.flags & (PBaseSize|PMinSize)))
+               return 1;
+       if (hints.flags & PBaseSize)
+       {
+               win_attributes.width -= hints.base_width;
+               win_attributes.height -= hints.base_height;
+       } else
+       {
+               win_attributes.width -= hints.min_width;
+               win_attributes.height -= hints.min_height;
+       }
+       *p_width = win_attributes.width / hints.width_inc;
+       *p_height = win_attributes.height / hints.height_inc;
+       return 0;
+}
+
+int main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       char *cp;
+       Display *dpy;
+       int size[2];
+
+       _scrsize(size);
+       cp = getenv("WINDOWID");
+       if (cp != NULL)
+       {
+               dpy = XOpenDisplay(NULL);
+               if (dpy != NULL)
+               {
+                       get_winsize(dpy, (Window) atol(cp), &size[0], &size[1]);
+                       XCloseDisplay(dpy);
+               }
+       }
+       printf("%i %i\n", size[0], size[1]);
+       return (0);
+}
diff --git a/thirdparty/less/search.c b/thirdparty/less/search.c
new file mode 100644 (file)
index 0000000..143779e
--- /dev/null
@@ -0,0 +1,1211 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines to search a file for a pattern.
+ */
+
+#include "less.h"
+#include "pattern.h"
+#include "position.h"
+#include "charset.h"
+
+#define        MINPOS(a,b)     (((a) < (b)) ? (a) : (b))
+#define        MAXPOS(a,b)     (((a) > (b)) ? (a) : (b))
+
+extern int sigs;
+extern int how_search;
+extern int caseless;
+extern int linenums;
+extern int sc_height;
+extern int jump_sline;
+extern int bs_mode;
+extern int ctldisp;
+extern int status_col;
+extern void * constant ml_search;
+extern POSITION start_attnpos;
+extern POSITION end_attnpos;
+extern int utf_mode;
+extern int screen_trashed;
+#if HILITE_SEARCH
+extern int hilite_search;
+extern int size_linebuf;
+extern int squished;
+extern int can_goto_line;
+static int hide_hilite;
+static POSITION prep_startpos;
+static POSITION prep_endpos;
+static int is_caseless;
+static int is_ucase_pattern;
+
+struct hilite
+{
+       struct hilite *hl_next;
+       POSITION hl_startpos;
+       POSITION hl_endpos;
+};
+static struct hilite hilite_anchor = { NULL, NULL_POSITION, NULL_POSITION };
+static struct hilite filter_anchor = { NULL, NULL_POSITION, NULL_POSITION };
+#define        hl_first        hl_next
+#endif
+
+/*
+ * These are the static variables that represent the "remembered"
+ * search pattern and filter pattern.
+ */
+struct pattern_info {
+       DEFINE_PATTERN(compiled);
+       char* text;
+       int search_type;
+};
+       
+static struct pattern_info search_info;
+static struct pattern_info filter_info;
+
+/*
+ * Are there any uppercase letters in this string?
+ */
+       static int
+is_ucase(str)
+       char *str;
+{
+       char *str_end = str + strlen(str);
+       LWCHAR ch;
+
+       while (str < str_end)
+       {
+               ch = step_char(&str, +1, str_end);
+               if (IS_UPPER(ch))
+                       return (1);
+       }
+       return (0);
+}
+
+/*
+ * Compile and save a search pattern.
+ */
+       static int
+set_pattern(info, pattern, search_type)
+       struct pattern_info *info;
+       char *pattern;
+       int search_type;
+{
+       if (pattern == NULL)
+               CLEAR_PATTERN(search_info.compiled);
+       else if (compile_pattern(pattern, search_type, &info->compiled) < 0)
+               return -1;
+       /* Pattern compiled successfully; save the text too. */
+       if (info->text != NULL)
+               free(info->text);
+       info->text = NULL;
+       if (pattern != NULL)
+       {
+               info->text = (char *) ecalloc(1, strlen(pattern)+1);
+               strcpy(info->text, pattern);
+       }
+       info->search_type = search_type;
+
+       /*
+        * Ignore case if -I is set OR
+        * -i is set AND the pattern is all lowercase.
+        */
+       is_ucase_pattern = is_ucase(pattern);
+       if (is_ucase_pattern && caseless != OPT_ONPLUS)
+               is_caseless = 0;
+       else
+               is_caseless = caseless;
+       return 0;
+}
+
+/*
+ * Discard a saved pattern.
+ */
+       static void
+clear_pattern(info)
+       struct pattern_info *info;
+{
+       if (info->text != NULL)
+               free(info->text);
+       info->text = NULL;
+       uncompile_pattern(&info->compiled);
+}
+
+/*
+ * Initialize saved pattern to nothing.
+ */
+       static void
+init_pattern(info)
+       struct pattern_info *info;
+{
+       CLEAR_PATTERN(info->compiled);
+       info->text = NULL;
+       info->search_type = 0;
+}
+
+/*
+ * Initialize search variables.
+ */
+       public void
+init_search()
+{
+       init_pattern(&search_info);
+       init_pattern(&filter_info);
+}
+
+/*
+ * Determine which text conversions to perform before pattern matching.
+ */
+       static int
+get_cvt_ops()
+{
+       int ops = 0;
+       if (is_caseless || bs_mode == BS_SPECIAL)
+       {
+               if (is_caseless) 
+                       ops |= CVT_TO_LC;
+               if (bs_mode == BS_SPECIAL)
+                       ops |= CVT_BS;
+               if (bs_mode != BS_CONTROL)
+                       ops |= CVT_CRLF;
+       } else if (bs_mode != BS_CONTROL)
+       {
+               ops |= CVT_CRLF;
+       }
+       if (ctldisp == OPT_ONPLUS)
+               ops |= CVT_ANSI;
+       return (ops);
+}
+
+/*
+ * Is there a previous (remembered) search pattern?
+ */
+       static int
+prev_pattern(info)
+       struct pattern_info *info;
+{
+       if (info->search_type & SRCH_NO_REGEX)
+               return (info->text != NULL);
+       return (!is_null_pattern(info->compiled));
+}
+
+#if HILITE_SEARCH
+/*
+ * Repaint the hilites currently displayed on the screen.
+ * Repaint each line which contains highlighted text.
+ * If on==0, force all hilites off.
+ */
+       public void
+repaint_hilite(on)
+       int on;
+{
+       int slinenum;
+       POSITION pos;
+       POSITION epos;
+       int save_hide_hilite;
+
+       if (squished)
+               repaint();
+
+       save_hide_hilite = hide_hilite;
+       if (!on)
+       {
+               if (hide_hilite)
+                       return;
+               hide_hilite = 1;
+       }
+
+       if (!can_goto_line)
+       {
+               repaint();
+               hide_hilite = save_hide_hilite;
+               return;
+       }
+
+       for (slinenum = TOP;  slinenum < TOP + sc_height-1;  slinenum++)
+       {
+               pos = position(slinenum);
+               if (pos == NULL_POSITION)
+                       continue;
+               epos = position(slinenum+1);
+               (void) forw_line(pos);
+               goto_line(slinenum);
+               put_line();
+       }
+       lower_left();
+       hide_hilite = save_hide_hilite;
+}
+
+/*
+ * Clear the attn hilite.
+ */
+       public void
+clear_attn()
+{
+       int slinenum;
+       POSITION old_start_attnpos;
+       POSITION old_end_attnpos;
+       POSITION pos;
+       POSITION epos;
+       int moved = 0;
+
+       if (start_attnpos == NULL_POSITION)
+               return;
+       old_start_attnpos = start_attnpos;
+       old_end_attnpos = end_attnpos;
+       start_attnpos = end_attnpos = NULL_POSITION;
+
+       if (!can_goto_line)
+       {
+               repaint();
+               return;
+       }
+       if (squished)
+               repaint();
+
+       for (slinenum = TOP;  slinenum < TOP + sc_height-1;  slinenum++)
+       {
+               pos = position(slinenum);
+               if (pos == NULL_POSITION)
+                       continue;
+               epos = position(slinenum+1);
+               if (pos < old_end_attnpos &&
+                    (epos == NULL_POSITION || epos > old_start_attnpos))
+               {
+                       (void) forw_line(pos);
+                       goto_line(slinenum);
+                       put_line();
+                       moved = 1;
+               }
+       }
+       if (moved)
+               lower_left();
+}
+#endif
+
+/*
+ * Hide search string highlighting.
+ */
+       public void
+undo_search()
+{
+       if (!prev_pattern(&search_info))
+       {
+               error("No previous regular expression", NULL_PARG);
+               return;
+       }
+#if HILITE_SEARCH
+       hide_hilite = !hide_hilite;
+       repaint_hilite(1);
+#endif
+}
+
+#if HILITE_SEARCH
+/*
+ * Clear the hilite list.
+ */
+       public void
+clr_hlist(anchor)
+       struct hilite *anchor;
+{
+       struct hilite *hl;
+       struct hilite *nexthl;
+
+       for (hl = anchor->hl_first;  hl != NULL;  hl = nexthl)
+       {
+               nexthl = hl->hl_next;
+               free((void*)hl);
+       }
+       anchor->hl_first = NULL;
+       prep_startpos = prep_endpos = NULL_POSITION;
+}
+
+       public void
+clr_hilite()
+{
+       clr_hlist(&hilite_anchor);
+}
+
+       public void
+clr_filter()
+{
+       clr_hlist(&filter_anchor);
+}
+
+/*
+ * Should any characters in a specified range be highlighted?
+ */
+       static int
+is_hilited_range(pos, epos)
+       POSITION pos;
+       POSITION epos;
+{
+       struct hilite *hl;
+
+       /*
+        * Look at each highlight and see if any part of it falls in the range.
+        */
+       for (hl = hilite_anchor.hl_first;  hl != NULL;  hl = hl->hl_next)
+       {
+               if (hl->hl_endpos > pos &&
+                   (epos == NULL_POSITION || epos > hl->hl_startpos))
+                       return (1);
+       }
+       return (0);
+}
+
+/* 
+ * Is a line "filtered" -- that is, should it be hidden?
+ */
+       public int
+is_filtered(pos)
+       POSITION pos;
+{
+       struct hilite *hl;
+
+       if (ch_getflags() & CH_HELPFILE)
+               return (0);
+
+       /*
+        * Look at each filter and see if the start position
+        * equals the start position of the line.
+        */
+       for (hl = filter_anchor.hl_first;  hl != NULL;  hl = hl->hl_next)
+       {
+               if (hl->hl_startpos == pos)
+                       return (1);
+       }
+       return (0);
+}
+
+/*
+ * Should any characters in a specified range be highlighted?
+ * If nohide is nonzero, don't consider hide_hilite.
+ */
+       public int
+is_hilited(pos, epos, nohide, p_matches)
+       POSITION pos;
+       POSITION epos;
+       int nohide;
+       int *p_matches;
+{
+       int match;
+
+       if (p_matches != NULL)
+               *p_matches = 0;
+
+       if (!status_col &&
+           start_attnpos != NULL_POSITION && 
+           pos < end_attnpos &&
+            (epos == NULL_POSITION || epos > start_attnpos))
+               /*
+                * The attn line overlaps this range.
+                */
+               return (1);
+
+       match = is_hilited_range(pos, epos);
+       if (!match)
+               return (0);
+
+       if (p_matches != NULL)
+               /*
+                * Report matches, even if we're hiding highlights.
+                */
+               *p_matches = 1;
+
+       if (hilite_search == 0)
+               /*
+                * Not doing highlighting.
+                */
+               return (0);
+
+       if (!nohide && hide_hilite)
+               /*
+                * Highlighting is hidden.
+                */
+               return (0);
+
+       return (1);
+}
+
+/*
+ * Add a new hilite to a hilite list.
+ */
+       static void
+add_hilite(anchor, hl)
+       struct hilite *anchor;
+       struct hilite *hl;
+{
+       struct hilite *ihl;
+
+       /*
+        * Hilites are sorted in the list; find where new one belongs.
+        * Insert new one after ihl.
+        */
+       for (ihl = anchor;  ihl->hl_next != NULL;  ihl = ihl->hl_next)
+       {
+               if (ihl->hl_next->hl_startpos > hl->hl_startpos)
+                       break;
+       }
+
+       /*
+        * Truncate hilite so it doesn't overlap any existing ones
+        * above and below it.
+        */
+       if (ihl != anchor)
+               hl->hl_startpos = MAXPOS(hl->hl_startpos, ihl->hl_endpos);
+       if (ihl->hl_next != NULL)
+               hl->hl_endpos = MINPOS(hl->hl_endpos, ihl->hl_next->hl_startpos);
+       if (hl->hl_startpos >= hl->hl_endpos)
+       {
+               /*
+                * Hilite was truncated out of existence.
+                */
+               free(hl);
+               return;
+       }
+       hl->hl_next = ihl->hl_next;
+       ihl->hl_next = hl;
+}
+
+/*
+ * Make a hilite for each string in a physical line which matches 
+ * the current pattern.
+ * sp,ep delimit the first match already found.
+ */
+       static void
+hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
+       POSITION linepos;
+       char *line;
+       int line_len;
+       int *chpos;
+       char *sp;
+       char *ep;
+       int cvt_ops;
+{
+       char *searchp;
+       char *line_end = line + line_len;
+       struct hilite *hl;
+
+       if (sp == NULL || ep == NULL)
+               return;
+       /*
+        * sp and ep delimit the first match in the line.
+        * Mark the corresponding file positions, then
+        * look for further matches and mark them.
+        * {{ This technique, of calling match_pattern on subsequent
+        *    substrings of the line, may mark more than is correct
+        *    if the pattern starts with "^".  This bug is fixed
+        *    for those regex functions that accept a notbol parameter
+        *    (currently POSIX, PCRE and V8-with-regexec2). }}
+        */
+       searchp = line;
+       do {
+               if (ep > sp)
+               {
+                       hl = (struct hilite *) ecalloc(1, sizeof(struct hilite));
+                       hl->hl_startpos = linepos + chpos[sp-line];
+                       hl->hl_endpos = linepos + chpos[ep-line];
+                       add_hilite(&hilite_anchor, hl);
+               }
+               /*
+                * If we matched more than zero characters,
+                * move to the first char after the string we matched.
+                * If we matched zero, just move to the next char.
+                */
+               if (ep > searchp)
+                       searchp = ep;
+               else if (searchp != line_end)
+                       searchp++;
+               else /* end of line */
+                       break;
+       } while (match_pattern(search_info.compiled, search_info.text,
+                       searchp, line_end - searchp, &sp, &ep, 1, search_info.search_type));
+}
+#endif
+
+/*
+ * Change the caseless-ness of searches.  
+ * Updates the internal search state to reflect a change in the -i flag.
+ */
+       public void
+chg_caseless()
+{
+       if (!is_ucase_pattern)
+               /*
+                * Pattern did not have uppercase.
+                * Just set the search caselessness to the global caselessness.
+                */
+               is_caseless = caseless;
+       else
+               /*
+                * Pattern did have uppercase.
+                * Discard the pattern; we can't change search caselessness now.
+                */
+               clear_pattern(&search_info);
+}
+
+#if HILITE_SEARCH
+/*
+ * Find matching text which is currently on screen and highlight it.
+ */
+       static void
+hilite_screen()
+{
+       struct scrpos scrpos;
+
+       get_scrpos(&scrpos);
+       if (scrpos.pos == NULL_POSITION)
+               return;
+       prep_hilite(scrpos.pos, position(BOTTOM_PLUS_ONE), -1);
+       repaint_hilite(1);
+}
+
+/*
+ * Change highlighting parameters.
+ */
+       public void
+chg_hilite()
+{
+       /*
+        * Erase any highlights currently on screen.
+        */
+       clr_hilite();
+       hide_hilite = 0;
+
+       if (hilite_search == OPT_ONPLUS)
+               /*
+                * Display highlights.
+                */
+               hilite_screen();
+}
+#endif
+
+/*
+ * Figure out where to start a search.
+ */
+       static POSITION
+search_pos(search_type)
+       int search_type;
+{
+       POSITION pos;
+       int linenum;
+
+       if (empty_screen())
+       {
+               /*
+                * Start at the beginning (or end) of the file.
+                * The empty_screen() case is mainly for 
+                * command line initiated searches;
+                * for example, "+/xyz" on the command line.
+                * Also for multi-file (SRCH_PAST_EOF) searches.
+                */
+               if (search_type & SRCH_FORW)
+               {
+                       pos = ch_zero();
+               } else
+               {
+                       pos = ch_length();
+                       if (pos == NULL_POSITION)
+                       {
+                               (void) ch_end_seek();
+                               pos = ch_length();
+                       }
+               }
+               linenum = 0;
+       } else 
+       {
+               int add_one = 0;
+
+               if (how_search == OPT_ON)
+               {
+                       /*
+                        * Search does not include current screen.
+                        */
+                       if (search_type & SRCH_FORW)
+                               linenum = BOTTOM_PLUS_ONE;
+                       else
+                               linenum = TOP;
+               } else if (how_search == OPT_ONPLUS && !(search_type & SRCH_AFTER_TARGET))
+               {
+                       /*
+                        * Search includes all of displayed screen.
+                        */
+                       if (search_type & SRCH_FORW)
+                               linenum = TOP;
+                       else
+                               linenum = BOTTOM_PLUS_ONE;
+               } else 
+               {
+                       /*
+                        * Search includes the part of current screen beyond the jump target.
+                        * It starts at the jump target (if searching backwards),
+                        * or at the jump target plus one (if forwards).
+                        */
+                       linenum = jump_sline;
+                       if (search_type & SRCH_FORW) 
+                           add_one = 1;
+               }
+               linenum = adjsline(linenum);
+               pos = position(linenum);
+               if (add_one)
+                       pos = forw_raw_line(pos, (char **)NULL, (int *)NULL);
+       }
+
+       /*
+        * If the line is empty, look around for a plausible starting place.
+        */
+       if (search_type & SRCH_FORW) 
+       {
+           while (pos == NULL_POSITION)
+           {
+               if (++linenum >= sc_height)
+                   break;
+               pos = position(linenum);
+           }
+       } else 
+       {
+           while (pos == NULL_POSITION)
+           {
+               if (--linenum < 0)
+                   break;
+               pos = position(linenum);
+           }
+       }
+       return (pos);
+}
+
+/*
+ * Search a subset of the file, specified by start/end position.
+ */
+       static int
+search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos)
+       POSITION pos;
+       POSITION endpos;
+       int search_type;
+       int matches;
+       int maxlines;
+       POSITION *plinepos;
+       POSITION *pendpos;
+{
+       char *line;
+       char *cline;
+       int line_len;
+       LINENUM linenum;
+       char *sp, *ep;
+       int line_match;
+       int cvt_ops;
+       int cvt_len;
+       int *chpos;
+       POSITION linepos, oldpos;
+
+       linenum = find_linenum(pos);
+       oldpos = pos;
+       for (;;)
+       {
+               /*
+                * Get lines until we find a matching one or until
+                * we hit end-of-file (or beginning-of-file if we're 
+                * going backwards), or until we hit the end position.
+                */
+               if (ABORT_SIGS())
+               {
+                       /*
+                        * A signal aborts the search.
+                        */
+                       return (-1);
+               }
+
+               if ((endpos != NULL_POSITION && pos >= endpos) || maxlines == 0)
+               {
+                       /*
+                        * Reached end position without a match.
+                        */
+                       if (pendpos != NULL)
+                               *pendpos = pos;
+                       return (matches);
+               }
+               if (maxlines > 0)
+                       maxlines--;
+
+               if (search_type & SRCH_FORW)
+               {
+                       /*
+                        * Read the next line, and save the 
+                        * starting position of that line in linepos.
+                        */
+                       linepos = pos;
+                       pos = forw_raw_line(pos, &line, &line_len);
+                       if (linenum != 0)
+                               linenum++;
+               } else
+               {
+                       /*
+                        * Read the previous line and save the
+                        * starting position of that line in linepos.
+                        */
+                       pos = back_raw_line(pos, &line, &line_len);
+                       linepos = pos;
+                       if (linenum != 0)
+                               linenum--;
+               }
+
+               if (pos == NULL_POSITION)
+               {
+                       /*
+                        * Reached EOF/BOF without a match.
+                        */
+                       if (pendpos != NULL)
+                               *pendpos = oldpos;
+                       return (matches);
+               }
+
+               /*
+                * If we're using line numbers, we might as well
+                * remember the information we have now (the position
+                * and line number of the current line).
+                * Don't do it for every line because it slows down
+                * the search.  Remember the line number only if
+                * we're "far" from the last place we remembered it.
+                */
+               if (linenums && abs((int)(pos - oldpos)) > 2048)
+                       add_lnum(linenum, pos);
+               oldpos = pos;
+
+               if (is_filtered(linepos))
+                       continue;
+
+               /*
+                * If it's a caseless search, convert the line to lowercase.
+                * If we're doing backspace processing, delete backspaces.
+                */
+               cvt_ops = get_cvt_ops();
+               cvt_len = cvt_length(line_len, cvt_ops);
+               cline = (char *) ecalloc(1, cvt_len);
+               chpos = cvt_alloc_chpos(cvt_len);
+               cvt_text(cline, line, chpos, &line_len, cvt_ops);
+
+#if HILITE_SEARCH
+               /*
+                * Check to see if the line matches the filter pattern.
+                * If so, add an entry to the filter list.
+                */
+               if ((search_type & SRCH_FIND_ALL) && prev_pattern(&filter_info)) {
+                       int line_filter = match_pattern(filter_info.compiled, filter_info.text,
+                               cline, line_len, &sp, &ep, 0, filter_info.search_type);
+                       if (line_filter)
+                       {
+                               struct hilite *hl = (struct hilite *)
+                                       ecalloc(1, sizeof(struct hilite));
+                               hl->hl_startpos = linepos;
+                               hl->hl_endpos = pos;
+                               add_hilite(&filter_anchor, hl);
+                       }
+               }
+#endif
+
+               /*
+                * Test the next line to see if we have a match.
+                * We are successful if we either want a match and got one,
+                * or if we want a non-match and got one.
+                */
+               if (prev_pattern(&search_info))
+               {
+                       line_match = match_pattern(search_info.compiled, search_info.text,
+                               cline, line_len, &sp, &ep, 0, search_type);
+                       if (line_match)
+                       {
+                               /*
+                                * Got a match.
+                                */
+                               if (search_type & SRCH_FIND_ALL)
+                               {
+#if HILITE_SEARCH
+                                       /*
+                                        * We are supposed to find all matches in the range.
+                                        * Just add the matches in this line to the 
+                                        * hilite list and keep searching.
+                                        */
+                                       hilite_line(linepos, cline, line_len, chpos, sp, ep, cvt_ops);
+#endif
+                               } else if (--matches <= 0)
+                               {
+                                       /*
+                                        * Found the one match we're looking for.
+                                        * Return it.
+                                        */
+#if HILITE_SEARCH
+                                       if (hilite_search == OPT_ON)
+                                       {
+                                               /*
+                                                * Clear the hilite list and add only
+                                                * the matches in this one line.
+                                                */
+                                               clr_hilite();
+                                               hilite_line(linepos, cline, line_len, chpos, sp, ep, cvt_ops);
+                                       }
+#endif
+                                       free(cline);
+                                       free(chpos);
+                                       if (plinepos != NULL)
+                                               *plinepos = linepos;
+                                       return (0);
+                               }
+                       }
+               }
+               free(cline);
+               free(chpos);
+       }
+}
+
+/*
+ * search for a pattern in history. If found, compile that pattern.
+ */
+       static int 
+hist_pattern(search_type) 
+       int search_type;
+{
+#if CMD_HISTORY
+       char *pattern;
+
+       set_mlist(ml_search, 0);
+       pattern = cmd_lastpattern();
+       if (pattern == NULL)
+               return (0);
+
+       if (set_pattern(&search_info, pattern, search_type) < 0)
+               return (0);
+
+#if HILITE_SEARCH
+       if (hilite_search == OPT_ONPLUS && !hide_hilite)
+               hilite_screen();
+#endif
+
+       return (1);
+#else /* CMD_HISTORY */
+       return (0);
+#endif /* CMD_HISTORY */
+}
+
+/*
+ * Search for the n-th occurrence of a specified pattern, 
+ * either forward or backward.
+ * Return the number of matches not yet found in this file
+ * (that is, n minus the number of matches found).
+ * Return -1 if the search should be aborted.
+ * Caller may continue the search in another file 
+ * if less than n matches are found in this file.
+ */
+       public int
+search(search_type, pattern, n)
+       int search_type;
+       char *pattern;
+       int n;
+{
+       POSITION pos;
+
+       if (pattern == NULL || *pattern == '\0')
+       {
+               /*
+                * A null pattern means use the previously compiled pattern.
+                */
+               search_type |= SRCH_AFTER_TARGET;
+               if (!prev_pattern(&search_info) && !hist_pattern(search_type))
+               {
+                       error("No previous regular expression", NULL_PARG);
+                       return (-1);
+               }
+               if ((search_type & SRCH_NO_REGEX) != 
+                     (search_info.search_type & SRCH_NO_REGEX))
+               {
+                       error("Please re-enter search pattern", NULL_PARG);
+                       return -1;
+               }
+#if HILITE_SEARCH
+               if (hilite_search == OPT_ON)
+               {
+                       /*
+                        * Erase the highlights currently on screen.
+                        * If the search fails, we'll redisplay them later.
+                        */
+                       repaint_hilite(0);
+               }
+               if (hilite_search == OPT_ONPLUS && hide_hilite)
+               {
+                       /*
+                        * Highlight any matches currently on screen,
+                        * before we actually start the search.
+                        */
+                       hide_hilite = 0;
+                       hilite_screen();
+               }
+               hide_hilite = 0;
+#endif
+       } else
+       {
+               /*
+                * Compile the pattern.
+                */
+               if (set_pattern(&search_info, pattern, search_type) < 0)
+                       return (-1);
+#if HILITE_SEARCH
+               if (hilite_search)
+               {
+                       /*
+                        * Erase the highlights currently on screen.
+                        * Also permanently delete them from the hilite list.
+                        */
+                       repaint_hilite(0);
+                       hide_hilite = 0;
+                       clr_hilite();
+               }
+               if (hilite_search == OPT_ONPLUS)
+               {
+                       /*
+                        * Highlight any matches currently on screen,
+                        * before we actually start the search.
+                        */
+                       hilite_screen();
+               }
+#endif
+       }
+
+       /*
+        * Figure out where to start the search.
+        */
+       pos = search_pos(search_type);
+       if (pos == NULL_POSITION)
+       {
+               /*
+                * Can't find anyplace to start searching from.
+                */
+               if (search_type & SRCH_PAST_EOF)
+                       return (n);
+               /* repaint(); -- why was this here? */
+               error("Nothing to search", NULL_PARG);
+               return (-1);
+       }
+
+       n = search_range(pos, NULL_POSITION, search_type, n, -1,
+                       &pos, (POSITION*)NULL);
+       if (n != 0)
+       {
+               /*
+                * Search was unsuccessful.
+                */
+#if HILITE_SEARCH
+               if (hilite_search == OPT_ON && n > 0)
+                       /*
+                        * Redisplay old hilites.
+                        */
+                       repaint_hilite(1);
+#endif
+               return (n);
+       }
+
+       if (!(search_type & SRCH_NO_MOVE))
+       {
+               /*
+                * Go to the matching line.
+                */
+               jump_loc(pos, jump_sline);
+       }
+
+#if HILITE_SEARCH
+       if (hilite_search == OPT_ON)
+               /*
+                * Display new hilites in the matching line.
+                */
+               repaint_hilite(1);
+#endif
+       return (0);
+}
+
+
+#if HILITE_SEARCH
+/*
+ * Prepare hilites in a given range of the file.
+ *
+ * The pair (prep_startpos,prep_endpos) delimits a contiguous region
+ * of the file that has been "prepared"; that is, scanned for matches for
+ * the current search pattern, and hilites have been created for such matches.
+ * If prep_startpos == NULL_POSITION, the prep region is empty.
+ * If prep_endpos == NULL_POSITION, the prep region extends to EOF.
+ * prep_hilite asks that the range (spos,epos) be covered by the prep region.
+ */
+       public void
+prep_hilite(spos, epos, maxlines)
+       POSITION spos;
+       POSITION epos;
+       int maxlines;
+{
+       POSITION nprep_startpos = prep_startpos;
+       POSITION nprep_endpos = prep_endpos;
+       POSITION new_epos;
+       POSITION max_epos;
+       int result;
+       int i;
+
+/*
+ * Search beyond where we're asked to search, so the prep region covers
+ * more than we need.  Do one big search instead of a bunch of small ones.
+ */
+#define        SEARCH_MORE (3*size_linebuf)
+
+       if (!prev_pattern(&search_info) && !is_filtering())
+               return;
+
+       /*
+        * If we're limited to a max number of lines, figure out the
+        * file position we should stop at.
+        */
+       if (maxlines < 0)
+               max_epos = NULL_POSITION;
+       else
+       {
+               max_epos = spos;
+               for (i = 0;  i < maxlines;  i++)
+                       max_epos = forw_raw_line(max_epos, (char **)NULL, (int *)NULL);
+       }
+
+       /*
+        * Find two ranges:
+        * The range that we need to search (spos,epos); and the range that
+        * the "prep" region will then cover (nprep_startpos,nprep_endpos).
+        */
+
+       if (prep_startpos == NULL_POSITION ||
+           (epos != NULL_POSITION && epos < prep_startpos) ||
+           spos > prep_endpos)
+       {
+               /*
+                * New range is not contiguous with old prep region.
+                * Discard the old prep region and start a new one.
+                */
+               clr_hilite();
+               clr_filter();
+               if (epos != NULL_POSITION)
+                       epos += SEARCH_MORE;
+               nprep_startpos = spos;
+       } else
+       {
+               /*
+                * New range partially or completely overlaps old prep region.
+                */
+               if (epos == NULL_POSITION)
+               {
+                       /*
+                        * New range goes to end of file.
+                        */
+                       ;
+               } else if (epos > prep_endpos)
+               {
+                       /*
+                        * New range ends after old prep region.
+                        * Extend prep region to end at end of new range.
+                        */
+                       epos += SEARCH_MORE;
+               } else /* (epos <= prep_endpos) */
+               {
+                       /*
+                        * New range ends within old prep region.
+                        * Truncate search to end at start of old prep region.
+                        */
+                       epos = prep_startpos;
+               }
+
+               if (spos < prep_startpos)
+               {
+                       /*
+                        * New range starts before old prep region.
+                        * Extend old prep region backwards to start at 
+                        * start of new range.
+                        */
+                       if (spos < SEARCH_MORE)
+                               spos = 0;
+                       else
+                               spos -= SEARCH_MORE;
+                       nprep_startpos = spos;
+               } else /* (spos >= prep_startpos) */
+               {
+                       /*
+                        * New range starts within or after old prep region.
+                        * Trim search to start at end of old prep region.
+                        */
+                       spos = prep_endpos;
+               }
+       }
+
+       if (epos != NULL_POSITION && max_epos != NULL_POSITION &&
+           epos > max_epos)
+               /*
+                * Don't go past the max position we're allowed.
+                */
+               epos = max_epos;
+
+       if (epos == NULL_POSITION || epos > spos)
+       {
+               int search_type = SRCH_FORW | SRCH_FIND_ALL;
+               search_type |= (search_info.search_type & SRCH_NO_REGEX);
+               result = search_range(spos, epos, search_type, 0,
+                               maxlines, (POSITION*)NULL, &new_epos);
+               if (result < 0)
+                       return;
+               if (prep_endpos == NULL_POSITION || new_epos > prep_endpos)
+                       nprep_endpos = new_epos;
+       }
+       prep_startpos = nprep_startpos;
+       prep_endpos = nprep_endpos;
+}
+
+/*
+ * Set the pattern to be used for line filtering.
+ */
+       public void
+set_filter_pattern(pattern, search_type)
+       char *pattern;
+       int search_type;
+{
+       clr_filter();
+       if (pattern == NULL || *pattern == '\0')
+               clear_pattern(&filter_info);
+       else
+               set_pattern(&filter_info, pattern, search_type);
+       screen_trashed = 1;
+}
+
+/*
+ * Is there a line filter in effect?
+ */
+       public int
+is_filtering()
+{
+       if (ch_getflags() & CH_HELPFILE)
+               return (0);
+       return prev_pattern(&filter_info);
+}
+#endif
+
+#if HAVE_V8_REGCOMP
+/*
+ * This function is called by the V8 regcomp to report 
+ * errors in regular expressions.
+ */
+       void 
+regerror(s) 
+       char *s; 
+{
+       PARG parg;
+
+       parg.p_string = s;
+       error("%s", &parg);
+}
+#endif
+
diff --git a/thirdparty/less/signal.c b/thirdparty/less/signal.c
new file mode 100644 (file)
index 0000000..0fbaf7e
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines dealing with signals.
+ *
+ * A signal usually merely causes a bit to be set in the "signals" word.
+ * At some convenient time, the mainline code checks to see if any
+ * signals need processing by calling psignal().
+ * If we happen to be reading from a file [in iread()] at the time
+ * the signal is received, we call intread to interrupt the iread.
+ */
+
+#include "less.h"
+#include <signal.h>
+
+/*
+ * "sigs" contains bits indicating signals which need to be processed.
+ */
+public int sigs;
+
+extern int sc_width, sc_height;
+extern int screen_trashed;
+extern int lnloop;
+extern int linenums;
+extern int wscroll;
+extern int reading;
+extern int quit_on_intr;
+extern long jump_sline_fraction;
+
+/*
+ * Interrupt signal handler.
+ */
+       /* ARGSUSED*/
+       static RETSIGTYPE
+u_interrupt(type)
+       int type;
+{
+       bell();
+#if OS2
+       LSIGNAL(SIGINT, SIG_ACK);
+#endif
+       LSIGNAL(SIGINT, u_interrupt);
+       sigs |= S_INTERRUPT;
+#if MSDOS_COMPILER==DJGPPC
+       /*
+        * If a keyboard has been hit, it must be Ctrl-C
+        * (as opposed to Ctrl-Break), so consume it.
+        * (Otherwise, Less will beep when it sees Ctrl-C from keyboard.)
+        */
+       if (kbhit())
+               getkey();
+#endif
+       if (reading)
+               intread(); /* May longjmp */
+}
+
+#ifdef SIGTSTP
+/*
+ * "Stop" (^Z) signal handler.
+ */
+       /* ARGSUSED*/
+       static RETSIGTYPE
+stop(type)
+       int type;
+{
+       LSIGNAL(SIGTSTP, stop);
+       sigs |= S_STOP;
+       if (reading)
+               intread();
+}
+#endif
+
+#ifdef SIGWINCH
+/*
+ * "Window" change handler
+ */
+       /* ARGSUSED*/
+       public RETSIGTYPE
+winch(type)
+       int type;
+{
+       LSIGNAL(SIGWINCH, winch);
+       sigs |= S_WINCH;
+       if (reading)
+               intread();
+}
+#else
+#ifdef SIGWIND
+/*
+ * "Window" change handler
+ */
+       /* ARGSUSED*/
+       public RETSIGTYPE
+winch(type)
+       int type;
+{
+       LSIGNAL(SIGWIND, winch);
+       sigs |= S_WINCH;
+       if (reading)
+               intread();
+}
+#endif
+#endif
+
+#if MSDOS_COMPILER==WIN32C
+/*
+ * Handle CTRL-C and CTRL-BREAK keys.
+ */
+#include "windows.h"
+
+       static BOOL WINAPI 
+wbreak_handler(dwCtrlType)
+       DWORD dwCtrlType;
+{
+       switch (dwCtrlType)
+       {
+       case CTRL_C_EVENT:
+       case CTRL_BREAK_EVENT:
+               sigs |= S_INTERRUPT;
+               return (TRUE);
+       default:
+               break;
+       }
+       return (FALSE);
+}
+#endif
+
+/*
+ * Set up the signal handlers.
+ */
+       public void
+init_signals(on)
+       int on;
+{
+       if (on)
+       {
+               /*
+                * Set signal handlers.
+                */
+               (void) LSIGNAL(SIGINT, u_interrupt);
+#if MSDOS_COMPILER==WIN32C
+               SetConsoleCtrlHandler(wbreak_handler, TRUE);
+#endif
+#ifdef SIGTSTP
+               (void) LSIGNAL(SIGTSTP, stop);
+#endif
+#ifdef SIGWINCH
+               (void) LSIGNAL(SIGWINCH, winch);
+#endif
+#ifdef SIGWIND
+               (void) LSIGNAL(SIGWIND, winch);
+#endif
+#ifdef SIGQUIT
+               (void) LSIGNAL(SIGQUIT, SIG_IGN);
+#endif
+       } else
+       {
+               /*
+                * Restore signals to defaults.
+                */
+               (void) LSIGNAL(SIGINT, SIG_DFL);
+#if MSDOS_COMPILER==WIN32C
+               SetConsoleCtrlHandler(wbreak_handler, FALSE);
+#endif
+#ifdef SIGTSTP
+               (void) LSIGNAL(SIGTSTP, SIG_DFL);
+#endif
+#ifdef SIGWINCH
+               (void) LSIGNAL(SIGWINCH, SIG_IGN);
+#endif
+#ifdef SIGWIND
+               (void) LSIGNAL(SIGWIND, SIG_IGN);
+#endif
+#ifdef SIGQUIT
+               (void) LSIGNAL(SIGQUIT, SIG_DFL);
+#endif
+       }
+}
+
+/*
+ * Process any signals we have received.
+ * A received signal cause a bit to be set in "sigs".
+ */
+       public void
+psignals()
+{
+       register int tsignals;
+
+       if ((tsignals = sigs) == 0)
+               return;
+       sigs = 0;
+
+#ifdef SIGTSTP
+       if (tsignals & S_STOP)
+       {
+               /*
+                * Clean up the terminal.
+                */
+#ifdef SIGTTOU
+               LSIGNAL(SIGTTOU, SIG_IGN);
+#endif
+               clear_bot();
+               deinit();
+               flush();
+               raw_mode(0);
+#ifdef SIGTTOU
+               LSIGNAL(SIGTTOU, SIG_DFL);
+#endif
+               LSIGNAL(SIGTSTP, SIG_DFL);
+               kill(getpid(), SIGTSTP);
+               /*
+                * ... Bye bye. ...
+                * Hopefully we'll be back later and resume here...
+                * Reset the terminal and arrange to repaint the
+                * screen when we get back to the main command loop.
+                */
+               LSIGNAL(SIGTSTP, stop);
+               raw_mode(1);
+               init();
+               screen_trashed = 1;
+               tsignals |= S_WINCH;
+       }
+#endif
+#ifdef S_WINCH
+       if (tsignals & S_WINCH)
+       {
+               int old_width, old_height;
+               /*
+                * Re-execute scrsize() to read the new window size.
+                */
+               old_width = sc_width;
+               old_height = sc_height;
+               get_term();
+               if (sc_width != old_width || sc_height != old_height)
+               {
+                       wscroll = (sc_height + 1) / 2;
+                       calc_jump_sline();
+                       calc_shift_count();
+                       screen_trashed = 1;
+               }
+       }
+#endif
+       if (tsignals & S_INTERRUPT)
+       {
+               if (quit_on_intr)
+                       quit(QUIT_INTERRUPT);
+       }
+}
diff --git a/thirdparty/less/tags.c b/thirdparty/less/tags.c
new file mode 100644 (file)
index 0000000..c00f9d4
--- /dev/null
@@ -0,0 +1,757 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+#include "less.h"
+
+#define        WHITESP(c)      ((c)==' ' || (c)=='\t')
+
+#if TAGS
+
+public char *tags = "tags";
+
+static int total;
+static int curseq;
+
+extern int linenums;
+extern int sigs;
+
+enum tag_result {
+       TAG_FOUND,
+       TAG_NOFILE,
+       TAG_NOTAG,
+       TAG_NOTYPE,
+       TAG_INTR
+};
+
+/*
+ * Tag type
+ */
+enum {
+       T_CTAGS,        /* 'tags': standard and extended format (ctags) */
+       T_CTAGS_X,      /* stdin: cross reference format (ctags) */
+       T_GTAGS,        /* 'GTAGS': function defenition (global) */
+       T_GRTAGS,       /* 'GRTAGS': function reference (global) */
+       T_GSYMS,        /* 'GSYMS': other symbols (global) */
+       T_GPATH         /* 'GPATH': path name (global) */
+};
+
+static enum tag_result findctag();
+static enum tag_result findgtag();
+static char *nextgtag();
+static char *prevgtag();
+static POSITION ctagsearch();
+static POSITION gtagsearch();
+static int getentry();
+
+/*
+ * The list of tags generated by the last findgtag() call.
+ *
+ * Use either pattern or line number.
+ * findgtag() always uses line number, so pattern is always NULL.
+ * findctag() uses either pattern (in which case line number is 0),
+ * or line number (in which case pattern is NULL).
+ */
+struct taglist {
+       struct tag *tl_first;
+       struct tag *tl_last;
+};
+#define TAG_END  ((struct tag *) &taglist)
+static struct taglist taglist = { TAG_END, TAG_END };
+struct tag {
+       struct tag *next, *prev; /* List links */
+       char *tag_file;         /* Source file containing the tag */
+       LINENUM tag_linenum;    /* Appropriate line number in source file */
+       char *tag_pattern;      /* Pattern used to find the tag */
+       char tag_endline;       /* True if the pattern includes '$' */
+};
+static struct tag *curtag;
+
+#define TAG_INS(tp) \
+       (tp)->next = TAG_END; \
+       (tp)->prev = taglist.tl_last; \
+       taglist.tl_last->next = (tp); \
+       taglist.tl_last = (tp);
+
+#define TAG_RM(tp) \
+       (tp)->next->prev = (tp)->prev; \
+       (tp)->prev->next = (tp)->next;
+
+/*
+ * Delete tag structures.
+ */
+       public void
+cleantags()
+{
+       register struct tag *tp;
+
+       /*
+        * Delete any existing tag list.
+        * {{ Ideally, we wouldn't do this until after we know that we
+        *    can load some other tag information. }}
+        */
+       while ((tp = taglist.tl_first) != TAG_END)
+       {
+               TAG_RM(tp);
+               free(tp);
+       }
+       curtag = NULL;
+       total = curseq = 0;
+}
+
+/*
+ * Create a new tag entry.
+ */
+       static struct tag *
+maketagent(name, file, linenum, pattern, endline)
+       char *name;
+       char *file;
+       LINENUM linenum;
+       char *pattern;
+       int endline;
+{
+       register struct tag *tp;
+
+       tp = (struct tag *) ecalloc(sizeof(struct tag), 1);
+       tp->tag_file = (char *) ecalloc(strlen(file) + 1, sizeof(char));
+       strcpy(tp->tag_file, file);
+       tp->tag_linenum = linenum;
+       tp->tag_endline = endline;
+       if (pattern == NULL)
+               tp->tag_pattern = NULL;
+       else
+       {
+               tp->tag_pattern = (char *) ecalloc(strlen(pattern) + 1, sizeof(char));
+               strcpy(tp->tag_pattern, pattern);
+       }
+       return (tp);
+}
+
+/*
+ * Get tag mode.
+ */
+       public int
+gettagtype()
+{
+       int f;
+
+       if (strcmp(tags, "GTAGS") == 0)
+               return T_GTAGS;
+       if (strcmp(tags, "GRTAGS") == 0)
+               return T_GRTAGS;
+       if (strcmp(tags, "GSYMS") == 0)
+               return T_GSYMS;
+       if (strcmp(tags, "GPATH") == 0)
+               return T_GPATH;
+       if (strcmp(tags, "-") == 0)
+               return T_CTAGS_X;
+       f = open(tags, OPEN_READ);
+       if (f >= 0)
+       {
+               close(f);
+               return T_CTAGS;
+       }
+       return T_GTAGS;
+}
+
+/*
+ * Find tags in tag file.
+ * Find a tag in the "tags" file.
+ * Sets "tag_file" to the name of the file containing the tag,
+ * and "tagpattern" to the search pattern which should be used
+ * to find the tag.
+ */
+       public void
+findtag(tag)
+       register char *tag;
+{
+       int type = gettagtype();
+       enum tag_result result;
+
+       if (type == T_CTAGS)
+               result = findctag(tag);
+       else
+               result = findgtag(tag, type);
+       switch (result)
+       {
+       case TAG_FOUND:
+       case TAG_INTR:
+               break;
+       case TAG_NOFILE:
+               error("No tags file", NULL_PARG);
+               break;
+       case TAG_NOTAG:
+               error("No such tag in tags file", NULL_PARG);
+               break;
+       case TAG_NOTYPE:
+               error("unknown tag type", NULL_PARG);
+               break;
+       }
+}
+
+/*
+ * Search for a tag.
+ */
+       public POSITION
+tagsearch()
+{
+       if (curtag == NULL)
+               return (NULL_POSITION);  /* No gtags loaded! */
+       if (curtag->tag_linenum != 0)
+               return gtagsearch();
+       else
+               return ctagsearch();
+}
+
+/*
+ * Go to the next tag.
+ */
+       public char *
+nexttag(n)
+       int n;
+{
+       char *tagfile = (char *) NULL;
+
+       while (n-- > 0)
+               tagfile = nextgtag();
+       return tagfile;
+}
+
+/*
+ * Go to the previous tag.
+ */
+       public char *
+prevtag(n)
+       int n;
+{
+       char *tagfile = (char *) NULL;
+
+       while (n-- > 0)
+               tagfile = prevgtag();
+       return tagfile;
+}
+
+/*
+ * Return the total number of tags.
+ */
+       public int
+ntags()
+{
+       return total;
+}
+
+/*
+ * Return the sequence number of current tag.
+ */
+       public int
+curr_tag()
+{
+       return curseq;
+}
+
+/*****************************************************************************
+ * ctags
+ */
+
+/*
+ * Find tags in the "tags" file.
+ * Sets curtag to the first tag entry.
+ */
+       static enum tag_result
+findctag(tag)
+       register char *tag;
+{
+       char *p;
+       register FILE *f;
+       register int taglen;
+       LINENUM taglinenum;
+       char *tagfile;
+       char *tagpattern;
+       int tagendline;
+       int search_char;
+       int err;
+       char tline[TAGLINE_SIZE];
+       struct tag *tp;
+
+       p = shell_unquote(tags);
+       f = fopen(p, "r");
+       free(p);
+       if (f == NULL)
+               return TAG_NOFILE;
+
+       cleantags();
+       total = 0;
+       taglen = strlen(tag);
+
+       /*
+        * Search the tags file for the desired tag.
+        */
+       while (fgets(tline, sizeof(tline), f) != NULL)
+       {
+               if (tline[0] == '!')
+                       /* Skip header of extended format. */
+                       continue;
+               if (strncmp(tag, tline, taglen) != 0 || !WHITESP(tline[taglen]))
+                       continue;
+
+               /*
+                * Found it.
+                * The line contains the tag, the filename and the
+                * location in the file, separated by white space.
+                * The location is either a decimal line number, 
+                * or a search pattern surrounded by a pair of delimiters.
+                * Parse the line and extract these parts.
+                */
+               tagpattern = NULL;
+
+               /*
+                * Skip over the whitespace after the tag name.
+                */
+               p = skipsp(tline+taglen);
+               if (*p == '\0')
+                       /* File name is missing! */
+                       continue;
+
+               /*
+                * Save the file name.
+                * Skip over the whitespace after the file name.
+                */
+               tagfile = p;
+               while (!WHITESP(*p) && *p != '\0')
+                       p++;
+               *p++ = '\0';
+               p = skipsp(p);
+               if (*p == '\0')
+                       /* Pattern is missing! */
+                       continue;
+
+               /*
+                * First see if it is a line number. 
+                */
+               tagendline = 0;
+               taglinenum = getnum(&p, 0, &err);
+               if (err)
+               {
+                       /*
+                        * No, it must be a pattern.
+                        * Delete the initial "^" (if present) and 
+                        * the final "$" from the pattern.
+                        * Delete any backslash in the pattern.
+                        */
+                       taglinenum = 0;
+                       search_char = *p++;
+                       if (*p == '^')
+                               p++;
+                       tagpattern = p;
+                       while (*p != search_char && *p != '\0')
+                       {
+                               if (*p == '\\')
+                                       p++;
+                               p++;
+                       }
+                       tagendline = (p[-1] == '$');
+                       if (tagendline)
+                               p--;
+                       *p = '\0';
+               }
+               tp = maketagent(tag, tagfile, taglinenum, tagpattern, tagendline);
+               TAG_INS(tp);
+               total++;
+       }
+       fclose(f);
+       if (total == 0)
+               return TAG_NOTAG;
+       curtag = taglist.tl_first;
+       curseq = 1;
+       return TAG_FOUND;
+}
+
+/*
+ * Edit current tagged file.
+ */
+       public int
+edit_tagfile()
+{
+       if (curtag == NULL)
+               return (1);
+       return (edit(curtag->tag_file));
+}
+
+/*
+ * Search for a tag.
+ * This is a stripped-down version of search().
+ * We don't use search() for several reasons:
+ *   - We don't want to blow away any search string we may have saved.
+ *   - The various regular-expression functions (from different systems:
+ *     regcmp vs. re_comp) behave differently in the presence of 
+ *     parentheses (which are almost always found in a tag).
+ */
+       static POSITION
+ctagsearch()
+{
+       POSITION pos, linepos;
+       LINENUM linenum;
+       int len;
+       char *line;
+
+       pos = ch_zero();
+       linenum = find_linenum(pos);
+
+       for (;;)
+       {
+               /*
+                * Get lines until we find a matching one or 
+                * until we hit end-of-file.
+                */
+               if (ABORT_SIGS())
+                       return (NULL_POSITION);
+
+               /*
+                * Read the next line, and save the 
+                * starting position of that line in linepos.
+                */
+               linepos = pos;
+               pos = forw_raw_line(pos, &line, (int *)NULL);
+               if (linenum != 0)
+                       linenum++;
+
+               if (pos == NULL_POSITION)
+               {
+                       /*
+                        * We hit EOF without a match.
+                        */
+                       error("Tag not found", NULL_PARG);
+                       return (NULL_POSITION);
+               }
+
+               /*
+                * If we're using line numbers, we might as well
+                * remember the information we have now (the position
+                * and line number of the current line).
+                */
+               if (linenums)
+                       add_lnum(linenum, pos);
+
+               /*
+                * Test the line to see if we have a match.
+                * Use strncmp because the pattern may be
+                * truncated (in the tags file) if it is too long.
+                * If tagendline is set, make sure we match all
+                * the way to end of line (no extra chars after the match).
+                */
+               len = strlen(curtag->tag_pattern);
+               if (strncmp(curtag->tag_pattern, line, len) == 0 &&
+                   (!curtag->tag_endline || line[len] == '\0' || line[len] == '\r'))
+               {
+                       curtag->tag_linenum = find_linenum(linepos);
+                       break;
+               }
+       }
+
+       return (linepos);
+}
+
+/*******************************************************************************
+ * gtags
+ */
+
+/*
+ * Find tags in the GLOBAL's tag file.
+ * The findgtag() will try and load information about the requested tag.
+ * It does this by calling "global -x tag" and storing the parsed output
+ * for future use by gtagsearch().
+ * Sets curtag to the first tag entry.
+ */
+       static enum tag_result
+findgtag(tag, type)
+       char *tag;              /* tag to load */
+       int type;               /* tags type */
+{
+       char buf[256];
+       FILE *fp;
+       struct tag *tp;
+
+       if (type != T_CTAGS_X && tag == NULL)
+               return TAG_NOFILE;
+
+       cleantags();
+       total = 0;
+
+       /*
+        * If type == T_CTAGS_X then read ctags's -x format from stdin
+        * else execute global(1) and read from it.
+        */
+       if (type == T_CTAGS_X)
+       {
+               fp = stdin;
+               /* Set tag default because we cannot read stdin again. */
+               tags = "tags";
+       } else
+       {
+#if !HAVE_POPEN
+               return TAG_NOFILE;
+#else
+               char *command;
+               char *flag;
+               char *qtag;
+               char *cmd = lgetenv("LESSGLOBALTAGS");
+
+               if (cmd == NULL || *cmd == '\0')
+                       return TAG_NOFILE;
+               /* Get suitable flag value for global(1). */
+               switch (type)
+               {
+               case T_GTAGS:
+                       flag = "" ;
+                       break;
+               case T_GRTAGS:
+                       flag = "r";
+                       break;
+               case T_GSYMS:
+                       flag = "s";
+                       break;
+               case T_GPATH:
+                       flag = "P";
+                       break;
+               default:
+                       return TAG_NOTYPE;
+               }
+
+               /* Get our data from global(1). */
+               qtag = shell_quote(tag);
+               if (qtag == NULL)
+                       qtag = tag;
+               command = (char *) ecalloc(strlen(cmd) + strlen(flag) +
+                               strlen(qtag) + 5, sizeof(char));
+               sprintf(command, "%s -x%s %s", cmd, flag, qtag);
+               if (qtag != tag)
+                       free(qtag);
+               fp = popen(command, "r");
+               free(command);
+#endif
+       }
+       if (fp != NULL)
+       {
+               while (fgets(buf, sizeof(buf), fp))
+               {
+                       char *name, *file, *line;
+                       int len;
+
+                       if (sigs)
+                       {
+#if HAVE_POPEN
+                               if (fp != stdin)
+                                       pclose(fp);
+#endif
+                               return TAG_INTR;
+                       }
+                       len = strlen(buf);
+                       if (len > 0 && buf[len-1] == '\n')
+                               buf[len-1] = '\0';
+                       else
+                       {
+                               int c;
+                               do {
+                                       c = fgetc(fp);
+                               } while (c != '\n' && c != EOF);
+                       }
+
+                       if (getentry(buf, &name, &file, &line))
+                       {
+                               /*
+                                * Couldn't parse this line for some reason.
+                                * We'll just pretend it never happened.
+                                */
+                               break;
+                       }
+
+                       /* Make new entry and add to list. */
+                       tp = maketagent(name, file, (LINENUM) atoi(line), NULL, 0);
+                       TAG_INS(tp);
+                       total++;
+               }
+               if (fp != stdin)
+               {
+                       if (pclose(fp))
+                       {
+                               curtag = NULL;
+                               total = curseq = 0;
+                               return TAG_NOFILE;
+                       }
+               }
+       }
+
+       /* Check to see if we found anything. */
+       tp = taglist.tl_first;
+       if (tp == TAG_END)
+               return TAG_NOTAG;
+       curtag = tp;
+       curseq = 1;
+       return TAG_FOUND;
+}
+
+static int circular = 0;       /* 1: circular tag structure */
+
+/*
+ * Return the filename required for the next gtag in the queue that was setup
+ * by findgtag().  The next call to gtagsearch() will try to position at the
+ * appropriate tag.
+ */
+       static char *
+nextgtag()
+{
+       struct tag *tp;
+
+       if (curtag == NULL)
+               /* No tag loaded */
+               return NULL;
+
+       tp = curtag->next;
+       if (tp == TAG_END)
+       {
+               if (!circular)
+                       return NULL;
+               /* Wrapped around to the head of the queue */
+               curtag = taglist.tl_first;
+               curseq = 1;
+       } else
+       {
+               curtag = tp;
+               curseq++;
+       }
+       return (curtag->tag_file);
+}
+
+/*
+ * Return the filename required for the previous gtag in the queue that was
+ * setup by findgtat().  The next call to gtagsearch() will try to position
+ * at the appropriate tag.
+ */
+       static char *
+prevgtag()
+{
+       struct tag *tp;
+
+       if (curtag == NULL)
+               /* No tag loaded */
+               return NULL;
+
+       tp = curtag->prev;
+       if (tp == TAG_END)
+       {
+               if (!circular)
+                       return NULL;
+               /* Wrapped around to the tail of the queue */
+               curtag = taglist.tl_last;
+               curseq = total;
+       } else
+       {
+               curtag = tp;
+               curseq--;
+       }
+       return (curtag->tag_file);
+}
+
+/*
+ * Position the current file at at what is hopefully the tag that was chosen
+ * using either findtag() or one of nextgtag() and prevgtag().  Returns -1
+ * if it was unable to position at the tag, 0 if successful.
+ */
+       static POSITION
+gtagsearch()
+{
+       if (curtag == NULL)
+               return (NULL_POSITION);  /* No gtags loaded! */
+       return (find_pos(curtag->tag_linenum));
+}
+
+/*
+ * The getentry() parses both standard and extended ctags -x format.
+ *
+ * [standard format]
+ * <tag>   <lineno>  <file>         <image>
+ * +------------------------------------------------
+ * |main     30      main.c         main(argc, argv)
+ * |func     21      subr.c         func(arg)
+ *
+ * The following commands write this format.
+ *     o Traditinal Ctags with -x option
+ *     o Global with -x option
+ *             See <http://www.gnu.org/software/global/global.html>
+ *
+ * [extended format]
+ * <tag>   <type>  <lineno>   <file>        <image>
+ * +----------------------------------------------------------
+ * |main     function 30      main.c         main(argc, argv)
+ * |func     function 21      subr.c         func(arg)
+ *
+ * The following commands write this format.
+ *     o Exuberant Ctags with -x option
+ *             See <http://ctags.sourceforge.net>
+ *
+ * Returns 0 on success, -1 on error.
+ * The tag, file, and line will each be NUL-terminated pointers
+ * into buf.
+ */
+       static int
+getentry(buf, tag, file, line)
+       char *buf;      /* standard or extended ctags -x format data */
+       char **tag;     /* name of the tag we actually found */
+       char **file;    /* file in which to find this tag */
+       char **line;    /* line number of file where this tag is found */
+{
+       char *p = buf;
+
+       for (*tag = p;  *p && !IS_SPACE(*p);  p++)      /* tag name */
+               ;
+       if (*p == 0)
+               return (-1);
+       *p++ = 0;
+       for ( ;  *p && IS_SPACE(*p);  p++)              /* (skip blanks) */
+               ;
+       if (*p == 0)
+               return (-1);
+       /*
+        * If the second part begin with other than digit,
+        * it is assumed tag type. Skip it.
+        */
+       if (!IS_DIGIT(*p))
+       {
+               for ( ;  *p && !IS_SPACE(*p);  p++)     /* (skip tag type) */
+                       ;
+               for (;  *p && IS_SPACE(*p);  p++)       /* (skip blanks) */
+                       ;
+       }
+       if (!IS_DIGIT(*p))
+               return (-1);
+       *line = p;                                      /* line number */
+       for (*line = p;  *p && !IS_SPACE(*p);  p++)
+               ;
+       if (*p == 0)
+               return (-1);
+       *p++ = 0;
+       for ( ; *p && IS_SPACE(*p);  p++)               /* (skip blanks) */
+               ;
+       if (*p == 0)
+               return (-1);
+       *file = p;                                      /* file name */
+       for (*file = p;  *p && !IS_SPACE(*p);  p++)
+               ;
+       if (*p == 0)
+               return (-1);
+       *p = 0;
+
+       /* value check */
+       if (strlen(*tag) && strlen(*line) && strlen(*file) && atoi(*line) > 0)
+               return (0);
+       return (-1);
+}
+  
+#endif
diff --git a/thirdparty/less/ttyin.c b/thirdparty/less/ttyin.c
new file mode 100644 (file)
index 0000000..00f2c9e
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Routines dealing with getting input from the keyboard (i.e. from the user).
+ */
+
+#include "less.h"
+#if OS2
+#include "cmd.h"
+#include "pckeys.h"
+#endif
+#if MSDOS_COMPILER==WIN32C
+#include "windows.h"
+extern char WIN32getch();
+static DWORD console_mode;
+#endif
+
+public int tty;
+extern int sigs;
+extern int utf_mode;
+
+/*
+ * Open keyboard for input.
+ */
+       public void
+open_getchr()
+{
+#if MSDOS_COMPILER==WIN32C
+       /* Need this to let child processes inherit our console handle */
+       SECURITY_ATTRIBUTES sa;
+       memset(&sa, 0, sizeof(SECURITY_ATTRIBUTES));
+       sa.nLength = sizeof(SECURITY_ATTRIBUTES);
+       sa.bInheritHandle = TRUE;
+       tty = (int) CreateFile("CONIN$", GENERIC_READ,
+                       FILE_SHARE_READ, &sa, 
+                       OPEN_EXISTING, 0L, NULL);
+       GetConsoleMode((HANDLE)tty, &console_mode);
+       /* Make sure we get Ctrl+C events. */
+       SetConsoleMode((HANDLE)tty, ENABLE_PROCESSED_INPUT);
+#else
+#if MSDOS_COMPILER
+       extern int fd0;
+       /*
+        * Open a new handle to CON: in binary mode 
+        * for unbuffered keyboard read.
+        */
+        fd0 = dup(0);
+        close(0);
+        tty = open("CON", OPEN_READ);
+#if MSDOS_COMPILER==DJGPPC
+       /*
+        * Setting stdin to binary causes Ctrl-C to not
+        * raise SIGINT.  We must undo that side-effect.
+        */
+       (void) __djgpp_set_ctrl_c(1);
+#endif
+#else
+       /*
+        * Try /dev/tty.
+        * If that doesn't work, use file descriptor 2,
+        * which in Unix is usually attached to the screen,
+        * but also usually lets you read from the keyboard.
+        */
+#if OS2
+       /* The __open() system call translates "/dev/tty" to "con". */
+       tty = __open("/dev/tty", OPEN_READ);
+#else
+       tty = open("/dev/tty", OPEN_READ);
+#endif
+       if (tty < 0)
+               tty = 2;
+#endif
+#endif
+}
+
+/*
+ * Close the keyboard.
+ */
+       public void
+close_getchr()
+{
+#if MSDOS_COMPILER==WIN32C
+       SetConsoleMode((HANDLE)tty, console_mode);
+       CloseHandle((HANDLE)tty);
+#endif
+}
+
+/*
+ * Get a character from the keyboard.
+ */
+       public int
+getchr()
+{
+       char c;
+       int result;
+
+       do
+       {
+#if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC
+               /*
+                * In raw read, we don't see ^C so look here for it.
+                */
+               flush();
+#if MSDOS_COMPILER==WIN32C
+               if (ABORT_SIGS())
+                       return (READ_INTR);
+               c = WIN32getch(tty);
+#else
+               c = getch();
+#endif
+               result = 1;
+               if (c == '\003')
+                       return (READ_INTR);
+#else
+               result = iread(tty, &c, sizeof(char));
+               if (result == READ_INTR)
+                       return (READ_INTR);
+               if (result < 0)
+               {
+                       /*
+                        * Don't call error() here,
+                        * because error calls getchr!
+                        */
+                       quit(QUIT_ERROR);
+               }
+#endif
+#if 0 /* allow entering arbitrary hex chars for testing */
+               /* ctrl-A followed by two hex chars makes a byte */
+       {
+               int hex_in = 0;
+               int hex_value = 0;
+               if (c == CONTROL('A'))
+               {
+                       hex_in = 2;
+                       result = 0;
+                       continue;
+               }
+               if (hex_in > 0)
+               {
+                       int v;
+                       if (c >= '0' && c <= '9')
+                               v = c - '0';
+                       else if (c >= 'a' && c <= 'f')
+                               v = c - 'a' + 10;
+                       else if (c >= 'A' && c <= 'F')
+                               v = c - 'A' + 10;
+                       else
+                               hex_in = 0;
+                       hex_value = (hex_value << 4) | v;
+                       if (--hex_in > 0)
+                       {
+                               result = 0;
+                               continue;
+                       }
+                       c = hex_value;
+               }
+       }
+#endif
+               /*
+                * Various parts of the program cannot handle
+                * an input character of '\0'.
+                * If a '\0' was actually typed, convert it to '\340' here.
+                */
+               if (c == '\0')
+                       c = '\340';
+       } while (result != 1);
+
+       return (c & 0xFF);
+}
diff --git a/thirdparty/less/version.c b/thirdparty/less/version.c
new file mode 100644 (file)
index 0000000..dc5bb0c
--- /dev/null
@@ -0,0 +1,748 @@
+/*
+ * Copyright (C) 1984-2011  Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to 
+ * contact the author, see the README file.
+ */
+
+
+/*
+----------------------- CHANGE HISTORY --------------------------
+
+       1/29/84  Allowed use on standard input
+       2/1/84   Added E, N, P commands
+       4/17/84  Added '=' command, 'stop' signal handling
+       4/20/84  Added line folding
+v2     4/27/84  Fixed '=' command to use BOTTOM_PLUS_ONE,
+                instead of TOP, added 'p' & 'v' commands
+v3     5/3/84   Added -m and -t options, '-' command
+v4     5/3/84   Added LESS environment variable
+v5     5/3/84   New comments, fixed '-' command slightly
+v6     5/15/84  Added -Q, visual bell
+v7     5/24/84  Fixed jump_back(n) bug: n should count real
+                lines, not folded lines.  Also allow number on G command.
+v8     5/30/84  Re-do -q and -Q commands
+v9     9/25/84  Added "+<cmd>" argument
+v10    10/10/84 Fixed bug in -b<n> argument processing
+v11    10/18/84 Made error() ring bell if \n not entered.
+-----------------------------------------------------------------
+v12    2/13/85  Reorganized signal handling and made portable to 4.2bsd.
+v13    2/16/85  Reword error message for '-' command.
+v14    2/22/85  Added -bf and -bp variants of -b.
+v15    2/25/85  Miscellaneous changes.
+v16    3/13/85  Added -u flag for backspace processing.
+v17    4/13/85  Added j and k commands, changed -t default.
+v18    4/20/85  Rewrote signal handling code.
+v19    5/2/85   Got rid of "verbose" eq_message().
+                Made search() scroll in some cases.
+v20    5/21/85  Fixed screen.c ioctls for System V.
+v21    5/23/85  Fixed some first_cmd bugs.
+v22    5/24/85  Added support for no RECOMP nor REGCMP.
+v23    5/25/85  Miscellanous changes and prettying up.
+                Posted to USENET.
+-----------------------------------------------------------------
+v24    6/3/85   Added ti,te terminal init & de-init.       
+                (Thanks to Mike Kersenbrock)
+v25    6/8/85   Added -U flag, standout mode underlining.
+v26    6/9/85   Added -M flag.
+                Use underline termcap (us) if it exists.
+v27    6/15/85  Renamed some variables to make unique in
+                6 chars.  Minor fix to -m.
+v28    6/28/85  Fixed right margin bug.
+v29    6/28/85  Incorporated M.Rose's changes to signal.c
+v30    6/29/85  Fixed stupid bug in argument processing.
+v31    7/15/85  Added -p flag, changed repaint algorithm.  
+                Added kludge for magic cookie terminals.
+v32    7/16/85  Added cat_file if output not a tty.
+v33    7/23/85  Added -e flag and EDITOR.
+v34    7/26/85  Added -s flag.
+v35    7/27/85  Rewrote option handling; added option.c.
+v36    7/29/85  Fixed -e flag to work if not last file.
+v37    8/10/85  Added -x flag.
+v38    8/19/85  Changed prompting; created prompt.c.
+v39    8/24/85  (Not -p) does not initially clear screen.
+v40    8/26/85  Added "skipping" indicator in forw().
+                Posted to USENET.
+-----------------------------------------------------------------
+v41    9/17/85  ONLY_RETURN, control char commands,
+                faster search, other minor fixes.
+v42    9/25/85  Added ++ command line syntax;
+                ch_fsize for pipes.
+v43    10/15/85 Added -h flag, changed prim.c algorithms.
+v44    10/16/85 Made END print in all cases of eof;
+                ignore SIGTTOU after receiv ing SIGTSTP.
+v45    10/16/85 Never print backspaces unless -u.
+v46    10/24/85 Backwards scroll in jump_loc.
+v47    10/30/85 Fixed bug in edit(): *first_cmd==0
+v48    11/16/85 Use TIOCSETN instead of TIOCSETP.
+                Added marks (m and ' commands).
+                Posted to USENET.
+-----------------------------------------------------------------
+v49    1/9/86   Fixed bug: signal didn't clear mcc.
+v50    1/15/86  Added ' (quote) to gomark.
+v51    1/16/86  Added + cmd, fixed problem if first_cmd
+                fails, made g cmd sort of "work" on pipes
+                ev en if bof is no longer buffered.
+v52    1/17/86  Made short files work better.
+v53    1/20/86  Added -P option.
+v54    1/20/86  Changed help to use HELPFILE.
+v55    1/23/86  Messages work better if not tty output.
+v56    1/24/86  Added -l option.
+v57    1/31/86  Fixed -l to get confirmation before
+                ov erwriting an existing file.
+v58    8/28/86  Added filename globbing.
+v59    9/15/86  Fixed some bugs with very long filenames.
+v60    9/26/86  Incorporated changes from Leith (Casey)
+                Leedom for boldface and -z option.
+v61    9/26/86  Got rid of annoying repaints after ! cmd.
+                Posted to USENET.
+-----------------------------------------------------------------
+v62    12/23/86 Added is_directory(); change -z default to
+                -1 instead of 24; cat-and-exit if -e and
+                file is less than a screenful.
+v63    1/8/87   Fixed bug in cat-and-exit if > 1 file.
+v64    1/12/87  Changed puts/putstr, putc/putchr,
+                getc/getchr to av oid name conflict with
+                stdio functions.
+v65    1/26/87  Allowed '-' command to change NUMBER
+                v alued options (thanks to Gary Puckering)
+v66    2/13/87  Fixed bug: prepaint should use force=1.
+v67    2/24/87  Added !! and % expansion to ! command.
+v68    2/25/87  Added SIGWINCH and TIOCGWINSZ support;
+                changed is_directory to bad_file.
+                (thanks to J. Robert Ward)
+v69    2/25/87  Added SIGWIND and WIOCGETD (for Unix PC).
+v70    3/13/87  Changed help cmd from 'h' to 'H'; better
+                error msgs in bad_file, errno_message.
+v71    5/11/87  Changed -p to -c, made triple -c/-C
+                for clear-eol like more's -c.
+v72    6/26/87  Added -E, -L, use $SHELL in lsystem().
+                (thanks to Stev e Spearman)
+v73    6/26/87  Allow Examine "#" for previous file.
+                Posted to USENET 8/25/87.
+-----------------------------------------------------------------
+v74    9/18/87  Fix conflict in EOF symbol with stdio.h,
+                Make os.c more portable to BSD.
+v75    9/23/87  Fix problems in get_term (thanks to 
+                Paul Eggert); new backwards scrolling in
+                jump_loc (thanks to Marion Hakanson).
+v76    9/23/87  Added -i flag; allow single "!" to
+                inv oke a shell (thanks to Franco Barber).
+v77    9/24/87  Added -n flag and line number support.
+v78    9/25/87  Fixed problem with prompts longer than
+                the screen width.
+v79    9/29/87  Added the _ command.
+v80    10/6/87  Allow signal to break out of linenum scan.
+v81    10/6/87  Allow -b to be changed from within less.
+v82    10/7/87  Add cmd_decode to use a table for key
+                binding (thanks to Dav id Nason).
+v83    10/9/87  Allow .less file for user-defined keys.
+v84    10/11/87 Fix -e/-E problems (thanks to Felix Lee).
+v85    10/15/87 Search now keeps track of line numbers.
+v86    10/20/87 Added -B option and autobuf; fixed
+                "pipe error" bug.
+v87    3/1/88   Fix bug re BSD signals while reading file.
+v88    3/12/88  Use new format for -P option (thanks to
+                der Mouse), allow "+-c" without message,
+                fix bug re BSD hangup.
+v89    3/18/88  Turn off line numbers if linenum scan
+                is interrupted.
+v90    3/30/88  Allow -P from within less.
+v91    3/30/88  Added tags file support (new -t option)
+                (thanks to Brian Campbell).
+v92    4/4/88   Added -+option syntax.
+v93    4/11/88  Add support for slow input (thanks to
+                Joe Orost & apologies for taking almost
+                3 years to get this in!)
+v94    4/11/88  Redo reading/signal stuff.
+v95    4/20/88  Repaint screen better after signal.
+v96    4/21/88  Add /! and ?! commands.
+v97    5/17/88  Allow -l/-L from within less.
+                Eliminate some static arrays (use calloc).
+                Posted to USENET.
+-----------------------------------------------------------------
+v98    10/14/88 Fix incorrect calloc call; uninitialized
+                var in exec_mca; core dump on unknown TERM.
+                Make v cmd work if past last line of file.
+                Fix some signal bugs.
+v99    10/29/88 Allow space between -X and string,
+                when X is a string-valued option.
+v100   1/5/89   Fix globbing bug when $SHELL not set;
+                allow spaces after -t command.
+v101   1/6/89   Fix problem with long (truncated) lines
+                in tags file (thanks to Neil Dixon).
+v102   1/6/89   Fix bug with E# when no prev file;
+                allow spaces after -l command.
+v103   3/14/89  Add -N, -f and -? options.  Add z and w
+                commands.  Add %L for prompt strings.
+v104   3/16/89  Added EDITPROTO.
+v105   3/20/89  Fix bug in find_linenum which cached
+                incorrectly on long lines.
+v106   3/31/89  Added -k option and multiple lesskey      
+                files.
+v107   4/27/89  Add 8-bit char support and -g option.
+                Split option code into 3 files.
+v108   5/5/89   Allocate position table dynamically       
+                (thanks to Paul Eggert); change % command
+                from "percent" to vi-style brace finder.
+v109   5/10/89  Added ESC-% command, split prim.c.
+v110   5/24/89  Fixed bug in + option; fixed repaint bug
+                under Sun windows (thanks to Paul Eggert).
+v111   5/25/89  Generalized # and % expansion; use 
+                calloc for some error messages.
+v112   5/30/89  Get rid of ESC-%, add {}()[] commands.
+v113   5/31/89  Optimize lseeks (thanks to Paul Eggert).
+v114   7/25/89  Added ESC-/ and ESC-/! commands.
+v115   7/26/89  Added ESC-n command.
+v116   7/31/89  Added find_pos to optimize g command.
+v117   8/1/89   Change -f option to -r.
+v118   8/2/89   Save positions for all previous files,
+                not just the immediately previous one.
+v119   8/7/89   Save marks across file boundaries.
+                Add file handle stuff.
+v120   8/11/89  Add :ta command.
+v121   8/16/89  Add -f option.
+v122   8/30/89  Fix performance with many buffers.
+v123   8/31/89  Verbose prompts for string options.
+                Posted beta to USENET.
+-----------------------------------------------------------------
+v124   9/18/89  Reorganize search commands,
+                N = rev, ESC-n = span, add ESC-N.
+v125   9/18/89  Fix tab bug (thanks to Alex Liu).
+                Fix EOF bug when both -w and -c.
+v126   10/25/89 Add -j option.
+v127   10/27/89 Fix problems with blank lines before BOF.
+v128   10/27/89 Add %bj, etc. to prompt strings.
+v129   11/3/89  Add -+,-- commands; add set-option and
+                unset-option to lesskey.
+v130   11/6/89  Generalize A_EXTRA to string, remove
+                set-option, unset-option from lesskey.
+v131   11/7/89  Changed name of EDITPROTO to LESSEDIT.
+v132   11/8/89  Allow editing of command prefix.
+v133   11/16/89 Add -y option (thanks to Jeff Sullivan).
+v134   12/1/89  Glob filenames in the -l command.
+v135   12/5/89  Combined {}()[] commands into one, and
+                added ESC-^F and ESC-^B commands.
+v136   1/20/90  Added -S, -R flags.  Added | command.
+                Added warning for binary files. (thanks
+                to Richard Brittain and J. Sullivan).
+v137   1/21/90  Rewrote horrible pappend code.
+                Added * notation for hi-bit chars.
+v138   1/24/90  Fix magic cookie terminal handling.
+                Get rid of "cleanup" loop in ch_get.
+v139   1/27/90  Added MSDOS support.  (many thanks
+                to Richard Brittain).
+v140   2/7/90   Editing a new file adds it to the
+                command line list.
+v141   2/8/90   Add edit_list for editing >1 file.
+v142   2/10/90  Add :x command.
+v143   2/11/90  Add * and @ modifies to search cmds.
+                Change ESC-/ cmd from /@* to / *.
+v144   3/1/90   Messed around with ch_zero; 
+                no real change.
+v145   3/2/90   Added -R and -v/-V for MSDOS;
+                renamed FILENAME to avoid conflict.
+v146   3/5/90   Pull cmdbuf functions out of command.c
+v147   3/7/90   Implement ?@; fix multi-file edit bugs.
+v148   3/29/90  Fixed bug in :e<file> then :e#.
+v149   4/3/90   Change error,ierror,query to use PARG.
+v150   4/6/90   Add LESS_CHARSET, LESS_CHARDEF.
+v151   4/13/90  Remove -g option; clean up ispipe.
+v152   4/14/90  lsystem() closes input file, for
+                editors which require exclusive open.
+v153   4/18/90  Fix bug if SHELL unset; 
+                fix bug in overstrike control char.
+v154   4/25/90  Output to fd 2 via buffer.
+v155   4/30/90  Ignore -i if uppercase in pattern
+                (thanks to Michael Rendell.)
+v156   5/3/90   Remove scroll limits in forw() & back();
+                causes problems with -c.
+v157   5/4/90   Forward search starts at next real line
+                (not screen line) after jump target.
+v158   6/14/90  Added F command.
+v159   7/29/90  Fix bug in exiting: output not flushed.
+v160   7/29/90  Clear screen before initial output w/ -c.
+v161   7/29/90  Add -T flag.
+v162   8/14/90  Fix bug with +F on command line.
+v163   8/21/90  Added LESSBINFMT variable.
+v164   9/5/90   Added -p, LINES, COLUMNS and
+                unset mark ' == BOF, for 1003.2 D5.
+v165   9/6/90   At EOF with -c set, don't display empty
+                screen when try to page forward.
+v166   9/6/90   Fix G when final line in file wraps.
+v167   9/11/90  Translate CR/LF -> LF for 1003.2.
+v168   9/13/90  Return to curr file if "tag not found".
+v169   12/12/90 G goes to EOF even if file has grown.
+v170   1/17/91  Add optimization for BSD _setjmp;
+                fix #include ioctl.h TERMIO problem.
+                (thanks to Paul Eggert)
+                Posted to USENET.
+-----------------------------------------------------------------
+v171   3/6/91   Fix -? bug in get_filename.
+v172   3/15/91  Fix G bug in empty file.
+                Fix bug with ?\n and -i and uppercase
+                pattern at EOF!
+                (thanks to Paul Eggert)
+v173   3/17/91  Change N cmd to not permanently change
+                direction. (thanks to Brian Matthews)
+v174   3/18/91  Fix bug with namelogfile not getting
+                cleared when change files.
+v175   3/18/91  Fix bug with ++cmd on command line.
+                (thanks to Jim Meyering)
+v176   4/2/91   Change | to not force current screen,
+                include marked line, start/end from
+                top of screen.  Improve search speed.
+                (thanks to Don Mears)
+v177   4/2/91   Add LESSHELP variable.
+                Fix bug with F command with -e.
+                Try /dev/tty for input before using fd 2.
+                Patches posted to USENET  4/2/91.
+-----------------------------------------------------------------
+v178   4/8/91   Fixed bug in globbing logfile name.
+                (thanks to Jim Meyering)
+v179   4/9/91   Allow negative -z for screen-relative.
+v180   4/9/91   Clear to eos rather than eol if "db";
+                don't use "sr" if "da".
+                (thanks to Tor Lillqvist)
+v181   4/18/91  Fixed bug with "negative" chars 80 - FF.
+                (thanks to Benny Sander Hofmann)
+v182   5/16/91  Fixed bug with attribute at EOL.
+                (thanks to Brian Matthews)
+v183   6/1/91   Rewrite linstall to do smart config.
+v184   7/11/91  Process \b in searches based on -u
+                rather than -i.
+v185   7/11/91  -Pxxx sets short prompt; assume SIGWINCH
+                after a SIGSTOP. (thanks to Ken Laprade)
+-----------------------------------------------------------------
+v186   4/20/92  Port to MS-DOS (Microsoft C).
+v187   4/23/92  Added -D option & TAB_COMPLETE_FILENAME.
+v188   4/28/92  Added command line editing features.
+v189   12/8/92  Fix mem overrun in anscreen.c:init; 
+                fix edit_list to recover from bin file.
+v190   2/13/93  Make TAB enter one filename at a time;
+                create ^L with old TAB functionality.
+v191   3/10/93  Defer creating "flash" page for MS-DOS.
+v192   9/6/93   Add BACK-TAB.
+v193   9/17/93  Simplify binary_file handling.
+v194   1/4/94   Add rudiments of alt_filename handling.
+v195   1/11/94  Port back to Unix; support keypad.
+-----------------------------------------------------------------
+v196   6/7/94   Fix bug with bad filename; fix IFILE
+                type problem. (thanks to David MacKenzie)
+v197   6/7/94   Fix bug with .less tables inserted wrong.
+v198   6/23/94  Use autoconf installation technology.
+                (thanks to David MacKenzie)
+v199   6/29/94  Fix MS-DOS build (thanks to Tim Wiegman).
+v200   7/25/94  Clean up copyright, minor fixes.
+        Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v201   7/27/94  Check for no memcpy; add casts to calloc;
+                look for regcmp in libgen.a.
+                (thanks to Kaveh Ghazi).
+v202   7/28/94  Fix bug in edit_next/edit_prev with 
+                non-existant files.
+v203   8/2/94   Fix a variety of configuration bugs on
+                various systems. (thanks to Sakai
+                Kiyotaka, Harald Koenig, Bjorn Brox,
+                Teemu Rantanen, and Thorsten Lockert)
+v204   8/3/94   Use strerror if available.
+                (thanks to J.T. Conklin)
+v205   8/5/94   Fix bug in finding "me" termcap entry.
+                (thanks to Andreas Stolcke)
+8/10/94         v205+: Change BUFSIZ to LBUFSIZE to avoid name
+                conflict with stdio.h.
+                Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v206   8/10/94  Use initial_scrpos for -t to avoid
+                displaying first page before init().
+                (thanks to Dominique Petitpierre)
+v207   8/12/94  Fix bug if stdout is not tty.
+v208   8/16/94  Fix bug in close_altfile if goto err1
+                in edit_ifile. (Thanks to M.J. Hewitt)
+v209   8/16/94  Change scroll to wscroll to avoid 
+                conflict with library function.
+v210   8/16/94  Fix bug with bold on 8 bit chars.
+                (thanks to Vitor Duarte)
+v211   8/16/94  Don't quit on EOI in jump_loc / forw.
+v212   8/18/94  Use time_t if available.
+v213   8/20/94  Allow ospeed to be defined in termcap.h.
+v214   8/20/94  Added HILITE_SEARCH, -F, ESC-u cmd.
+                (thanks to Paul Lew and Bob Byrnes)
+v215   8/23/94  Fix -i toggle behavior.
+v216   8/23/94  Process BS in all searches, not only -u.
+v217   8/24/94  Added -X flag.
+v218   8/24/94  Reimplement undo_search.
+v219   8/24/94  Find tags marked with line number
+                instead of pattern.
+v220   8/24/94  Stay at same position after SIG_WINCH.
+v221   8/24/94  Fix bug in file percentage in big file.
+v222   8/25/94  Do better if can't reopen current file.
+v223   8/27/94  Support setlocale.
+                (thanks to Robert Joop)
+v224   8/29/94  Revert v216: process BS in search
+                only if -u.
+v225   9/6/94   Rewrite undo_search again: toggle.
+v226   9/15/94  Configuration fixes. 
+                (thanks to David MacKenzie)
+v227   9/19/94  Fixed strerror config problem.
+                Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v228   9/21/94  Fix bug in signals: repeated calls to
+                get_editkeys overflowed st_edittable.
+v229   9/21/94  Fix "Nothing to search" error if -a
+                and SRCH_PAST_EOF.
+v230   9/21/94  Don't print extra error msg in search
+                after regerror().
+v231   9/22/94  Fix hilite bug if search matches 0 chars.
+                (thanks to John Polstra)
+v232   9/23/94  Deal with weird systems that have 
+                termios.h but not tcgetattr().
+                Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v233   9/26/94  Use get_term() instead of pos_init() in
+                psignals to re-get lower_left termcap.
+                (Thanks to John Malecki)
+v234   9/26/94  Make MIDDLE closer to middle of screen.
+v235   9/27/94  Use local strchr if system doesn't have.
+v236   9/28/94  Don't use libucb; use libterm if 
+                libtermcap & libcurses doesn't work.
+                (Fix for Solaris; thanks to Frank Kaefer)
+v237   9/30/94  Use system isupper() etc if provided.
+                Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v238   10/6/94  Make binary non-blinking if LESSBINFMT
+                is set to a string without a *.
+v239   10/7/94  Don't let delimit_word run back past
+                beginning of cmdbuf.
+v240   10/10/94 Don't write into termcap buffer.
+                (Thanks to Benoit Speckel)
+v241   10/13/94 New lesskey file format.
+                Don't expand filenames in search command.
+v242   10/14/94 Allow lesskey specification of "literal".
+v243   10/14/94 Add #stop command to lesskey.
+v244   10/16/94 Add -f flag to lesskey.
+v245   10/25/94 Allow TAB_COMPLETE_FILENAME to be undefd.
+v246   10/27/94 Move help file to /usr/local/share.
+v247   10/27/94 Add -V option.
+v248   11/5/94  Add -V option to lesskey.
+v249   11/5/94  Remove -f flag from lesskey; default
+                input file is ~/.lesskey.in, not stdin.
+v250   11/7/94  Lesskey input file "-" means stdin.
+v251   11/9/94  Convert cfgetospeed result to ospeed.
+                (Thanks to Andrew Chernov)
+v252   11/16/94 Change default lesskey input file from 
+                .lesskey.in to .lesskey.
+                Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v253   11/21/94 Fix bug when tags file has a backslash.
+v254   12/6/94  Fix -k option.
+v255   12/8/94  Add #define EXAMINE to disable :e etc.
+v256   12/10/94 Change highlighting: only highlite search
+                results (but now it is reliable).
+v257   12/10/94 Add goto_line and repaint_highlight
+                to optimize highlight repaints.
+v258   12/12/94 Fixup in hilite_line if BS_SPECIAL.
+v259   12/12/94 Convert to autoconf 2.0.
+v260   12/13/94 Add SECURE define.
+v261   12/14/94 Use system WERASE char as EC_W_BACKSPACE.
+v262   12/16/94 Add -g/-G flag and screen_hilite.
+v263   12/20/94 Reimplement/optimize -G flag behavior.
+v264   12/23/94 Allow EXTRA string after line-edit cmd
+                in lesskey file.
+v265   12/24/94 Add LESSOPEN=|cmd syntax.
+v266   12/26/94 Add -I flag.
+v267   12/28/94 Formalize the four-byte header emitted
+                by a LESSOPEN pipe.
+v268   12/28/94 Get rid of four-byte header.
+v269   1/2/95   Close alt file before open new one.
+                Avoids multiple popen().
+v270   1/3/95   Use VISUAL; use S_ISDIR/S_ISREG; fix
+                config problem with Solaris POSIX regcomp.
+v271   1/4/95   Don't quit on read error.
+v272   1/5/95   Get rid of -L.
+v273   1/6/95   Fix ch_ungetchar bug; don't call
+                LESSOPEN on a pipe.
+v274   1/6/95   Ported to OS/2 (thanks to Kai Uwe Rommel)
+v275   1/18/95  Fix bug if toggle -G at EOF.
+v276   1/30/95  Fix OS/2 version.
+v277   1/31/95  Add "next" charset; don't display ^X 
+                for X > 128.
+v278   2/14/95  Change default for -G.
+                Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v279   2/22/95  Add GNU options --help, --version.
+                Minor config fixes.
+v280   2/24/95  Clean up calls to glob(); don't set #
+                if we can't open the new file.
+v281   2/24/95  Repeat search should turn on hilites.
+v282   3/2/95   Minor fixes.
+v283   3/2/95   Fix homefile; make OS2 look in $HOME.
+v284   3/2/95   Error if "v" on LESSOPENed file;
+                "%" figures out file size on pipe.
+v285   3/7/95   Don't set # in lsystem; 
+                lesskey try $HOME first.
+v286   3/7/95   Reformat change history (too much free time?).
+v287   3/8/95   Fix hilite bug if overstrike multiple chars.
+v288   3/8/95   Allow lesskey to override get_editkey keys.
+v289   3/9/95   Fix adj_hilite bug when line gets processed by
+                hilite_line more than once.
+v290   3/9/95   Make configure automatically.  Fix Sequent problem
+                with incompatible sigsetmask().
+                Posted to prep.ai.mit.edu
+-----------------------------------------------------------------
+v291   3/21/95  Add #env to lesskey.  Fix MS-DOS build.
+                Posted to simtel.
+-----------------------------------------------------------------
+v292   4/24/95  Add MS-DOS support for Borland C.
+                Fix arrow keys in MS-DOS versions.
+v293   4/28/95  Add auto-versioning stuff to make dist.
+v294   5/12/95  Fix Borland build.
+v295   1/20/96  Fix search on squished file; add /@@.
+v296   1/23/96  Allow cmdbuf larger than screen width.
+v297   1/24/96  Don't call termcap if tgetent fails; 
+                add #defines for buffers.
+v298   1/24/96  Change @@ to ^K.  
+                Add alternate search modifiers ^N, ^F, ^E.
+v299   1/25/96  Fix percent overflow in jump_percent (thanks to Brent Wiese);
+                don't send "ti" after shell command till RETURN pressed.
+v300   1/25/96  Change -U to print tabs as ^I.
+v301   1/30/96  Make hilites work in cmd F output.
+v302   1/31/96  Fix cmd F to notice window-change signals.
+v303   1/31/96  Add ESC-SPACE command.
+v304   2/1/96   Add ^R search modifier; add LESSSECURE.
+v305   2/2/96   Workaround Linux /proc kernel bug; add LESSKEY.
+v306   3/16/96  Minor fixes.
+v307   3/25/96  Allow cmd line arg "--"; fix DOS & OS/2 defines.h.
+v308   4/4/96   Port to OS-9 (thanks to Boisy Pitre); fix -d.
+v309   4/9/96   Fix OS-9 version; fix tags bug with "$".
+v310   4/10/96  Get rid of HELPFILE.
+v311   4/22/96  Add Windows32 support; merge doscreen.c into screen.c.
+v312   4/24/96  Don't quit after "cannot reopen" error.
+v313   4/25/96  Added horizontal scrolling.
+v314   4/26/96  Modified -e to quit on reaching end of a squished file.
+v315   4/26/96  Fix "!;TAB" bug.
+v316   5/2/96   Make "|a" when (a < curr screen) go to end of curr screen.
+v317   5/14/96  Various fixes for the MS-DOS and OS/2 builds.
+                Added ## and %% handling for filenames
+v318   5/29/96  Port to OS-9 Microware compiler; minor fixes 
+                (thanks to Martin Gregorie).
+v319   7/8/96   Fix Windows port (thanks to Jeff Paquette).
+v320   7/11/96  Final fixes for Windows port.
+v321   7/18/96  Minor fixes.
+                Posted to Web page.
+-----------------------------------------------------------------
+v322   8/13/96  Fix bug in shell escape from help file; add support for 
+                Microsoft Visual C under Windows; numerous small fixes.
+v323   8/19/96  Fixes for Windows version (thanks to Simon Munton);
+                fix for Linux library weirdness (thanks to Jim Diamond);
+                port to DJGPP (thanks to Eli Zaretskii).
+v324   8/21/96  Add support for spaces in filenames (thanks to Simon Munton).
+v325   8/21/96  Add lessecho, for spaces in filenames under Unix.
+v326   8/27/96  Fix DJGPP version.
+v327   9/1/96   Reorganize lglob, make spaces in filenames work better in Unix.
+v328   10/7/96  Append / to directory name in filename completion.
+                Fix MS-DOS and OS-9 versions.
+v329   10/11/96 Fix more MS-DOS bugs; add LESSSEPARATOR; add -" option.
+                Add LESSMETACHARS, LESSMETAESCAPE.
+v330   10/21/96 Minor fixes.
+                Posted to Web page.
+-----------------------------------------------------------------
+v331   4/22/97  Various Windows fixes (thanks to Gurusamy Sarathy).
+v332   4/22/97  Enter filenames from cmd line into edit history.
+                Posted to Web page.
+-----------------------------------------------------------------
+v333    3/4/99  Changed -w to highlite new line after forward movement.
+v334    3/9/99  Avoid overflowing prompt buffer; add %d and %D.
+v335   3/20/99  Add EBCDIC support (thanks to Thomas Dorner).
+                Use HOMEDRIVE/HOMEPATH on Windows (thanks to Preston Bannister).
+                Posted to Web page.
+-----------------------------------------------------------------
+v336    4/8/99  Fix installation bugs.
+v337    4/9/99  Fix another installation bug.
+                Posted to Web page.
+-----------------------------------------------------------------
+v338   4/13/99  Add support for long option names.
+v339   4/18/99  Add \k, long option names to lesskey.  Add -^P.  Add :d.
+v340   4/21/99  Add regexec2.  Fix Windows build.
+                Posted to Web page.
+-----------------------------------------------------------------
+v341    5/6/99  Add -F option; %c & ?c prompt escapes.
+                (Thanks to Michele Maltoni)
+v342   7/22/99  Add system-wide lesskey file; allow GPL or Less License.
+v343   9/23/99  Support UTF-8 (Thanks to Robert Brady).
+                Add %P and ?P in prompts.
+v344  10/27/99  -w highlights target line of g and p commands.
+v345  10/29/99  Make -R pass thru ESC but not other control chars.
+                Posted to Web page.
+-----------------------------------------------------------------
+v346   11/4/99  Fix bugs in long option processing; R cmd should clear hilites.
+                Posted to Web page.
+-----------------------------------------------------------------
+v347  12/13/99  Fixes for DJGPP version (thanks to Eli Zaretskii).
+v348  12/28/99  Fix deleting file with marks (thanks to Dimitar Jekov).
+                Fix color problem in DJGPP version (thanks to Eli Zaretskii).
+v349   1/24/00  Fix minor DJGPP bugs; check environment vars for UTF-8;
+                add --with-editor (thanks to Eli, Markus Kuhn, Thomas Schoepf).
+v350   3/1/00   Fix clear-while-standout bug.
+v351   3/5/00   Change -M and = prompts to show top & bottom line number.
+                Posted to Web page.
+-----------------------------------------------------------------
+v352   3/8/00   Fix scan_option NULL dereference.
+-----------------------------------------------------------------
+v353   3/20/00  Fix SECURE compile bug, allow space after numeric option.
+v354   3/23/00  Add support for PCRE; add --with-regex configure option.
+-----------------------------------------------------------------
+v355   6/28/00  Add -# option (thanks to Andy Levinson).
+v356   7/5/00   Add -J option.
+v357   7/6/00   Support sigprocmask.
+-----------------------------------------------------------------
+v358   7/8/00   Fix problems with #stop in lesskey file.
+                Posted to Web page.
+-----------------------------------------------------------------
+v359  9/10/00   Fixes for Win32 display problems (thanks to Maurizio Vairani).
+v360  1/17/01   Move sysless to etc.
+v361  12/4/01   Add IBM-1047 charset & EBCDIC fixes (thanks to Thomas Dorner).
+                Fix 32 bit dependencies (thanks to Paul Eggert).
+                Fix UTF-8 overstriking (thanks to Robert Brady).
+v362  12/4/01   Make status column show search targets.
+v363  12/6/01   Add --no-keypad option.
+                Add variable width tabstops (thanks to Peter Samuelson).
+v364 12/10/01   Better handling of very long lines in input;
+                Fix horizontal shifting of colored text.
+v365 12/11/01   Fix overstriking of tabs;
+                Add support for global(1) and multiple tag matches
+                (thanks to Shigio Yamaguchi and Tim Vanderhoek).
+v366 12/11/01   Fixes for OS/2 (thanks to Kyosuke Tokoro).
+v367 12/13/01   Allow -D and -x options to terminate without dollar sign;
+                Right/left arrow when entering N are shift cmds, not line edit.
+v368 12/18/01   Update lesskey commands.
+v370 12/23/01   Fix tags error messages.
+                Posted to Web page.
+-----------------------------------------------------------------
+v371 12/26/01   Fix new_file bug; use popen in Windows version;
+                fix some compiler warnings.
+v372 12/29/01   Make -b be in units of 1K.
+v373  1/14/02   Improve handling of filenames containing shell metachars.
+v374   2/7/02   Fix memory leak; fix bug in -x argument parsing.
+v375   4/7/02   Fix searching for SGR sequences; fix SECURE build;
+                add SGR support to DJGPP version (thanks to Eli Zaretskii).
+v376  6/10/02   Fix bug in overstriking mulitbyte UTF-8 characters
+                (thanks to Jungshik Shin).
+                Posted to Web page.
+-----------------------------------------------------------------
+v377  9/10/02   Fix bug in Windows version when file contains CR;
+                fix bug in search highlights with -R;
+                make initial buffer limit really be 64K not unlimited.
+v378  9/30/02   Misc bug fixes and compiler warning cleanup.
+                Posted to Web page.
+-----------------------------------------------------------------
+v379 11/23/02   Add -L option; fix bug with ctrl-K in lesskey files;
+                improve UTF-8 overstriking and underscore overstriking;
+                fix minor man page problems; change to autoconf 2.54.
+v380 11/24/02   Make LINENUM same as POSITION.
+v381 11/28/02   Make -N use 7 columns for line number if possible.
+-----------------------------------------------------------------
+v382   2/3/04   Remove copyrighted code.
+-----------------------------------------------------------------
+v383  2/16/04   Add history file; add -K option; improve UTF-8 handling;
+                fix some signed char bugs (thanks to Christian Biere);
+                fix some upper/lower case bugs (thanks to Bjoern Jacke);
+                add erase2 char (thanks to David Lawrence);
+                add windows charset (thanks to Dimitar Zhekov).
+v384  2/20/04   Improvements in UTF-8 handling.
+v385  2/23/04   Fix UTF-8 output bug.
+-----------------------------------------------------------------
+v386  9/13/05   Improvements to UTF-8 shift & color (thanks to Charles Levert);
+                protect against invalid LESSOPEN and LESSCLOSE values.
+v387  9/14/05   Update Charles Levert's UTF-8 patch.
+v388  9/14/05   Change history behavior; change most sprintf calls to snprintf.
+v389  9/14/05   Fix copy & paste with long lines; improve performance of 
+                expand_linebuf; fix crash in init_mlist; 
+v390  9/15/05   Show search matches in status column even if -G is set.
+-----------------------------------------------------------------
+v391  9/17/05   Fix bugs.
+v392  10/14/05  Fix line wrapping bug.
+v393  10/19/05  Allow multiple attributes per char; fix bold+underline bug
+                (thanks again to Charles Levert).
+v394  11/8/05   Fix prompt bug; fix compile problem in Windows build.
+-----------------------------------------------------------------
+v395  1/12/07   Update Unicode tables (thanks to Charles Levert);
+                don't chmod if LESSHISTFILE = /dev/null;
+                make -f work for directories; support DESTDIR in Makefile;
+                fix sigset_t detection in configure; 
+                make "t" cmd traverse tags in correct order
+v396  1/13/07   Add compatibility with POSIX more.
+v397  3/21/07   Allow decimal point in number for % command;
+                Allow decimal point in number for -j option;
+                Allow n command to fetch last search pattern from history
+                (thanks to arno).
+v398  3/22/07   Don't rewrite history file if not necessary;
+                fix bug when filenames contain "$".
+v399  3/22/07   Don't move to bottom of screen at startup;
+                don't output extraneous newlines.
+v400  3/23/07   Allow search to find pattern after null byte (PCRE and no-regex)
+                (thanks to Michael Constant).
+-----------------------------------------------------------------
+v401  3/24/07   Minor documentation fixes.
+v402  3/30/07   Fix autoconf bug when memcpy etc are inline;
+                fix bug in terminating number following -j option.
+v403  5/25/07   Fix Windows build.
+v404  6/5/07    Fix display bug with F command and long lines.
+v405  6/17/07   Fix display bug when using -w option.
+v406  6/17/07   Fix secure build.
+v407  8/16/07   Fix bugs; support CSI chars.
+v408  10/1/07   Fix bug in -i with non-ASCII chars.
+v409  10/12/07  Fix crash when viewing text with invalid UTF-8 sequences.
+v411  11/6/07   Fix case-insensitive searching with non-ASCII text.
+v412  11/6/07   Use symbolic SEEK constants.
+v413  11/6/07   Fix search highlight bug with non-ASCII text.
+v414  11/6/07   Fix display bug with no-wrap terminals.
+v415  11/14/07  Add --follow-name option.
+v416  11/22/07  Fix crash when searching text with invalid UTF-8 sequences.
+v417  12/31/07  Don't support single-char CSI in UTF-8 mode;
+                fix bug with -R and invalid CSI sequences;
+                fix bug searching text with SGR sequences with -r;
+                emulate SGR sequences in WIN32 build.
+v418  12/31/07  Clean up.
+-----------------------------------------------------------------
+v419  1/16/08   Make CSI char 0x9B work in UTF-8 mode (thanks to Colin Watson).
+v420  2/24/08   Add & command; fix -F option; fix '' after G.
+v421  2/24/08   Ignore filtered lines when searching.
+v422  3/2/08    Output CR at startup.
+v423  5/27/08   Clean up.
+v424  6/16/08   Fix compile bug with pcre; don't filter help file.
+v425  7/14/08   Fix non-ANSI code in list handling in ch.c.
+v426  10/27/08  Fix ignaw terminal handling (thanks to Per Hedeland);
+                fix binary file detection in UTF-8 mode.
+v427  3/16/09   A few Win32 fixes (thanks to Jason Hood).
+v428  3/30/09   Add "|-" syntax to LESSOPEN.
+v429  4/10/09   Fix search highlighting bug with underlined text.
+-----------------------------------------------------------------
+v430  4/22/09   Don't pass "-" to non-pipe LESSOPEN unless it starts with "-".
+v431  4/29/09   Fix highlight bug when match is at end of line.
+v432  6/27/09   Better fix for highlight bugs;
+                fix new problems with ignaw terminals.
+v433  6/28/09   Cleanup search code.
+v434  6/29/09   More cleanup.
+v435  7/04/09   Fix bugs with non-regex filtering.
+v436  7/05/09   Fix memory leak.
+-----------------------------------------------------------------
+v437  7/14/09   Fix bug in handling some long option names;
+                make percentage calculation more accurate.
+v438  12/29/10  Fix bugs with -i/-I and & filtering; 
+                exit with status 2 on ctrl-C with -K.
+v439  12/31/10  Add -A option.
+v440  1/5/11    Fix bug displaying prompt after = command.
+v441  1/21/11   Fix semi-infinite loop if no newlines in file;
+                make new -A behavior the default.
+-----------------------------------------------------------------
+v442  3/2/11    Fix search bug.
+                Add ctrl-G line edit command.
+v443  4/9/11    Fix Windows build.
+v444  6/8/11    Fix ungetc bug; remove vestiges of obsolete -l option.
+*/
+
+char version[] = "444";
index 0659ae39d243b698280ca748d97cbcdb04590333..3bf7c73efa1fc74cf1d496086b5ca30c38f9da23 100644 (file)
@@ -1,5 +1,5 @@
 
-Libpng 1.5.2 - March 31, 2011
+Libpng 1.5.9 - February 18, 2012
 
 This is a public release of libpng, intended for use in production codes.
 
@@ -8,55 +8,35 @@ Files available for download:
 Source files with LF line endings (for Unix/Linux) and with a
 "configure" script
 
-   libpng-1.5.2.tar.xz (LZMA-compressed, recommended)
-   libpng-1.5.2.tar.gz
-   libpng-1.5.2.tar.bz2
+   libpng-1.5.9.tar.xz (LZMA-compressed, recommended)
+   libpng-1.5.9.tar.gz
+   libpng-1.5.9.tar.bz2
 
 Source files with CRLF line endings (for Windows), without the
 "configure" script
 
-   lpng152.7z  (LZMA-compressed, recommended)
-   lpng152.zip
+   lpng159.7z  (LZMA-compressed, recommended)
+   lpng159.zip
 
 Other information:
 
-   libpng-1.5.2-README.txt
-   libpng-1.5.2-LICENSE.txt
-
-Changes since the last public release (1.5.2):
-
-  More -Wshadow fixes for older gcc compilers.  Older gcc versions apparently
-    check formal parameters names in function declarations (as well as
-    definitions) to see if they match a name in the global namespace.
-  Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the
-    old VisualC++ preprocessor.
-  Turned on interlace handling in png_read_png().
-  Fixed gcc pendantic warnings.
-  Handle longjmp in Cygwin.
-  Fixed png_get_current_row_number() in the interlaced case.
-  Cleaned up ALPHA flags and transformations.
-  Implemented expansion to 16 bits.
-  Fixed mistake in the descriptions of user read_transform and write_transform
-    function prototypes in the manual.  The row_info struct is png_row_infop.
-  Corrected png_get_current_row_number documentation
-  Fixed the read/write row callback documentation.
-    This documents the current behavior, where the callback is called after
-    every row with information pertaining to the next row.
-  Fixed scripts/makefile.vcwin32
-  Updated contrib/pngsuite/README to add the word "modify".
-  Define PNG_ALLOCATED and other attributes to blank when _MSC_VER<1300.
-  ifdef out mask arrays in pngread.c when interlacing is not supported.
-  Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak
-    and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip"
-    from the makefiles.
-  Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail
-    to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill)
-  Don't include standard header files in png.h while building the symbol table,
-    to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro).
+   libpng-1.5.9-README.txt
+   libpng-1.5.9-LICENSE.txt
+
+Changes since the last public release (1.5.8):
+
+  Rebuilt configure scripts in the tar distributions.
+  Removed two unused definitions from scripts/pnglibconf.h.prebuilt
+  Removed some unused arrays (with #ifdef) from png_read_push_finish_row().
+  Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h
+  Fixed CVE-2011-3026 buffer overrun bug.  Deal more correctly with the test
+    on iCCP chunk length. Also removed spurious casts that may hide problems
+    on 16-bit systems.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe) or to glennrp at users.sourceforge.net
+to subscribe)
+or to glennrp at users.sourceforge.net
 
 Glenn R-P
index fb069121a45024e4904e7f4ea0636f183b7ec350..301b80c7182b1e5918ecc4431f53fd76d8dd9cb5 100644 (file)
@@ -1,5 +1,4 @@
 #if 0
-libpng_changes(){ /*
 CHANGES - changes for libpng
 
 Version 0.2
@@ -15,7 +14,7 @@ Version 0.3
   fixed some bugs in writer
   interfaced with zlib 0.5
   added K&R support
-  added check for 64 KB blocks for 16 bit machines
+  added check for 64 KB blocks for 16-bit machines
 
 Version 0.4
   cleaned up code and commented code
@@ -74,7 +73,7 @@ Version 0.82 [September, 1995]
 Version 0.85 [December, 1995]
   added more medium model code (almost everything's a far)
   added i/o, error, and memory callback functions
-  fixed some bugs (16 bit, 4 bit interlaced, etc.)
+  fixed some bugs (16-bit, 4-bit interlaced, etc.)
   added first run progressive reader (barely tested)
 
 Version 0.86 [January, 1996]
@@ -180,7 +179,7 @@ Version 0.96 [May, 1997]
   Fixed serious bug with < 8bpp images introduced in 0.95
   Fixed 256-color transparency bug (Greg Roelofs)
   Fixed up documentation (Greg Roelofs, Laszlo Nyul)
-  Fixed "error" in pngconf.h for Linux setjmp() behaviour
+  Fixed "error" in pngconf.h for Linux setjmp() behavior
   Fixed DOS medium model support (Tim Wegner)
   Fixed png_check_keyword() for case with error in static string text
   Added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul)
@@ -197,18 +196,20 @@ Version 0.97 [January, 1998]
   Added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P)
   Minor corrections in libpng.txt
   Added simple sRGB support (Glenn R-P)
-  Easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
+  Easier conditional compiling, e.g.,
+    define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
     all configurable options can be selected from command-line instead
     of having to edit pngconf.h (Glenn R-P)
   Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
   Added more conditions for png_do_background, to avoid changing
     black pixels to background when a background is supplied and
     no pixels are transparent
-  Repaired PNG_NO_STDIO behaviour
-  Tested NODIV support and made it default behaviour (Greg Roelofs)
+  Repaired PNG_NO_STDIO behavior
+  Tested NODIV support and made it default behavior (Greg Roelofs)
   Added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler)
   Regularized version numbering scheme and bumped shared-library major
-     version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs)
+    version number to 2 to avoid problems with libpng 0.89 apps
+    (Greg Roelofs)
 
 Version 0.98 [January, 1998]
   Cleaned up some typos in libpng.txt and in code documentation
@@ -1778,7 +1779,7 @@ Version 1.2.13beta1 [October 2, 2006]
   Removed AC_FUNC_MALLOC from configure.ac
   Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h
   Change "logical" to "bitwise" throughout documentation.
-  Detect and fix attempt to write wrong iCCP profile length.
+  Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244)
 
 Version 1.0.21, 1.2.13 [November 14, 2006]
   Fix potential buffer overflow in sPLT chunk handler.
@@ -2361,7 +2362,7 @@ Version 1.4.0beta72 [August 1, 2009]
 
 Version 1.4.0beta73 [August 1, 2009]
   Reject attempt to write iCCP chunk with negative embedded profile length
-    (JD Chen)
+    (JD Chen) (CVE-2009-5063).
 
 Version 1.4.0beta74 [August 8, 2009]
   Changed png_ptr and info_ptr member "trans" to "trans_alpha".
@@ -2935,7 +2936,7 @@ Version 1.5.0beta36 [July 29, 2010]
     PNG_INTERLACE transform and to get the number of rows in the current
     pass.
   A new test program, pngvalid.c, validates the gamma code.
-  Errors in the 16 bit gamma correction (overflows) have been corrected.
+  Errors in the 16-bit gamma correction (overflows) have been corrected.
   cHRM chunk testing is done consistently (previously the floating point
     API bypassed it, because the test really didn't work on FP, now the test
     is performed on the actual values to be stored in the PNG file so it
@@ -3149,8 +3150,8 @@ version 1.5.1beta01 [January 8, 2011]
     in version 1.5.0beta36 but is not noted in the CHANGES.  Similarly,
     it was changed from png_charpp to png_const_bytepp in png_set_iCCP().
   Ensure that png_rgb_to_gray ignores palette mapped images, if libpng
-    internally happens to call it with one.
-  Fixed a failure to handle palette mapped images correctly.
+    internally happens to call it with one, and fixed a failure to handle
+    palette mapped images correctly.  This fixes CVE-2690.
 
 Version 1.5.1beta02 [January 14, 2011]
   Fixed a bug in handling of interlaced images (bero at arklinux.org).
@@ -3208,9 +3209,9 @@ Version 1.5.1beta09 [January 24, 2011]
     pngvalid contains tests of transforms, which tests are currently disabled
     because they are incompletely tested.  gray_to_rgb was failing to expand
     the bit depth for smaller bit depth images; this seems to be a long
-    standing error and resulted, apparently, in invalid output.  The
-    documentation did not accurately describe what libpng really does when
-    converting RGB to gray.
+    standing error and resulted, apparently, in invalid output
+    (CVE-2011-0408, CERT VU#643140).  The documentation did not accurately
+    describe what libpng really does when converting RGB to gray.
 
 Version 1.5.1beta10 [January 27, 2010]
   Fixed incorrect examples of callback prototypes in the manual, that were
@@ -3227,7 +3228,7 @@ Version 1.5.1beta10 [January 27, 2010]
 Version 1.5.1beta11 [January 28, 2011]
   Changed PNG_UNUSED from "param=param;" to "{if(param){}}".
   Corrected local variable type in new API png_process_data_skip()
-    The type was self-evidently incorrect but only causes problems on 64 bit
+    The type was self-evidently incorrect but only causes problems on 64-bit
     architectures.
   Added transform tests to pngvalid and simplified the arguments.
 
@@ -3285,6 +3286,529 @@ Version 1.5.2rc03 [March 24, 2011]
     to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro).
 
 Version 1.5.2 [March 31, 2011]
+  No changes.
+
+Version 1.5.3beta01 [April 1, 2011]
+  Re-initialize the zlib compressor before compressing non-IDAT chunks.
+  Added API functions (png_set_text_compression_level() and four others) to
+    set parameters for zlib compression of non-IDAT chunks.
+
+Version 1.5.3beta02 [April 3, 2011]
+  Updated scripts/symbols.def with new API functions.
+  Only compile the new zlib re-initializing code when text or iCCP is
+    supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro.
+  Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03).
+  Optimize the zlib CMF byte in non-IDAT compressed chunks
+
+Version 1.5.3beta03 [April 16, 2011]
+  Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have
+    snprintf, and the "__STRICT_ANSI__" detects that condition more reliably
+    than __STDC__ (John Bowler).
+  Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells
+    the compiler that a user supplied callback (the error handler) does not
+    return, yet there is no guarantee in practice that the application code
+    will correctly implement the error handler because the compiler only
+    issues a warning if there is a mistake (John Bowler).
+  Removed the no-longer-used PNG_DEPSTRUCT macro.
+  Updated the zlib version to 1.2.5 in the VStudio project.
+  Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in
+    pngwutil.c (John Bowler).
+  Fixed bug with stripping the filler or alpha channel when writing, that
+    was introduced in libpng-1.5.2beta01 (bug report by Andrew Church).
+
+Version 1.5.3beta04 [April 27, 2011]
+  Updated pngtest.png with the new zlib CMF optimization.
+  Cleaned up conditional compilation code and of background/gamma handling
+    Internal changes only except a new option to avoid compiling the
+    png_build_grayscale_palette API (which is not used at all internally.)
+    The main change is to move the transform tests (READ_TRANSFORMS,
+    WRITE_TRANSFORMS) up one level to the caller of the APIs.  This avoids
+    calls to spurious functions if all transforms are disabled and slightly
+    simplifies those functions.  Pngvalid modified to handle this.
+    A minor change is to stop the strip_16 and expand_16 interfaces from
+    disabling each other; this allows the future alpha premultiplication
+    code to use 16-bit intermediate values while still producing 8-bit output.
+    png_do_background and png_do_gamma have been simplified to take a single
+    pointer to the png_struct rather than pointers to every item required
+    from the png_struct. This makes no practical difference to the internal
+    code.
+  A serious bug in the pngvalid internal routine 'standard_display_init' has
+    been fixed - this failed to initialize the red channel and accidentally
+    initialized the alpha channel twice.
+  Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to
+    avoid a possible clash with the png_jmpbuf macro on some platforms.
+
+Version 1.5.3beta05 [May 6, 2011]
+  Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the
+    correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and
+    pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs.
+  Removed png_snprintf and added formatted warning messages.  This change adds
+    internal APIs to allow png_warning messages to have parameters without
+    requiring the host OS to implement snprintf.  As a side effect the
+    dependency of the tIME-supporting RFC1132 code on stdio is removed and
+    PNG_NO_WARNINGS does actually work now.
+  Pass "" instead of '\0' to png_default_error() in png_err().  This mistake
+    was introduced in libpng-1.2.20beta01.  This fixes CVE-2011-2691.
+  Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
+    optimization configureable.
+  IDAT compression failed if preceded by a compressed text chunk (bug
+    introduced in libpng-1.5.3beta01-02).  This was because the attempt to
+    reset the zlib stream in png_write_IDAT happened after the first IDAT
+    chunk had been deflated - much too late.  In this change internal
+    functions were added to claim/release the z_stream and, hopefully, make
+    the code more robust.  Also deflateEnd checking is added - previously
+    libpng would ignore an error at the end of the stream.
+
+Version 1.5.3beta06 [May 8, 2011]
+  Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt
+  Implemented premultiplied alpha support: png_set_alpha_mode API
+
+Version 1.5.3beta07 [May 11, 2011]
+  Added expand_16 support to the high level interface.
+  Added named value and 'flag' gamma support to png_set_gamma.  Made a minor
+    change from the previous (unreleased) ABI/API to hide the exact value used
+    for Macs - it's not a good idea to embed this in the ABI!
+  Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT
+    from pngpriv.h to png.h because they must be visible to applications
+    that call png_set_unknown_chunks().
+  Check for up->location !PNG_AFTER_IDAT when writing unknown chunks
+    before IDAT.
+
+Version 1.5.3beta08 [May 16, 2011]
+  Improved "pngvalid --speed" to exclude more of pngvalid from the time.
+  Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt
+  The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative
+    parameters are supplied by the caller), while in the absence of cHRM
+    sRGB/Rec 709 values are still used.  This introduced a divide-by-zero
+    bug in png_handle_cHRM().
+  The bKGD chunk no longer overwrites the background value set by
+    png_set_background(), allowing the latter to be used before the file
+    header is read. It never performed any useful function to override
+    the default anyway.
+  Added memory overwrite and palette image checks to pngvalid.c
+    Previously palette image code was poorly checked. Since the transformation
+    code has a special palette path in most cases this was a severe weakness.
+  Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When
+    expanding an indexed image, always expand to RGBA if transparency is
+    present.
+
+Version 1.5.3beta09 [May 17, 2011]
+  Reversed earlier 1.5.3 change of transformation order; move png_expand_16
+    back where it was.  The change doesn't work because it requires 16-bit
+    gamma tables when the code only generates 8-bit ones.  This fails
+    silently; the libpng code just doesn't do any gamma correction.  Moving
+    the tests back leaves the old, inaccurate, 8-bit gamma calculations, but
+    these are clearly better than none!
+
+Version 1.5.3beta10 [May 20, 2011]
+
+  png_set_background() and png_expand_16() did not work together correctly.
+    This problem is present in 1.5.2; if png_set_background is called with
+    need_expand false and the matching 16 bit color libpng erroneously just
+    treats it as an 8-bit color because of where png_do_expand_16 is in the
+    transform list.  This simple fix reduces the supplied colour to 8-bits,
+    so it gets smashed, but this is better than the current behavior.
+  Added tests for expand16, more fixes for palette image tests to pngvalid.
+    Corrects the code for palette image tests and disables attempts to
+    validate palette colors.
+
+Version 1.5.3rc01 [June 3, 2011]
+  No changes.
+
+Version 1.5.3rc02 [June 8, 2011]
+  Fixed uninitialized memory read in png_format_buffer() (Bug report by
+    Frank Busse, CVE-2011-2501, related to CVE-2004-0421).
+
+Version 1.5.3beta11 [June 11, 2011]
+  Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692.
+  Added sCAL to pngtest.png
+  Revised documentation about png_set_user_limits() to say that it also affects
+    png writing.
+  Revised handling of png_set_user_limits() so that it can increase the
+    limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only
+    reduce it.
+  Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is
+    wrong (high by one) 25% of the time. Dividing by 257 with rounding is
+    wrong in 128 out of 65536 cases. Getting the right answer all the time
+    without division is easy.
+  Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro.
+  Added projects/owatcom, an IDE project for OpenWatcom to replace
+    scripts/makefile.watcom.  This project works with OpenWatcom 1.9. The
+    IDE autogenerates appropriate makefiles (libpng.mk) for batch processing.
+    The project is configurable, unlike the Visual Studio project, so long
+    as the developer has an awk.
+  Changed png_set_gAMA to limit the gamma value range so that the inverse
+    of the stored value cannot overflow the fixed point representation,
+    and changed other things OpenWatcom warns about.
+  Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows
+    pngvalid to build when ALPHA_MODE is not supported, which is required if
+    it is to build on libpng 1.4.
+  Removed string/memory macros that are no longer used and are not
+    necessarily fully supportable, particularly png_strncpy and png_snprintf.
+  Added log option to pngvalid.c and attempted to improve gamma messages.
+
+Version 1.5.3 [omitted]
+  People found the presence of a beta release following an rc release
+    to be confusing; therefore we bump the version to libpng-1.5.4beta01
+    and there will be no libpng-1.5.3 release.
+
+Version 1.5.4beta01 [June 14, 2011]
+  Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
+    to get the same (inaccurate) output as libpng-1.5.2 and earlier.
+  Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE
+    outside of an unknown-chunk block in png.h because they are also
+    needed for other uses.
+
+Version 1.5.4beta02 [June 14, 2011]
+  Fixed and clarified LEGACY 16-to-8 scaling code.
+  Added png_set_chop_16() API, to match inaccurate results from previous
+    libpng versions.
+  Removed the ACCURATE and LEGACY options (they are no longer useable)
+  Use the old scaling method for background if png_set_chop_16() was
+    called.
+  Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED
+
+Version 1.5.4beta03 [June 15, 2011]
+  Fixed a problem in png_do_expand_palette() exposed by optimization in
+    1.5.3beta06
+  Also removed a spurious and confusing "trans" member ("trans") from png_info.
+  The palette expand optimization prevented expansion to an intermediate RGBA
+    form if tRNS was present but alpha was marked to be stripped; this exposed
+    a check for tRNS in png_do_expand_palette() which is inconsistent with the
+    code elsewhere in libpng.
+  Correction to the expand_16 code; removed extra instance of
+    png_set_scale_16_to_8 from pngpriv.h
+
+Version 1.5.4beta04 [June 16, 2011]
+  Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c
+  Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms.
+  Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again.  If this is
+    not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built.
+  Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8
+
+Version 1.5.4beta05 [June 16, 2011]
+  Renamed png_set_strip_16() to png_set_scale_16() and renamed
+    png_set_chop_16() to png_set_strip(16) in an attempt to minimize the
+    behavior changes between libpng14 and libpng15.
+
+Version 1.5.4beta06 [June 18, 2011]
+  Fixed new bug that was causing both strip_16 and scale_16 to be applied.
+
+Version 1.5.4beta07 [June 19, 2011]
+  Fixed pngvalid, simplified macros, added checking for 0 in sCAL.
+    The ACCURATE scale macro is no longer defined in 1.5 - call the
+    png_scale_16_to_8 API.  Made sure that PNG_READ_16_TO_8 is still defined
+    if the png_strip_16_to_8 API is present.  png_check_fp_number now
+    maintains some state so that positive, negative and zero values are
+    identified.  sCAL uses these to be strictly spec conformant.
+
+Version 1.5.4beta08 [June 23, 2011]
+  Fixed pngvalid if ACCURATE_SCALE is defined.
+  Updated scripts/pnglibconf.h.prebuilt.
+
+Version 1.5.4rc01 [June 30, 2011]
+  Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400.
+
+Version 1.5.4 [July 7, 2011]
+  No changes.
+
+Version 1.5.5beta01 [July 13, 2011]
+  Fixed some typos and made other minor changes in the manual.
+  Updated contrib/pngminus/makefile.std (Samuli Souminen)
+
+Version 1.5.5beta02 [July 14, 2011]
+  Revised Makefile.am and Makefile.in to look in the right directory for
+    pnglibconf.h.prebuilt
+
+Version 1.5.5beta03 [July 27, 2011]
+  Enabled compilation with g++ compiler.  This compiler does not recognize
+    the file extension, so it always compiles with C++ rules.  Made minor
+    changes to pngrutil.c to cast results where C++ expects it but C does not.
+  Minor editing of libpng.3 and libpng-manual.txt.
+
+Version 1.5.5beta04 [July 29, 2011]
+  Revised CMakeLists.txt (Clifford Yapp)
+  Updated commentary about the png_rgb_to_gray() default coefficients
+    in the manual and in pngrtran.c
+
+Version 1.5.5beta05 [August 17, 2011]
+  Prevent unexpected API exports from non-libpng DLLs on Windows.  The "_DLL"
+    is removed from the test of whether a DLL is being built (this erroneously
+    caused the libpng APIs to be marked as DLL exports in static builds under
+    Microsoft Visual Studio).  Almost all of the libpng building configuration
+    is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in
+    pngconf.h, though, so that it is colocated with the import definition (it
+    is no longer used anywhere in the installed headers).  The VStudio project
+    definitions have been cleaned up: "_USRDLL" has been removed from the
+    static library builds (this was incorrect), and PNG_USE_DLL has been added
+    to pngvalid to test the functionality (pngtest does not supply it,
+    deliberately).  The spurious "_EXPORTS" has been removed from the
+    libpng build (all these errors were a result of copy/paste between project
+    configurations.)
+  Added new types and internal functions for CIE RGB end point handling to
+    pngpriv.h (functions yet to be implemented).
+
+Version 1.5.5beta06 [August 26, 2011]
+  Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt
+    (Clifford Yap)
+  Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler):
+    The rgb_to_gray code had errors when combined with gamma correction.
+    Some pixels were treated as true grey when they weren't and such pixels
+    and true grey ones were not gamma corrected (the original value of the
+    red component was used instead).  APIs to get and set cHRM using color
+    space end points have been added and the rgb_to_gray code that defaults
+    based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT
+    VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected.
+  A considerable number of tests has been added to pngvalid for the
+    rgb_to_gray transform.
+  Arithmetic errors in rgb_to_gray whereby the calculated gray value was
+    truncated to the bit depth rather than rounded have been fixed except in
+    the 8-bit non-gamma-corrected case (where consistency seems more important
+    than correctness.)  The code still has considerable inaccuracies in the
+    8-bit case because 8-bit linear arithmetic is used.
+
+Version 1.5.5beta07 [September 7, 2011]
+  Added "$(ARCH)" option to makefile.darwin
+  Added SunOS support to configure.ac and Makefile.am
+  Changed png_chunk_benign_error() to png_warning() in png.c, in
+    png_XYZ_from_xy_checked().
+
+Version 1.5.5beta08 [September 10, 2011]
+  Fixed 64-bit compilation errors (gcc). The errors fixed relate
+    to conditions where types that are 32 bits in the GCC 32-bit
+    world (uLong and png_size_t) become 64 bits in the 64-bit
+    world.  This produces potential truncation errors which the
+    compiler correctly flags.
+  Relocated new HAVE_SOLARIS_LD definition in configure.ac
+  Constant changes for 64-bit compatibility (removal of L suffixes). The
+    16-bit cases still use "L" as we don't have a 16-bit test system.
+
+Version 1.5.5rc01 [September 15, 2011]
+  Removed "L" suffixes in pngpriv.h
+
+Version 1.5.5 [September 22, 2011]
+  No changes.
+
+Version 1.5.6beta01 [September 22, 2011]
+  Fixed some 64-bit type conversion warnings in pngrtran.c
+  Moved row_info from png_struct to a local variable.
+  The various interlace mask arrays have been made into arrays of
+    bytes and made PNG_CONST and static (previously some arrays were
+    marked PNG_CONST and some weren't).
+  Additional checks have been added to the transform code to validate the
+    pixel depths after the transforms on both read and write.
+  Removed some redundant code from pngwrite.c, in png_destroy_write_struct().
+  Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4].
+    This removes the need to allocate temporary strings for chunk names on
+    the stack in the read/write code.  Unknown chunk handling still uses the
+    string form because this is exposed in the API.
+
+Version 1.5.6beta02 [September 26, 2011]
+  Added a note in the manual the png_read_update_info() must be called only
+    once with a particular info_ptr.
+  Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro.
+
+Version 1.5.6beta03 [September 28, 2011]
+  Revised test-pngtest.sh to report FAIL when pngtest fails.
+  Added "--strict" option to pngtest, to report FAIL when the failure is
+    only because the resulting valid files are different.
+  Revised CMakeLists.txt to work with mingw and removed some material from
+    CMakeLists.txt that is no longer useful in libpng-1.5.
+
+Version 1.5.6beta04 [October 5, 2011]
+  Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")."
+
+Version 1.5.6beta05 [October 12, 2011]
+  Speed up png_combine_row() for interlaced images. This reduces the generality
+    of the code, allowing it to be optimized for Adam7 interlace.  The masks
+    passed to png_combine_row() are now generated internally, avoiding
+    some code duplication and localizing the interlace handling somewhat.
+  Align png_struct::row_buf - previously it was always unaligned, caused by
+    a bug in the code that attempted to align it; the code needs to subtract
+    one from the pointer to take account of the filter byte prepended to
+    each row.
+  Optimized png_combine_row() when rows are aligned. This gains a small
+    percentage for 16-bit and 32-bit pixels in the typical case where the
+    output row buffers are appropriately aligned. The optimization was not
+    previously possible because the png_struct buffer was always misaligned.
+  Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01.
+
+Version 1.5.6beta06 [October 17, 2011]
+  Removed two redundant tests for unitialized row.
+  Fixed a relatively harmless memory overwrite in compressed text writing
+    with a 1 byte zlib buffer.
+  Add ability to call png_read_update_info multiple times to pngvalid.c.
+  Fixes for multiple calls to png_read_update_info. These fixes attend to
+    most of the errors revealed in pngvalid, however doing the gamma work
+    twice results in inaccuracies that can't be easily fixed.  There is now
+    a warning in the code if this is going to happen.
+  Turned on multiple png_read_update_info in pngvalid transform tests.
+  Prevent libpng from overwriting unused bits at the end of the image when
+    it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would
+    overwrite the partial byte at the end of each row if the row width was not
+    an exact multiple of 8 bits and the image is not interlaced.
+
+Version 1.5.6beta07 [October 21, 2011]
+  Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row
+    (Mans Rullgard).
+
+Version 1.5.6rc01 [October 26, 2011]
+  Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM"
+
+Version 1.5.6rc02 [October 27, 2011]
+  Added LSR() macro to defend against buggy compilers that evaluate non-taken
+    code branches and complain about out-of-range shifts.
+
+Version 1.5.6rc03 [October 28, 2011]
+  Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro.
+  Fixed compiler warnings with Intel and MSYS compilers. The logical shift
+    fix for Microsoft Visual C is required by other compilers, so this
+    enables that fix for all compilers when using compile-time constants.
+    Under MSYS 'byte' is a name declared in a system header file, so we
+    changed the name of a local variable to avoid the warnings that result.
+  Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h
+
+Version 1.5.6 [November 3, 2011]
+  No changes.
+
+Version 1.5.7beta01 [November 4, 2011]
+  Added support for ARM processor (Mans Rullgard)
+  Fixed bug in pngvalid on early allocation failure; fixed type cast in
+    pngmem.c; pngvalid would attempt to call png_error() if the allocation
+    of a png_struct or png_info failed. This would probably have led to a
+    crash.  The pngmem.c implementation of png_malloc() included a cast
+    to png_size_t which would fail on large allocations on 16-bit systems.
+  Fix for the preprocessor of the Intel C compiler. The preprocessor
+    splits adjacent @ signs with a space; this changes the concatentation
+    token from @-@-@ to PNG_JOIN; that should work with all compiler
+    preprocessors.
+  Paeth filter speed improvements from work by Siarhei Siamashka. This
+    changes the 'Paeth' reconstruction function to improve the GCC code
+    generation on x86. The changes are only part of the suggested ones;
+    just the changes that definitely improve speed and remain simple.
+    The changes also slightly increase the clarity of the code.
+
+Version 1.5.7beta02 [November 11, 2011]
+  Check compression_type parameter in png_get_iCCP and remove spurious
+    casts. The compression_type parameter is always assigned to, so must
+    be non-NULL. The cast of the profile length potentially truncated the
+    value unnecessarily on a 16-bit int system, so the cast of the (byte)
+    compression type to (int) is specified by ANSI-C anyway.
+  Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left
+    the sBIT fields in the test pixel as 0, which resulted in a floating
+    point division by zero which was irrelevant but causes systems where
+    FP exceptions cause a crash. Added code to pngvalid to turn on FP
+    exceptions if the appropriate glibc support is there to ensure this is
+    tested in the future.
+  Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the
+    new PNG_JOIN macro.
+  Added versioning to pnglibconf.h comments.
+  Simplified read/write API initial version; basic read/write tested on
+    a variety of images, limited documentation (in the header file.)
+  Installed more accurate linear to sRGB conversion tables. The slightly
+    modified tables reduce the number of 16-bit values that
+    convert to an off-by-one 8-bit value.  The "makesRGB.c" code that was used
+    to generate the tables is now in a contrib/sRGBtables sub-directory.
+
+Version 1.5.7beta03 [November 17, 2011]
+  Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c
+  Added run-time detection of NEON support.
+  Added contrib/libtests; includes simplified API test and timing test and
+    a color conversion utility for rapid checking of failed 'pngstest' results.
+  Multiple transform bug fixes plus a work-round for double gamma correction.
+    libpng does not support more than one transform that requires linear data
+    at once - if this is tried typically the results is double gamma
+    correction. Since the simplified APIs can need rgb to gray combined with
+    a compose operation it is necessary to do one of these outside the main
+    libpng transform code. This check-in also contains fixes to various bugs
+    in the simplified APIs themselves and to some bugs in compose and rgb to
+    gray (on palette) itself.
+  Fixes for C++ compilation using g++ When libpng source is compiled
+    using g++. The compiler imposes C++ rules on the C source; thus it
+    is desireable to make the source work with either C or C++ rules
+    without throwing away useful error information.  This change adds
+    png_voidcast to allow C semantic (void*) cases or the corresponding
+    C++ static_cast operation, as appropriate.
+  Added --noexecstack to assembler file compilation. GCC does not set
+    this on assembler compilation, even though it does on C compilation.
+    This creates security issues if assembler code is enabled; the
+    work-around is to set it by default in the flags for $(CCAS)
+  Work around compilers that don't support declaration of const data. Some
+    compilers fault 'extern const' data declarations (because the data is
+    not initialized); this turns on const-ness only for compilers where
+    this is known to work.
+
+Version 1.5.7beta04 [November 17, 2011]
+  Since the gcc driver does not recognize the --noexecstack flag, we must
+    use the -Wa prefix to have it passed through to the assembler.
+    Also removed a duplicate setting of this flag.
+  Added files that were omitted from the libpng-1.5.7beta03 zip distribution.
+
+Version 1.5.7beta05 [November 25, 2011]
+  Removed "zTXt" from warning in generic chunk decompression function.
+  Validate time settings passed to pngset() and png_convert_to_rfc1123()
+    (Frank Busse).
+  Added MINGW support to CMakeLists.txt
+  Reject invalid compression flag or method when reading the iTXt chunk.
+  Backed out 'simplified' API changes. The API seems too complex and there
+    is a lack of consensus or enthusiasm for the proposals.  The API also
+    reveals significant bugs inside libpng (double gamma correction and the
+    known bug of being unable to retrieve a corrected palette). It seems
+    better to wait until the bugs, at least, are corrected.
+  Moved pngvalid.c into contrib/libtests
+  Rebuilt Makefile.in, configure, etc., with autoconf-2.68
+
+Version 1.5.7rc01 [December 1, 2011]
+  Replaced an "#if" with "#ifdef" in pngrtran.c
+  Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else)
+
+Version 1.5.7rc02 [December 5, 2011]
+  Revised project files and contrib/pngvalid/pngvalid.c to account for
+    the relocation of pngvalid into contrib/libtests.
+  Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400,
+    as in libpng-1.5.4.
+  Put CRLF line endings in the owatcom project files.
+
+Version 1.5.7rc03 [December 7, 2011]
+  Updated CMakeLists.txt to account for the relocation of pngvalid.c
+
+Version 1.5.7 [December 15, 2011]
+  Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings
+    reported by earlier versions.
+
+Version 1.5.8beta01 [January 15, 2011]
+  Removed '#include config.h"' from contrib/libtests/pngvalid.c.  It's not
+    needed and causes trouble for VPATH building.
+  Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
+    location in configure.ac (Gilles Espinasse).
+  Fix bug in pngerror.c: some long warnings were being improperly truncated
+    (CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
+
+Version 1.5.8rc01 [January 21, 2012]
+  No changes.
+
+Version 1.5.8rc02 [January 25, 2012]
+  Fixed Min/GW uninstall to remove libpng.dll.a
+  Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt
+
+Version 1.5.8 [February 1, 2012]
+  No changes.
+
+Version 1.5.9beta01 [February 3, 2012]
+  Rebuilt configure scripts in the tar distributions.
+
+Version 1.5.9beta02 [February 16, 2012]
+  Removed two unused definitions from scripts/pnglibconf.h.prebuilt
+  Removed some unused arrays (with #ifdef) from png_read_push_finish_row().
+  Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h
+
+Version 1.5.9rc01 [February 17, 2012]
+  Fixed CVE-2011-3026 buffer overrun bug.  Deal more correctly with the test
+    on iCCP chunk length. Also removed spurious casts that may hide problems
+    on 16-bit systems.
+
+Version 1.5.9 [February 18, 2012]
+  No changes.
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
@@ -3293,5 +3817,4 @@ to subscribe)
 or to glennrp at users.sourceforge.net
 
 Glenn R-P
-*/ }
 #endif
index 6e4808cc0bc2df01d16b6c43c544814e5fb31fd5..dd43d3bf2c4c4c7d9a117270f7f6bd7a4a1768ad 100644 (file)
@@ -10,7 +10,7 @@ this sentence.
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.5.2, March 31, 2011, are
+libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are
 Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-March 31, 2011
+February 18, 2012
index 6a7cb33b212a4c7745aae7fbb06b8d7d355cbf31..ac682fecc55491cdfb18b0837023f56cf2501bc1 100644 (file)
@@ -1,4 +1,4 @@
-README for libpng version 1.5.2 - March 31, 2011 (shared library 15.0)
+README for libpng version 1.5.9 - February 18, 2012 (shared library 15.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -114,19 +114,16 @@ given in previous versions of this document.  He and Andreas will
 read mail addressed to the png-implement list, however.
 
 Please do not send general questions about PNG.  Send them to
-the (png-list at ccrc.wustl.edu, subscription required, write to
-majordomo at ccrc.wustl.edu with "subscribe png-list" in your message).
-On the other hand,
-please do not send libpng questions to that address, send them to me
-or to the png-implement list.  I'll
-get them in the end anyway.  If you have a question about something
+png-mng-misc at lists.sf.net (subscription required; visit
+https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
+subscribe).  If you have a question about something
 in the PNG specification that is related to using libpng, send it
 to me.  Send me any questions that start with "I was using libpng,
 and ...".  If in doubt, send questions to me.  I'll bounce them
 to others, if necessary.
 
 Please do not send suggestions on how to change PNG.  We have
-been discussing PNG for nine years now, and it is official and
+been discussing PNG for sixteen years now, and it is official and
 finished.  If you have suggestions for libpng, however, I'll
 gladly listen.  Even if your suggestion is not used immediately,
 it may be used later.
diff --git a/thirdparty/libpng/libpng.txt b/thirdparty/libpng/libpng.txt
deleted file mode 100644 (file)
index dbd7e3b..0000000
+++ /dev/null
@@ -1,3352 +0,0 @@
-libpng.txt - A description on how to use and modify libpng
-
- libpng version 1.4.4 - September 23, 2010
- Updated and distributed by Glenn Randers-Pehrson
- <glennrp at users.sourceforge.net>
- Copyright (c) 1998-2010 Glenn Randers-Pehrson
-
- This document is released under the libpng license.
- For conditions of distribution and use, see the disclaimer
- and license in png.h
-
- Based on:
-
- libpng versions 0.97, January 1998, through 1.4.4 - September 23, 2010
- Updated and distributed by Glenn Randers-Pehrson
- Copyright (c) 1998-2010 Glenn Randers-Pehrson
-
- libpng 1.0 beta 6  version 0.96 May 28, 1997
- Updated and distributed by Andreas Dilger
- Copyright (c) 1996, 1997 Andreas Dilger
-
- libpng 1.0 beta 2 - version 0.88  January 26, 1996
- For conditions of distribution and use, see copyright
- notice in png.h. Copyright (c) 1995, 1996 Guy Eric
- Schalnat, Group 42, Inc.
-
- Updated/rewritten per request in the libpng FAQ
- Copyright (c) 1995, 1996 Frank J. T. Wojcik
- December 18, 1995 & January 20, 1996
-
-I. Introduction
-
-This file describes how to use and modify the PNG reference library
-(known as libpng) for your own use.  There are five sections to this
-file: introduction, structures, reading, writing, and modification and
-configuration notes for various special platforms.  In addition to this
-file, example.c is a good starting point for using the library, as
-it is heavily commented and should include everything most people
-will need.  We assume that libpng is already installed; see the
-INSTALL file for instructions on how to install libpng.
-
-For examples of libpng usage, see the files "example.c", "pngtest.c",
-and the files in the "contrib" directory, all of which are included in
-the libpng distribution.
-
-Libpng was written as a companion to the PNG specification, as a way
-of reducing the amount of time and effort it takes to support the PNG
-file format in application programs.
-
-The PNG specification (second edition), November 2003, is available as
-a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
-<http://www.w3.org/TR/2003/REC-PNG-20031110/
-The W3C and ISO documents have identical technical content.
-
-The PNG-1.2 specification is available at
-<http://www.libpng.org/pub/png/documents/>.  It is technically equivalent
-to the PNG specification (second edition) but has some additional material.
-
-The PNG-1.0 specification is available
-as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
-W3C Recommendation <http://www.w3.org/TR/REC.png.html>.
-
-Some additional chunks are described in the special-purpose public chunks
-documents at <http://www.libpng.org/pub/png/documents/>.
-
-Other information
-about PNG, and the latest version of libpng, can be found at the PNG home
-page, <http://www.libpng.org/pub/png/>.
-
-Most users will not have to modify the library significantly; advanced
-users may want to modify it more.  All attempts were made to make it as
-complete as possible, while keeping the code easy to understand.
-Currently, this library only supports C.  Support for other languages
-is being considered.
-
-Libpng has been designed to handle multiple sessions at one time,
-to be easily modifiable, to be portable to the vast majority of
-machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy
-to use.  The ultimate goal of libpng is to promote the acceptance of
-the PNG file format in whatever way possible.  While there is still
-work to be done (see the TODO file), libpng should cover the
-majority of the needs of its users.
-
-Libpng uses zlib for its compression and decompression of PNG files.
-Further information about zlib, and the latest version of zlib, can
-be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>.
-The zlib compression utility is a general purpose utility that is
-useful for more than PNG files, and can be used without libpng.
-See the documentation delivered with zlib for more details.
-You can usually find the source files for the zlib utility wherever you
-find the libpng source files.
-
-Libpng is thread safe, provided the threads are using different
-instances of the structures.  Each thread should have its own
-png_struct and png_info instances, and thus its own image.
-Libpng does not protect itself against two threads using the
-same instance of a structure.
-
-II. Structures
-
-There are two main structures that are important to libpng, png_struct
-and png_info.  The first, png_struct, is an internal structure that
-will not, for the most part, be used by a user except as the first
-variable passed to every libpng function call.
-
-The png_info structure is designed to provide information about the
-PNG file.  At one time, the fields of png_info were intended to be
-directly accessible to the user.  However, this tended to cause problems
-with applications using dynamically loaded libraries, and as a result
-a set of interface functions for png_info (the png_get_*() and png_set_*()
-functions) was developed.  The fields of png_info are still available for
-older applications, but it is suggested that applications use the new
-interfaces if at all possible.
-
-Applications that do make direct access to the members of png_struct (except
-for png_ptr->jmpbuf) must be recompiled whenever the library is updated,
-and applications that make direct access to the members of png_info must
-be recompiled if they were compiled or loaded with libpng version 1.0.6,
-in which the members were in a different order.  In version 1.0.7, the
-members of the png_info structure reverted to the old order, as they were
-in versions 0.97c through 1.0.5.  Starting with version 2.0.0, both
-structures are going to be hidden, and the contents of the structures will
-only be accessible through the png_get/png_set functions.
-
-The png.h header file is an invaluable reference for programming with libpng.
-And while I'm on the topic, make sure you include the libpng header file:
-
-#include <png.h>
-
-III. Reading
-
-We'll now walk you through the possible functions to call when reading
-in a PNG file sequentially, briefly explaining the syntax and purpose
-of each one.  See example.c and png.h for more detail.  While
-progressive reading is covered in the next section, you will still
-need some of the functions discussed in this section to read a PNG
-file.
-
-Setup
-
-You will want to do the I/O initialization(*) before you get into libpng,
-so if it doesn't work, you don't have much to undo.  Of course, you
-will also want to insure that you are, in fact, dealing with a PNG
-file.  Libpng provides a simple check to see if a file is a PNG file.
-To use it, pass in the first 1 to 8 bytes of the file to the function
-png_sig_cmp(), and it will return 0 (false) if the bytes match the
-corresponding bytes of the PNG signature, or nonzero (true) otherwise.
-Of course, the more bytes you pass in, the greater the accuracy of the
-prediction.
-
-If you are intending to keep the file pointer open for use in libpng,
-you must ensure you don't read more than 8 bytes from the beginning
-of the file, and you also have to make a call to png_set_sig_bytes_read()
-with the number of bytes you read from the beginning.  Libpng will
-then only check the bytes (if any) that your program didn't read.
-
-(*): If you are not using the standard I/O functions, you will need
-to replace them with custom functions.  See the discussion under
-Customizing libpng.
-
-
-    FILE *fp = fopen(file_name, "rb");
-    if (!fp)
-    {
-        return (ERROR);
-    }
-    fread(header, 1, number, fp);
-    is_png = !png_sig_cmp(header, 0, number);
-    if (!is_png)
-    {
-        return (NOT_PNG);
-    }
-
-
-Next, png_struct and png_info need to be allocated and initialized.  In
-order to ensure that the size of these structures is correct even with a
-dynamically linked libpng, there are functions to initialize and
-allocate the structures.  We also pass the library version, optional
-pointers to error handling functions, and a pointer to a data struct for
-use by the error functions, if necessary (the pointer and functions can
-be NULL if the default error handlers are to be used).  See the section
-on Changes to Libpng below regarding the old initialization functions.
-The structure allocation functions quietly return NULL if they fail to
-create the structure, so your application should check for that.
-
-    png_structp png_ptr = png_create_read_struct
-       (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
-        user_error_fn, user_warning_fn);
-    if (!png_ptr)
-        return (ERROR);
-
-    png_infop info_ptr = png_create_info_struct(png_ptr);
-    if (!info_ptr)
-    {
-        png_destroy_read_struct(&png_ptr,
-           (png_infopp)NULL, (png_infopp)NULL);
-        return (ERROR);
-    }
-
-    png_infop end_info = png_create_info_struct(png_ptr);
-    if (!end_info)
-    {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
-          (png_infopp)NULL);
-        return (ERROR);
-    }
-
-If you want to use your own memory allocation routines,
-define PNG_USER_MEM_SUPPORTED and use
-png_create_read_struct_2() instead of png_create_read_struct():
-
-    png_structp png_ptr = png_create_read_struct_2
-       (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
-        user_error_fn, user_warning_fn, (png_voidp)
-        user_mem_ptr, user_malloc_fn, user_free_fn);
-
-The error handling routines passed to png_create_read_struct()
-and the memory alloc/free routines passed to png_create_struct_2()
-are only necessary if you are not using the libpng supplied error
-handling and memory alloc/free functions.
-
-When libpng encounters an error, it expects to longjmp back
-to your routine.  Therefore, you will need to call setjmp and pass
-your png_jmpbuf(png_ptr).  If you read the file from different
-routines, you will need to update the jmpbuf field every time you enter
-a new routine that will call a png_*() function.
-
-See your documentation of setjmp/longjmp for your compiler for more
-information on setjmp/longjmp.  See the discussion on libpng error
-handling in the Customizing Libpng section below for more information
-on the libpng error handling.  If an error occurs, and libpng longjmp's
-back to your setjmp, you will want to call png_destroy_read_struct() to
-free any memory.
-
-    if (setjmp(png_jmpbuf(png_ptr)))
-    {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
-           &end_info);
-        fclose(fp);
-        return (ERROR);
-    }
-
-If you would rather avoid the complexity of setjmp/longjmp issues,
-you can compile libpng with PNG_NO_SETJMP, in which case
-errors will result in a call to PNG_ABORT() which defaults to abort().
-
-You can #define PNG_ABORT() to a function that does something
-more useful than abort(), as long as your function does not
-return.
-
-Now you need to set up the input code.  The default for libpng is to
-use the C function fread().  If you use this, you will need to pass a
-valid FILE * in the function png_init_io().  Be sure that the file is
-opened in binary mode.  If you wish to handle reading data in another
-way, you need not call the png_init_io() function, but you must then
-implement the libpng I/O methods discussed in the Customizing Libpng
-section below.
-
-    png_init_io(png_ptr, fp);
-
-If you had previously opened the file and read any of the signature from
-the beginning in order to see if this was a PNG file, you need to let
-libpng know that there are some bytes missing from the start of the file.
-
-    png_set_sig_bytes(png_ptr, number);
-
-You can change the zlib compression buffer size to be used while
-reading compressed data with
-
-    png_set_compression_buffer_size(png_ptr, buffer_size);
-
-where the default size is 8192 bytes.  Note that the buffer size
-is changed immediately and the buffer is reallocated immediately,
-instead of setting a flag to be acted upon later.
-
-Setting up callback code
-
-You can set up a callback function to handle any unknown chunks in the
-input stream. You must supply the function
-
-    read_chunk_callback(png_ptr ptr,
-         png_unknown_chunkp chunk);
-    {
-       /* The unknown chunk structure contains your
-          chunk data, along with similar data for any other
-          unknown chunks: */
-
-           png_byte name[5];
-           png_byte *data;
-           png_size_t size;
-
-       /* Note that libpng has already taken care of
-          the CRC handling */
-
-       /* put your code here.  Search for your chunk in the
-          unknown chunk structure, process it, and return one
-          of the following: */
-
-       return (-n); /* chunk had an error */
-       return (0); /* did not recognize */
-       return (n); /* success */
-    }
-
-(You can give your function another name that you like instead of
-"read_chunk_callback")
-
-To inform libpng about your function, use
-
-    png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr,
-        read_chunk_callback);
-
-This names not only the callback function, but also a user pointer that
-you can retrieve with
-
-    png_get_user_chunk_ptr(png_ptr);
-
-If you call the png_set_read_user_chunk_fn() function, then all unknown
-chunks will be saved when read, in case your callback function will need
-one or more of them.  This behavior can be changed with the
-png_set_keep_unknown_chunks() function, described below.
-
-At this point, you can set up a callback function that will be
-called after each row has been read, which you can use to control
-a progress meter or the like.  It's demonstrated in pngtest.c.
-You must supply a function
-
-    void read_row_callback(png_ptr ptr, png_uint_32 row,
-       int pass);
-    {
-      /* put your code here */
-    }
-
-(You can give it another name that you like instead of "read_row_callback")
-
-To inform libpng about your function, use
-
-    png_set_read_status_fn(png_ptr, read_row_callback);
-
-Unknown-chunk handling
-
-Now you get to set the way the library processes unknown chunks in the
-input PNG stream. Both known and unknown chunks will be read.  Normal
-behavior is that known chunks will be parsed into information in
-various info_ptr members while unknown chunks will be discarded. This
-behavior can be wasteful if your application will never use some known
-chunk types. To change this, you can call:
-
-    png_set_keep_unknown_chunks(png_ptr, keep,
-        chunk_list, num_chunks);
-    keep       - 0: default unknown chunk handling
-                 1: ignore; do not keep
-                 2: keep only if safe-to-copy
-                 3: keep even if unsafe-to-copy
-               You can use these definitions:
-                 PNG_HANDLE_CHUNK_AS_DEFAULT   0
-                 PNG_HANDLE_CHUNK_NEVER        1
-                 PNG_HANDLE_CHUNK_IF_SAFE      2
-                 PNG_HANDLE_CHUNK_ALWAYS       3
-    chunk_list - list of chunks affected (a byte string,
-                 five bytes per chunk, NULL or '\0' if
-                 num_chunks is 0)
-    num_chunks - number of chunks affected; if 0, all
-                 unknown chunks are affected.  If nonzero,
-                 only the chunks in the list are affected
-
-Unknown chunks declared in this way will be saved as raw data onto a
-list of png_unknown_chunk structures.  If a chunk that is normally
-known to libpng is named in the list, it will be handled as unknown,
-according to the "keep" directive.  If a chunk is named in successive
-instances of png_set_keep_unknown_chunks(), the final instance will
-take precedence.  The IHDR and IEND chunks should not be named in
-chunk_list; if they are, libpng will process them normally anyway.
-
-Here is an example of the usage of png_set_keep_unknown_chunks(),
-where the private "vpAg" chunk will later be processed by a user chunk
-callback function:
-
-    png_byte vpAg[5]={118, 112,  65, 103, (png_byte) '\0'};
-
-    #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-      png_byte unused_chunks[]=
-      {
-        104,  73,  83,  84, (png_byte) '\0',   /* hIST */
-        105,  84,  88, 116, (png_byte) '\0',   /* iTXt */
-        112,  67,  65,  76, (png_byte) '\0',   /* pCAL */
-        115,  67,  65,  76, (png_byte) '\0',   /* sCAL */
-        115,  80,  76,  84, (png_byte) '\0',   /* sPLT */
-        116,  73,  77,  69, (png_byte) '\0',   /* tIME */
-      };
-    #endif
-
-    ...
-
-    #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-      /* ignore all unknown chunks: */
-      png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
-      /* except for vpAg: */
-      png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
-      /* also ignore unused known chunks: */
-      png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
-         (int)sizeof(unused_chunks)/5);
-    #endif
-
-User limits
-
-The PNG specification allows the width and height of an image to be as
-large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
-Since very few applications really need to process such large images,
-we have imposed an arbitrary 1-million limit on rows and columns.
-Larger images will be rejected immediately with a png_error() call. If
-you wish to override this limit, you can use
-
-   png_set_user_limits(png_ptr, width_max, height_max);
-
-to set your own limits, or use width_max = height_max = 0x7fffffffL
-to allow all valid dimensions (libpng may reject some very large images
-anyway because of potential buffer overflow conditions).
-
-You should put this statement after you create the PNG structure and
-before calling png_read_info(), png_read_png(), or png_process_data().
-If you need to retrieve the limits that are being applied, use
-
-   width_max = png_get_user_width_max(png_ptr);
-   height_max = png_get_user_height_max(png_ptr);
-
-The PNG specification sets no limit on the number of ancillary chunks
-allowed in a PNG datastream.  You can impose a limit on the total number
-of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with
-
-   png_set_chunk_cache_max(png_ptr, user_chunk_cache_max);
-
-where 0x7fffffffL means unlimited.  You can retrieve this limit with
-
-   chunk_cache_max = png_get_chunk_cache_max(png_ptr);
-
-This limit also applies to the number of buffers that can be allocated
-by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks.
-
-You can also set a limit on the amount of memory that a compressed chunk
-other than IDAT can occupy, with
-
-   png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max);
-
-and you can retrieve the limit with
-
-   chunk_malloc_max = png_get_chunk_malloc_max(png_ptr);
-
-Any chunks that would cause either of these limits to be exceeded will
-be ignored.
-
-The high-level read interface
-
-At this point there are two ways to proceed; through the high-level
-read interface, or through a sequence of low-level read operations.
-You can use the high-level interface if (a) you are willing to read
-the entire image into memory, and (b) the input transformations
-you want to do are limited to the following set:
-
-    PNG_TRANSFORM_IDENTITY      No transformation
-    PNG_TRANSFORM_STRIP_16      Strip 16-bit samples to
-                                8 bits
-    PNG_TRANSFORM_STRIP_ALPHA   Discard the alpha channel
-    PNG_TRANSFORM_PACKING       Expand 1, 2 and 4-bit
-                                samples to bytes
-    PNG_TRANSFORM_PACKSWAP      Change order of packed
-                                pixels to LSB first
-    PNG_TRANSFORM_EXPAND        Perform set_expand()
-    PNG_TRANSFORM_INVERT_MONO   Invert monochrome images
-    PNG_TRANSFORM_SHIFT         Normalize pixels to the
-                                sBIT depth
-    PNG_TRANSFORM_BGR           Flip RGB to BGR, RGBA
-                                to BGRA
-    PNG_TRANSFORM_SWAP_ALPHA    Flip RGBA to ARGB or GA
-                                to AG
-    PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity
-                                to transparency
-    PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
-    PNG_TRANSFORM_GRAY_TO_RGB   Expand grayscale samples
-                                to RGB (or GA to RGBA)
-
-(This excludes setting a background color, doing gamma transformation,
-quantizing, and setting filler.)  If this is the case, simply do this:
-
-    png_read_png(png_ptr, info_ptr, png_transforms, NULL)
-
-where png_transforms is an integer containing the bitwise OR of some
-set of transformation flags.  This call is equivalent to png_read_info(),
-followed the set of transformations indicated by the transform mask,
-then png_read_image(), and finally png_read_end().
-
-(The final parameter of this call is not yet used.  Someday it might point
-to transformation parameters required by some future input transform.)
-
-You must use png_transforms and not call any png_set_transform() functions
-when you use png_read_png().
-
-After you have called png_read_png(), you can retrieve the image data
-with
-
-   row_pointers = png_get_rows(png_ptr, info_ptr);
-
-where row_pointers is an array of pointers to the pixel data for each row:
-
-   png_bytep row_pointers[height];
-
-If you know your image size and pixel size ahead of time, you can allocate
-row_pointers prior to calling png_read_png() with
-
-   if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
-      png_error (png_ptr,
-         "Image is too tall to process in memory");
-   if (width > PNG_UINT_32_MAX/pixel_size)
-      png_error (png_ptr,
-         "Image is too wide to process in memory");
-   row_pointers = png_malloc(png_ptr,
-      height*png_sizeof(png_bytep));
-   for (int i=0; i<height, i++)
-      row_pointers[i]=NULL;  /* security precaution */
-   for (int i=0; i<height, i++)
-      row_pointers[i]=png_malloc(png_ptr,
-         width*pixel_size);
-   png_set_rows(png_ptr, info_ptr, &row_pointers);
-
-Alternatively you could allocate your image in one big block and define
-row_pointers[i] to point into the proper places in your block.
-
-If you use png_set_rows(), the application is responsible for freeing
-row_pointers (and row_pointers[i], if they were separately allocated).
-
-If you don't allocate row_pointers ahead of time, png_read_png() will
-do it, and it'll be free'ed when you call png_destroy_*().
-
-The low-level read interface
-
-If you are going the low-level route, you are now ready to read all
-the file information up to the actual image data.  You do this with a
-call to png_read_info().
-
-    png_read_info(png_ptr, info_ptr);
-
-This will process all chunks up to but not including the image data.
-
-Querying the info structure
-
-Functions are used to get the information from the info_ptr once it
-has been read.  Note that these fields may not be completely filled
-in until png_read_end() has read the chunk data following the image.
-
-    png_get_IHDR(png_ptr, info_ptr, &width, &height,
-       &bit_depth, &color_type, &interlace_type,
-       &compression_type, &filter_method);
-
-    width          - holds the width of the image
-                     in pixels (up to 2^31).
-    height         - holds the height of the image
-                     in pixels (up to 2^31).
-    bit_depth      - holds the bit depth of one of the
-                     image channels.  (valid values are
-                     1, 2, 4, 8, 16 and depend also on
-                     the color_type.  See also
-                     significant bits (sBIT) below).
-    color_type     - describes which color/alpha channels
-                         are present.
-                     PNG_COLOR_TYPE_GRAY
-                        (bit depths 1, 2, 4, 8, 16)
-                     PNG_COLOR_TYPE_GRAY_ALPHA
-                        (bit depths 8, 16)
-                     PNG_COLOR_TYPE_PALETTE
-                        (bit depths 1, 2, 4, 8)
-                     PNG_COLOR_TYPE_RGB
-                        (bit_depths 8, 16)
-                     PNG_COLOR_TYPE_RGB_ALPHA
-                        (bit_depths 8, 16)
-
-                     PNG_COLOR_MASK_PALETTE
-                     PNG_COLOR_MASK_COLOR
-                     PNG_COLOR_MASK_ALPHA
-
-    filter_method  - (must be PNG_FILTER_TYPE_BASE
-                     for PNG 1.0, and can also be
-                     PNG_INTRAPIXEL_DIFFERENCING if
-                     the PNG datastream is embedded in
-                     a MNG-1.0 datastream)
-    compression_type - (must be PNG_COMPRESSION_TYPE_BASE
-                     for PNG 1.0)
-    interlace_type - (PNG_INTERLACE_NONE or
-                     PNG_INTERLACE_ADAM7)
-
-    Any or all of interlace_type, compression_type, or
-    filter_method can be NULL if you are
-    not interested in their values.
-
-    Note that png_get_IHDR() returns 32-bit data into
-    the application's width and height variables.
-    This is an unsafe situation if these are 16-bit
-    variables.  In such situations, the
-    png_get_image_width() and png_get_image_height()
-    functions described below are safer.
-
-    width            = png_get_image_width(png_ptr,
-                         info_ptr);
-    height           = png_get_image_height(png_ptr,
-                         info_ptr);
-    bit_depth        = png_get_bit_depth(png_ptr,
-                         info_ptr);
-    color_type       = png_get_color_type(png_ptr,
-                         info_ptr);
-    filter_method    = png_get_filter_type(png_ptr,
-                         info_ptr);
-    compression_type = png_get_compression_type(png_ptr,
-                         info_ptr);
-    interlace_type   = png_get_interlace_type(png_ptr,
-                         info_ptr);
-
-    channels = png_get_channels(png_ptr, info_ptr);
-    channels       - number of channels of info for the
-                     color type (valid values are 1 (GRAY,
-                     PALETTE), 2 (GRAY_ALPHA), 3 (RGB),
-                     4 (RGB_ALPHA or RGB + filler byte))
-    rowbytes = png_get_rowbytes(png_ptr, info_ptr);
-    rowbytes       - number of bytes needed to hold a row
-
-    signature = png_get_signature(png_ptr, info_ptr);
-    signature      - holds the signature read from the
-                     file (if any).  The data is kept in
-                     the same offset it would be if the
-                     whole signature were read (i.e. if an
-                     application had already read in 4
-                     bytes of signature before starting
-                     libpng, the remaining 4 bytes would
-                     be in signature[4] through signature[7]
-                     (see png_set_sig_bytes())).
-
-These are also important, but their validity depends on whether the chunk
-has been read.  The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
-png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
-data has been read, or zero if it is missing.  The parameters to the
-png_get_<chunk> are set directly if they are simple data types, or a
-pointer into the info_ptr is returned for any complex types.
-
-    png_get_PLTE(png_ptr, info_ptr, &palette,
-                     &num_palette);
-    palette        - the palette for the file
-                     (array of png_color)
-    num_palette    - number of entries in the palette
-
-    png_get_gAMA(png_ptr, info_ptr, &gamma);
-    gamma          - the gamma the file is written
-                     at (PNG_INFO_gAMA)
-
-    png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
-    srgb_intent    - the rendering intent (PNG_INFO_sRGB)
-                     The presence of the sRGB chunk
-                     means that the pixel data is in the
-                     sRGB color space.  This chunk also
-                     implies specific values of gAMA and
-                     cHRM.
-
-    png_get_iCCP(png_ptr, info_ptr, &name,
-       &compression_type, &profile, &proflen);
-    name            - The profile name.
-    compression     - The compression type; always
-                      PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
-                      You may give NULL to this argument to
-                      ignore it.
-    profile         - International Color Consortium color
-                      profile data. May contain NULs.
-    proflen         - length of profile data in bytes.
-
-    png_get_sBIT(png_ptr, info_ptr, &sig_bit);
-    sig_bit        - the number of significant bits for
-                     (PNG_INFO_sBIT) each of the gray,
-                     red, green, and blue channels,
-                     whichever are appropriate for the
-                     given color type (png_color_16)
-
-    png_get_tRNS(png_ptr, info_ptr, &trans_alpha,
-                     &num_trans, &trans_color);
-    trans_alpha    - array of alpha (transparency)
-                     entries for palette (PNG_INFO_tRNS)
-    trans_color    - graylevel or color sample values of
-                     the single transparent color for
-                     non-paletted images (PNG_INFO_tRNS)
-    num_trans      - number of transparent entries
-                     (PNG_INFO_tRNS)
-
-    png_get_hIST(png_ptr, info_ptr, &hist);
-                     (PNG_INFO_hIST)
-    hist           - histogram of palette (array of
-                     png_uint_16)
-
-    png_get_tIME(png_ptr, info_ptr, &mod_time);
-    mod_time       - time image was last modified
-                    (PNG_VALID_tIME)
-
-    png_get_bKGD(png_ptr, info_ptr, &background);
-    background     - background color (PNG_VALID_bKGD)
-                     valid 16-bit red, green and blue
-                     values, regardless of color_type
-
-    num_comments   = png_get_text(png_ptr, info_ptr,
-                     &text_ptr, &num_text);
-    num_comments   - number of comments
-    text_ptr       - array of png_text holding image
-                     comments
-    text_ptr[i].compression - type of compression used
-                 on "text" PNG_TEXT_COMPRESSION_NONE
-                           PNG_TEXT_COMPRESSION_zTXt
-                           PNG_ITXT_COMPRESSION_NONE
-                           PNG_ITXT_COMPRESSION_zTXt
-    text_ptr[i].key   - keyword for comment.  Must contain
-                         1-79 characters.
-    text_ptr[i].text  - text comments for current
-                         keyword.  Can be empty.
-    text_ptr[i].text_length - length of text string,
-                 after decompression, 0 for iTXt
-    text_ptr[i].itxt_length - length of itxt string,
-                 after decompression, 0 for tEXt/zTXt
-    text_ptr[i].lang  - language of comment (empty
-                         string for unknown).
-    text_ptr[i].lang_key  - keyword in UTF-8
-                         (empty string for unknown).
-    Note that the itxt_length, lang, and lang_key
-    members of the text_ptr structure only exist
-    when the library is built with iTXt chunk support.
-
-    num_text       - number of comments (same as
-                     num_comments; you can put NULL here
-                     to avoid the duplication)
-    Note while png_set_text() will accept text, language,
-    and translated keywords that can be NULL pointers, the
-    structure returned by png_get_text will always contain
-    regular zero-terminated C strings.  They might be
-    empty strings but they will never be NULL pointers.
-
-    num_spalettes = png_get_sPLT(png_ptr, info_ptr,
-       &palette_ptr);
-    palette_ptr    - array of palette structures holding
-                     contents of one or more sPLT chunks
-                     read.
-    num_spalettes  - number of sPLT chunks read.
-
-    png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
-       &unit_type);
-    offset_x       - positive offset from the left edge
-                     of the screen
-    offset_y       - positive offset from the top edge
-                     of the screen
-    unit_type      - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
-
-    png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
-       &unit_type);
-    res_x          - pixels/unit physical resolution in
-                     x direction
-    res_y          - pixels/unit physical resolution in
-                     x direction
-    unit_type      - PNG_RESOLUTION_UNKNOWN,
-                     PNG_RESOLUTION_METER
-
-    png_get_sCAL(png_ptr, info_ptr, &unit, &width,
-       &height)
-    unit        - physical scale units (an integer)
-    width       - width of a pixel in physical scale units
-    height      - height of a pixel in physical scale units
-                 (width and height are doubles)
-
-    png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
-       &height)
-    unit        - physical scale units (an integer)
-    width       - width of a pixel in physical scale units
-    height      - height of a pixel in physical scale units
-                 (width and height are strings like "2.54")
-
-    num_unknown_chunks = png_get_unknown_chunks(png_ptr,
-       info_ptr, &unknowns)
-    unknowns          - array of png_unknown_chunk
-                        structures holding unknown chunks
-    unknowns[i].name  - name of unknown chunk
-    unknowns[i].data  - data of unknown chunk
-    unknowns[i].size  - size of unknown chunk's data
-    unknowns[i].location - position of chunk in file
-
-    The value of "i" corresponds to the order in which the
-    chunks were read from the PNG file or inserted with the
-    png_set_unknown_chunks() function.
-
-The data from the pHYs chunk can be retrieved in several convenient
-forms:
-
-    res_x = png_get_x_pixels_per_meter(png_ptr,
-       info_ptr)
-    res_y = png_get_y_pixels_per_meter(png_ptr,
-       info_ptr)
-    res_x_and_y = png_get_pixels_per_meter(png_ptr,
-       info_ptr)
-    res_x = png_get_x_pixels_per_inch(png_ptr,
-       info_ptr)
-    res_y = png_get_y_pixels_per_inch(png_ptr,
-       info_ptr)
-    res_x_and_y = png_get_pixels_per_inch(png_ptr,
-       info_ptr)
-    aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
-       info_ptr)
-
-   (Each of these returns 0 [signifying "unknown"] if
-       the data is not present or if res_x is 0;
-       res_x_and_y is 0 if res_x != res_y)
-
-The data from the oFFs chunk can be retrieved in several convenient
-forms:
-
-    x_offset = png_get_x_offset_microns(png_ptr, info_ptr);
-    y_offset = png_get_y_offset_microns(png_ptr, info_ptr);
-    x_offset = png_get_x_offset_inches(png_ptr, info_ptr);
-    y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
-
-   (Each of these returns 0 [signifying "unknown" if both
-       x and y are 0] if the data is not present or if the
-       chunk is present but the unit is the pixel)
-
-For more information, see the png_info definition in png.h and the
-PNG specification for chunk contents.  Be careful with trusting
-rowbytes, as some of the transformations could increase the space
-needed to hold a row (expand, filler, gray_to_rgb, etc.).
-See png_read_update_info(), below.
-
-A quick word about text_ptr and num_text.  PNG stores comments in
-keyword/text pairs, one pair per chunk, with no limit on the number
-of text chunks, and a 2^31 byte limit on their size.  While there are
-suggested keywords, there is no requirement to restrict the use to these
-strings.  It is strongly suggested that keywords and text be sensible
-to humans (that's the point), so don't use abbreviations.  Non-printing
-symbols are not allowed.  See the PNG specification for more details.
-There is also no requirement to have text after the keyword.
-
-Keywords should be limited to 79 Latin-1 characters without leading or
-trailing spaces, but non-consecutive spaces are allowed within the
-keyword.  It is possible to have the same keyword any number of times.
-The text_ptr is an array of png_text structures, each holding a
-pointer to a language string, a pointer to a keyword and a pointer to
-a text string.  The text string, language code, and translated
-keyword may be empty or NULL pointers.  The keyword/text
-pairs are put into the array in the order that they are received.
-However, some or all of the text chunks may be after the image, so, to
-make sure you have read all the text chunks, don't mess with these
-until after you read the stuff after the image.  This will be
-mentioned again below in the discussion that goes with png_read_end().
-
-Input transformations
-
-After you've read the header information, you can set up the library
-to handle any special transformations of the image data.  The various
-ways to transform the data will be described in the order that they
-should occur.  This is important, as some of these change the color
-type and/or bit depth of the data, and some others only work on
-certain color types and bit depths.  Even though each transformation
-checks to see if it has data that it can do something with, you should
-make sure to only enable a transformation if it will be valid for the
-data.  For example, don't swap red and blue on grayscale data.
-
-The colors used for the background and transparency values should be
-supplied in the same format/depth as the current image data.  They
-are stored in the same format/depth as the image data in a bKGD or tRNS
-chunk, so this is what libpng expects for this data.  The colors are
-transformed to keep in sync with the image data when an application
-calls the png_read_update_info() routine (see below).
-
-Data will be decoded into the supplied row buffers packed into bytes
-unless the library has been told to transform it into another format.
-For example, 4 bit/pixel paletted or grayscale data will be returned
-2 pixels/byte with the leftmost pixel in the high-order bits of the
-byte, unless png_set_packing() is called.  8-bit RGB data will be stored
-in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
-is called to insert filler bytes, either before or after each RGB triplet.
-16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
-byte of the color value first, unless png_set_strip_16() is called to
-transform it to regular RGB RGB triplets, or png_set_filler() or
-png_set_add alpha() is called to insert filler bytes, either before or
-after each RRGGBB triplet.  Similarly, 8-bit or 16-bit grayscale data can
-be modified with
-png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
-
-The following code transforms grayscale images of less than 8 to 8 bits,
-changes paletted images to RGB, and adds a full alpha channel if there is
-transparency information in a tRNS chunk.  This is most useful on
-grayscale images with bit depths of 2 or 4 or if there is a multiple-image
-viewing application that wishes to treat all images in the same way.
-
-    if (color_type == PNG_COLOR_TYPE_PALETTE)
-        png_set_palette_to_rgb(png_ptr);
-
-    if (color_type == PNG_COLOR_TYPE_GRAY &&
-        bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);
-
-    if (png_get_valid(png_ptr, info_ptr,
-        PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
-
-These three functions are actually aliases for png_set_expand(), added
-in libpng version 1.0.4, with the function names expanded to improve code
-readability.  In some future version they may actually do different
-things.
-
-As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
-added.  It expands the sample depth without changing tRNS to alpha.
-
-As of libpng version 1.4.4, not all possible expansions are supported.
-
-In the following table, the 01 means grayscale with depth<8, 31 means
-indexed with depth<8, other numerals represent the color type, "T" means
-the tRNS chunk is present, A means an alpha channel is present, and O
-means tRNS or alpha is present but all pixels in the image are opaque.
-
-  FROM  01  31   0  0T  0O   2  2T  2O   3  3T  3O  4A  4O  6A  6O 
-   TO
-   01    -                   
-   31        -
-    0    1       -           
-   0T                -
-   0O                    -
-    2           GX           -
-   2T                            -
-   2O                                -
-    3        1                           -
-   3T                                        -
-   3O                                            -
-   4A                T                               -
-   4O                                                    -
-   6A               GX         TX           TX               -
-   6O                   GX                      TX               -
-
-Within the matrix,
-     "-" means the transformation is not supported.
-     "X" means the transformation is obtained by png_set_expand().
-     "1" means the transformation is obtained by
-         png_set_expand_gray_1_2_4_to_8
-     "G" means the transformation is obtained by
-         png_set_gray_to_rgb().
-     "P" means the transformation is obtained by
-         png_set_expand_palette_to_rgb().
-     "T" means the transformation is obtained by
-         png_set_tRNS_to_alpha().
-
-PNG can have files with 16 bits per channel.  If you only can handle
-8 bits per channel, this will strip the pixels down to 8 bit.
-
-    if (bit_depth == 16)
-        png_set_strip_16(png_ptr);
-
-If, for some reason, you don't need the alpha channel on an image,
-and you want to remove it rather than combining it with the background
-(but the image author certainly had in mind that you *would* combine
-it with the background, so that's what you should probably do):
-
-    if (color_type & PNG_COLOR_MASK_ALPHA)
-        png_set_strip_alpha(png_ptr);
-
-In PNG files, the alpha channel in an image
-is the level of opacity.  If you need the alpha channel in an image to
-be the level of transparency instead of opacity, you can invert the
-alpha channel (or the tRNS chunk data) after it's read, so that 0 is
-fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
-images) is fully transparent, with
-
-    png_set_invert_alpha(png_ptr);
-
-PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
-they can, resulting in, for example, 8 pixels per byte for 1 bit
-files.  This code expands to 1 pixel per byte without changing the
-values of the pixels:
-
-    if (bit_depth < 8)
-        png_set_packing(png_ptr);
-
-PNG files have possible bit depths of 1, 2, 4, 8, and 16.  All pixels
-stored in a PNG image have been "scaled" or "shifted" up to the next
-higher possible bit depth (e.g. from 5 bits/sample in the range [0,31]
-to 8 bits/sample in the range [0, 255]).  However, it is also possible
-to convert the PNG pixel data back to the original bit depth of the
-image.  This call reduces the pixels back down to the original bit depth:
-
-    png_color_8p sig_bit;
-
-    if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
-        png_set_shift(png_ptr, sig_bit);
-
-PNG files store 3-color pixels in red, green, blue order.  This code
-changes the storage of the pixels to blue, green, red:
-
-    if (color_type == PNG_COLOR_TYPE_RGB ||
-        color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-        png_set_bgr(png_ptr);
-
-PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
-into 4 or 8 bytes for windowing systems that need them in this format:
-
-    if (color_type == PNG_COLOR_TYPE_RGB)
-        png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
-
-where "filler" is the 8 or 16-bit number to fill with, and the location is
-either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
-you want the filler before the RGB or after.  This transformation
-does not affect images that already have full alpha channels.  To add an
-opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
-will generate RGBA pixels.
-
-Note that png_set_filler() does not change the color type.  If you want
-to do that, you can add a true alpha channel with
-
-    if (color_type == PNG_COLOR_TYPE_RGB ||
-           color_type == PNG_COLOR_TYPE_GRAY)
-    png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
-
-where "filler" contains the alpha value to assign to each pixel.
-This function was added in libpng-1.2.7.
-
-If you are reading an image with an alpha channel, and you need the
-data as ARGB instead of the normal PNG format RGBA:
-
-    if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-        png_set_swap_alpha(png_ptr);
-
-For some uses, you may want a grayscale image to be represented as
-RGB.  This code will do that conversion:
-
-    if (color_type == PNG_COLOR_TYPE_GRAY ||
-        color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-          png_set_gray_to_rgb(png_ptr);
-
-Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
-with alpha.
-
-    if (color_type == PNG_COLOR_TYPE_RGB ||
-        color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-          png_set_rgb_to_gray_fixed(png_ptr, error_action,
-             int red_weight, int green_weight);
-
-    error_action = 1: silently do the conversion
-    error_action = 2: issue a warning if the original
-                      image has any pixel where
-                      red != green or red != blue
-    error_action = 3: issue an error and abort the
-                      conversion if the original
-                      image has any pixel where
-                      red != green or red != blue
-
-    red_weight:       weight of red component times 100000
-    green_weight:     weight of green component times 100000
-                      If either weight is negative, default
-                      weights (21268, 71514) are used.
-
-If you have set error_action = 1 or 2, you can
-later check whether the image really was gray, after processing
-the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
-It will return a png_byte that is zero if the image was gray or
-1 if there were any non-gray pixels.  bKGD and sBIT data
-will be silently converted to grayscale, using the green channel
-data, regardless of the error_action setting.
-
-With red_weight+green_weight<=100000,
-the normalized graylevel is computed:
-
-    int rw = red_weight * 65536;
-    int gw = green_weight * 65536;
-    int bw = 65536 - (rw + gw);
-    gray = (rw*red + gw*green + bw*blue)/65536;
-
-The default values approximate those recommended in the Charles
-Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
-Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
-
-    Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
-
-Libpng approximates this with
-
-    Y = 0.21268 * R    + 0.7151 * G    + 0.07217 * B
-
-which can be expressed with integers as
-
-    Y = (6969 * R + 23434 * G + 2365 * B)/32768
-
-The calculation is done in a linear colorspace, if the image gamma
-is known.
-
-If you have a grayscale and you are using png_set_expand_depth(),
-png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
-a higher bit-depth, you must either supply the background color as a gray
-value at the original file bit-depth (need_expand = 1) or else supply the
-background color as an RGB triplet at the final, expanded bit depth
-(need_expand = 0).  Similarly, if you are reading a paletted image, you
-must either supply the background color as a palette index (need_expand = 1)
-or as an RGB triplet that may or may not be in the palette (need_expand = 0).
-
-    png_color_16 my_background;
-    png_color_16p image_background;
-
-    if (png_get_bKGD(png_ptr, info_ptr, &image_background))
-        png_set_background(png_ptr, image_background,
-          PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
-    else
-        png_set_background(png_ptr, &my_background,
-          PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
-
-The png_set_background() function tells libpng to composite images
-with alpha or simple transparency against the supplied background
-color.  If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
-you may use this color, or supply another color more suitable for
-the current display (e.g., the background color from a web page).  You
-need to tell libpng whether the color is in the gamma space of the
-display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
-(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
-that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
-know why anyone would use this, but it's here).
-
-To properly display PNG images on any kind of system, the application needs
-to know what the display gamma is.  Ideally, the user will know this, and
-the application will allow them to set it.  One method of allowing the user
-to set the display gamma separately for each system is to check for a
-SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be
-correctly set.
-
-Note that display_gamma is the overall gamma correction required to produce
-pleasing results, which depends on the lighting conditions in the surrounding
-environment.  In a dim or brightly lit room, no compensation other than
-the physical gamma exponent of the monitor is needed, while in a dark room
-a slightly smaller exponent is better.
-
-   double gamma, screen_gamma;
-
-   if (/* We have a user-defined screen
-       gamma value */)
-   {
-      screen_gamma = user_defined_screen_gamma;
-   }
-   /* One way that applications can share the same
-      screen gamma value */
-   else if ((gamma_str = getenv("SCREEN_GAMMA"))
-      != NULL)
-   {
-      screen_gamma = (double)atof(gamma_str);
-   }
-   /* If we don't have another value */
-   else
-   {
-      screen_gamma = 2.2; /* A good guess for a
-           PC monitor in a bright office or a dim room */
-      screen_gamma = 2.0; /* A good guess for a
-           PC monitor in a dark room */
-      screen_gamma = 1.7 or 1.0;  /* A good
-           guess for Mac systems */
-   }
-
-The png_set_gamma() function handles gamma transformations of the data.
-Pass both the file gamma and the current screen_gamma.  If the file does
-not have a gamma value, you can pass one anyway if you have an idea what
-it is (usually 0.45455 is a good guess for GIF images on PCs).  Note
-that file gammas are inverted from screen gammas.  See the discussions
-on gamma in the PNG specification for an excellent description of what
-gamma is, and why all applications should support it.  It is strongly
-recommended that PNG viewers support gamma correction.
-
-   if (png_get_gAMA(png_ptr, info_ptr, &gamma))
-      png_set_gamma(png_ptr, screen_gamma, gamma);
-   else
-      png_set_gamma(png_ptr, screen_gamma, 0.45455);
-
-If you need to reduce an RGB file to a paletted file, or if a paletted
-file has more entries then will fit on your screen, png_set_quantize()
-will do that.  Note that this is a simple match dither that merely
-finds the closest color available.  This should work fairly well with
-optimized palettes, and fairly badly with linear color cubes.  If you
-pass a palette that is larger then maximum_colors, the file will
-reduce the number of colors in the palette so it will fit into
-maximum_colors.  If there is a histogram, it will use it to make
-more intelligent choices when reducing the palette.  If there is no
-histogram, it may not do as good a job.
-
-   if (color_type & PNG_COLOR_MASK_COLOR)
-   {
-      if (png_get_valid(png_ptr, info_ptr,
-         PNG_INFO_PLTE))
-      {
-         png_uint_16p histogram = NULL;
-
-         png_get_hIST(png_ptr, info_ptr,
-            &histogram);
-         png_set_quantize(png_ptr, palette, num_palette,
-            max_screen_colors, histogram, 1);
-      }
-      else
-      {
-         png_color std_color_cube[MAX_SCREEN_COLORS] =
-            { ... colors ... };
-
-         png_set_quantize(png_ptr, std_color_cube,
-            MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
-            NULL,0);
-      }
-   }
-
-PNG files describe monochrome as black being zero and white being one.
-The following code will reverse this (make black be one and white be
-zero):
-
-   if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
-      png_set_invert_mono(png_ptr);
-
-This function can also be used to invert grayscale and gray-alpha images:
-
-   if (color_type == PNG_COLOR_TYPE_GRAY ||
-        color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-      png_set_invert_mono(png_ptr);
-
-PNG files store 16 bit pixels in network byte order (big-endian,
-ie. most significant bits first).  This code changes the storage to the
-other way (little-endian, i.e. least significant bits first, the
-way PCs store them):
-
-    if (bit_depth == 16)
-        png_set_swap(png_ptr);
-
-If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
-need to change the order the pixels are packed into bytes, you can use:
-
-    if (bit_depth < 8)
-       png_set_packswap(png_ptr);
-
-Finally, you can write your own transformation function if none of
-the existing ones meets your needs.  This is done by setting a callback
-with
-
-    png_set_read_user_transform_fn(png_ptr,
-       read_transform_fn);
-
-You must supply the function
-
-    void read_transform_fn(png_ptr ptr, row_info_ptr
-       row_info, png_bytep data)
-
-See pngtest.c for a working example.  Your function will be called
-after all of the other transformations have been processed.
-
-You can also set up a pointer to a user structure for use by your
-callback function, and you can inform libpng that your transform
-function will change the number of channels or bit depth with the
-function
-
-    png_set_user_transform_info(png_ptr, user_ptr,
-       user_depth, user_channels);
-
-The user's application, not libpng, is responsible for allocating and
-freeing any memory required for the user structure.
-
-You can retrieve the pointer via the function
-png_get_user_transform_ptr().  For example:
-
-    voidp read_user_transform_ptr =
-       png_get_user_transform_ptr(png_ptr);
-
-The last thing to handle is interlacing; this is covered in detail below,
-but you must call the function here if you want libpng to handle expansion
-of the interlaced image.
-
-    number_of_passes = png_set_interlace_handling(png_ptr);
-
-After setting the transformations, libpng can update your png_info
-structure to reflect any transformations you've requested with this
-call.  This is most useful to update the info structure's rowbytes
-field so you can use it to allocate your image memory.  This function
-will also update your palette with the correct screen_gamma and
-background if these have been given with the calls above.
-
-    png_read_update_info(png_ptr, info_ptr);
-
-After you call png_read_update_info(), you can allocate any
-memory you need to hold the image.  The row data is simply
-raw byte data for all forms of images.  As the actual allocation
-varies among applications, no example will be given.  If you
-are allocating one large chunk, you will need to build an
-array of pointers to each row, as it will be needed for some
-of the functions below.
-
-Reading image data
-
-After you've allocated memory, you can read the image data.
-The simplest way to do this is in one function call.  If you are
-allocating enough memory to hold the whole image, you can just
-call png_read_image() and libpng will read in all the image data
-and put it in the memory area supplied.  You will need to pass in
-an array of pointers to each row.
-
-This function automatically handles interlacing, so you don't need
-to call png_set_interlace_handling() or call this function multiple
-times, or any of that other stuff necessary with png_read_rows().
-
-   png_read_image(png_ptr, row_pointers);
-
-where row_pointers is:
-
-   png_bytep row_pointers[height];
-
-You can point to void or char or whatever you use for pixels.
-
-If you don't want to read in the whole image at once, you can
-use png_read_rows() instead.  If there is no interlacing (check
-interlace_type == PNG_INTERLACE_NONE), this is simple:
-
-    png_read_rows(png_ptr, row_pointers, NULL,
-       number_of_rows);
-
-where row_pointers is the same as in the png_read_image() call.
-
-If you are doing this just one row at a time, you can do this with
-a single row_pointer instead of an array of row_pointers:
-
-    png_bytep row_pointer = row;
-    png_read_row(png_ptr, row_pointer, NULL);
-
-If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
-get somewhat harder.  The only current (PNG Specification version 1.2)
-interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
-is a somewhat complicated 2D interlace scheme, known as Adam7, that
-breaks down an image into seven smaller images of varying size, based
-on an 8x8 grid.
-
-libpng can fill out those images or it can give them to you "as is".
-If you want them filled out, there are two ways to do that.  The one
-mentioned in the PNG specification is to expand each pixel to cover
-those pixels that have not been read yet (the "rectangle" method).
-This results in a blocky image for the first pass, which gradually
-smooths out as more pixels are read.  The other method is the "sparkle"
-method, where pixels are drawn only in their final locations, with the
-rest of the image remaining whatever colors they were initialized to
-before the start of the read.  The first method usually looks better,
-but tends to be slower, as there are more pixels to put in the rows.
-
-If you don't want libpng to handle the interlacing details, just call
-png_read_rows() seven times to read in all seven images.  Each of the
-images is a valid image by itself, or they can all be combined on an
-8x8 grid to form a single image (although if you intend to combine them
-you would be far better off using the libpng interlace handling).
-
-The first pass will return an image 1/8 as wide as the entire image
-(every 8th column starting in column 0) and 1/8 as high as the original
-(every 8th row starting in row 0), the second will be 1/8 as wide
-(starting in column 4) and 1/8 as high (also starting in row 0).  The
-third pass will be 1/4 as wide (every 4th pixel starting in column 0) and
-1/8 as high (every 8th row starting in row 4), and the fourth pass will
-be 1/4 as wide and 1/4 as high (every 4th column starting in column 2,
-and every 4th row starting in row 0).  The fifth pass will return an
-image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2),
-while the sixth pass will be 1/2 as wide and 1/2 as high as the original
-(starting in column 1 and row 0).  The seventh and final pass will be as
-wide as the original, and 1/2 as high, containing all of the odd
-numbered scanlines.  Phew!
-
-If you want libpng to expand the images, call this before calling
-png_start_read_image() or png_read_update_info():
-
-    if (interlace_type == PNG_INTERLACE_ADAM7)
-        number_of_passes
-           = png_set_interlace_handling(png_ptr);
-
-This will return the number of passes needed.  Currently, this
-is seven, but may change if another interlace type is added.
-This function can be called even if the file is not interlaced,
-where it will return one pass.
-
-If you are not going to display the image after each pass, but are
-going to wait until the entire image is read in, use the sparkle
-effect.  This effect is faster and the end result of either method
-is exactly the same.  If you are planning on displaying the image
-after each pass, the "rectangle" effect is generally considered the
-better looking one.
-
-If you only want the "sparkle" effect, just call png_read_rows() as
-normal, with the third parameter NULL.  Make sure you make pass over
-the image number_of_passes times, and you don't change the data in the
-rows between calls.  You can change the locations of the data, just
-not the data.  Each pass only writes the pixels appropriate for that
-pass, and assumes the data from previous passes is still valid.
-
-    png_read_rows(png_ptr, row_pointers, NULL,
-       number_of_rows);
-
-If you only want the first effect (the rectangles), do the same as
-before except pass the row buffer in the third parameter, and leave
-the second parameter NULL.
-
-    png_read_rows(png_ptr, NULL, row_pointers,
-       number_of_rows);
-
-Finishing a sequential read
-
-After you are finished reading the image through the
-low-level interface, you can finish reading the file.  If you are
-interested in comments or time, which may be stored either before or
-after the image data, you should pass the separate png_info struct if
-you want to keep the comments from before and after the image
-separate.  If you are not interested, you can pass NULL.
-
-   png_read_end(png_ptr, end_info);
-
-When you are done, you can free all memory allocated by libpng like this:
-
-   png_destroy_read_struct(&png_ptr, &info_ptr,
-       &end_info);
-
-It is also possible to individually free the info_ptr members that
-point to libpng-allocated storage with the following function:
-
-    png_free_data(png_ptr, info_ptr, mask, seq)
-    mask - identifies data to be freed, a mask
-           containing the bitwise OR of one or
-           more of
-             PNG_FREE_PLTE, PNG_FREE_TRNS,
-             PNG_FREE_HIST, PNG_FREE_ICCP,
-             PNG_FREE_PCAL, PNG_FREE_ROWS,
-             PNG_FREE_SCAL, PNG_FREE_SPLT,
-             PNG_FREE_TEXT, PNG_FREE_UNKN,
-           or simply PNG_FREE_ALL
-    seq  - sequence number of item to be freed
-           (-1 for all items)
-
-This function may be safely called when the relevant storage has
-already been freed, or has not yet been allocated, or was allocated
-by the user and not by libpng,  and will in those cases do nothing.
-The "seq" parameter is ignored if only one item of the selected data
-type, such as PLTE, is allowed.  If "seq" is not -1, and multiple items
-are allowed for the data type identified in the mask, such as text or
-sPLT, only the n'th item in the structure is freed, where n is "seq".
-
-The default behavior is only to free data that was allocated internally
-by libpng.  This can be changed, so that libpng will not free the data,
-or so that it will free data that was allocated by the user with png_malloc()
-or png_zalloc() and passed in via a png_set_*() function, with
-
-    png_data_freer(png_ptr, info_ptr, freer, mask)
-    mask   - which data elements are affected
-             same choices as in png_free_data()
-    freer  - one of
-               PNG_DESTROY_WILL_FREE_DATA
-               PNG_SET_WILL_FREE_DATA
-               PNG_USER_WILL_FREE_DATA
-
-This function only affects data that has already been allocated.
-You can call this function after reading the PNG data but before calling
-any png_set_*() functions, to control whether the user or the png_set_*()
-function is responsible for freeing any existing data that might be present,
-and again after the png_set_*() functions to control whether the user
-or png_destroy_*() is supposed to free the data.  When the user assumes
-responsibility for libpng-allocated data, the application must use
-png_free() to free it, and when the user transfers responsibility to libpng
-for data that the user has allocated, the user must have used png_malloc()
-or png_zalloc() to allocate it.
-
-If you allocated your row_pointers in a single block, as suggested above in
-the description of the high level read interface, you must not transfer
-responsibility for freeing it to the png_set_rows or png_read_destroy function,
-because they would also try to free the individual row_pointers[i].
-
-If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
-separately, do not transfer responsibility for freeing text_ptr to libpng,
-because when libpng fills a png_text structure it combines these members with
-the key member, and png_free_data() will free only text_ptr.key.  Similarly,
-if you transfer responsibility for free'ing text_ptr from libpng to your
-application, your application must not separately free those members.
-
-The png_free_data() function will turn off the "valid" flag for anything
-it frees.  If you need to turn the flag off for a chunk that was freed by
-your application instead of by libpng, you can use
-
-    png_set_invalid(png_ptr, info_ptr, mask);
-    mask - identifies the chunks to be made invalid,
-           containing the bitwise OR of one or
-           more of
-             PNG_INFO_gAMA, PNG_INFO_sBIT,
-             PNG_INFO_cHRM, PNG_INFO_PLTE,
-             PNG_INFO_tRNS, PNG_INFO_bKGD,
-             PNG_INFO_hIST, PNG_INFO_pHYs,
-             PNG_INFO_oFFs, PNG_INFO_tIME,
-             PNG_INFO_pCAL, PNG_INFO_sRGB,
-             PNG_INFO_iCCP, PNG_INFO_sPLT,
-             PNG_INFO_sCAL, PNG_INFO_IDAT
-
-For a more compact example of reading a PNG image, see the file example.c.
-
-Reading PNG files progressively
-
-The progressive reader is slightly different then the non-progressive
-reader.  Instead of calling png_read_info(), png_read_rows(), and
-png_read_end(), you make one call to png_process_data(), which calls
-callbacks when it has the info, a row, or the end of the image.  You
-set up these callbacks with png_set_progressive_read_fn().  You don't
-have to worry about the input/output functions of libpng, as you are
-giving the library the data directly in png_process_data().  I will
-assume that you have read the section on reading PNG files above,
-so I will only highlight the differences (although I will show
-all of the code).
-
-png_structp png_ptr;
-png_infop info_ptr;
-
- /*  An example code fragment of how you would
-     initialize the progressive reader in your
-     application. */
- int
- initialize_png_reader()
- {
-    png_ptr = png_create_read_struct
-        (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
-         user_error_fn, user_warning_fn);
-    if (!png_ptr)
-        return (ERROR);
-    info_ptr = png_create_info_struct(png_ptr);
-    if (!info_ptr)
-    {
-        png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
-           (png_infopp)NULL);
-        return (ERROR);
-    }
-
-    if (setjmp(png_jmpbuf(png_ptr)))
-    {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
-           (png_infopp)NULL);
-        return (ERROR);
-    }
-
-    /* This one's new.  You can provide functions
-       to be called when the header info is valid,
-       when each row is completed, and when the image
-       is finished.  If you aren't using all functions,
-       you can specify NULL parameters.  Even when all
-       three functions are NULL, you need to call
-       png_set_progressive_read_fn().  You can use
-       any struct as the user_ptr (cast to a void pointer
-       for the function call), and retrieve the pointer
-       from inside the callbacks using the function
-
-          png_get_progressive_ptr(png_ptr);
-
-       which will return a void pointer, which you have
-       to cast appropriately.
-     */
-    png_set_progressive_read_fn(png_ptr, (void *)user_ptr,
-        info_callback, row_callback, end_callback);
-
-    return 0;
- }
-
- /* A code fragment that you call as you receive blocks
-   of data */
- int
- process_data(png_bytep buffer, png_uint_32 length)
- {
-    if (setjmp(png_jmpbuf(png_ptr)))
-    {
-        png_destroy_read_struct(&png_ptr, &info_ptr,
-           (png_infopp)NULL);
-        return (ERROR);
-    }
-
-    /* This one's new also.  Simply give it a chunk
-       of data from the file stream (in order, of
-       course).  On machines with segmented memory
-       models machines, don't give it any more than
-       64K.  The library seems to run fine with sizes
-       of 4K. Although you can give it much less if
-       necessary (I assume you can give it chunks of
-       1 byte, I haven't tried less then 256 bytes
-       yet).  When this function returns, you may
-       want to display any rows that were generated
-       in the row callback if you don't already do
-       so there.
-     */
-    png_process_data(png_ptr, info_ptr, buffer, length);
-    return 0;
- }
-
- /* This function is called (as set by
-    png_set_progressive_read_fn() above) when enough data
-    has been supplied so all of the header has been
-    read.
- */
- void
- info_callback(png_structp png_ptr, png_infop info)
- {
-    /* Do any setup here, including setting any of
-       the transformations mentioned in the Reading
-       PNG files section.  For now, you _must_ call
-       either png_start_read_image() or
-       png_read_update_info() after all the
-       transformations are set (even if you don't set
-       any).  You may start getting rows before
-       png_process_data() returns, so this is your
-       last chance to prepare for that.
-     */
- }
-
- /* This function is called when each row of image
-    data is complete */
- void
- row_callback(png_structp png_ptr, png_bytep new_row,
-    png_uint_32 row_num, int pass)
- {
-    /* If the image is interlaced, and you turned
-       on the interlace handler, this function will
-       be called for every row in every pass.  Some
-       of these rows will not be changed from the
-       previous pass.  When the row is not changed,
-       the new_row variable will be NULL.  The rows
-       and passes are called in order, so you don't
-       really need the row_num and pass, but I'm
-       supplying them because it may make your life
-       easier.
-
-       For the non-NULL rows of interlaced images,
-       you must call png_progressive_combine_row()
-       passing in the row and the old row.  You can
-       call this function for NULL rows (it will just
-       return) and for non-interlaced images (it just
-       does the memcpy for you) if it will make the
-       code easier.  Thus, you can just do this for
-       all cases:
-     */
-
-        png_progressive_combine_row(png_ptr, old_row,
-          new_row);
-
-    /* where old_row is what was displayed for
-       previously for the row.  Note that the first
-       pass (pass == 0, really) will completely cover
-       the old row, so the rows do not have to be
-       initialized.  After the first pass (and only
-       for interlaced images), you will have to pass
-       the current row, and the function will combine
-       the old row and the new row.
-    */
- }
-
- void
- end_callback(png_structp png_ptr, png_infop info)
- {
-    /* This function is called after the whole image
-       has been read, including any chunks after the
-       image (up to and including the IEND).  You
-       will usually have the same info chunk as you
-       had in the header, although some data may have
-       been added to the comments and time fields.
-
-       Most people won't do much here, perhaps setting
-       a flag that marks the image as finished.
-     */
- }
-
-
-
-IV. Writing
-
-Much of this is very similar to reading.  However, everything of
-importance is repeated here, so you won't have to constantly look
-back up in the reading section to understand writing.
-
-Setup
-
-You will want to do the I/O initialization before you get into libpng,
-so if it doesn't work, you don't have anything to undo. If you are not
-using the standard I/O functions, you will need to replace them with
-custom writing functions.  See the discussion under Customizing libpng.
-
-    FILE *fp = fopen(file_name, "wb");
-    if (!fp)
-    {
-       return (ERROR);
-    }
-
-Next, png_struct and png_info need to be allocated and initialized.
-As these can be both relatively large, you may not want to store these
-on the stack, unless you have stack space to spare.  Of course, you
-will want to check if they return NULL.  If you are also reading,
-you won't want to name your read structure and your write structure
-both "png_ptr"; you can call them anything you like, such as
-"read_ptr" and "write_ptr".  Look at pngtest.c, for example.
-
-    png_structp png_ptr = png_create_write_struct
-       (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
-        user_error_fn, user_warning_fn);
-    if (!png_ptr)
-       return (ERROR);
-
-    png_infop info_ptr = png_create_info_struct(png_ptr);
-    if (!info_ptr)
-    {
-       png_destroy_write_struct(&png_ptr,
-         (png_infopp)NULL);
-       return (ERROR);
-    }
-
-If you want to use your own memory allocation routines,
-define PNG_USER_MEM_SUPPORTED and use
-png_create_write_struct_2() instead of png_create_write_struct():
-
-    png_structp png_ptr = png_create_write_struct_2
-       (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
-        user_error_fn, user_warning_fn, (png_voidp)
-        user_mem_ptr, user_malloc_fn, user_free_fn);
-
-After you have these structures, you will need to set up the
-error handling.  When libpng encounters an error, it expects to
-longjmp() back to your routine.  Therefore, you will need to call
-setjmp() and pass the png_jmpbuf(png_ptr).  If you
-write the file from different routines, you will need to update
-the png_jmpbuf(png_ptr) every time you enter a new routine that will
-call a png_*() function.  See your documentation of setjmp/longjmp
-for your compiler for more information on setjmp/longjmp.  See
-the discussion on libpng error handling in the Customizing Libpng
-section below for more information on the libpng error handling.
-
-    if (setjmp(png_jmpbuf(png_ptr)))
-    {
-       png_destroy_write_struct(&png_ptr, &info_ptr);
-       fclose(fp);
-       return (ERROR);
-    }
-    ...
-    return;
-
-If you would rather avoid the complexity of setjmp/longjmp issues,
-you can compile libpng with PNG_NO_SETJMP, in which case
-errors will result in a call to PNG_ABORT() which defaults to abort().
-
-You can #define PNG_ABORT() to a function that does something
-more useful than abort(), as long as your function does not
-return.
-
-Now you need to set up the output code.  The default for libpng is to
-use the C function fwrite().  If you use this, you will need to pass a
-valid FILE * in the function png_init_io().  Be sure that the file is
-opened in binary mode.  Again, if you wish to handle writing data in
-another way, see the discussion on libpng I/O handling in the Customizing
-Libpng section below.
-
-    png_init_io(png_ptr, fp);
-
-If you are embedding your PNG into a datastream such as MNG, and don't
-want libpng to write the 8-byte signature, or if you have already
-written the signature in your application, use
-
-    png_set_sig_bytes(png_ptr, 8);
-
-to inform libpng that it should not write a signature.
-
-Write callbacks
-
-At this point, you can set up a callback function that will be
-called after each row has been written, which you can use to control
-a progress meter or the like.  It's demonstrated in pngtest.c.
-You must supply a function
-
-    void write_row_callback(png_ptr, png_uint_32 row,
-       int pass);
-    {
-      /* put your code here */
-    }
-
-(You can give it another name that you like instead of "write_row_callback")
-
-To inform libpng about your function, use
-
-    png_set_write_status_fn(png_ptr, write_row_callback);
-
-You now have the option of modifying how the compression library will
-run.  The following functions are mainly for testing, but may be useful
-in some cases, like if you need to write PNG files extremely fast and
-are willing to give up some compression, or if you want to get the
-maximum possible compression at the expense of slower writing.  If you
-have no special needs in this area, let the library do what it wants by
-not calling this function at all, as it has been tuned to deliver a good
-speed/compression ratio. The second parameter to png_set_filter() is
-the filter method, for which the only valid values are 0 (as of the
-July 1999 PNG specification, version 1.2) or 64 (if you are writing
-a PNG datastream that is to be embedded in a MNG datastream).  The third
-parameter is a flag that indicates which filter type(s) are to be tested
-for each scanline.  See the PNG specification for details on the specific
-filter types.
-
-
-    /* turn on or off filtering, and/or choose
-       specific filters.  You can use either a single
-       PNG_FILTER_VALUE_NAME or the bitwise OR of one
-       or more PNG_FILTER_NAME masks. */
-    png_set_filter(png_ptr, 0,
-       PNG_FILTER_NONE  | PNG_FILTER_VALUE_NONE |
-       PNG_FILTER_SUB   | PNG_FILTER_VALUE_SUB  |
-       PNG_FILTER_UP    | PNG_FILTER_VALUE_UP   |
-       PNG_FILTER_AVG   | PNG_FILTER_VALUE_AVG  |
-       PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
-       PNG_ALL_FILTERS);
-
-If an application
-wants to start and stop using particular filters during compression,
-it should start out with all of the filters (to ensure that the previous
-row of pixels will be stored in case it's needed later), and then add
-and remove them after the start of compression.
-
-If you are writing a PNG datastream that is to be embedded in a MNG
-datastream, the second parameter can be either 0 or 64.
-
-The png_set_compression_*() functions interface to the zlib compression
-library, and should mostly be ignored unless you really know what you are
-doing.  The only generally useful call is png_set_compression_level()
-which changes how much time zlib spends on trying to compress the image
-data.  See the Compression Library (zlib.h and algorithm.txt, distributed
-with zlib) for details on the compression levels.
-
-    /* set the zlib compression level */
-    png_set_compression_level(png_ptr,
-        Z_BEST_COMPRESSION);
-
-    /* set other zlib parameters */
-    png_set_compression_mem_level(png_ptr, 8);
-    png_set_compression_strategy(png_ptr,
-        Z_DEFAULT_STRATEGY);
-    png_set_compression_window_bits(png_ptr, 15);
-    png_set_compression_method(png_ptr, 8);
-    png_set_compression_buffer_size(png_ptr, 8192)
-
-extern PNG_EXPORT(void,png_set_zbuf_size)
-
-Setting the contents of info for output
-
-You now need to fill in the png_info structure with all the data you
-wish to write before the actual image.  Note that the only thing you
-are allowed to write after the image is the text chunks and the time
-chunk (as of PNG Specification 1.2, anyway).  See png_write_end() and
-the latest PNG specification for more information on that.  If you
-wish to write them before the image, fill them in now, and flag that
-data as being valid.  If you want to wait until after the data, don't
-fill them until png_write_end().  For all the fields in png_info and
-their data types, see png.h.  For explanations of what the fields
-contain, see the PNG specification.
-
-Some of the more important parts of the png_info are:
-
-    png_set_IHDR(png_ptr, info_ptr, width, height,
-       bit_depth, color_type, interlace_type,
-       compression_type, filter_method)
-    width          - holds the width of the image
-                     in pixels (up to 2^31).
-    height         - holds the height of the image
-                     in pixels (up to 2^31).
-    bit_depth      - holds the bit depth of one of the
-                     image channels.
-                     (valid values are 1, 2, 4, 8, 16
-                     and depend also on the
-                     color_type.  See also significant
-                     bits (sBIT) below).
-    color_type     - describes which color/alpha
-                     channels are present.
-                     PNG_COLOR_TYPE_GRAY
-                        (bit depths 1, 2, 4, 8, 16)
-                     PNG_COLOR_TYPE_GRAY_ALPHA
-                        (bit depths 8, 16)
-                     PNG_COLOR_TYPE_PALETTE
-                        (bit depths 1, 2, 4, 8)
-                     PNG_COLOR_TYPE_RGB
-                        (bit_depths 8, 16)
-                     PNG_COLOR_TYPE_RGB_ALPHA
-                        (bit_depths 8, 16)
-
-                     PNG_COLOR_MASK_PALETTE
-                     PNG_COLOR_MASK_COLOR
-                     PNG_COLOR_MASK_ALPHA
-
-    interlace_type - PNG_INTERLACE_NONE or
-                     PNG_INTERLACE_ADAM7
-    compression_type - (must be
-                     PNG_COMPRESSION_TYPE_DEFAULT)
-    filter_method  - (must be PNG_FILTER_TYPE_DEFAULT
-                     or, if you are writing a PNG to
-                     be embedded in a MNG datastream,
-                     can also be
-                     PNG_INTRAPIXEL_DIFFERENCING)
-
-If you call png_set_IHDR(), the call must appear before any of the
-other png_set_*() functions, because they might require access to some of
-the IHDR settings.  The remaining png_set_*() functions can be called
-in any order.
-
-If you wish, you can reset the compression_type, interlace_type, or
-filter_method later by calling png_set_IHDR() again; if you do this, the
-width, height, bit_depth, and color_type must be the same in each call.
-
-    png_set_PLTE(png_ptr, info_ptr, palette,
-       num_palette);
-    palette        - the palette for the file
-                     (array of png_color)
-    num_palette    - number of entries in the palette
-
-    png_set_gAMA(png_ptr, info_ptr, gamma);
-    gamma          - the gamma the image was created
-                     at (PNG_INFO_gAMA)
-
-    png_set_sRGB(png_ptr, info_ptr, srgb_intent);
-    srgb_intent    - the rendering intent
-                     (PNG_INFO_sRGB) The presence of
-                     the sRGB chunk means that the pixel
-                     data is in the sRGB color space.
-                     This chunk also implies specific
-                     values of gAMA and cHRM.  Rendering
-                     intent is the CSS-1 property that
-                     has been defined by the International
-                     Color Consortium
-                     (http://www.color.org).
-                     It can be one of
-                     PNG_sRGB_INTENT_SATURATION,
-                     PNG_sRGB_INTENT_PERCEPTUAL,
-                     PNG_sRGB_INTENT_ABSOLUTE, or
-                     PNG_sRGB_INTENT_RELATIVE.
-
-
-    png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
-       srgb_intent);
-    srgb_intent    - the rendering intent
-                     (PNG_INFO_sRGB) The presence of the
-                     sRGB chunk means that the pixel
-                     data is in the sRGB color space.
-                     This function also causes gAMA and
-                     cHRM chunks with the specific values
-                     that are consistent with sRGB to be
-                     written.
-
-    png_set_iCCP(png_ptr, info_ptr, name, compression_type,
-                      profile, proflen);
-    name            - The profile name.
-    compression     - The compression type; always
-                      PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
-                      You may give NULL to this argument to
-                      ignore it.
-    profile         - International Color Consortium color
-                      profile data. May contain NULs.
-    proflen         - length of profile data in bytes.
-
-    png_set_sBIT(png_ptr, info_ptr, sig_bit);
-    sig_bit        - the number of significant bits for
-                     (PNG_INFO_sBIT) each of the gray, red,
-                     green, and blue channels, whichever are
-                     appropriate for the given color type
-                     (png_color_16)
-
-    png_set_tRNS(png_ptr, info_ptr, trans_alpha,
-       num_trans, trans_color);
-    trans_alpha    - array of alpha (transparency)
-                     entries for palette (PNG_INFO_tRNS)
-    trans_color    - graylevel or color sample values
-                     (in order red, green, blue) of the
-                     single transparent color for
-                     non-paletted images (PNG_INFO_tRNS)
-    num_trans      - number of transparent entries
-                     (PNG_INFO_tRNS)
-
-    png_set_hIST(png_ptr, info_ptr, hist);
-                    (PNG_INFO_hIST)
-    hist           - histogram of palette (array of
-                     png_uint_16)
-
-    png_set_tIME(png_ptr, info_ptr, mod_time);
-    mod_time       - time image was last modified
-                     (PNG_VALID_tIME)
-
-    png_set_bKGD(png_ptr, info_ptr, background);
-    background     - background color (PNG_VALID_bKGD)
-
-    png_set_text(png_ptr, info_ptr, text_ptr, num_text);
-    text_ptr       - array of png_text holding image
-                     comments
-    text_ptr[i].compression - type of compression used
-                 on "text" PNG_TEXT_COMPRESSION_NONE
-                           PNG_TEXT_COMPRESSION_zTXt
-                           PNG_ITXT_COMPRESSION_NONE
-                           PNG_ITXT_COMPRESSION_zTXt
-    text_ptr[i].key   - keyword for comment.  Must contain
-                 1-79 characters.
-    text_ptr[i].text  - text comments for current
-                         keyword.  Can be NULL or empty.
-    text_ptr[i].text_length - length of text string,
-                 after decompression, 0 for iTXt
-    text_ptr[i].itxt_length - length of itxt string,
-                 after decompression, 0 for tEXt/zTXt
-    text_ptr[i].lang  - language of comment (NULL or
-                         empty for unknown).
-    text_ptr[i].translated_keyword  - keyword in UTF-8 (NULL
-                         or empty for unknown).
-    Note that the itxt_length, lang, and lang_key
-    members of the text_ptr structure only exist
-    when the library is built with iTXt chunk support.
-
-    num_text       - number of comments
-
-    png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
-       num_spalettes);
-    palette_ptr    - array of png_sPLT_struct structures
-                     to be added to the list of palettes
-                     in the info structure.
-    num_spalettes  - number of palette structures to be
-                     added.
-
-    png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
-        unit_type);
-    offset_x  - positive offset from the left
-                     edge of the screen
-    offset_y  - positive offset from the top
-                     edge of the screen
-    unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
-
-    png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
-        unit_type);
-    res_x       - pixels/unit physical resolution
-                  in x direction
-    res_y       - pixels/unit physical resolution
-                  in y direction
-    unit_type   - PNG_RESOLUTION_UNKNOWN,
-                  PNG_RESOLUTION_METER
-
-    png_set_sCAL(png_ptr, info_ptr, unit, width, height)
-    unit        - physical scale units (an integer)
-    width       - width of a pixel in physical scale units
-    height      - height of a pixel in physical scale units
-                  (width and height are doubles)
-
-    png_set_sCAL_s(png_ptr, info_ptr, unit, width, height)
-    unit        - physical scale units (an integer)
-    width       - width of a pixel in physical scale units
-    height      - height of a pixel in physical scale units
-                 (width and height are strings like "2.54")
-
-    png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
-       num_unknowns)
-    unknowns          - array of png_unknown_chunk
-                        structures holding unknown chunks
-    unknowns[i].name  - name of unknown chunk
-    unknowns[i].data  - data of unknown chunk
-    unknowns[i].size  - size of unknown chunk's data
-    unknowns[i].location - position to write chunk in file
-                           0: do not write chunk
-                           PNG_HAVE_IHDR: before PLTE
-                           PNG_HAVE_PLTE: before IDAT
-                           PNG_AFTER_IDAT: after IDAT
-
-The "location" member is set automatically according to
-what part of the output file has already been written.
-You can change its value after calling png_set_unknown_chunks()
-as demonstrated in pngtest.c.  Within each of the "locations",
-the chunks are sequenced according to their position in the
-structure (that is, the value of "i", which is the order in which
-the chunk was either read from the input file or defined with
-png_set_unknown_chunks).
-
-A quick word about text and num_text.  text is an array of png_text
-structures.  num_text is the number of valid structures in the array.
-Each png_text structure holds a language code, a keyword, a text value,
-and a compression type.
-
-The compression types have the same valid numbers as the compression
-types of the image data.  Currently, the only valid number is zero.
-However, you can store text either compressed or uncompressed, unlike
-images, which always have to be compressed.  So if you don't want the
-text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
-Because tEXt and zTXt chunks don't have a language field, if you
-specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
-any language code or translated keyword will not be written out.
-
-Until text gets around 1000 bytes, it is not worth compressing it.
-After the text has been written out to the file, the compression type
-is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
-so that it isn't written out again at the end (in case you are calling
-png_write_end() with the same struct.
-
-The keywords that are given in the PNG Specification are:
-
-    Title            Short (one line) title or
-                     caption for image
-    Author           Name of image's creator
-    Description      Description of image (possibly long)
-    Copyright        Copyright notice
-    Creation Time    Time of original image creation
-                     (usually RFC 1123 format, see below)
-    Software         Software used to create the image
-    Disclaimer       Legal disclaimer
-    Warning          Warning of nature of content
-    Source           Device used to create the image
-    Comment          Miscellaneous comment; conversion
-                     from other image format
-
-The keyword-text pairs work like this.  Keywords should be short
-simple descriptions of what the comment is about.  Some typical
-keywords are found in the PNG specification, as is some recommendations
-on keywords.  You can repeat keywords in a file.  You can even write
-some text before the image and some after.  For example, you may want
-to put a description of the image before the image, but leave the
-disclaimer until after, so viewers working over modem connections
-don't have to wait for the disclaimer to go over the modem before
-they start seeing the image.  Finally, keywords should be full
-words, not abbreviations.  Keywords and text are in the ISO 8859-1
-(Latin-1) character set (a superset of regular ASCII) and can not
-contain NUL characters, and should not contain control or other
-unprintable characters.  To make the comments widely readable, stick
-with basic ASCII, and avoid machine specific character set extensions
-like the IBM-PC character set.  The keyword must be present, but
-you can leave off the text string on non-compressed pairs.
-Compressed pairs must have a text string, as only the text string
-is compressed anyway, so the compression would be meaningless.
-
-PNG supports modification time via the png_time structure.  Two
-conversion routines are provided, png_convert_from_time_t() for
-time_t and png_convert_from_struct_tm() for struct tm.  The
-time_t routine uses gmtime().  You don't have to use either of
-these, but if you wish to fill in the png_time structure directly,
-you should provide the time in universal time (GMT) if possible
-instead of your local time.  Note that the year number is the full
-year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
-that months start with 1.
-
-If you want to store the time of the original image creation, you should
-use a plain tEXt chunk with the "Creation Time" keyword.  This is
-necessary because the "creation time" of a PNG image is somewhat vague,
-depending on whether you mean the PNG file, the time the image was
-created in a non-PNG format, a still photo from which the image was
-scanned, or possibly the subject matter itself.  In order to facilitate
-machine-readable dates, it is recommended that the "Creation Time"
-tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
-although this isn't a requirement.  Unlike the tIME chunk, the
-"Creation Time" tEXt chunk is not expected to be automatically changed
-by the software.  To facilitate the use of RFC 1123 dates, a function
-png_convert_to_rfc1123(png_timep) is provided to convert from PNG
-time to an RFC 1123 format string.
-
-Writing unknown chunks
-
-You can use the png_set_unknown_chunks function to queue up chunks
-for writing.  You give it a chunk name, raw data, and a size; that's
-all there is to it.  The chunks will be written by the next following
-png_write_info_before_PLTE, png_write_info, or png_write_end function.
-Any chunks previously read into the info structure's unknown-chunk
-list will also be written out in a sequence that satisfies the PNG
-specification's ordering rules.
-
-The high-level write interface
-
-At this point there are two ways to proceed; through the high-level
-write interface, or through a sequence of low-level write operations.
-You can use the high-level interface if your image data is present
-in the info structure.  All defined output
-transformations are permitted, enabled by the following masks.
-
-    PNG_TRANSFORM_IDENTITY      No transformation
-    PNG_TRANSFORM_PACKING       Pack 1, 2 and 4-bit samples
-    PNG_TRANSFORM_PACKSWAP      Change order of packed
-                                pixels to LSB first
-    PNG_TRANSFORM_INVERT_MONO   Invert monochrome images
-    PNG_TRANSFORM_SHIFT         Normalize pixels to the
-                                sBIT depth
-    PNG_TRANSFORM_BGR           Flip RGB to BGR, RGBA
-                                to BGRA
-    PNG_TRANSFORM_SWAP_ALPHA    Flip RGBA to ARGB or GA
-                                to AG
-    PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity
-                                to transparency
-    PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
-    PNG_TRANSFORM_STRIP_FILLER        Strip out filler
-                                      bytes (deprecated).
-    PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
-                                      filler bytes
-    PNG_TRANSFORM_STRIP_FILLER_AFTER  Strip out trailing
-                                      filler bytes
-
-If you have valid image data in the info structure (you can use
-png_set_rows() to put image data in the info structure), simply do this:
-
-    png_write_png(png_ptr, info_ptr, png_transforms, NULL)
-
-where png_transforms is an integer containing the bitwise OR of some set of
-transformation flags.  This call is equivalent to png_write_info(),
-followed the set of transformations indicated by the transform mask,
-then png_write_image(), and finally png_write_end().
-
-(The final parameter of this call is not yet used.  Someday it might point
-to transformation parameters required by some future output transform.)
-
-You must use png_transforms and not call any png_set_transform() functions
-when you use png_write_png().
-
-The low-level write interface
-
-If you are going the low-level route instead, you are now ready to
-write all the file information up to the actual image data.  You do
-this with a call to png_write_info().
-
-    png_write_info(png_ptr, info_ptr);
-
-Note that there is one transformation you may need to do before
-png_write_info().  In PNG files, the alpha channel in an image is the
-level of opacity.  If your data is supplied as a level of transparency,
-you can invert the alpha channel before you write it, so that 0 is
-fully transparent and 255 (in 8-bit or paletted images) or 65535
-(in 16-bit images) is fully opaque, with
-
-    png_set_invert_alpha(png_ptr);
-
-This must appear before png_write_info() instead of later with the
-other transformations because in the case of paletted images the tRNS
-chunk data has to be inverted before the tRNS chunk is written.  If
-your image is not a paletted image, the tRNS data (which in such cases
-represents a single color to be rendered as transparent) won't need to
-be changed, and you can safely do this transformation after your
-png_write_info() call.
-
-If you need to write a private chunk that you want to appear before
-the PLTE chunk when PLTE is present, you can write the PNG info in
-two steps, and insert code to write your own chunk between them:
-
-    png_write_info_before_PLTE(png_ptr, info_ptr);
-    png_set_unknown_chunks(png_ptr, info_ptr, ...);
-    png_write_info(png_ptr, info_ptr);
-
-After you've written the file information, you can set up the library
-to handle any special transformations of the image data.  The various
-ways to transform the data will be described in the order that they
-should occur.  This is important, as some of these change the color
-type and/or bit depth of the data, and some others only work on
-certain color types and bit depths.  Even though each transformation
-checks to see if it has data that it can do something with, you should
-make sure to only enable a transformation if it will be valid for the
-data.  For example, don't swap red and blue on grayscale data.
-
-PNG files store RGB pixels packed into 3 or 6 bytes.  This code tells
-the library to strip input data that has 4 or 8 bytes per pixel down
-to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
-bytes per pixel).
-
-    png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
-
-where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
-PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
-is stored XRGB or RGBX.
-
-PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
-they can, resulting in, for example, 8 pixels per byte for 1 bit files.
-If the data is supplied at 1 pixel per byte, use this code, which will
-correctly pack the pixels into a single byte:
-
-    png_set_packing(png_ptr);
-
-PNG files reduce possible bit depths to 1, 2, 4, 8, and 16.  If your
-data is of another bit depth, you can write an sBIT chunk into the
-file so that decoders can recover the original data if desired.
-
-    /* Set the true bit depth of the image data */
-    if (color_type & PNG_COLOR_MASK_COLOR)
-    {
-        sig_bit.red = true_bit_depth;
-        sig_bit.green = true_bit_depth;
-        sig_bit.blue = true_bit_depth;
-    }
-    else
-    {
-        sig_bit.gray = true_bit_depth;
-    }
-    if (color_type & PNG_COLOR_MASK_ALPHA)
-    {
-        sig_bit.alpha = true_bit_depth;
-    }
-
-    png_set_sBIT(png_ptr, info_ptr, &sig_bit);
-
-If the data is stored in the row buffer in a bit depth other than
-one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
-this will scale the values to appear to be the correct bit depth as
-is required by PNG.
-
-    png_set_shift(png_ptr, &sig_bit);
-
-PNG files store 16 bit pixels in network byte order (big-endian,
-ie. most significant bits first).  This code would be used if they are
-supplied the other way (little-endian, i.e. least significant bits
-first, the way PCs store them):
-
-    if (bit_depth > 8)
-       png_set_swap(png_ptr);
-
-If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
-need to change the order the pixels are packed into bytes, you can use:
-
-    if (bit_depth < 8)
-       png_set_packswap(png_ptr);
-
-PNG files store 3 color pixels in red, green, blue order.  This code
-would be used if they are supplied as blue, green, red:
-
-    png_set_bgr(png_ptr);
-
-PNG files describe monochrome as black being zero and white being
-one. This code would be used if the pixels are supplied with this reversed
-(black being one and white being zero):
-
-    png_set_invert_mono(png_ptr);
-
-Finally, you can write your own transformation function if none of
-the existing ones meets your needs.  This is done by setting a callback
-with
-
-    png_set_write_user_transform_fn(png_ptr,
-       write_transform_fn);
-
-You must supply the function
-
-    void write_transform_fn(png_ptr ptr, row_info_ptr
-       row_info, png_bytep data)
-
-See pngtest.c for a working example.  Your function will be called
-before any of the other transformations are processed.
-
-You can also set up a pointer to a user structure for use by your
-callback function.
-
-    png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
-
-The user_channels and user_depth parameters of this function are ignored
-when writing; you can set them to zero as shown.
-
-You can retrieve the pointer via the function png_get_user_transform_ptr().
-For example:
-
-    voidp write_user_transform_ptr =
-       png_get_user_transform_ptr(png_ptr);
-
-It is possible to have libpng flush any pending output, either manually,
-or automatically after a certain number of lines have been written.  To
-flush the output stream a single time call:
-
-    png_write_flush(png_ptr);
-
-and to have libpng flush the output stream periodically after a certain
-number of scanlines have been written, call:
-
-    png_set_flush(png_ptr, nrows);
-
-Note that the distance between rows is from the last time png_write_flush()
-was called, or the first row of the image if it has never been called.
-So if you write 50 lines, and then png_set_flush 25, it will flush the
-output on the next scanline, and every 25 lines thereafter, unless
-png_write_flush() is called before 25 more lines have been written.
-If nrows is too small (less than about 10 lines for a 640 pixel wide
-RGB image) the image compression may decrease noticeably (although this
-may be acceptable for real-time applications).  Infrequent flushing will
-only degrade the compression performance by a few percent over images
-that do not use flushing.
-
-Writing the image data
-
-That's it for the transformations.  Now you can write the image data.
-The simplest way to do this is in one function call.  If you have the
-whole image in memory, you can just call png_write_image() and libpng
-will write the image.  You will need to pass in an array of pointers to
-each row.  This function automatically handles interlacing, so you don't
-need to call png_set_interlace_handling() or call this function multiple
-times, or any of that other stuff necessary with png_write_rows().
-
-    png_write_image(png_ptr, row_pointers);
-
-where row_pointers is:
-
-    png_byte *row_pointers[height];
-
-You can point to void or char or whatever you use for pixels.
-
-If you don't want to write the whole image at once, you can
-use png_write_rows() instead.  If the file is not interlaced,
-this is simple:
-
-    png_write_rows(png_ptr, row_pointers,
-       number_of_rows);
-
-row_pointers is the same as in the png_write_image() call.
-
-If you are just writing one row at a time, you can do this with
-a single row_pointer instead of an array of row_pointers:
-
-    png_bytep row_pointer = row;
-
-    png_write_row(png_ptr, row_pointer);
-
-When the file is interlaced, things can get a good deal more complicated.
-The only currently (as of the PNG Specification version 1.2, dated July
-1999) defined interlacing scheme for PNG files is the "Adam7" interlace
-scheme, that breaks down an image into seven smaller images of varying
-size.  libpng will build these images for you, or you can do them
-yourself.  If you want to build them yourself, see the PNG specification
-for details of which pixels to write when.
-
-If you don't want libpng to handle the interlacing details, just
-use png_set_interlace_handling() and call png_write_rows() the
-correct number of times to write all seven sub-images.
-
-If you want libpng to build the sub-images, call this before you start
-writing any rows:
-
-    number_of_passes =
-       png_set_interlace_handling(png_ptr);
-
-This will return the number of passes needed.  Currently, this is seven,
-but may change if another interlace type is added.
-
-Then write the complete image number_of_passes times.
-
-    png_write_rows(png_ptr, row_pointers,
-       number_of_rows);
-
-As some of these rows are not used, and thus return immediately, you may
-want to read about interlacing in the PNG specification, and only update
-the rows that are actually used.
-
-Finishing a sequential write
-
-After you are finished writing the image, you should finish writing
-the file.  If you are interested in writing comments or time, you should
-pass an appropriately filled png_info pointer.  If you are not interested,
-you can pass NULL.
-
-    png_write_end(png_ptr, info_ptr);
-
-When you are done, you can free all memory used by libpng like this:
-
-    png_destroy_write_struct(&png_ptr, &info_ptr);
-
-It is also possible to individually free the info_ptr members that
-point to libpng-allocated storage with the following function:
-
-    png_free_data(png_ptr, info_ptr, mask, seq)
-    mask  - identifies data to be freed, a mask
-            containing the bitwise OR of one or
-            more of
-              PNG_FREE_PLTE, PNG_FREE_TRNS,
-              PNG_FREE_HIST, PNG_FREE_ICCP,
-              PNG_FREE_PCAL, PNG_FREE_ROWS,
-              PNG_FREE_SCAL, PNG_FREE_SPLT,
-              PNG_FREE_TEXT, PNG_FREE_UNKN,
-            or simply PNG_FREE_ALL
-    seq   - sequence number of item to be freed
-            (-1 for all items)
-
-This function may be safely called when the relevant storage has
-already been freed, or has not yet been allocated, or was allocated
-by the user  and not by libpng,  and will in those cases do nothing.
-The "seq" parameter is ignored if only one item of the selected data
-type, such as PLTE, is allowed.  If "seq" is not -1, and multiple items
-are allowed for the data type identified in the mask, such as text or
-sPLT, only the n'th item in the structure is freed, where n is "seq".
-
-If you allocated data such as a palette that you passed in to libpng
-with png_set_*, you must not free it until just before the call to
-png_destroy_write_struct().
-
-The default behavior is only to free data that was allocated internally
-by libpng.  This can be changed, so that libpng will not free the data,
-or so that it will free data that was allocated by the user with png_malloc()
-or png_zalloc() and passed in via a png_set_*() function, with
-
-    png_data_freer(png_ptr, info_ptr, freer, mask)
-    mask   - which data elements are affected
-             same choices as in png_free_data()
-    freer  - one of
-               PNG_DESTROY_WILL_FREE_DATA
-               PNG_SET_WILL_FREE_DATA
-               PNG_USER_WILL_FREE_DATA
-
-For example, to transfer responsibility for some data from a read structure
-to a write structure, you could use
-
-    png_data_freer(read_ptr, read_info_ptr,
-       PNG_USER_WILL_FREE_DATA,
-       PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
-    png_data_freer(write_ptr, write_info_ptr,
-       PNG_DESTROY_WILL_FREE_DATA,
-       PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
-
-thereby briefly reassigning responsibility for freeing to the user but
-immediately afterwards reassigning it once more to the write_destroy
-function.  Having done this, it would then be safe to destroy the read
-structure and continue to use the PLTE, tRNS, and hIST data in the write
-structure.
-
-This function only affects data that has already been allocated.
-You can call this function before calling after the png_set_*() functions
-to control whether the user or png_destroy_*() is supposed to free the data.
-When the user assumes responsibility for libpng-allocated data, the
-application must use
-png_free() to free it, and when the user transfers responsibility to libpng
-for data that the user has allocated, the user must have used png_malloc()
-or png_zalloc() to allocate it.
-
-If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
-separately, do not transfer responsibility for freeing text_ptr to libpng,
-because when libpng fills a png_text structure it combines these members with
-the key member, and png_free_data() will free only text_ptr.key.  Similarly,
-if you transfer responsibility for free'ing text_ptr from libpng to your
-application, your application must not separately free those members.
-For a more compact example of writing a PNG image, see the file example.c.
-
-V. Modifying/Customizing libpng:
-
-There are two issues here.  The first is changing how libpng does
-standard things like memory allocation, input/output, and error handling.
-The second deals with more complicated things like adding new chunks,
-adding new transformations, and generally changing how libpng works.
-Both of those are compile-time issues; that is, they are generally
-determined at the time the code is written, and there is rarely a need
-to provide the user with a means of changing them.
-
-Memory allocation, input/output, and error handling
-
-All of the memory allocation, input/output, and error handling in libpng
-goes through callbacks that are user-settable.  The default routines are
-in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively.  To change
-these functions, call the appropriate png_set_*_fn() function.
-
-Memory allocation is done through the functions png_malloc(), png_calloc(),
-and png_free().  These currently just call the standard C functions.
-png_calloc() calls png_malloc() and then png_memset() to clear the newly
-allocated memory to zero.  If your pointers can't access more then 64K
-at a time, you will want to set MAXSEG_64K in zlib.h.  Since it is
-unlikely that the method of handling memory allocation on a platform
-will change between applications, these functions must be modified in
-the library at compile time.  If you prefer to use a different method
-of allocating and freeing data, you can use png_create_read_struct_2() or
-png_create_write_struct_2() to register your own functions as described
-above.  These functions also provide a void pointer that can be retrieved
-via
-
-    mem_ptr=png_get_mem_ptr(png_ptr);
-
-Your replacement memory functions must have prototypes as follows:
-
-    png_voidp malloc_fn(png_structp png_ptr,
-       png_alloc_size_t size);
-    void free_fn(png_structp png_ptr, png_voidp ptr);
-
-Your malloc_fn() must return NULL in case of failure.  The png_malloc()
-function will normally call png_error() if it receives a NULL from the
-system memory allocator or from your replacement malloc_fn().
-
-Your free_fn() will never be called with a NULL ptr, since libpng's
-png_free() checks for NULL before calling free_fn().
-
-Input/Output in libpng is done through png_read() and png_write(),
-which currently just call fread() and fwrite().  The FILE * is stored in
-png_struct and is initialized via png_init_io().  If you wish to change
-the method of I/O, the library supplies callbacks that you can set
-through the function png_set_read_fn() and png_set_write_fn() at run
-time, instead of calling the png_init_io() function.  These functions
-also provide a void pointer that can be retrieved via the function
-png_get_io_ptr().  For example:
-
-    png_set_read_fn(png_structp read_ptr,
-        voidp read_io_ptr, png_rw_ptr read_data_fn)
-
-    png_set_write_fn(png_structp write_ptr,
-        voidp write_io_ptr, png_rw_ptr write_data_fn,
-        png_flush_ptr output_flush_fn);
-
-    voidp read_io_ptr = png_get_io_ptr(read_ptr);
-    voidp write_io_ptr = png_get_io_ptr(write_ptr);
-
-The replacement I/O functions must have prototypes as follows:
-
-    void user_read_data(png_structp png_ptr,
-        png_bytep data, png_size_t length);
-    void user_write_data(png_structp png_ptr,
-        png_bytep data, png_size_t length);
-    void user_flush_data(png_structp png_ptr);
-
-The user_read_data() function is responsible for detecting and
-handling end-of-data errors.
-
-Supplying NULL for the read, write, or flush functions sets them back
-to using the default C stream functions, which expect the io_ptr to
-point to a standard *FILE structure.  It is probably a mistake
-to use NULL for one of write_data_fn and output_flush_fn but not both
-of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
-It is an error to read from a write stream, and vice versa.
-
-Error handling in libpng is done through png_error() and png_warning().
-Errors handled through png_error() are fatal, meaning that png_error()
-should never return to its caller.  Currently, this is handled via
-setjmp() and longjmp() (unless you have compiled libpng with
-PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()),
-but you could change this to do things like exit() if you should wish,
-as long as your function does not return.
-
-On non-fatal errors, png_warning() is called
-to print a warning message, and then control returns to the calling code.
-By default png_error() and png_warning() print a message on stderr via
-fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined
-(because you don't want the messages) or PNG_NO_STDIO defined (because
-fprintf() isn't available).  If you wish to change the behavior of the error
-functions, you will need to set up your own message callbacks.  These
-functions are normally supplied at the time that the png_struct is created.
-It is also possible to redirect errors and warnings to your own replacement
-functions after png_create_*_struct() has been called by calling:
-
-    png_set_error_fn(png_structp png_ptr,
-        png_voidp error_ptr, png_error_ptr error_fn,
-        png_error_ptr warning_fn);
-
-    png_voidp error_ptr = png_get_error_ptr(png_ptr);
-
-If NULL is supplied for either error_fn or warning_fn, then the libpng
-default function will be used, calling fprintf() and/or longjmp() if a
-problem is encountered.  The replacement error functions should have
-parameters as follows:
-
-    void user_error_fn(png_structp png_ptr,
-        png_const_charp error_msg);
-    void user_warning_fn(png_structp png_ptr,
-        png_const_charp warning_msg);
-
-The motivation behind using setjmp() and longjmp() is the C++ throw and
-catch exception handling methods.  This makes the code much easier to write,
-as there is no need to check every return code of every function call.
-However, there are some uncertainties about the status of local variables
-after a longjmp, so the user may want to be careful about doing anything
-after setjmp returns non-zero besides returning itself.  Consult your
-compiler documentation for more details.  For an alternative approach, you
-may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net).
-
-Custom chunks
-
-If you need to read or write custom chunks, you may need to get deeper
-into the libpng code.  The library now has mechanisms for storing
-and writing chunks of unknown type; you can even declare callbacks
-for custom chunks.  However, this may not be good enough if the
-library code itself needs to know about interactions between your
-chunk and existing `intrinsic' chunks.
-
-If you need to write a new intrinsic chunk, first read the PNG
-specification. Acquire a first level of understanding of how it works.
-Pay particular attention to the sections that describe chunk names,
-and look at how other chunks were designed, so you can do things
-similarly.  Second, check out the sections of libpng that read and
-write chunks.  Try to find a chunk that is similar to yours and use
-it as a template.  More details can be found in the comments inside
-the code.  It is best to handle unknown chunks in a generic method,
-via callback functions, instead of by modifying libpng functions.
-
-If you wish to write your own transformation for the data, look through
-the part of the code that does the transformations, and check out some of
-the simpler ones to get an idea of how they work.  Try to find a similar
-transformation to the one you want to add and copy off of it.  More details
-can be found in the comments inside the code itself.
-
-Configuring for 16 bit platforms
-
-You will want to look into zconf.h to tell zlib (and thus libpng) that
-it cannot allocate more then 64K at a time.  Even if you can, the memory
-won't be accessible.  So limit zlib and libpng to 64K by defining MAXSEG_64K.
-
-Configuring for DOS
-
-For DOS users who only have access to the lower 640K, you will
-have to limit zlib's memory usage via a png_set_compression_mem_level()
-call.  See zlib.h or zconf.h in the zlib library for more information.
-
-Configuring for Medium Model
-
-Libpng's support for medium model has been tested on most of the popular
-compilers.  Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
-defined, and FAR gets defined to far in pngconf.h, and you should be
-all set.  Everything in the library (except for zlib's structure) is
-expecting far data.  You must use the typedefs with the p or pp on
-the end for pointers (or at least look at them and be careful).  Make
-note that the rows of data are defined as png_bytepp, which is an
-unsigned char far * far *.
-
-Configuring for gui/windowing platforms:
-
-You will need to write new error and warning functions that use the GUI
-interface, as described previously, and set them to be the error and
-warning functions at the time that png_create_*_struct() is called,
-in order to have them available during the structure initialization.
-They can be changed later via png_set_error_fn().  On some compilers,
-you may also have to change the memory allocators (png_malloc, etc.).
-
-Configuring for compiler xxx:
-
-All includes for libpng are in pngconf.h.  If you need to add, change
-or delete an include, this is the place to do it.
-The includes that are not needed outside libpng are placed in pngpriv.h,
-which is only used by the routines inside libpng itself.
-The files in libpng proper only include pngpriv.h and png.h, which
-in turn includes pngconf.h.
-
-Configuring zlib:
-
-There are special functions to configure the compression.  Perhaps the
-most useful one changes the compression level, which currently uses
-input compression values in the range 0 - 9.  The library normally
-uses the default compression level (Z_DEFAULT_COMPRESSION = 6).  Tests
-have shown that for a large majority of images, compression values in
-the range 3-6 compress nearly as well as higher levels, and do so much
-faster.  For online applications it may be desirable to have maximum speed
-(Z_BEST_SPEED = 1).  With versions of zlib after v0.99, you can also
-specify no compression (Z_NO_COMPRESSION = 0), but this would create
-files larger than just storing the raw bitmap.  You can specify the
-compression level by calling:
-
-    png_set_compression_level(png_ptr, level);
-
-Another useful one is to reduce the memory level used by the library.
-The memory level defaults to 8, but it can be lowered if you are
-short on memory (running DOS, for example, where you only have 640K).
-Note that the memory level does have an effect on compression; among
-other things, lower levels will result in sections of incompressible
-data being emitted in smaller stored blocks, with a correspondingly
-larger relative overhead of up to 15% in the worst case.
-
-    png_set_compression_mem_level(png_ptr, level);
-
-The other functions are for configuring zlib.  They are not recommended
-for normal use and may result in writing an invalid PNG file.  See
-zlib.h for more information on what these mean.
-
-    png_set_compression_strategy(png_ptr,
-        strategy);
-    png_set_compression_window_bits(png_ptr,
-        window_bits);
-    png_set_compression_method(png_ptr, method);
-    png_set_compression_buffer_size(png_ptr, size);
-
-Controlling row filtering
-
-If you want to control whether libpng uses filtering or not, which
-filters are used, and how it goes about picking row filters, you
-can call one of these functions.  The selection and configuration
-of row filters can have a significant impact on the size and
-encoding speed and a somewhat lesser impact on the decoding speed
-of an image.  Filtering is enabled by default for RGB and grayscale
-images (with and without alpha), but not for paletted images nor
-for any images with bit depths less than 8 bits/pixel.
-
-The 'method' parameter sets the main filtering method, which is
-currently only '0' in the PNG 1.2 specification.  The 'filters'
-parameter sets which filter(s), if any, should be used for each
-scanline.  Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
-to turn filtering on and off, respectively.
-
-Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
-PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
-ORed together with '|' to specify one or more filters to use.
-These filters are described in more detail in the PNG specification.
-If you intend to change the filter type during the course of writing
-the image, you should start with flags set for all of the filters
-you intend to use so that libpng can initialize its internal
-structures appropriately for all of the filter types.  (Note that this
-means the first row must always be adaptively filtered, because libpng
-currently does not allocate the filter buffers until png_write_row()
-is called for the first time.)
-
-    filters = PNG_FILTER_NONE | PNG_FILTER_SUB
-              PNG_FILTER_UP | PNG_FILTER_AVG |
-              PNG_FILTER_PAETH | PNG_ALL_FILTERS;
-
-    png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
-       filters);
-              The second parameter can also be
-              PNG_INTRAPIXEL_DIFFERENCING if you are
-              writing a PNG to be embedded in a MNG
-              datastream.  This parameter must be the
-              same as the value of filter_method used
-              in png_set_IHDR().
-
-It is also possible to influence how libpng chooses from among the
-available filters.  This is done in one or both of two ways - by
-telling it how important it is to keep the same filter for successive
-rows, and by telling it the relative computational costs of the filters.
-
-    double weights[3] = {1.5, 1.3, 1.1},
-       costs[PNG_FILTER_VALUE_LAST] =
-       {1.0, 1.3, 1.3, 1.5, 1.7};
-
-    png_set_filter_heuristics(png_ptr,
-       PNG_FILTER_HEURISTIC_WEIGHTED, 3,
-       weights, costs);
-
-The weights are multiplying factors that indicate to libpng that the
-row filter should be the same for successive rows unless another row filter
-is that many times better than the previous filter.  In the above example,
-if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
-"sum of absolute differences" 1.5 x 1.3 times higher than other filters
-and still be chosen, while the NONE filter could have a sum 1.1 times
-higher than other filters and still be chosen.  Unspecified weights are
-taken to be 1.0, and the specified weights should probably be declining
-like those above in order to emphasize recent filters over older filters.
-
-The filter costs specify for each filter type a relative decoding cost
-to be considered when selecting row filters.  This means that filters
-with higher costs are less likely to be chosen over filters with lower
-costs, unless their "sum of absolute differences" is that much smaller.
-The costs do not necessarily reflect the exact computational speeds of
-the various filters, since this would unduly influence the final image
-size.
-
-Note that the numbers above were invented purely for this example and
-are given only to help explain the function usage.  Little testing has
-been done to find optimum values for either the costs or the weights.
-
-Removing unwanted object code
-
-There are a bunch of #define's in pngconf.h that control what parts of
-libpng are compiled.  All the defines end in _SUPPORTED.  If you are
-never going to use a capability, you can change the #define to #undef
-before recompiling libpng and save yourself code and data space, or
-you can turn off individual capabilities with defines that begin with
-PNG_NO_.
-
-You can also turn all of the transforms and ancillary chunk capabilities
-off en masse with compiler directives that define
-PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
-or all four,
-along with directives to turn on any of the capabilities that you do
-want.  The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
-transformations but still leave the library fully capable of reading
-and writing PNG files with all known public chunks. Use of the
-PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
-that is incapable of reading or writing ancillary chunks.  If you are
-not using the progressive reading capability, you can turn that off
-with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
-capability, which you'll still have).
-
-All the reading and writing specific code are in separate files, so the
-linker should only grab the files it needs.  However, if you want to
-make sure, or if you are building a stand alone library, all the
-reading files start with pngr and all the writing files start with
-pngw.  The files that don't match either (like png.c, pngtrans.c, etc.)
-are used for both reading and writing, and always need to be included.
-The progressive reader is in pngpread.c
-
-If you are creating or distributing a dynamically linked library (a .so
-or DLL file), you should not remove or disable any parts of the library,
-as this will cause applications linked with different versions of the
-library to fail if they call functions not available in your library.
-The size of the library itself should not be an issue, because only
-those sections that are actually used will be loaded into memory.
-
-Requesting debug printout
-
-The macro definition PNG_DEBUG can be used to request debugging
-printout.  Set it to an integer value in the range 0 to 3.  Higher
-numbers result in increasing amounts of debugging information.  The
-information is printed to the "stderr" file, unless another file
-name is specified in the PNG_DEBUG_FILE macro definition.
-
-When PNG_DEBUG > 0, the following functions (macros) become available:
-
-   png_debug(level, message)
-   png_debug1(level, message, p1)
-   png_debug2(level, message, p1, p2)
-
-in which "level" is compared to PNG_DEBUG to decide whether to print
-the message, "message" is the formatted string to be printed,
-and p1 and p2 are parameters that are to be embedded in the string
-according to printf-style formatting directives.  For example,
-
-   png_debug1(2, "foo=%d\n", foo);
-
-is expanded to
-
-   if(PNG_DEBUG > 2)
-     fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
-
-When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
-can still use PNG_DEBUG to control your own debugging:
-
-   #ifdef PNG_DEBUG
-       fprintf(stderr, ...
-   #endif
-
-When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
-having level = 0 will be printed.  There aren't any such statements in
-this version of libpng, but if you insert some they will be printed.
-
-VI.  MNG support
-
-The MNG specification (available at http://www.libpng.org/pub/mng) allows
-certain extensions to PNG for PNG images that are embedded in MNG datastreams.
-Libpng can support some of these extensions.  To enable them, use the
-png_permit_mng_features() function:
-
-   feature_set = png_permit_mng_features(png_ptr, mask)
-   mask is a png_uint_32 containing the bitwise OR of the
-        features you want to enable.  These include
-        PNG_FLAG_MNG_EMPTY_PLTE
-        PNG_FLAG_MNG_FILTER_64
-        PNG_ALL_MNG_FEATURES
-   feature_set is a png_uint_32 that is the bitwise AND of
-      your mask with the set of MNG features that is
-      supported by the version of libpng that you are using.
-
-It is an error to use this function when reading or writing a standalone
-PNG file with the PNG 8-byte signature.  The PNG datastream must be wrapped
-in a MNG datastream.  As a minimum, it must have the MNG 8-byte signature
-and the MHDR and MEND chunks.  Libpng does not provide support for these
-or any other MNG chunks; your application must provide its own support for
-them.  You may wish to consider using libmng (available at
-http://www.libmng.com) instead.
-
-VII.  Changes to Libpng from version 0.88
-
-It should be noted that versions of libpng later than 0.96 are not
-distributed by the original libpng author, Guy Schalnat, nor by
-Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
-distributed versions 0.89 through 0.96, but rather by another member
-of the original PNG Group, Glenn Randers-Pehrson.  Guy and Andreas are
-still alive and well, but they have moved on to other things.
-
-The old libpng functions png_read_init(), png_write_init(),
-png_info_init(), png_read_destroy(), and png_write_destroy() have been
-moved to PNG_INTERNAL in version 0.95 to discourage their use.  These
-functions will be removed from libpng version 2.0.0.
-
-The preferred method of creating and initializing the libpng structures is
-via the png_create_read_struct(), png_create_write_struct(), and
-png_create_info_struct() because they isolate the size of the structures
-from the application, allow version error checking, and also allow the
-use of custom error handling routines during the initialization, which
-the old functions do not.  The functions png_read_destroy() and
-png_write_destroy() do not actually free the memory that libpng
-allocated for these structs, but just reset the data structures, so they
-can be used instead of png_destroy_read_struct() and
-png_destroy_write_struct() if you feel there is too much system overhead
-allocating and freeing the png_struct for each image read.
-
-Setting the error callbacks via png_set_message_fn() before
-png_read_init() as was suggested in libpng-0.88 is no longer supported
-because this caused applications that do not use custom error functions
-to fail if the png_ptr was not initialized to zero.  It is still possible
-to set the error callbacks AFTER png_read_init(), or to change them with
-png_set_error_fn(), which is essentially the same function, but with a new
-name to force compilation errors with applications that try to use the old
-method.
-
-Starting with version 1.0.7, you can find out which version of the library
-you are using at run-time:
-
-   png_uint_32 libpng_vn = png_access_version_number();
-
-The number libpng_vn is constructed from the major version, minor
-version with leading zero, and release number with leading zero,
-(e.g., libpng_vn for version 1.0.7 is 10007).
-
-You can also check which version of png.h you used when compiling your
-application:
-
-   png_uint_32 application_vn = PNG_LIBPNG_VER;
-
-VIII.  Changes to Libpng from version 1.0.x to 1.2.x
-
-Support for user memory management was enabled by default.  To
-accomplish this, the functions png_create_read_struct_2(),
-png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(),
-png_malloc_default(), and png_free_default() were added.
-
-Support for the iTXt chunk has been enabled by default as of
-version 1.2.41.
-
-Support for certain MNG features was enabled.
-
-Support for numbered error messages was added.  However, we never got
-around to actually numbering the error messages.  The function
-png_set_strip_error_numbers() was added (Note: the prototype for this
-function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE
-builds of libpng-1.2.15.  It was restored in libpng-1.2.36).
-
-The png_malloc_warn() function was added at libpng-1.2.3.  This issues
-a png_warning and returns NULL instead of aborting when it fails to
-acquire the requested memory allocation.
-
-Support for setting user limits on image width and height was enabled
-by default.  The functions png_set_user_limits(), png_get_user_width_max(),
-and png_get_user_height_max() were added at libpng-1.2.6.
-
-The png_set_add_alpha() function was added at libpng-1.2.7.
-
-The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9.
-Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the
-tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is
-deprecated.
-
-A number of macro definitions in support of runtime selection of
-assembler code features (especially Intel MMX code support) were
-added at libpng-1.2.0:
-
-    PNG_ASM_FLAG_MMX_SUPPORT_COMPILED
-    PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
-    PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
-    PNG_ASM_FLAG_MMX_READ_INTERLACE
-    PNG_ASM_FLAG_MMX_READ_FILTER_SUB
-    PNG_ASM_FLAG_MMX_READ_FILTER_UP
-    PNG_ASM_FLAG_MMX_READ_FILTER_AVG
-    PNG_ASM_FLAG_MMX_READ_FILTER_PAETH
-    PNG_ASM_FLAGS_INITIALIZED
-    PNG_MMX_READ_FLAGS
-    PNG_MMX_FLAGS
-    PNG_MMX_WRITE_FLAGS
-    PNG_MMX_FLAGS
-
-We added the following functions in support of runtime
-selection of assembler code features:
-
-    png_get_mmx_flagmask()
-    png_set_mmx_thresholds()
-    png_get_asm_flags()
-    png_get_mmx_bitdepth_threshold()
-    png_get_mmx_rowbytes_threshold()
-    png_set_asm_flags()
-
-We replaced all of these functions with simple stubs in libpng-1.2.20,
-when the Intel assembler code was removed due to a licensing issue.
-
-These macros are deprecated:
-
-    PNG_READ_TRANSFORMS_NOT_SUPPORTED
-    PNG_PROGRESSIVE_READ_NOT_SUPPORTED
-    PNG_NO_SEQUENTIAL_READ_SUPPORTED
-    PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
-    PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
-    PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
-
-They have been replaced, respectively, by:
-
-    PNG_NO_READ_TRANSFORMS
-    PNG_NO_PROGRESSIVE_READ
-    PNG_NO_SEQUENTIAL_READ
-    PNG_NO_WRITE_TRANSFORMS
-    PNG_NO_READ_ANCILLARY_CHUNKS
-    PNG_NO_WRITE_ANCILLARY_CHUNKS
-
-PNG_MAX_UINT was replaced with PNG_UINT_31_MAX.  It has been
-deprecated since libpng-1.0.16 and libpng-1.2.6.
-
-The function
-    png_check_sig(sig, num)
-was replaced with
-    !png_sig_cmp(sig, 0, num)
-It has been deprecated since libpng-0.90.
-
-The function
-    png_set_gray_1_2_4_to_8()
-which also expands tRNS to alpha was replaced with
-    png_set_expand_gray_1_2_4_to_8()
-which does not. It has been deprecated since libpng-1.0.18 and 1.2.9.
-
-IX.  Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
-
-Private libpng prototypes and macro definitions were moved from
-png.h and pngconf.h into a new pngpriv.h header file.
-
-Functions png_set_benign_errors(), png_benign_error(), and
-png_chunk_benign_error() were added.
-
-Support for setting the maximum amount of memory that the application
-will allocate for reading chunks was added, as a security measure.
-The functions png_set_chunk_cache_max() and png_get_chunk_cache_max()
-were added to the library.
-
-We implemented support for I/O states by adding png_ptr member io_state
-and functions png_get_io_chunk_name() and png_get_io_state() in pngget.c
-
-We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level
-input transforms.
-
-Checking for and reporting of errors in the IHDR chunk is more thorough.
-
-Support for global arrays was removed, to improve thread safety.
-
-Some obsolete/deprecated macros and functions have been removed.
-
-Typecasted NULL definitions such as
-   #define png_voidp_NULL            (png_voidp)NULL
-were eliminated.  If you used these in your application, just use
-NULL instead.
-
-The png_struct and info_struct members "trans" and "trans_values" were
-changed to "trans_alpha" and "trans_color", respectively.
-
-The obsolete, unused pnggccrd.c and pngvcrd.c files and related makefiles
-were removed.
-
-The PNG_1_0_X and PNG_1_2_X macros were eliminated.
-
-The PNG_LEGACY_SUPPORTED macro was eliminated.
-
-Many WIN32_WCE #ifdefs were removed.
-
-The functions png_read_init(info_ptr), png_write_init(info_ptr),
-png_info_init(info_ptr), png_read_destroy(), and png_write_destroy()
-have been removed.  They have been deprecated since libpng-0.95.
-
-The png_permit_empty_plte() was removed. It has been deprecated
-since libpng-1.0.9.  Use png_permit_mng_features() instead.
-
-We removed the obsolete stub functions png_get_mmx_flagmask(),
-png_set_mmx_thresholds(), png_get_asm_flags(),
-png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(),
-png_set_asm_flags(), and png_mmx_supported()
-
-We removed the obsolete png_check_sig(), png_memcpy_check(), and
-png_memset_check() functions.  Instead use !png_sig_cmp(), png_memcpy(),
-and png_memset(), respectively.
-
-The function png_set_gray_1_2_4_to_8() was removed. It has been
-deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
-png_set_expand_gray_1_2_4_to_8() because the former function also
-expanded palette images.
-
-We changed the prototype for png_malloc() from
-    png_malloc(png_structp png_ptr, png_uint_32 size)
-to
-    png_malloc(png_structp png_ptr, png_alloc_size_t size)
-
-This also applies to the prototype for the user replacement malloc_fn().
-
-The png_calloc() function was added and is used in place of
-of "png_malloc(); png_memset();" except in the case in png_read_png()
-where the array consists of pointers; in this case a "for" loop is used
-after the png_malloc() to set the pointers to NULL, to give robust.
-behavior in case the application runs out of memory part-way through
-the process.
-
-We changed the prototypes of png_get_compression_buffer_size() and
-png_set_compression_buffer_size() to work with png_size_t instead of
-png_uint_32.
-
-Support for numbered error messages was removed by default, since we
-never got around to actually numbering the error messages. The function
-png_set_strip_error_numbers() was removed from the library by default.
-
-The png_zalloc() and png_zfree() functions are no longer exported.
-The png_zalloc() function no longer zeroes out the memory that it
-allocates.
-
-Support for dithering was disabled by default in libpng-1.4.0, because
-been well tested and doesn't actually "dither".  The code was not
-removed, however, and could be enabled by building libpng with
-PNG_READ_DITHER_SUPPORTED defined.  In libpng-1.4.2, this support
-was reenabled, but the function was renamed png_set_quantize() to
-reflect more accurately what it actually does.  At the same time,
-the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to
-PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS.
-
-We removed the trailing '.' from the warning and error messages.
-
-X. Detecting libpng
-
-The png_get_io_ptr() function has been present since libpng-0.88, has never
-changed, and is unaffected by conditional compilation macros.  It is the
-best choice for use in configure scripts for detecting the presence of any
-libpng version since 0.88.  In an autoconf "configure.in" you could use
-
-    AC_CHECK_LIB(png, png_get_io_ptr, ...
-
-XI. Source code repository
-
-Since about February 2009, version 1.2.34, libpng has been under "git" source
-control.  The git repository was built from old libpng-x.y.z.tar.gz files
-going back to version 0.70.  You can access the git repository (read only)
-at
-
-    git://libpng.git.sourceforge.net/gitroot/libpng
-
-or you can browse it via "gitweb" at
-
-    http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
-
-Patches can be sent to glennrp at users.sourceforge.net or to
-png-mng-implement at lists.sourceforge.net or you can upload them to
-the libpng bug tracker at
-
-    http://libpng.sourceforge.net
-
-XII. Coding style
-
-Our coding style is similar to the "Allman" style, with curly
-braces on separate lines:
-
-    if (condition)
-    {
-       action;
-    }
-
-    else if (another condition)
-    {
-       another action;
-    }
-
-The braces can be omitted from simple one-line actions:
-
-    if (condition)
-       return (0);
-
-We use 3-space indentation, except for continued statements which
-are usually indented the same as the first line of the statement
-plus four more spaces.
-
-For macro definitions we use 2-space indentation, always leaving the "#"
-in the first column.
-
-    #ifndef PNG_NO_FEATURE
-    #  ifndef PNG_FEATURE_SUPPORTED
-    #    define PNG_FEATURE_SUPPORTED
-    #  endif
-    #endif
-
-Comments appear with the leading "/*" at the same indentation as
-the statement that follows the comment:
-
-    /* Single-line comment */
-    statement;
-
-    /* This is a multiple-line
-     * comment.
-     */
-    statement;
-
-Very short comments can be placed after the end of the statement
-to which they pertain:
-
-    statement;    /* comment */
-
-We don't use C++ style ("//") comments. We have, however,
-used them in the past in some now-abandoned MMX assembler
-code.
-
-Functions and their curly braces are not indented, and
-exported functions are marked with PNGAPI:
-
- /* This is a public function that is visible to
-  * application programers. It does thus-and-so.
-  */
- void PNGAPI
- png_exported_function(png_ptr, png_info, foo)
- {
-    body;
- }
-
-The prototypes for all exported functions appear in png.h,
-above the comment that says
-
-    /* Maintainer: Put new public prototypes here ... */
-
-We mark all non-exported functions with "/* PRIVATE */"":
-
- void /* PRIVATE */
- png_non_exported_function(png_ptr, png_info, foo)
- {
-    body;
- }
-
-The prototypes for non-exported functions (except for those in
-pngtest) appear in
-pngpriv.h
-above the comment that says
-
-  /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
-
-The names of all exported functions and variables begin
-with  "png_", and all publicly visible C preprocessor
-macros begin with "PNG_".
-
-We put a space after each comma and after each semicolon
-in "for" statments, and we put spaces before and after each
-C binary operator and after "for" or "while", and before
-"?".  We don't put a space between a typecast and the expression
-being cast, nor do we put one between a function name and the
-left parenthesis that follows it:
-
-    for (i = 2; i > 0; --i)
-       y[i] = a(x) + (int)b;
-
-We prefer #ifdef and #ifndef to #if defined() and if !defined()
-when there is only one macro being tested.
-
-We do not use the TAB character for indentation in the C sources.
-
-Lines do not exceed 80 characters.
-
-Other rules can be inferred by inspecting the libpng source.
-
-XIII. Y2K Compliance in libpng
-
-September 23, 2010
-
-Since the PNG Development group is an ad-hoc body, we can't make
-an official declaration.
-
-This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.4.4 are Y2K compliant.  It is my belief that earlier
-versions were also Y2K compliant.
-
-Libpng only has three year fields.  One is a 2-byte unsigned integer that
-will hold years up to 65535.  The other two hold the date in text
-format, and will hold years up to 9999.
-
-The integer is
-    "png_uint_16 year" in png_time_struct.
-
-The strings are
-    "png_charp time_buffer" in png_struct and
-    "near_time_buffer", which is a local character string in png.c.
-
-There are seven time-related functions:
-
-    png_convert_to_rfc_1123() in png.c
-      (formerly png_convert_to_rfc_1152() in error)
-    png_convert_from_struct_tm() in pngwrite.c, called
-      in pngwrite.c
-    png_convert_from_time_t() in pngwrite.c
-    png_get_tIME() in pngget.c
-    png_handle_tIME() in pngrutil.c, called in pngread.c
-    png_set_tIME() in pngset.c
-    png_write_tIME() in pngwutil.c, called in pngwrite.c
-
-All appear to handle dates properly in a Y2K environment.  The
-png_convert_from_time_t() function calls gmtime() to convert from system
-clock time, which returns (year - 1900), which we properly convert to
-the full 4-digit year.  There is a possibility that applications using
-libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
-function, or that they are incorrectly passing only a 2-digit year
-instead of "year - 1900" into the png_convert_from_struct_tm() function,
-but this is not under our control.  The libpng documentation has always
-stated that it works with 4-digit years, and the APIs have been
-documented as such.
-
-The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
-integer to hold the year, and can hold years as large as 65535.
-
-zlib, upon which libpng depends, is also Y2K compliant.  It contains
-no date-related code.
-
-
-   Glenn Randers-Pehrson
-   libpng maintainer
-   PNG Development Group
index 7d09b0dbd2104d5a0f1da7090b7eb0bf9e549e9c..ca1de48664e5d39cfaeac14a6f93542320ebda99 100644 (file)
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * Last changed in libpng 1.5.1 [February 3, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -14,7 +14,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_5_2 Your_png_h_is_not_version_1_5_2;
+typedef png_libpng_version_1_5_9 Your_png_h_is_not_version_1_5_9;
 
 /* Tells libpng that we have already handled the first "num_bytes" bytes
  * of the PNG file signature.  If the PNG data is embedded into another
@@ -43,7 +43,7 @@ png_set_sig_bytes(png_structp png_ptr, int num_bytes)
  * can simply check the remaining bytes for extra assurance.  Returns
  * an integer less than, equal to, or greater than zero if sig is found,
  * respectively, to be less than, to match, or be greater than the correct
- * PNG signature (this is the same behaviour as strcmp, memcmp, etc).
+ * PNG signature (this is the same behavior as strcmp, memcmp, etc).
  */
 int PNGAPI
 png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)
@@ -107,7 +107,8 @@ png_zfree(voidpf png_ptr, voidpf ptr)
 void /* PRIVATE */
 png_reset_crc(png_structp png_ptr)
 {
-   png_ptr->crc = crc32(0, Z_NULL, 0);
+   /* The cast is safe because the crc is a 32 bit value. */
+   png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);
 }
 
 /* Calculate the CRC over a section of data.  We can only pass as
@@ -120,21 +121,103 @@ png_calculate_crc(png_structp png_ptr, png_const_bytep ptr, png_size_t length)
 {
    int need_crc = 1;
 
-   if (png_ptr->chunk_name[0] & 0x20)                     /* ancillary */
+   if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))
    {
       if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
           (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
          need_crc = 0;
    }
 
-   else                                                    /* critical */
+   else /* critical */
    {
       if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
          need_crc = 0;
    }
 
-   if (need_crc)
-      png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length);
+   /* 'uLong' is defined as unsigned long, this means that on some systems it is
+    * a 64 bit value.  crc32, however, returns 32 bits so the following cast is
+    * safe.  'uInt' may be no more than 16 bits, so it is necessary to perform a
+    * loop here.
+    */
+   if (need_crc && length > 0)
+   {
+      uLong crc = png_ptr->crc; /* Should never issue a warning */
+
+      do
+      {
+         uInt safeLength = (uInt)length;
+         if (safeLength == 0)
+            safeLength = (uInt)-1; /* evil, but safe */
+
+         crc = crc32(crc, ptr, safeLength);
+
+         /* The following should never issue compiler warnings, if they do the
+          * target system has characteristics that will probably violate other
+          * assumptions within the libpng code.
+          */
+         ptr += safeLength;
+         length -= safeLength;
+      }
+      while (length > 0);
+
+      /* And the following is always safe because the crc is only 32 bits. */
+      png_ptr->crc = (png_uint_32)crc;
+   }
+}
+
+/* Check a user supplied version number, called from both read and write
+ * functions that create a png_struct
+ */
+int
+png_user_version_check(png_structp png_ptr, png_const_charp user_png_ver)
+{
+   if (user_png_ver)
+   {
+      int i = 0;
+
+      do
+      {
+         if (user_png_ver[i] != png_libpng_ver[i])
+            png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
+      } while (png_libpng_ver[i++]);
+   }
+
+   else
+      png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
+
+   if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
+   {
+     /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
+      * we must recompile any applications that use any older library version.
+      * For versions after libpng 1.0, we will be compatible, so we need
+      * only check the first digit.
+      */
+      if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
+          (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
+          (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
+      {
+#ifdef PNG_WARNINGS_SUPPORTED
+         size_t pos = 0;
+         char m[128];
+
+         pos = png_safecat(m, sizeof m, pos, "Application built with libpng-");
+         pos = png_safecat(m, sizeof m, pos, user_png_ver);
+         pos = png_safecat(m, sizeof m, pos, " but running with ");
+         pos = png_safecat(m, sizeof m, pos, png_libpng_ver);
+
+         png_warning(png_ptr, m);
+#endif
+
+#ifdef PNG_ERROR_NUMBERS_SUPPORTED
+         png_ptr->flags = 0;
+#endif
+
+         return 0;
+      }
+   }
+
+   /* Success return. */
+   return 1;
 }
 
 /* Allocate the memory for an info_struct for the application.  We don't
@@ -291,12 +374,10 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
    /* Free any sCAL entry */
    if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
    {
-#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
       png_free(png_ptr, info_ptr->scal_s_width);
       png_free(png_ptr, info_ptr->scal_s_height);
       info_ptr->scal_s_width = NULL;
       info_ptr->scal_s_height = NULL;
-#endif
       info_ptr->valid &= ~PNG_INFO_sCAL;
    }
 #endif
@@ -489,8 +570,8 @@ png_get_io_ptr(png_structp png_ptr)
 /* Initialize the default input/output functions for the PNG file.  If you
  * use your own read or write routines, you can call either png_set_read_fn()
  * or png_set_write_fn() instead of png_init_io().  If you have defined
- * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
- * necessarily available.
+ * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a
+ * function of your own because "FILE *" isn't necessarily available.
  */
 void PNGAPI
 png_init_io(png_structp png_ptr, png_FILE_p fp)
@@ -518,28 +599,47 @@ png_convert_to_rfc1123(png_structp png_ptr, png_const_timep ptime)
    if (png_ptr == NULL)
       return (NULL);
 
-   if (png_ptr->time_buffer == NULL)
+   if (ptime->year > 9999 /* RFC1123 limitation */ ||
+       ptime->month == 0    ||  ptime->month > 12  ||
+       ptime->day   == 0    ||  ptime->day   > 31  ||
+       ptime->hour  > 23    ||  ptime->minute > 59 ||
+       ptime->second > 60)
    {
-      png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
-         png_sizeof(char)));
+      png_warning(png_ptr, "Ignoring invalid time value");
+      return (NULL);
    }
 
-#    ifdef USE_FAR_KEYWORD
    {
-      char near_time_buf[29];
-      png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000",
-          ptime->day % 32, short_months[(ptime->month - 1) % 12],
-          ptime->year, ptime->hour % 24, ptime->minute % 60,
-          ptime->second % 61);
-      png_memcpy(png_ptr->time_buffer, near_time_buf,
-          29*png_sizeof(char));
+      size_t pos = 0;
+      char number_buf[5]; /* enough for a four-digit year */
+
+#     define APPEND_STRING(string)\
+         pos = png_safecat(png_ptr->time_buffer, sizeof png_ptr->time_buffer,\
+            pos, (string))
+#     define APPEND_NUMBER(format, value)\
+         APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value)))
+#     define APPEND(ch)\
+         if (pos < (sizeof png_ptr->time_buffer)-1)\
+            png_ptr->time_buffer[pos++] = (ch)
+
+      APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day);
+      APPEND(' ');
+      APPEND_STRING(short_months[(ptime->month - 1)]);
+      APPEND(' ');
+      APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year);
+      APPEND(' ');
+      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour);
+      APPEND(':');
+      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute);
+      APPEND(':');
+      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);
+      APPEND_STRING(" +0000"); /* This reliably terminates the buffer */
+
+#     undef APPEND
+#     undef APPEND_NUMBER
+#     undef APPEND_STRING
    }
-#    else
-   png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000",
-       ptime->day % 32, short_months[(ptime->month - 1) % 12],
-       ptime->year, ptime->hour % 24, ptime->minute % 60,
-       ptime->second % 61);
-#    endif
+
    return png_ptr->time_buffer;
 }
 #  endif /* PNG_TIME_RFC1123_SUPPORTED */
@@ -555,13 +655,13 @@ png_get_copyright(png_const_structp png_ptr)
 #else
 #  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-     "libpng version 1.5.2 - March 31, 2011" PNG_STRING_NEWLINE \
+     "libpng version 1.5.9 - February 18, 2012" PNG_STRING_NEWLINE \
      "Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
      "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
      "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
      PNG_STRING_NEWLINE;
 #  else
-      return "libpng version 1.5.2 - March 31, 2011\
+      return "libpng version 1.5.9 - February 18, 2012\
       Copyright (c) 1998-2011 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -608,25 +708,43 @@ png_get_header_version(png_const_structp png_ptr)
 #endif
 }
 
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-#  ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
 int PNGAPI
 png_handle_as_unknown(png_structp png_ptr, png_const_bytep chunk_name)
 {
    /* Check chunk_name and return "keep" value if it's on the list, else 0 */
-   int i;
-   png_bytep p;
-   if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
-      return 0;
+   png_const_bytep p, p_end;
 
-   p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
-   for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
+   if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list <= 0)
+      return PNG_HANDLE_CHUNK_AS_DEFAULT;
+
+   p_end = png_ptr->chunk_list;
+   p = p_end + png_ptr->num_chunk_list*5; /* beyond end */
+
+   /* The code is the fifth byte after each four byte string.  Historically this
+    * code was always searched from the end of the list, so it should continue
+    * to do so in case there are duplicated entries.
+    */
+   do /* num_chunk_list > 0, so at least one */
+   {
+      p -= 5;
       if (!png_memcmp(chunk_name, p, 4))
-        return ((int)*(p + 4));
-   return 0;
+         return p[4];
+   }
+   while (p > p_end);
+
+   return PNG_HANDLE_CHUNK_AS_DEFAULT;
 }
-#  endif
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
+
+int /* PRIVATE */
+png_chunk_unknown_handling(png_structp png_ptr, png_uint_32 chunk_name)
+{
+   png_byte chunk_string[5];
+
+   PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name);
+   return png_handle_as_unknown(png_ptr, chunk_string);
+}
+#endif
 
 #ifdef PNG_READ_SUPPORTED
 /* This function, added to libpng-1.0.6g, is untested. */
@@ -651,18 +769,9 @@ png_access_version_number(void)
 
 
 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-#  ifdef PNG_SIZE_T
-/* Added at libpng version 1.2.6 */
-   PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
-png_size_t PNGAPI
-png_convert_size(size_t size)
-{
-   if (size > (png_size_t)-1)
-      PNG_ABORT();  /* We haven't got access to png_ptr, so no png_error() */
-
-   return ((png_size_t)size);
-}
-#  endif /* PNG_SIZE_T */
+/* png_convert_size: a PNGAPI but no longer in png.h, so deleted
+ * at libpng 1.5.5!
+ */
 
 /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
 #  ifdef PNG_CHECK_cHRM_SUPPORTED
@@ -681,6 +790,13 @@ png_check_cHRM_fixed(png_structp png_ptr,
    if (png_ptr == NULL)
       return 0;
 
+   /* (x,y,z) values are first limited to 0..100000 (PNG_FP_1), the white
+    * y must also be greater than 0.  To test for the upper limit calculate
+    * (PNG_FP_1-y) - x must be <= to this for z to be >= 0 (and the expression
+    * cannot overflow.)  At this point we know x and y are >= 0 and (x+y) is
+    * <= PNG_FP_1.  The previous test on PNG_MAX_UINT_31 is removed because it
+    * pointless (and it produces compiler warnings!)
+    */
    if (white_x < 0 || white_y <= 0 ||
          red_x < 0 ||   red_y <  0 ||
        green_x < 0 || green_y <  0 ||
@@ -690,38 +806,26 @@ png_check_cHRM_fixed(png_structp png_ptr,
         "Ignoring attempt to set negative chromaticity value");
       ret = 0;
    }
-   if (white_x > (png_fixed_point)PNG_UINT_31_MAX ||
-       white_y > (png_fixed_point)PNG_UINT_31_MAX ||
-         red_x > (png_fixed_point)PNG_UINT_31_MAX ||
-         red_y > (png_fixed_point)PNG_UINT_31_MAX ||
-       green_x > (png_fixed_point)PNG_UINT_31_MAX ||
-       green_y > (png_fixed_point)PNG_UINT_31_MAX ||
-        blue_x > (png_fixed_point)PNG_UINT_31_MAX ||
-        blue_y > (png_fixed_point)PNG_UINT_31_MAX )
-   {
-      png_warning(png_ptr,
-        "Ignoring attempt to set chromaticity value exceeding 21474.83");
-      ret = 0;
-   }
-   if (white_x > 100000L - white_y)
+   /* And (x+y) must be <= PNG_FP_1 (so z is >= 0) */
+   if (white_x > PNG_FP_1 - white_y)
    {
       png_warning(png_ptr, "Invalid cHRM white point");
       ret = 0;
    }
 
-   if (red_x > 100000L - red_y)
+   if (red_x > PNG_FP_1 - red_y)
    {
       png_warning(png_ptr, "Invalid cHRM red point");
       ret = 0;
    }
 
-   if (green_x > 100000L - green_y)
+   if (green_x > PNG_FP_1 - green_y)
    {
       png_warning(png_ptr, "Invalid cHRM green point");
       ret = 0;
    }
 
-   if (blue_x > 100000L - blue_y)
+   if (blue_x > PNG_FP_1 - blue_y)
    {
       png_warning(png_ptr, "Invalid cHRM blue point");
       ret = 0;
@@ -741,6 +845,326 @@ png_check_cHRM_fixed(png_structp png_ptr,
 }
 #  endif /* PNG_CHECK_cHRM_SUPPORTED */
 
+#ifdef PNG_cHRM_SUPPORTED
+/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
+ * cHRM, as opposed to using chromaticities.  These internal APIs return
+ * non-zero on a parameter error.  The X, Y and Z values are required to be
+ * positive and less than 1.0.
+ */
+int png_xy_from_XYZ(png_xy *xy, png_XYZ XYZ)
+{
+   png_int_32 d, dwhite, whiteX, whiteY;
+
+   d = XYZ.redX + XYZ.redY + XYZ.redZ;
+   if (!png_muldiv(&xy->redx, XYZ.redX, PNG_FP_1, d)) return 1;
+   if (!png_muldiv(&xy->redy, XYZ.redY, PNG_FP_1, d)) return 1;
+   dwhite = d;
+   whiteX = XYZ.redX;
+   whiteY = XYZ.redY;
+
+   d = XYZ.greenX + XYZ.greenY + XYZ.greenZ;
+   if (!png_muldiv(&xy->greenx, XYZ.greenX, PNG_FP_1, d)) return 1;
+   if (!png_muldiv(&xy->greeny, XYZ.greenY, PNG_FP_1, d)) return 1;
+   dwhite += d;
+   whiteX += XYZ.greenX;
+   whiteY += XYZ.greenY;
+
+   d = XYZ.blueX + XYZ.blueY + XYZ.blueZ;
+   if (!png_muldiv(&xy->bluex, XYZ.blueX, PNG_FP_1, d)) return 1;
+   if (!png_muldiv(&xy->bluey, XYZ.blueY, PNG_FP_1, d)) return 1;
+   dwhite += d;
+   whiteX += XYZ.blueX;
+   whiteY += XYZ.blueY;
+
+   /* The reference white is simply the same of the end-point (X,Y,Z) vectors,
+    * thus:
+    */
+   if (!png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite)) return 1;
+   if (!png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite)) return 1;
+
+   return 0;
+}
+
+int png_XYZ_from_xy(png_XYZ *XYZ, png_xy xy)
+{
+   png_fixed_point red_inverse, green_inverse, blue_scale;
+   png_fixed_point left, right, denominator;
+
+   /* Check xy and, implicitly, z.  Note that wide gamut color spaces typically
+    * have end points with 0 tristimulus values (these are impossible end
+    * points, but they are used to cover the possible colors.)
+    */
+   if (xy.redx < 0 || xy.redx > PNG_FP_1) return 1;
+   if (xy.redy < 0 || xy.redy > PNG_FP_1-xy.redx) return 1;
+   if (xy.greenx < 0 || xy.greenx > PNG_FP_1) return 1;
+   if (xy.greeny < 0 || xy.greeny > PNG_FP_1-xy.greenx) return 1;
+   if (xy.bluex < 0 || xy.bluex > PNG_FP_1) return 1;
+   if (xy.bluey < 0 || xy.bluey > PNG_FP_1-xy.bluex) return 1;
+   if (xy.whitex < 0 || xy.whitex > PNG_FP_1) return 1;
+   if (xy.whitey < 0 || xy.whitey > PNG_FP_1-xy.whitex) return 1;
+
+   /* The reverse calculation is more difficult because the original tristimulus
+    * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
+    * derived values were recorded in the cHRM chunk;
+    * (red,green,blue,white)x(x,y).  This loses one degree of freedom and
+    * therefore an arbitrary ninth value has to be introduced to undo the
+    * original transformations.
+    *
+    * Think of the original end-points as points in (X,Y,Z) space.  The
+    * chromaticity values (c) have the property:
+    *
+    *           C
+    *   c = ---------
+    *       X + Y + Z
+    *
+    * For each c (x,y,z) from the corresponding original C (X,Y,Z).  Thus the
+    * three chromaticity values (x,y,z) for each end-point obey the
+    * relationship:
+    *
+    *   x + y + z = 1
+    *
+    * This describes the plane in (X,Y,Z) space that intersects each axis at the
+    * value 1.0; call this the chromaticity plane.  Thus the chromaticity
+    * calculation has scaled each end-point so that it is on the x+y+z=1 plane
+    * and chromaticity is the intersection of the vector from the origin to the
+    * (X,Y,Z) value with the chromaticity plane.
+    *
+    * To fully invert the chromaticity calculation we would need the three
+    * end-point scale factors, (red-scale, green-scale, blue-scale), but these
+    * were not recorded.  Instead we calculated the reference white (X,Y,Z) and
+    * recorded the chromaticity of this.  The reference white (X,Y,Z) would have
+    * given all three of the scale factors since:
+    *
+    *    color-C = color-c * color-scale
+    *    white-C = red-C + green-C + blue-C
+    *            = red-c*red-scale + green-c*green-scale + blue-c*blue-scale
+    *
+    * But cHRM records only white-x and white-y, so we have lost the white scale
+    * factor:
+    *
+    *    white-C = white-c*white-scale
+    *
+    * To handle this the inverse transformation makes an arbitrary assumption
+    * about white-scale:
+    *
+    *    Assume: white-Y = 1.0
+    *    Hence:  white-scale = 1/white-y
+    *    Or:     red-Y + green-Y + blue-Y = 1.0
+    *
+    * Notice the last statement of the assumption gives an equation in three of
+    * the nine values we want to calculate.  8 more equations come from the
+    * above routine as summarised at the top above (the chromaticity
+    * calculation):
+    *
+    *    Given: color-x = color-X / (color-X + color-Y + color-Z)
+    *    Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0
+    *
+    * This is 9 simultaneous equations in the 9 variables "color-C" and can be
+    * solved by Cramer's rule.  Cramer's rule requires calculating 10 9x9 matrix
+    * determinants, however this is not as bad as it seems because only 28 of
+    * the total of 90 terms in the various matrices are non-zero.  Nevertheless
+    * Cramer's rule is notoriously numerically unstable because the determinant
+    * calculation involves the difference of large, but similar, numbers.  It is
+    * difficult to be sure that the calculation is stable for real world values
+    * and it is certain that it becomes unstable where the end points are close
+    * together.
+    *
+    * So this code uses the perhaps slighly less optimal but more understandable
+    * and totally obvious approach of calculating color-scale.
+    *
+    * This algorithm depends on the precision in white-scale and that is
+    * (1/white-y), so we can immediately see that as white-y approaches 0 the
+    * accuracy inherent in the cHRM chunk drops off substantially.
+    *
+    * libpng arithmetic: a simple invertion of the above equations
+    * ------------------------------------------------------------
+    *
+    *    white_scale = 1/white-y
+    *    white-X = white-x * white-scale
+    *    white-Y = 1.0
+    *    white-Z = (1 - white-x - white-y) * white_scale
+    *
+    *    white-C = red-C + green-C + blue-C
+    *            = red-c*red-scale + green-c*green-scale + blue-c*blue-scale
+    *
+    * This gives us three equations in (red-scale,green-scale,blue-scale) where
+    * all the coefficients are now known:
+    *
+    *    red-x*red-scale + green-x*green-scale + blue-x*blue-scale
+    *       = white-x/white-y
+    *    red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1
+    *    red-z*red-scale + green-z*green-scale + blue-z*blue-scale
+    *       = (1 - white-x - white-y)/white-y
+    *
+    * In the last equation color-z is (1 - color-x - color-y) so we can add all
+    * three equations together to get an alternative third:
+    *
+    *    red-scale + green-scale + blue-scale = 1/white-y = white-scale
+    *
+    * So now we have a Cramer's rule solution where the determinants are just
+    * 3x3 - far more tractible.  Unfortunately 3x3 determinants still involve
+    * multiplication of three coefficients so we can't guarantee to avoid
+    * overflow in the libpng fixed point representation.  Using Cramer's rule in
+    * floating point is probably a good choice here, but it's not an option for
+    * fixed point.  Instead proceed to simplify the first two equations by
+    * eliminating what is likely to be the largest value, blue-scale:
+    *
+    *    blue-scale = white-scale - red-scale - green-scale
+    *
+    * Hence:
+    *
+    *    (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale =
+    *                (white-x - blue-x)*white-scale
+    *
+    *    (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale =
+    *                1 - blue-y*white-scale
+    *
+    * And now we can trivially solve for (red-scale,green-scale):
+    *
+    *    green-scale =
+    *                (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale
+    *                -----------------------------------------------------------
+    *                                  green-x - blue-x
+    *
+    *    red-scale =
+    *                1 - blue-y*white-scale - (green-y - blue-y) * green-scale
+    *                ---------------------------------------------------------
+    *                                  red-y - blue-y
+    *
+    * Hence:
+    *
+    *    red-scale =
+    *          ( (green-x - blue-x) * (white-y - blue-y) -
+    *            (green-y - blue-y) * (white-x - blue-x) ) / white-y
+    * -------------------------------------------------------------------------
+    *  (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)
+    *
+    *    green-scale =
+    *          ( (red-y - blue-y) * (white-x - blue-x) -
+    *            (red-x - blue-x) * (white-y - blue-y) ) / white-y
+    * -------------------------------------------------------------------------
+    *  (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)
+    *
+    * Accuracy:
+    * The input values have 5 decimal digits of accuracy.  The values are all in
+    * the range 0 < value < 1, so simple products are in the same range but may
+    * need up to 10 decimal digits to preserve the original precision and avoid
+    * underflow.  Because we are using a 32-bit signed representation we cannot
+    * match this; the best is a little over 9 decimal digits, less than 10.
+    *
+    * The approach used here is to preserve the maximum precision within the
+    * signed representation.  Because the red-scale calculation above uses the
+    * difference between two products of values that must be in the range -1..+1
+    * it is sufficient to divide the product by 7; ceil(100,000/32767*2).  The
+    * factor is irrelevant in the calculation because it is applied to both
+    * numerator and denominator.
+    *
+    * Note that the values of the differences of the products of the
+    * chromaticities in the above equations tend to be small, for example for
+    * the sRGB chromaticities they are:
+    *
+    * red numerator:    -0.04751
+    * green numerator:  -0.08788
+    * denominator:      -0.2241 (without white-y multiplication)
+    *
+    *  The resultant Y coefficients from the chromaticities of some widely used
+    *  color space definitions are (to 15 decimal places):
+    *
+    *  sRGB
+    *    0.212639005871510 0.715168678767756 0.072192315360734
+    *  Kodak ProPhoto
+    *    0.288071128229293 0.711843217810102 0.000085653960605
+    *  Adobe RGB
+    *    0.297344975250536 0.627363566255466 0.075291458493998
+    *  Adobe Wide Gamut RGB
+    *    0.258728243040113 0.724682314948566 0.016589442011321
+    */
+   /* By the argument, above overflow should be impossible here. The return
+    * value of 2 indicates an internal error to the caller.
+    */
+   if (!png_muldiv(&left, xy.greenx-xy.bluex, xy.redy - xy.bluey, 7)) return 2;
+   if (!png_muldiv(&right, xy.greeny-xy.bluey, xy.redx - xy.bluex, 7)) return 2;
+   denominator = left - right;
+
+   /* Now find the red numerator. */
+   if (!png_muldiv(&left, xy.greenx-xy.bluex, xy.whitey-xy.bluey, 7)) return 2;
+   if (!png_muldiv(&right, xy.greeny-xy.bluey, xy.whitex-xy.bluex, 7)) return 2;
+
+   /* Overflow is possible here and it indicates an extreme set of PNG cHRM
+    * chunk values.  This calculation actually returns the reciprocal of the
+    * scale value because this allows us to delay the multiplication of white-y
+    * into the denominator, which tends to produce a small number.
+    */
+   if (!png_muldiv(&red_inverse, xy.whitey, denominator, left-right) ||
+       red_inverse <= xy.whitey /* r+g+b scales = white scale */)
+      return 1;
+
+   /* Similarly for green_inverse: */
+   if (!png_muldiv(&left, xy.redy-xy.bluey, xy.whitex-xy.bluex, 7)) return 2;
+   if (!png_muldiv(&right, xy.redx-xy.bluex, xy.whitey-xy.bluey, 7)) return 2;
+   if (!png_muldiv(&green_inverse, xy.whitey, denominator, left-right) ||
+       green_inverse <= xy.whitey)
+      return 1;
+
+   /* And the blue scale, the checks above guarantee this can't overflow but it
+    * can still produce 0 for extreme cHRM values.
+    */
+   blue_scale = png_reciprocal(xy.whitey) - png_reciprocal(red_inverse) -
+      png_reciprocal(green_inverse);
+   if (blue_scale <= 0) return 1;
+
+
+   /* And fill in the png_XYZ: */
+   if (!png_muldiv(&XYZ->redX, xy.redx, PNG_FP_1, red_inverse)) return 1;
+   if (!png_muldiv(&XYZ->redY, xy.redy, PNG_FP_1, red_inverse)) return 1;
+   if (!png_muldiv(&XYZ->redZ, PNG_FP_1 - xy.redx - xy.redy, PNG_FP_1,
+      red_inverse))
+      return 1;
+
+   if (!png_muldiv(&XYZ->greenX, xy.greenx, PNG_FP_1, green_inverse)) return 1;
+   if (!png_muldiv(&XYZ->greenY, xy.greeny, PNG_FP_1, green_inverse)) return 1;
+   if (!png_muldiv(&XYZ->greenZ, PNG_FP_1 - xy.greenx - xy.greeny, PNG_FP_1,
+      green_inverse))
+      return 1;
+
+   if (!png_muldiv(&XYZ->blueX, xy.bluex, blue_scale, PNG_FP_1)) return 1;
+   if (!png_muldiv(&XYZ->blueY, xy.bluey, blue_scale, PNG_FP_1)) return 1;
+   if (!png_muldiv(&XYZ->blueZ, PNG_FP_1 - xy.bluex - xy.bluey, blue_scale,
+      PNG_FP_1))
+      return 1;
+
+   return 0; /*success*/
+}
+
+int png_XYZ_from_xy_checked(png_structp png_ptr, png_XYZ *XYZ, png_xy xy)
+{
+   switch (png_XYZ_from_xy(XYZ, xy))
+   {
+      case 0: /* success */
+         return 1;
+
+      case 1:
+         /* The chunk may be technically valid, but we got png_fixed_point
+          * overflow while trying to get XYZ values out of it.  This is
+          * entirely benign - the cHRM chunk is pretty extreme.
+          */
+         png_warning(png_ptr,
+            "extreme cHRM chunk cannot be converted to tristimulus values");
+         break;
+
+      default:
+         /* libpng is broken; this should be a warning but if it happens we
+          * want error reports so for the moment it is an error.
+          */
+         png_error(png_ptr, "internal error in png_XYZ_from_xy");
+         break;
+   }
+
+   /* ERROR RETURN */
+   return 0;
+}
+#endif
+
 void /* PRIVATE */
 png_check_IHDR(png_structp png_ptr,
    png_uint_32 width, png_uint_32 height, int bit_depth,
@@ -763,7 +1187,7 @@ png_check_IHDR(png_structp png_ptr,
    }
 
 #  ifdef PNG_SET_USER_LIMITS_SUPPORTED
-   if (width > png_ptr->user_width_max || width > PNG_USER_WIDTH_MAX)
+   if (width > png_ptr->user_width_max)
 
 #  else
    if (width > PNG_USER_WIDTH_MAX)
@@ -774,7 +1198,7 @@ png_check_IHDR(png_structp png_ptr,
    }
 
 #  ifdef PNG_SET_USER_LIMITS_SUPPORTED
-   if (height > png_ptr->user_height_max || height > PNG_USER_HEIGHT_MAX)
+   if (height > png_ptr->user_height_max)
 #  else
    if (height > PNG_USER_HEIGHT_MAX)
 #  endif
@@ -889,16 +1313,9 @@ png_check_IHDR(png_structp png_ptr,
 /* Check an ASCII formated floating point value, see the more detailed
  * comments in pngpriv.h
  */
-/* The following is used internally to preserve the 'valid' flag */
+/* The following is used internally to preserve the sticky flags */
 #define png_fp_add(state, flags) ((state) |= (flags))
-#define png_fp_set(state, value)\
-   ((state) = (value) | ((state) & PNG_FP_WAS_VALID))
-
-/* Internal type codes: bits above the base state! */
-#define PNG_FP_SIGN   0  /* [+-] */
-#define PNG_FP_DOT    4  /* . */
-#define PNG_FP_DIGIT  8  /* [0123456789] */
-#define PNG_FP_E     12  /* [Ee] */
+#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY))
 
 int /* PRIVATE */
 png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
@@ -911,55 +1328,55 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
    {
       int type;
       /* First find the type of the next character */
+      switch (string[i])
       {
-         char ch = string[i];
-
-         if (ch >= 48 && ch <= 57)
-            type = PNG_FP_DIGIT;
-
-         else switch (ch)
-         {
-         case 43: case 45:  type = PNG_FP_SIGN;  break;
-         case 46:           type = PNG_FP_DOT;   break;
-         case 69: case 101: type = PNG_FP_E;     break;
-         default:           goto PNG_FP_End;
-         }
+      case 43:  type = PNG_FP_SAW_SIGN;                   break;
+      case 45:  type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break;
+      case 46:  type = PNG_FP_SAW_DOT;                    break;
+      case 48:  type = PNG_FP_SAW_DIGIT;                  break;
+      case 49: case 50: case 51: case 52:
+      case 53: case 54: case 55: case 56:
+      case 57:  type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break;
+      case 69:
+      case 101: type = PNG_FP_SAW_E;                      break;
+      default:  goto PNG_FP_End;
       }
 
       /* Now deal with this type according to the current
        * state, the type is arranged to not overlap the
        * bits of the PNG_FP_STATE.
        */
-      switch ((state & PNG_FP_STATE) + type)
+      switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))
       {
-      case PNG_FP_INTEGER + PNG_FP_SIGN:
+      case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:
          if (state & PNG_FP_SAW_ANY)
             goto PNG_FP_End; /* not a part of the number */
 
-         png_fp_add(state, PNG_FP_SAW_SIGN);
+         png_fp_add(state, type);
          break;
 
-      case PNG_FP_INTEGER + PNG_FP_DOT:
+      case PNG_FP_INTEGER + PNG_FP_SAW_DOT:
          /* Ok as trailer, ok as lead of fraction. */
          if (state & PNG_FP_SAW_DOT) /* two dots */
             goto PNG_FP_End;
 
          else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */
-            png_fp_add(state, PNG_FP_SAW_DOT);
+            png_fp_add(state, type);
 
          else
-            png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
+            png_fp_set(state, PNG_FP_FRACTION | type);
 
          break;
 
-      case PNG_FP_INTEGER + PNG_FP_DIGIT:
+      case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:
          if (state & PNG_FP_SAW_DOT) /* delayed fraction */
             png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
 
-         png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
+         png_fp_add(state, type | PNG_FP_WAS_VALID);
 
          break;
-      case PNG_FP_INTEGER + PNG_FP_E:
+
+      case PNG_FP_INTEGER + PNG_FP_SAW_E:
          if ((state & PNG_FP_SAW_DIGIT) == 0)
             goto PNG_FP_End;
 
@@ -967,17 +1384,17 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
 
          break;
 
-   /* case PNG_FP_FRACTION + PNG_FP_SIGN:
-         goto PNG_FP_End; ** no sign in exponent */
+   /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN:
+         goto PNG_FP_End; ** no sign in fraction */
 
-   /* case PNG_FP_FRACTION + PNG_FP_DOT:
+   /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT:
          goto PNG_FP_End; ** Because SAW_DOT is always set */
 
-      case PNG_FP_FRACTION + PNG_FP_DIGIT:
-         png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
+      case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:
+         png_fp_add(state, type | PNG_FP_WAS_VALID);
          break;
 
-      case PNG_FP_FRACTION + PNG_FP_E:
+      case PNG_FP_FRACTION + PNG_FP_SAW_E:
          /* This is correct because the trailing '.' on an
           * integer is handled above - so we can only get here
           * with the sequence ".E" (with no preceding digits).
@@ -989,7 +1406,7 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
 
          break;
 
-      case PNG_FP_EXPONENT + PNG_FP_SIGN:
+      case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:
          if (state & PNG_FP_SAW_ANY)
             goto PNG_FP_End; /* not a part of the number */
 
@@ -997,15 +1414,15 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep,
 
          break;
 
-   /* case PNG_FP_EXPONENT + PNG_FP_DOT:
+   /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT:
          goto PNG_FP_End; */
 
-      case PNG_FP_EXPONENT + PNG_FP_DIGIT:
-         png_fp_add(state, PNG_FP_SAW_DIGIT + PNG_FP_WAS_VALID);
+      case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:
+         png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);
 
          break;
 
-   /* case PNG_FP_EXPONEXT + PNG_FP_E:
+   /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E:
          goto PNG_FP_End; */
 
       default: goto PNG_FP_End; /* I.e. break 2 */
@@ -1033,8 +1450,11 @@ png_check_fp_string(png_const_charp string, png_size_t size)
    int        state=0;
    png_size_t char_index=0;
 
-   return png_check_fp_number(string, size, &state, &char_index) &&
-      (char_index == size || string[char_index] == 0);
+   if (png_check_fp_number(string, size, &state, &char_index) &&
+      (char_index == size || string[char_index] == 0))
+      return state /* must be non-zero - see above */;
+
+   return 0; /* i.e. fail */
 }
 #endif /* pCAL or sCAL */
 
@@ -1102,7 +1522,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
       if (fp < 0)
       {
          fp = -fp;
-         *ascii++ = 45; /* '-'  PLUS 1 TOTAL 1*/
+         *ascii++ = 45; /* '-'  PLUS 1 TOTAL 1 */
          --size;
       }
 
@@ -1329,19 +1749,31 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
              */
             size -= cdigits;
 
-            *ascii++ = 69, --size;    /* 'E': PLUS 1 TOTAL 2+precision*/
-            if (exp_b10 < 0)
+            *ascii++ = 69, --size;    /* 'E': PLUS 1 TOTAL 2+precision */
+
+            /* The following use of an unsigned temporary avoids ambiguities in
+             * the signed arithmetic on exp_b10 and permits GCC at least to do
+             * better optimization.
+             */
             {
-               *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
-               exp_b10 = -exp_b10;
-            }
+               unsigned int uexp_b10;
+
+               if (exp_b10 < 0)
+               {
+                  *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
+                  uexp_b10 = -exp_b10;
+               }
+
+               else
+                  uexp_b10 = exp_b10;
 
-            cdigits = 0;
+               cdigits = 0;
 
-            while (exp_b10 > 0)
-            {
-               exponent[cdigits++] = (char)(48 + exp_b10 % 10);
-               exp_b10 /= 10;
+               while (uexp_b10 > 0)
+               {
+                  exponent[cdigits++] = (char)(48 + uexp_b10 % 10);
+                  uexp_b10 /= 10;
+               }
             }
 
             /* Need another size check here for the exponent digits, so
@@ -1399,9 +1831,9 @@ png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size,
       else
          num = fp;
 
-      if (num <= 0x80000000U) /* else overflowed */
+      if (num <= 0x80000000) /* else overflowed */
       {
-         unsigned int ndigits = 0, first = 16/*flag value*/;
+         unsigned int ndigits = 0, first = 16 /* flag value */;
          char digits[10];
 
          while (num)
@@ -1495,7 +1927,7 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
          r /= divisor;
          r = floor(r+.5);
 
-         /* A png_fixed_point is a 32 bit integer. */
+         /* A png_fixed_point is a 32-bit integer. */
          if (r <= 2147483647. && r >= -2147483648.)
          {
             *res = (png_fixed_point)r;
@@ -1540,7 +1972,7 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
 
          if (s32 < D) /* else overflow */
          {
-            /* s32.s00 is now the 64 bit product, do a standard
+            /* s32.s00 is now the 64-bit product, do a standard
              * division, we know that s32 < D, so the maximum
              * required shift is 31.
              */
@@ -1683,7 +2115,7 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
  * 2010: moved from pngset.c) */
 /*
  *    Multiply two 32-bit numbers, V1 and V2, using 32-bit
- *    arithmetic, to produce a 64 bit result in the HI/LO words.
+ *    arithmetic, to produce a 64-bit result in the HI/LO words.
  *
  *                  A B
  *                x C D
@@ -1727,24 +2159,24 @@ png_64bit_product (long v1, long v2, unsigned long *hi_product,
 /* Fixed point gamma.
  *
  * To calculate gamma this code implements fast log() and exp() calls using only
- * fixed point arithmetic.  This code has sufficient precision for either 8 or
- * 16 bit sample values.
+ * fixed point arithmetic.  This code has sufficient precision for either 8-bit
+ * or 16-bit sample values.
  *
  * The tables used here were calculated using simple 'bc' programs, but C double
  * precision floating point arithmetic would work fine.  The programs are given
  * at the head of each table.
  *
- * 8 bit log table
+ * 8-bit log table
  *   This is a table of -log(value/255)/log(2) for 'value' in the range 128 to
- *   255, so it's the base 2 logarithm of a normalized 8 bit floating point
- *   mantissa.  The numbers are 32 bit fractions.
+ *   255, so it's the base 2 logarithm of a normalized 8-bit floating point
+ *   mantissa.  The numbers are 32-bit fractions.
  */
 static png_uint_32
 png_8bit_l2[128] =
 {
-#  if PNG_DO_BC
+#  ifdef PNG_DO_BC
       for (i=128;i<256;++i) { .5 - l(i/255)/l(2)*65536*65536; }
-#  endif
+#  else
    4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U,
    3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U,
    3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U,
@@ -1767,11 +2199,13 @@ png_8bit_l2[128] =
    324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U,
    172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U,
    24347096U, 0U
+#  endif
+
 #if 0
-   /* The following are the values for 16 bit tables - these work fine for the 8
-    * bit conversions but produce very slightly larger errors in the 16 bit log
-    * (about 1.2 as opposed to 0.7 absolute error in the final value).  To use
-    * these all the shifts below must be adjusted appropriately.
+   /* The following are the values for 16-bit tables - these work fine for the
+    * 8-bit conversions but produce very slightly larger errors in the 16-bit
+    * log (about 1.2 as opposed to 0.7 absolute error in the final value).  To
+    * use these all the shifts below must be adjusted appropriately.
     */
    65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054,
    57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803,
@@ -1788,7 +2222,7 @@ png_8bit_l2[128] =
 #endif
 };
 
-static png_int_32
+PNG_STATIC png_int_32
 png_log8bit(unsigned int x)
 {
    unsigned int lg2 = 0;
@@ -1814,11 +2248,11 @@ png_log8bit(unsigned int x)
    return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16));
 }
 
-/* The above gives exact (to 16 binary places) log2 values for 8 bit images,
- * for 16 bit images we use the most significant 8 bits of the 16 bit value to
+/* The above gives exact (to 16 binary places) log2 values for 8-bit images,
+ * for 16-bit images we use the most significant 8 bits of the 16-bit value to
  * get an approximation then multiply the approximation by a correction factor
  * determined by the remaining up to 8 bits.  This requires an additional step
- * in the 16 bit case.
+ * in the 16-bit case.
  *
  * We want log2(value/65535), we have log2(v'/255), where:
  *
@@ -1827,8 +2261,8 @@ png_log8bit(unsigned int x)
  *
  * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128
  * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less
- * than 258.  The final factor also needs to correct for the fact that our 8 bit
- * value is scaled by 255, whereas the 16 bit values must be scaled by 65535.
+ * than 258.  The final factor also needs to correct for the fact that our 8-bit
+ * value is scaled by 255, whereas the 16-bit values must be scaled by 65535.
  *
  * This gives a final formula using a calculated value 'x' which is value/v' and
  * scaling by 65536 to match the above table:
@@ -1838,13 +2272,13 @@ png_log8bit(unsigned int x)
  * Since these numbers are so close to '1' we can use simple linear
  * interpolation between the two end values 256/257 (result -368.61) and 258/257
  * (result 367.179).  The values used below are scaled by a further 64 to give
- * 16 bit precision in the interpolation:
+ * 16-bit precision in the interpolation:
  *
  * Start (256): -23591
  * Zero  (257):      0
  * End   (258):  23499
  */
-static png_int_32
+PNG_STATIC png_int_32
 png_log16bit(png_uint_32 x)
 {
    unsigned int lg2 = 0;
@@ -1865,7 +2299,7 @@ png_log16bit(png_uint_32 x)
    if ((x & 0x8000) == 0)
       lg2 += 1, x <<= 1;
 
-   /* Calculate the base logarithm from the top 8 bits as a 28 bit fractional
+   /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional
     * value.
     */
    lg2 <<= 28;
@@ -1895,34 +2329,35 @@ png_log16bit(png_uint_32 x)
    return (png_int_32)((lg2 + 2048) >> 12);
 }
 
-/* The 'exp()' case must invert the above, taking a 20 bit fixed point
- * logarithmic value and returning a 16 or 8 bit number as appropriate.  In
+/* The 'exp()' case must invert the above, taking a 20-bit fixed point
+ * logarithmic value and returning a 16 or 8-bit number as appropriate.  In
  * each case only the low 16 bits are relevant - the fraction - since the
  * integer bits (the top 4) simply determine a shift.
  *
- * The worst case is the 16 bit distinction between 65535 and 65534, this
- * requires perhaps spurious accuracty in the decoding of the logarithm to
+ * The worst case is the 16-bit distinction between 65535 and 65534, this
+ * requires perhaps spurious accuracy in the decoding of the logarithm to
  * distinguish log2(65535/65534.5) - 10^-5 or 17 bits.  There is little chance
  * of getting this accuracy in practice.
  *
  * To deal with this the following exp() function works out the exponent of the
- * frational part of the logarithm by using an accurate 32 bit value from the
+ * frational part of the logarithm by using an accurate 32-bit value from the
  * top four fractional bits then multiplying in the remaining bits.
  */
 static png_uint_32
 png_32bit_exp[16] =
 {
-#  if PNG_DO_BC
+#  ifdef PNG_DO_BC
       for (i=0;i<16;++i) { .5 + e(-i/16*l(2))*2^32; }
-#  endif
-   /* NOTE: the first entry is deliberately set to the maximum 32 bit value. */
+#  else
+   /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */
    4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U,
    3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U,
    2553802834U, 2445529972U, 2341847524U, 2242560872U
+#  endif
 };
 
 /* Adjustment table; provided to explain the numbers in the code below. */
-#if PNG_DO_BC
+#ifdef PNG_DO_BC
 for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"}
    11 44937.64284865548751208448
    10 45180.98734845585101160448
@@ -1938,12 +2373,12 @@ for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"}
     0 45425.85339951654943850496
 #endif
 
-static png_uint_32
+PNG_STATIC png_uint_32
 png_exp(png_fixed_point x)
 {
    if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */
    {
-      /* Obtain a 4 bit approximation */
+      /* Obtain a 4-bit approximation */
       png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf];
 
       /* Incorporate the low 12 bits - these decrease the returned value by
@@ -1986,13 +2421,13 @@ png_exp(png_fixed_point x)
    return 0;
 }
 
-static png_byte
+PNG_STATIC png_byte
 png_exp8bit(png_fixed_point lg2)
 {
-   /* Get a 32 bit value: */
+   /* Get a 32-bit value: */
    png_uint_32 x = png_exp(lg2);
 
-   /* Convert the 32 bit value to 0..255 by multiplying by 256-1, note that the
+   /* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the
     * second, rounding, step can't overflow because of the first, subtraction,
     * step.
     */
@@ -2000,13 +2435,13 @@ png_exp8bit(png_fixed_point lg2)
    return (png_byte)((x + 0x7fffffU) >> 24);
 }
 
-static png_uint_16
+PNG_STATIC png_uint_16
 png_exp16bit(png_fixed_point lg2)
 {
-   /* Get a 32 bit value: */
+   /* Get a 32-bit value: */
    png_uint_32 x = png_exp(lg2);
 
-   /* Convert the 32 bit value to 0..65535 by multiplying by 65536-1: */
+   /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */
    x -= x >> 16;
    return (png_uint_16)((x + 32767U) >> 16);
 }
@@ -2059,9 +2494,9 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
 }
 
 /* This does the right thing based on the bit_depth field of the
- * png_struct, interpreting values as 8 or 16 bit.  While the result
- * is nominally a 16 bit value if bit depth is 8 then the result is
- * 8 bit (as are the arguments.)
+ * png_struct, interpreting values as 8-bit or 16-bit.  While the result
+ * is nominally a 16-bit value if bit depth is 8 then the result is
+ * 8-bit (as are the arguments.)
  */
 png_uint_16 /* PRIVATE */
 png_gamma_correct(png_structp png_ptr, unsigned int value,
@@ -2084,8 +2519,8 @@ png_gamma_significant(png_fixed_point gamma_val)
        gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED;
 }
 
-/* Internal function to build a single 16 bit table - the table consists of
- * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount
+/* Internal function to build a single 16-bit table - the table consists of
+ * 'num' 256-entry subtables, where 'num' is determined by 'shift' - the amount
  * to shift the input values right (or 16-number_of_signifiant_bits).
  *
  * The caller is responsible for ensuring that the table gets cleaned up on
@@ -2111,7 +2546,7 @@ png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
           (png_uint_16p)png_malloc(png_ptr, 256 * png_sizeof(png_uint_16));
 
       /* The 'threshold' test is repeated here because it can arise for one of
-       * the 16 bit tables even if the others don't hit it.
+       * the 16-bit tables even if the others don't hit it.
        */
       if (png_gamma_significant(gamma_val))
       {
@@ -2172,9 +2607,9 @@ png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,
    png_uint_16pp table = *ptable =
        (png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p));
 
-   /* 'num' is the number of tables and also the number of low bits of low
-    * bits of the input 16 bit value used to select a table.  Each table is
-    * itself index by the high 8 bits of the value.
+   /* 'num' is the number of tables and also the number of low bits of the
+    * input 16-bit value used to select a table.  Each table is itself indexed
+    * by the high 8 bits of the value.
     */
    for (i = 0; i < num; i++)
       table[i] = (png_uint_16p)png_malloc(png_ptr,
@@ -2183,24 +2618,24 @@ png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,
    /* 'gamma_val' is set to the reciprocal of the value calculated above, so
     * pow(out,g) is an *input* value.  'last' is the last input value set.
     *
-    * In the loop 'i' is used to find output values.  Since the output is 8
-    * bit there are only 256 possible values.  The tables are set up to
+    * In the loop 'i' is used to find output values.  Since the output is
+    * 8-bit there are only 256 possible values.  The tables are set up to
     * select the closest possible output value for each input by finding
     * the input value at the boundary between each pair of output values
     * and filling the table up to that boundary with the lower output
     * value.
     *
-    * The boundary values are 0.5,1.5..253.5,254.5.  Since these are 9 bit
-    * values the code below uses a 16 bit value in i; the values start at
+    * The boundary values are 0.5,1.5..253.5,254.5.  Since these are 9-bit
+    * values the code below uses a 16-bit value in i; the values start at
     * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last
     * entries are filled with 255).  Start i at 128 and fill all 'last'
     * table entries <= 'max'
     */
    last = 0;
-   for (i = 0; i < 255; ++i) /* 8 bit output value */
+   for (i = 0; i < 255; ++i) /* 8-bit output value */
    {
       /* Find the corresponding maximum input value */
-      png_uint_16 out = (png_uint_16)(i * 257U); /* 16 bit output value */
+      png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */
 
       /* Find the boundary value in 16 bits: */
       png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val);
@@ -2223,9 +2658,9 @@ png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,
    }
 }
 
-/* Build a single 8 bit table: same as the 16 bit case but much simpler (and
+/* Build a single 8-bit table: same as the 16-bit case but much simpler (and
  * typically much faster).  Note that libpng currently does no sBIT processing
- * (apparently contrary to the spec) so a 256 entry table is always generated.
+ * (apparently contrary to the spec) so a 256-entry table is always generated.
  */
 static void
 png_build_8bit_table(png_structp png_ptr, png_bytepp ptable,
@@ -2241,6 +2676,60 @@ png_build_8bit_table(png_structp png_ptr, png_bytepp ptable,
       table[i] = (png_byte)i;
 }
 
+/* Used from png_read_destroy and below to release the memory used by the gamma
+ * tables.
+ */
+void /* PRIVATE */
+png_destroy_gamma_table(png_structp png_ptr)
+{
+   png_free(png_ptr, png_ptr->gamma_table);
+   png_ptr->gamma_table = NULL;
+
+   if (png_ptr->gamma_16_table != NULL)
+   {
+      int i;
+      int istop = (1 << (8 - png_ptr->gamma_shift));
+      for (i = 0; i < istop; i++)
+      {
+         png_free(png_ptr, png_ptr->gamma_16_table[i]);
+      }
+   png_free(png_ptr, png_ptr->gamma_16_table);
+   png_ptr->gamma_16_table = NULL;
+   }
+
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
+   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
+   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
+   png_free(png_ptr, png_ptr->gamma_from_1);
+   png_ptr->gamma_from_1 = NULL;
+   png_free(png_ptr, png_ptr->gamma_to_1);
+   png_ptr->gamma_to_1 = NULL;
+
+   if (png_ptr->gamma_16_from_1 != NULL)
+   {
+      int i;
+      int istop = (1 << (8 - png_ptr->gamma_shift));
+      for (i = 0; i < istop; i++)
+      {
+         png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
+      }
+   png_free(png_ptr, png_ptr->gamma_16_from_1);
+   png_ptr->gamma_16_from_1 = NULL;
+   }
+   if (png_ptr->gamma_16_to_1 != NULL)
+   {
+      int i;
+      int istop = (1 << (8 - png_ptr->gamma_shift));
+      for (i = 0; i < istop; i++)
+      {
+         png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
+      }
+   png_free(png_ptr, png_ptr->gamma_16_to_1);
+   png_ptr->gamma_16_to_1 = NULL;
+   }
+#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
+}
+
 /* We build the 8- or 16-bit gamma tables here.  Note that for 16-bit
  * tables, we don't make a full table if we are reducing to 8-bit in
  * the future.  Note also how the gamma_16 tables are segmented so that
@@ -2251,6 +2740,18 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
 {
   png_debug(1, "in png_build_gamma_table");
 
+  /* Remove any existing table; this copes with multiple calls to
+   * png_read_update_info.  The warning is because building the gamma tables
+   * multiple times is a performance hit - it's harmless but the ability to call
+   * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible
+   * to warn if the app introduces such a hit.
+   */
+  if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)
+  {
+    png_warning(png_ptr, "gamma table being rebuilt");
+    png_destroy_gamma_table(png_ptr);
+  }
+
   if (bit_depth <= 8)
   {
      png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
@@ -2258,8 +2759,9 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
          png_ptr->screen_gamma) : PNG_FP_1);
 
 #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
+   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
    defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-     if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
+     if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
      {
         png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,
             png_reciprocal(png_ptr->gamma));
@@ -2268,7 +2770,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
             png_ptr->screen_gamma > 0 ?  png_reciprocal(png_ptr->screen_gamma) :
             png_ptr->gamma/* Probably doing rgb_to_gray */);
      }
-#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */
+#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
   }
   else
   {
@@ -2287,14 +2789,14 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
      else
         sig_bit = png_ptr->sig_bit.gray;
 
-     /* 16 bit gamma code uses this equation:
+     /* 16-bit gamma code uses this equation:
       *
       *   ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]
       *
       * Where 'iv' is the input color value and 'ov' is the output value -
       * pow(iv, gamma).
       *
-      * Thus the gamma table consists of up to 256 256 entry tables.  The table
+      * Thus the gamma table consists of up to 256 256-entry tables.  The table
       * is selected by the (8-gamma_shift) most significant of the low 8 bits of
       * the color value then indexed by the upper 8 bits:
       *
@@ -2302,7 +2804,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
       *
       * So the table 'n' corresponds to all those 'iv' of:
       *
-      *   <all high 8 bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>
+      *   <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>
       *
       */
      if (sig_bit > 0 && sig_bit < 16U)
@@ -2311,7 +2813,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
      else
         shift = 0; /* keep all 16 bits */
 
-     if (png_ptr->transformations & PNG_16_TO_8)
+     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
      {
         /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
          * the significant bits in the *input* when the output will
@@ -2327,7 +2829,12 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
      png_ptr->gamma_shift = shift;
 
 #ifdef PNG_16BIT_SUPPORTED
-     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
+     /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
+      * PNG_COMPOSE).  This effectively smashed the background calculation for
+      * 16-bit output because the 8-bit table assumes the result will be reduced
+      * to 8 bits.
+      */
+     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
 #endif
          png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
          png_ptr->screen_gamma > 0 ? png_product2(png_ptr->gamma,
@@ -2341,8 +2848,9 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
 #endif
 
 #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
+   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
    defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-     if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
+     if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
      {
         png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,
             png_reciprocal(png_ptr->gamma));
@@ -2355,7 +2863,7 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth)
             png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
             png_ptr->gamma/* Probably doing rgb_to_gray */);
      }
-#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */
+#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
   }
 }
 #endif /* READ_GAMMA */
index 0af42b170ecd9fb2b5acb4be956aa64496830167..5617c9720e2a00ca94f26752e1172aefe55bf74a 100644 (file)
@@ -1,8 +1,8 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.5.2 - March 31, 2011
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * libpng version 1.5.9 - February 18, 2012
+ * Copyright (c) 1998-2012 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -11,7 +11,7 @@
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.5.2 - March 31, 2011: Glenn
+ *   libpng versions 0.97, January 1998, through 1.5.9 - February 18, 2012: Glenn
  *   See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
  *    1.5.2beta01-03          15    10502  15.so.15.2[.0]
  *    1.5.2rc01-03            15    10502  15.so.15.2[.0]
  *    1.5.2                   15    10502  15.so.15.2[.0]
+ *    1.5.3beta01-10          15    10503  15.so.15.3[.0]
+ *    1.5.3rc01-02            15    10503  15.so.15.3[.0]
+ *    1.5.3beta11             15    10503  15.so.15.3[.0]
+ *    1.5.3 [omitted]
+ *    1.5.4beta01-08          15    10504  15.so.15.4[.0]
+ *    1.5.4rc01               15    10504  15.so.15.4[.0]
+ *    1.5.4                   15    10504  15.so.15.4[.0]
+ *    1.5.5beta01-08          15    10505  15.so.15.5[.0]
+ *    1.5.5rc01               15    10505  15.so.15.5[.0]
+ *    1.5.5                   15    10505  15.so.15.5[.0]
+ *    1.5.6beta01-07          15    10506  15.so.15.6[.0]
+ *    1.5.6rc01-03            15    10506  15.so.15.6[.0]
+ *    1.5.6                   15    10506  15.so.15.6[.0]
+ *    1.5.7beta01-05          15    10507  15.so.15.7[.0]
+ *    1.5.7rc01-03            15    10507  15.so.15.7[.0]
+ *    1.5.7                   15    10507  15.so.15.7[.0]
+ *    1.5.8beta01             15    10508  15.so.15.8[.0]
+ *    1.5.8rc01               15    10508  15.so.15.8[.0]
+ *    1.5.8                   15    10508  15.so.15.8[.0]
+ *    1.5.9beta01-02          15    10509  15.so.15.9[.0]
+ *    1.5.9rc01               15    10509  15.so.15.9[.0]
+ *    1.5.9                   15    10509  15.so.15.9[.0]
  *
  *   Henceforth the source version will match the shared-library major
  *   and minor numbers; the shared-library major version number will be
  *
  * This code is released under the libpng license.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.5.2, March 31, 2011, are
- * Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
+ * libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are
+ * Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
  * distributed according to the same disclaimer and license as libpng-1.2.5
  * with the following individual added to the list of Contributing Authors:
  *
  * Y2K compliance in libpng:
  * =========================
  *
- *    March 31, 2011
+ *    February 18, 2012
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
  *
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.5.2 are Y2K compliant.  It is my belief that
+ *    upward through 1.5.9 are Y2K compliant.  It is my belief that
  *    earlier versions were also Y2K compliant.
  *
- *    Libpng only has three year fields.  One is a 2-byte unsigned integer
- *    that will hold years up to 65535.  The other two hold the date in text
+ *    Libpng only has two year fields.  One is a 2-byte unsigned integer
+ *    that will hold years up to 65535.  The other holds the date in text
  *    format, and will hold years up to 9999.
  *
  *    The integer is
  *        "png_uint_16 year" in png_time_struct.
  *
- *    The strings are
- *        "png_charp time_buffer" in png_struct and
- *        "near_time_buffer", which is a local character string in png.c.
+ *    The string is
+ *        "png_char time_buffer" in png_struct
  *
  *    There are seven time-related functions:
  *        png.c: png_convert_to_rfc_1123() in png.c
  * describes how to use libpng, and the file example.c summarizes it
  * with some code on which to build.  This file is useful for looking
  * at the actual function definitions and structure components.
+ *
+ * If you just need to read a PNG file and don't want to read the documentation
+ * skip to the end of this file and read the section entitled 'simplified API'.
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.5.2"
+#define PNG_LIBPNG_VER_STRING "1.5.9"
 #define PNG_HEADER_VERSION_STRING \
-     " libpng version 1.5.2 - March 31, 2011\n"
+     " libpng version 1.5.9 - February 18, 2012\n"
 
 #define PNG_LIBPNG_VER_SONUM   15
 #define PNG_LIBPNG_VER_DLLNUM  15
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   5
-#define PNG_LIBPNG_VER_RELEASE 2
+#define PNG_LIBPNG_VER_RELEASE 9
+
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
  */
  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
  */
-#define PNG_LIBPNG_VER 10502 /* 1.5.2 */
+#define PNG_LIBPNG_VER 10509 /* 1.5.9 */
 
 /* Library configuration: these options cannot be changed after
  * the library has been built.
@@ -517,7 +542,7 @@ extern "C" {
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef char* png_libpng_version_1_5_2;
+typedef char* png_libpng_version_1_5_9;
 
 /* Three color definitions.  The order of the red, green, and blue, (and the
  * exact size) is not important, although the size of the fields need to
@@ -592,11 +617,20 @@ typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
 #ifdef PNG_TEXT_SUPPORTED
 /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
  * and whether that contents is compressed or not.  The "key" field
- * points to a regular zero-terminated C string.  The "text", "lang", and
- * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
- * However, the * structure returned by png_get_text() will always contain
- * regular zero-terminated C strings (possibly empty), never NULL pointers,
- * so they can be safely used in printf() and other string-handling functions.
+ * points to a regular zero-terminated C string.  The "text" fields can be a
+ * regular C string, an empty string, or a NULL pointer.
+ * However, the structure returned by png_get_text() will always contain
+ * the "text" field as a regular zero-terminated C string (possibly
+ * empty), never a NULL pointer, so it can be safely used in printf() and
+ * other string-handling functions.  Note that the "itxt_length", "lang", and
+ * "lang_key" members of the structure only exist when the library is built
+ * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by
+ * default without iTXt support. Also note that when iTXt *is* supported,
+ * the "lang" and "lang_key" fields contain NULL pointers when the
+ * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or
+ * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the
+ * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag"
+ * which is always 0 or 1, or its "compression method" which is always 0.
  */
 typedef struct png_text_struct
 {
@@ -665,12 +699,24 @@ typedef struct png_unknown_chunk_t
     /* libpng-using applications should NOT directly modify this byte. */
     png_byte location; /* mode of operation at read time */
 }
+
+
 png_unknown_chunk;
 typedef png_unknown_chunk FAR * png_unknown_chunkp;
 typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp;
 typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
 #endif
 
+/* Values for the unknown chunk location byte */
+
+#define PNG_HAVE_IHDR  0x01
+#define PNG_HAVE_PLTE  0x02
+#define PNG_AFTER_IDAT 0x08
+
+/* The complete definition of png_info has, as of libpng-1.5.0,
+ * been moved into a separate header file that is not accessible to
+ * applications.  Read libpng-manual.txt or libpng.3 for more info.
+ */
 typedef struct png_info_def png_info;
 typedef png_info FAR * png_infop;
 typedef PNG_CONST png_info FAR * png_const_infop;
@@ -686,6 +732,8 @@ typedef png_info FAR * FAR * png_infopp;
  */
 #define PNG_FP_1    100000
 #define PNG_FP_HALF  50000
+#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)
+#define PNG_FP_MIN  (-PNG_FP_MAX)
 
 /* These describe the color_type field in png_info. */
 /* color type masks */
@@ -773,7 +821,7 @@ typedef png_info FAR * FAR * png_infopp;
 #define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */
 #define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
 #define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
-#define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
+#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */
 
 /* This is used for the transformation routines, as some of them
  * change these values for the row.  It also should enable using
@@ -792,6 +840,14 @@ typedef struct png_row_info_struct
 typedef png_row_info FAR * png_row_infop;
 typedef png_row_info FAR * FAR * png_row_infopp;
 
+/* The complete definition of png_struct has, as of libpng-1.5.0,
+ * been moved into a separate header file that is not accessible to
+ * applications.  Read libpng-manual.txt or libpng.3 for more info.
+ */
+typedef struct png_struct_def png_struct;
+typedef PNG_CONST png_struct FAR * png_const_structp;
+typedef png_struct FAR * png_structp;
+
 /* These are the function types for the I/O functions and for the functions
  * that allow the user to override the default I/O functions with his or her
  * own.  The png_error_ptr type should match that of user-supplied warning
@@ -800,10 +856,6 @@ typedef png_row_info FAR * FAR * png_row_infopp;
  * modify the buffer it is passed. The 'read' function, on the other hand, is
  * expected to return the read data in the buffer.
  */
-typedef struct png_struct_def png_struct;
-typedef PNG_CONST png_struct FAR * png_const_structp;
-typedef png_struct FAR * png_structp;
-
 typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
 typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));
 typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
@@ -845,25 +897,18 @@ typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp));
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
-/* This must match the function definition in <setjmp.h>, and the
- * application must include this before png.h to obtain the definition
- * of jmp_buf.  The function is required to be PNG_NORETURN.  (Note that
- * PNG_PTR_NORETURN is used here because current versions of the Microsoft
- * C compiler do not support the PNG_NORETURN attribute on a pointer.)
- *
- * If you get a type warning from the compiler when linking against this line
- * then your compiler has 'longjmp' that does not match the requirements of the
- * compiler that built libpng.  You will have to write a wrapper function for
- * your compiler's longjmp and call png_set_longjmp_fn directly (not via the
- * png_jmpbuf macro.)
- *
- * If you get a warning here while building the library you will need to make
+/* This must match the function definition in <setjmp.h>, and the application
+ * must include this before png.h to obtain the definition of jmp_buf.  The
+ * function is required to be PNG_NORETURN, but this is not checked.  If the
+ * function does return the application will crash via an abort() or similar
+ * system level call.
+ *
+ * If you get a warning here while building the library you may need to make
  * changes to ensure that pnglibconf.h records the calling convention used by
  * your compiler.  This may be very difficult - try using a different compiler
  * to build the library!
  */
-typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)),
-   PNG_PTR_NORETURN);
+PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
 #endif
 
 /* Transform masks for the high-level interface */
@@ -885,6 +930,9 @@ typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)),
 #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */
 /* Added to libpng-1.4.0 */
 #define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */
+/* Added to libpng-1.5.4 */
+#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */
+#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */
 
 /* Flags for MNG supported features */
 #define PNG_FLAG_MNG_EMPTY_PLTE     0x01
@@ -1079,7 +1127,7 @@ PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structp png_ptr));
 #endif
 
 #ifdef PNG_READ_EXPAND_16_SUPPORTED
-/* Expand to 16 bit channels, forces conversion of palette to RGB and expansion
+/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion
  * of a tRNS chunk if present.
  */
 PNG_EXPORT(221, void, png_set_expand_16, (png_structp png_ptr));
@@ -1097,6 +1145,11 @@ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));
 
 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
 /* Reduce RGB to grayscale. */
+#define PNG_ERROR_ACTION_NONE  1
+#define PNG_ERROR_ACTION_WARN  2
+#define PNG_ERROR_ACTION_ERROR 3
+#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/
+
 PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,
     int error_action, double red, double green));
 PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr,
@@ -1106,8 +1159,219 @@ PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp
     png_ptr));
 #endif
 
+#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
 PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
     png_colorp palette));
+#endif
+
+#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+/* How the alpha channel is interpreted - this affects how the color channels of
+ * a PNG file are returned when an alpha channel, or tRNS chunk in a palette
+ * file, is present.
+ *
+ * This has no effect on the way pixels are written into a PNG output
+ * datastream. The color samples in a PNG datastream are never premultiplied
+ * with the alpha samples.
+ *
+ * The default is to return data according to the PNG specification: the alpha
+ * channel is a linear measure of the contribution of the pixel to the
+ * corresponding composited pixel.  The gamma encoded color channels must be
+ * scaled according to the contribution and to do this it is necessary to undo
+ * the encoding, scale the color values, perform the composition and reencode
+ * the values.  This is the 'PNG' mode.
+ *
+ * The alternative is to 'associate' the alpha with the color information by
+ * storing color channel values that have been scaled by the alpha.  The
+ * advantage is that the color channels can be resampled (the image can be
+ * scaled) in this form.  The disadvantage is that normal practice is to store
+ * linear, not (gamma) encoded, values and this requires 16-bit channels for
+ * still images rather than the 8-bit channels that are just about sufficient if
+ * gamma encoding is used.  In addition all non-transparent pixel values,
+ * including completely opaque ones, must be gamma encoded to produce the final
+ * image.  This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the
+ * latter being the two common names for associated alpha color channels.)
+ *
+ * Since it is not necessary to perform arithmetic on opaque color values so
+ * long as they are not to be resampled and are in the final color space it is
+ * possible to optimize the handling of alpha by storing the opaque pixels in
+ * the PNG format (adjusted for the output color space) while storing partially
+ * opaque pixels in the standard, linear, format.  The accuracy required for
+ * standard alpha composition is relatively low, because the pixels are
+ * isolated, therefore typically the accuracy loss in storing 8-bit linear
+ * values is acceptable.  (This is not true if the alpha channel is used to
+ * simulate transparency over large areas - use 16 bits or the PNG mode in
+ * this case!)  This is the 'OPTIMIZED' mode.  For this mode a pixel is
+ * treated as opaque only if the alpha value is equal to the maximum value.
+ *
+ * The final choice is to gamma encode the alpha channel as well.  This is
+ * broken because, in practice, no implementation that uses this choice
+ * correctly undoes the encoding before handling alpha composition.  Use this
+ * choice only if other serious errors in the software or hardware you use
+ * mandate it; the typical serious error is for dark halos to appear around
+ * opaque areas of the composited PNG image because of arithmetic overflow.
+ *
+ * The API function png_set_alpha_mode specifies which of these choices to use
+ * with an enumerated 'mode' value and the gamma of the required output:
+ */
+#define PNG_ALPHA_PNG           0 /* according to the PNG standard */
+#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */
+#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */
+#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */
+#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */
+#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */
+
+PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structp png_ptr, int mode,
+    double output_gamma));
+PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structp png_ptr,
+    int mode, png_fixed_point output_gamma));
+#endif
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
+/* The output_gamma value is a screen gamma in libpng terminology: it expresses
+ * how to decode the output values, not how they are encoded.  The values used
+ * correspond to the normal numbers used to describe the overall gamma of a
+ * computer display system; for example 2.2 for an sRGB conformant system.  The
+ * values are scaled by 100000 in the _fixed version of the API (so 220000 for
+ * sRGB.)
+ *
+ * The inverse of the value is always used to provide a default for the PNG file
+ * encoding if it has no gAMA chunk and if png_set_gamma() has not been called
+ * to override the PNG gamma information.
+ *
+ * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode
+ * opaque pixels however pixels with lower alpha values are not encoded,
+ * regardless of the output gamma setting.
+ *
+ * When the standard Porter Duff handling is requested with mode 1 the output
+ * encoding is set to be linear and the output_gamma value is only relevant
+ * as a default for input data that has no gamma information.  The linear output
+ * encoding will be overridden if png_set_gamma() is called - the results may be
+ * highly unexpected!
+ *
+ * The following numbers are derived from the sRGB standard and the research
+ * behind it.  sRGB is defined to be approximated by a PNG gAMA chunk value of
+ * 0.45455 (1/2.2) for PNG.  The value implicitly includes any viewing
+ * correction required to take account of any differences in the color
+ * environment of the original scene and the intended display environment; the
+ * value expresses how to *decode* the image for display, not how the original
+ * data was *encoded*.
+ *
+ * sRGB provides a peg for the PNG standard by defining a viewing environment.
+ * sRGB itself, and earlier TV standards, actually use a more complex transform
+ * (a linear portion then a gamma 2.4 power law) than PNG can express.  (PNG is
+ * limited to simple power laws.)  By saying that an image for direct display on
+ * an sRGB conformant system should be stored with a gAMA chunk value of 45455
+ * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification
+ * makes it possible to derive values for other display systems and
+ * environments.
+ *
+ * The Mac value is deduced from the sRGB based on an assumption that the actual
+ * extra viewing correction used in early Mac display systems was implemented as
+ * a power 1.45 lookup table.
+ *
+ * Any system where a programmable lookup table is used or where the behavior of
+ * the final display device characteristics can be changed requires system
+ * specific code to obtain the current characteristic.  However this can be
+ * difficult and most PNG gamma correction only requires an approximate value.
+ *
+ * By default, if png_set_alpha_mode() is not called, libpng assumes that all
+ * values are unencoded, linear, values and that the output device also has a
+ * linear characteristic.  This is only very rarely correct - it is invariably
+ * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the
+ * default if you don't know what the right answer is!
+ *
+ * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS
+ * 10.6) which used a correction table to implement a somewhat lower gamma on an
+ * otherwise sRGB system.
+ *
+ * Both these values are reserved (not simple gamma values) in order to allow
+ * more precise correction internally in the future.
+ *
+ * NOTE: the following values can be passed to either the fixed or floating
+ * point APIs, but the floating point API will also accept floating point
+ * values.
+ */
+#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */
+#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */
+#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */
+#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */
+#endif
+
+/* The following are examples of calls to png_set_alpha_mode to achieve the
+ * required overall gamma correction and, where necessary, alpha
+ * premultiplication.
+ *
+ * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
+ *    This is the default libpng handling of the alpha channel - it is not
+ *    pre-multiplied into the color components.  In addition the call states
+ *    that the output is for a sRGB system and causes all PNG files without gAMA
+ *    chunks to be assumed to be encoded using sRGB.
+ *
+ * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
+ *    In this case the output is assumed to be something like an sRGB conformant
+ *    display preceeded by a power-law lookup table of power 1.45.  This is how
+ *    early Mac systems behaved.
+ *
+ * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);
+ *    This is the classic Jim Blinn approach and will work in academic
+ *    environments where everything is done by the book.  It has the shortcoming
+ *    of assuming that input PNG data with no gamma information is linear - this
+ *    is unlikely to be correct unless the PNG files where generated locally.
+ *    Most of the time the output precision will be so low as to show
+ *    significant banding in dark areas of the image.
+ *
+ * png_set_expand_16(pp);
+ * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);
+ *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files
+ *    are assumed to have the sRGB encoding if not marked with a gamma value and
+ *    the output is always 16 bits per component.  This permits accurate scaling
+ *    and processing of the data.  If you know that your input PNG files were
+ *    generated locally you might need to replace PNG_DEFAULT_sRGB with the
+ *    correct value for your system.
+ *
+ * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);
+ *    If you just need to composite the PNG image onto an existing background
+ *    and if you control the code that does this you can use the optimization
+ *    setting.  In this case you just copy completely opaque pixels to the
+ *    output.  For pixels that are not completely transparent (you just skip
+ *    those) you do the composition math using png_composite or png_composite_16
+ *    below then encode the resultant 8-bit or 16-bit values to match the output
+ *    encoding.
+ *
+ * Other cases
+ *    If neither the PNG nor the standard linear encoding work for you because
+ *    of the software or hardware you use then you have a big problem.  The PNG
+ *    case will probably result in halos around the image.  The linear encoding
+ *    will probably result in a washed out, too bright, image (it's actually too
+ *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably
+ *    substantially reduce the halos.  Alternatively try:
+ *
+ * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);
+ *    This option will also reduce the halos, but there will be slight dark
+ *    halos round the opaque parts of the image where the background is light.
+ *    In the OPTIMIZED mode the halos will be light halos where the background
+ *    is dark.  Take your pick - the halos are unavoidable unless you can get
+ *    your hardware/software fixed!  (The OPTIMIZED approach is slightly
+ *    faster.)
+ *
+ * When the default gamma of PNG files doesn't match the output gamma.
+ *    If you have PNG files with no gamma information png_set_alpha_mode allows
+ *    you to provide a default gamma, but it also sets the ouput gamma to the
+ *    matching value.  If you know your PNG files have a gamma that doesn't
+ *    match the output you can take advantage of the fact that
+ *    png_set_alpha_mode always sets the output gamma but only sets the PNG
+ *    default if it is not already set:
+ *
+ * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
+ * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);
+ *    The first call sets both the default and the output gamma values, the
+ *    second call overrides the output gamma without changing the default.  This
+ *    is easier than achieving the same effect with png_set_gamma.  You must use
+ *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will
+ *    fire if more than one call to png_set_alpha_mode and png_set_background is
+ *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG
+ *    are ignored.
+ */
 
 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
 PNG_EXPORT(36, void, png_set_strip_alpha, (png_structp png_ptr));
@@ -1175,7 +1439,11 @@ PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));
 #endif
 
 #ifdef PNG_READ_BACKGROUND_SUPPORTED
-/* Handle alpha and tRNS by replacing with a background color. */
+/* Handle alpha and tRNS by replacing with a background color.  Prior to
+ * libpng-1.5.4 this API must not be called before the PNG file header has been
+ * read.  Doing so will result in unexpected behavior and possible warnings or
+ * errors if the PNG file contains a bKGD chunk.
+ */
 PNG_FP_EXPORT(47, void, png_set_background, (png_structp png_ptr,
     png_const_color_16p background_color, int background_gamma_code,
     int need_expand, double background_gamma));
@@ -1190,7 +1458,13 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,
 #  define PNG_BACKGROUND_GAMMA_UNIQUE  3
 #endif
 
-#ifdef PNG_READ_16_TO_8_SUPPORTED
+#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+/* Scale a 16-bit depth file down to 8-bit, accurately. */
+PNG_EXPORT(229, void, png_set_scale_16, (png_structp png_ptr));
+#endif
+
+#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
+#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
 /* Strip the second byte of information from a 16-bit depth file. */
 PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));
 #endif
@@ -1211,12 +1485,22 @@ PNG_EXPORT(49, void, png_set_quantize,
  */
 #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)
 
-/* Handle gamma correction. Screen_gamma=(display_exponent) */
+/* Handle gamma correction. Screen_gamma=(display_exponent).
+ * NOTE: this API simply sets the screen and file gamma values. It will
+ * therefore override the value for gamma in a PNG file if it is called after
+ * the file header has been read - use with care  - call before reading the PNG
+ * file for best results!
+ *
+ * These routines accept the same gamma values as png_set_alpha_mode (described
+ * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either
+ * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value
+ * is the inverse of a 'screen gamma' value.
+ */
 PNG_FP_EXPORT(50, void, png_set_gamma,
     (png_structp png_ptr, double screen_gamma,
-    double default_file_gamma));
+    double override_file_gamma));
 PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structp png_ptr,
-    png_fixed_point screen_gamma, png_fixed_point default_file_gamma));
+    png_fixed_point screen_gamma, png_fixed_point override_file_gamma));
 #endif
 
 #ifdef PNG_WRITE_FLUSH_SUPPORTED
@@ -1391,6 +1675,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
 #define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
 #define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
 
+#ifdef PNG_WRITE_SUPPORTED
 /* Set the library compression level.  Currently, valid values range from
  * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
  * (0 - no compression, 9 - "maximal" compression).  Note that tests have
@@ -1407,11 +1692,36 @@ PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr,
 PNG_EXPORT(71, void, png_set_compression_strategy, (png_structp png_ptr,
     int strategy));
 
+/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
+ * smaller value of window_bits if it can do so safely.
+ */
 PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structp png_ptr,
     int window_bits));
 
 PNG_EXPORT(73, void, png_set_compression_method, (png_structp png_ptr,
     int method));
+#endif
+
+#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
+/* Also set zlib parameters for compressing non-IDAT chunks */
+PNG_EXPORT(222, void, png_set_text_compression_level,
+    (png_structp png_ptr, int level));
+
+PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structp png_ptr,
+    int mem_level));
+
+PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structp png_ptr,
+    int strategy));
+
+/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
+ * smaller value of window_bits if it can do so safely.
+ */
+PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structp
+    png_ptr, int window_bits));
+
+PNG_EXPORT(226, void, png_set_text_compression_method, (png_structp png_ptr,
+    int method));
+#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
 
 /* These next functions are called for input/output, memory, and error
  * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
@@ -1550,6 +1860,7 @@ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save));
  */
 PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));
 
+#ifdef PNG_READ_INTERLACING_SUPPORTED
 /* Function that combines rows.  'new_row' is a flag that should come from
  * the callback and be non-NULL if anything needs to be done; the library
  * stores its own version of the new data internally and ignores the passed
@@ -1557,6 +1868,7 @@ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));
  */
 PNG_EXPORT(93, void, png_progressive_combine_row, (png_structp png_ptr,
     png_bytep old_row, png_const_bytep new_row));
+#endif /* PNG_READ_INTERLACING_SUPPORTED */
 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
 
 PNG_EXPORTA(94, png_voidp, png_malloc,
@@ -1623,6 +1935,7 @@ PNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr,
 PNG_EXPORTA(104, void, png_err, (png_structp png_ptr), PNG_NORETURN);
 #endif
 
+#ifdef PNG_WARNINGS_SUPPORTED
 /* Non-fatal error in libpng.  Can continue, but may have a problem. */
 PNG_EXPORT(105, void, png_warning, (png_structp png_ptr,
     png_const_charp warning_message));
@@ -1630,6 +1943,7 @@ PNG_EXPORT(105, void, png_warning, (png_structp png_ptr,
 /* Non-fatal error in libpng, chunk name is prepended to message. */
 PNG_EXPORT(106, void, png_chunk_warning, (png_structp png_ptr,
     png_const_charp warning_message));
+#endif
 
 #ifdef PNG_BENIGN_ERRORS_SUPPORTED
 /* Benign error in libpng.  Can continue, but may have a problem.
@@ -1768,6 +2082,10 @@ PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr,
    png_const_infop info_ptr, double *white_x, double *white_y, double *red_x,
     double *red_y, double *green_x, double *green_y, double *blue_x,
     double *blue_y));
+PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_structp png_ptr,
+    png_const_infop info_ptr, double *red_X, double *red_Y, double *red_Z,
+    double *green_X, double *green_Y, double *green_Z, double *blue_X,
+    double *blue_Y, double *blue_Z));
 #ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */
 PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
     (png_const_structp png_ptr,
@@ -1777,6 +2095,13 @@ PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
     png_fixed_point *int_green_y, png_fixed_point *int_blue_x,
     png_fixed_point *int_blue_y));
 #endif
+PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,
+    (png_structp png_ptr, png_const_infop info_ptr,
+    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
+    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
+    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
+    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
+    png_fixed_point *int_blue_Z));
 #endif
 
 #ifdef PNG_cHRM_SUPPORTED
@@ -1784,12 +2109,22 @@ PNG_FP_EXPORT(135, void, png_set_cHRM,
     (png_structp png_ptr, png_infop info_ptr,
     double white_x, double white_y, double red_x, double red_y, double green_x,
     double green_y, double blue_x, double blue_y));
+PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structp png_ptr,
+    png_infop info_ptr, double red_X, double red_Y, double red_Z,
+    double green_X, double green_Y, double green_Z, double blue_X,
+    double blue_Y, double blue_Z));
 PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr,
     png_infop info_ptr, png_fixed_point int_white_x,
     png_fixed_point int_white_y, png_fixed_point int_red_x,
     png_fixed_point int_red_y, png_fixed_point int_green_x,
     png_fixed_point int_green_y, png_fixed_point int_blue_x,
     png_fixed_point int_blue_y));
+PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structp png_ptr,
+    png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
+    png_fixed_point int_red_Z, png_fixed_point int_green_X,
+    png_fixed_point int_green_Y, png_fixed_point int_green_Z,
+    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
+    png_fixed_point int_blue_Z));
 #endif
 
 #ifdef PNG_gAMA_SUPPORTED
@@ -2002,15 +2337,21 @@ PNG_EXPORT(171, void, png_set_sCAL_s,
 /* Provide a list of chunks and how they are to be handled, if the built-in
    handling or default unknown chunk handling is not desired.  Any chunks not
    listed will be handled in the default manner.  The IHDR and IEND chunks
-   must not be listed.
-      keep = 0: follow default behaviour
-           = 1: do not keep
-           = 2: keep only if safe-to-copy
-           = 3: keep even if unsafe-to-copy
+   must not be listed.  Because this turns off the default handling for chunks
+   that would otherwise be recognized the behavior of libpng transformations may
+   well become incorrect!
+      keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior
+           = 1: PNG_HANDLE_CHUNK_NEVER:      do not keep
+           = 2: PNG_HANDLE_CHUNK_IF_SAFE:    keep only if safe-to-copy
+           = 3: PNG_HANDLE_CHUNK_ALWAYS:     keep even if unsafe-to-copy
 */
 PNG_EXPORT(172, void, png_set_keep_unknown_chunks,
     (png_structp png_ptr, int keep,
     png_const_bytep chunk_list, int num_chunks));
+
+/* The handling code is returned; the result is therefore true (non-zero) if
+ * special handling is required, false for the default handling.
+ */
 PNG_EXPORT(173, int, png_handle_as_unknown, (png_structp png_ptr,
     png_const_bytep chunk_name));
 #endif
@@ -2150,8 +2491,16 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
  * full, image which appears in a given pass.  'pass' is in the range 0
  * to 6 and the result is in the range 0 to 7.
  */
-#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7)
-#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7)
+#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)
+#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)
+
+/* A macro to return the offset between pixels in the output row for a pair of
+ * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that
+ * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas
+ * COL_OFFSET is from one column to the next, within a row.
+ */
+#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)
+#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))
 
 /* Two macros to help evaluate the number of rows or columns in each
  * pass.  This is expressed as a shift - effectively log2 of the number or
@@ -2186,8 +2535,8 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
  * the tile.
  */
 #define PNG_PASS_MASK(pass,off) ( \
-   ((0x110145AFU>>(((7-(off))-(pass))<<2)) & 0xFU) | \
-   ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U))
+   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \
+   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))
 
 #define PNG_ROW_IN_INTERLACE_PASS(y, pass) \
    ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)
@@ -2213,14 +2562,14 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
      { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
            * (png_uint_16)(alpha)                         \
            + (png_uint_16)(bg)*(png_uint_16)(255          \
-           - (png_uint_16)(alpha)) + (png_uint_16)128);   \
+           - (png_uint_16)(alpha)) + 128);                \
        (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
 
 #  define png_composite_16(composite, fg, alpha, bg)       \
      { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \
            * (png_uint_32)(alpha)                          \
-           + (png_uint_32)(bg)*(png_uint_32)(65535L        \
-           - (png_uint_32)(alpha)) + (png_uint_32)32768L); \
+           + (png_uint_32)(bg)*(65535                      \
+           - (png_uint_32)(alpha)) + 32768);               \
        (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
 
 #else  /* Standard method using integer division */
@@ -2228,12 +2577,12 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
 #  define png_composite(composite, fg, alpha, bg)                          \
      (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
      (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \
-     (png_uint_16)127) / 255)
+     127) / 255)
 
 #  define png_composite_16(composite, fg, alpha, bg)                         \
      (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
-     (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) +        \
-     (png_uint_32)32767) / (png_uint_32)65535L)
+     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \
+     32767) / 65535)
 #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
 
 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
@@ -2297,7 +2646,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
  * scripts/symbols.def as well.
  */
 #ifdef PNG_EXPORT_LAST_ORDINAL
-  PNG_EXPORT_LAST_ORDINAL(221);
+  PNG_EXPORT_LAST_ORDINAL(233);
 #endif
 
 #ifdef __cplusplus
index c82fa5866c1e5119235121304f36ee21a649ac0b..1aa268beef524ad405bae8943ddffc2c1459d985 100644 (file)
@@ -1,9 +1,9 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.5.2 - March 31, 2011
+ * libpng version 1.5.9 - February 18, 2012
  *
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2012 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
  *                       'type', compiler specific.
  *
  * PNG_DLL_EXPORT Set to the magic to use during a libpng build to
- *                make a symbol exported from the DLL.
+ *                make a symbol exported from the DLL.  Not used in the
+ *                public header files; see pngpriv.h for how it is used
+ *                in the libpng build.
  *
  * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
  *                from a DLL - used to define PNG_IMPEXP when
 #  define PNGAPI PNGCAPI
 #endif
 
-/* The default for PNG_IMPEXP depends on whether the library is
- * being built or used.
+/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
+ * then in an internal header file when building the library, otherwise (when
+ * using the library) it is set here.
  */
 #ifndef PNG_IMPEXP
-#  ifdef PNGLIB_BUILD
-    /* Building the library */
-#    if (defined(DLL_EXPORT)/*from libtool*/ ||\
-        defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\
-        defined(_USRDLL) ||\
-        defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT)
-      /* Building a DLL. */
-#      define PNG_IMPEXP PNG_DLL_EXPORT
-#    endif /* DLL */
-#  else
-    /* Using the library */
-#    if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
-      /* This forces use of a DLL, disallowing static linking */
-#      define PNG_IMPEXP PNG_DLL_IMPORT
-#    endif
+#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
+     /* This forces use of a DLL, disallowing static linking */
+#    define PNG_IMPEXP PNG_DLL_IMPORT
 #  endif
 
 #  ifndef PNG_IMPEXP
 #    ifndef PNG_NORETURN
 #      define PNG_NORETURN   __attribute__((__noreturn__))
 #    endif
-#    ifndef PNG_PTR_NORETURN
-       /* It's not enough to have the compiler be the correct compiler at
-        * this point - it's necessary for the library (which defines
-        * the type of the library longjmp) to also be the GNU library.
-        * This is because many systems use the GNU compiler with a
-        * non-GNU libc implementation.  Min/GW headers are also compatible
-        * with GCC as well as uclibc, so it seems best to exclude known
-        * problem libcs here rather than just including known libcs.
-        *
-        * NOTE: this relies on the only use of PNG_PTR_NORETURN being with
-        * the system longjmp.  If the same type is used elsewhere then this
-        * will need to be changed.
-        */
-#      if !defined(__CYGWIN__)
-#         define PNG_PTR_NORETURN   __attribute__((__noreturn__))
-#      endif
-#    endif
 #    ifndef PNG_ALLOCATED
 #      define PNG_ALLOCATED  __attribute__((__malloc__))
 #    endif
-
-    /* This specifically protects structure members that should only be
-     * accessed from within the library, therefore should be empty during
-     * a library build.
-     */
-#    ifndef PNGLIB_BUILD
-#      ifndef PNG_DEPRECATED
-#        define PNG_DEPRECATED __attribute__((__deprecated__))
-#      endif
-#      ifndef PNG_DEPSTRUCT
-#        define PNG_DEPSTRUCT  __attribute__((__deprecated__))
-#      endif
-#      ifndef PNG_PRIVATE
-#        if 0 /* Doesn't work so we use deprecated instead*/
-#          define PNG_PRIVATE \
-            __attribute__((warning("This function is not exported by libpng.")))
-#        else
-#          define PNG_PRIVATE \
-            __attribute__((__deprecated__))
-#        endif
+#    ifndef PNG_DEPRECATED
+#      define PNG_DEPRECATED __attribute__((__deprecated__))
+#    endif
+#    ifndef PNG_PRIVATE
+#      if 0 /* Doesn't work so we use deprecated instead*/
+#        define PNG_PRIVATE \
+          __attribute__((warning("This function is not exported by libpng.")))
+#      else
+#        define PNG_PRIVATE \
+          __attribute__((__deprecated__))
 #      endif
-#    endif /* PNGLIB_BUILD */
+#    endif
 #  endif /* __GNUC__ */
 
 #  if defined(_MSC_VER)  && (_MSC_VER >= 1300)
 #      define PNG_USE_RESULT /* not supported */
 #    endif
 #    ifndef PNG_NORETURN
-#      define PNG_NORETURN   __declspec(noreturn)
-#    endif
-#    ifndef PNG_PTR_NORETURN
-#      define PNG_PTR_NORETURN /* not supported */
+#      define PNG_NORETURN __declspec(noreturn)
 #    endif
 #    ifndef PNG_ALLOCATED
-#      define PNG_ALLOCATED __declspec(restrict)
-#    endif
-
-    /* This specifically protects structure members that should only be
-     * accessed from within the library, therefore should be empty during
-     * a library build.
-     */
-#    ifndef PNGLIB_BUILD
-#      ifndef PNG_DEPRECATED
-#        define PNG_DEPRECATED __declspec(deprecated)
-#      endif
-#      ifndef PNG_DEPSTRUCT
-#        define PNG_DEPSTRUCT  __declspec(deprecated)
-#      endif
-#      ifndef PNG_PRIVATE
-#        define PNG_PRIVATE __declspec(deprecated)
+#      if (_MSC_VER >= 1400)
+#        define PNG_ALLOCATED __declspec(restrict)
 #      endif
-#    endif /* PNGLIB_BUILD */
+#    endif
+#    ifndef PNG_DEPRECATED
+#      define PNG_DEPRECATED __declspec(deprecated)
+#    endif
+#    ifndef PNG_PRIVATE
+#      define PNG_PRIVATE __declspec(deprecated)
+#    endif
 #  endif /* _MSC_VER */
 #endif /* PNG_PEDANTIC_WARNINGS */
 
 #ifndef PNG_NORETURN
 #  define PNG_NORETURN    /* This function does not return */
 #endif
-#ifndef PNG_PTR_NORETURN
-#  define PNG_PTR_NORETURN /* This function does not return */
-#endif
 #ifndef PNG_ALLOCATED
 #  define PNG_ALLOCATED   /* The result of the function is new memory */
 #endif
-#ifndef PNG_DEPSTRUCT
-#  define PNG_DEPSTRUCT   /* Access to this struct member is deprecated */
-#endif
 #ifndef PNG_PRIVATE
 #  define PNG_PRIVATE     /* This is a private libpng function */
 #endif
index 8290bb4106efbd5f18563a7c69f82e73bf47982c..95002f84f704b017f7de90f5e4e19b8561dc128c 100644 (file)
@@ -1,8 +1,8 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * Last changed in libpng 1.5.1 [February 3, 2011]
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.8 [February 1, 2011]
+ * Copyright (c) 1998-2012 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -89,15 +89,121 @@ png_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)
 PNG_FUNCTION(void,PNGAPI
 png_err,(png_structp png_ptr),PNG_NORETURN)
 {
+   /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
+    * erroneously as '\0', instead of the empty string "".  This was
+    * apparently an error, introduced in libpng-1.2.20, and png_default_error
+    * will crash in this case.
+    */
    if (png_ptr != NULL && png_ptr->error_fn != NULL)
-      (*(png_ptr->error_fn))(png_ptr, '\0');
+      (*(png_ptr->error_fn))(png_ptr, "");
 
    /* If the custom handler doesn't exist, or if it returns,
       use the default handler, which will not return. */
-   png_default_error(png_ptr, '\0');
+   png_default_error(png_ptr, "");
 }
 #endif /* PNG_ERROR_TEXT_SUPPORTED */
 
+/* Utility to safely appends strings to a buffer.  This never errors out so
+ * error checking is not required in the caller.
+ */
+size_t
+png_safecat(png_charp buffer, size_t bufsize, size_t pos,
+   png_const_charp string)
+{
+   if (buffer != NULL && pos < bufsize)
+   {
+      if (string != NULL)
+         while (*string != '\0' && pos < bufsize-1)
+           buffer[pos++] = *string++;
+
+      buffer[pos] = '\0';
+   }
+
+   return pos;
+}
+
+#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
+/* Utility to dump an unsigned value into a buffer, given a start pointer and
+ * and end pointer (which should point just *beyond* the end of the buffer!)
+ * Returns the pointer to the start of the formatted string.
+ */
+png_charp
+png_format_number(png_const_charp start, png_charp end, int format,
+   png_alloc_size_t number)
+{
+   int count = 0;    /* number of digits output */
+   int mincount = 1; /* minimum number required */
+   int output = 0;   /* digit output (for the fixed point format) */
+
+   *--end = '\0';
+
+   /* This is written so that the loop always runs at least once, even with
+    * number zero.
+    */
+   while (end > start && (number != 0 || count < mincount))
+   {
+
+      static const char digits[] = "0123456789ABCDEF";
+
+      switch (format)
+      {
+         case PNG_NUMBER_FORMAT_fixed:
+            /* Needs five digits (the fraction) */
+            mincount = 5;
+            if (output || number % 10 != 0)
+            {
+               *--end = digits[number % 10];
+               output = 1;
+            }
+            number /= 10;
+            break;
+
+         case PNG_NUMBER_FORMAT_02u:
+            /* Expects at least 2 digits. */
+            mincount = 2;
+            /* fall through */
+
+         case PNG_NUMBER_FORMAT_u:
+            *--end = digits[number % 10];
+            number /= 10;
+            break;
+
+         case PNG_NUMBER_FORMAT_02x:
+            /* This format expects at least two digits */
+            mincount = 2;
+            /* fall through */
+
+         case PNG_NUMBER_FORMAT_x:
+            *--end = digits[number & 0xf];
+            number >>= 4;
+            break;
+
+         default: /* an error */
+            number = 0;
+            break;
+      }
+
+      /* Keep track of the number of digits added */
+      ++count;
+
+      /* Float a fixed number here: */
+      if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
+      {
+         /* End of the fraction, but maybe nothing was output?  In that case
+          * drop the decimal point.  If the number is a true zero handle that
+          * here.
+          */
+         if (output)
+            *--end = '.';
+         else if (number == 0) /* and !output */
+            *--end = '0';
+      }
+   }
+
+   return end;
+}
+#endif
+
 #ifdef PNG_WARNINGS_SUPPORTED
 /* This function is called whenever there is a non-fatal error.  This function
  * should not be changed.  If there is a need to handle warnings differently,
@@ -128,6 +234,124 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
    else
       png_default_warning(png_ptr, warning_message + offset);
 }
+
+/* These functions support 'formatted' warning messages with up to
+ * PNG_WARNING_PARAMETER_COUNT parameters.  In the format string the parameter
+ * is introduced by @<number>, where 'number' starts at 1.  This follows the
+ * standard established by X/Open for internationalizable error messages.
+ */
+void
+png_warning_parameter(png_warning_parameters p, int number,
+   png_const_charp string)
+{
+   if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)
+      (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);
+}
+
+void
+png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
+   png_alloc_size_t value)
+{
+   char buffer[PNG_NUMBER_BUFFER_SIZE];
+   png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
+}
+
+void
+png_warning_parameter_signed(png_warning_parameters p, int number, int format,
+   png_int_32 value)
+{
+   png_alloc_size_t u;
+   png_charp str;
+   char buffer[PNG_NUMBER_BUFFER_SIZE];
+
+   /* Avoid overflow by doing the negate in a png_alloc_size_t: */
+   u = (png_alloc_size_t)value;
+   if (value < 0)
+      u = ~u + 1;
+
+   str = PNG_FORMAT_NUMBER(buffer, format, u);
+
+   if (value < 0 && str > buffer)
+      *--str = '-';
+
+   png_warning_parameter(p, number, str);
+}
+
+void
+png_formatted_warning(png_structp png_ptr, png_warning_parameters p,
+   png_const_charp message)
+{
+   /* The internal buffer is just 192 bytes - enough for all our messages,
+    * overflow doesn't happen because this code checks!  If someone figures
+    * out how to send us a message longer than 192 bytes, all that will
+    * happen is that the message will be truncated appropriately.
+    */
+   size_t i = 0; /* Index in the msg[] buffer: */
+   char msg[192];
+
+   /* Each iteration through the following loop writes at most one character
+    * to msg[i++] then returns here to validate that there is still space for
+    * the trailing '\0'.  It may (in the case of a parameter) read more than
+    * one character from message[]; it must check for '\0' and continue to the
+    * test if it finds the end of string.
+    */
+   while (i<(sizeof msg)-1 && *message != '\0')
+   {
+      /* '@' at end of string is now just printed (previously it was skipped);
+       * it is an error in the calling code to terminate the string with @.
+       */
+      if (p != NULL && *message == '@' && message[1] != '\0')
+      {
+         int parameter_char = *++message; /* Consume the '@' */
+         static const char valid_parameters[] = "123456789";
+         int parameter = 0;
+
+         /* Search for the parameter digit, the index in the string is the
+          * parameter to use.
+          */
+         while (valid_parameters[parameter] != parameter_char &&
+            valid_parameters[parameter] != '\0')
+            ++parameter;
+
+         /* If the parameter digit is out of range it will just get printed. */
+         if (parameter < PNG_WARNING_PARAMETER_COUNT)
+         {
+            /* Append this parameter */
+            png_const_charp parm = p[parameter];
+            png_const_charp pend = p[parameter] + (sizeof p[parameter]);
+
+            /* No need to copy the trailing '\0' here, but there is no guarantee
+             * that parm[] has been initialized, so there is no guarantee of a
+             * trailing '\0':
+             */
+            while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend)
+               msg[i++] = *parm++;
+
+            /* Consume the parameter digit too: */
+            ++message;
+            continue;
+         }
+
+         /* else not a parameter and there is a character after the @ sign; just
+          * copy that.  This is known not to be '\0' because of the test above.
+          */
+      }
+
+      /* At this point *message can't be '\0', even in the bad parameter case
+       * above where there is a lone '@' at the end of the message string.
+       */
+      msg[i++] = *message++;
+   }
+
+   /* i is always less than (sizeof msg), so: */
+   msg[i] = '\0';
+
+   /* And this is the formatted message, it may be larger than
+    * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are
+    * not (currently) formatted.
+    */
+   png_warning(png_ptr, msg);
+}
 #endif /* PNG_WARNINGS_SUPPORTED */
 
 #ifdef PNG_BENIGN_ERRORS_SUPPORTED
@@ -159,11 +383,14 @@ static void /* PRIVATE */
 png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
     error_message)
 {
-   int iout = 0, iin = 0;
+   png_uint_32 chunk_name = png_ptr->chunk_name;
+   int iout = 0, ishift = 24;
 
-   while (iin < 4)
+   while (ishift >= 0)
    {
-      int c = png_ptr->chunk_name[iin++];
+      int c = (int)(chunk_name >> ishift) & 0xff;
+
+      ishift -= 8;
       if (isnonalpha(c))
       {
          buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
@@ -174,7 +401,7 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
 
       else
       {
-         buffer[iout++] = (png_byte)c;
+         buffer[iout++] = (char)c;
       }
    }
 
@@ -183,10 +410,16 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
 
    else
    {
+      int iin = 0;
+
       buffer[iout++] = ':';
       buffer[iout++] = ' ';
-      png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
-      buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
+
+      while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0')
+         buffer[iout++] = error_message[iin++];
+
+      /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */
+      buffer[iout] = '\0';
    }
 }
 #endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
@@ -272,7 +505,7 @@ png_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,
       return NULL;
 
    png_ptr->longjmp_fn = longjmp_fn;
-   return &png_ptr->png_jmpbuf;
+   return &png_ptr->longjmp_buffer;
 }
 #endif
 
@@ -287,7 +520,8 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
 {
 #ifdef PNG_CONSOLE_IO_SUPPORTED
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
-   if (*error_message == PNG_LITERAL_SHARP)
+   /* Check on NULL only added in 1.5.4 */
+   if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
    {
       /* Strip "#nnnn " from beginning of error message. */
       int offset;
@@ -317,11 +551,11 @@ png_default_error,(png_structp png_ptr, png_const_charp error_message),
    else
 #endif
    {
-      fprintf(stderr, "libpng error: %s", error_message);
+      fprintf(stderr, "libpng error: %s", error_message ? error_message :
+         "undefined");
       fprintf(stderr, PNG_STRING_NEWLINE);
    }
-#endif
-#ifndef PNG_CONSOLE_IO_SUPPORTED
+#else
    PNG_UNUSED(error_message) /* Make compiler happy */
 #endif
    png_longjmp(png_ptr, 1);
@@ -335,13 +569,13 @@ png_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)
    {
 #  ifdef USE_FAR_KEYWORD
       {
-         jmp_buf png_jmpbuf;
-         png_memcpy(png_jmpbuf, png_ptr->png_jmpbuf, png_sizeof(jmp_buf));
-         png_ptr->longjmp_fn(png_jmpbuf, val);
+         jmp_buf tmp_jmpbuf;
+         png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
+         png_ptr->longjmp_fn(tmp_jmpbuf, val);
       }
 
 #  else
-   png_ptr->longjmp_fn(png_ptr->png_jmpbuf, val);
+   png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);
 #  endif
    }
 #endif
@@ -403,7 +637,7 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
 /* This function is called when the application wants to use another method
  * of handling errors and warnings.  Note that the error function MUST NOT
  * return to the calling routine or serious problems will occur.  The return
- * method used in the default routine calls longjmp(png_ptr->png_jmpbuf, 1)
+ * method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)
  */
 void PNGAPI
 png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
@@ -414,7 +648,11 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
 
    png_ptr->error_ptr = error_ptr;
    png_ptr->error_fn = error_fn;
+#ifdef PNG_WARNINGS_SUPPORTED
    png_ptr->warning_fn = warning_fn;
+#else
+   PNG_UNUSED(warning_fn)
+#endif
 }
 
 
index b5e5798c020d12161f5e25f296a38b55d9ec0236..43400cda7e88deb41249570afd21d79a8e94a373 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * Last changed in libpng 1.5.1 [February 3, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -459,6 +459,65 @@ png_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,
 #endif
 
 #ifdef PNG_cHRM_SUPPORTED
+/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
+ * same time to correct the rgb grayscale coefficient defaults obtained from the
+ * cHRM chunk in 1.5.4
+ */
+png_uint_32 PNGFAPI
+png_get_cHRM_XYZ_fixed(png_structp png_ptr, png_const_infop info_ptr,
+    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
+    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
+    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
+    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
+    png_fixed_point *int_blue_Z)
+{
+   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
+   {
+      png_xy xy;
+      png_XYZ XYZ;
+
+      png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
+
+      xy.whitex = info_ptr->x_white;
+      xy.whitey = info_ptr->y_white;
+      xy.redx = info_ptr->x_red;
+      xy.redy = info_ptr->y_red;
+      xy.greenx = info_ptr->x_green;
+      xy.greeny = info_ptr->y_green;
+      xy.bluex = info_ptr->x_blue;
+      xy.bluey = info_ptr->y_blue;
+
+      /* The *_checked function handles error reporting, so just return 0 if
+       * there is a failure here.
+       */
+      if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
+      {
+         if (int_red_X != NULL)
+            *int_red_X = XYZ.redX;
+         if (int_red_Y != NULL)
+            *int_red_Y = XYZ.redY;
+         if (int_red_Z != NULL)
+            *int_red_Z = XYZ.redZ;
+         if (int_green_X != NULL)
+            *int_green_X = XYZ.greenX;
+         if (int_green_Y != NULL)
+            *int_green_Y = XYZ.greenY;
+         if (int_green_Z != NULL)
+            *int_green_Z = XYZ.greenZ;
+         if (int_blue_X != NULL)
+            *int_blue_X = XYZ.blueX;
+         if (int_blue_Y != NULL)
+            *int_blue_Y = XYZ.blueY;
+         if (int_blue_Z != NULL)
+            *int_blue_Z = XYZ.blueZ;
+
+         return (PNG_INFO_cHRM);
+      }
+   }
+
+   return (0);
+}
+
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
 png_uint_32 PNGAPI
 png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
@@ -490,6 +549,42 @@ png_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,
 
    return (0);
 }
+
+png_uint_32 PNGAPI
+png_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,
+   double *red_X, double *red_Y, double *red_Z, double *green_X,
+   double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
+   double *blue_Z)
+{
+   png_XYZ XYZ;
+
+   if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,
+      &XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,
+      &XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)
+   {
+      if (red_X != NULL)
+         *red_X = png_float(png_ptr, XYZ.redX, "cHRM red X");
+      if (red_Y != NULL)
+         *red_Y = png_float(png_ptr, XYZ.redY, "cHRM red Y");
+      if (red_Z != NULL)
+         *red_Z = png_float(png_ptr, XYZ.redZ, "cHRM red Z");
+      if (green_X != NULL)
+         *green_X = png_float(png_ptr, XYZ.greenX, "cHRM green X");
+      if (green_Y != NULL)
+         *green_Y = png_float(png_ptr, XYZ.greenY, "cHRM green Y");
+      if (green_Z != NULL)
+         *green_Z = png_float(png_ptr, XYZ.greenZ, "cHRM green Z");
+      if (blue_X != NULL)
+         *blue_X = png_float(png_ptr, XYZ.blueX, "cHRM blue X");
+      if (blue_Y != NULL)
+         *blue_Y = png_float(png_ptr, XYZ.blueY, "cHRM blue Y");
+      if (blue_Z != NULL)
+         *blue_Z = png_float(png_ptr, XYZ.blueZ, "cHRM blue Z");
+      return (PNG_INFO_cHRM);
+   }
+
+   return (0);
+}
 #  endif
 
 #  ifdef PNG_FIXED_POINT_SUPPORTED
@@ -587,15 +682,16 @@ png_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,
    png_debug1(1, "in %s retrieval function", "iCCP");
 
    if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
-       && name != NULL && profile != NULL && proflen != NULL)
+       && name != NULL && compression_type != NULL && profile != NULL &&
+                proflen != NULL)
    {
       *name = info_ptr->iccp_name;
       *profile = info_ptr->iccp_profile;
       /* Compression_type is a dummy so the API won't have to change
        * if we introduce multiple compression types later.
        */
-      *proflen = (int)info_ptr->iccp_proflen;
-      *compression_type = (int)info_ptr->iccp_compression;
+      *proflen = info_ptr->iccp_proflen;
+      *compression_type = info_ptr->iccp_compression;
       return (PNG_INFO_iCCP);
    }
 
@@ -855,9 +951,8 @@ png_get_text(png_const_structp png_ptr, png_const_infop info_ptr,
 {
    if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
    {
-      png_debug1(1, "in %s retrieval function",
-          (png_ptr->chunk_name[0] == '\0' ? "text" :
-          (png_const_charp)png_ptr->chunk_name));
+      png_debug1(1, "in 0x%lx retrieval function",
+         (unsigned long)png_ptr->chunk_name);
 
       if (text_ptr != NULL)
          *text_ptr = info_ptr->text;
@@ -971,10 +1066,9 @@ png_get_user_chunk_ptr(png_const_structp png_ptr)
 png_size_t PNGAPI
 png_get_compression_buffer_size(png_const_structp png_ptr)
 {
-   return (png_ptr ? png_ptr->zbuf_size : 0L);
+   return (png_ptr ? png_ptr->zbuf_size : 0);
 }
 
-
 #ifdef PNG_SET_USER_LIMITS_SUPPORTED
 /* These functions were added to libpng 1.2.6 and were enabled
  * by default in libpng-1.4.0 */
@@ -1016,16 +1110,14 @@ png_get_io_state (png_structp png_ptr)
 png_uint_32 PNGAPI
 png_get_io_chunk_type (png_const_structp png_ptr)
 {
-   return ((png_ptr->chunk_name[0] << 24) +
-           (png_ptr->chunk_name[1] << 16) +
-           (png_ptr->chunk_name[2] <<  8) +
-           (png_ptr->chunk_name[3]));
+   return png_ptr->chunk_name;
 }
 
 png_const_bytep PNGAPI
 png_get_io_chunk_name (png_structp png_ptr)
 {
-   return png_ptr->chunk_name;
+   PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);
+   return png_ptr->io_chunk_string;
 }
 #endif /* ?PNG_IO_STATE_SUPPORTED */
 
index fa19f85e72c00895f5de3be5557e25cfb79b680d..a33bfab06de28fc52096ddb90b8bca6915abc8c1 100644 (file)
@@ -138,7 +138,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
     * single color specified that should be treated as fully transparent.
     * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
     */
-   png_bytep trans;    /* alpha values for paletted image */
    png_bytep trans_alpha;    /* alpha values for paletted image */
    png_color_16 trans_color; /* transparent color for non-palette image */
 #endif
index 5f0c8525bea233036d6396be6ae8084e58d36326..49fcc8cb4dd37f33e09fc930c8d545f7246abee3 100644 (file)
@@ -3,7 +3,7 @@
 
 /* pnglibconf.h - library build configuration */
 
-/* libpng version 1.5.0 - last changed on February 11, 2011 */
+/* Libpng 1.5.9 - February 18, 2012 */
 
 /* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
 
@@ -17,7 +17,7 @@
 /* pnglibconf.dfa with respect to the dependencies between the following */
 /* symbols.  It is much better to generate a new file using */
 /* scripts/libpngconf.mak */
-  
+
 #ifndef PNGLCONF_H
 #define PNGLCONF_H
 /* settings */
@@ -33,8 +33,8 @@
 #define PNG_sCAL_PRECISION 5
 #define PNG_USER_CHUNK_CACHE_MAX 0
 #define PNG_USER_CHUNK_MALLOC_MAX 0
-#define PNG_USER_HEIGHT_MAX 1000000L
-#define PNG_USER_WIDTH_MAX 1000000L
+#define PNG_USER_HEIGHT_MAX 1000000
+#define PNG_USER_WIDTH_MAX 1000000
 #define PNG_WEIGHT_SHIFT 8
 #define PNG_ZBUF_SIZE 8192
 /* end of settings */
 #define PNG_ALIGN_MEMORY_SUPPORTED
 #define PNG_BENIGN_ERRORS_SUPPORTED
 #define PNG_bKGD_SUPPORTED
+#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
 #define PNG_CHECK_cHRM_SUPPORTED
 #define PNG_cHRM_SUPPORTED
 #define PNG_CONSOLE_IO_SUPPORTED
 #define PNG_CONVERT_tIME_SUPPORTED
 #define PNG_EASY_ACCESS_SUPPORTED
+/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
 #define PNG_ERROR_TEXT_SUPPORTED
 #define PNG_FIXED_POINT_SUPPORTED
 #define PNG_FLOATING_ARITHMETIC_SUPPORTED
 #define PNG_POINTER_INDEXING_SUPPORTED
 #define PNG_PROGRESSIVE_READ_SUPPORTED
 #define PNG_READ_16BIT_SUPPORTED
-#define PNG_READ_16_TO_8_SUPPORTED
+#define PNG_READ_ALPHA_MODE_SUPPORTED
 #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
 #define PNG_READ_BACKGROUND_SUPPORTED
 #define PNG_READ_BGR_SUPPORTED
 #define PNG_READ_bKGD_SUPPORTED
 #define PNG_READ_cHRM_SUPPORTED
 #define PNG_READ_COMPOSITE_NODIV_SUPPORTED
+#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
 #define PNG_READ_EXPAND_16_SUPPORTED
 #define PNG_READ_EXPAND_SUPPORTED
 #define PNG_READ_FILLER_SUPPORTED
 #define PNG_READ_QUANTIZE_SUPPORTED
 #define PNG_READ_RGB_TO_GRAY_SUPPORTED
 #define PNG_READ_sBIT_SUPPORTED
+#define PNG_READ_SCALE_16_TO_8_SUPPORTED
 #define PNG_READ_sCAL_SUPPORTED
 #define PNG_READ_SHIFT_SUPPORTED
 #define PNG_READ_sPLT_SUPPORTED
 #define PNG_READ_sRGB_SUPPORTED
+#define PNG_READ_STRIP_16_TO_8_SUPPORTED
 #define PNG_READ_STRIP_ALPHA_SUPPORTED
 #define PNG_READ_SUPPORTED
 #define PNG_READ_SWAP_ALPHA_SUPPORTED
 #define PNG_WRITE_BGR_SUPPORTED
 #define PNG_WRITE_bKGD_SUPPORTED
 #define PNG_WRITE_cHRM_SUPPORTED
+#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
+#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
 #define PNG_WRITE_FILLER_SUPPORTED
 #define PNG_WRITE_FILTER_SUPPORTED
 #define PNG_WRITE_FLUSH_SUPPORTED
 #define PNG_WRITE_INVERT_SUPPORTED
 #define PNG_WRITE_iTXt_SUPPORTED
 #define PNG_WRITE_oFFs_SUPPORTED
+#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
 #define PNG_WRITE_PACK_SUPPORTED
 #define PNG_WRITE_PACKSWAP_SUPPORTED
 #define PNG_WRITE_pCAL_SUPPORTED
 #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
 #define PNG_WRITE_zTXt_SUPPORTED
 #define PNG_zTXt_SUPPORTED
-/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
-/*#undef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED*/
 /* end of options */
 #endif /* PNGLCONF_H */
index a15d8b085936b5eb3271eaf3d4602198b12bad03..bf5ff037dadf3710522cc72f173b417313bc7ab2 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * Last changed in libpng 1.5.1 [February 3, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -56,9 +56,9 @@ png_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),
    if (malloc_fn != NULL)
    {
       png_struct dummy_struct;
-      png_structp png_ptr = &dummy_struct;
-      png_ptr->mem_ptr=mem_ptr;
-      struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
+      memset(&dummy_struct, 0, sizeof dummy_struct);
+      dummy_struct.mem_ptr=mem_ptr;
+      struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size);
    }
 
    else
@@ -90,9 +90,9 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
       if (free_fn != NULL)
       {
          png_struct dummy_struct;
-         png_structp png_ptr = &dummy_struct;
-         png_ptr->mem_ptr=mem_ptr;
-         (*(free_fn))(png_ptr, struct_ptr);
+         memset(&dummy_struct, 0, sizeof dummy_struct);
+         dummy_struct.mem_ptr=mem_ptr;
+         (*(free_fn))(&dummy_struct, struct_ptr);
          return;
       }
 
@@ -143,7 +143,7 @@ png_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
 
 #  ifdef PNG_USER_MEM_SUPPORTED
    if (png_ptr->malloc_fn != NULL)
-      ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
+      ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
 
    else
       ret = (png_malloc_default(png_ptr, size));
@@ -187,8 +187,9 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
             int num_blocks;
             png_uint_32 total_size;
             png_bytep table;
-            int i;
+            int i, mem_level, window_bits;
             png_byte huge * hptr;
+            int window_bits
 
             if (ret != NULL)
             {
@@ -196,14 +197,22 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
                ret = NULL;
             }
 
-            if (png_ptr->zlib_window_bits > 14)
-               num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
+            window_bits =
+                png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?
+                png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;
+
+            if (window_bits > 14)
+               num_blocks = (int)(1 << (window_bits - 14));
 
             else
                num_blocks = 1;
 
-            if (png_ptr->zlib_mem_level >= 7)
-               num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
+            mem_level =
+                png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?
+                png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;
+
+            if (mem_level >= 7)
+               num_blocks += (int)(1 << (mem_level - 7));
 
             else
                num_blocks++;
@@ -277,7 +286,7 @@ png_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
       {
 #  ifndef PNG_USER_MEM_SUPPORTED
          if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
-            png_error(png_ptr, "Out of Memory"); /* Note "o" and "M" */
+            png_error(png_ptr, "Out of Memory"); /* Note "O" and "M" */
 
          else
             png_warning(png_ptr, "Out of Memory");
index 5ab9007a161696492b3a0f5b02f0f7dc7c3557fb..95a2082e40c9df3448b44ea41aabf312f276004f 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * Last changed in libpng 1.5.2 [March 31, 2011]
+ * Last changed in libpng 1.5.9 [February 18, 2012]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -208,61 +208,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
 void /* PRIVATE */
 png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 {
-      PNG_IHDR;
-      PNG_IDAT;
-      PNG_IEND;
-      PNG_PLTE;
-#ifdef PNG_READ_bKGD_SUPPORTED
-      PNG_bKGD;
-#endif
-#ifdef PNG_READ_cHRM_SUPPORTED
-      PNG_cHRM;
-#endif
-#ifdef PNG_READ_gAMA_SUPPORTED
-      PNG_gAMA;
-#endif
-#ifdef PNG_READ_hIST_SUPPORTED
-      PNG_hIST;
-#endif
-#ifdef PNG_READ_iCCP_SUPPORTED
-      PNG_iCCP;
-#endif
-#ifdef PNG_READ_iTXt_SUPPORTED
-      PNG_iTXt;
-#endif
-#ifdef PNG_READ_oFFs_SUPPORTED
-      PNG_oFFs;
-#endif
-#ifdef PNG_READ_pCAL_SUPPORTED
-      PNG_pCAL;
-#endif
-#ifdef PNG_READ_pHYs_SUPPORTED
-      PNG_pHYs;
-#endif
-#ifdef PNG_READ_sBIT_SUPPORTED
-      PNG_sBIT;
-#endif
-#ifdef PNG_READ_sCAL_SUPPORTED
-      PNG_sCAL;
-#endif
-#ifdef PNG_READ_sRGB_SUPPORTED
-      PNG_sRGB;
-#endif
-#ifdef PNG_READ_sPLT_SUPPORTED
-      PNG_sPLT;
-#endif
-#ifdef PNG_READ_tEXt_SUPPORTED
-      PNG_tEXt;
-#endif
-#ifdef PNG_READ_tIME_SUPPORTED
-      PNG_tIME;
-#endif
-#ifdef PNG_READ_tRNS_SUPPORTED
-      PNG_tRNS;
-#endif
-#ifdef PNG_READ_zTXt_SUPPORTED
-      PNG_zTXt;
-#endif
+   png_uint_32 chunk_name;
 
    /* First we make sure we have enough data for the 4 byte chunk name
     * and the 4 byte chunk length before proceeding with decoding the
@@ -273,6 +219,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
    if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
    {
       png_byte chunk_length[4];
+      png_byte chunk_tag[4];
 
       if (png_ptr->buffer_size < 8)
       {
@@ -283,16 +230,27 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
       png_push_fill_buffer(png_ptr, chunk_length, 4);
       png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
       png_reset_crc(png_ptr);
-      png_crc_read(png_ptr, png_ptr->chunk_name, 4);
+      png_crc_read(png_ptr, chunk_tag, 4);
+      png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
       png_check_chunk_name(png_ptr, png_ptr->chunk_name);
       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
    }
 
-   if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+   chunk_name = png_ptr->chunk_name;
+
+   if (chunk_name == png_IDAT)
+   {
+      /* This is here above the if/else case statement below because if the
+       * unknown handling marks 'IDAT' as unknown then the IDAT handling case is
+       * completely skipped.
+       *
+       * TODO: there must be a better way of doing this.
+       */
       if (png_ptr->mode & PNG_AFTER_IDAT)
          png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
+   }
 
-   if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
+   if (chunk_name == png_IHDR)
    {
       if (png_ptr->push_length != 13)
          png_error(png_ptr, "Invalid IHDR length");
@@ -306,7 +264,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
       png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
    }
 
-   else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
+   else if (chunk_name == png_IEND)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -321,7 +279,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
    }
 
 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-   else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
+   else if (png_chunk_unknown_handling(png_ptr, chunk_name))
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -329,15 +287,15 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
          return;
       }
 
-      if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+      if (chunk_name == png_IDAT)
          png_ptr->mode |= PNG_HAVE_IDAT;
 
       png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
 
-      if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
+      if (chunk_name == png_PLTE)
          png_ptr->mode |= PNG_HAVE_PLTE;
 
-      else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+      else if (chunk_name == png_IDAT)
       {
          if (!(png_ptr->mode & PNG_HAVE_IHDR))
             png_error(png_ptr, "Missing IHDR before IDAT");
@@ -349,7 +307,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
    }
 
 #endif
-   else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
+   else if (chunk_name == png_PLTE)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -359,7 +317,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
       png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
    }
 
-   else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+   else if (chunk_name == png_IDAT)
    {
       /* If we reach an IDAT chunk, this means we have read all of the
        * header chunks, and we can start reading the image (or if this
@@ -395,7 +353,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
    }
 
 #ifdef PNG_READ_gAMA_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
+   else if (png_ptr->chunk_name == png_gAMA)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -408,7 +366,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_sBIT_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
+   else if (png_ptr->chunk_name == png_sBIT)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -421,7 +379,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_cHRM_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
+   else if (png_ptr->chunk_name == png_cHRM)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -434,7 +392,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_sRGB_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
+   else if (chunk_name == png_sRGB)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -447,7 +405,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_iCCP_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
+   else if (png_ptr->chunk_name == png_iCCP)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -460,7 +418,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_sPLT_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
+   else if (chunk_name == png_sPLT)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -473,7 +431,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_tRNS_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
+   else if (chunk_name == png_tRNS)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -486,7 +444,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_bKGD_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
+   else if (chunk_name == png_bKGD)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -499,7 +457,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_hIST_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
+   else if (chunk_name == png_hIST)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -512,7 +470,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_pHYs_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
+   else if (chunk_name == png_pHYs)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -525,7 +483,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_oFFs_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
+   else if (chunk_name == png_oFFs)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -538,7 +496,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 #endif
 
 #ifdef PNG_READ_pCAL_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
+   else if (chunk_name == png_pCAL)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -551,7 +509,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_sCAL_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
+   else if (chunk_name == png_sCAL)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -564,7 +522,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_tIME_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
+   else if (chunk_name == png_tIME)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -577,7 +535,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_tEXt_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
+   else if (chunk_name == png_tEXt)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -590,7 +548,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_zTXt_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
+   else if (chunk_name == png_zTXt)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -603,7 +561,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 
 #endif
 #ifdef PNG_READ_iTXt_SUPPORTED
-   else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
+   else if (chunk_name == png_iTXt)
    {
       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
       {
@@ -772,8 +730,7 @@ png_push_save_buffer(png_structp png_ptr)
 
       new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
       old_buffer = png_ptr->save_buffer;
-      png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr,
-          (png_size_t)new_max);
+      png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, new_max);
 
       if (png_ptr->save_buffer == NULL)
       {
@@ -809,11 +766,12 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
 void /* PRIVATE */
 png_push_read_IDAT(png_structp png_ptr)
 {
-   PNG_IDAT;
    if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
    {
       png_byte chunk_length[4];
+      png_byte chunk_tag[4];
 
+      /* TODO: this code can be commoned up with the same code in push_read */
       if (png_ptr->buffer_size < 8)
       {
          png_push_save_buffer(png_ptr);
@@ -823,10 +781,11 @@ png_push_read_IDAT(png_structp png_ptr)
       png_push_fill_buffer(png_ptr, chunk_length, 4);
       png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
       png_reset_crc(png_ptr);
-      png_crc_read(png_ptr, png_ptr->chunk_name, 4);
+      png_crc_read(png_ptr, chunk_tag, 4);
+      png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
 
-      if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+      if (png_ptr->chunk_name != png_IDAT)
       {
          png_ptr->process_mode = PNG_READ_CHUNK_MODE;
 
@@ -838,6 +797,7 @@ png_push_read_IDAT(png_structp png_ptr)
 
       png_ptr->idat_size = png_ptr->push_length;
    }
+
    if (png_ptr->idat_size && png_ptr->save_buffer_size)
    {
       png_size_t save_size = png_ptr->save_buffer_size;
@@ -1011,34 +971,56 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
 void /* PRIVATE */
 png_push_process_row(png_structp png_ptr)
 {
-   png_ptr->row_info.color_type = png_ptr->color_type;
-   png_ptr->row_info.width = png_ptr->iwidth;
-   png_ptr->row_info.channels = png_ptr->channels;
-   png_ptr->row_info.bit_depth = png_ptr->bit_depth;
-   png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
+   /* 1.5.6: row_info moved out of png_struct to a local here. */
+   png_row_info row_info;
 
-   png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
-       png_ptr->row_info.width);
+   row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
+   row_info.color_type = png_ptr->color_type;
+   row_info.bit_depth = png_ptr->bit_depth;
+   row_info.channels = png_ptr->channels;
+   row_info.pixel_depth = png_ptr->pixel_depth;
+   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
 
-   png_read_filter_row(png_ptr, &(png_ptr->row_info),
-       png_ptr->row_buf + 1, png_ptr->prev_row + 1,
-       (int)(png_ptr->row_buf[0]));
+   if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
+   {
+      if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
+         png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
+            png_ptr->prev_row + 1, png_ptr->row_buf[0]);
+      else
+         png_error(png_ptr, "bad adaptive filter value");
+   }
 
-   png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
+   /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
+    * 1.5.6, while the buffer really is this big in current versions of libpng
+    * it may not be in the future, so this was changed just to copy the
+    * interlaced row count:
+    */
+   png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
 
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
    if (png_ptr->transformations)
-      png_do_read_transformations(png_ptr);
+      png_do_read_transformations(png_ptr, &row_info);
+#endif
+
+   /* The transformed pixel depth should match the depth now in row_info. */
+   if (png_ptr->transformed_pixel_depth == 0)
+   {
+      png_ptr->transformed_pixel_depth = row_info.pixel_depth;
+      if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
+         png_error(png_ptr, "progressive row overflow");
+   }
+
+   else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
+      png_error(png_ptr, "internal progressive row size calculation error");
+
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
    /* Blow up interlaced rows to full size */
    if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
    {
       if (png_ptr->pass < 6)
-/*       old interface (pre-1.0.9):
-         png_do_read_interlace(&(png_ptr->row_info),
-             png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
- */
-         png_do_read_interlace(png_ptr);
+         png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
+            png_ptr->transformations);
 
     switch (png_ptr->pass)
     {
@@ -1218,24 +1200,26 @@ png_push_process_row(png_structp png_ptr)
 void /* PRIVATE */
 png_read_push_finish_row(png_structp png_ptr)
 {
+#ifdef PNG_READ_INTERLACING_SUPPORTED
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
+   static PNG_CONST png_byte FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST png_byte FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
+   static PNG_CONST png_byte FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
+   static PNG_CONST png_byte FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
 
    /* Height of interlace block.  This is not currently used - if you need
     * it, uncomment it here and in png.h
-   PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST png_byte FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
    */
+#endif
 
    png_ptr->row_number++;
    if (png_ptr->row_number < png_ptr->num_rows)
@@ -1288,7 +1272,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
       {
          PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
          png_error(png_ptr, "Out of place tEXt");
-         /*NOT REACHED*/
+         /* NOT REACHED */
       }
 
 #ifdef PNG_MAX_MALLOC_64K
@@ -1302,8 +1286,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
    }
 #endif
 
-   png_ptr->current_text = (png_charp)png_malloc(png_ptr,
-       (png_size_t)(length + 1));
+   png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
    png_ptr->current_text[length] = '\0';
    png_ptr->current_text_ptr = png_ptr->current_text;
    png_ptr->current_text_size = (png_size_t)length;
@@ -1385,7 +1368,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
    {
       PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
       png_error(png_ptr, "Out of place zTXt");
-      /*NOT REACHED*/
+      /* NOT REACHED */
    }
 
 #ifdef PNG_MAX_MALLOC_64K
@@ -1401,8 +1384,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
    }
 #endif
 
-   png_ptr->current_text = (png_charp)png_malloc(png_ptr,
-       (png_size_t)(length + 1));
+   png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
    png_ptr->current_text[length] = '\0';
    png_ptr->current_text_ptr = png_ptr->current_text;
    png_ptr->current_text_size = (png_size_t)length;
@@ -1589,7 +1571,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
    {
       PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
       png_error(png_ptr, "Out of place iTXt");
-      /*NOT REACHED*/
+      /* NOT REACHED */
    }
 
 #ifdef PNG_MAX_MALLOC_64K
@@ -1603,8 +1585,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
    }
 #endif
 
-   png_ptr->current_text = (png_charp)png_malloc(png_ptr,
-       (png_size_t)(length + 1));
+   png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
    png_ptr->current_text[length] = '\0';
    png_ptr->current_text_ptr = png_ptr->current_text;
    png_ptr->current_text_size = (png_size_t)length;
@@ -1712,11 +1693,12 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
     length)
 {
    png_uint_32 skip = 0;
+   png_uint_32 chunk_name = png_ptr->chunk_name;
 
-   if (!(png_ptr->chunk_name[0] & 0x20))
+   if (PNG_CHUNK_CRITICAL(chunk_name))
    {
 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
-      if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+      if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
           PNG_HANDLE_CHUNK_ALWAYS
 #ifdef PNG_READ_USER_CHUNKS_SUPPORTED
           && png_ptr->read_user_chunk_fn == NULL
@@ -1729,23 +1711,26 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
    }
 
 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
+   /* TODO: the code below is apparently just using the
+    * png_struct::unknown_chunk member as a temporarily variable, it should be
+    * possible to eliminate both it and the temporary buffer.
+    */
    if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
    {
 #ifdef PNG_MAX_MALLOC_64K
-      if (length > (png_uint_32)65535L)
+      if (length > 65535)
       {
          png_warning(png_ptr, "unknown chunk too large to fit in memory");
-         skip = length - (png_uint_32)65535L;
-         length = (png_uint_32)65535L;
+         skip = length - 65535;
+         length = 65535;
       }
 #endif
-      png_memcpy((png_charp)png_ptr->unknown_chunk.name,
-          (png_charp)png_ptr->chunk_name,
-          png_sizeof(png_ptr->unknown_chunk.name));
-      png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1]
-          = '\0';
+      /* This is just a record for the user; libpng doesn't use the character
+       * form of the name.
+       */
+      PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
 
-      png_ptr->unknown_chunk.size = (png_size_t)length;
+      png_ptr->unknown_chunk.size = length;
 
       if (length == 0)
          png_ptr->unknown_chunk.data = NULL;
@@ -1753,8 +1738,9 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
       else
       {
          png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
-             (png_size_t)length);
-         png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
+            png_ptr->unknown_chunk.size);
+         png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data,
+            png_ptr->unknown_chunk.size);
       }
 
 #ifdef PNG_READ_USER_CHUNKS_SUPPORTED
@@ -1770,8 +1756,8 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
 
          if (ret == 0)
          {
-            if (!(png_ptr->chunk_name[0] & 0x20))
-               if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+            if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
+               if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
                    PNG_HANDLE_CHUNK_ALWAYS)
                   png_chunk_error(png_ptr, "unknown critical chunk");
             png_set_unknown_chunks(png_ptr, info_ptr,
@@ -1814,19 +1800,22 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
          (int)png_ptr->pass);
 }
 
+#ifdef PNG_READ_INTERLACING_SUPPORTED
 void PNGAPI
 png_progressive_combine_row (png_structp png_ptr, png_bytep old_row,
     png_const_bytep new_row)
 {
-   PNG_CONST int FARDATA png_pass_dsp_mask[7] =
-      {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
-
    if (png_ptr == NULL)
       return;
 
-   if (new_row != NULL)    /* new_row must == png_ptr->row_buf here. */
-      png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
+   /* new_row is a flag here - if it is NULL then the app callback was called
+    * from an empty row (see the calls to png_struct::row_fn below), otherwise
+    * it must be png_ptr->row_buf+1
+    */
+   if (new_row != NULL)
+      png_combine_row(png_ptr, old_row, 1/*display*/);
 }
+#endif /* PNG_READ_INTERLACING_SUPPORTED */
 
 void PNGAPI
 png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
index a7e3b5272700ddebe49f33fec0f7d55045ec66ff..67e486c577f3f40c1ca217015db4adc688a2758d 100644 (file)
@@ -6,7 +6,7 @@
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.5.2 [March 31, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
 #ifndef PNGPRIV_H
 #define PNGPRIV_H
 
+/* Feature Test Macros.  The following are defined here to ensure that correctly
+ * implemented libraries reveal the APIs libpng needs to build and hide those
+ * that are not needed and potentially damaging to the compilation.
+ *
+ * Feature Test Macros must be defined before any system header is included (see
+ * POSIX 1003.1 2.8.2 "POSIX Symbols."
+ *
+ * These macros only have an effect if the operating system supports either
+ * POSIX 1003.1 or C99, or both.  On other operating systems (particularly
+ * Windows/Visual Studio) there is no effect; the OS specific tests below are
+ * still required (as of 2011-05-02.)
+ */
+#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
+
 /* This is required for the definition of abort(), used as a last ditch
  * error handler when all else fails.
  */
 #include <stdlib.h>
 
-#define PNGLIB_BUILD
+/* This is used to find 'offsetof', used below for alignment tests. */
+#include <stddef.h>
+
+#define PNGLIB_BUILD /*libpng is being built, not used*/
+
 #ifdef PNG_USER_CONFIG
 #  include "pngusr.h"
    /* These should have been defined in pngusr.h */
 #    define PNG_USER_DLLFNAME_POSTFIX "Cb"
 #  endif
 #endif
+
+/* Is this a build of a DLL where compilation of the object modules requires
+ * different preprocessor settings to those required for a simple library?  If
+ * so PNG_BUILD_DLL must be set.
+ *
+ * If libpng is used inside a DLL but that DLL does not export the libpng APIs
+ * PNG_BUILD_DLL must not be set.  To avoid the code below kicking in build a
+ * static library of libpng then link the DLL against that.
+ */
+#ifndef PNG_BUILD_DLL
+#  ifdef DLL_EXPORT
+      /* This is set by libtool when files are compiled for a DLL; libtool
+       * always compiles twice, even on systems where it isn't necessary.  Set
+       * PNG_BUILD_DLL in case it is necessary:
+       */
+#     define PNG_BUILD_DLL
+#  else
+#     ifdef _WINDLL
+         /* This is set by the Microsoft Visual Studio IDE in projects that
+          * build a DLL.  It can't easily be removed from those projects (it
+          * isn't visible in the Visual Studio UI) so it is a fairly reliable
+          * indication that PNG_IMPEXP needs to be set to the DLL export
+          * attributes.
+          */
+#        define PNG_BUILD_DLL
+#     else
+#        ifdef __DLL__
+            /* This is set by the Borland C system when compiling for a DLL
+             * (as above.)
+             */
+#           define PNG_BUILD_DLL
+#        else
+            /* Add additional compiler cases here. */
+#        endif
+#     endif
+#  endif
+#endif /* Setting PNG_BUILD_DLL if required */
+
+/* See pngconf.h for more details: the builder of the library may set this on
+ * the command line to the right thing for the specific compilation system or it
+ * may be automagically set above (at present we know of no system where it does
+ * need to be set on the command line.)
+ *
+ * PNG_IMPEXP must be set here when building the library to prevent pngconf.h
+ * setting it to the "import" setting for a DLL build.
+ */
+#ifndef PNG_IMPEXP
+#  ifdef PNG_BUILD_DLL
+#     define PNG_IMPEXP PNG_DLL_EXPORT
+#  else
+      /* Not building a DLL, or the DLL doesn't require specific export
+       * definitions.
+       */
+#     define PNG_IMPEXP
+#  endif
+#endif
+
+/* No warnings for private or deprecated functions in the build: */
+#ifndef PNG_DEPRECATED
+#  define PNG_DEPRECATED
+#endif
+#ifndef PNG_PRIVATE
+#  define PNG_PRIVATE
+#endif
+
 #include "png.h"
 #include "pnginfo.h"
 #include "pngstruct.h"
 
+/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */
+#ifndef PNG_DLL_EXPORT
+#  define PNG_DLL_EXPORT
+#endif
+
 /* This is used for 16 bit gamma tables - only the top level pointers are const,
  * this could be changed:
  */
@@ -101,12 +189,44 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
 #  define PNG_ZBUF_SIZE 65536L
 #endif
 
-/* If warnings or errors are turned off the code is disabled
- * or redirected here.
+/* PNG_STATIC is used to mark internal file scope functions if they need to be
+ * accessed for implementation tests (see the code in tests/?*).
  */
-#ifndef PNG_WARNINGS_SUPPORTED
-#  define png_warning(s1,s2) ((void)0)
-#  define png_chunk_warning(s1,s2) ((void)0)
+#ifndef PNG_STATIC
+#   define PNG_STATIC static
+#endif
+
+/* C99 restrict is used where possible, to do this 'restrict' is defined as
+ * empty if we can't be sure it is supported.  configure builds have already
+ * done this work.
+ */
+#ifdef PNG_CONFIGURE_LIBPNG
+#  define PNG_RESTRICT restrict
+#else
+   /* Modern compilers support restrict, but assume not for anything not
+    * recognized here:
+    */
+#  if defined __GNUC__ || defined _MSC_VER || defined __WATCOMC__
+#     define PNG_RESTRICT restrict
+#  else
+#     define PNG_RESTRICT
+#  endif
+#endif
+
+/* If warnings or errors are turned off the code is disabled or redirected here.
+ * From 1.5.4 functions have been added to allow very limited formatting of
+ * error and warning messages - this code will also be disabled here.
+ */
+#ifdef PNG_WARNINGS_SUPPORTED
+#  define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;
+#else
+#  define png_warning(s1,s2) ((void)(s1))
+#  define png_chunk_warning(s1,s2) ((void)(s1))
+#  define png_warning_parameter(p,number,string) ((void)0)
+#  define png_warning_parameter_unsigned(p,number,format,value) ((void)0)
+#  define png_warning_parameter_signed(p,number,format,value) ((void)0)
+#  define png_formatted_warning(pp,p,message) ((void)(pp))
+#  define PNG_WARNING_PARAMETERS(p)
 #endif
 #ifndef PNG_ERROR_TEXT_SUPPORTED
 #  define png_error(s1,s2) png_err(s1)
@@ -114,15 +234,28 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
 #  define png_fixed_error(s1,s2) png_err(s1)
 #endif
 
+/* C allows up-casts from (void*) to any pointer and (const void*) to any
+ * pointer to a const object.  C++ regards this as a type error and requires an
+ * explicit, static, cast and provides the static_cast<> rune to ensure that
+ * const is not cast away.
+ */
+#ifdef __cplusplus
+#  define png_voidcast(type, value) static_cast<type>(value)
+#else
+#  define png_voidcast(type, value) (value)
+#endif /* __cplusplus */
+
 #ifndef PNG_EXTERN
 /* The functions exported by PNG_EXTERN are internal functions, which
  * aren't usually used outside the library (as far as I know), so it is
  * debatable if they should be exported at all.  In the future, when it
  * is possible to have run-time registry of chunk-handling functions,
  * some of these might be made available again.
-#  define PNG_EXTERN extern
+ *
+ * 1.5.7: turned the use of 'extern' back on, since it is localized to pngpriv.h
+ * it should be safe now (it is unclear why it was turned off.)
  */
-#  define PNG_EXTERN
+#  define PNG_EXTERN extern
 #endif
 
 /* Some fixed point APIs are still required even if not exported because
@@ -200,60 +333,74 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
 #  define NOCHECK 0
 #  define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
 #  define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
-#  define png_strcpy  _fstrcpy
-#  define png_strncpy _fstrncpy   /* Added to v 1.2.6 */
 #  define png_strlen  _fstrlen
 #  define png_memcmp  _fmemcmp    /* SJT: added */
 #  define png_memcpy  _fmemcpy
 #  define png_memset  _fmemset
-#  define png_sprintf sprintf
 #else
 #  ifdef _WINDOWS_  /* Favor Windows over C runtime fns */
 #    define CVT_PTR(ptr)         (ptr)
 #    define CVT_PTR_NOCHECK(ptr) (ptr)
-#    define png_strcpy  lstrcpyA
-#    define png_strncpy lstrcpynA
 #    define png_strlen  lstrlenA
 #    define png_memcmp  memcmp
 #    define png_memcpy  CopyMemory
 #    define png_memset  memset
-#    define png_sprintf wsprintfA
 #  else
 #    define CVT_PTR(ptr)         (ptr)
 #    define CVT_PTR_NOCHECK(ptr) (ptr)
-#    define png_strcpy  strcpy
-#    define png_strncpy strncpy     /* Added to v 1.2.6 */
 #    define png_strlen  strlen
 #    define png_memcmp  memcmp      /* SJT: added */
 #    define png_memcpy  memcpy
 #    define png_memset  memset
-#    define png_sprintf sprintf
 #  endif
 #endif
-/* End of memory model/platform independent support */
 
-#ifndef PNG_NO_SNPRINTF
-#  ifdef _MSC_VER
-#    define png_snprintf _snprintf   /* Added to v 1.2.19 */
-#    define png_snprintf2 _snprintf
-#    define png_snprintf6 _snprintf
+/* These macros may need to be architecture dependent. */
+#define PNG_ALIGN_NONE   0 /* do not use data alignment */
+#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
+#ifdef offsetof
+#  define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
+#else
+#  define PNG_ALIGN_OFFSET -1 /* prevent the use of this */
+#endif
+#define PNG_ALIGN_SIZE   3 /* use sizeof to determine alignment */
+
+#ifndef PNG_ALIGN_TYPE
+   /* Default to using aligned access optimizations and requiring alignment to a
+    * multiple of the data type size.  Override in a compiler specific fashion
+    * if necessary by inserting tests here:
+    */
+#  define PNG_ALIGN_TYPE PNG_ALIGN_SIZE
+#endif
+
+#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE
+   /* This is used because in some compiler implementations non-aligned
+    * structure members are supported, so the offsetof approach below fails.
+    * Set PNG_ALIGN_TO_SIZE=0 for compiler combinations where unaligned access
+    * is good for performance.  Do not do this unless you have tested the result
+    * and understand it.
+    */
+#  define png_alignof(type) (sizeof (type))
+#else
+#  if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET
+#     define png_alignof(type) offsetof(struct{char c; type t;}, t)
 #  else
-#    define png_snprintf snprintf   /* Added to v 1.2.19 */
-#    define png_snprintf2 snprintf
-#    define png_snprintf6 snprintf
+#     if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
+#        define png_alignof(type) (1)
+#     endif
+      /* Else leave png_alignof undefined to prevent use thereof */
 #  endif
+#endif
+
+/* This implicitly assumes alignment is always to a power of 2. */
+#ifdef png_alignof
+#  define png_isaligned(ptr, type)\
+   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)
 #else
-  /* You don't have or don't want to use snprintf().  Caution: Using
-   * sprintf instead of snprintf exposes your application to accidental
-   * or malevolent buffer overflows.  If you don't have snprintf()
-   * as a general rule you should provide one (you can get one from
-   * Portable OpenSSH).
-   */
-#  define png_snprintf(s1,n,fmt,x1) png_sprintf(s1,fmt,x1)
-#  define png_snprintf2(s1,n,fmt,x1,x2) png_sprintf(s1,fmt,x1,x2)
-#  define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
-      png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
+#  define png_isaligned(ptr, type) 0
 #endif
+
+/* End of memory model/platform independent support */
 /* End of 1.5.0beta36 move from pngconf.h */
 
 /* CONSTANTS and UTILITY MACROS
@@ -261,12 +408,14 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
  */
 
 /* Various modes of operation.  Note that after an init, mode is set to
- * zero automatically when the structure is created.
+ * zero automatically when the structure is created.  Three of these
+ * are defined in png.h because they need to be visible to applications
+ * that call png_set_unknown_chunk().
  */
-#define PNG_HAVE_IHDR               0x01
-#define PNG_HAVE_PLTE               0x02
+/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */
+/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */
 #define PNG_HAVE_IDAT               0x04
-#define PNG_AFTER_IDAT              0x08 /* Have complete zlib datastream */
+/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */
 #define PNG_HAVE_IEND               0x10
 #define PNG_HAVE_gAMA               0x20
 #define PNG_HAVE_cHRM               0x40
@@ -286,32 +435,31 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
 #define PNG_SWAP_BYTES          0x0010
 #define PNG_INVERT_MONO         0x0020
 #define PNG_QUANTIZE            0x0040
-#define PNG_BACKGROUND          0x0080
+#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */
 #define PNG_BACKGROUND_EXPAND   0x0100
 #define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */
-#define PNG_16_TO_8             0x0400
+#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */
 #define PNG_RGBA                0x0800
 #define PNG_EXPAND              0x1000
 #define PNG_GAMMA               0x2000
 #define PNG_GRAY_TO_RGB         0x4000
-#define PNG_FILLER              0x8000L
-#define PNG_PACKSWAP           0x10000L
-#define PNG_SWAP_ALPHA         0x20000L
-#define PNG_STRIP_ALPHA        0x40000L
-#define PNG_INVERT_ALPHA       0x80000L
-#define PNG_USER_TRANSFORM    0x100000L
-#define PNG_RGB_TO_GRAY_ERR   0x200000L
-#define PNG_RGB_TO_GRAY_WARN  0x400000L
-#define PNG_RGB_TO_GRAY       0x600000L  /* two bits, RGB_TO_GRAY_ERR|WARN */
-                       /*     0x800000L     Unused */
-#define PNG_ADD_ALPHA         0x1000000L  /* Added to libpng-1.2.7 */
-#define PNG_EXPAND_tRNS       0x2000000L  /* Added to libpng-1.2.9 */
-                       /*   0x4000000L  unused */
-                       /*   0x8000000L  unused */
-                       /*  0x10000000L  unused */
-                       /*  0x20000000L  unused */
-                       /*  0x40000000L  unused */
-
+#define PNG_FILLER              0x8000
+#define PNG_PACKSWAP           0x10000
+#define PNG_SWAP_ALPHA         0x20000
+#define PNG_STRIP_ALPHA        0x40000
+#define PNG_INVERT_ALPHA       0x80000
+#define PNG_USER_TRANSFORM    0x100000
+#define PNG_RGB_TO_GRAY_ERR   0x200000
+#define PNG_RGB_TO_GRAY_WARN  0x400000
+#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
+#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */
+#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */
+#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */
+#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */
+                       /*   0x8000000 unused */
+                       /*  0x10000000 unused */
+                       /*  0x20000000 unused */
+                       /*  0x40000000 unused */
 /* Flags for png_create_struct */
 #define PNG_STRUCT_PNG   0x0001
 #define PNG_STRUCT_INFO  0x0002
@@ -333,25 +481,25 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
 #define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200
 #define PNG_FLAG_CRC_CRITICAL_USE         0x0400
 #define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800
-                                /*        0x1000  unused */
-                                /*        0x2000  unused */
-                                /*        0x4000  unused */
-#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000L
-#define PNG_FLAG_KEEP_UNSAFE_CHUNKS       0x10000L
-#define PNG_FLAG_LIBRARY_MISMATCH         0x20000L
-#define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000L
-#define PNG_FLAG_STRIP_ERROR_TEXT         0x80000L
-#define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000L
-                                  /*      0x200000L  unused */
-                                  /*      0x400000L  unused */
-#define PNG_FLAG_BENIGN_ERRORS_WARN       0x800000L  /* Added to libpng-1.4.0 */
-                                  /*     0x1000000L  unused */
-                                  /*     0x2000000L  unused */
-                                  /*     0x4000000L  unused */
-                                  /*     0x8000000L  unused */
-                                  /*    0x10000000L  unused */
-                                  /*    0x20000000L  unused */
-                                  /*    0x40000000L  unused */
+#define PNG_FLAG_ASSUME_sRGB              0x1000  /* Added to libpng-1.5.4 */
+#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000  /* Added to libpng-1.5.4 */
+#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000  /* Added to libpng-1.5.4 */
+#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000
+#define PNG_FLAG_KEEP_UNSAFE_CHUNKS       0x10000
+#define PNG_FLAG_LIBRARY_MISMATCH         0x20000
+#define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000
+#define PNG_FLAG_STRIP_ERROR_TEXT         0x80000
+#define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000
+                                  /*      0x200000  unused */
+                                  /*      0x400000  unused */
+#define PNG_FLAG_BENIGN_ERRORS_WARN       0x800000  /* Added to libpng-1.4.0 */
+#define PNG_FLAG_ZTXT_CUSTOM_STRATEGY    0x1000000  /* 5 lines added */
+#define PNG_FLAG_ZTXT_CUSTOM_LEVEL       0x2000000  /* to libpng-1.5.4 */
+#define PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL   0x4000000
+#define PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS 0x8000000
+#define PNG_FLAG_ZTXT_CUSTOM_METHOD      0x10000000
+                                  /*     0x20000000  unused */
+                                  /*     0x40000000  unused */
 
 #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
@@ -433,32 +581,75 @@ PNG_EXTERN png_fixed_point png_fixed PNGARG((png_structp png_ptr, double fp,
 #endif
 #endif
 
-/* Constant strings for known chunk types.  If you need to add a chunk,
- * define the name here, and add an invocation of the macro wherever it's
- * needed.
+/* Constants for known chunk types.  If you need to add a chunk, define the name
+ * here.  For historical reasons these constants have the form png_<name>; i.e.
+ * the prefix is lower case.  Please use decimal values as the parameters to
+ * match the ISO PNG specification and to avoid relying on the C locale
+ * interpretation of character values.
+ *
+ * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values
+ * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string
+ * to be generated if required.
+ *
+ * PNG_32b correctly produces a value shifted by up to 24 bits, even on
+ * architectures where (int) is only 16 bits.
  */
-#define PNG_IHDR PNG_CONST png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'}
-#define PNG_IDAT PNG_CONST png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'}
-#define PNG_IEND PNG_CONST png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'}
-#define PNG_PLTE PNG_CONST png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'}
-#define PNG_bKGD PNG_CONST png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'}
-#define PNG_cHRM PNG_CONST png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'}
-#define PNG_gAMA PNG_CONST png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'}
-#define PNG_hIST PNG_CONST png_byte png_hIST[5] = {104,  73,  83,  84, '\0'}
-#define PNG_iCCP PNG_CONST png_byte png_iCCP[5] = {105,  67,  67,  80, '\0'}
-#define PNG_iTXt PNG_CONST png_byte png_iTXt[5] = {105,  84,  88, 116, '\0'}
-#define PNG_oFFs PNG_CONST png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'}
-#define PNG_pCAL PNG_CONST png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'}
-#define PNG_sCAL PNG_CONST png_byte png_sCAL[5] = {115,  67,  65,  76, '\0'}
-#define PNG_pHYs PNG_CONST png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'}
-#define PNG_sBIT PNG_CONST png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'}
-#define PNG_sPLT PNG_CONST png_byte png_sPLT[5] = {115,  80,  76,  84, '\0'}
-#define PNG_sRGB PNG_CONST png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'}
-#define PNG_sTER PNG_CONST png_byte png_sTER[5] = {115,  84,  69,  82, '\0'}
-#define PNG_tEXt PNG_CONST png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'}
-#define PNG_tIME PNG_CONST png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
-#define PNG_tRNS PNG_CONST png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
-#define PNG_zTXt PNG_CONST png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
+#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
+#define PNG_CHUNK(b1,b2,b3,b4) \
+   (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
+
+#define png_IHDR PNG_CHUNK( 73,  72,  68,  82)
+#define png_IDAT PNG_CHUNK( 73,  68,  65,  84)
+#define png_IEND PNG_CHUNK( 73,  69,  78,  68)
+#define png_PLTE PNG_CHUNK( 80,  76,  84,  69)
+#define png_bKGD PNG_CHUNK( 98,  75,  71,  68)
+#define png_cHRM PNG_CHUNK( 99,  72,  82,  77)
+#define png_gAMA PNG_CHUNK(103,  65,  77,  65)
+#define png_hIST PNG_CHUNK(104,  73,  83,  84)
+#define png_iCCP PNG_CHUNK(105,  67,  67,  80)
+#define png_iTXt PNG_CHUNK(105,  84,  88, 116)
+#define png_oFFs PNG_CHUNK(111,  70,  70, 115)
+#define png_pCAL PNG_CHUNK(112,  67,  65,  76)
+#define png_sCAL PNG_CHUNK(115,  67,  65,  76)
+#define png_pHYs PNG_CHUNK(112,  72,  89, 115)
+#define png_sBIT PNG_CHUNK(115,  66,  73,  84)
+#define png_sPLT PNG_CHUNK(115,  80,  76,  84)
+#define png_sRGB PNG_CHUNK(115,  82,  71,  66)
+#define png_sTER PNG_CHUNK(115,  84,  69,  82)
+#define png_tEXt PNG_CHUNK(116,  69,  88, 116)
+#define png_tIME PNG_CHUNK(116,  73,  77,  69)
+#define png_tRNS PNG_CHUNK(116,  82,  78,  83)
+#define png_zTXt PNG_CHUNK(122,  84,  88, 116)
+
+/* The following will work on (signed char*) strings, whereas the get_uint_32
+ * macro will fail on top-bit-set values because of the sign extension.
+ */
+#define PNG_CHUNK_FROM_STRING(s)\
+   PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
+
+/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
+ * signed and the argument is a (char[])  This macro will fail miserably on
+ * systems where (char) is more than 8 bits.
+ */
+#define PNG_STRING_FROM_CHUNK(s,c)\
+   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
+   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
+
+/* Do the same but terminate with a null character. */
+#define PNG_CSTRING_FROM_CHUNK(s,c)\
+   (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)
+
+/* Test on flag values as defined in the spec (section 5.4): */
+#define PNG_CHUNK_ANCILLIARY(c)   (1 & ((c) >> 29))
+#define PNG_CHUNK_CRITICAL(c)     (!PNG_CHUNK_ANCILLIARY(c))
+#define PNG_CHUNK_PRIVATE(c)      (1 & ((c) >> 21))
+#define PNG_CHUNK_RESERVED(c)     (1 & ((c) >> 13))
+#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >>  5))
+
+/* Gamma values (new at libpng-1.5.4): */
+#define PNG_GAMMA_MAC_OLD 151724  /* Assume '1.8' is really 2.2/1.45! */
+#define PNG_GAMMA_MAC_INVERSE 65909
+#define PNG_GAMMA_sRGB_INVERSE 45455
 
 
 /* Inhibit C++ name-mangling for libpng functions but not for system calls. */
@@ -472,6 +663,12 @@ extern "C" {
  * be found in the files where the functions are located.
  */
 
+/* Check the user version string for compatibility, returns false if the version
+ * numbers aren't compatible.
+ */
+PNG_EXTERN int png_user_version_check(png_structp png_ptr,
+   png_const_charp user_png_ver);
+
 /* Allocate memory for an internal libpng struct */
 PNG_EXTERN PNG_FUNCTION(png_voidp,png_create_struct,PNGARG((int type)),
    PNG_ALLOCATED);
@@ -540,8 +737,7 @@ PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
     png_size_t length));
 
 /* Decompress data in a chunk that uses compression */
-#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
-    defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
+#if defined(PNG_READ_COMPRESSED_TEXT_SUPPORTED)
 PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
     int comp_type, png_size_t chunklength, png_size_t prefix_length,
     png_size_t *data_length));
@@ -644,6 +840,7 @@ PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr,
     png_const_uint_16p hist, int num_hist));
 #endif
 
+/* Chunks that have keywords */
 #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
     defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
 PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
@@ -704,17 +901,44 @@ PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
 /* Internal use only.   Called before first row of data */
 PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
 
-/* Combine a row of data, dealing with alpha, etc. if requested */
+/* Combine a row of data, dealing with alpha, etc. if requested.  'row' is an
+ * array of png_ptr->width pixels.  If the image is not interlaced or this
+ * is the final pass this just does a png_memcpy, otherwise the "display" flag
+ * is used to determine whether to copy pixels that are not in the current pass.
+ *
+ * Because 'png_do_read_interlace' (below) replicates pixels this allows this
+ * function to achieve the documented 'blocky' appearance during interlaced read
+ * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'
+ * are not changed if they are not in the current pass, when display is 0.
+ *
+ * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.
+ *
+ * The API always reads from the png_struct row buffer and always assumes that
+ * it is full width (png_do_read_interlace has already been called.)
+ *
+ * This function is only ever used to write to row buffers provided by the
+ * caller of the relevant libpng API and the row must have already been
+ * transformed by the read transformations.
+ *
+ * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed
+ * bitmasks for use within the code, otherwise runtime generated masks are used.
+ * The default is compile time masks.
+ */
+#ifndef PNG_USE_COMPILE_TIME_MASKS
+#  define PNG_USE_COMPILE_TIME_MASKS 1
+#endif
 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
-    int mask));
+    int display));
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
-/* Expand an interlaced row */
-/* OLD pre-1.0.9 interface:
+/* Expand an interlaced row: the 'row_info' describes the pass data that has
+ * been read in and must correspond to the pixels in 'row', the pixels are
+ * expanded (moved apart) in 'row' to match the final layout, when doing this
+ * the pixels are *replicated* to the intervening space.  This is essential for
+ * the correct operation of png_combine_row, above.
+ */
 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
     png_bytep row, int pass, png_uint_32 transformations));
- */
-PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
 #endif
 
 /* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */
@@ -725,26 +949,42 @@ PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
     png_bytep row, int pass));
 #endif
 
-/* Unfilter a row */
-PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
-    png_row_infop row_info, png_bytep row, png_const_bytep prev_row,
-    int filter));
+/* Unfilter a row: check the filter value before calling this, there is no point
+ * calling it for PNG_FILTER_VALUE_NONE.
+ */
+PNG_EXTERN void png_read_filter_row PNGARG((png_structp pp, png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row, int filter));
+
+PNG_EXTERN void png_read_filter_row_up_neon PNGARG((png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row));
+PNG_EXTERN void png_read_filter_row_sub3_neon PNGARG((png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row));
+PNG_EXTERN void png_read_filter_row_sub4_neon PNGARG((png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row));
+PNG_EXTERN void png_read_filter_row_avg3_neon PNGARG((png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row));
+PNG_EXTERN void png_read_filter_row_avg4_neon PNGARG((png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row));
+PNG_EXTERN void png_read_filter_row_paeth3_neon PNGARG((png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row));
+PNG_EXTERN void png_read_filter_row_paeth4_neon PNGARG((png_row_infop row_info,
+    png_bytep row, png_const_bytep prev_row));
 
 /* Choose the best filter to use and filter the row data */
 PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
     png_row_infop row_info));
 
-/* Write out the filtered row. */
-PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
-    png_bytep filtered_row));
 /* Finish a row while reading, dealing with interlacing passes, etc. */
 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
 
 /* Initialize the row buffers, etc. */
 PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
+
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
 /* Optional call to update the users info structure */
 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
     png_infop info_ptr));
+#endif
 
 /* These are the functions that do the transformations */
 #ifdef PNG_READ_FILLER_SUPPORTED
@@ -816,7 +1056,12 @@ PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,
     png_bytep row));
 #endif
 
-#ifdef PNG_READ_16_TO_8_SUPPORTED
+#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+PNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,
+    png_bytep row));
+#endif
+
+#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
 PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,
     png_bytep row));
 #endif
@@ -847,26 +1092,20 @@ PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info,
     png_bytep row, png_const_color_8p bit_depth));
 #endif
 
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-#  ifdef PNG_READ_GAMMA_SUPPORTED
-PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info,
-    png_bytep row, png_const_color_16p trans_color,
-    png_const_color_16p background, png_const_color_16p background_1,
-    png_const_bytep gamma_table, png_const_bytep gamma_from_1,
-    png_const_bytep gamma_to_1, png_const_uint_16pp gamma_16,
-    png_const_uint_16pp gamma_16_from_1, png_const_uint_16pp gamma_16_to_1,
-    int gamma_shift));
-#  else
-PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info,
-    png_bytep row, png_const_color_16p trans_color,
-    png_const_color_16p background));
-#  endif
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
+    defined(PNG_READ_ALPHA_MODE_SUPPORTED)
+PNG_EXTERN void png_do_compose PNGARG((png_row_infop row_info,
+    png_bytep row, png_structp png_ptr));
 #endif
 
 #ifdef PNG_READ_GAMMA_SUPPORTED
 PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info,
-    png_bytep row, png_const_bytep gamma_table,
-    png_const_uint_16pp gamma_16_table, int gamma_shift));
+    png_bytep row, png_structp png_ptr));
+#endif
+
+#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+PNG_EXTERN void png_do_encode_alpha PNGARG((png_row_infop row_info,
+   png_bytep row, png_structp png_ptr));
 #endif
 
 #ifdef PNG_READ_EXPAND_SUPPORTED
@@ -979,17 +1218,35 @@ PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
     png_uint_32 length));
 #endif
 
+#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
 PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
     png_infop info_ptr, png_uint_32 length));
+#endif
 
 PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
-    png_const_bytep chunk_name));
+    png_uint_32 chunk_name));
+
+#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+/* Exactly as png_handle_as_unknown() except that the argument is a 32-bit chunk
+ * name, not a string.
+ */
+PNG_EXTERN int png_chunk_unknown_handling PNGARG((png_structp png_ptr,
+    png_uint_32 chunk_name));
+#endif
 
 /* Handle the transformations for reading and writing */
-PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
+PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr,
+   png_row_infop row_info));
+#endif
+#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
+PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr,
+   png_row_infop row_info));
+#endif
 
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
 PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
+#endif
 
 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
 PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
@@ -1063,6 +1320,35 @@ PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
     unsigned long *hi_product, unsigned long *lo_product));
 #endif
 
+#ifdef PNG_cHRM_SUPPORTED
+/* Added at libpng version 1.5.5 */
+typedef struct png_xy
+{
+   png_fixed_point redx, redy;
+   png_fixed_point greenx, greeny;
+   png_fixed_point bluex, bluey;
+   png_fixed_point whitex, whitey;
+} png_xy;
+
+typedef struct png_XYZ
+{
+   png_fixed_point redX, redY, redZ;
+   png_fixed_point greenX, greenY, greenZ;
+   png_fixed_point blueX, blueY, blueZ;
+} png_XYZ;
+
+/* The conversion APIs return 0 on success, non-zero on a parameter error. They
+ * allow conversion between the above representations of a color encoding.  When
+ * converting from XYZ end points to chromaticities the absolute magnitude of
+ * the end points is lost, when converting back the sum of the Y values of the
+ * three end points will be 1.0
+ */
+PNG_EXTERN int png_xy_from_XYZ PNGARG((png_xy *xy, png_XYZ XYZ));
+PNG_EXTERN int png_XYZ_from_xy PNGARG((png_XYZ *XYZ, png_xy xy));
+PNG_EXTERN int png_XYZ_from_xy_checked PNGARG((png_structp png_ptr,
+   png_XYZ *XYZ, png_xy xy));
+#endif
+
 /* Added at libpng version 1.4.0 */
 PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
     png_uint_32 width, png_uint_32 height, int bit_depth,
@@ -1086,6 +1372,76 @@ PNG_EXTERN PNG_FUNCTION(void, png_fixed_error, (png_structp png_ptr,
    png_const_charp name),PNG_NORETURN);
 #endif
 
+/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite
+ * the end.  Always leaves the buffer nul terminated.  Never errors out (and
+ * there is no error code.)
+ */
+PNG_EXTERN size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos,
+    png_const_charp string);
+
+/* Various internal functions to handle formatted warning messages, currently
+ * only implemented for warnings.
+ */
+#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)
+/* Utility to dump an unsigned value into a buffer, given a start pointer and
+ * and end pointer (which should point just *beyond* the end of the buffer!)
+ * Returns the pointer to the start of the formatted string.  This utility only
+ * does unsigned values.
+ */
+PNG_EXTERN png_charp png_format_number(png_const_charp start, png_charp end,
+   int format, png_alloc_size_t number);
+
+/* Convenience macro that takes an array: */
+#define PNG_FORMAT_NUMBER(buffer,format,number) \
+   png_format_number(buffer, buffer + (sizeof buffer), format, number)
+
+/* Suggested size for a number buffer (enough for 64 bits and a sign!) */
+#define PNG_NUMBER_BUFFER_SIZE 24
+
+/* These are the integer formats currently supported, the name is formed from
+ * the standard printf(3) format string.
+ */
+#define PNG_NUMBER_FORMAT_u     1 /* chose unsigned API! */
+#define PNG_NUMBER_FORMAT_02u   2
+#define PNG_NUMBER_FORMAT_d     1 /* chose signed API! */
+#define PNG_NUMBER_FORMAT_02d   2
+#define PNG_NUMBER_FORMAT_x     3
+#define PNG_NUMBER_FORMAT_02x   4
+#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */
+#endif
+
+#ifdef PNG_WARNINGS_SUPPORTED
+/* New defines and members adding in libpng-1.5.4 */
+#  define PNG_WARNING_PARAMETER_SIZE 32
+#  define PNG_WARNING_PARAMETER_COUNT 8
+
+/* An l-value of this type has to be passed to the APIs below to cache the
+ * values of the parameters to a formatted warning message.
+ */
+typedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][
+   PNG_WARNING_PARAMETER_SIZE];
+
+PNG_EXTERN void png_warning_parameter(png_warning_parameters p, int number,
+    png_const_charp string);
+    /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,
+     * including the trailing '\0'.
+     */
+PNG_EXTERN void png_warning_parameter_unsigned(png_warning_parameters p,
+    int number, int format, png_alloc_size_t value);
+    /* Use png_alloc_size_t because it is an unsigned type as big as any we
+     * need to output.  Use the following for a signed value.
+     */
+PNG_EXTERN void png_warning_parameter_signed(png_warning_parameters p,
+    int number, int format, png_int_32 value);
+
+PNG_EXTERN void png_formatted_warning(png_structp png_ptr,
+    png_warning_parameters p, png_const_charp message);
+    /* 'message' follows the X/Open approach of using @1, @2 to insert
+     * parameters previously supplied using the above functions.  Errors in
+     * specifying the paramters will simple result in garbage substitutions.
+     */
+#endif
+
 /* ASCII to FP interfaces, currently only implemented if sCAL
  * support is required.
  */
@@ -1148,8 +1504,18 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
 #define PNG_FP_SAW_DOT   16  /* Saw a dot in current state */
 #define PNG_FP_SAW_E     32  /* Saw an E (or e) in current state */
 #define PNG_FP_SAW_ANY   60  /* Saw any of the above 4 */
+
+/* These three values don't affect the parser.  They are set but not used.
+ */
 #define PNG_FP_WAS_VALID 64  /* Preceding substring is a valid fp number */
-#define PNG_FP_INVALID  128  /* Available for callers as a distinct value */
+#define PNG_FP_NEGATIVE 128  /* A negative number, including "-0" */
+#define PNG_FP_NONZERO  256  /* A non-zero value */
+#define PNG_FP_STICKY   448  /* The above three flags */
+
+/* This is available for the caller to store in 'state' if required.  Do not
+ * call the parser after setting it (the parser sometimes clears it.)
+ */
+#define PNG_FP_INVALID  512  /* Available for callers as a distinct value */
 
 /* Result codes for the parser (boolean - true meants ok, false means
  * not ok yet.)
@@ -1157,6 +1523,20 @@ PNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,
 #define PNG_FP_MAYBE      0  /* The number may be valid in the future */
 #define PNG_FP_OK         1  /* The number is valid */
 
+/* Tests on the sticky non-zero and negative flags.  To pass these checks
+ * the state must also indicate that the whole number is valid - this is
+ * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this
+ * is equivalent to PNG_FP_OK above.)
+ */
+#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)
+   /* NZ_MASK: the string is valid and a non-zero negative value */
+#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)
+   /* Z MASK: the string is valid and a non-zero value. */
+   /* PNG_FP_SAW_DIGIT: the string is valid. */
+#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)
+#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)
+#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)
 /* The actual parser.  This can be called repeatedly, it updates
  * the index into the string and the state variable (which must
  * be initialzed to 0).  It returns a result code, as above.  There
@@ -1176,7 +1556,10 @@ PNG_EXTERN int png_check_fp_number PNGARG((png_const_charp string,
     png_size_t size, int *statep, png_size_tp whereami));
 
 /* This is the same but it checks a complete string and returns true
- * only if it just contains a floating point number.
+ * only if it just contains a floating point number.  As of 1.5.4 this
+ * function also returns the state at the end of parsing the number if
+ * it was valid (otherwise it returns 0.)  This can be used for testing
+ * for negative or zero values using the sticky flag.
  */
 PNG_EXTERN int png_check_fp_string PNGARG((png_const_charp string,
     png_size_t size));
@@ -1230,13 +1613,13 @@ PNG_EXTERN png_uint_16 png_gamma_16bit_correct PNGARG((unsigned int value,
     png_fixed_point gamma_value));
 PNG_EXTERN png_byte png_gamma_8bit_correct PNGARG((unsigned int value,
     png_fixed_point gamma_value));
+PNG_EXTERN void png_destroy_gamma_table(png_structp png_ptr);
 PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,
     int bit_depth));
 #endif
 
 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
 
-
 #include "pngdebug.h"
 
 #ifdef __cplusplus
index aa84001c4523559fcf4857ab26eb2fdafdb1e187..0643754dad00f7206f78e7c92ec2b622d56396c2 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * Last changed in libpng 1.5.2 [March 31, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -47,12 +47,10 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
 
 #ifdef PNG_SETJMP_SUPPORTED
 #ifdef USE_FAR_KEYWORD
-   jmp_buf png_jmpbuf;
+   jmp_buf tmp_jmpbuf;
 #endif
 #endif
 
-   int i;
-
    png_debug(1, "in png_create_read_struct");
 
 #ifdef PNG_USER_MEM_SUPPORTED
@@ -82,16 +80,17 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
 
 #ifdef PNG_SETJMP_SUPPORTED
 /* Applications that neglect to set up their own setjmp() and then
-   encounter a png_error() will longjmp here.  Since the jmpbuf is
-   then meaningless we abort instead of returning. */
+ * encounter a png_error() will longjmp here.  Since the jmpbuf is
+ * then meaningless we abort instead of returning.
+ */
 #ifdef USE_FAR_KEYWORD
-   if (setjmp(png_jmpbuf))
+   if (setjmp(tmp_jmpbuf))
 #else
    if (setjmp(png_jmpbuf(png_ptr))) /* Sets longjmp to match setjmp */
 #endif
       PNG_ABORT();
 #ifdef USE_FAR_KEYWORD
-   png_memcpy(png_jmpbuf(png_ptr), png_jmpbuf, png_sizeof(jmp_buf));
+   png_memcpy(png_jmpbuf(png_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));
 #endif
 #endif /* PNG_SETJMP_SUPPORTED */
 
@@ -101,54 +100,9 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
 
    png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
 
-   if (user_png_ver)
-   {
-      i = 0;
-
-      do
-      {
-         if (user_png_ver[i] != png_libpng_ver[i])
-            png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
-      } while (png_libpng_ver[i++]);
-   }
-
-   else
-      png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
-
-
-   if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
-   {
-     /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
-      * we must recompile any applications that use any older library version.
-      * For versions after libpng 1.0, we will be compatible, so we need
-      * only check the first digit.
-      */
-      if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
-          (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
-          (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
-      {
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-         char msg[80];
-         if (user_png_ver)
-         {
-            png_snprintf2(msg, 80,
-                "Application built with libpng-%.20s"
-                " but running with %.20s",
-                user_png_ver,
-                png_libpng_ver);
-            png_warning(png_ptr, msg);
-         }
-#else
-         png_warning(png_ptr,
-             "Incompatible libpng version in application and library");
-#endif
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-         png_ptr->flags = 0;
-#endif
-
-         png_cleanup_needed = 1;
-      }
-   }
+   /* Call the general version checker (shared with read and write code): */
+   if (!png_user_version_check(png_ptr, user_png_ver))
+      png_cleanup_needed = 1;
 
    if (!png_cleanup_needed)
    {
@@ -237,89 +191,35 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
 
    for (;;)
    {
-      PNG_IHDR;
-      PNG_IDAT;
-      PNG_IEND;
-      PNG_PLTE;
-#ifdef PNG_READ_bKGD_SUPPORTED
-      PNG_bKGD;
-#endif
-#ifdef PNG_READ_cHRM_SUPPORTED
-      PNG_cHRM;
-#endif
-#ifdef PNG_READ_gAMA_SUPPORTED
-      PNG_gAMA;
-#endif
-#ifdef PNG_READ_hIST_SUPPORTED
-      PNG_hIST;
-#endif
-#ifdef PNG_READ_iCCP_SUPPORTED
-      PNG_iCCP;
-#endif
-#ifdef PNG_READ_iTXt_SUPPORTED
-      PNG_iTXt;
-#endif
-#ifdef PNG_READ_oFFs_SUPPORTED
-      PNG_oFFs;
-#endif
-#ifdef PNG_READ_pCAL_SUPPORTED
-      PNG_pCAL;
-#endif
-#ifdef PNG_READ_pHYs_SUPPORTED
-      PNG_pHYs;
-#endif
-#ifdef PNG_READ_sBIT_SUPPORTED
-      PNG_sBIT;
-#endif
-#ifdef PNG_READ_sCAL_SUPPORTED
-      PNG_sCAL;
-#endif
-#ifdef PNG_READ_sPLT_SUPPORTED
-      PNG_sPLT;
-#endif
-#ifdef PNG_READ_sRGB_SUPPORTED
-      PNG_sRGB;
-#endif
-#ifdef PNG_READ_tEXt_SUPPORTED
-      PNG_tEXt;
-#endif
-#ifdef PNG_READ_tIME_SUPPORTED
-      PNG_tIME;
-#endif
-#ifdef PNG_READ_tRNS_SUPPORTED
-      PNG_tRNS;
-#endif
-#ifdef PNG_READ_zTXt_SUPPORTED
-      PNG_zTXt;
-#endif
       png_uint_32 length = png_read_chunk_header(png_ptr);
-      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
+      png_uint_32 chunk_name = png_ptr->chunk_name;
 
       /* This should be a binary subdivision search or a hash for
        * matching the chunk name rather than a linear search.
        */
-      if (!png_memcmp(chunk_name, png_IDAT, 4))
+      if (chunk_name == png_IDAT)
          if (png_ptr->mode & PNG_AFTER_IDAT)
             png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
 
-      if (!png_memcmp(chunk_name, png_IHDR, 4))
+      if (chunk_name == png_IHDR)
          png_handle_IHDR(png_ptr, info_ptr, length);
 
-      else if (!png_memcmp(chunk_name, png_IEND, 4))
+      else if (chunk_name == png_IEND)
          png_handle_IEND(png_ptr, info_ptr, length);
 
 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-      else if (png_handle_as_unknown(png_ptr, chunk_name))
+      else if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
+         PNG_HANDLE_CHUNK_AS_DEFAULT)
       {
-         if (!png_memcmp(chunk_name, png_IDAT, 4))
+         if (chunk_name == png_IDAT)
             png_ptr->mode |= PNG_HAVE_IDAT;
 
          png_handle_unknown(png_ptr, info_ptr, length);
 
-         if (!png_memcmp(chunk_name, png_PLTE, 4))
+         if (chunk_name == png_PLTE)
             png_ptr->mode |= PNG_HAVE_PLTE;
 
-         else if (!png_memcmp(chunk_name, png_IDAT, 4))
+         else if (chunk_name == png_IDAT)
          {
             if (!(png_ptr->mode & PNG_HAVE_IHDR))
                png_error(png_ptr, "Missing IHDR before IDAT");
@@ -332,10 +232,10 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
          }
       }
 #endif
-      else if (!png_memcmp(chunk_name, png_PLTE, 4))
+      else if (chunk_name == png_PLTE)
          png_handle_PLTE(png_ptr, info_ptr, length);
 
-      else if (!png_memcmp(chunk_name, png_IDAT, 4))
+      else if (chunk_name == png_IDAT)
       {
          if (!(png_ptr->mode & PNG_HAVE_IHDR))
             png_error(png_ptr, "Missing IHDR before IDAT");
@@ -350,87 +250,87 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
       }
 
 #ifdef PNG_READ_bKGD_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_bKGD, 4))
+      else if (chunk_name == png_bKGD)
          png_handle_bKGD(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_cHRM_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_cHRM, 4))
+      else if (chunk_name == png_cHRM)
          png_handle_cHRM(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_gAMA_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_gAMA, 4))
+      else if (chunk_name == png_gAMA)
          png_handle_gAMA(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_hIST_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_hIST, 4))
+      else if (chunk_name == png_hIST)
          png_handle_hIST(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_oFFs_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_oFFs, 4))
+      else if (chunk_name == png_oFFs)
          png_handle_oFFs(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_pCAL_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_pCAL, 4))
+      else if (chunk_name == png_pCAL)
          png_handle_pCAL(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sCAL_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sCAL, 4))
+      else if (chunk_name == png_sCAL)
          png_handle_sCAL(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_pHYs_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_pHYs, 4))
+      else if (chunk_name == png_pHYs)
          png_handle_pHYs(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sBIT_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sBIT, 4))
+      else if (chunk_name == png_sBIT)
          png_handle_sBIT(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sRGB_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sRGB, 4))
+      else if (chunk_name == png_sRGB)
          png_handle_sRGB(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_iCCP_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_iCCP, 4))
+      else if (chunk_name == png_iCCP)
          png_handle_iCCP(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sPLT_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sPLT, 4))
+      else if (chunk_name == png_sPLT)
          png_handle_sPLT(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_tEXt_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_tEXt, 4))
+      else if (chunk_name == png_tEXt)
          png_handle_tEXt(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_tIME_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_tIME, 4))
+      else if (chunk_name == png_tIME)
          png_handle_tIME(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_tRNS_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_tRNS, 4))
+      else if (chunk_name == png_tRNS)
          png_handle_tRNS(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_zTXt_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_zTXt, 4))
+      else if (chunk_name == png_zTXt)
          png_handle_zTXt(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_iTXt_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_iTXt, 4))
+      else if (chunk_name == png_iTXt)
          png_handle_iTXt(png_ptr, info_ptr, length);
 #endif
 
@@ -449,15 +349,13 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
    if (png_ptr == NULL)
       return;
 
-   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
-      png_read_start_row(png_ptr);
-
-   else
-      png_warning(png_ptr,
-          "Ignoring extra png_read_update_info() call;"
-          " row buffer not reallocated");
+   png_read_start_row(png_ptr);
 
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
    png_read_transform_info(png_ptr, info_ptr);
+#else
+   PNG_UNUSED(info_ptr)
+#endif
 }
 
 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
@@ -471,15 +369,8 @@ png_start_read_image(png_structp png_ptr)
 {
    png_debug(1, "in png_start_read_image");
 
-   if (png_ptr == NULL)
-      return;
-
-   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
-      png_read_start_row(png_ptr);
-   else
-      png_warning(png_ptr,
-          "Ignoring extra png_start_read_image() call;"
-          " row buffer not reallocated");
+   if (png_ptr != NULL)
+     png_read_start_row(png_ptr);
 }
 #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
 
@@ -487,23 +378,30 @@ png_start_read_image(png_structp png_ptr)
 void PNGAPI
 png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
 {
-   PNG_IDAT;
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-   PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
-       0xff};
-   PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
-#endif
    int ret;
 
+   png_row_info row_info;
+
    if (png_ptr == NULL)
       return;
 
    png_debug2(1, "in png_read_row (row %lu, pass %d)",
        (unsigned long)png_ptr->row_number, png_ptr->pass);
 
+   /* png_read_start_row sets the information (in particular iwidth) for this
+    * interlace pass.
+    */
    if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
       png_read_start_row(png_ptr);
 
+   /* 1.5.6: row_info moved out of png_struct to a local here. */
+   row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */
+   row_info.color_type = png_ptr->color_type;
+   row_info.bit_depth = png_ptr->bit_depth;
+   row_info.channels = png_ptr->channels;
+   row_info.pixel_depth = png_ptr->pixel_depth;
+   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
+
    if (png_ptr->row_number == 0 && png_ptr->pass == 0)
    {
    /* Check for transforms that have been set but were defined out */
@@ -545,7 +443,12 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
    }
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
-   /* If interlaced and we do not need a new row, combine row and return */
+   /* If interlaced and we do not need a new row, combine row and return.
+    * Notice that the pixels we have from previous rows have been transformed
+    * already; we can only combine like with like (transformed or
+    * untransformed) and, because of the libpng API for interlaced images, this
+    * means we must transform before de-interlacing.
+    */
    if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
    {
       switch (png_ptr->pass)
@@ -554,8 +457,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
             if (png_ptr->row_number & 0x07)
             {
                if (dsp_row != NULL)
-                  png_combine_row(png_ptr, dsp_row,
-                     png_pass_dsp_mask[png_ptr->pass]);
+                  png_combine_row(png_ptr, dsp_row, 1/*display*/);
                png_read_finish_row(png_ptr);
                return;
             }
@@ -565,8 +467,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
             if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
             {
                if (dsp_row != NULL)
-                  png_combine_row(png_ptr, dsp_row,
-                      png_pass_dsp_mask[png_ptr->pass]);
+                  png_combine_row(png_ptr, dsp_row, 1/*display*/);
 
                png_read_finish_row(png_ptr);
                return;
@@ -577,8 +478,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
             if ((png_ptr->row_number & 0x07) != 4)
             {
                if (dsp_row != NULL && (png_ptr->row_number & 4))
-                  png_combine_row(png_ptr, dsp_row,
-                      png_pass_dsp_mask[png_ptr->pass]);
+                  png_combine_row(png_ptr, dsp_row, 1/*display*/);
 
                png_read_finish_row(png_ptr);
                return;
@@ -589,8 +489,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
             if ((png_ptr->row_number & 3) || png_ptr->width < 3)
             {
                if (dsp_row != NULL)
-                  png_combine_row(png_ptr, dsp_row,
-                      png_pass_dsp_mask[png_ptr->pass]);
+                  png_combine_row(png_ptr, dsp_row, 1/*display*/);
 
                png_read_finish_row(png_ptr);
                return;
@@ -601,8 +500,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
             if ((png_ptr->row_number & 3) != 2)
             {
                if (dsp_row != NULL && (png_ptr->row_number & 2))
-                  png_combine_row(png_ptr, dsp_row,
-                      png_pass_dsp_mask[png_ptr->pass]);
+                  png_combine_row(png_ptr, dsp_row, 1/*display*/);
 
                png_read_finish_row(png_ptr);
                return;
@@ -612,8 +510,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
             if ((png_ptr->row_number & 1) || png_ptr->width < 2)
             {
                if (dsp_row != NULL)
-                  png_combine_row(png_ptr, dsp_row,
-                      png_pass_dsp_mask[png_ptr->pass]);
+                  png_combine_row(png_ptr, dsp_row, 1/*display*/);
 
                png_read_finish_row(png_ptr);
                return;
@@ -649,7 +546,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
             png_crc_finish(png_ptr, 0);
 
             png_ptr->idat_size = png_read_chunk_header(png_ptr);
-            if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+            if (png_ptr->chunk_name != png_IDAT)
                png_error(png_ptr, "Not enough image data");
          }
          png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
@@ -679,33 +576,47 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
 
    } while (png_ptr->zstream.avail_out);
 
-   png_ptr->row_info.color_type = png_ptr->color_type;
-   png_ptr->row_info.width = png_ptr->iwidth;
-   png_ptr->row_info.channels = png_ptr->channels;
-   png_ptr->row_info.bit_depth = png_ptr->bit_depth;
-   png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
-   png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
-       png_ptr->row_info.width);
-
-   if (png_ptr->row_buf[0])
-   png_read_filter_row(png_ptr, &(png_ptr->row_info),
-       png_ptr->row_buf + 1, png_ptr->prev_row + 1,
-       (int)(png_ptr->row_buf[0]));
+   if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
+   {
+      if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)
+         png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,
+            png_ptr->prev_row + 1, png_ptr->row_buf[0]);
+      else
+         png_error(png_ptr, "bad adaptive filter value");
+   }
 
-   png_memcpy(png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1);
+   /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before
+    * 1.5.6, while the buffer really is this big in current versions of libpng
+    * it may not be in the future, so this was changed just to copy the
+    * interlaced count:
+    */
+   png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
    if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
        (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
    {
       /* Intrapixel differencing */
-      png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1);
    }
 #endif
 
 
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
    if (png_ptr->transformations)
-      png_do_read_transformations(png_ptr);
+      png_do_read_transformations(png_ptr, &row_info);
+#endif
+
+   /* The transformed pixel depth should match the depth now in row_info. */
+   if (png_ptr->transformed_pixel_depth == 0)
+   {
+      png_ptr->transformed_pixel_depth = row_info.pixel_depth;
+      if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)
+         png_error(png_ptr, "sequential row overflow");
+   }
+
+   else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)
+      png_error(png_ptr, "internal sequential row size calculation error");
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
    /* Blow up interlaced rows to full size */
@@ -713,27 +624,24 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
       (png_ptr->transformations & PNG_INTERLACE))
    {
       if (png_ptr->pass < 6)
-         /* Old interface (pre-1.0.9):
-          * png_do_read_interlace(&(png_ptr->row_info),
-          *    png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
-          */
-         png_do_read_interlace(png_ptr);
+         png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
+            png_ptr->transformations);
 
       if (dsp_row != NULL)
-         png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]);
+         png_combine_row(png_ptr, dsp_row, 1/*display*/);
 
       if (row != NULL)
-         png_combine_row(png_ptr, row, png_pass_mask[png_ptr->pass]);
+         png_combine_row(png_ptr, row, 0/*row*/);
    }
 
    else
 #endif
    {
       if (row != NULL)
-         png_combine_row(png_ptr, row, 0xff);
+         png_combine_row(png_ptr, row, -1/*ignored*/);
 
       if (dsp_row != NULL)
-         png_combine_row(png_ptr, dsp_row, 0xff);
+         png_combine_row(png_ptr, dsp_row, -1/*ignored*/);
    }
    png_read_finish_row(png_ptr);
 
@@ -899,85 +807,31 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
 
    do
    {
-      PNG_IHDR;
-      PNG_IDAT;
-      PNG_IEND;
-      PNG_PLTE;
-#ifdef PNG_READ_bKGD_SUPPORTED
-      PNG_bKGD;
-#endif
-#ifdef PNG_READ_cHRM_SUPPORTED
-      PNG_cHRM;
-#endif
-#ifdef PNG_READ_gAMA_SUPPORTED
-      PNG_gAMA;
-#endif
-#ifdef PNG_READ_hIST_SUPPORTED
-      PNG_hIST;
-#endif
-#ifdef PNG_READ_iCCP_SUPPORTED
-      PNG_iCCP;
-#endif
-#ifdef PNG_READ_iTXt_SUPPORTED
-      PNG_iTXt;
-#endif
-#ifdef PNG_READ_oFFs_SUPPORTED
-      PNG_oFFs;
-#endif
-#ifdef PNG_READ_pCAL_SUPPORTED
-      PNG_pCAL;
-#endif
-#ifdef PNG_READ_pHYs_SUPPORTED
-      PNG_pHYs;
-#endif
-#ifdef PNG_READ_sBIT_SUPPORTED
-      PNG_sBIT;
-#endif
-#ifdef PNG_READ_sCAL_SUPPORTED
-      PNG_sCAL;
-#endif
-#ifdef PNG_READ_sPLT_SUPPORTED
-      PNG_sPLT;
-#endif
-#ifdef PNG_READ_sRGB_SUPPORTED
-      PNG_sRGB;
-#endif
-#ifdef PNG_READ_tEXt_SUPPORTED
-      PNG_tEXt;
-#endif
-#ifdef PNG_READ_tIME_SUPPORTED
-      PNG_tIME;
-#endif
-#ifdef PNG_READ_tRNS_SUPPORTED
-      PNG_tRNS;
-#endif
-#ifdef PNG_READ_zTXt_SUPPORTED
-      PNG_zTXt;
-#endif
       png_uint_32 length = png_read_chunk_header(png_ptr);
-      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
+      png_uint_32 chunk_name = png_ptr->chunk_name;
 
-      if (!png_memcmp(chunk_name, png_IHDR, 4))
+      if (chunk_name == png_IHDR)
          png_handle_IHDR(png_ptr, info_ptr, length);
 
-      else if (!png_memcmp(chunk_name, png_IEND, 4))
+      else if (chunk_name == png_IEND)
          png_handle_IEND(png_ptr, info_ptr, length);
 
 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-      else if (png_handle_as_unknown(png_ptr, chunk_name))
+      else if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
+         PNG_HANDLE_CHUNK_AS_DEFAULT)
       {
-         if (!png_memcmp(chunk_name, png_IDAT, 4))
+         if (chunk_name == png_IDAT)
          {
             if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
                png_benign_error(png_ptr, "Too many IDATs found");
          }
          png_handle_unknown(png_ptr, info_ptr, length);
-         if (!png_memcmp(chunk_name, png_PLTE, 4))
+         if (chunk_name == png_PLTE)
             png_ptr->mode |= PNG_HAVE_PLTE;
       }
 #endif
 
-      else if (!png_memcmp(chunk_name, png_IDAT, 4))
+      else if (chunk_name == png_IDAT)
       {
          /* Zero length IDATs are legal after the last IDAT has been
           * read, but not after other chunks have been read.
@@ -987,91 +841,91 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
 
          png_crc_finish(png_ptr, length);
       }
-      else if (!png_memcmp(chunk_name, png_PLTE, 4))
+      else if (chunk_name == png_PLTE)
          png_handle_PLTE(png_ptr, info_ptr, length);
 
 #ifdef PNG_READ_bKGD_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_bKGD, 4))
+      else if (chunk_name == png_bKGD)
          png_handle_bKGD(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_cHRM_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_cHRM, 4))
+      else if (chunk_name == png_cHRM)
          png_handle_cHRM(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_gAMA_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_gAMA, 4))
+      else if (chunk_name == png_gAMA)
          png_handle_gAMA(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_hIST_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_hIST, 4))
+      else if (chunk_name == png_hIST)
          png_handle_hIST(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_oFFs_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_oFFs, 4))
+      else if (chunk_name == png_oFFs)
          png_handle_oFFs(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_pCAL_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_pCAL, 4))
+      else if (chunk_name == png_pCAL)
          png_handle_pCAL(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sCAL_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sCAL, 4))
+      else if (chunk_name == png_sCAL)
          png_handle_sCAL(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_pHYs_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_pHYs, 4))
+      else if (chunk_name == png_pHYs)
          png_handle_pHYs(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sBIT_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sBIT, 4))
+      else if (chunk_name == png_sBIT)
          png_handle_sBIT(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sRGB_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sRGB, 4))
+      else if (chunk_name == png_sRGB)
          png_handle_sRGB(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_iCCP_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_iCCP, 4))
+      else if (chunk_name == png_iCCP)
          png_handle_iCCP(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_sPLT_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_sPLT, 4))
+      else if (chunk_name == png_sPLT)
          png_handle_sPLT(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_tEXt_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_tEXt, 4))
+      else if (chunk_name == png_tEXt)
          png_handle_tEXt(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_tIME_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_tIME, 4))
+      else if (chunk_name == png_tIME)
          png_handle_tIME(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_tRNS_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_tRNS, 4))
+      else if (chunk_name == png_tRNS)
          png_handle_tRNS(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_zTXt_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_zTXt, 4))
+      else if (chunk_name == png_zTXt)
          png_handle_zTXt(png_ptr, info_ptr, length);
 #endif
 
 #ifdef PNG_READ_iTXt_SUPPORTED
-      else if (!png_memcmp(chunk_name, png_iTXt, 4))
+      else if (chunk_name == png_iTXt)
          png_handle_iTXt(png_ptr, info_ptr, length);
 #endif
 
@@ -1163,7 +1017,9 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
    jmp_buf tmp_jmp;
 #endif
    png_error_ptr error_fn;
+#ifdef PNG_WARNINGS_SUPPORTED
    png_error_ptr warning_fn;
+#endif
    png_voidp error_ptr;
 #ifdef PNG_USER_MEM_SUPPORTED
    png_free_ptr free_fn;
@@ -1177,9 +1033,13 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
    if (end_info_ptr != NULL)
       png_info_destroy(png_ptr, end_info_ptr);
 
+#ifdef PNG_READ_GAMMA_SUPPORTED
+   png_destroy_gamma_table(png_ptr);
+#endif
+
    png_free(png_ptr, png_ptr->zbuf);
    png_free(png_ptr, png_ptr->big_row_buf);
-   png_free(png_ptr, png_ptr->prev_row);
+   png_free(png_ptr, png_ptr->big_prev_row);
    png_free(png_ptr, png_ptr->chunkdata);
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
@@ -1187,15 +1047,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
    png_free(png_ptr, png_ptr->quantize_index);
 #endif
 
-#ifdef PNG_READ_GAMMA_SUPPORTED
-   png_free(png_ptr, png_ptr->gamma_table);
-#endif
-
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-   png_free(png_ptr, png_ptr->gamma_from_1);
-   png_free(png_ptr, png_ptr->gamma_to_1);
-#endif
-
    if (png_ptr->free_me & PNG_FREE_PLTE)
       png_zfree(png_ptr, png_ptr->palette);
    png_ptr->free_me &= ~PNG_FREE_PLTE;
@@ -1213,46 +1064,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
    png_ptr->free_me &= ~PNG_FREE_HIST;
 #endif
 
-#ifdef PNG_READ_GAMMA_SUPPORTED
-   if (png_ptr->gamma_16_table != NULL)
-   {
-      int i;
-      int istop = (1 << (8 - png_ptr->gamma_shift));
-      for (i = 0; i < istop; i++)
-      {
-         png_free(png_ptr, png_ptr->gamma_16_table[i]);
-      }
-   png_free(png_ptr, png_ptr->gamma_16_table);
-   }
-
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-   if (png_ptr->gamma_16_from_1 != NULL)
-   {
-      int i;
-      int istop = (1 << (8 - png_ptr->gamma_shift));
-      for (i = 0; i < istop; i++)
-      {
-         png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
-      }
-   png_free(png_ptr, png_ptr->gamma_16_from_1);
-   }
-   if (png_ptr->gamma_16_to_1 != NULL)
-   {
-      int i;
-      int istop = (1 << (8 - png_ptr->gamma_shift));
-      for (i = 0; i < istop; i++)
-      {
-         png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
-      }
-   png_free(png_ptr, png_ptr->gamma_16_to_1);
-   }
-#endif
-#endif
-
-#ifdef PNG_TIME_RFC1123_SUPPORTED
-   png_free(png_ptr, png_ptr->time_buffer);
-#endif
-
    inflateEnd(&png_ptr->zstream);
 
 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
@@ -1269,11 +1080,13 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
     * being used again.
     */
 #ifdef PNG_SETJMP_SUPPORTED
-   png_memcpy(tmp_jmp, png_ptr->png_jmpbuf, png_sizeof(jmp_buf));
+   png_memcpy(tmp_jmp, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
 #endif
 
    error_fn = png_ptr->error_fn;
+#ifdef PNG_WARNINGS_SUPPORTED
    warning_fn = png_ptr->warning_fn;
+#endif
    error_ptr = png_ptr->error_ptr;
 #ifdef PNG_USER_MEM_SUPPORTED
    free_fn = png_ptr->free_fn;
@@ -1282,14 +1095,16 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
    png_memset(png_ptr, 0, png_sizeof(png_struct));
 
    png_ptr->error_fn = error_fn;
+#ifdef PNG_WARNINGS_SUPPORTED
    png_ptr->warning_fn = warning_fn;
+#endif
    png_ptr->error_ptr = error_ptr;
 #ifdef PNG_USER_MEM_SUPPORTED
    png_ptr->free_fn = free_fn;
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
-   png_memcpy(png_ptr->png_jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
+   png_memcpy(png_ptr->longjmp_buffer, tmp_jmp, png_sizeof(jmp_buf));
 #endif
 
 }
@@ -1325,8 +1140,22 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
 
    /* -------------- image transformations start here ------------------- */
 
-#ifdef PNG_READ_16_TO_8_SUPPORTED
-   /* Tell libpng to strip 16 bit/color files down to 8 bits per color.
+#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+   /* Tell libpng to strip 16-bit/color files down to 8 bits per color.
+    */
+   if (transforms & PNG_TRANSFORM_SCALE_16)
+   {
+     /* Added at libpng-1.5.4. "strip_16" produces the same result that it
+      * did in earlier versions, while "scale_16" is now more accurate.
+      */
+      png_set_scale_16(png_ptr);
+   }
+#endif
+
+#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
+   /* If both SCALE and STRIP are required pngrtran will effectively cancel the
+    * latter by doing SCALE first.  This is ok and allows apps not to check for
+    * which is supported to get the right answer.
     */
    if (transforms & PNG_TRANSFORM_STRIP_16)
       png_set_strip_16(png_ptr);
@@ -1407,7 +1236,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
 #endif
 
 #ifdef PNG_READ_SWAP_SUPPORTED
-   /* Swap bytes of 16 bit files to least significant byte first */
+   /* Swap bytes of 16-bit files to least significant byte first */
    if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
       png_set_swap(png_ptr);
 #endif
@@ -1426,6 +1255,12 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
       png_set_gray_to_rgb(png_ptr);
 #endif
 
+/* Added at libpng-1.5.4 */
+#ifdef PNG_READ_EXPAND_16_SUPPORTED
+   if (transforms & PNG_TRANSFORM_EXPAND_16)
+      png_set_expand_16(png_ptr);
+#endif
+
    /* We don't handle adding filler bytes */
 
    /* We use png_read_image and rely on that for interlace handling, but we also
index de5871add02319793b487e5f07625283b67e9d9a..1079595f0afd78fcac70debe6a5e22dacd8e4b26 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * Last changed in libpng 1.5.2 [March 31, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -106,12 +106,18 @@ png_set_background_fixed(png_structp png_ptr,
       return;
    }
 
-   png_ptr->transformations |= PNG_BACKGROUND;
+   png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA;
+   png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
+   png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+
    png_memcpy(&(png_ptr->background), background_color,
       png_sizeof(png_color_16));
    png_ptr->background_gamma = background_gamma;
    png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
-   png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
+   if (need_expand)
+      png_ptr->transformations |= PNG_BACKGROUND_EXPAND;
+   else
+      png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
 }
 
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -126,8 +132,25 @@ png_set_background(png_structp png_ptr,
 #  endif  /* FLOATING_POINT */
 #endif /* READ_BACKGROUND */
 
-#ifdef PNG_READ_16_TO_8_SUPPORTED
-/* Strip 16 bit depth files to 8 bit depth */
+/* Scale 16-bit depth files to 8-bit depth.  If both of these are set then the
+ * one that pngrtran does first (scale) happens.  This is necessary to allow the
+ * TRANSFORM and API behavior to be somewhat consistent, and it's simpler.
+ */
+#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+void PNGAPI
+png_set_scale_16(png_structp png_ptr)
+{
+   png_debug(1, "in png_set_scale_16");
+
+   if (png_ptr == NULL)
+      return;
+
+   png_ptr->transformations |= PNG_SCALE_16_TO_8;
+}
+#endif
+
+#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
+/* Chop 16-bit depth files to 8-bit depth */
 void PNGAPI
 png_set_strip_16(png_structp png_ptr)
 {
@@ -137,7 +160,6 @@ png_set_strip_16(png_structp png_ptr)
       return;
 
    png_ptr->transformations |= PNG_16_TO_8;
-   png_ptr->transformations &= ~PNG_EXPAND_16;
 }
 #endif
 
@@ -154,8 +176,190 @@ png_set_strip_alpha(png_structp png_ptr)
 }
 #endif
 
+#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
+static png_fixed_point
+translate_gamma_flags(png_structp png_ptr, png_fixed_point output_gamma,
+   int is_screen)
+{
+   /* Check for flag values.  The main reason for having the old Mac value as a
+    * flag is that it is pretty near impossible to work out what the correct
+    * value is from Apple documentation - a working Mac system is needed to
+    * discover the value!
+    */
+   if (output_gamma == PNG_DEFAULT_sRGB ||
+      output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB)
+   {
+      /* If there is no sRGB support this just sets the gamma to the standard
+       * sRGB value.  (This is a side effect of using this function!)
+       */
+#     ifdef PNG_READ_sRGB_SUPPORTED
+         png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;
+#     endif
+      if (is_screen)
+         output_gamma = PNG_GAMMA_sRGB;
+      else
+         output_gamma = PNG_GAMMA_sRGB_INVERSE;
+   }
+
+   else if (output_gamma == PNG_GAMMA_MAC_18 ||
+      output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18)
+   {
+      if (is_screen)
+         output_gamma = PNG_GAMMA_MAC_OLD;
+      else
+         output_gamma = PNG_GAMMA_MAC_INVERSE;
+   }
+
+   return output_gamma;
+}
+
+#  ifdef PNG_FLOATING_POINT_SUPPORTED
+static png_fixed_point
+convert_gamma_value(png_structp png_ptr, double output_gamma)
+{
+   /* The following silently ignores cases where fixed point (times 100,000)
+    * gamma values are passed to the floating point API.  This is safe and it
+    * means the fixed point constants work just fine with the floating point
+    * API.  The alternative would just lead to undetected errors and spurious
+    * bug reports.  Negative values fail inside the _fixed API unless they
+    * correspond to the flag values.
+    */
+   if (output_gamma > 0 && output_gamma < 128)
+      output_gamma *= PNG_FP_1;
+
+   /* This preserves -1 and -2 exactly: */
+   output_gamma = floor(output_gamma + .5);
+
+   if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN)
+      png_fixed_error(png_ptr, "gamma value");
+
+   return (png_fixed_point)output_gamma;
+}
+#  endif
+#endif /* READ_ALPHA_MODE || READ_GAMMA */
+
+#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+void PNGFAPI
+png_set_alpha_mode_fixed(png_structp png_ptr, int mode,
+   png_fixed_point output_gamma)
+{
+   int compose = 0;
+   png_fixed_point file_gamma;
+
+   png_debug(1, "in png_set_alpha_mode");
+
+   if (png_ptr == NULL)
+      return;
+
+   output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
+
+   /* Validate the value to ensure it is in a reasonable range. The value
+    * is expected to be 1 or greater, but this range test allows for some
+    * viewing correction values.  The intent is to weed out users of this API
+    * who use the inverse of the gamma value accidentally!  Since some of these
+    * values are reasonable this may have to be changed.
+    */
+   if (output_gamma < 70000 || output_gamma > 300000)
+      png_error(png_ptr, "output gamma out of expected range");
+
+   /* The default file gamma is the inverse of the output gamma; the output
+    * gamma may be changed below so get the file value first:
+    */
+   file_gamma = png_reciprocal(output_gamma);
+
+   /* There are really 8 possibilities here, composed of any combination
+    * of:
+    *
+    *    premultiply the color channels
+    *    do not encode non-opaque pixels
+    *    encode the alpha as well as the color channels
+    *
+    * The differences disappear if the input/output ('screen') gamma is 1.0,
+    * because then the encoding is a no-op and there is only the choice of
+    * premultiplying the color channels or not.
+    *
+    * png_set_alpha_mode and png_set_background interact because both use
+    * png_compose to do the work.  Calling both is only useful when
+    * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along
+    * with a default gamma value.  Otherwise PNG_COMPOSE must not be set.
+    */
+   switch (mode)
+   {
+      case PNG_ALPHA_PNG:        /* default: png standard */
+         /* No compose, but it may be set by png_set_background! */
+         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
+         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+         break;
+
+      case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */
+         compose = 1;
+         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
+         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+         /* The output is linear: */
+         output_gamma = PNG_FP_1;
+         break;
+
+      case PNG_ALPHA_OPTIMIZED:  /* associated, non-opaque pixels linear */
+         compose = 1;
+         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
+         png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA;
+         /* output_gamma records the encoding of opaque pixels! */
+         break;
+
+      case PNG_ALPHA_BROKEN:     /* associated, non-linear, alpha encoded */
+         compose = 1;
+         png_ptr->transformations |= PNG_ENCODE_ALPHA;
+         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+         break;
+
+      default:
+         png_error(png_ptr, "invalid alpha mode");
+   }
+
+   /* Only set the default gamma if the file gamma has not been set (this has
+    * the side effect that the gamma in a second call to png_set_alpha_mode will
+    * be ignored.)
+    */
+   if (png_ptr->gamma == 0)
+      png_ptr->gamma = file_gamma;
+
+   /* But always set the output gamma: */
+   png_ptr->screen_gamma = output_gamma;
+
+   /* Finally, if pre-multiplying, set the background fields to achieve the
+    * desired result.
+    */
+   if (compose)
+   {
+      /* And obtain alpha pre-multiplication by composing on black: */
+      png_memset(&png_ptr->background, 0, sizeof png_ptr->background);
+      png_ptr->background_gamma = png_ptr->gamma; /* just in case */
+      png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
+      png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
+
+      if (png_ptr->transformations & PNG_COMPOSE)
+         png_error(png_ptr,
+            "conflicting calls to set alpha mode and background");
+
+      png_ptr->transformations |= PNG_COMPOSE;
+   }
+
+   /* New API, make sure apps call the correct initializers: */
+   png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
+}
+
+#  ifdef PNG_FLOATING_POINT_SUPPORTED
+void PNGAPI
+png_set_alpha_mode(png_structp png_ptr, int mode, double output_gamma)
+{
+   png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,
+      output_gamma));
+}
+#  endif
+#endif
+
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
-/* Dither file to 8 bit.  Supply a palette, the current number
+/* Dither file to 8-bit.  Supply a palette, the current number
  * of elements in the palette, the maximum number of elements
  * allowed, and a histogram if possible.  If the current number
  * of colors is greater then the maximum number, the palette will be
@@ -561,30 +765,6 @@ png_set_quantize(png_structp png_ptr, png_colorp palette,
 #endif /* PNG_READ_QUANTIZE_SUPPORTED */
 
 #ifdef PNG_READ_GAMMA_SUPPORTED
-/* Transform the image from the file_gamma to the screen_gamma.  We
- * only do transformations on images where the file_gamma and screen_gamma
- * are not close reciprocals, otherwise it slows things down slightly, and
- * also needlessly introduces small errors.
- *
- * We will turn off gamma transformation later if no semitransparent entries
- * are present in the tRNS array for palette images.  We can't do it here
- * because we don't necessarily have the tRNS chunk yet.
- */
-static int /* PRIVATE */
-png_gamma_threshold(png_fixed_point scrn_gamma, png_fixed_point file_gamma)
-{
-   /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma
-    * correction as a difference of the overall transform from 1.0
-    *
-    * We want to compare the threshold with s*f - 1, if we get
-    * overflow here it is because of wacky gamma values so we
-    * turn on processing anyway.
-    */
-   png_fixed_point gtest;
-   return !png_muldiv(&gtest, scrn_gamma, file_gamma, PNG_FP_1) ||
-       png_gamma_significant(gtest);
-}
-
 void PNGFAPI
 png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,
    png_fixed_point file_gamma)
@@ -594,10 +774,32 @@ png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,
    if (png_ptr == NULL)
       return;
 
-   if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
-       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
-       png_gamma_threshold(scrn_gamma, file_gamma))
-      png_ptr->transformations |= PNG_GAMMA;
+   /* New in libpng-1.5.4 - reserve particular negative values as flags. */
+   scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
+   file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
+
+#if PNG_LIBPNG_VER >= 10600
+   /* Checking the gamma values for being >0 was added in 1.5.4 along with the
+    * premultiplied alpha support; this actually hides an undocumented feature
+    * of the previous implementation which allowed gamma processing to be
+    * disabled in background handling.  There is no evidence (so far) that this
+    * was being used; however, png_set_background itself accepted and must still
+    * accept '0' for the gamma value it takes, because it isn't always used.
+    *
+    * Since this is an API change (albeit a very minor one that removes an
+    * undocumented API feature) it will not be made until libpng-1.6.0.
+    */
+   if (file_gamma <= 0)
+      png_error(png_ptr, "invalid file gamma in png_set_gamma");
+
+   if (scrn_gamma <= 0)
+      png_error(png_ptr, "invalid screen gamma in png_set_gamma");
+#endif
+
+   /* Set the gamma values unconditionally - this overrides the value in the PNG
+    * file if a gAMA chunk was present.  png_set_alpha_mode provides a
+    * different, easier, way to default the file gamma.
+    */
    png_ptr->gamma = file_gamma;
    png_ptr->screen_gamma = scrn_gamma;
 }
@@ -606,9 +808,8 @@ png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,
 void PNGAPI
 png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
 {
-   png_set_gamma_fixed(png_ptr,
-      png_fixed(png_ptr, scrn_gamma, "png_set_gamma screen gamma"),
-      png_fixed(png_ptr, file_gamma, "png_set_gamma file gamma"));
+   png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
+      convert_gamma_value(png_ptr, file_gamma));
 }
 #  endif /* FLOATING_POINT_SUPPORTED */
 #endif /* READ_GAMMA */
@@ -688,7 +889,7 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
 #endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
 
 #ifdef PNG_READ_EXPAND_16_SUPPORTED
-/* Expand to 16 bit channels, expand the tRNS chunk too (because otherwise
+/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise
  * it may not work correctly.)
  */
 void PNGAPI
@@ -700,9 +901,10 @@ png_set_expand_16(png_structp png_ptr)
       return;
 
    png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
-   png_ptr->transformations &= ~PNG_16_TO_8;
-
    png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
+
+   /* New API, make sure apps call the correct initializers: */
+   png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;
 }
 #endif
 
@@ -734,15 +936,15 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
 
    switch(error_action)
    {
-      case 1:
+      case PNG_ERROR_ACTION_NONE:
          png_ptr->transformations |= PNG_RGB_TO_GRAY;
          break;
 
-      case 2:
+      case PNG_ERROR_ACTION_WARN:
          png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;
          break;
 
-      case 3:
+      case PNG_ERROR_ACTION_ERROR:
          png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
          break;
 
@@ -762,30 +964,43 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
    }
 #endif
    {
-      png_uint_16 red_int, green_int;
-      if (red < 0 || green < 0)
+      if (red >= 0 && green >= 0 && red + green <= PNG_FP_1)
       {
-         red_int   =  6968; /* .212671 * 32768 + .5 */
-         green_int = 23434; /* .715160 * 32768 + .5 */
-      }
+         png_uint_16 red_int, green_int;
 
-      else if (red + green < 100000L)
-      {
-         red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
-         green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
+         /* NOTE: this calculation does not round, but this behavior is retained
+          * for consistency, the inaccuracy is very small.  The code here always
+          * overwrites the coefficients, regardless of whether they have been
+          * defaulted or set already.
+          */
+         red_int = (png_uint_16)(((png_uint_32)red*32768)/100000);
+         green_int = (png_uint_16)(((png_uint_32)green*32768)/100000);
+
+         png_ptr->rgb_to_gray_red_coeff   = red_int;
+         png_ptr->rgb_to_gray_green_coeff = green_int;
+         png_ptr->rgb_to_gray_coefficients_set = 1;
       }
 
       else
       {
-         png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients");
-         red_int   =  6968;
-         green_int = 23434;
+         if (red >= 0 && green >= 0)
+            png_warning(png_ptr,
+               "ignoring out of range rgb_to_gray coefficients");
+
+         /* Use the defaults, from the cHRM chunk if set, else the historical
+          * values which are close to the sRGB/HDTV/ITU-Rec 709 values.  See
+          * png_do_rgb_to_gray for more discussion of the values.  In this case
+          * the coefficients are not marked as 'set' and are not overwritten if
+          * something has already provided a default.
+          */
+         if (png_ptr->rgb_to_gray_red_coeff == 0 &&
+            png_ptr->rgb_to_gray_green_coeff == 0)
+         {
+            png_ptr->rgb_to_gray_red_coeff   = 6968;
+            png_ptr->rgb_to_gray_green_coeff = 23434;
+            /* png_ptr->rgb_to_gray_blue_coeff  = 2366; */
+         }
       }
-
-      png_ptr->rgb_to_gray_red_coeff   = red_int;
-      png_ptr->rgb_to_gray_green_coeff = green_int;
-      png_ptr->rgb_to_gray_blue_coeff  =
-          (png_uint_16)(32768 - red_int - green_int);
    }
 }
 
@@ -827,167 +1042,513 @@ png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
 }
 #endif
 
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
+#ifdef PNG_READ_GAMMA_SUPPORTED
+/* In the case of gamma transformations only do transformations on images where
+ * the [file] gamma and screen_gamma are not close reciprocals, otherwise it
+ * slows things down slightly, and also needlessly introduces small errors.
+ */
+static int /* PRIVATE */
+png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)
+{
+   /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma
+    * correction as a difference of the overall transform from 1.0
+    *
+    * We want to compare the threshold with s*f - 1, if we get
+    * overflow here it is because of wacky gamma values so we
+    * turn on processing anyway.
+    */
+   png_fixed_point gtest;
+   return !png_muldiv(&gtest, screen_gamma, file_gamma, PNG_FP_1) ||
+       png_gamma_significant(gtest);
+}
+#endif
+
 /* Initialize everything needed for the read.  This includes modifying
  * the palette.
  */
-void /* PRIVATE */
-png_init_read_transformations(png_structp png_ptr)
+
+/*For the moment 'png_init_palette_transformations' and
+ * 'png_init_rgb_transformations' only do some flag canceling optimizations.
+ * The intent is that these two routines should have palette or rgb operations
+ * extracted from 'png_init_read_transformations'.
+ */
+static void /* PRIVATE */
+png_init_palette_transformations(png_structp png_ptr)
 {
-   png_debug(1, "in png_init_read_transformations");
+   /* Called to handle the (input) palette case.  In png_do_read_transformations
+    * the first step is to expand the palette if requested, so this code must
+    * take care to only make changes that are invariant with respect to the
+    * palette expansion, or only do them if there is no expansion.
+    *
+    * STRIP_ALPHA has already been handled in the caller (by setting num_trans
+    * to 0.)
+    */
+   int input_has_alpha = 0;
+   int input_has_transparency = 0;
 
-  {
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
-    defined(PNG_READ_SHIFT_SUPPORTED) || \
-    defined(PNG_READ_GAMMA_SUPPORTED)
-   int color_type = png_ptr->color_type;
-#endif
+   if (png_ptr->num_trans > 0)
+   {
+      int i;
+
+      /* Ignore if all the entries are opaque (unlikely!) */
+      for (i=0; i<png_ptr->num_trans; ++i)
+         if (png_ptr->trans_alpha[i] == 255)
+            continue;
+         else if (png_ptr->trans_alpha[i] == 0)
+            input_has_transparency = 1;
+         else
+            input_has_alpha = 1;
+   }
+
+   /* If no alpha we can optimize. */
+   if (!input_has_alpha)
+   {
+      /* Any alpha means background and associative alpha processing is
+       * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA
+       * and ENCODE_ALPHA are irrelevant.
+       */
+      png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
+      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+
+      if (!input_has_transparency)
+         png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);
+   }
 
 #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
+   /* png_set_background handling - deals with the complexity of whether the
+    * background color is in the file format or the screen format in the case
+    * where an 'expand' will happen.
+    */
 
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
-   /* Detect gray background and attempt to enable optimization
-    * for gray --> RGB case
-    *
-    * Note:  if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
-    * RGB_ALPHA (in which case need_expand is superfluous anyway), the
-    * background color might actually be gray yet not be flagged as such.
-    * This is not a problem for the current code, which uses
-    * PNG_BACKGROUND_IS_GRAY only to decide when to do the
-    * png_do_gray_to_rgb() transformation.
+   /* The following code cannot be entered in the alpha pre-multiplication case
+    * because PNG_BACKGROUND_EXPAND is cancelled below.
     */
    if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
-       !(color_type & PNG_COLOR_MASK_COLOR))
+       (png_ptr->transformations & PNG_EXPAND))
    {
-      png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
-   }
+      {
+         png_ptr->background.red   =
+             png_ptr->palette[png_ptr->background.index].red;
+         png_ptr->background.green =
+             png_ptr->palette[png_ptr->background.index].green;
+         png_ptr->background.blue  =
+             png_ptr->palette[png_ptr->background.index].blue;
+
+#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
+        if (png_ptr->transformations & PNG_INVERT_ALPHA)
+        {
+           if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
+           {
+              /* Invert the alpha channel (in tRNS) unless the pixels are
+               * going to be expanded, in which case leave it for later
+               */
+              int i, istop = png_ptr->num_trans;
 
-   else if ((png_ptr->transformations & PNG_BACKGROUND) &&
-       !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
-       (png_ptr->transformations & PNG_GRAY_TO_RGB) &&
-       png_ptr->background.red == png_ptr->background.green &&
-       png_ptr->background.red == png_ptr->background.blue)
+              for (i=0; i<istop; i++)
+                 png_ptr->trans_alpha[i] = (png_byte)(255 -
+                    png_ptr->trans_alpha[i]);
+           }
+        }
+#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */
+      }
+   } /* background expand and (therefore) no alpha association. */
+#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
+}
+
+static void /* PRIVATE */
+png_init_rgb_transformations(png_structp png_ptr)
+{
+   /* Added to libpng-1.5.4: check the color type to determine whether there
+    * is any alpha or transparency in the image and simply cancel the
+    * background and alpha mode stuff if there isn't.
+    */
+   int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0;
+   int input_has_transparency = png_ptr->num_trans > 0;
+
+   /* If no alpha we can optimize. */
+   if (!input_has_alpha)
    {
-      png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
-      png_ptr->background.gray = png_ptr->background.red;
+      /* Any alpha means background and associative alpha processing is
+       * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA
+       * and ENCODE_ALPHA are irrelevant.
+       */
+#     ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
+         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+#     endif
+
+      if (!input_has_transparency)
+         png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);
    }
-#endif
 
+#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
+   /* png_set_background handling - deals with the complexity of whether the
+    * background color is in the file format or the screen format in the case
+    * where an 'expand' will happen.
+    */
+
+   /* The following code cannot be entered in the alpha pre-multiplication case
+    * because PNG_BACKGROUND_EXPAND is cancelled below.
+    */
    if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
-       (png_ptr->transformations & PNG_EXPAND))
+       (png_ptr->transformations & PNG_EXPAND) &&
+       !(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
+       /* i.e., GRAY or GRAY_ALPHA */
    {
-      if (!(color_type & PNG_COLOR_MASK_COLOR))  /* i.e., GRAY or GRAY_ALPHA */
       {
          /* Expand background and tRNS chunks */
+         int gray = png_ptr->background.gray;
+         int trans_gray = png_ptr->trans_color.gray;
+
          switch (png_ptr->bit_depth)
          {
             case 1:
-               png_ptr->background.gray *= (png_uint_16)0xff;
-               png_ptr->background.red = png_ptr->background.green
-                   =  png_ptr->background.blue = png_ptr->background.gray;
-               if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
-               {
-                 png_ptr->trans_color.gray *= (png_uint_16)0xff;
-                 png_ptr->trans_color.red = png_ptr->trans_color.green
-                     = png_ptr->trans_color.blue = png_ptr->trans_color.gray;
-               }
+               gray *= 0xff;
+               trans_gray *= 0xff;
                break;
 
             case 2:
-               png_ptr->background.gray *= (png_uint_16)0x55;
-               png_ptr->background.red = png_ptr->background.green
-                   = png_ptr->background.blue = png_ptr->background.gray;
-               if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
-               {
-                  png_ptr->trans_color.gray *= (png_uint_16)0x55;
-                  png_ptr->trans_color.red = png_ptr->trans_color.green
-                      = png_ptr->trans_color.blue = png_ptr->trans_color.gray;
-               }
+               gray *= 0x55;
+               trans_gray *= 0x55;
                break;
 
             case 4:
-               png_ptr->background.gray *= (png_uint_16)0x11;
-               png_ptr->background.red = png_ptr->background.green
-                   = png_ptr->background.blue = png_ptr->background.gray;
-               if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
-               {
-                  png_ptr->trans_color.gray *= (png_uint_16)0x11;
-                  png_ptr->trans_color.red = png_ptr->trans_color.green
-                      = png_ptr->trans_color.blue = png_ptr->trans_color.gray;
-               }
+               gray *= 0x11;
+               trans_gray *= 0x11;
                break;
 
             default:
 
             case 8:
+               /* Already 8 bits, fall through */
 
             case 16:
-               png_ptr->background.red = png_ptr->background.green
-                   = png_ptr->background.blue = png_ptr->background.gray;
+               /* Already a full 16 bits */
                break;
          }
+
+         png_ptr->background.red = png_ptr->background.green =
+            png_ptr->background.blue = (png_uint_16)gray;
+
+         if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
+         {
+            png_ptr->trans_color.red = png_ptr->trans_color.green =
+               png_ptr->trans_color.blue = (png_uint_16)trans_gray;
+         }
       }
-      else if (color_type == PNG_COLOR_TYPE_PALETTE)
-      {
-         png_ptr->background.red   =
-             png_ptr->palette[png_ptr->background.index].red;
-         png_ptr->background.green =
-             png_ptr->palette[png_ptr->background.index].green;
-         png_ptr->background.blue  =
-             png_ptr->palette[png_ptr->background.index].blue;
+   } /* background expand and (therefore) no alpha association. */
+#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
+}
 
-#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
-        if (png_ptr->transformations & PNG_INVERT_ALPHA)
-        {
-#ifdef PNG_READ_EXPAND_SUPPORTED
-           if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
-#endif
-           {
-              /* Invert the alpha channel (in tRNS) unless the pixels are
-               * going to be expanded, in which case leave it for later
-               */
-              int i, istop;
-              istop=(int)png_ptr->num_trans;
-              for (i=0; i<istop; i++)
-                 png_ptr->trans_alpha[i] = (png_byte)(255 -
-                    png_ptr->trans_alpha[i]);
-           }
-        }
-#endif
+void /* PRIVATE */
+png_init_read_transformations(png_structp png_ptr)
+{
+   png_debug(1, "in png_init_read_transformations");
+
+   /* This internal function is called from png_read_start_row in pngrutil.c
+    * and it is called before the 'rowbytes' calculation is done, so the code
+    * in here can change or update the transformations flags.
+    *
+    * First do updates that do not depend on the details of the PNG image data
+    * being processed.
+    */
 
+#ifdef PNG_READ_GAMMA_SUPPORTED
+   /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds
+    * png_set_alpha_mode and this is another source for a default file gamma so
+    * the test needs to be performed later - here.  In addition prior to 1.5.4
+    * the tests were repeated for the PALETTE color type here - this is no
+    * longer necessary (and doesn't seem to have been necessary before.)
+    */
+   {
+      /* The following temporary indicates if overall gamma correction is
+       * required.
+       */
+      int gamma_correction = 0;
+
+      if (png_ptr->gamma != 0) /* has been set */
+      {
+         if (png_ptr->screen_gamma != 0) /* screen set too */
+            gamma_correction = png_gamma_threshold(png_ptr->gamma,
+               png_ptr->screen_gamma);
+
+         else
+            /* Assume the output matches the input; a long time default behavior
+             * of libpng, although the standard has nothing to say about this.
+             */
+            png_ptr->screen_gamma = png_reciprocal(png_ptr->gamma);
       }
+
+      else if (png_ptr->screen_gamma != 0)
+         /* The converse - assume the file matches the screen, note that this
+          * perhaps undesireable default can (from 1.5.4) be changed by calling
+          * png_set_alpha_mode (even if the alpha handling mode isn't required
+          * or isn't changed from the default.)
+          */
+         png_ptr->gamma = png_reciprocal(png_ptr->screen_gamma);
+
+      else /* neither are set */
+         /* Just in case the following prevents any processing - file and screen
+          * are both assumed to be linear and there is no way to introduce a
+          * third gamma value other than png_set_background with 'UNIQUE', and,
+          * prior to 1.5.4
+          */
+         png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1;
+
+      /* Now turn the gamma transformation on or off as appropriate.  Notice
+       * that PNG_GAMMA just refers to the file->screen correction.  Alpha
+       * composition may independently cause gamma correction because it needs
+       * linear data (e.g. if the file has a gAMA chunk but the screen gamma
+       * hasn't been specified.)  In any case this flag may get turned off in
+       * the code immediately below if the transform can be handled outside the
+       * row loop.
+       */
+      if (gamma_correction)
+         png_ptr->transformations |= PNG_GAMMA;
+
+      else
+         png_ptr->transformations &= ~PNG_GAMMA;
    }
 #endif
 
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
-   png_ptr->background_1 = png_ptr->background;
+   /* Certain transformations have the effect of preventing other
+    * transformations that happen afterward in png_do_read_transformations,
+    * resolve the interdependencies here.  From the code of
+    * png_do_read_transformations the order is:
+    *
+    *  1) PNG_EXPAND (including PNG_EXPAND_tRNS)
+    *  2) PNG_STRIP_ALPHA (if no compose)
+    *  3) PNG_RGB_TO_GRAY
+    *  4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY
+    *  5) PNG_COMPOSE
+    *  6) PNG_GAMMA
+    *  7) PNG_STRIP_ALPHA (if compose)
+    *  8) PNG_ENCODE_ALPHA
+    *  9) PNG_SCALE_16_TO_8
+    * 10) PNG_16_TO_8
+    * 11) PNG_QUANTIZE (converts to palette)
+    * 12) PNG_EXPAND_16
+    * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY
+    * 14) PNG_INVERT_MONO
+    * 15) PNG_SHIFT
+    * 16) PNG_PACK
+    * 17) PNG_BGR
+    * 18) PNG_PACKSWAP
+    * 19) PNG_FILLER (includes PNG_ADD_ALPHA)
+    * 20) PNG_INVERT_ALPHA
+    * 21) PNG_SWAP_ALPHA
+    * 22) PNG_SWAP_BYTES
+    * 23) PNG_USER_TRANSFORM [must be last]
+    */
+#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
+   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
+      !(png_ptr->transformations & PNG_COMPOSE))
+   {
+      /* Stripping the alpha channel happens immediately after the 'expand'
+       * transformations, before all other transformation, so it cancels out
+       * the alpha handling.  It has the side effect negating the effect of
+       * PNG_EXPAND_tRNS too:
+       */
+      png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA |
+         PNG_EXPAND_tRNS);
+      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+
+      /* Kill the tRNS chunk itself too.  Prior to 1.5.4 this did not happen
+       * so transparency information would remain just so long as it wasn't
+       * expanded.  This produces unexpected API changes if the set of things
+       * that do PNG_EXPAND_tRNS changes (perfectly possible given the
+       * documentation - which says ask for what you want, accept what you
+       * get.)  This makes the behavior consistent from 1.5.4:
+       */
+      png_ptr->num_trans = 0;
+   }
+#endif /* STRIP_ALPHA supported, no COMPOSE */
+
+#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+   /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA
+    * settings will have no effect.
+    */
+   if (!png_gamma_significant(png_ptr->screen_gamma))
+   {
+      png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
+      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
+   }
 #endif
-#ifdef PNG_READ_GAMMA_SUPPORTED
 
-   if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0)
-       && png_gamma_threshold(png_ptr->screen_gamma, png_ptr->gamma))
+#if defined(PNG_READ_EXPAND_SUPPORTED) && \
+   defined(PNG_READ_BACKGROUND_SUPPORTED) && \
+   defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
+   /* Detect gray background and attempt to enable optimization for
+    * gray --> RGB case.
+    *
+    * Note:  if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
+    * RGB_ALPHA (in which case need_expand is superfluous anyway), the
+    * background color might actually be gray yet not be flagged as such.
+    * This is not a problem for the current code, which uses
+    * PNG_BACKGROUND_IS_GRAY only to decide when to do the
+    * png_do_gray_to_rgb() transformation.
+    *
+    * TODO: this code needs to be revised to avoid the complexity and
+    * interdependencies.  The color type of the background should be recorded in
+    * png_set_background, along with the bit depth, then the code has a record
+    * of exactly what color space the background is currently in.
+    */
+   if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
+   {
+      /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if
+       * the file was grayscale the background value is gray.
+       */
+      if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
+         png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
+   }
+
+   else if (png_ptr->transformations & PNG_COMPOSE)
    {
-      int i, k;
-      k=0;
-      for (i=0; i<png_ptr->num_trans; i++)
+      /* PNG_COMPOSE: png_set_background was called with need_expand false,
+       * so the color is in the color space of the output or png_set_alpha_mode
+       * was called and the color is black.  Ignore RGB_TO_GRAY because that
+       * happens before GRAY_TO_RGB.
+       */
+      if (png_ptr->transformations & PNG_GRAY_TO_RGB)
       {
-        if (png_ptr->trans_alpha[i] != 0 && png_ptr->trans_alpha[i] != 0xff)
-           k=1; /* Partial transparency is present */
+         if (png_ptr->background.red == png_ptr->background.green &&
+             png_ptr->background.red == png_ptr->background.blue)
+         {
+            png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
+            png_ptr->background.gray = png_ptr->background.red;
+         }
       }
-      if (k == 0)
-         png_ptr->transformations &= ~PNG_GAMMA;
    }
+#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED (etc) */
+
+   /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
+    * can be performed directly on the palette, and some (such as rgb to gray)
+    * can be optimized inside the palette.  This is particularly true of the
+    * composite (background and alpha) stuff, which can be pretty much all done
+    * in the palette even if the result is expanded to RGB or gray afterward.
+    *
+    * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and
+    * earlier and the palette stuff is actually handled on the first row.  This
+    * leads to the reported bug that the palette returned by png_get_PLTE is not
+    * updated.
+    */
+   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+      png_init_palette_transformations(png_ptr);
 
-   if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
-       png_ptr->gamma != 0)
+   else
+      png_init_rgb_transformations(png_ptr);
+
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
+   defined(PNG_READ_EXPAND_16_SUPPORTED)
+   if ((png_ptr->transformations & PNG_EXPAND_16) &&
+      (png_ptr->transformations & PNG_COMPOSE) &&
+      !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
+      png_ptr->bit_depth != 16)
+   {
+      /* TODO: fix this.  Because the expand_16 operation is after the compose
+       * handling the background color must be 8, not 16, bits deep, but the
+       * application will supply a 16-bit value so reduce it here.
+       *
+       * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at
+       * present, so that case is ok (until do_expand_16 is moved.)
+       *
+       * NOTE: this discards the low 16 bits of the user supplied background
+       * color, but until expand_16 works properly there is no choice!
+       */
+#     define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))
+      CHOP(png_ptr->background.red);
+      CHOP(png_ptr->background.green);
+      CHOP(png_ptr->background.blue);
+      CHOP(png_ptr->background.gray);
+#     undef CHOP
+   }
+#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
+
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
+   (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \
+   defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))
+   if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) &&
+      (png_ptr->transformations & PNG_COMPOSE) &&
+      !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
+      png_ptr->bit_depth == 16)
+   {
+      /* On the other hand, if a 16-bit file is to be reduced to 8-bits per
+       * component this will also happen after PNG_COMPOSE and so the background
+       * color must be pre-expanded here.
+       *
+       * TODO: fix this too.
+       */
+      png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257);
+      png_ptr->background.green =
+         (png_uint_16)(png_ptr->background.green * 257);
+      png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257);
+      png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257);
+   }
+#endif
+
+   /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the
+    * background support (see the comments in scripts/pnglibconf.dfa), this
+    * allows pre-multiplication of the alpha channel to be implemented as
+    * compositing on black.  This is probably sub-optimal and has been done in
+    * 1.5.4 betas simply to enable external critique and testing (i.e. to
+    * implement the new API quickly, without lots of internal changes.)
+    */
+
+#ifdef PNG_READ_GAMMA_SUPPORTED
+#  ifdef PNG_READ_BACKGROUND_SUPPORTED
+      /* Includes ALPHA_MODE */
+      png_ptr->background_1 = png_ptr->background;
+#  endif
+
+   /* This needs to change - in the palette image case a whole set of tables are
+    * built when it would be quicker to just calculate the correct value for
+    * each palette entry directly.  Also, the test is too tricky - why check
+    * PNG_RGB_TO_GRAY if PNG_GAMMA is not set?  The answer seems to be that
+    * PNG_GAMMA is cancelled even if the gamma is known?  The test excludes the
+    * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction
+    * the gamma tables will not be built even if composition is required on a
+    * gamma encoded value.
+    *
+    * In 1.5.4 this is addressed below by an additional check on the individual
+    * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the
+    * tables.
+    */
+   if ((png_ptr->transformations & PNG_GAMMA)
+      || ((png_ptr->transformations & PNG_RGB_TO_GRAY)
+         && (png_gamma_significant(png_ptr->gamma) ||
+            png_gamma_significant(png_ptr->screen_gamma)))
+      || ((png_ptr->transformations & PNG_COMPOSE)
+         && (png_gamma_significant(png_ptr->gamma)
+            || png_gamma_significant(png_ptr->screen_gamma)
+#  ifdef PNG_READ_BACKGROUND_SUPPORTED
+            || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
+               && png_gamma_significant(png_ptr->background_gamma))
+#  endif
+      )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)
+         && png_gamma_significant(png_ptr->screen_gamma))
+      )
    {
       png_build_gamma_table(png_ptr, png_ptr->bit_depth);
 
 #ifdef PNG_READ_BACKGROUND_SUPPORTED
-      if (png_ptr->transformations & PNG_BACKGROUND)
+      if (png_ptr->transformations & PNG_COMPOSE)
       {
-         if (color_type == PNG_COLOR_TYPE_PALETTE)
+         /* Issue a warning about this combination: because RGB_TO_GRAY is
+          * optimized to do the gamma transform if present yet do_background has
+          * to do the same thing if both options are set a
+          * double-gamma-correction happens.  This is true in all versions of
+          * libpng to date.
+          */
+         if (png_ptr->transformations & PNG_RGB_TO_GRAY)
+            png_warning(png_ptr,
+               "libpng does not support gamma+background+rgb_to_gray");
+
+         if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
          {
-            /* Could skip if no transparency */
+            /* We don't get to here unless there is a tRNS chunk with non-opaque
+             * entries - see the checking code at the start of this function.
+             */
             png_color back, back_1;
             png_colorp palette = png_ptr->palette;
             int num_palette = png_ptr->num_palette;
@@ -1032,27 +1593,40 @@ png_init_read_transformations(png_structp png_ptr)
                }
 
                if (png_gamma_significant(gs))
+               {
+                  back.red = png_gamma_8bit_correct(png_ptr->background.red,
+                      gs);
+                  back.green = png_gamma_8bit_correct(png_ptr->background.green,
+                      gs);
+                  back.blue = png_gamma_8bit_correct(png_ptr->background.blue,
+                      gs);
+               }
+
+               else
                {
                   back.red   = (png_byte)png_ptr->background.red;
                   back.green = (png_byte)png_ptr->background.green;
                   back.blue  = (png_byte)png_ptr->background.blue;
                }
 
+               if (png_gamma_significant(g))
+               {
+                  back_1.red = png_gamma_8bit_correct(png_ptr->background.red,
+                     g);
+                  back_1.green = png_gamma_8bit_correct(
+                     png_ptr->background.green, g);
+                  back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue,
+                     g);
+               }
+
                else
                {
-                  back.red = png_gamma_8bit_correct(png_ptr->background.red,
-                      gs);
-                  back.green = png_gamma_8bit_correct(png_ptr->background.green,
-                      gs);
-                  back.blue = png_gamma_8bit_correct(png_ptr->background.blue,
-                      gs);
+                  back_1.red   = (png_byte)png_ptr->background.red;
+                  back_1.green = (png_byte)png_ptr->background.green;
+                  back_1.blue  = (png_byte)png_ptr->background.blue;
                }
-               back_1.red = png_gamma_8bit_correct(png_ptr->background.red, g);
-               back_1.green = png_gamma_8bit_correct(png_ptr->background.green,
-                   g);
-               back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue,
-                   g);
             }
+
             for (i = 0; i < num_palette; i++)
             {
                if (i < (int)png_ptr->num_trans &&
@@ -1086,22 +1660,22 @@ png_init_read_transformations(png_structp png_ptr)
                   palette[i].blue = png_ptr->gamma_table[palette[i].blue];
                }
             }
-            /* Prevent the transformations being done again, and make sure
-             * that the now spurious alpha channel is stripped - the code
-             * has just reduced background composition and gamma correction
-             * to a simple alpha channel strip.
+
+            /* Prevent the transformations being done again.
+             *
+             * NOTE: this is highly dubious; it removes the transformations in
+             * place.  This seems inconsistent with the general treatment of the
+             * transformations elsewhere.
              */
-            png_ptr->transformations &= ~PNG_BACKGROUND;
-            png_ptr->transformations &= ~PNG_GAMMA;
-            png_ptr->transformations |= PNG_STRIP_ALPHA;
-         }
+            png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA);
+         } /* color_type == PNG_COLOR_TYPE_PALETTE */
 
          /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
-         else
-         /* color_type != PNG_COLOR_TYPE_PALETTE */
+         else /* color_type != PNG_COLOR_TYPE_PALETTE */
          {
-            png_fixed_point g = PNG_FP_1;
-            png_fixed_point gs = PNG_FP_1;
+            int gs_sig, g_sig;
+            png_fixed_point g = PNG_FP_1;  /* Correction to linear */
+            png_fixed_point gs = PNG_FP_1; /* Correction to screen */
 
             switch (png_ptr->background_gamma_type)
             {
@@ -1125,34 +1699,45 @@ png_init_read_transformations(png_structp png_ptr)
                   png_error(png_ptr, "invalid background gamma type");
             }
 
-            png_ptr->background_1.gray = png_gamma_correct(png_ptr,
-                png_ptr->background.gray, g);
+            g_sig = png_gamma_significant(g);
+            gs_sig = png_gamma_significant(gs);
 
-            png_ptr->background.gray = png_gamma_correct(png_ptr,
-                png_ptr->background.gray, gs);
+            if (g_sig)
+               png_ptr->background_1.gray = png_gamma_correct(png_ptr,
+                   png_ptr->background.gray, g);
+
+            if (gs_sig)
+               png_ptr->background.gray = png_gamma_correct(png_ptr,
+                   png_ptr->background.gray, gs);
 
             if ((png_ptr->background.red != png_ptr->background.green) ||
                 (png_ptr->background.red != png_ptr->background.blue) ||
                 (png_ptr->background.red != png_ptr->background.gray))
             {
                /* RGB or RGBA with color background */
-               png_ptr->background_1.red = png_gamma_correct(png_ptr,
-                   png_ptr->background.red, g);
+               if (g_sig)
+               {
+                  png_ptr->background_1.red = png_gamma_correct(png_ptr,
+                      png_ptr->background.red, g);
 
-               png_ptr->background_1.green = png_gamma_correct(png_ptr,
-                   png_ptr->background.green, g);
+                  png_ptr->background_1.green = png_gamma_correct(png_ptr,
+                      png_ptr->background.green, g);
 
-               png_ptr->background_1.blue = png_gamma_correct(png_ptr,
-                   png_ptr->background.blue, g);
+                  png_ptr->background_1.blue = png_gamma_correct(png_ptr,
+                      png_ptr->background.blue, g);
+               }
 
-               png_ptr->background.red = png_gamma_correct(png_ptr,
-                   png_ptr->background.red, gs);
+               if (gs_sig)
+               {
+                  png_ptr->background.red = png_gamma_correct(png_ptr,
+                      png_ptr->background.red, gs);
 
-               png_ptr->background.green = png_gamma_correct(png_ptr,
-                   png_ptr->background.green, gs);
+                  png_ptr->background.green = png_gamma_correct(png_ptr,
+                      png_ptr->background.green, gs);
 
-               png_ptr->background.blue = png_gamma_correct(png_ptr,
-                   png_ptr->background.blue, gs);
+                  png_ptr->background.blue = png_gamma_correct(png_ptr,
+                      png_ptr->background.blue, gs);
+               }
             }
 
             else
@@ -1164,17 +1749,30 @@ png_init_read_transformations(png_structp png_ptr)
                png_ptr->background.red = png_ptr->background.green
                    = png_ptr->background.blue = png_ptr->background.gray;
             }
-         }
-      }
+
+            /* The background is now in screen gamma: */
+            png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN;
+         } /* color_type != PNG_COLOR_TYPE_PALETTE */
+      }/* png_ptr->transformations & PNG_BACKGROUND */
+
       else
       /* Transformation does not include PNG_BACKGROUND */
 #endif /* PNG_READ_BACKGROUND_SUPPORTED */
-      if (color_type == PNG_COLOR_TYPE_PALETTE)
+      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+         /* RGB_TO_GRAY needs to have non-gamma-corrected values! */
+         && ((png_ptr->transformations & PNG_EXPAND) == 0 ||
+         (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0)
+#endif
+         )
       {
          png_colorp palette = png_ptr->palette;
          int num_palette = png_ptr->num_palette;
          int i;
 
+         /*NOTE: there are other transformations that should probably be in here
+          * too.
+          */
          for (i = 0; i < num_palette; i++)
          {
             palette[i].red = png_ptr->gamma_table[palette[i].red];
@@ -1184,16 +1782,17 @@ png_init_read_transformations(png_structp png_ptr)
 
          /* Done the gamma correction. */
          png_ptr->transformations &= ~PNG_GAMMA;
-      }
+      } /* color_type == PALETTE && !PNG_BACKGROUND transformation */
    }
 #ifdef PNG_READ_BACKGROUND_SUPPORTED
    else
 #endif
 #endif /* PNG_READ_GAMMA_SUPPORTED */
+
 #ifdef PNG_READ_BACKGROUND_SUPPORTED
-   /* No GAMMA transformation */
-   if ((png_ptr->transformations & PNG_BACKGROUND) &&
-       (color_type == PNG_COLOR_TYPE_PALETTE))
+   /* No GAMMA transformation (see the hanging else 4 lines above) */
+   if ((png_ptr->transformations & PNG_COMPOSE) &&
+       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
    {
       int i;
       int istop = (int)png_ptr->num_trans;
@@ -1225,45 +1824,49 @@ png_init_read_transformations(png_structp png_ptr)
          }
       }
 
-      /* Handled alpha, still need to strip the channel. */
-      png_ptr->transformations &= ~PNG_BACKGROUND;
-      png_ptr->transformations |= PNG_STRIP_ALPHA;
+      png_ptr->transformations &= ~PNG_COMPOSE;
    }
 #endif /* PNG_READ_BACKGROUND_SUPPORTED */
 
 #ifdef PNG_READ_SHIFT_SUPPORTED
    if ((png_ptr->transformations & PNG_SHIFT) &&
-       (color_type == PNG_COLOR_TYPE_PALETTE))
+       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
    {
-      png_uint_16 i;
-      png_uint_16 istop = png_ptr->num_palette;
-      int sr = 8 - png_ptr->sig_bit.red;
-      int sg = 8 - png_ptr->sig_bit.green;
-      int sb = 8 - png_ptr->sig_bit.blue;
+      int i;
+      int istop = png_ptr->num_palette;
+      int shift = 8 - png_ptr->sig_bit.red;
 
-      if (sr < 0 || sr > 8)
-         sr = 0;
+      /* significant bits can be in the range 1 to 7 for a meaninful result, if
+       * the number of significant bits is 0 then no shift is done (this is an
+       * error condition which is silently ignored.)
+       */
+      if (shift > 0 && shift < 8) for (i=0; i<istop; ++i)
+      {
+         int component = png_ptr->palette[i].red;
+
+         component >>= shift;
+         png_ptr->palette[i].red = (png_byte)component;
+      }
 
-      if (sg < 0 || sg > 8)
-         sg = 0;
+      shift = 8 - png_ptr->sig_bit.green;
+      if (shift > 0 && shift < 8) for (i=0; i<istop; ++i)
+      {
+         int component = png_ptr->palette[i].green;
 
-      if (sb < 0 || sb > 8)
-         sb = 0;
+         component >>= shift;
+         png_ptr->palette[i].green = (png_byte)component;
+      }
 
-      for (i = 0; i < istop; i++)
+      shift = 8 - png_ptr->sig_bit.blue;
+      if (shift > 0 && shift < 8) for (i=0; i<istop; ++i)
       {
-         png_ptr->palette[i].red >>= sr;
-         png_ptr->palette[i].green >>= sg;
-         png_ptr->palette[i].blue >>= sb;
+         int component = png_ptr->palette[i].blue;
+
+         component >>= shift;
+         png_ptr->palette[i].blue = (png_byte)component;
       }
    }
 #endif  /* PNG_READ_SHIFT_SUPPORTED */
- }
-#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
- && !defined(PNG_READ_BACKGROUND_SUPPORTED)
-   if (png_ptr)
-      return;
-#endif
 }
 
 /* Modify the info structure to reflect the transformations.  The
@@ -1280,8 +1883,11 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
    {
       if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
       {
-         if (png_ptr->num_trans &&
-             (png_ptr->transformations & PNG_EXPAND_tRNS))
+         /* This check must match what actually happens in
+          * png_do_expand_palette; if it ever checks the tRNS chunk to see if
+          * it is all opaque we must do the same (at present it does not.)
+          */
+         if (png_ptr->num_trans > 0)
             info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
 
          else
@@ -1305,53 +1911,72 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
    }
 #endif
 
-#ifdef PNG_READ_EXPAND_16_SUPPORTED
-   if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&
-      info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
-   {
-      info_ptr->bit_depth = 16;
-   }
-#endif
-
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-   if (png_ptr->transformations & PNG_BACKGROUND)
-   {
-      info_ptr->color_type = (png_byte)(info_ptr->color_type &
-          ~PNG_COLOR_MASK_ALPHA);
-      info_ptr->num_trans = 0;
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
+   defined(PNG_READ_ALPHA_MODE_SUPPORTED)
+   /* The following is almost certainly wrong unless the background value is in
+    * the screen space!
+    */
+   if (png_ptr->transformations & PNG_COMPOSE)
       info_ptr->background = png_ptr->background;
-   }
 #endif
 
 #ifdef PNG_READ_GAMMA_SUPPORTED
-   if (png_ptr->transformations & PNG_GAMMA)
-   {
-      info_ptr->gamma = png_ptr->gamma;
-   }
+   /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4),
+    * however it seems that the code in png_init_read_transformations, which has
+    * been called before this from png_read_update_info->png_read_start_row
+    * sometimes does the gamma transform and cancels the flag.
+    */
+   info_ptr->gamma = png_ptr->gamma;
 #endif
 
-#ifdef PNG_READ_16_TO_8_SUPPORTED
-#ifdef PNG_READ_16BIT_SUPPORTED
-   if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16))
-      info_ptr->bit_depth = 8;
-#else
-   /* Force chopping 16-bit input down to 8 */
    if (info_ptr->bit_depth == 16)
    {
-      png_ptr->transformations |=PNG_16_TO_8;
-      info_ptr->bit_depth = 8;
+#  ifdef PNG_READ_16BIT_SUPPORTED
+#     ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+         if (png_ptr->transformations & PNG_SCALE_16_TO_8)
+            info_ptr->bit_depth = 8;
+#     endif
+
+#     ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
+         if (png_ptr->transformations & PNG_16_TO_8)
+            info_ptr->bit_depth = 8;
+#     endif
+
+#  else
+      /* No 16 bit support: force chopping 16-bit input down to 8, in this case
+       * the app program can chose if both APIs are available by setting the
+       * correct scaling to use.
+       */
+#     ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
+         /* For compatibility with previous versions use the strip method by
+          * default.  This code works because if PNG_SCALE_16_TO_8 is already
+          * set the code below will do that in preference to the chop.
+          */
+         png_ptr->transformations |= PNG_16_TO_8;
+         info_ptr->bit_depth = 8;
+#     else
+
+#        ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+            png_ptr->transformations |= PNG_SCALE_16_TO_8;
+            info_ptr->bit_depth = 8;
+#        else
+
+            CONFIGURATION ERROR: you must enable at least one 16 to 8 method
+#        endif
+#    endif
+#endif /* !READ_16BIT_SUPPORTED */
    }
-#endif
-#endif
 
 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
    if (png_ptr->transformations & PNG_GRAY_TO_RGB)
-      info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
+      info_ptr->color_type = (png_byte)(info_ptr->color_type |
+         PNG_COLOR_MASK_COLOR);
 #endif
 
 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
    if (png_ptr->transformations & PNG_RGB_TO_GRAY)
-      info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR;
+      info_ptr->color_type = (png_byte)(info_ptr->color_type &
+         ~PNG_COLOR_MASK_COLOR);
 #endif
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
@@ -1366,6 +1991,14 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
    }
 #endif
 
+#ifdef PNG_READ_EXPAND_16_SUPPORTED
+   if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&
+      info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
+   {
+      info_ptr->bit_depth = 16;
+   }
+#endif
+
 #ifdef PNG_READ_PACK_SUPPORTED
    if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
       info_ptr->bit_depth = 8;
@@ -1382,7 +2015,11 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
 
 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
    if (png_ptr->transformations & PNG_STRIP_ALPHA)
-      info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA;
+   {
+      info_ptr->color_type = (png_byte)(info_ptr->color_type &
+         ~PNG_COLOR_MASK_ALPHA);
+      info_ptr->num_trans = 0;
+   }
 #endif
 
    if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
@@ -1418,6 +2055,14 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
 
    info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
 
+   /* Adding in 1.5.4: cache the above value in png_struct so that we can later
+    * check in png_rowbytes that the user buffer won't get overwritten.  Note
+    * that the field is not always set - if png_read_update_info isn't called
+    * the application has to either not do any transforms or get the calculation
+    * right itself.
+    */
+   png_ptr->info_rowbytes = info_ptr->rowbytes;
+
 #ifndef PNG_READ_EXPAND_SUPPORTED
    if (png_ptr)
       return;
@@ -1429,42 +2074,40 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
  * decide how it fits in with the other transformations here.
  */
 void /* PRIVATE */
-png_do_read_transformations(png_structp png_ptr)
+png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
 {
    png_debug(1, "in png_do_read_transformations");
 
    if (png_ptr->row_buf == NULL)
    {
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-      char msg[50];
-
-      png_snprintf2(msg, 50,
-          "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number,
-          png_ptr->pass);
-      png_error(png_ptr, msg);
-#else
+      /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this
+       * error is incredibly rare and incredibly easy to debug without this
+       * information.
+       */
       png_error(png_ptr, "NULL row buffer");
-#endif
    }
-#ifdef PNG_WARN_UNINITIALIZED_ROW
-   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
-      /* Application has failed to call either png_read_start_image()
-       * or png_read_update_info() after setting transforms that expand
-       * pixels.  This check added to libpng-1.2.19
+
+   /* The following is debugging; prior to 1.5.4 the code was never compiled in;
+    * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro
+    * PNG_WARN_UNINITIALIZED_ROW removed.  In 1.5 the new flag is set only for
+    * selected new APIs to ensure that there is no API change.
+    */
+   if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
+      !(png_ptr->flags & PNG_FLAG_ROW_INIT))
+   {
+      /* Application has failed to call either png_read_start_image() or
+       * png_read_update_info() after setting transforms that expand pixels.
+       * This check added to libpng-1.2.19 (but not enabled until 1.5.4).
        */
-#if (PNG_WARN_UNINITIALIZED_ROW==1)
       png_error(png_ptr, "Uninitialized row");
-#else
-      png_warning(png_ptr, "Uninitialized row");
-#endif
-#endif
+   }
 
 #ifdef PNG_READ_EXPAND_SUPPORTED
    if (png_ptr->transformations & PNG_EXPAND)
    {
-      if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE)
+      if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
       {
-         png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1,
+         png_do_expand_palette(row_info, png_ptr->row_buf + 1,
              png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
       }
 
@@ -1472,33 +2115,30 @@ png_do_read_transformations(png_structp png_ptr)
       {
          if (png_ptr->num_trans &&
              (png_ptr->transformations & PNG_EXPAND_tRNS))
-            png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
+            png_do_expand(row_info, png_ptr->row_buf + 1,
                 &(png_ptr->trans_color));
 
          else
-            png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
+            png_do_expand(row_info, png_ptr->row_buf + 1,
                 NULL);
       }
    }
 #endif
 
-   /* Delay the 'expand 16' step until later for efficiency, so that the
-    * intermediate steps work with 8 bit data.
-    */
-
 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
    if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
-      (png_ptr->row_info.color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
-      png_ptr->row_info.color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
-      png_do_strip_channel(&(png_ptr->row_info), png_ptr->row_buf + 1,
-         0/*!at_start, because SWAP_ALPHA happens later*/);
+      !(png_ptr->transformations & PNG_COMPOSE) &&
+      (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
+      row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
+      png_do_strip_channel(row_info, png_ptr->row_buf + 1,
+         0 /* at_start == false, because SWAP_ALPHA happens later */);
 #endif
 
 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
    if (png_ptr->transformations & PNG_RGB_TO_GRAY)
    {
       int rgb_error =
-          png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info),
+          png_do_rgb_to_gray(png_ptr, row_info,
               png_ptr->row_buf + 1);
 
       if (rgb_error)
@@ -1552,50 +2192,73 @@ png_do_read_transformations(png_structp png_ptr)
     */
    if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
        !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
-      png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
 #endif
 
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-   if ((png_ptr->transformations & PNG_BACKGROUND) &&
-       ((png_ptr->num_trans != 0) ||
-       (png_ptr->color_type & PNG_COLOR_MASK_ALPHA)))
-      png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1,
-          &(png_ptr->trans_color), &(png_ptr->background)
-#ifdef PNG_READ_GAMMA_SUPPORTED
-          , &(png_ptr->background_1),
-          png_ptr->gamma_table, png_ptr->gamma_from_1,
-          png_ptr->gamma_to_1, png_ptr->gamma_16_table,
-          png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1,
-          png_ptr->gamma_shift
-#endif
-          );
+#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
+   (defined PNG_READ_ALPHA_MODE_SUPPORTED)
+   if (png_ptr->transformations & PNG_COMPOSE)
+      png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
 #endif
 
 #ifdef PNG_READ_GAMMA_SUPPORTED
    if ((png_ptr->transformations & PNG_GAMMA) &&
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
-       !((png_ptr->transformations & PNG_BACKGROUND) &&
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+      /* Because RGB_TO_GRAY does the gamma transform. */
+      !(png_ptr->transformations & PNG_RGB_TO_GRAY) &&
+#endif
+#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
+   (defined PNG_READ_ALPHA_MODE_SUPPORTED)
+      /* Because PNG_COMPOSE does the gamma transform if there is something to
+       * do (if there is an alpha channel or transparency.)
+       */
+       !((png_ptr->transformations & PNG_COMPOSE) &&
        ((png_ptr->num_trans != 0) ||
        (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
 #endif
+      /* Because png_init_read_transformations transforms the palette, unless
+       * RGB_TO_GRAY will do the transform.
+       */
        (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))
-      png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1,
-          png_ptr->gamma_table, png_ptr->gamma_16_table,
-          png_ptr->gamma_shift);
+      png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr);
+#endif
+
+#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
+   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
+      (png_ptr->transformations & PNG_COMPOSE) &&
+      (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
+      row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
+      png_do_strip_channel(row_info, png_ptr->row_buf + 1,
+         0 /* at_start == false, because SWAP_ALPHA happens later */);
+#endif
+
+#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+   if ((png_ptr->transformations & PNG_ENCODE_ALPHA) &&
+      (row_info->color_type & PNG_COLOR_MASK_ALPHA))
+      png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr);
 #endif
 
-#ifdef PNG_READ_16_TO_8_SUPPORTED
+#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+   if (png_ptr->transformations & PNG_SCALE_16_TO_8)
+      png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1);
+#endif
+
+#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
+   /* There is no harm in doing both of these because only one has any effect,
+    * by putting the 'scale' option first if the app asks for scale (either by
+    * calling the API or in a TRANSFORM flag) this is what happens.
+    */
    if (png_ptr->transformations & PNG_16_TO_8)
-      png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_chop(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_QUANTIZE_SUPPORTED
    if (png_ptr->transformations & PNG_QUANTIZE)
    {
-      png_do_quantize(&(png_ptr->row_info), png_ptr->row_buf + 1,
+      png_do_quantize(row_info, png_ptr->row_buf + 1,
           png_ptr->palette_lookup, png_ptr->quantize_index);
 
-      if (png_ptr->row_info.rowbytes == 0)
+      if (row_info->rowbytes == 0)
          png_error(png_ptr, "png_do_quantize returned rowbytes=0");
    }
 #endif /* PNG_READ_QUANTIZE_SUPPORTED */
@@ -1607,65 +2270,62 @@ png_do_read_transformations(png_structp png_ptr)
     * better accuracy results faster!)
     */
    if (png_ptr->transformations & PNG_EXPAND_16)
-      png_do_expand_16(&png_ptr->row_info, png_ptr->row_buf + 1);
+      png_do_expand_16(row_info, png_ptr->row_buf + 1);
+#endif
+
+#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
+   /*NOTE: moved here in 1.5.4 (from much later in this list.) */
+   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
+       (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
+      png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_INVERT_SUPPORTED
    if (png_ptr->transformations & PNG_INVERT_MONO)
-      png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_invert(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_SHIFT_SUPPORTED
    if (png_ptr->transformations & PNG_SHIFT)
-      png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1,
+      png_do_unshift(row_info, png_ptr->row_buf + 1,
           &(png_ptr->shift));
 #endif
 
 #ifdef PNG_READ_PACK_SUPPORTED
    if (png_ptr->transformations & PNG_PACK)
-      png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_unpack(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_BGR_SUPPORTED
    if (png_ptr->transformations & PNG_BGR)
-      png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_bgr(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_PACKSWAP_SUPPORTED
    if (png_ptr->transformations & PNG_PACKSWAP)
-      png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
-   /*NOTE: this must be in the wrong place - what happens if BGR is set too?
-    * Need pngvalid to test this combo.
-    */
-   /* If gray -> RGB, do so now only if we did not do so above */
-   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
-       (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
-      png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_packswap(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_FILLER_SUPPORTED
    if (png_ptr->transformations & PNG_FILLER)
-      png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
+      png_do_read_filler(row_info, png_ptr->row_buf + 1,
           (png_uint_32)png_ptr->filler, png_ptr->flags);
 #endif
 
 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
    if (png_ptr->transformations & PNG_INVERT_ALPHA)
-      png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
    if (png_ptr->transformations & PNG_SWAP_ALPHA)
-      png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_READ_16BIT_SUPPORTED
 #ifdef PNG_READ_SWAP_SUPPORTED
    if (png_ptr->transformations & PNG_SWAP_BYTES)
-      png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_swap(row_info, png_ptr->row_buf + 1);
 #endif
 #endif
 
@@ -1674,8 +2334,8 @@ png_do_read_transformations(png_structp png_ptr)
     {
       if (png_ptr->read_user_transform_fn != NULL)
          (*(png_ptr->read_user_transform_fn)) /* User read transform function */
-             (png_ptr,                    /* png_ptr */
-             &(png_ptr->row_info),     /* row_info: */
+             (png_ptr,     /* png_ptr */
+             row_info,     /* row_info: */
                 /*  png_uint_32 width;       width of row */
                 /*  png_size_t rowbytes;     number of bytes in row */
                 /*  png_byte color_type;     color type of pixels */
@@ -1685,19 +2345,17 @@ png_do_read_transformations(png_structp png_ptr)
              png_ptr->row_buf + 1);    /* start of pixel data for row */
 #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
       if (png_ptr->user_transform_depth)
-         png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
+         row_info->bit_depth = png_ptr->user_transform_depth;
 
       if (png_ptr->user_transform_channels)
-         png_ptr->row_info.channels = png_ptr->user_transform_channels;
+         row_info->channels = png_ptr->user_transform_channels;
 #endif
-      png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
-          png_ptr->row_info.channels);
+      row_info->pixel_depth = (png_byte)(row_info->bit_depth *
+          row_info->channels);
 
-      png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
-          png_ptr->row_info.width);
+      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width);
    }
 #endif
-
 }
 
 #ifdef PNG_READ_PACK_SUPPORTED
@@ -1809,164 +2467,219 @@ void /* PRIVATE */
 png_do_unshift(png_row_infop row_info, png_bytep row,
     png_const_color_8p sig_bits)
 {
+   int color_type;
+
    png_debug(1, "in png_do_unshift");
 
-   if (
-       row_info->color_type != PNG_COLOR_TYPE_PALETTE)
+   /* The palette case has already been handled in the _init routine. */
+   color_type = row_info->color_type;
+
+   if (color_type != PNG_COLOR_TYPE_PALETTE)
    {
       int shift[4];
       int channels = 0;
-      int c;
-      png_uint_16 value = 0;
-      png_uint_32 row_width = row_info->width;
+      int bit_depth = row_info->bit_depth;
 
-      if (row_info->color_type & PNG_COLOR_MASK_COLOR)
+      if (color_type & PNG_COLOR_MASK_COLOR)
       {
-         shift[channels++] = row_info->bit_depth - sig_bits->red;
-         shift[channels++] = row_info->bit_depth - sig_bits->green;
-         shift[channels++] = row_info->bit_depth - sig_bits->blue;
+         shift[channels++] = bit_depth - sig_bits->red;
+         shift[channels++] = bit_depth - sig_bits->green;
+         shift[channels++] = bit_depth - sig_bits->blue;
       }
 
       else
       {
-         shift[channels++] = row_info->bit_depth - sig_bits->gray;
+         shift[channels++] = bit_depth - sig_bits->gray;
       }
 
-      if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
+      if (color_type & PNG_COLOR_MASK_ALPHA)
       {
-         shift[channels++] = row_info->bit_depth - sig_bits->alpha;
+         shift[channels++] = bit_depth - sig_bits->alpha;
       }
 
-      for (c = 0; c < channels; c++)
       {
-         if (shift[c] <= 0)
-            shift[c] = 0;
+         int c, have_shift;
 
-         else
-            value = 1;
-      }
+         for (c = have_shift = 0; c < channels; ++c)
+         {
+            /* A shift of more than the bit depth is an error condition but it
+             * gets ignored here.
+             */
+            if (shift[c] <= 0 || shift[c] >= bit_depth)
+               shift[c] = 0;
 
-      if (!value)
-         return;
+            else
+               have_shift = 1;
+         }
 
-      switch (row_info->bit_depth)
+         if (!have_shift)
+            return;
+      }
+
+      switch (bit_depth)
       {
          default:
+         /* Must be 1bpp gray: should not be here! */
+            /* NOTREACHED */
             break;
 
          case 2:
+         /* Must be 2bpp gray */
+         /* assert(channels == 1 && shift[0] == 1) */
          {
-            png_bytep bp;
-            png_size_t i;
-            png_size_t istop = row_info->rowbytes;
+            png_bytep bp = row;
+            png_bytep bp_end = bp + row_info->rowbytes;
 
-            for (bp = row, i = 0; i < istop; i++)
+            while (bp < bp_end)
             {
-               *bp >>= 1;
-               *bp++ &= 0x55;
+               int b = (*bp >> 1) & 0x55;
+               *bp++ = (png_byte)b;
             }
             break;
          }
 
          case 4:
+         /* Must be 4bpp gray */
+         /* assert(channels == 1) */
          {
             png_bytep bp = row;
-            png_size_t i;
-            png_size_t istop = row_info->rowbytes;
-            png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) |
-                (png_byte)((int)0xf >> shift[0]));
+            png_bytep bp_end = bp + row_info->rowbytes;
+            int gray_shift = shift[0];
+            int mask =  0xf >> gray_shift;
+
+            mask |= mask << 4;
 
-            for (i = 0; i < istop; i++)
+            while (bp < bp_end)
             {
-               *bp >>= shift[0];
-               *bp++ &= mask;
+               int b = (*bp >> gray_shift) & mask;
+               *bp++ = (png_byte)b;
             }
             break;
          }
 
          case 8:
+         /* Single byte components, G, GA, RGB, RGBA */
          {
             png_bytep bp = row;
-            png_uint_32 i;
-            png_uint_32 istop = row_width * channels;
+            png_bytep bp_end = bp + row_info->rowbytes;
+            int channel = 0;
 
-            for (i = 0; i < istop; i++)
+            while (bp < bp_end)
             {
-               *bp++ >>= shift[i%channels];
+               int b = *bp >> shift[channel];
+               if (++channel >= channels)
+                  channel = 0;
+               *bp++ = (png_byte)b;
             }
             break;
          }
 
 #ifdef PNG_READ_16BIT_SUPPORTED
          case 16:
+         /* Double byte components, G, GA, RGB, RGBA */
          {
             png_bytep bp = row;
-            png_uint_32 i;
-            png_uint_32 istop = channels * row_width;
+            png_bytep bp_end = bp + row_info->rowbytes;
+            int channel = 0;
+
+            while (bp < bp_end)
+            {
+               int value = (bp[0] << 8) + bp[1];
+
+               value >>= shift[channel];
+               if (++channel >= channels)
+                  channel = 0;
+               *bp++ = (png_byte)(value >> 8);
+               *bp++ = (png_byte)(value & 0xff);
+            }
+            break;
+         }
+#endif
+      }
+   }
+}
+#endif
+
+#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
+/* Scale rows of bit depth 16 down to 8 accurately */
+void /* PRIVATE */
+png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
+{
+   png_debug(1, "in png_do_scale_16_to_8");
+
+   if (row_info->bit_depth == 16)
+   {
+      png_bytep sp = row; /* source */
+      png_bytep dp = row; /* destination */
+      png_bytep ep = sp + row_info->rowbytes; /* end+1 */
+
+      while (sp < ep)
+      {
+         /* The input is an array of 16 bit components, these must be scaled to
+          * 8 bits each.  For a 16 bit value V the required value (from the PNG
+          * specification) is:
+          *
+          *    (V * 255) / 65535
+          *
+          * This reduces to round(V / 257), or floor((V + 128.5)/257)
+          *
+          * Represent V as the two byte value vhi.vlo.  Make a guess that the
+          * result is the top byte of V, vhi, then the correction to this value
+          * is:
+          *
+          *    error = floor(((V-vhi.vhi) + 128.5) / 257)
+          *          = floor(((vlo-vhi) + 128.5) / 257)
+          *
+          * This can be approximated using integer arithmetic (and a signed
+          * shift):
+          *
+          *    error = (vlo-vhi+128) >> 8;
+          *
+          * The approximate differs from the exact answer only when (vlo-vhi) is
+          * 128; it then gives a correction of +1 when the exact correction is
+          * 0.  This gives 128 errors.  The exact answer (correct for all 16 bit
+          * input values) is:
+          *
+          *    error = (vlo-vhi+128)*65535 >> 24;
+          *
+          * An alternative arithmetic calculation which also gives no errors is:
+          *
+          *    (V * 255 + 32895) >> 16
+          */
 
-            for (i = 0; i < istop; i++)
-            {
-               value = (png_uint_16)((*bp << 8) + *(bp + 1));
-               value >>= shift[i%channels];
-               *bp++ = (png_byte)(value >> 8);
-               *bp++ = (png_byte)(value & 0xff);
-            }
-            break;
-         }
-#endif
+         png_int_32 tmp = *sp++; /* must be signed! */
+         tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24;
+         *dp++ = (png_byte)tmp;
       }
+
+      row_info->bit_depth = 8;
+      row_info->pixel_depth = (png_byte)(8 * row_info->channels);
+      row_info->rowbytes = row_info->width * row_info->channels;
    }
 }
 #endif
 
-#ifdef PNG_READ_16_TO_8_SUPPORTED
-/* Chop rows of bit depth 16 down to 8 */
+#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
 void /* PRIVATE */
+/* Simply discard the low byte.  This was the default behavior prior
+ * to libpng-1.5.4.
+ */
 png_do_chop(png_row_infop row_info, png_bytep row)
 {
    png_debug(1, "in png_do_chop");
 
    if (row_info->bit_depth == 16)
    {
-      png_bytep sp = row;
-      png_bytep dp = row;
-      png_uint_32 i;
-      png_uint_32 istop = row_info->width * row_info->channels;
+      png_bytep sp = row; /* source */
+      png_bytep dp = row; /* destination */
+      png_bytep ep = sp + row_info->rowbytes; /* end+1 */
 
-      for (i = 0; i<istop; i++, sp += 2, dp++)
+      while (sp < ep)
       {
-#ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
-      /* This does a more accurate scaling of the 16-bit color
-       * value, rather than a simple low-byte truncation.
-       *
-       * What the ideal calculation should be:
-       *   *dp = (((((png_uint_32)(*sp) << 8) |
-       *          (png_uint_32)(*(sp + 1))) * 255 + 127)
-       *          / (png_uint_32)65535L;
-       *
-       * GRR: no, I think this is what it really should be:
-       *   *dp = (((((png_uint_32)(*sp) << 8) |
-       *           (png_uint_32)(*(sp + 1))) + 128L)
-       *           / (png_uint_32)257L;
-       *
-       * GRR: here's the exact calculation with shifts:
-       *   temp = (((png_uint_32)(*sp) << 8) |
-       *           (png_uint_32)(*(sp + 1))) + 128L;
-       *   *dp = (temp - (temp >> 8)) >> 8;
-       *
-       * Approximate calculation with shift/add instead of multiply/divide:
-       *   *dp = ((((png_uint_32)(*sp) << 8) |
-       *          (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8;
-       *
-       * What we actually do to avoid extra shifting and conversion:
-       */
-
-         *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0);
-#else
-       /* Simply discard the low order byte */
-         *dp = *sp;
-#endif
+         *dp++ = *sp;
+         sp += 2; /* skip low byte */
       }
+
       row_info->bit_depth = 8;
       row_info->pixel_depth = (png_byte)(8 * row_info->channels);
       row_info->rowbytes = row_info->width * row_info->channels;
@@ -2438,7 +3151,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
             }
          }
       }
-      row_info->channels += (png_byte)2;
+      row_info->channels = (png_byte)(row_info->channels + 2);
       row_info->color_type |= PNG_COLOR_MASK_COLOR;
       row_info->pixel_depth = (png_byte)(row_info->channels *
           row_info->bit_depth);
@@ -2449,33 +3162,61 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
 
 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
 /* Reduce RGB files to grayscale, with or without alpha
- * using the equation given in Poynton's ColorFAQ at
- * <http://www.inforamp.net/~poynton/>  (THIS LINK IS DEAD June 2008)
- * New link:
- * <http://www.poynton.com/notes/colour_and_gamma/>
+ * using the equation given in Poynton's ColorFAQ of 1998-01-04 at
+ * <http://www.inforamp.net/~poynton/>  (THIS LINK IS DEAD June 2008 but
+ * versions dated 1998 through November 2002 have been archived at
+ * http://web.archive.org/web/20000816232553/http://www.inforamp.net/
+ * ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
  * Charles Poynton poynton at poynton.com
  *
  *     Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
  *
- *  We approximate this with
+ *  which can be expressed with integers as
+ *
+ *     Y = (6969 * R + 23434 * G + 2365 * B)/32768
+ *
+ * Poynton's current link (as of January 2003 through July 2011):
+ * <http://www.poynton.com/notes/colour_and_gamma/>
+ * has changed the numbers slightly:
  *
- *     Y = 0.21268 * R    + 0.7151 * G    + 0.07217 * B
+ *     Y = 0.2126*R + 0.7152*G + 0.0722*B
  *
  *  which can be expressed with integers as
  *
- *     Y = (6969 * R + 23434 * G + 2365 * B)/32768
+ *     Y = (6966 * R + 23436 * G + 2366 * B)/32768
+ *
+ *  Historically, however, libpng uses numbers derived from the ITU-R Rec 709
+ *  end point chromaticities and the D65 white point.  Depending on the
+ *  precision used for the D65 white point this produces a variety of different
+ *  numbers, however if the four decimal place value used in ITU-R Rec 709 is
+ *  used (0.3127,0.3290) the Y calculation would be:
+ *
+ *     Y = (6968 * R + 23435 * G + 2366 * B)/32768
+ *
+ *  While this is correct the rounding results in an overflow for white, because
+ *  the sum of the rounded coefficients is 32769, not 32768.  Consequently
+ *  libpng uses, instead, the closest non-overflowing approximation:
  *
- *  The calculation is to be done in a linear colorspace.
+ *     Y = (6968 * R + 23434 * G + 2366 * B)/32768
  *
- *  Other integer coefficents can be used via png_set_rgb_to_gray().
+ *  Starting with libpng-1.5.5, if the image being converted has a cHRM chunk
+ *  (including an sRGB chunk) then the chromaticities are used to calculate the
+ *  coefficients.  See the chunk handling in pngrutil.c for more information.
+ *
+ *  In all cases the calculation is to be done in a linear colorspace.  If no
+ *  gamma information is available to correct the encoding of the original RGB
+ *  values this results in an implicit assumption that the original PNG RGB
+ *  values were linear.
+ *
+ *  Other integer coefficents can be used via png_set_rgb_to_gray().  Because
+ *  the API takes just red and green coefficients the blue coefficient is
+ *  calculated to make the sum 32768.  This will result in different rounding
+ *  to that used above.
  */
 int /* PRIVATE */
 png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
 
 {
-   png_uint_32 i;
-
-   png_uint_32 row_width = row_info->width;
    int rgb_error = 0;
 
    png_debug(1, "in png_do_rgb_to_gray");
@@ -2483,235 +3224,180 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
    if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
        (row_info->color_type & PNG_COLOR_MASK_COLOR))
    {
-      png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
-      png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
-      png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff;
+      PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
+      PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
+      PNG_CONST png_uint_32 bc = 32768 - rc - gc;
+      PNG_CONST png_uint_32 row_width = row_info->width;
+      PNG_CONST int have_alpha =
+         (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
 
-      if (row_info->color_type == PNG_COLOR_TYPE_RGB)
+      if (row_info->bit_depth == 8)
       {
-         if (row_info->bit_depth == 8)
-         {
 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
-            if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
+         /* Notice that gamma to/from 1 are not necessarily inverses (if
+          * there is an overall gamma correction).  Prior to 1.5.5 this code
+          * checked the linearized values for equality; this doesn't match
+          * the documentation, the original values must be checked.
+          */
+         if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
+         {
+            png_bytep sp = row;
+            png_bytep dp = row;
+            png_uint_32 i;
+
+            for (i = 0; i < row_width; i++)
             {
-               png_bytep sp = row;
-               png_bytep dp = row;
+               png_byte red   = *(sp++);
+               png_byte green = *(sp++);
+               png_byte blue  = *(sp++);
 
-               for (i = 0; i < row_width; i++)
+               if (red != green || red != blue)
                {
-                  png_byte red   = png_ptr->gamma_to_1[*(sp++)];
-                  png_byte green = png_ptr->gamma_to_1[*(sp++)];
-                  png_byte blue  = png_ptr->gamma_to_1[*(sp++)];
-
-                  if (red != green || red != blue)
-                  {
-                     rgb_error |= 1;
-                     *(dp++) = png_ptr->gamma_from_1[
-                         (rc*red + gc*green + bc*blue)>>15];
-                  }
+                  red = png_ptr->gamma_to_1[red];
+                  green = png_ptr->gamma_to_1[green];
+                  blue = png_ptr->gamma_to_1[blue];
 
-                  else
-                     *(dp++) = *(sp - 1);
+                  rgb_error |= 1;
+                  *(dp++) = png_ptr->gamma_from_1[
+                      (rc*red + gc*green + bc*blue + 16384)>>15];
                }
-            }
-            else
-#endif
-            {
-               png_bytep sp = row;
-               png_bytep dp = row;
-               for (i = 0; i < row_width; i++)
-               {
-                  png_byte red   = *(sp++);
-                  png_byte green = *(sp++);
-                  png_byte blue  = *(sp++);
 
-                  if (red != green || red != blue)
-                  {
-                     rgb_error |= 1;
-                     *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
-                  }
+               else
+               {
+                  /* If there is no overall correction the table will not be
+                   * set.
+                   */
+                  if (png_ptr->gamma_table != NULL)
+                     red = png_ptr->gamma_table[red];
 
-                  else
-                     *(dp++) = *(sp - 1);
+                  *(dp++) = red;
                }
+
+               if (have_alpha)
+                  *(dp++) = *(sp++);
             }
          }
-
-         else /* RGB bit_depth == 16 */
+         else
+#endif
          {
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
-            if (png_ptr->gamma_16_to_1 != NULL &&
-                png_ptr->gamma_16_from_1 != NULL)
-            {
-               png_bytep sp = row;
-               png_bytep dp = row;
-               for (i = 0; i < row_width; i++)
-               {
-                  png_uint_16 red, green, blue, w;
-
-                  red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-                  green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-                  blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-
-                  if (red == green && red == blue)
-                     w = red;
-
-                  else
-                  {
-                     png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red&0xff)
-                         >> png_ptr->gamma_shift][red>>8];
-                     png_uint_16 green_1 =
-                         png_ptr->gamma_16_to_1[(green&0xff) >>
-                         png_ptr->gamma_shift][green>>8];
-                     png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff)
-                         >> png_ptr->gamma_shift][blue>>8];
-                     png_uint_16 gray16  = (png_uint_16)((rc*red_1 + gc*green_1
-                         + bc*blue_1)>>15);
-                     w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
-                         png_ptr->gamma_shift][gray16 >> 8];
-                     rgb_error |= 1;
-                  }
+            png_bytep sp = row;
+            png_bytep dp = row;
+            png_uint_32 i;
 
-                  *(dp++) = (png_byte)((w>>8) & 0xff);
-                  *(dp++) = (png_byte)(w & 0xff);
-               }
-            }
-            else
-#endif
+            for (i = 0; i < row_width; i++)
             {
-               png_bytep sp = row;
-               png_bytep dp = row;
-               for (i = 0; i < row_width; i++)
-               {
-                  png_uint_16 red, green, blue, gray16;
+               png_byte red   = *(sp++);
+               png_byte green = *(sp++);
+               png_byte blue  = *(sp++);
 
-                  red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-                  green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-                  blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+               if (red != green || red != blue)
+               {
+                  rgb_error |= 1;
+                  /*NOTE: this is the historical approach which simply
+                   * truncates the results.
+                   */
+                  *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
+               }
 
-                  if (red != green || red != blue)
-                     rgb_error |= 1;
+               else
+                  *(dp++) = red;
 
-                  gray16  = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
-                  *(dp++) = (png_byte)((gray16>>8) & 0xff);
-                  *(dp++) = (png_byte)(gray16 & 0xff);
-               }
+               if (have_alpha)
+                  *(dp++) = *(sp++);
             }
          }
       }
-      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+
+      else /* RGB bit_depth == 16 */
       {
-         if (row_info->bit_depth == 8)
-         {
 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
-            if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
+         if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)
+         {
+            png_bytep sp = row;
+            png_bytep dp = row;
+            png_uint_32 i;
+
+            for (i = 0; i < row_width; i++)
             {
-               png_bytep sp = row;
-               png_bytep dp = row;
-               for (i = 0; i < row_width; i++)
-               {
-                  png_byte red   = png_ptr->gamma_to_1[*(sp++)];
-                  png_byte green = png_ptr->gamma_to_1[*(sp++)];
-                  png_byte blue  = png_ptr->gamma_to_1[*(sp++)];
+               png_uint_16 red, green, blue, w;
 
-                  if (red != green || red != blue)
-                     rgb_error |= 1;
+               red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+               green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+               blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
 
-                  *(dp++) =  png_ptr->gamma_from_1
-                      [(rc*red + gc*green + bc*blue)>>15];
+               if (red == green && red == blue)
+               {
+                  if (png_ptr->gamma_16_table != NULL)
+                     w = png_ptr->gamma_16_table[(red&0xff)
+                         >> png_ptr->gamma_shift][red>>8];
 
-                  *(dp++) = *(sp++);  /* alpha */
+                  else
+                     w = red;
                }
-            }
-            else
-#endif
-            {
-               png_bytep sp = row;
-               png_bytep dp = row;
-               for (i = 0; i < row_width; i++)
+
+               else
+               {
+                  png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red&0xff)
+                      >> png_ptr->gamma_shift][red>>8];
+                  png_uint_16 green_1 =
+                      png_ptr->gamma_16_to_1[(green&0xff) >>
+                      png_ptr->gamma_shift][green>>8];
+                  png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff)
+                      >> png_ptr->gamma_shift][blue>>8];
+                  png_uint_16 gray16  = (png_uint_16)((rc*red_1 + gc*green_1
+                      + bc*blue_1 + 16384)>>15);
+                  w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
+                      png_ptr->gamma_shift][gray16 >> 8];
+                  rgb_error |= 1;
+               }
+
+               *(dp++) = (png_byte)((w>>8) & 0xff);
+               *(dp++) = (png_byte)(w & 0xff);
+
+               if (have_alpha)
                {
-                  png_byte red   = *(sp++);
-                  png_byte green = *(sp++);
-                  png_byte blue  = *(sp++);
-                  if (red != green || red != blue)
-                     rgb_error |= 1;
-
-                  *(dp++) =  (png_byte)((rc*red + gc*green + bc*blue)>>15);
-                  *(dp++) = *(sp++);  /* alpha */
+                  *(dp++) = *(sp++);
+                  *(dp++) = *(sp++);
                }
             }
          }
-         else /* RGBA bit_depth == 16 */
+         else
+#endif
          {
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
-            if (png_ptr->gamma_16_to_1 != NULL &&
-                png_ptr->gamma_16_from_1 != NULL)
-            {
-               png_bytep sp = row;
-               png_bytep dp = row;
-               for (i = 0; i < row_width; i++)
-               {
-                  png_uint_16 red, green, blue, w;
-
-                  red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-                  green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-                  blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
-
-                  if (red == green && red == blue)
-                     w = red;
-
-                  else
-                  {
-                     png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red&0xff) >>
-                         png_ptr->gamma_shift][red>>8];
-
-                     png_uint_16 green_1 =
-                         png_ptr->gamma_16_to_1[(green&0xff) >>
-                         png_ptr->gamma_shift][green>>8];
+            png_bytep sp = row;
+            png_bytep dp = row;
+            png_uint_32 i;
 
-                     png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff) >>
-                         png_ptr->gamma_shift][blue>>8];
+            for (i = 0; i < row_width; i++)
+            {
+               png_uint_16 red, green, blue, gray16;
 
-                     png_uint_16 gray16  = (png_uint_16)((rc * red_1
-                         + gc * green_1 + bc * blue_1)>>15);
+               red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+               green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+               blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
 
-                     w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
-                         png_ptr->gamma_shift][gray16 >> 8];
+               if (red != green || red != blue)
+                  rgb_error |= 1;
 
-                     rgb_error |= 1;
-                  }
+               /* From 1.5.5 in the 16 bit case do the accurate conversion even
+                * in the 'fast' case - this is because this is where the code
+                * ends up when handling linear 16 bit data.
+                */
+               gray16  = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
+                  15);
+               *(dp++) = (png_byte)((gray16>>8) & 0xff);
+               *(dp++) = (png_byte)(gray16 & 0xff);
 
-                  *(dp++) = (png_byte)((w>>8) & 0xff);
-                  *(dp++) = (png_byte)(w & 0xff);
-                  *(dp++) = *(sp++);  /* alpha */
-                  *(dp++) = *(sp++);
-               }
-            }
-            else
-#endif
-            {
-               png_bytep sp = row;
-               png_bytep dp = row;
-               for (i = 0; i < row_width; i++)
+               if (have_alpha)
                {
-                  png_uint_16 red, green, blue, gray16;
-                  red   = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
-                  green = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
-                  blue  = (png_uint_16)((*(sp)<<8) | *(sp + 1)); sp += 2;
-
-                  if (red != green || red != blue)
-                     rgb_error |= 1;
-
-                  gray16  = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
-                  *(dp++) = (png_byte)((gray16>>8) & 0xff);
-                  *(dp++) = (png_byte)(gray16 & 0xff);
-                  *(dp++) = *(sp++);  /* alpha */
+                  *(dp++) = *(sp++);
                   *(dp++) = *(sp++);
                }
             }
          }
       }
-      row_info->channels -= 2;
+
+      row_info->channels = (png_byte)(row_info->channels - 2);
       row_info->color_type = (png_byte)(row_info->color_type &
           ~PNG_COLOR_MASK_COLOR);
       row_info->pixel_depth = (png_byte)(row_info->channels *
@@ -2721,11 +3407,13 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
    return rgb_error;
 }
 #endif
+#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
 
+#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
 /* Build a grayscale palette.  Palette is assumed to be 1 << bit_depth
  * large of png_color.  This lets grayscale images be treated as
  * paletted.  Most useful for gamma correction and simplification
- * of code.
+ * of code.  This API is not used internally.
  */
 void PNGAPI
 png_build_grayscale_palette(int bit_depth, png_colorp palette)
@@ -2775,34 +3463,37 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
       palette[i].blue = (png_byte)v;
    }
 }
+#endif
 
 
-#ifdef PNG_READ_BACKGROUND_SUPPORTED
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
+#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
+   (defined PNG_READ_ALPHA_MODE_SUPPORTED)
 /* Replace any alpha or transparency with the supplied background color.
  * "background" is already in the screen gamma, while "background_1" is
  * at a gamma of 1.0.  Paletted files have already been taken care of.
  */
 void /* PRIVATE */
-png_do_background(png_row_infop row_info, png_bytep row,
-    png_const_color_16p trans_color, png_const_color_16p background
+png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)
+{
 #ifdef PNG_READ_GAMMA_SUPPORTED
-    , png_const_color_16p background_1, png_const_bytep gamma_table,
-    png_const_bytep gamma_from_1, png_const_bytep gamma_to_1,
-    png_const_uint_16pp gamma_16, png_const_uint_16pp gamma_16_from_1,
-    png_const_uint_16pp gamma_16_to_1, int gamma_shift
+   png_const_bytep gamma_table = png_ptr->gamma_table;
+   png_const_bytep gamma_from_1 = png_ptr->gamma_from_1;
+   png_const_bytep gamma_to_1 = png_ptr->gamma_to_1;
+   png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table;
+   png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1;
+   png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1;
+   int gamma_shift = png_ptr->gamma_shift;
 #endif
-    )
-{
-   png_bytep sp, dp;
+
+   png_bytep sp;
    png_uint_32 i;
    png_uint_32 row_width = row_info->width;
+   int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;
    int shift;
 
-   png_debug(1, "in png_do_background");
+   png_debug(1, "in png_do_compose");
 
-   if (background != NULL &&
-      (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) ||
-      (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_color)))
    {
       switch (row_info->color_type)
       {
@@ -2817,10 +3508,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
                   for (i = 0; i < row_width; i++)
                   {
                      if ((png_uint_16)((*sp >> shift) & 0x01)
-                        == trans_color->gray)
+                        == png_ptr->trans_color.gray)
                      {
                         *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
-                        *sp |= (png_byte)(background->gray << shift);
+                        *sp |= (png_byte)(png_ptr->background.gray << shift);
                      }
 
                      if (!shift)
@@ -2845,10 +3536,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      for (i = 0; i < row_width; i++)
                      {
                         if ((png_uint_16)((*sp >> shift) & 0x03)
-                            == trans_color->gray)
+                            == png_ptr->trans_color.gray)
                         {
                            *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
-                           *sp |= (png_byte)(background->gray << shift);
+                           *sp |= (png_byte)(png_ptr->background.gray << shift);
                         }
 
                         else
@@ -2879,10 +3570,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      for (i = 0; i < row_width; i++)
                      {
                         if ((png_uint_16)((*sp >> shift) & 0x03)
-                            == trans_color->gray)
+                            == png_ptr->trans_color.gray)
                         {
                            *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
-                           *sp |= (png_byte)(background->gray << shift);
+                           *sp |= (png_byte)(png_ptr->background.gray << shift);
                         }
 
                         if (!shift)
@@ -2908,10 +3599,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      for (i = 0; i < row_width; i++)
                      {
                         if ((png_uint_16)((*sp >> shift) & 0x0f)
-                            == trans_color->gray)
+                            == png_ptr->trans_color.gray)
                         {
                            *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
-                           *sp |= (png_byte)(background->gray << shift);
+                           *sp |= (png_byte)(png_ptr->background.gray << shift);
                         }
 
                         else
@@ -2942,10 +3633,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      for (i = 0; i < row_width; i++)
                      {
                         if ((png_uint_16)((*sp >> shift) & 0x0f)
-                            == trans_color->gray)
+                            == png_ptr->trans_color.gray)
                         {
                            *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
-                           *sp |= (png_byte)(background->gray << shift);
+                           *sp |= (png_byte)(png_ptr->background.gray << shift);
                         }
 
                         if (!shift)
@@ -2969,8 +3660,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      sp = row;
                      for (i = 0; i < row_width; i++, sp++)
                      {
-                        if (*sp == trans_color->gray)
-                           *sp = (png_byte)background->gray;
+                        if (*sp == png_ptr->trans_color.gray)
+                           *sp = (png_byte)png_ptr->background.gray;
 
                         else
                            *sp = gamma_table[*sp];
@@ -2982,8 +3673,8 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      sp = row;
                      for (i = 0; i < row_width; i++, sp++)
                      {
-                        if (*sp == trans_color->gray)
-                           *sp = (png_byte)background->gray;
+                        if (*sp == png_ptr->trans_color.gray)
+                           *sp = (png_byte)png_ptr->background.gray;
                      }
                   }
                   break;
@@ -3001,11 +3692,11 @@ png_do_background(png_row_infop row_info, png_bytep row,
 
                         v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
 
-                        if (v == trans_color->gray)
+                        if (v == png_ptr->trans_color.gray)
                         {
                            /* Background is already in screen gamma */
-                           *sp = (png_byte)((background->gray >> 8) & 0xff);
-                           *(sp + 1) = (png_byte)(background->gray & 0xff);
+                           *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
+                           *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
                         }
 
                         else
@@ -3026,10 +3717,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
 
                         v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
 
-                        if (v == trans_color->gray)
+                        if (v == png_ptr->trans_color.gray)
                         {
-                           *sp = (png_byte)((background->gray >> 8) & 0xff);
-                           *(sp + 1) = (png_byte)(background->gray & 0xff);
+                           *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
+                           *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
                         }
                      }
                   }
@@ -3052,13 +3743,13 @@ png_do_background(png_row_infop row_info, png_bytep row,
                   sp = row;
                   for (i = 0; i < row_width; i++, sp += 3)
                   {
-                     if (*sp == trans_color->red &&
-                         *(sp + 1) == trans_color->green &&
-                         *(sp + 2) == trans_color->blue)
+                     if (*sp == png_ptr->trans_color.red &&
+                         *(sp + 1) == png_ptr->trans_color.green &&
+                         *(sp + 2) == png_ptr->trans_color.blue)
                      {
-                        *sp = (png_byte)background->red;
-                        *(sp + 1) = (png_byte)background->green;
-                        *(sp + 2) = (png_byte)background->blue;
+                        *sp = (png_byte)png_ptr->background.red;
+                        *(sp + 1) = (png_byte)png_ptr->background.green;
+                        *(sp + 2) = (png_byte)png_ptr->background.blue;
                      }
 
                      else
@@ -3075,13 +3766,13 @@ png_do_background(png_row_infop row_info, png_bytep row,
                   sp = row;
                   for (i = 0; i < row_width; i++, sp += 3)
                   {
-                     if (*sp == trans_color->red &&
-                         *(sp + 1) == trans_color->green &&
-                         *(sp + 2) == trans_color->blue)
+                     if (*sp == png_ptr->trans_color.red &&
+                         *(sp + 1) == png_ptr->trans_color.green &&
+                         *(sp + 2) == png_ptr->trans_color.blue)
                      {
-                        *sp = (png_byte)background->red;
-                        *(sp + 1) = (png_byte)background->green;
-                        *(sp + 2) = (png_byte)background->blue;
+                        *sp = (png_byte)png_ptr->background.red;
+                        *(sp + 1) = (png_byte)png_ptr->background.green;
+                        *(sp + 2) = (png_byte)png_ptr->background.blue;
                      }
                   }
                }
@@ -3102,16 +3793,17 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
                          + *(sp + 5));
 
-                     if (r == trans_color->red && g == trans_color->green &&
-                         b == trans_color->blue)
+                     if (r == png_ptr->trans_color.red &&
+                         g == png_ptr->trans_color.green &&
+                         b == png_ptr->trans_color.blue)
                      {
                         /* Background is already in screen gamma */
-                        *sp = (png_byte)((background->red >> 8) & 0xff);
-                        *(sp + 1) = (png_byte)(background->red & 0xff);
-                        *(sp + 2) = (png_byte)((background->green >> 8) & 0xff);
-                        *(sp + 3) = (png_byte)(background->green & 0xff);
-                        *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff);
-                        *(sp + 5) = (png_byte)(background->blue & 0xff);
+                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
+                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
+                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
+                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
+                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
                      }
 
                      else
@@ -3145,15 +3837,16 @@ png_do_background(png_row_infop row_info, png_bytep row,
                      png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
                          + *(sp + 5));
 
-                     if (r == trans_color->red && g == trans_color->green &&
-                         b == trans_color->blue)
+                     if (r == png_ptr->trans_color.red &&
+                         g == png_ptr->trans_color.green &&
+                         b == png_ptr->trans_color.blue)
                      {
-                        *sp = (png_byte)((background->red >> 8) & 0xff);
-                        *(sp + 1) = (png_byte)(background->red & 0xff);
-                        *(sp + 2) = (png_byte)((background->green >> 8) & 0xff);
-                        *(sp + 3) = (png_byte)(background->green & 0xff);
-                        *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff);
-                        *(sp + 5) = (png_byte)(background->blue & 0xff);
+                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
+                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
+                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
+                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
+                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
                      }
                   }
                }
@@ -3170,18 +3863,17 @@ png_do_background(png_row_infop row_info, png_bytep row,
                    gamma_table != NULL)
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 2, dp++)
+                  for (i = 0; i < row_width; i++, sp += 2)
                   {
                      png_uint_16 a = *(sp + 1);
 
                      if (a == 0xff)
-                        *dp = gamma_table[*sp];
+                        *sp = gamma_table[*sp];
 
                      else if (a == 0)
                      {
                         /* Background is already in screen gamma */
-                        *dp = (png_byte)background->gray;
+                        *sp = (png_byte)png_ptr->background.gray;
                      }
 
                      else
@@ -3189,8 +3881,10 @@ png_do_background(png_row_infop row_info, png_bytep row,
                         png_byte v, w;
 
                         v = gamma_to_1[*sp];
-                        png_composite(w, v, a, background_1->gray);
-                        *dp = gamma_from_1[w];
+                        png_composite(w, v, a, png_ptr->background_1.gray);
+                        if (!optimize)
+                           w = gamma_from_1[w];
+                        *sp = w;
                      }
                   }
                }
@@ -3198,24 +3892,15 @@ png_do_background(png_row_infop row_info, png_bytep row,
 #endif
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 2, dp++)
+                  for (i = 0; i < row_width; i++, sp += 2)
                   {
                      png_byte a = *(sp + 1);
 
-                     if (a == 0xff)
-                        *dp = *sp;
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-                     else if (a == 0)
-                        *dp = (png_byte)background->gray;
-
-                     else
-                        png_composite(*dp, *sp, a, background_1->gray);
+                     if (a == 0)
+                        *sp = (png_byte)png_ptr->background.gray;
 
-#else
-                     *dp = (png_byte)background->gray;
-#endif
+                     else if (a < 0xff)
+                        png_composite(*sp, *sp, a, png_ptr->background_1.gray);
                   }
                }
             }
@@ -3226,8 +3911,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
                    gamma_16_to_1 != NULL)
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 4, dp += 2)
+                  for (i = 0; i < row_width; i++, sp += 4)
                   {
                      png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
                          + *(sp + 3));
@@ -3237,69 +3921,56 @@ png_do_background(png_row_infop row_info, png_bytep row,
                         png_uint_16 v;
 
                         v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
-                        *dp = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(v & 0xff);
+                        *sp = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(v & 0xff);
                      }
 
-#ifdef PNG_READ_GAMMA_SUPPORTED
                      else if (a == 0)
-#else
-                     else
-#endif
                      {
                         /* Background is already in screen gamma */
-                        *dp = (png_byte)((background->gray >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(background->gray & 0xff);
+                        *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
                      }
 
-#ifdef PNG_READ_GAMMA_SUPPORTED
                      else
                      {
                         png_uint_16 g, v, w;
 
                         g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
-                        png_composite_16(v, g, a, background_1->gray);
-                        w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
-                        *dp = (png_byte)((w >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(w & 0xff);
+                        png_composite_16(v, g, a, png_ptr->background_1.gray);
+                        if (optimize)
+                           w = v;
+                        else
+                           w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
+                        *sp = (png_byte)((w >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(w & 0xff);
                      }
-#endif
                   }
                }
                else
 #endif
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 4, dp += 2)
+                  for (i = 0; i < row_width; i++, sp += 4)
                   {
                      png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)
                          + *(sp + 3));
 
-                     if (a == (png_uint_16)0xffff)
-                        png_memcpy(dp, sp, 2);
-
-#ifdef PNG_READ_GAMMA_SUPPORTED
-                     else if (a == 0)
-#else
-                     else
-#endif
+                     if (a == 0)
                      {
-                        *dp = (png_byte)((background->gray >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(background->gray & 0xff);
+                        *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);
                      }
 
-#ifdef PNG_READ_GAMMA_SUPPORTED
-                     else
+                     else if (a < 0xffff)
                      {
                         png_uint_16 g, v;
 
                         g = (png_uint_16)(((*sp) << 8) + *(sp + 1));
-                        png_composite_16(v, g, a, background_1->gray);
-                        *dp = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(v & 0xff);
+                        png_composite_16(v, g, a, png_ptr->background_1.gray);
+                        *sp = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(v & 0xff);
                      }
-#endif
                   }
                }
             }
@@ -3315,24 +3986,23 @@ png_do_background(png_row_infop row_info, png_bytep row,
                    gamma_table != NULL)
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 4, dp += 3)
+                  for (i = 0; i < row_width; i++, sp += 4)
                   {
                      png_byte a = *(sp + 3);
 
                      if (a == 0xff)
                      {
-                        *dp = gamma_table[*sp];
-                        *(dp + 1) = gamma_table[*(sp + 1)];
-                        *(dp + 2) = gamma_table[*(sp + 2)];
+                        *sp = gamma_table[*sp];
+                        *(sp + 1) = gamma_table[*(sp + 1)];
+                        *(sp + 2) = gamma_table[*(sp + 2)];
                      }
 
                      else if (a == 0)
                      {
                         /* Background is already in screen gamma */
-                        *dp = (png_byte)background->red;
-                        *(dp + 1) = (png_byte)background->green;
-                        *(dp + 2) = (png_byte)background->blue;
+                        *sp = (png_byte)png_ptr->background.red;
+                        *(sp + 1) = (png_byte)png_ptr->background.green;
+                        *(sp + 2) = (png_byte)png_ptr->background.blue;
                      }
 
                      else
@@ -3340,16 +4010,19 @@ png_do_background(png_row_infop row_info, png_bytep row,
                         png_byte v, w;
 
                         v = gamma_to_1[*sp];
-                        png_composite(w, v, a, background_1->red);
-                        *dp = gamma_from_1[w];
+                        png_composite(w, v, a, png_ptr->background_1.red);
+                        if (!optimize) w = gamma_from_1[w];
+                        *sp = w;
 
                         v = gamma_to_1[*(sp + 1)];
-                        png_composite(w, v, a, background_1->green);
-                        *(dp + 1) = gamma_from_1[w];
+                        png_composite(w, v, a, png_ptr->background_1.green);
+                        if (!optimize) w = gamma_from_1[w];
+                        *(sp + 1) = w;
 
                         v = gamma_to_1[*(sp + 2)];
-                        png_composite(w, v, a, background_1->blue);
-                        *(dp + 2) = gamma_from_1[w];
+                        png_composite(w, v, a, png_ptr->background_1.blue);
+                        if (!optimize) w = gamma_from_1[w];
+                        *(sp + 2) = w;
                      }
                   }
                }
@@ -3357,34 +4030,26 @@ png_do_background(png_row_infop row_info, png_bytep row,
 #endif
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 4, dp += 3)
+                  for (i = 0; i < row_width; i++, sp += 4)
                   {
                      png_byte a = *(sp + 3);
 
-                     if (a == 0xff)
-                     {
-                        *dp = *sp;
-                        *(dp + 1) = *(sp + 1);
-                        *(dp + 2) = *(sp + 2);
-                     }
-
-                     else if (a == 0)
+                     if (a == 0)
                      {
-                        *dp = (png_byte)background->red;
-                        *(dp + 1) = (png_byte)background->green;
-                        *(dp + 2) = (png_byte)background->blue;
+                        *sp = (png_byte)png_ptr->background.red;
+                        *(sp + 1) = (png_byte)png_ptr->background.green;
+                        *(sp + 2) = (png_byte)png_ptr->background.blue;
                      }
 
-                     else
+                     else if (a < 0xff)
                      {
-                        png_composite(*dp, *sp, a, background->red);
+                        png_composite(*sp, *sp, a, png_ptr->background.red);
 
-                        png_composite(*(dp + 1), *(sp + 1), a,
-                            background->green);
+                        png_composite(*(sp + 1), *(sp + 1), a,
+                            png_ptr->background.green);
 
-                        png_composite(*(dp + 2), *(sp + 2), a,
-                            background->blue);
+                        png_composite(*(sp + 2), *(sp + 2), a,
+                            png_ptr->background.blue);
                      }
                   }
                }
@@ -3396,8 +4061,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
                    gamma_16_to_1 != NULL)
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 8, dp += 6)
+                  for (i = 0; i < row_width; i++, sp += 8)
                   {
                      png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
                          << 8) + (png_uint_16)(*(sp + 7)));
@@ -3407,53 +4071,55 @@ png_do_background(png_row_infop row_info, png_bytep row,
                         png_uint_16 v;
 
                         v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
-                        *dp = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(v & 0xff);
+                        *sp = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(v & 0xff);
 
                         v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
-                        *(dp + 2) = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 3) = (png_byte)(v & 0xff);
+                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 3) = (png_byte)(v & 0xff);
 
                         v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
-                        *(dp + 4) = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 5) = (png_byte)(v & 0xff);
+                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 5) = (png_byte)(v & 0xff);
                      }
 
                      else if (a == 0)
                      {
                         /* Background is already in screen gamma */
-                        *dp = (png_byte)((background->red >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(background->red & 0xff);
-                        *(dp + 2) = (png_byte)((background->green >> 8) & 0xff);
-                        *(dp + 3) = (png_byte)(background->green & 0xff);
-                        *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff);
-                        *(dp + 5) = (png_byte)(background->blue & 0xff);
+                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
+                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
+                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
+                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
+                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
                      }
 
                      else
                      {
-                        png_uint_16 v, w, x;
+                        png_uint_16 v, w;
 
                         v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
-                        png_composite_16(w, v, a, background_1->red);
-
-                        x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
-                        *dp = (png_byte)((x >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(x & 0xff);
+                        png_composite_16(w, v, a, png_ptr->background_1.red);
+                        if (!optimize)
+                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
+                        *sp = (png_byte)((w >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(w & 0xff);
 
                         v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
-                        png_composite_16(w, v, a, background_1->green);
+                        png_composite_16(w, v, a, png_ptr->background_1.green);
+                        if (!optimize)
+                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
 
-                        x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
-                        *(dp + 2) = (png_byte)((x >> 8) & 0xff);
-                        *(dp + 3) = (png_byte)(x & 0xff);
+                        *(sp + 2) = (png_byte)((w >> 8) & 0xff);
+                        *(sp + 3) = (png_byte)(w & 0xff);
 
                         v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
-                        png_composite_16(w, v, a, background_1->blue);
+                        png_composite_16(w, v, a, png_ptr->background_1.blue);
+                        if (!optimize)
+                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
 
-                        x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8];
-                        *(dp + 4) = (png_byte)((x >> 8) & 0xff);
-                        *(dp + 5) = (png_byte)(x & 0xff);
+                        *(sp + 4) = (png_byte)((w >> 8) & 0xff);
+                        *(sp + 5) = (png_byte)(w & 0xff);
                      }
                   }
                }
@@ -3462,28 +4128,22 @@ png_do_background(png_row_infop row_info, png_bytep row,
 #endif
                {
                   sp = row;
-                  dp = row;
-                  for (i = 0; i < row_width; i++, sp += 8, dp += 6)
+                  for (i = 0; i < row_width; i++, sp += 8)
                   {
                      png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
                          << 8) + (png_uint_16)(*(sp + 7)));
 
-                     if (a == (png_uint_16)0xffff)
-                     {
-                        png_memcpy(dp, sp, 6);
-                     }
-
-                     else if (a == 0)
+                     if (a == 0)
                      {
-                        *dp = (png_byte)((background->red >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(background->red & 0xff);
-                        *(dp + 2) = (png_byte)((background->green >> 8) & 0xff);
-                        *(dp + 3) = (png_byte)(background->green & 0xff);
-                        *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff);
-                        *(dp + 5) = (png_byte)(background->blue & 0xff);
+                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);
+                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);
+                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);
+                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);
+                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);
                      }
 
-                     else
+                     else if (a < 0xffff)
                      {
                         png_uint_16 v;
 
@@ -3493,17 +4153,17 @@ png_do_background(png_row_infop row_info, png_bytep row,
                         png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
                             + *(sp + 5));
 
-                        png_composite_16(v, r, a, background->red);
-                        *dp = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 1) = (png_byte)(v & 0xff);
+                        png_composite_16(v, r, a, png_ptr->background.red);
+                        *sp = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 1) = (png_byte)(v & 0xff);
 
-                        png_composite_16(v, g, a, background->green);
-                        *(dp + 2) = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 3) = (png_byte)(v & 0xff);
+                        png_composite_16(v, g, a, png_ptr->background.green);
+                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 3) = (png_byte)(v & 0xff);
 
-                        png_composite_16(v, b, a, background->blue);
-                        *(dp + 4) = (png_byte)((v >> 8) & 0xff);
-                        *(dp + 5) = (png_byte)(v & 0xff);
+                        png_composite_16(v, b, a, png_ptr->background.blue);
+                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);
+                        *(sp + 5) = (png_byte)(v & 0xff);
                      }
                   }
                }
@@ -3514,19 +4174,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
          default:
             break;
       }
-
-      if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
-      {
-         row_info->color_type = (png_byte)(row_info->color_type &
-             ~PNG_COLOR_MASK_ALPHA);
-         row_info->channels--;
-         row_info->pixel_depth = (png_byte)(row_info->channels *
-             row_info->bit_depth);
-         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
-      }
    }
 }
-#endif
+#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */
 
 #ifdef PNG_READ_GAMMA_SUPPORTED
 /* Gamma correct the image, avoiding the alpha channel.  Make sure
@@ -3536,10 +4186,12 @@ png_do_background(png_row_infop row_info, png_bytep row,
  * build_gamma_table().
  */
 void /* PRIVATE */
-png_do_gamma(png_row_infop row_info, png_bytep row,
-    png_const_bytep gamma_table, png_const_uint_16pp gamma_16_table,
-    int gamma_shift)
+png_do_gamma(png_row_infop row_info, png_bytep row, png_structp png_ptr)
 {
+   png_const_bytep gamma_table = png_ptr->gamma_table;
+   png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table;
+   int gamma_shift = png_ptr->gamma_shift;
+
    png_bytep sp;
    png_uint_32 i;
    png_uint_32 row_width=row_info->width;
@@ -3729,6 +4381,73 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
 }
 #endif
 
+#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
+/* Encode the alpha channel to the output gamma (the input channel is always
+ * linear.)  Called only with color types that have an alpha channel.  Needs the
+ * from_1 tables.
+ */
+void /* PRIVATE */
+png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structp png_ptr)
+{
+   png_uint_32 row_width = row_info->width;
+
+   png_debug(1, "in png_do_encode_alpha");
+
+   if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
+   {
+      if (row_info->bit_depth == 8)
+      {
+         PNG_CONST png_bytep table = png_ptr->gamma_from_1;
+
+         if (table != NULL)
+         {
+            PNG_CONST int step =
+               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
+
+            /* The alpha channel is the last component: */
+            row += step - 1;
+
+            for (; row_width > 0; --row_width, row += step)
+               *row = table[*row];
+
+            return;
+         }
+      }
+
+      else if (row_info->bit_depth == 16)
+      {
+         PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1;
+         PNG_CONST int gamma_shift = png_ptr->gamma_shift;
+
+         if (table != NULL)
+         {
+            PNG_CONST int step =
+               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
+
+            /* The alpha channel is the last component: */
+            row += step - 2;
+
+            for (; row_width > 0; --row_width, row += step)
+            {
+               png_uint_16 v;
+
+               v = table[*(row + 1) >> gamma_shift][*row];
+               *row = (png_byte)((v >> 8) & 0xff);
+               *(row + 1) = (png_byte)(v & 0xff);
+            }
+
+            return;
+         }
+      }
+   }
+
+   /* Only get to here if called with a weird row_info; no harm has been done,
+    * so just issue a warning.
+    */
+   png_warning(png_ptr, "png_do_encode_alpha: unexpected call");
+}
+#endif
+
 #ifdef PNG_READ_EXPAND_SUPPORTED
 /* Expands a palette row to an RGB or RGBA row depending
  * upon whether you supply trans and num_trans.
@@ -3834,7 +4553,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
       if (row_info->bit_depth == 8)
       {
          {
-            if (trans_alpha != NULL)
+            if (num_trans > 0)
             {
                sp = row + (png_size_t)row_width - 1;
                dp = row + (png_size_t)(row_width << 2) - 1;
@@ -3888,7 +4607,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
  */
 void /* PRIVATE */
 png_do_expand(png_row_infop row_info, png_bytep row,
-    png_const_color_16p trans_value)
+    png_const_color_16p trans_color)
 {
    int shift, value;
    png_bytep sp, dp;
@@ -3900,7 +4619,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
    {
       if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
       {
-         png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0);
+         png_uint_16 gray = (png_uint_16)(trans_color ? trans_color->gray : 0);
 
          if (row_info->bit_depth < 8)
          {
@@ -3992,7 +4711,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
             row_info->rowbytes = row_width;
          }
 
-         if (trans_value != NULL)
+         if (trans_color != NULL)
          {
             if (row_info->bit_depth == 8)
             {
@@ -4044,13 +4763,13 @@ png_do_expand(png_row_infop row_info, png_bytep row,
                row_width);
          }
       }
-      else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value)
+      else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)
       {
          if (row_info->bit_depth == 8)
          {
-            png_byte red = (png_byte)(trans_value->red & 0xff);
-            png_byte green = (png_byte)(trans_value->green & 0xff);
-            png_byte blue = (png_byte)(trans_value->blue & 0xff);
+            png_byte red = (png_byte)(trans_color->red & 0xff);
+            png_byte green = (png_byte)(trans_color->green & 0xff);
+            png_byte blue = (png_byte)(trans_color->blue & 0xff);
             sp = row + (png_size_t)row_info->rowbytes - 1;
             dp = row + (png_size_t)(row_width << 2) - 1;
             for (i = 0; i < row_width; i++)
@@ -4068,12 +4787,12 @@ png_do_expand(png_row_infop row_info, png_bytep row,
          }
          else if (row_info->bit_depth == 16)
          {
-            png_byte red_high = (png_byte)((trans_value->red >> 8) & 0xff);
-            png_byte green_high = (png_byte)((trans_value->green >> 8) & 0xff);
-            png_byte blue_high = (png_byte)((trans_value->blue >> 8) & 0xff);
-            png_byte red_low = (png_byte)(trans_value->red & 0xff);
-            png_byte green_low = (png_byte)(trans_value->green & 0xff);
-            png_byte blue_low = (png_byte)(trans_value->blue & 0xff);
+            png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff);
+            png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff);
+            png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff);
+            png_byte red_low = (png_byte)(trans_color->red & 0xff);
+            png_byte green_low = (png_byte)(trans_color->green & 0xff);
+            png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
             sp = row + row_info->rowbytes - 1;
             dp = row + (png_size_t)(row_width << 3) - 1;
             for (i = 0; i < row_width; i++)
@@ -4113,7 +4832,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
 #endif
 
 #ifdef PNG_READ_EXPAND_16_SUPPORTED
-/* If the bit depth is 8 and the colour type is not a palette type expand the
+/* If the bit depth is 8 and the color type is not a palette type expand the
  * whole row to 16 bits.  Has no effect otherwise.
  */
 void /* PRIVATE */
@@ -4236,6 +4955,7 @@ png_do_quantize(png_row_infop row_info, png_bytep row,
    }
 }
 #endif /* PNG_READ_QUANTIZE_SUPPORTED */
+#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
 /* Undoes intrapixel differencing  */
@@ -4289,8 +5009,8 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
             png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);
             png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);
             png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);
-            png_uint_32 red  = (png_uint_32)((s0 + s1 + 65536L) & 0xffffL);
-            png_uint_32 blue = (png_uint_32)((s2 + s1 + 65536L) & 0xffffL);
+            png_uint_32 red  = (s0 + s1 + 65536) & 0xffff;
+            png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;
             *(rp    ) = (png_byte)((red >> 8) & 0xff);
             *(rp + 1) = (png_byte)(red & 0xff);
             *(rp + 4) = (png_byte)((blue >> 8) & 0xff);
index d4764317444f4ae85282c8e87d139329186971df..d6c0e0350f3d383d4bb01af470d9e0369860da82 100644 (file)
@@ -1,8 +1,8 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * Last changed in libpng 1.5.2 [March 31, 2011]
- * Copyright (c) 1998-2011 Glenn Randers-Pehrson
+ * Last changed in libpng 1.5.9 [February 18, 2012]
+ * Copyright (c) 1998-2012 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
@@ -87,10 +87,10 @@ png_int_32 (PNGAPI
 png_get_int_32)(png_const_bytep buf)
 {
    png_uint_32 uval = png_get_uint_32(buf);
-   if ((uval & 0x80000000L) == 0) /* non-negative */
+   if ((uval & 0x80000000) == 0) /* non-negative */
       return uval;
 
-   uval = (uval ^ 0xffffffffL) + 1;  /* 2's complement: -x = ~x+1 */
+   uval = (uval ^ 0xffffffff) + 1;  /* 2's complement: -x = ~x+1 */
    return -(png_int_32)uval;
 }
 
@@ -165,14 +165,14 @@ png_read_chunk_header(png_structp png_ptr)
    length = png_get_uint_31(png_ptr, buf);
 
    /* Put the chunk name into png_ptr->chunk_name. */
-   png_memcpy(png_ptr->chunk_name, buf + 4, 4);
+   png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
 
-   png_debug2(0, "Reading %s chunk, length = %u",
-       png_ptr->chunk_name, length);
+   png_debug2(0, "Reading %lx chunk, length = %lu",
+       (unsigned long)png_ptr->chunk_name, (unsigned long)length);
 
    /* Reset the crc and run it over the chunk name. */
    png_reset_crc(png_ptr);
-   png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
+   png_calculate_crc(png_ptr, buf + 4, 4);
 
    /* Check to see if chunk name is valid. */
    png_check_chunk_name(png_ptr, png_ptr->chunk_name);
@@ -218,10 +218,9 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
 
    if (png_crc_error(png_ptr))
    {
-      if (((png_ptr->chunk_name[0] & 0x20) &&                /* Ancillary */
-          !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) ||
-          (!(png_ptr->chunk_name[0] & 0x20) &&             /* Critical  */
-          (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE)))
+      if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name) ?
+          !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :
+          (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))
       {
          png_chunk_warning(png_ptr, "CRC error");
       }
@@ -248,14 +247,14 @@ png_crc_error(png_structp png_ptr)
    png_uint_32 crc;
    int need_crc = 1;
 
-   if (png_ptr->chunk_name[0] & 0x20)                     /* ancillary */
+   if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))
    {
       if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
           (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
          need_crc = 0;
    }
 
-   else                                                    /* critical */
+   else /* critical */
    {
       if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
          need_crc = 0;
@@ -278,8 +277,7 @@ png_crc_error(png_structp png_ptr)
       return (0);
 }
 
-#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \
-    defined(PNG_READ_iCCP_SUPPORTED)
+#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
 static png_size_t
 png_inflate(png_structp png_ptr, png_bytep data, png_size_t size,
     png_bytep output, png_size_t output_size)
@@ -303,7 +301,7 @@ png_inflate(png_structp png_ptr, png_bytep data, png_size_t size,
    {
       int ret, avail;
 
-      /* The setting of 'avail_in' used to be outside the loop, by setting it
+      /* The setting of 'avail_in' used to be outside the loop; by setting it
        * inside it is possible to chunk the input to zlib and simply rely on
        * zlib to advance the 'next_in' pointer.  This allows arbitrary amounts o
        * data to be passed through zlib at the unavoidable cost of requiring a
@@ -370,41 +368,31 @@ png_inflate(png_structp png_ptr, png_bytep data, png_size_t size,
        * and the error message is dumped into the uncompressed
        * buffer if available.
        */
+#     ifdef PNG_WARNINGS_SUPPORTED
       {
-         PNG_CONST char *msg;
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-         char umsg[52];
-#endif
+         png_const_charp msg;
+
          if (png_ptr->zstream.msg != 0)
             msg = png_ptr->zstream.msg;
 
-         else
+         else switch (ret)
          {
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-            switch (ret)
-            {
-               case Z_BUF_ERROR:
-                  msg = "Buffer error in compressed datastream in %s chunk";
-                  break;
-
-               case Z_DATA_ERROR:
-                  msg = "Data error in compressed datastream in %s chunk";
-                  break;
+            case Z_BUF_ERROR:
+               msg = "Buffer error in compressed datastream";
+               break;
 
-               default:
-                  msg = "Incomplete compressed datastream in %s chunk";
-                  break;
-            }
+            case Z_DATA_ERROR:
+               msg = "Data error in compressed datastream";
+               break;
 
-            png_snprintf(umsg, sizeof umsg, msg, png_ptr->chunk_name);
-            msg = umsg;
-#else
-            msg = "Damaged compressed datastream in chunk other than IDAT";
-#endif
+            default:
+               msg = "Incomplete compressed datastream";
+               break;
          }
 
-         png_warning(png_ptr, msg);
+         png_chunk_warning(png_ptr, msg);
       }
+#     endif
 
       /* 0 means an error - notice that this code simply ignores
        * zero length compressed chunks as a result.
@@ -438,21 +426,24 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
       png_size_t expanded_size = png_inflate(png_ptr,
           (png_bytep)(png_ptr->chunkdata + prefix_size),
           chunklength - prefix_size,
-          0,            /*output*/
-          0);           /*output size*/
+          0,            /* output */
+          0);           /* output size */
 
       /* Now check the limits on this chunk - if the limit fails the
        * compressed data will be removed, the prefix will remain.
        */
+      if (prefix_size >= (~(png_size_t)0) - 1 ||
+         expanded_size >= (~(png_size_t)0) - 1 - prefix_size
 #ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
-      if (png_ptr->user_chunk_malloc_max &&
+         || (png_ptr->user_chunk_malloc_max &&
           (prefix_size + expanded_size >= png_ptr->user_chunk_malloc_max - 1))
 #else
 #  ifdef PNG_USER_CHUNK_MALLOC_MAX
-      if ((PNG_USER_CHUNK_MALLOC_MAX > 0) &&
+         || ((PNG_USER_CHUNK_MALLOC_MAX > 0) &&
           prefix_size + expanded_size >= PNG_USER_CHUNK_MALLOC_MAX - 1)
 #  endif
 #endif
+         )
          png_warning(png_ptr, "Exceeded size limit while expanding chunk");
 
       /* If the size is zero either there was an error and a message
@@ -460,16 +451,11 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
        * and we have nothing to do - the code will exit through the
        * error case below.
        */
-#if defined(PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED) || \
-    defined(PNG_USER_CHUNK_MALLOC_MAX)
       else if (expanded_size > 0)
-#else
-      if (expanded_size > 0)
-#endif
       {
          /* Success (maybe) - really uncompress the chunk. */
          png_size_t new_size = 0;
-         png_charp text = png_malloc_warn(png_ptr,
+         png_charp text = (png_charp)png_malloc_warn(png_ptr,
              prefix_size + expanded_size + 1);
 
          if (text != NULL)
@@ -500,15 +486,9 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
 
    else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */
    {
-#ifdef PNG_STDIO_SUPPORTED
-      char umsg[50];
-
-      png_snprintf(umsg, sizeof umsg,
-          "Unknown zTXt compression type %d", comp_type);
-      png_warning(png_ptr, umsg);
-#else
-      png_warning(png_ptr, "Unknown zTXt compression type");
-#endif
+      PNG_WARNING_PARAMETERS(p)
+      png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_d, comp_type);
+      png_formatted_warning(png_ptr, p, "Unknown compression type @1");
 
       /* The recovery is to simply drop the data. */
    }
@@ -518,7 +498,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
     * amount of compressed data.
     */
    {
-      png_charp text = png_malloc_warn(png_ptr, prefix_size + 1);
+      png_charp text = (png_charp)png_malloc_warn(png_ptr, prefix_size + 1);
 
       if (text != NULL)
       {
@@ -536,7 +516,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
 
    *newlength = prefix_size;
 }
-#endif
+#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */
 
 /* Read and check the IDHR chunk */
 void /* PRIVATE */
@@ -844,14 +824,12 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 #  ifdef PNG_READ_sRGB_SUPPORTED
    if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
    {
-      if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
+      if (PNG_OUT_OF_RANGE(igamma, 45500, 500))
       {
-         png_warning(png_ptr,
-             "Ignoring incorrect gAMA value when sRGB is also present");
-
-#    ifdef PNG_CONSOLE_IO_SUPPORTED
-         fprintf(stderr, "gamma = (%d/100000)", (int)igamma);
-#    endif
+         PNG_WARNING_PARAMETERS(p)
+         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_fixed, igamma);
+         png_formatted_warning(png_ptr, p,
+             "Ignoring incorrect gAMA value @1 when sRGB is also present");
          return;
       }
    }
@@ -961,7 +939,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 
    else if (png_ptr->mode & PNG_HAVE_PLTE)
       /* Should be an error, but we can cope with it */
-      png_warning(png_ptr, "Missing PLTE before cHRM");
+      png_warning(png_ptr, "Out of place cHRM chunk");
 
    if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
 #  ifdef PNG_READ_sRGB_SUPPORTED
@@ -1013,28 +991,112 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    {
       if (PNG_OUT_OF_RANGE(x_white, 31270,  1000) ||
           PNG_OUT_OF_RANGE(y_white, 32900,  1000) ||
-          PNG_OUT_OF_RANGE(x_red,   64000L, 1000) ||
+          PNG_OUT_OF_RANGE(x_red,   64000 1000) ||
           PNG_OUT_OF_RANGE(y_red,   33000,  1000) ||
           PNG_OUT_OF_RANGE(x_green, 30000,  1000) ||
-          PNG_OUT_OF_RANGE(y_green, 60000L, 1000) ||
+          PNG_OUT_OF_RANGE(y_green, 60000 1000) ||
           PNG_OUT_OF_RANGE(x_blue,  15000,  1000) ||
           PNG_OUT_OF_RANGE(y_blue,   6000,  1000))
       {
-         png_warning(png_ptr,
-             "Ignoring incorrect cHRM value when sRGB is also present");
-
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-         fprintf(stderr, "wx=%d, wy=%d, rx=%d, ry=%d\n",
-             x_white, y_white, x_red, y_red);
-
-         fprintf(stderr, "gx=%d, gy=%d, bx=%d, by=%d\n",
-             x_green, y_green, x_blue, y_blue);
-#endif /* PNG_CONSOLE_IO_SUPPORTED */
+         PNG_WARNING_PARAMETERS(p)
+
+         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_fixed, x_white);
+         png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_fixed, y_white);
+         png_warning_parameter_signed(p, 3, PNG_NUMBER_FORMAT_fixed, x_red);
+         png_warning_parameter_signed(p, 4, PNG_NUMBER_FORMAT_fixed, y_red);
+         png_warning_parameter_signed(p, 5, PNG_NUMBER_FORMAT_fixed, x_green);
+         png_warning_parameter_signed(p, 6, PNG_NUMBER_FORMAT_fixed, y_green);
+         png_warning_parameter_signed(p, 7, PNG_NUMBER_FORMAT_fixed, x_blue);
+         png_warning_parameter_signed(p, 8, PNG_NUMBER_FORMAT_fixed, y_blue);
+
+         png_formatted_warning(png_ptr, p,
+             "Ignoring incorrect cHRM white(@1,@2) r(@3,@4)g(@5,@6)b(@7,@8) "
+             "when sRGB is also present");
       }
       return;
    }
 #endif /* PNG_READ_sRGB_SUPPORTED */
 
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+   /* Store the _white values as default coefficients for the rgb to gray
+    * operation if it is supported.  Check if the transform is already set to
+    * avoid destroying the transform values.
+    */
+   if (!png_ptr->rgb_to_gray_coefficients_set)
+   {
+      /* png_set_background has not been called and we haven't seen an sRGB
+       * chunk yet.  Find the XYZ of the three end points.
+       */
+      png_XYZ XYZ;
+      png_xy xy;
+
+      xy.redx = x_red;
+      xy.redy = y_red;
+      xy.greenx = x_green;
+      xy.greeny = y_green;
+      xy.bluex = x_blue;
+      xy.bluey = y_blue;
+      xy.whitex = x_white;
+      xy.whitey = y_white;
+
+      if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))
+      {
+         /* The success case, because XYZ_from_xy normalises to a reference
+          * white Y of 1.0 we just need to scale the numbers.  This should
+          * always work just fine. It is an internal error if this overflows.
+          */
+         {
+            png_fixed_point r, g, b;
+            if (png_muldiv(&r, XYZ.redY, 32768, PNG_FP_1) &&
+               r >= 0 && r <= 32768 &&
+               png_muldiv(&g, XYZ.greenY, 32768, PNG_FP_1) &&
+               g >= 0 && g <= 32768 &&
+               png_muldiv(&b, XYZ.blueY, 32768, PNG_FP_1) &&
+               b >= 0 && b <= 32768 &&
+               r+g+b <= 32769)
+            {
+               /* We allow 0 coefficients here.  r+g+b may be 32769 if two or
+                * all of the coefficients were rounded up.  Handle this by
+                * reducing the *largest* coefficient by 1; this matches the
+                * approach used for the default coefficients in pngrtran.c
+                */
+               int add = 0;
+
+               if (r+g+b > 32768)
+                  add = -1;
+               else if (r+g+b < 32768)
+                  add = 1;
+
+               if (add != 0)
+               {
+                  if (g >= r && g >= b)
+                     g += add;
+                  else if (r >= g && r >= b)
+                     r += add;
+                  else
+                     b += add;
+               }
+
+               /* Check for an internal error. */
+               if (r+g+b != 32768)
+                  png_error(png_ptr,
+                     "internal error handling cHRM coefficients");
+
+               png_ptr->rgb_to_gray_red_coeff   = (png_uint_16)r;
+               png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g;
+            }
+
+            /* This is a png_error at present even though it could be ignored -
+             * it should never happen, but it is important that if it does, the
+             * bug is fixed.
+             */
+            else
+               png_error(png_ptr, "internal error handling cHRM->XYZ");
+         }
+      }
+   }
+#endif
+
    png_set_cHRM_fixed(png_ptr, info_ptr, x_white, y_white, x_red, y_red,
       x_green, y_green, x_blue, y_blue);
 }
@@ -1094,13 +1156,15 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 #if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
    if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA))
    {
-      if (PNG_OUT_OF_RANGE(info_ptr->gamma, 45500L, 500))
+      if (PNG_OUT_OF_RANGE(info_ptr->gamma, 45500, 500))
       {
-         png_warning(png_ptr,
-             "Ignoring incorrect gAMA value when sRGB is also present");
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-         fprintf(stderr, "incorrect gamma=(%d/100000)\n", info_ptr->gamma);
-#endif
+         PNG_WARNING_PARAMETERS(p)
+
+         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_fixed,
+            info_ptr->gamma);
+
+         png_formatted_warning(png_ptr, p,
+             "Ignoring incorrect gAMA value @1 when sRGB is also present");
       }
    }
 #endif /* PNG_READ_gAMA_SUPPORTED */
@@ -1109,10 +1173,10 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
       if (PNG_OUT_OF_RANGE(info_ptr->x_white, 31270,  1000) ||
           PNG_OUT_OF_RANGE(info_ptr->y_white, 32900,  1000) ||
-          PNG_OUT_OF_RANGE(info_ptr->x_red,   64000L, 1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->x_red,   64000 1000) ||
           PNG_OUT_OF_RANGE(info_ptr->y_red,   33000,  1000) ||
           PNG_OUT_OF_RANGE(info_ptr->x_green, 30000,  1000) ||
-          PNG_OUT_OF_RANGE(info_ptr->y_green, 60000L, 1000) ||
+          PNG_OUT_OF_RANGE(info_ptr->y_green, 60000 1000) ||
           PNG_OUT_OF_RANGE(info_ptr->x_blue,  15000,  1000) ||
           PNG_OUT_OF_RANGE(info_ptr->y_blue,   6000,  1000))
       {
@@ -1121,6 +1185,47 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       }
 #endif /* PNG_READ_cHRM_SUPPORTED */
 
+   /* This is recorded for use when handling the cHRM chunk above.  An sRGB
+    * chunk unconditionally overwrites the coefficients for grayscale conversion
+    * too.
+    */
+   png_ptr->is_sRGB = 1;
+
+#  ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+      /* Don't overwrite user supplied values: */
+      if (!png_ptr->rgb_to_gray_coefficients_set)
+      {
+         /* These numbers come from the sRGB specification (or, since one has to
+          * pay much money to get a copy, the wikipedia sRGB page) the
+          * chromaticity values quoted have been inverted to get the reverse
+          * transformation from RGB to XYZ and the 'Y' coefficients scaled by
+          * 32768 (then rounded).
+          *
+          * sRGB and ITU Rec-709 both truncate the values for the D65 white
+          * point to four digits and, even though it actually stores five
+          * digits, the PNG spec gives the truncated value.
+          *
+          * This means that when the chromaticities are converted back to XYZ
+          * end points we end up with (6968,23435,2366), which, as described in
+          * pngrtran.c, would overflow.  If the five digit precision and up is
+          * used we get, instead:
+          *
+          *    6968*R + 23435*G + 2365*B
+          *
+          * (Notice that this rounds the blue coefficient down, rather than the
+          * choice used in pngrtran.c which is to round the green one down.)
+          */
+         png_ptr->rgb_to_gray_red_coeff   =  6968; /* 0.212639005871510 */
+         png_ptr->rgb_to_gray_green_coeff = 23434; /* 0.715168678767756 */
+         /* png_ptr->rgb_to_gray_blue_coeff  =  2366; 0.072192315360734        */
+
+         /* The following keeps the cHRM chunk from destroying the
+          * coefficients again in the event that it follows the sRGB chunk.
+          */
+         png_ptr->rgb_to_gray_coefficients_set = 1;
+      }
+#  endif
+
    png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);
 }
 #endif /* PNG_READ_sRGB_SUPPORTED */
@@ -1172,7 +1277,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 
    png_free(png_ptr, png_ptr->chunkdata);
    png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
-   slength = (png_size_t)length;
+   slength = length;
    png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
 
    if (png_crc_finish(png_ptr, skip))
@@ -1240,23 +1345,15 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    /* And the following guarantees that profile_size == profile_length. */
    if (profile_size > profile_length)
    {
+      PNG_WARNING_PARAMETERS(p)
+
       png_free(png_ptr, png_ptr->chunkdata);
       png_ptr->chunkdata = NULL;
-#ifdef PNG_STDIO_SUPPORTED
-      {
-         char umsg[80];
-
-         png_snprintf2(umsg, 80,
-             "Ignoring iCCP chunk with declared size = %u "
-              "and actual length = %u",
-              (unsigned int) profile_size,
-              (unsigned int) profile_length);
-         png_warning(png_ptr, umsg);
-      }
-#else
-      png_warning(png_ptr,
-         "Ignoring iCCP chunk with uncompressed size mismatch");
-#endif
+
+      png_warning_parameter_unsigned(p, 1, PNG_NUMBER_FORMAT_u, profile_size);
+      png_warning_parameter_unsigned(p, 2, PNG_NUMBER_FORMAT_u, profile_length);
+      png_formatted_warning(png_ptr, p,
+         "Ignoring iCCP chunk with declared size = @1 and actual length = @2");
       return;
    }
 
@@ -1330,7 +1427,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
     * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a
     * potential breakage point if the types in pngconf.h aren't exactly right.
     */
-   slength = (png_size_t)length;
+   slength = length;
    png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
 
    if (png_crc_finish(png_ptr, skip))
@@ -1565,6 +1662,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 {
    png_size_t truelen;
    png_byte buf[6];
+   png_color_16 background;
 
    png_debug(1, "in png_handle_bKGD");
 
@@ -1621,7 +1719,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
     */
    if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
    {
-      png_ptr->background.index = buf[0];
+      background.index = buf[0];
 
       if (info_ptr && info_ptr->num_palette)
       {
@@ -1631,33 +1729,36 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
             return;
          }
 
-         png_ptr->background.red =
-             (png_uint_16)png_ptr->palette[buf[0]].red;
+         background.red = (png_uint_16)png_ptr->palette[buf[0]].red;
+         background.green = (png_uint_16)png_ptr->palette[buf[0]].green;
+         background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue;
+      }
 
-         png_ptr->background.green =
-             (png_uint_16)png_ptr->palette[buf[0]].green;
+      else
+         background.red = background.green = background.blue = 0;
 
-         png_ptr->background.blue =
-             (png_uint_16)png_ptr->palette[buf[0]].blue;
-      }
+      background.gray = 0;
    }
 
    else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */
    {
-      png_ptr->background.red =
-      png_ptr->background.green =
-      png_ptr->background.blue =
-      png_ptr->background.gray = png_get_uint_16(buf);
+      background.index = 0;
+      background.red =
+      background.green =
+      background.blue =
+      background.gray = png_get_uint_16(buf);
    }
 
    else
    {
-      png_ptr->background.red = png_get_uint_16(buf);
-      png_ptr->background.green = png_get_uint_16(buf + 2);
-      png_ptr->background.blue = png_get_uint_16(buf + 4);
+      background.index = 0;
+      background.red = png_get_uint_16(buf);
+      background.green = png_get_uint_16(buf + 2);
+      background.blue = png_get_uint_16(buf + 4);
+      background.gray = 0;
    }
 
-   png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background));
+   png_set_bKGD(png_ptr, info_ptr, &background);
 }
 #endif
 
@@ -1853,7 +1954,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       return;
    }
 
-   slength = (png_size_t)length;
+   slength = length;
    png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
 
    if (png_crc_finish(png_ptr, 0))
@@ -1982,6 +2083,14 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       return;
    }
 
+   /* Need unit type, width, \0, height: minimum 4 bytes */
+   else if (length < 4)
+   {
+      png_warning(png_ptr, "sCAL chunk too short");
+      png_crc_finish(png_ptr, length);
+      return;
+   }
+
    png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)",
       length + 1);
 
@@ -1994,7 +2103,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       return;
    }
 
-   slength = (png_size_t)length;
+   slength = length;
    png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */
 
@@ -2017,23 +2126,29 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    /* Validate the ASCII numbers, need two ASCII numbers separated by
     * a '\0' and they need to fit exactly in the chunk data.
     */
-   i = 0;
+   i = 1;
    state = 0;
 
-   if (png_ptr->chunkdata[1] == 45 /* negative width */ ||
-       !png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
+   if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
        i >= slength || png_ptr->chunkdata[i++] != 0)
       png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format");
 
+   else if (!PNG_FP_IS_POSITIVE(state))
+      png_warning(png_ptr, "Invalid sCAL chunk ignored: non-positive width");
+
    else
    {
       png_size_t heighti = i;
 
-      if (png_ptr->chunkdata[i] == 45 /* negative height */ ||
-          !png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
+      state = 0;
+      if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
           i != slength)
          png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format");
 
+      else if (!PNG_FP_IS_POSITIVE(state))
+         png_warning(png_ptr,
+            "Invalid sCAL chunk ignored: non-positive height");
+
       else
          /* This is the (only) success case. */
          png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0],
@@ -2148,7 +2263,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
      return;
    }
 
-   slength = (png_size_t)length;
+   slength = length;
    png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
 
    if (png_crc_finish(png_ptr, skip))
@@ -2256,7 +2371,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       return;
    }
 
-   slength = (png_size_t)length;
+   slength = length;
    png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
 
    if (png_crc_finish(png_ptr, 0))
@@ -2387,7 +2502,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       return;
    }
 
-   slength = (png_size_t)length;
+   slength = length;
    png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
 
    if (png_crc_finish(png_ptr, 0))
@@ -2423,6 +2538,14 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       comp_type = *lang++;
    }
 
+   if (comp_type || (comp_flag && comp_flag != PNG_TEXT_COMPRESSION_zTXt))
+   {
+      png_warning(png_ptr, "Unknown iTXt compression type or method");
+      png_free(png_ptr, png_ptr->chunkdata);
+      png_ptr->chunkdata = NULL;
+      return;
+   }
+
    for (lang_key = lang; *lang_key; lang_key++)
       /* Empty loop */ ;
 
@@ -2523,16 +2646,14 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 
    if (png_ptr->mode & PNG_HAVE_IDAT)
    {
-      PNG_IDAT;
-
-      if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))  /* Not an IDAT */
+      if (png_ptr->chunk_name != png_IDAT)
          png_ptr->mode |= PNG_AFTER_IDAT;
    }
 
-   if (!(png_ptr->chunk_name[0] & 0x20))
+   if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
    {
 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-      if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+      if (png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name) !=
           PNG_HANDLE_CHUNK_ALWAYS
 #ifdef PNG_READ_USER_CHUNKS_SUPPORTED
           && png_ptr->read_user_chunk_fn == NULL
@@ -2550,21 +2671,20 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
        )
    {
 #ifdef PNG_MAX_MALLOC_64K
-      if (length > (png_uint_32)65535L)
+      if (length > 65535)
       {
          png_warning(png_ptr, "unknown chunk too large to fit in memory");
-         skip = length - (png_uint_32)65535L;
-         length = (png_uint_32)65535L;
+         skip = length - 65535;
+         length = 65535;
       }
 #endif
 
-      png_memcpy((png_charp)png_ptr->unknown_chunk.name,
-          (png_charp)png_ptr->chunk_name,
-          png_sizeof(png_ptr->unknown_chunk.name));
-
-      png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]
-          = '\0';
-
+      /* TODO: this code is very close to the unknown handling in pngpread.c,
+       * maybe it can be put into a common utility routine?
+       * png_struct::unknown_chunk is just used as a temporary variable, along
+       * with the data into which the chunk is read.  These can be eliminated.
+       */
+      PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
       png_ptr->unknown_chunk.size = (png_size_t)length;
 
       if (length == 0)
@@ -2573,7 +2693,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
       else
       {
          png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
-         png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
+         png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length);
       }
 
 #ifdef PNG_READ_USER_CHUNKS_SUPPORTED
@@ -2590,10 +2710,10 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 
          if (ret == 0)
          {
-            if (!(png_ptr->chunk_name[0] & 0x20))
+            if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
             {
 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-               if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
+               if (png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name) !=
                    PNG_HANDLE_CHUNK_ALWAYS)
 #endif
                   png_chunk_error(png_ptr, "unknown critical chunk");
@@ -2630,259 +2750,523 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
  * the chunk name itself is valid.
  */
 
-#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
+/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is:
+ *
+ * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
+ */
 
 void /* PRIVATE */
-png_check_chunk_name(png_structp png_ptr, png_const_bytep chunk_name)
+png_check_chunk_name(png_structp png_ptr, png_uint_32 chunk_name)
 {
+   int i;
+
    png_debug(1, "in png_check_chunk_name");
-   if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) ||
-       isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3]))
+
+   for (i=1; i<=4; ++i)
    {
-      png_chunk_error(png_ptr, "invalid chunk type");
+      int c = chunk_name & 0xff;
+
+      if (c < 65 || c > 122 || (c > 90 && c < 97))
+         png_chunk_error(png_ptr, "invalid chunk type");
+
+      chunk_name >>= 8;
    }
 }
 
-/* Combines the row recently read in with the existing pixels in the
- * row.  This routine takes care of alpha and transparency if requested.
- * This routine also handles the two methods of progressive display
- * of interlaced images, depending on the mask value.
- * The mask value describes which pixels are to be combined with
- * the row.  The pattern always repeats every 8 pixels, so just 8
- * bits are needed.  A one indicates the pixel is to be combined,
- * a zero indicates the pixel is to be skipped.  This is in addition
- * to any alpha or transparency value associated with the pixel.  If
- * you want all pixels to be combined, pass 0xff (255) in mask.
+/* Combines the row recently read in with the existing pixels in the row.  This
+ * routine takes care of alpha and transparency if requested.  This routine also
+ * handles the two methods of progressive display of interlaced images,
+ * depending on the 'display' value; if 'display' is true then the whole row
+ * (dp) is filled from the start by replicating the available pixels.  If
+ * 'display' is false only those pixels present in the pass are filled in.
  */
-
 void /* PRIVATE */
-png_combine_row(png_structp png_ptr, png_bytep row, int mask)
+png_combine_row(png_structp png_ptr, png_bytep dp, int display)
 {
+   unsigned int pixel_depth = png_ptr->transformed_pixel_depth;
+   png_const_bytep sp = png_ptr->row_buf + 1;
+   png_uint_32 row_width = png_ptr->width;
+   unsigned int pass = png_ptr->pass;
+   png_bytep end_ptr = 0;
+   png_byte end_byte = 0;
+   unsigned int end_mask;
+
    png_debug(1, "in png_combine_row");
 
-   if (mask == 0xff)
+   /* Added in 1.5.6: it should not be possible to enter this routine until at
+    * least one row has been read from the PNG data and transformed.
+    */
+   if (pixel_depth == 0)
+      png_error(png_ptr, "internal row logic error");
+
+   /* Added in 1.5.4: the pixel depth should match the information returned by
+    * any call to png_read_update_info at this point.  Do not continue if we got
+    * this wrong.
+    */
+   if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes !=
+          PNG_ROWBYTES(pixel_depth, row_width))
+      png_error(png_ptr, "internal row size calculation error");
+
+   /* Don't expect this to ever happen: */
+   if (row_width == 0)
+      png_error(png_ptr, "internal row width error");
+
+   /* Preserve the last byte in cases where only part of it will be overwritten,
+    * the multiply below may overflow, we don't care because ANSI-C guarantees
+    * we get the low bits.
+    */
+   end_mask = (pixel_depth * row_width) & 7;
+   if (end_mask != 0)
    {
-      png_memcpy(row, png_ptr->row_buf + 1,
-          PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width));
+      /* end_ptr == NULL is a flag to say do nothing */
+      end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1;
+      end_byte = *end_ptr;
+#     ifdef PNG_READ_PACKSWAP_SUPPORTED
+         if (png_ptr->transformations & PNG_PACKSWAP) /* little-endian byte */
+            end_mask = 0xff << end_mask;
+
+         else /* big-endian byte */
+#     endif
+         end_mask = 0xff >> end_mask;
+      /* end_mask is now the bits to *keep* from the destination row */
    }
 
-   else
+   /* For non-interlaced images this reduces to a png_memcpy(). A png_memcpy()
+    * will also happen if interlacing isn't supported or if the application
+    * does not call png_set_interlace_handling().  In the latter cases the
+    * caller just gets a sequence of the unexpanded rows from each interlace
+    * pass.
+    */
+#ifdef PNG_READ_INTERLACING_SUPPORTED
+   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE) &&
+      pass < 6 && (display == 0 ||
+      /* The following copies everything for 'display' on passes 0, 2 and 4. */
+      (display == 1 && (pass & 1) != 0)))
    {
-      switch (png_ptr->row_info.pixel_depth)
-      {
-         case 1:
-         {
-            png_bytep sp = png_ptr->row_buf + 1;
-            png_bytep dp = row;
-            int s_inc, s_start, s_end;
-            int m = 0x80;
-            int shift;
-            png_uint_32 i;
-            png_uint_32 row_width = png_ptr->width;
-
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
-            if (png_ptr->transformations & PNG_PACKSWAP)
-            {
-                s_start = 0;
-                s_end = 7;
-                s_inc = 1;
-            }
+      /* Narrow images may have no bits in a pass; the caller should handle
+       * this, but this test is cheap:
+       */
+      if (row_width <= PNG_PASS_START_COL(pass))
+         return;
 
-            else
-#endif
-            {
-                s_start = 7;
-                s_end = 0;
-                s_inc = -1;
-            }
+      if (pixel_depth < 8)
+      {
+         /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit
+          * into 32 bits, then a single loop over the bytes using the four byte
+          * values in the 32-bit mask can be used.  For the 'display' option the
+          * expanded mask may also not require any masking within a byte.  To
+          * make this work the PACKSWAP option must be taken into account - it
+          * simply requires the pixels to be reversed in each byte.
+          *
+          * The 'regular' case requires a mask for each of the first 6 passes,
+          * the 'display' case does a copy for the even passes in the range
+          * 0..6.  This has already been handled in the test above.
+          *
+          * The masks are arranged as four bytes with the first byte to use in
+          * the lowest bits (little-endian) regardless of the order (PACKSWAP or
+          * not) of the pixels in each byte.
+          *
+          * NOTE: the whole of this logic depends on the caller of this function
+          * only calling it on rows appropriate to the pass.  This function only
+          * understands the 'x' logic; the 'y' logic is handled by the caller.
+          *
+          * The following defines allow generation of compile time constant bit
+          * masks for each pixel depth and each possibility of swapped or not
+          * swapped bytes.  Pass 'p' is in the range 0..6; 'x', a pixel index,
+          * is in the range 0..7; and the result is 1 if the pixel is to be
+          * copied in the pass, 0 if not.  'S' is for the sparkle method, 'B'
+          * for the block method.
+          *
+          * With some compilers a compile time expression of the general form:
+          *
+          *    (shift >= 32) ? (a >> (shift-32)) : (b >> shift)
+          *
+          * Produces warnings with values of 'shift' in the range 33 to 63
+          * because the right hand side of the ?: expression is evaluated by
+          * the compiler even though it isn't used.  Microsoft Visual C (various
+          * versions) and the Intel C compiler are known to do this.  To avoid
+          * this the following macros are used in 1.5.6.  This is a temporary
+          * solution to avoid destabilizing the code during the release process.
+          */
+#        if PNG_USE_COMPILE_TIME_MASKS
+#           define PNG_LSR(x,s) ((x)>>((s) & 0x1f))
+#           define PNG_LSL(x,s) ((x)<<((s) & 0x1f))
+#        else
+#           define PNG_LSR(x,s) ((x)>>(s))
+#           define PNG_LSL(x,s) ((x)<<(s))
+#        endif
+#        define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\
+           PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1)
+#        define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\
+           PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1)
+
+         /* Return a mask for pass 'p' pixel 'x' at depth 'd'.  The mask is
+          * little endian - the first pixel is at bit 0 - however the extra
+          * parameter 's' can be set to cause the mask position to be swapped
+          * within each byte, to match the PNG format.  This is done by XOR of
+          * the shift with 7, 6 or 4 for bit depths 1, 2 and 4.
+          */
+#        define PIXEL_MASK(p,x,d,s) \
+            (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0))))
 
-            shift = s_start;
+         /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask.
+          */
+#        define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
+#        define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
 
-            for (i = 0; i < row_width; i++)
-            {
-               if (m & mask)
-               {
-                  int value;
+         /* Combine 8 of these to get the full mask.  For the 1-bpp and 2-bpp
+          * cases the result needs replicating, for the 4-bpp case the above
+          * generates a full 32 bits.
+          */
+#        define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1)))
 
-                  value = (*sp >> shift) & 0x01;
-                  *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
-                  *dp |= (png_byte)(value << shift);
-               }
+#        define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\
+            S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\
+            S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d)
 
-               if (shift == s_end)
-               {
-                  shift = s_start;
-                  sp++;
-                  dp++;
-               }
+#        define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\
+            B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\
+            B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d)
 
-               else
-                  shift += s_inc;
+#if PNG_USE_COMPILE_TIME_MASKS
+         /* Utility macros to construct all the masks for a depth/swap
+          * combination.  The 's' parameter says whether the format is PNG
+          * (big endian bytes) or not.  Only the three odd-numbered passes are
+          * required for the display/block algorithm.
+          */
+#        define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\
+            S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }
 
-               if (m == 1)
-                  m = 0x80;
+#        define B_MASKS(d,s) { B_MASK(1,d,s), S_MASK(3,d,s), S_MASK(5,d,s) }
 
-               else
-                  m >>= 1;
-            }
-            break;
-         }
+#        define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2))
 
-         case 2:
+         /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and
+          * then pass:
+          */
+         static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
          {
-            png_bytep sp = png_ptr->row_buf + 1;
-            png_bytep dp = row;
-            int s_start, s_end, s_inc;
-            int m = 0x80;
-            int shift;
-            png_uint_32 i;
-            png_uint_32 row_width = png_ptr->width;
-            int value;
+            /* Little-endian byte masks for PACKSWAP */
+            { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },
+            /* Normal (big-endian byte) masks - PNG format */
+            { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) }
+         };
+
+         /* display_mask has only three entries for the odd passes, so index by
+          * pass>>1.
+          */
+         static PNG_CONST png_uint_32 display_mask[2][3][3] =
+         {
+            /* Little-endian byte masks for PACKSWAP */
+            { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },
+            /* Normal (big-endian byte) masks - PNG format */
+            { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) }
+         };
+
+#        define MASK(pass,depth,display,png)\
+            ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\
+               row_mask[png][DEPTH_INDEX(depth)][pass])
+
+#else /* !PNG_USE_COMPILE_TIME_MASKS */
+         /* This is the runtime alternative: it seems unlikely that this will
+          * ever be either smaller or faster than the compile time approach.
+          */
+#        define MASK(pass,depth,display,png)\
+            ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))
+#endif /* !PNG_USE_COMPILE_TIME_MASKS */
+
+         /* Use the appropriate mask to copy the required bits.  In some cases
+          * the byte mask will be 0 or 0xff, optimize these cases.  row_width is
+          * the number of pixels, but the code copies bytes, so it is necessary
+          * to special case the end.
+          */
+         png_uint_32 pixels_per_byte = 8 / pixel_depth;
+         png_uint_32 mask;
 
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
+#        ifdef PNG_READ_PACKSWAP_SUPPORTED
             if (png_ptr->transformations & PNG_PACKSWAP)
-            {
-               s_start = 0;
-               s_end = 6;
-               s_inc = 2;
-            }
+               mask = MASK(pass, pixel_depth, display, 0);
 
             else
-#endif
+#        endif
+            mask = MASK(pass, pixel_depth, display, 1);
+
+         for (;;)
+         {
+            png_uint_32 m;
+
+            /* It doesn't matter in the following if png_uint_32 has more than
+             * 32 bits because the high bits always match those in m<<24; it is,
+             * however, essential to use OR here, not +, because of this.
+             */
+            m = mask;
+            mask = (m >> 8) | (m << 24); /* rotate right to good compilers */
+            m &= 0xff;
+
+            if (m != 0) /* something to copy */
             {
-               s_start = 6;
-               s_end = 0;
-               s_inc = -2;
+               if (m != 0xff)
+                  *dp = (png_byte)((*dp & ~m) | (*sp & m));
+               else
+                  *dp = *sp;
             }
 
-            shift = s_start;
+            /* NOTE: this may overwrite the last byte with garbage if the image
+             * is not an exact number of bytes wide; libpng has always done
+             * this.
+             */
+            if (row_width <= pixels_per_byte)
+               break; /* May need to restore part of the last byte */
 
-            for (i = 0; i < row_width; i++)
-            {
-               if (m & mask)
-               {
-                  value = (*sp >> shift) & 0x03;
-                  *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
-                  *dp |= (png_byte)(value << shift);
-               }
+            row_width -= pixels_per_byte;
+            ++dp;
+            ++sp;
+         }
+      }
 
-               if (shift == s_end)
-               {
-                  shift = s_start;
-                  sp++;
-                  dp++;
-               }
+      else /* pixel_depth >= 8 */
+      {
+         unsigned int bytes_to_copy, bytes_to_jump;
 
-               else
-                  shift += s_inc;
+         /* Validate the depth - it must be a multiple of 8 */
+         if (pixel_depth & 7)
+            png_error(png_ptr, "invalid user transform pixel depth");
 
-               if (m == 1)
-                  m = 0x80;
+         pixel_depth >>= 3; /* now in bytes */
+         row_width *= pixel_depth;
 
-               else
-                  m >>= 1;
-            }
-            break;
+         /* Regardless of pass number the Adam 7 interlace always results in a
+          * fixed number of pixels to copy then to skip.  There may be a
+          * different number of pixels to skip at the start though.
+          */
+         {
+            unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth;
+
+            row_width -= offset;
+            dp += offset;
+            sp += offset;
          }
 
-         case 4:
+         /* Work out the bytes to copy. */
+         if (display)
          {
-            png_bytep sp = png_ptr->row_buf + 1;
-            png_bytep dp = row;
-            int s_start, s_end, s_inc;
-            int m = 0x80;
-            int shift;
-            png_uint_32 i;
-            png_uint_32 row_width = png_ptr->width;
-            int value;
+            /* When doing the 'block' algorithm the pixel in the pass gets
+             * replicated to adjacent pixels.  This is why the even (0,2,4,6)
+             * passes are skipped above - the entire expanded row is copied.
+             */
+            bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth;
 
-#ifdef PNG_READ_PACKSWAP_SUPPORTED
-            if (png_ptr->transformations & PNG_PACKSWAP)
-            {
-               s_start = 0;
-               s_end = 4;
-               s_inc = 4;
-            }
+            /* But don't allow this number to exceed the actual row width. */
+            if (bytes_to_copy > row_width)
+               bytes_to_copy = row_width;
+         }
 
-            else
-#endif
-            {
-               s_start = 4;
-               s_end = 0;
-               s_inc = -4;
-            }
-            shift = s_start;
+         else /* normal row; Adam7 only ever gives us one pixel to copy. */
+            bytes_to_copy = pixel_depth;
 
-            for (i = 0; i < row_width; i++)
-            {
-               if (m & mask)
+         /* In Adam7 there is a constant offset between where the pixels go. */
+         bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth;
+
+         /* And simply copy these bytes.  Some optimization is possible here,
+          * depending on the value of 'bytes_to_copy'.  Special case the low
+          * byte counts, which we know to be frequent.
+          *
+          * Notice that these cases all 'return' rather than 'break' - this
+          * avoids an unnecessary test on whether to restore the last byte
+          * below.
+          */
+         switch (bytes_to_copy)
+         {
+            case 1:
+               for (;;)
                {
-                  value = (*sp >> shift) & 0xf;
-                  *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
-                  *dp |= (png_byte)(value << shift);
+                  *dp = *sp;
+
+                  if (row_width <= bytes_to_jump)
+                     return;
+
+                  dp += bytes_to_jump;
+                  sp += bytes_to_jump;
+                  row_width -= bytes_to_jump;
                }
 
-               if (shift == s_end)
+            case 2:
+               /* There is a possibility of a partial copy at the end here; this
+                * slows the code down somewhat.
+                */
+               do
                {
-                  shift = s_start;
-                  sp++;
-                  dp++;
+                  dp[0] = sp[0], dp[1] = sp[1];
+
+                  if (row_width <= bytes_to_jump)
+                     return;
+
+                  sp += bytes_to_jump;
+                  dp += bytes_to_jump;
+                  row_width -= bytes_to_jump;
                }
+               while (row_width > 1);
 
-               else
-                  shift += s_inc;
+               /* And there can only be one byte left at this point: */
+               *dp = *sp;
+               return;
 
-               if (m == 1)
-                  m = 0x80;
+            case 3:
+               /* This can only be the RGB case, so each copy is exactly one
+                * pixel and it is not necessary to check for a partial copy.
+                */
+               for(;;)
+               {
+                  dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];
 
-               else
-                  m >>= 1;
-            }
-            break;
-         }
+                  if (row_width <= bytes_to_jump)
+                     return;
 
-         default:
-         {
-            png_bytep sp = png_ptr->row_buf + 1;
-            png_bytep dp = row;
-            png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
-            png_uint_32 i;
-            png_uint_32 row_width = png_ptr->width;
-            png_byte m = 0x80;
+                  sp += bytes_to_jump;
+                  dp += bytes_to_jump;
+                  row_width -= bytes_to_jump;
+               }
 
-            for (i = 0; i < row_width; i++)
-            {
-               if (m & mask)
+            default:
+#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE
+               /* Check for double byte alignment and, if possible, use a
+                * 16-bit copy.  Don't attempt this for narrow images - ones that
+                * are less than an interlace panel wide.  Don't attempt it for
+                * wide bytes_to_copy either - use the png_memcpy there.
+                */
+               if (bytes_to_copy < 16 /*else use png_memcpy*/ &&
+                  png_isaligned(dp, png_uint_16) &&
+                  png_isaligned(sp, png_uint_16) &&
+                  bytes_to_copy % sizeof (png_uint_16) == 0 &&
+                  bytes_to_jump % sizeof (png_uint_16) == 0)
                {
-                  png_memcpy(dp, sp, pixel_bytes);
+                  /* Everything is aligned for png_uint_16 copies, but try for
+                   * png_uint_32 first.
+                   */
+                  if (png_isaligned(dp, png_uint_32) &&
+                     png_isaligned(sp, png_uint_32) &&
+                     bytes_to_copy % sizeof (png_uint_32) == 0 &&
+                     bytes_to_jump % sizeof (png_uint_32) == 0)
+                  {
+                     png_uint_32p dp32 = (png_uint_32p)dp;
+                     png_const_uint_32p sp32 = (png_const_uint_32p)sp;
+                     unsigned int skip = (bytes_to_jump-bytes_to_copy) /
+                        sizeof (png_uint_32);
+
+                     do
+                     {
+                        size_t c = bytes_to_copy;
+                        do
+                        {
+                           *dp32++ = *sp32++;
+                           c -= sizeof (png_uint_32);
+                        }
+                        while (c > 0);
+
+                        if (row_width <= bytes_to_jump)
+                           return;
+
+                        dp32 += skip;
+                        sp32 += skip;
+                        row_width -= bytes_to_jump;
+                     }
+                     while (bytes_to_copy <= row_width);
+
+                     /* Get to here when the row_width truncates the final copy.
+                      * There will be 1-3 bytes left to copy, so don't try the
+                      * 16-bit loop below.
+                      */
+                     dp = (png_bytep)dp32;
+                     sp = (png_const_bytep)sp32;
+                     do
+                        *dp++ = *sp++;
+                     while (--row_width > 0);
+                     return;
+                  }
+
+                  /* Else do it in 16-bit quantities, but only if the size is
+                   * not too large.
+                   */
+                  else
+                  {
+                     png_uint_16p dp16 = (png_uint_16p)dp;
+                     png_const_uint_16p sp16 = (png_const_uint_16p)sp;
+                     unsigned int skip = (bytes_to_jump-bytes_to_copy) /
+                        sizeof (png_uint_16);
+
+                     do
+                     {
+                        size_t c = bytes_to_copy;
+                        do
+                        {
+                           *dp16++ = *sp16++;
+                           c -= sizeof (png_uint_16);
+                        }
+                        while (c > 0);
+
+                        if (row_width <= bytes_to_jump)
+                           return;
+
+                        dp16 += skip;
+                        sp16 += skip;
+                        row_width -= bytes_to_jump;
+                     }
+                     while (bytes_to_copy <= row_width);
+
+                     /* End of row - 1 byte left, bytes_to_copy > row_width: */
+                     dp = (png_bytep)dp16;
+                     sp = (png_const_bytep)sp16;
+                     do
+                        *dp++ = *sp++;
+                     while (--row_width > 0);
+                     return;
+                  }
                }
+#endif /* PNG_ALIGN_ code */
 
-               sp += pixel_bytes;
-               dp += pixel_bytes;
+               /* The true default - use a png_memcpy: */
+               for (;;)
+               {
+                  png_memcpy(dp, sp, bytes_to_copy);
 
-               if (m == 1)
-                  m = 0x80;
+                  if (row_width <= bytes_to_jump)
+                     return;
 
-               else
-                  m >>= 1;
-            }
-            break;
+                  sp += bytes_to_jump;
+                  dp += bytes_to_jump;
+                  row_width -= bytes_to_jump;
+                  if (bytes_to_copy > row_width)
+                     bytes_to_copy = row_width;
+               }
          }
-      }
+
+         /* NOT REACHED*/
+      } /* pixel_depth >= 8 */
+
+      /* Here if pixel_depth < 8 to check 'end_ptr' below. */
    }
+   else
+#endif
+
+   /* If here then the switch above wasn't used so just png_memcpy the whole row
+    * from the temporary row buffer (notice that this overwrites the end of the
+    * destination row if it is a partial byte.)
+    */
+   png_memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width));
+
+   /* Restore the overwritten bits from the last byte if necessary. */
+   if (end_ptr != NULL)
+      *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask));
 }
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
 void /* PRIVATE */
-png_do_read_interlace(png_structp png_ptr)
+png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
+   png_uint_32 transformations /* Because these may affect the byte layout */)
 {
-   png_row_infop row_info = &(png_ptr->row_info);
-   png_bytep row = png_ptr->row_buf + 1;
-   int pass = png_ptr->pass;
-   png_uint_32 transformations = png_ptr->transformations;
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    /* Offset to next interlace block */
-   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    png_debug(1, "in png_do_read_interlace");
    if (row != NULL && row_info != NULL)
@@ -3047,7 +3431,7 @@ png_do_read_interlace(png_structp png_ptr)
 
             for (i = 0; i < row_info->width; i++)
             {
-               png_byte v = (png_byte)((*sp >> sshift) & 0xf);
+               png_byte v = (png_byte)((*sp >> sshift) & 0x0f);
                int j;
 
                for (j = 0; j < jstop; j++)
@@ -3076,6 +3460,7 @@ png_do_read_interlace(png_structp png_ptr)
             }
             break;
          }
+
          default:
          {
             png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
@@ -3106,6 +3491,7 @@ png_do_read_interlace(png_structp png_ptr)
             break;
          }
       }
+
       row_info->width = final_width;
       row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
    }
@@ -3115,132 +3501,252 @@ png_do_read_interlace(png_structp png_ptr)
 }
 #endif /* PNG_READ_INTERLACING_SUPPORTED */
 
-void /* PRIVATE */
-png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
-    png_const_bytep prev_row, int filter)
+static void
+png_read_filter_row_sub(png_row_infop row_info, png_bytep row,
+   png_const_bytep prev_row)
 {
-   png_debug(1, "in png_read_filter_row");
-   png_debug2(2, "row = %u, filter = %d", png_ptr->row_number, filter);
-   switch (filter)
+   png_size_t i;
+   png_size_t istop = row_info->rowbytes;
+   unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
+   png_bytep rp = row + bpp;
+
+   PNG_UNUSED(prev_row)
+
+   for (i = bpp; i < istop; i++)
    {
-      case PNG_FILTER_VALUE_NONE:
-         break;
+      *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);
+      rp++;
+   }
+}
 
-      case PNG_FILTER_VALUE_SUB:
-      {
-         png_size_t i;
-         png_size_t istop = row_info->rowbytes;
-         unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
-         png_bytep rp = row + bpp;
-         png_bytep lp = row;
+static void
+png_read_filter_row_up(png_row_infop row_info, png_bytep row,
+   png_const_bytep prev_row)
+{
+   png_size_t i;
+   png_size_t istop = row_info->rowbytes;
+   png_bytep rp = row;
+   png_const_bytep pp = prev_row;
 
-         for (i = bpp; i < istop; i++)
-         {
-            *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff);
-            rp++;
-         }
-         break;
-      }
-      case PNG_FILTER_VALUE_UP:
-      {
-         png_size_t i;
-         png_size_t istop = row_info->rowbytes;
-         png_bytep rp = row;
-         png_const_bytep pp = prev_row;
+   for (i = 0; i < istop; i++)
+   {
+      *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
+      rp++;
+   }
+}
 
-         for (i = 0; i < istop; i++)
-         {
-            *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
-            rp++;
-         }
-         break;
-      }
-      case PNG_FILTER_VALUE_AVG:
-      {
-         png_size_t i;
-         png_bytep rp = row;
-         png_const_bytep pp = prev_row;
-         png_bytep lp = row;
-         unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
-         png_size_t istop = row_info->rowbytes - bpp;
-
-         for (i = 0; i < bpp; i++)
-         {
-            *rp = (png_byte)(((int)(*rp) +
-                ((int)(*pp++) / 2 )) & 0xff);
+static void
+png_read_filter_row_avg(png_row_infop row_info, png_bytep row,
+   png_const_bytep prev_row)
+{
+   png_size_t i;
+   png_bytep rp = row;
+   png_const_bytep pp = prev_row;
+   unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
+   png_size_t istop = row_info->rowbytes - bpp;
 
-            rp++;
-         }
+   for (i = 0; i < bpp; i++)
+   {
+      *rp = (png_byte)(((int)(*rp) +
+         ((int)(*pp++) / 2 )) & 0xff);
 
-         for (i = 0; i < istop; i++)
-         {
-            *rp = (png_byte)(((int)(*rp) +
-                (int)(*pp++ + *lp++) / 2 ) & 0xff);
+      rp++;
+   }
 
-            rp++;
-         }
-         break;
-      }
-      case PNG_FILTER_VALUE_PAETH:
-      {
-         png_size_t i;
-         png_bytep rp = row;
-         png_const_bytep pp = prev_row;
-         png_bytep lp = row;
-         png_const_bytep cp = prev_row;
-         unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
-         png_size_t istop=row_info->rowbytes - bpp;
-
-         for (i = 0; i < bpp; i++)
-         {
-            *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
-            rp++;
-         }
+   for (i = 0; i < istop; i++)
+   {
+      *rp = (png_byte)(((int)(*rp) +
+         (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
 
-         for (i = 0; i < istop; i++)   /* Use leftover rp,pp */
-         {
-            int a, b, c, pa, pb, pc, p;
+      rp++;
+   }
+}
 
-            a = *lp++;
-            b = *pp++;
-            c = *cp++;
+static void
+png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
+   png_const_bytep prev_row)
+{
+   png_bytep rp_end = row + row_info->rowbytes;
+   int a, c;
 
-            p = b - c;
-            pc = a - c;
+   /* First pixel/byte */
+   c = *prev_row++;
+   a = *row + c;
+   *row++ = (png_byte)a;
 
-#ifdef PNG_USE_ABS
-            pa = abs(p);
-            pb = abs(pc);
-            pc = abs(p + pc);
-#else
-            pa = p < 0 ? -p : p;
-            pb = pc < 0 ? -pc : pc;
-            pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
+   /* Remainder */
+   while (row < rp_end)
+   {
+      int b, pa, pb, pc, p;
 
-            /*
-               if (pa <= pb && pa <= pc)
-                  p = a;
+      a &= 0xff; /* From previous iteration or start */
+      b = *prev_row++;
 
-               else if (pb <= pc)
-                  p = b;
+      p = b - c;
+      pc = a - c;
 
-               else
-                  p = c;
-             */
+#     ifdef PNG_USE_ABS
+         pa = abs(p);
+         pb = abs(pc);
+         pc = abs(p + pc);
+#     else
+         pa = p < 0 ? -p : p;
+         pb = pc < 0 ? -pc : pc;
+         pc = (p + pc) < 0 ? -(p + pc) : p + pc;
+#     endif
 
-            p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c;
+      /* Find the best predictor, the least of pa, pb, pc favoring the earlier
+       * ones in the case of a tie.
+       */
+      if (pb < pa) pa = pb, a = b;
+      if (pc < pa) a = c;
 
-            *rp = (png_byte)(((int)(*rp) + p) & 0xff);
-            rp++;
-         }
+      /* Calculate the current pixel in a, and move the previous row pixel to c
+       * for the next time round the loop
+       */
+      c = b;
+      a += *row;
+      *row++ = (png_byte)a;
+   }
+}
+
+static void
+png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
+   png_const_bytep prev_row)
+{
+   int bpp = (row_info->pixel_depth + 7) >> 3;
+   png_bytep rp_end = row + bpp;
+
+   /* Process the first pixel in the row completely (this is the same as 'up'
+    * because there is only one candidate predictor for the first row).
+    */
+   while (row < rp_end)
+   {
+      int a = *row + *prev_row++;
+      *row++ = (png_byte)a;
+   }
+
+   /* Remainder */
+   rp_end += row_info->rowbytes - bpp;
+
+   while (row < rp_end)
+   {
+      int a, b, c, pa, pb, pc, p;
+
+      c = *(prev_row - bpp);
+      a = *(row - bpp);
+      b = *prev_row++;
+
+      p = b - c;
+      pc = a - c;
+
+#     ifdef PNG_USE_ABS
+         pa = abs(p);
+         pb = abs(pc);
+         pc = abs(p + pc);
+#     else
+         pa = p < 0 ? -p : p;
+         pb = pc < 0 ? -pc : pc;
+         pc = (p + pc) < 0 ? -(p + pc) : p + pc;
+#     endif
+
+      if (pb < pa) pa = pb, a = b;
+      if (pc < pa) a = c;
+
+      c = b;
+      a += *row;
+      *row++ = (png_byte)a;
+   }
+}
+
+#ifdef PNG_ARM_NEON
+
+#ifdef __linux__
+#include <stdio.h>
+#include <elf.h>
+#include <asm/hwcap.h>
+
+static int png_have_hwcap(unsigned cap)
+{
+   FILE *f = fopen("/proc/self/auxv", "r");
+   Elf32_auxv_t aux;
+   int have_cap = 0;
+
+   if (!f)
+      return 0;
+
+   while (fread(&aux, sizeof(aux), 1, f) > 0)
+   {
+      if (aux.a_type == AT_HWCAP &&
+          aux.a_un.a_val & cap)
+      {
+         have_cap = 1;
          break;
       }
-      default:
-         png_error(png_ptr, "Ignoring bad adaptive filter type");
-         /*NOT REACHED */
-         break;
    }
+
+   fclose(f);
+
+   return have_cap;
+}
+#endif /* __linux__ */
+
+static void
+png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
+{
+#ifdef __linux__
+   if (!png_have_hwcap(HWCAP_NEON))
+      return;
+#endif
+
+   pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
+
+   if (bpp == 3)
+   {
+      pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
+      pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
+      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = 
+         png_read_filter_row_paeth3_neon;
+   }
+
+   else if (bpp == 4)
+   {
+      pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
+      pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
+      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
+          png_read_filter_row_paeth4_neon;
+   }
+}
+#endif /* PNG_ARM_NEON */
+
+static void
+png_init_filter_functions(png_structp pp)
+{
+   unsigned int bpp = (pp->pixel_depth + 7) >> 3;
+
+   pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub;
+   pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up;
+   pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg;
+   if (bpp == 1)
+      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
+         png_read_filter_row_paeth_1byte_pixel;
+   else
+      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
+         png_read_filter_row_paeth_multibyte_pixel;
+
+#ifdef PNG_ARM_NEON
+   png_init_filter_functions_neon(pp, bpp);
+#endif
+}
+
+void /* PRIVATE */
+png_read_filter_row(png_structp pp, png_row_infop row_info, png_bytep row,
+   png_const_bytep prev_row, int filter)
+{
+   if (pp->read_filter[0] == NULL)
+      png_init_filter_functions(pp);
+   if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST)
+      pp->read_filter[filter-1](row_info, row, prev_row);
 }
 
 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
@@ -3251,16 +3757,16 @@ png_read_finish_row(png_structp png_ptr)
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 #endif /* PNG_READ_INTERLACING_SUPPORTED */
 
    png_debug(1, "in png_read_finish_row");
@@ -3273,6 +3779,9 @@ png_read_finish_row(png_structp png_ptr)
    {
       png_ptr->row_number = 0;
 
+      /* TO DO: don't do this if prev_row isn't needed (requires
+       * read-ahead of the next row's filter byte.
+       */
       png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
 
       do
@@ -3307,7 +3816,6 @@ png_read_finish_row(png_structp png_ptr)
 
    if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
    {
-      PNG_IDAT;
       char extra;
       int ret;
 
@@ -3322,7 +3830,7 @@ png_read_finish_row(png_structp png_ptr)
             {
                png_crc_finish(png_ptr, 0);
                png_ptr->idat_size = png_read_chunk_header(png_ptr);
-               if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
+               if (png_ptr->chunk_name != png_IDAT)
                   png_error(png_ptr, "Not enough image data");
             }
 
@@ -3381,16 +3889,16 @@ png_read_start_row(png_structp png_ptr)
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 #endif
 
    int max_pixel_depth;
@@ -3398,7 +3906,9 @@ png_read_start_row(png_structp png_ptr)
 
    png_debug(1, "in png_read_start_row");
    png_ptr->zstream.avail_in = 0;
+#ifdef PNG_READ_TRANSFORMS_SUPPORTED
    png_init_read_transformations(png_ptr);
+#endif
 #ifdef PNG_READ_INTERLACING_SUPPORTED
    if (png_ptr->interlaced)
    {
@@ -3424,6 +3934,16 @@ png_read_start_row(png_structp png_ptr)
 
    max_pixel_depth = png_ptr->pixel_depth;
 
+   /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpliar set of
+    * calculations to calculate the final pixel depth, then
+    * png_do_read_transforms actually does the transforms.  This means that the
+    * code which effectively calculates this value is actually repeated in three
+    * separate places.  They must all match.  Innocent changes to the order of
+    * transformations can and will break libpng in a way that causes memory
+    * overwrites.
+    *
+    * TODO: fix this.
+    */
 #ifdef PNG_READ_PACK_SUPPORTED
    if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8)
       max_pixel_depth = 8;
@@ -3482,10 +4002,7 @@ png_read_start_row(png_structp png_ptr)
 #ifdef PNG_READ_FILLER_SUPPORTED
    if (png_ptr->transformations & (PNG_FILLER))
    {
-      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-         max_pixel_depth = 32;
-
-      else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
+      if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
       {
          if (max_pixel_depth <= 8)
             max_pixel_depth = 16;
@@ -3494,7 +4011,8 @@ png_read_start_row(png_structp png_ptr)
             max_pixel_depth = 32;
       }
 
-      else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
+      else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB ||
+         png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
       {
          if (max_pixel_depth <= 32)
             max_pixel_depth = 32;
@@ -3548,14 +4066,20 @@ png_read_start_row(png_structp png_ptr)
 defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    if (png_ptr->transformations & PNG_USER_TRANSFORM)
    {
-      int user_pixel_depth = png_ptr->user_transform_depth*
+      int user_pixel_depth = png_ptr->user_transform_depth *
          png_ptr->user_transform_channels;
 
       if (user_pixel_depth > max_pixel_depth)
-         max_pixel_depth=user_pixel_depth;
+         max_pixel_depth = user_pixel_depth;
    }
 #endif
 
+   /* This value is stored in png_struct and double checked in the row read
+    * code.
+    */
+   png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth;
+   png_ptr->transformed_pixel_depth = 0; /* calculated on demand */
+
    /* Align the width on the next larger 8 pixels.  Mainly used
     * for interlacing
     */
@@ -3574,28 +4098,39 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    if (row_bytes + 48 > png_ptr->old_big_row_buf_size)
    {
      png_free(png_ptr, png_ptr->big_row_buf);
+     png_free(png_ptr, png_ptr->big_prev_row);
 
      if (png_ptr->interlaced)
         png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,
             row_bytes + 48);
 
      else
-        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr,
-            row_bytes + 48);
+        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
 
-     png_ptr->old_big_row_buf_size = row_bytes + 48;
+     png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48);
 
 #ifdef PNG_ALIGNED_MEMORY_SUPPORTED
      /* Use 16-byte aligned memory for row_buf with at least 16 bytes
-      * of padding before and after row_buf.
+      * of padding before and after row_buf; treat prev_row similarly.
+      * NOTE: the alignment is to the start of the pixels, one beyond the start
+      * of the buffer, because of the filter byte.  Prior to libpng 1.5.6 this
+      * was incorrect; the filter byte was aligned, which had the exact
+      * opposite effect of that intended.
       */
-     png_ptr->row_buf = png_ptr->big_row_buf + 32 -
-         (((png_alloc_size_t)png_ptr->big_row_buf + 15) & 0x0F);
+     {
+        png_bytep temp = png_ptr->big_row_buf + 32;
+        int extra = (int)((temp - (png_bytep)0) & 0x0f);
+        png_ptr->row_buf = temp - extra - 1/*filter byte*/;
+
+        temp = png_ptr->big_prev_row + 32;
+        extra = (int)((temp - (png_bytep)0) & 0x0f);
+        png_ptr->prev_row = temp - extra - 1/*filter byte*/;
+     }
 
-     png_ptr->old_big_row_buf_size = row_bytes + 48;
 #else
-     /* Use 32 bytes of padding before and 16 bytes after row_buf. */
-     png_ptr->row_buf = png_ptr->big_row_buf + 32;
+     /* Use 31 bytes of padding before and 17 bytes after row_buf. */
+     png_ptr->row_buf = png_ptr->big_row_buf + 31;
+     png_ptr->prev_row = png_ptr->big_prev_row + 31;
 #endif
      png_ptr->old_big_row_buf_size = row_bytes + 48;
    }
@@ -3608,15 +4143,6 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1))
       png_error(png_ptr, "Row has too many bytes to allocate in memory");
 
-   if (png_ptr->rowbytes + 1 > png_ptr->old_prev_row_size)
-   {
-      png_free(png_ptr, png_ptr->prev_row);
-
-      png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
-
-      png_ptr->old_prev_row_size = png_ptr->rowbytes + 1;
-   }
-
    png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
 
    png_debug1(3, "width = %u,", png_ptr->width);
index 2cfcf33bdf97f41486d09cf4a0888b2b07957153..92db3890a89f85f38a7fe94408a51ee813a7fe0d 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * Last changed in libpng 1.5.1 [February 3, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -64,6 +64,39 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
    }
 }
 
+void PNGFAPI
+png_set_cHRM_XYZ_fixed(png_structp png_ptr, png_infop info_ptr,
+    png_fixed_point int_red_X, png_fixed_point int_red_Y,
+    png_fixed_point int_red_Z, png_fixed_point int_green_X,
+    png_fixed_point int_green_Y, png_fixed_point int_green_Z,
+    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
+    png_fixed_point int_blue_Z)
+{
+   png_XYZ XYZ;
+   png_xy xy;
+
+   png_debug1(1, "in %s storage function", "cHRM XYZ fixed");
+
+   if (png_ptr == NULL || info_ptr == NULL)
+      return;
+
+   XYZ.redX = int_red_X;
+   XYZ.redY = int_red_Y;
+   XYZ.redZ = int_red_Z;
+   XYZ.greenX = int_green_X;
+   XYZ.greenY = int_green_Y;
+   XYZ.greenZ = int_green_Z;
+   XYZ.blueX = int_blue_X;
+   XYZ.blueY = int_blue_Y;
+   XYZ.blueZ = int_blue_Z;
+
+   if (png_xy_from_XYZ(&xy, XYZ))
+      png_error(png_ptr, "XYZ values out of representable range");
+
+   png_set_cHRM_fixed(png_ptr, info_ptr, xy.whitex, xy.whitey, xy.redx, xy.redy,
+      xy.greenx, xy.greeny, xy.bluex, xy.bluey);
+}
+
 #  ifdef PNG_FLOATING_POINT_SUPPORTED
 void PNGAPI
 png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
@@ -80,6 +113,23 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
       png_fixed(png_ptr, blue_x, "cHRM Blue X"),
       png_fixed(png_ptr, blue_y, "cHRM Blue Y"));
 }
+
+void PNGAPI
+png_set_cHRM_XYZ(png_structp png_ptr, png_infop info_ptr, double red_X,
+    double red_Y, double red_Z, double green_X, double green_Y, double green_Z,
+    double blue_X, double blue_Y, double blue_Z)
+{
+   png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,
+      png_fixed(png_ptr, red_X, "cHRM Red X"),
+      png_fixed(png_ptr, red_Y, "cHRM Red Y"),
+      png_fixed(png_ptr, red_Z, "cHRM Red Z"),
+      png_fixed(png_ptr, green_X, "cHRM Red X"),
+      png_fixed(png_ptr, green_Y, "cHRM Red Y"),
+      png_fixed(png_ptr, green_Z, "cHRM Red Z"),
+      png_fixed(png_ptr, blue_X, "cHRM Red X"),
+      png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
+      png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
+}
 #  endif /* PNG_FLOATING_POINT_SUPPORTED */
 
 #endif /* PNG_cHRM_SUPPORTED */
@@ -94,15 +144,16 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
-   /* Previously these values were limited, however they must be
-    * wrong, therefore storing them (and setting PNG_INFO_gAMA)
-    * must be wrong too.
+   /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
+    * occur.  Since the fixed point representation is assymetrical it is
+    * possible for 1/gamma to overflow the limit of 21474 and this means the
+    * gamma value must be at least 5/100000 and hence at most 20000.0.  For
+    * safety the limits here are a little narrower.  The values are 0.00016 to
+    * 6250.0, which are truly ridiculous gammma values (and will produce
+    * displays that are all black or all white.)
     */
-   if (file_gamma > (png_fixed_point)PNG_UINT_31_MAX)
-      png_warning(png_ptr, "Gamma too large, ignored");
-
-   else if (file_gamma <= 0)
-      png_warning(png_ptr, "Negative or zero gamma ignored");
+   if (file_gamma < 16 || file_gamma > 625000000)
+      png_warning(png_ptr, "Out of range gamma value ignored");
 
    else
    {
@@ -340,12 +391,12 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
    if (unit != 1 && unit != 2)
       png_error(png_ptr, "Invalid sCAL unit");
 
-   if (swidth == NULL || (lengthw = png_strlen(swidth)) <= 0 ||
-       swidth[0] == 45 /*'-'*/ || !png_check_fp_string(swidth, lengthw))
+   if (swidth == NULL || (lengthw = png_strlen(swidth)) == 0 ||
+       swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))
       png_error(png_ptr, "Invalid sCAL width");
 
-   if (sheight == NULL || (lengthh = png_strlen(sheight)) <= 0 ||
-       sheight[0] == 45 /*'-'*/ || !png_check_fp_string(sheight, lengthh))
+   if (sheight == NULL || (lengthh = png_strlen(sheight)) == 0 ||
+       sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))
       png_error(png_ptr, "Invalid sCAL height");
 
    info_ptr->scal_unit = (png_byte)unit;
@@ -545,16 +596,16 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
    png_set_sRGB(png_ptr, info_ptr, srgb_intent);
 
 #  ifdef PNG_gAMA_SUPPORTED
-   png_set_gAMA_fixed(png_ptr, info_ptr, 45455L);
+   png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);
 #  endif
 
 #  ifdef PNG_cHRM_SUPPORTED
    png_set_cHRM_fixed(png_ptr, info_ptr,
       /* color      x       y */
-      /* white */ 31270L, 32900L,
-      /* red   */ 64000L, 33000L,
-      /* green */ 30000L, 60000L,
-      /* blue  */ 15000L,  6000L
+      /* white */ 31270, 32900,
+      /* red   */ 64000, 33000,
+      /* green */ 30000, 60000,
+      /* blue  */ 15000,  6000
    );
 #  endif /* cHRM */
 }
@@ -569,7 +620,7 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
 {
    png_charp new_iccp_name;
    png_bytep new_iccp_profile;
-   png_uint_32 length;
+   png_size_t length;
 
    png_debug1(1, "in %s storage function", "iCCP");
 
@@ -630,9 +681,8 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
 {
    int i;
 
-   png_debug1(1, "in %s storage function", ((png_ptr == NULL ||
-       png_ptr->chunk_name[0] == '\0') ?
-       "text" : (png_const_charp)png_ptr->chunk_name));
+   png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
+      (unsigned long)png_ptr->chunk_name);
 
    if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
       return(0);
@@ -814,6 +864,15 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)
        (png_ptr->mode & PNG_WROTE_tIME))
       return;
 
+   if (mod_time->month == 0   || mod_time->month > 12  ||
+       mod_time->day   == 0   || mod_time->day   > 31  ||
+       mod_time->hour  > 23   || mod_time->minute > 59 ||
+       mod_time->second > 60)
+   {
+      png_warning(png_ptr, "Ignoring invalid time value");
+      return;
+   }
+
    png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));
    info_ptr->valid |= PNG_INFO_tIME;
 }
@@ -915,10 +974,10 @@ png_set_sPLT(png_structp png_ptr,
    {
       png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
       png_const_sPLT_tp from = entries + i;
-      png_uint_32 length;
+      png_size_t length;
 
       length = png_strlen(from->name) + 1;
-      to->name = (png_charp)png_malloc_warn(png_ptr, (png_size_t)length);
+      to->name = (png_charp)png_malloc_warn(png_ptr, length);
 
       if (to->name == NULL)
       {
@@ -929,7 +988,7 @@ png_set_sPLT(png_structp png_ptr,
 
       png_memcpy(to->name, from->name, length);
       to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
-          (png_size_t)(from->nentries * png_sizeof(png_sPLT_entry)));
+          from->nentries * png_sizeof(png_sPLT_entry));
 
       if (to->entries == NULL)
       {
index 8d781faefecae306ff4c27cd391e10ee6b74cf05..860b8bff8f38000b9d7d20c51365e366452a4e90 100644 (file)
@@ -5,7 +5,7 @@
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.5.0 [January 6, 2011]
+ * Last changed in libpng 1.5.9 [February 18, 2012]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
 struct png_struct_def
 {
 #ifdef PNG_SETJMP_SUPPORTED
-   jmp_buf png_jmpbuf;            /* used in png_error */
+   jmp_buf longjmp_buffer;    /* used in png_error */
    png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
 #endif
    png_error_ptr error_fn;    /* function for printing errors and aborting */
+#ifdef PNG_WARNINGS_SUPPORTED
    png_error_ptr warning_fn;  /* function for printing warnings */
+#endif
    png_voidp error_ptr;       /* user supplied struct for error functions */
    png_rw_ptr write_data_fn;  /* function for writing output data */
    png_rw_ptr read_data_fn;   /* function for reading input data */
@@ -64,11 +66,36 @@ struct png_struct_def
    z_stream zstream;          /* pointer to decompression structure (below) */
    png_bytep zbuf;            /* buffer for zlib */
    uInt zbuf_size;            /* size of zbuf (typically 65536) */
+#ifdef PNG_WRITE_SUPPORTED
+
+/* Added in 1.5.4: state to keep track of whether the zstream has been
+ * initialized and if so whether it is for IDAT or some other chunk.
+ */
+#define PNG_ZLIB_UNINITIALIZED 0
+#define PNG_ZLIB_FOR_IDAT      1
+#define PNG_ZLIB_FOR_TEXT      2 /* anything other than IDAT */
+#define PNG_ZLIB_USE_MASK      3 /* bottom two bits */
+#define PNG_ZLIB_IN_USE        4 /* a flag value */
+
+   png_uint_32 zlib_state;       /* State of zlib initialization */
+/* End of material added at libpng 1.5.4 */
+
    int zlib_level;            /* holds zlib compression level */
    int zlib_method;           /* holds zlib compression method */
    int zlib_window_bits;      /* holds zlib compression window bits */
    int zlib_mem_level;        /* holds zlib compression memory level */
    int zlib_strategy;         /* holds zlib compression strategy */
+#endif
+/* Added at libpng 1.5.4 */
+#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \
+    defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)
+   int zlib_text_level;            /* holds zlib compression level */
+   int zlib_text_method;           /* holds zlib compression method */
+   int zlib_text_window_bits;      /* holds zlib compression window bits */
+   int zlib_text_mem_level;        /* holds zlib compression memory level */
+   int zlib_text_strategy;         /* holds zlib compression strategy */
+#endif
+/* End of material added at libpng 1.5.4 */
 
    png_uint_32 width;         /* width of image in pixels */
    png_uint_32 height;        /* height of image in pixels */
@@ -77,20 +104,24 @@ struct png_struct_def
    png_size_t rowbytes;       /* size of row in bytes */
    png_uint_32 iwidth;        /* width of current interlaced row in pixels */
    png_uint_32 row_number;    /* current row in interlace pass */
-   png_bytep prev_row;        /* buffer to save previous (unfiltered) row */
-   png_bytep row_buf;         /* buffer to save current (unfiltered) row */
+   png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */
+   png_bytep prev_row;        /* buffer to save previous (unfiltered) row.
+                               * This is a pointer into big_prev_row
+                               */
+   png_bytep row_buf;         /* buffer to save current (unfiltered) row.
+                               * This is a pointer into big_row_buf
+                               */
    png_bytep sub_row;         /* buffer to save "sub" row when filtering */
    png_bytep up_row;          /* buffer to save "up" row when filtering */
    png_bytep avg_row;         /* buffer to save "avg" row when filtering */
    png_bytep paeth_row;       /* buffer to save "Paeth" row when filtering */
-   png_row_info row_info;     /* used for transformation routines */
+   png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */
 
    png_uint_32 idat_size;     /* current IDAT size for read */
    png_uint_32 crc;           /* current chunk CRC value */
    png_colorp palette;        /* palette from the input file */
    png_uint_16 num_palette;   /* number of color entries in palette */
    png_uint_16 num_trans;     /* number of transparency values */
-   png_byte chunk_name[5];    /* null-terminated name of current chunk */
    png_byte compression;      /* file compression type (always 0) */
    png_byte filter;           /* file filter type (always 0) */
    png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
@@ -98,17 +129,24 @@ struct png_struct_def
    png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */
    png_byte color_type;       /* color type of file */
    png_byte bit_depth;        /* bit depth of file */
-   png_byte usr_bit_depth;    /* bit depth of users row */
+   png_byte usr_bit_depth;    /* bit depth of users row: write only */
    png_byte pixel_depth;      /* number of bits per pixel */
    png_byte channels;         /* number of channels in file */
-   png_byte usr_channels;     /* channels at start of write */
+   png_byte usr_channels;     /* channels at start of write: write only */
    png_byte sig_bytes;        /* magic bytes read/written from start of file */
+   png_byte maximum_pixel_depth;
+                              /* pixel depth used for the row buffers */
+   png_byte transformed_pixel_depth;
+                              /* pixel depth after read/write transforms */
+   png_byte io_chunk_string[5];
+                              /* string name of chunk */
 
 #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
    png_uint_16 filler;           /* filler bytes for pixel expansion */
 #endif
 
-#ifdef PNG_bKGD_SUPPORTED
+#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
+   defined(PNG_READ_ALPHA_MODE_SUPPORTED)
    png_byte background_gamma_type;
    png_fixed_point background_gamma;
    png_color_16 background;   /* background color in screen gamma space */
@@ -123,19 +161,21 @@ struct png_struct_def
    png_uint_32 flush_rows;    /* number of rows written since last flush */
 #endif
 
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
+#ifdef PNG_READ_GAMMA_SUPPORTED
    int gamma_shift;      /* number of "insignificant" bits in 16-bit gamma */
    png_fixed_point gamma;        /* file gamma value */
    png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
-#endif
 
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
    png_bytep gamma_table;     /* gamma table for 8-bit depth files */
+   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
+   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
+   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
    png_bytep gamma_from_1;    /* converts from 1.0 to screen */
    png_bytep gamma_to_1;      /* converts from file to 1.0 */
-   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
    png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
    png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
+#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
 #endif
 
 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
@@ -209,7 +249,7 @@ struct png_struct_def
 #endif
 
 #ifdef PNG_TIME_RFC1123_SUPPORTED
-   png_charp time_buffer; /* String to hold RFC 1123 time text */
+   char time_buffer[29]; /* String to hold RFC 1123 time text */
 #endif
 
 /* New members added in libpng-1.0.6 */
@@ -226,19 +266,24 @@ struct png_struct_def
    png_bytep chunk_list;
 #endif
 
+#ifdef PNG_READ_sRGB_SUPPORTED
+   /* Added in 1.5.5 to record an sRGB chunk in the png. */
+   png_byte is_sRGB;
+#endif
+
 /* New members added in libpng-1.0.3 */
 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
    png_byte rgb_to_gray_status;
+   /* Added in libpng 1.5.5 to record setting of coefficients: */
+   png_byte rgb_to_gray_coefficients_set;
    /* These were changed from png_byte in libpng-1.0.6 */
    png_uint_16 rgb_to_gray_red_coeff;
    png_uint_16 rgb_to_gray_green_coeff;
-   png_uint_16 rgb_to_gray_blue_coeff;
+   /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
 #endif
 
 /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
-#if defined(PNG_MNG_FEATURES_SUPPORTED) || \
-    defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
-    defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
+#if defined(PNG_MNG_FEATURES_SUPPORTED)
 /* Changed from png_byte to png_uint_32 at version 1.2.0 */
    png_uint_32 mng_features_permitted;
 #endif
@@ -293,9 +338,8 @@ struct png_struct_def
    png_unknown_chunk unknown_chunk;
 #endif
 
-/* New members added in libpng-1.2.26 */
+/* New member added in libpng-1.2.26 */
   png_size_t old_big_row_buf_size;
-  png_size_t old_prev_row_size;
 
 /* New member added in libpng-1.2.30 */
   png_charp chunkdata;  /* buffer for reading chunk data */
@@ -304,5 +348,11 @@ struct png_struct_def
 /* New member added in libpng-1.4.0 */
    png_uint_32 io_state;
 #endif
+
+/* New member added in libpng-1.5.6 */
+   png_bytep big_prev_row;
+
+   void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
+      png_bytep row, png_const_bytep prev_row);
 };
 #endif /* PNGSTRUCT_H */
index cf7622cdc6e4b0b220b7ab64f5d0e60bf6e3a2c7..6a6908dcd26892635ec6b1dd31d55ed848f9736c 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * Last changed in libpng 1.5.2 [March 31, 2011]
+ * Last changed in libpng 1.5.4 [July 7, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -442,7 +442,11 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
    /* At the start sp will point to the first byte to copy and dp to where
     * it is copied to.  ep always points just beyond the end of the row, so
     * the loop simply copies (channels-1) channels until sp reaches ep.
+    *
+    * at_start:        0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
+    *            nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
     */
+
    /* GA, GX, XG cases */
    if (row_info->channels == 2)
    {
@@ -450,7 +454,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
       {
          if (at_start) /* Skip initial filler */
             ++sp;
-         else          /* Skip initial channels and, for sp, the filler */
+         else          /* Skip initial channel and, for sp, the filler */
             sp += 2, ++dp;
 
          /* For a 1 pixel wide image there is nothing to do */
@@ -462,9 +466,9 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
 
       else if (row_info->bit_depth == 16)
       {
-         if (at_start)
+         if (at_start) /* Skip initial filler */
             sp += 2;
-         else
+         else          /* Skip initial channel and, for sp, the filler */
             sp += 4, dp += 2;
 
          while (sp < ep)
@@ -502,9 +506,9 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
 
       else if (row_info->bit_depth == 16)
       {
-         if (at_start)
+         if (at_start) /* Skip initial filler */
             sp += 2;
-         else
+         else          /* Skip initial channels and, for sp, the filler */
             sp += 8, dp += 6;
 
          while (sp < ep)
index 9277a951628fd9aef31a13d685cff4b291ddf8a8..6d3fd4c3861eddae22291cc00d7a9e5506943575 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * Last changed in libpng 1.5.1 [February 3, 2011]
+ * Last changed in libpng 1.5.7 [December 15, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -99,8 +99,10 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
          int keep = png_handle_as_unknown(png_ptr, up->name);
 
          if (keep != PNG_HANDLE_CHUNK_NEVER &&
-             up->location && !(up->location & PNG_HAVE_PLTE) &&
+             up->location &&
+             !(up->location & PNG_HAVE_PLTE) &&
              !(up->location & PNG_HAVE_IDAT) &&
+             !(up->location & PNG_AFTER_IDAT) &&
              ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
              (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
          {
@@ -273,8 +275,10 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
       {
          int keep = png_handle_as_unknown(png_ptr, up->name);
          if (keep != PNG_HANDLE_CHUNK_NEVER &&
-             up->location && (up->location & PNG_HAVE_PLTE) &&
+             up->location &&
+             (up->location & PNG_HAVE_PLTE) &&
              !(up->location & PNG_HAVE_IDAT) &&
+             !(up->location & PNG_AFTER_IDAT) &&
              ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
              (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
          {
@@ -380,7 +384,8 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
       {
          int keep = png_handle_as_unknown(png_ptr, up->name);
          if (keep != PNG_HANDLE_CHUNK_NEVER &&
-             up->location && (up->location & PNG_AFTER_IDAT) &&
+             up->location &&
+             (up->location & PNG_AFTER_IDAT) &&
              ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
              (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
          {
@@ -462,10 +467,9 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
    png_structp png_ptr;
 #ifdef PNG_SETJMP_SUPPORTED
 #ifdef USE_FAR_KEYWORD
-   jmp_buf png_jmpbuf;
+   jmp_buf tmp_jmpbuf;
 #endif
 #endif
-   int i;
 
    png_debug(1, "in png_create_write_struct");
 
@@ -486,15 +490,16 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
 
 #ifdef PNG_SETJMP_SUPPORTED
 /* Applications that neglect to set up their own setjmp() and then
-   encounter a png_error() will longjmp here.  Since the jmpbuf is
-   then meaningless we abort instead of returning. */
+ * encounter a png_error() will longjmp here.  Since the jmpbuf is
+ * then meaningless we abort instead of returning.
+ */
 #ifdef USE_FAR_KEYWORD
-   if (setjmp(png_jmpbuf))
+   if (setjmp(tmp_jmpbuf))
 #else
    if (setjmp(png_jmpbuf(png_ptr))) /* sets longjmp to match setjmp */
 #endif
 #ifdef USE_FAR_KEYWORD
-   png_memcpy(png_jmpbuf(png_ptr), png_jmpbuf, png_sizeof(jmp_buf));
+   png_memcpy(png_jmpbuf(png_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));
 #endif
       PNG_ABORT();
 #endif
@@ -504,49 +509,8 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
 #endif /* PNG_USER_MEM_SUPPORTED */
    png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
 
-   if (user_png_ver)
-   {
-      i = 0;
-      do
-      {
-         if (user_png_ver[i] != png_libpng_ver[i])
-            png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
-      } while (png_libpng_ver[i++]);
-   }
-
-   if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
-   {
-     /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
-      * we must recompile any applications that use any older library version.
-      * For versions after libpng 1.0, we will be compatible, so we need
-      * only check the first digit.
-      */
-     if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
-         (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
-         (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
-     {
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-        char msg[80];
-
-        if (user_png_ver)
-        {
-            png_snprintf2(msg, 80,
-                "Application built with libpng-%.20s"
-                " but running with %.20s",
-                user_png_ver,
-                png_libpng_ver);
-            png_warning(png_ptr, msg);
-         }
-#else
-         png_warning(png_ptr,
-             "Incompatible libpng version in application and library");
-#endif
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-        png_ptr->flags = 0;
-#endif
-        png_cleanup_needed = 1;
-     }
-   }
+   if (!png_user_version_check(png_ptr, user_png_ver))
+      png_cleanup_needed = 1;
 
    /* Initialize zbuf - compression buffer */
    png_ptr->zbuf_size = PNG_ZBUF_SIZE;
@@ -645,6 +609,9 @@ png_write_image(png_structp png_ptr, png_bytepp image)
 void PNGAPI
 png_write_row(png_structp png_ptr, png_const_bytep row)
 {
+   /* 1.5.6: moved from png_struct to be a local structure: */
+   png_row_info row_info;
+
    if (png_ptr == NULL)
       return;
 
@@ -768,36 +735,31 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
 #endif
 
    /* Set up row info for transformations */
-   png_ptr->row_info.color_type = png_ptr->color_type;
-   png_ptr->row_info.width = png_ptr->usr_width;
-   png_ptr->row_info.channels = png_ptr->usr_channels;
-   png_ptr->row_info.bit_depth = png_ptr->usr_bit_depth;
-   png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
-      png_ptr->row_info.channels);
-
-   png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
-      png_ptr->row_info.width);
-
-   png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type);
-   png_debug1(3, "row_info->width = %u", png_ptr->row_info.width);
-   png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
-   png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
-   png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
-   png_debug1(3, "row_info->rowbytes = %lu",
-       (unsigned long)png_ptr->row_info.rowbytes);
+   row_info.color_type = png_ptr->color_type;
+   row_info.width = png_ptr->usr_width;
+   row_info.channels = png_ptr->usr_channels;
+   row_info.bit_depth = png_ptr->usr_bit_depth;
+   row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);
+   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
+
+   png_debug1(3, "row_info->color_type = %d", row_info.color_type);
+   png_debug1(3, "row_info->width = %u", row_info.width);
+   png_debug1(3, "row_info->channels = %d", row_info.channels);
+   png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth);
+   png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth);
+   png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes);
 
    /* Copy user's row into buffer, leaving room for filter byte. */
-   png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);
+   png_memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);
 
 #ifdef PNG_WRITE_INTERLACING_SUPPORTED
    /* Handle interlacing */
    if (png_ptr->interlaced && png_ptr->pass < 6 &&
        (png_ptr->transformations & PNG_INTERLACE))
    {
-      png_do_write_interlace(&(png_ptr->row_info),
-          png_ptr->row_buf + 1, png_ptr->pass);
+      png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
       /* This should always get caught above, but still ... */
-      if (!(png_ptr->row_info.width))
+      if (!(row_info.width))
       {
          png_write_finish_row(png_ptr);
          return;
@@ -805,9 +767,18 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
    }
 #endif
 
+#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
    /* Handle other transformations */
    if (png_ptr->transformations)
-      png_do_write_transformations(png_ptr);
+      png_do_write_transformations(png_ptr, &row_info);
+#endif
+
+   /* At this point the row_info pixel depth must match the 'transformed' depth,
+    * which is also the output depth.
+    */
+   if (row_info.pixel_depth != png_ptr->pixel_depth ||
+      row_info.pixel_depth != png_ptr->transformed_pixel_depth)
+      png_error(png_ptr, "internal write transform logic error");
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
    /* Write filter_method 64 (intrapixel differencing) only if
@@ -823,12 +794,12 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
        (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
    {
       /* Intrapixel differencing */
-      png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);
    }
 #endif
 
    /* Find a filter if necessary, filter the row and write it out. */
-   png_write_find_filter(png_ptr, &(png_ptr->row_info));
+   png_write_find_filter(png_ptr, &row_info);
 
    if (png_ptr->write_row_fn != NULL)
       (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
@@ -884,8 +855,6 @@ png_write_flush(png_structp png_ptr)
       {
          /* Write the IDAT and reset the zlib output buffer */
          png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
-         png_ptr->zstream.next_out = png_ptr->zbuf;
-         png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
          wrote_IDAT = 1;
       }
    } while (wrote_IDAT == 1);
@@ -896,8 +865,6 @@ png_write_flush(png_structp png_ptr)
       /* Write the IDAT and reset the zlib output buffer */
       png_write_IDAT(png_ptr, png_ptr->zbuf,
           png_ptr->zbuf_size - png_ptr->zstream.avail_out);
-      png_ptr->zstream.next_out = png_ptr->zbuf;
-      png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
    }
    png_ptr->flush_rows = 0;
    png_flush(png_ptr);
@@ -918,13 +885,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
    png_debug(1, "in png_destroy_write_struct");
 
    if (png_ptr_ptr != NULL)
-   {
       png_ptr = *png_ptr_ptr;
-#ifdef PNG_USER_MEM_SUPPORTED
-      free_fn = png_ptr->free_fn;
-      mem_ptr = png_ptr->mem_ptr;
-#endif
-   }
 
 #ifdef PNG_USER_MEM_SUPPORTED
    if (png_ptr != NULL)
@@ -983,7 +944,9 @@ png_write_destroy(png_structp png_ptr)
    jmp_buf tmp_jmp; /* Save jump buffer */
 #endif
    png_error_ptr error_fn;
+#ifdef PNG_WARNINGS_SUPPORTED
    png_error_ptr warning_fn;
+#endif
    png_voidp error_ptr;
 #ifdef PNG_USER_MEM_SUPPORTED
    png_free_ptr free_fn;
@@ -992,7 +955,8 @@ png_write_destroy(png_structp png_ptr)
    png_debug(1, "in png_write_destroy");
 
    /* Free any memory zlib uses */
-   deflateEnd(&png_ptr->zstream);
+   if (png_ptr->zlib_state != PNG_ZLIB_UNINITIALIZED)
+      deflateEnd(&png_ptr->zstream);
 
    /* Free our memory.  png_free checks NULL for us. */
    png_free(png_ptr, png_ptr->zbuf);
@@ -1005,10 +969,6 @@ png_write_destroy(png_structp png_ptr)
    png_free(png_ptr, png_ptr->paeth_row);
 #endif
 
-#ifdef PNG_TIME_RFC1123_SUPPORTED
-   png_free(png_ptr, png_ptr->time_buffer);
-#endif
-
 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    /* Use this to save a little code space, it doesn't free the filter_costs */
    png_reset_filter_heuristics(png_ptr);
@@ -1018,11 +978,13 @@ png_write_destroy(png_structp png_ptr)
 
 #ifdef PNG_SETJMP_SUPPORTED
    /* Reset structure */
-   png_memcpy(tmp_jmp, png_ptr->png_jmpbuf, png_sizeof(jmp_buf));
+   png_memcpy(tmp_jmp, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));
 #endif
 
    error_fn = png_ptr->error_fn;
+#ifdef PNG_WARNINGS_SUPPORTED
    warning_fn = png_ptr->warning_fn;
+#endif
    error_ptr = png_ptr->error_ptr;
 #ifdef PNG_USER_MEM_SUPPORTED
    free_fn = png_ptr->free_fn;
@@ -1031,14 +993,16 @@ png_write_destroy(png_structp png_ptr)
    png_memset(png_ptr, 0, png_sizeof(png_struct));
 
    png_ptr->error_fn = error_fn;
+#ifdef PNG_WARNINGS_SUPPORTED
    png_ptr->warning_fn = warning_fn;
+#endif
    png_ptr->error_ptr = error_ptr;
 #ifdef PNG_USER_MEM_SUPPORTED
    png_ptr->free_fn = free_fn;
 #endif
 
 #ifdef PNG_SETJMP_SUPPORTED
-   png_memcpy(png_ptr->png_jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
+   png_memcpy(png_ptr->longjmp_buffer, tmp_jmp, png_sizeof(jmp_buf));
 #endif
 }
 
@@ -1451,6 +1415,9 @@ png_set_compression_strategy(png_structp png_ptr, int strategy)
    png_ptr->zlib_strategy = strategy;
 }
 
+/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
+ * smaller value of window_bits if it can do so safely.
+ */
 void PNGAPI
 png_set_compression_window_bits(png_structp png_ptr, int window_bits)
 {
@@ -1491,6 +1458,89 @@ png_set_compression_method(png_structp png_ptr, int method)
    png_ptr->zlib_method = method;
 }
 
+/* The following were added to libpng-1.5.4 */
+#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
+void PNGAPI
+png_set_text_compression_level(png_structp png_ptr, int level)
+{
+   png_debug(1, "in png_set_text_compression_level");
+
+   if (png_ptr == NULL)
+      return;
+
+   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_LEVEL;
+   png_ptr->zlib_text_level = level;
+}
+
+void PNGAPI
+png_set_text_compression_mem_level(png_structp png_ptr, int mem_level)
+{
+   png_debug(1, "in png_set_text_compression_mem_level");
+
+   if (png_ptr == NULL)
+      return;
+
+   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL;
+   png_ptr->zlib_text_mem_level = mem_level;
+}
+
+void PNGAPI
+png_set_text_compression_strategy(png_structp png_ptr, int strategy)
+{
+   png_debug(1, "in png_set_text_compression_strategy");
+
+   if (png_ptr == NULL)
+      return;
+
+   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_STRATEGY;
+   png_ptr->zlib_text_strategy = strategy;
+}
+
+/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
+ * smaller value of window_bits if it can do so safely.
+ */
+void PNGAPI
+png_set_text_compression_window_bits(png_structp png_ptr, int window_bits)
+{
+   if (png_ptr == NULL)
+      return;
+
+   if (window_bits > 15)
+      png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
+
+   else if (window_bits < 8)
+      png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
+
+#ifndef WBITS_8_OK
+   /* Avoid libpng bug with 256-byte windows */
+   if (window_bits == 8)
+      {
+        png_warning(png_ptr, "Text compression window is being reset to 512");
+        window_bits = 9;
+      }
+
+#endif
+   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS;
+   png_ptr->zlib_text_window_bits = window_bits;
+}
+
+void PNGAPI
+png_set_text_compression_method(png_structp png_ptr, int method)
+{
+   png_debug(1, "in png_set_text_compression_method");
+
+   if (png_ptr == NULL)
+      return;
+
+   if (method != 8)
+      png_warning(png_ptr, "Only compression method 8 is supported by PNG");
+
+   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_METHOD;
+   png_ptr->zlib_text_method = method;
+}
+#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
+/* end of API added to libpng-1.5.4 */
+
 void PNGAPI
 png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
 {
@@ -1557,7 +1607,7 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
 #endif
 
 #ifdef PNG_WRITE_FILLER_SUPPORTED
-   /* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */
+   /* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */
    if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
       png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
 
index bbf4a25b92e72b9f8400491691c084b480e31ba8..96608efcb4a9f526e6fa8019254da4df24705022 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * Last changed in libpng 1.5.2 [March 31, 2011]
+ * Last changed in libpng 1.5.6 [November 3, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
 
 #ifdef PNG_WRITE_SUPPORTED
 
+#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
 /* Transform the data according to the user's wishes.  The order of
  * transformations is significant.
  */
 void /* PRIVATE */
-png_do_write_transformations(png_structp png_ptr)
+png_do_write_transformations(png_structp png_ptr, png_row_infop row_info)
 {
    png_debug(1, "in png_do_write_transformations");
 
@@ -31,8 +32,8 @@ png_do_write_transformations(png_structp png_ptr)
       if (png_ptr->write_user_transform_fn != NULL)
          (*(png_ptr->write_user_transform_fn)) /* User write transform
                                                  function */
-             (png_ptr,                    /* png_ptr */
-             &(png_ptr->row_info),           /* row_info: */
+             (png_ptr,  /* png_ptr */
+             row_info,  /* row_info: */
                 /*  png_uint_32 width;       width of row */
                 /*  png_size_t rowbytes;     number of bytes in row */
                 /*  png_byte color_type;     color type of pixels */
@@ -44,50 +45,50 @@ png_do_write_transformations(png_structp png_ptr)
 
 #ifdef PNG_WRITE_FILLER_SUPPORTED
    if (png_ptr->transformations & PNG_FILLER)
-      png_do_strip_channel(&(png_ptr->row_info), png_ptr->row_buf + 1,
-         !(png_ptr->flags & PNG_FILLER_AFTER));
+      png_do_strip_channel(row_info, png_ptr->row_buf + 1,
+         !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
 #endif
 
 #ifdef PNG_WRITE_PACKSWAP_SUPPORTED
    if (png_ptr->transformations & PNG_PACKSWAP)
-      png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_packswap(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_WRITE_PACK_SUPPORTED
    if (png_ptr->transformations & PNG_PACK)
-      png_do_pack(&(png_ptr->row_info), png_ptr->row_buf + 1,
+      png_do_pack(row_info, png_ptr->row_buf + 1,
           (png_uint_32)png_ptr->bit_depth);
 #endif
 
 #ifdef PNG_WRITE_SWAP_SUPPORTED
    if (png_ptr->transformations & PNG_SWAP_BYTES)
-      png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_swap(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_WRITE_SHIFT_SUPPORTED
    if (png_ptr->transformations & PNG_SHIFT)
-      png_do_shift(&(png_ptr->row_info), png_ptr->row_buf + 1,
+      png_do_shift(row_info, png_ptr->row_buf + 1,
           &(png_ptr->shift));
 #endif
 
 #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
    if (png_ptr->transformations & PNG_SWAP_ALPHA)
-      png_do_write_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
    if (png_ptr->transformations & PNG_INVERT_ALPHA)
-      png_do_write_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_WRITE_BGR_SUPPORTED
    if (png_ptr->transformations & PNG_BGR)
-      png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_bgr(row_info, png_ptr->row_buf + 1);
 #endif
 
 #ifdef PNG_WRITE_INVERT_SUPPORTED
    if (png_ptr->transformations & PNG_INVERT_MONO)
-      png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
+      png_do_invert(row_info, png_ptr->row_buf + 1);
 #endif
 }
 
@@ -563,6 +564,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
    }
 }
 #endif
+#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
 
 #ifdef PNG_MNG_FEATURES_SUPPORTED
 /* Undoes intrapixel differencing  */
index 2c35785aa125a2138a069b75801e7449cc27c7c0..da18e9502efe3dc2a84e625dec615419597d9878 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * Last changed in libpng 1.5.0 [January 6, 2011]
+ * Last changed in libpng 1.5.6 [November 3, 2011]
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -82,39 +82,20 @@ png_write_sig(png_structp png_ptr)
       png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
 }
 
-/* Write a PNG chunk all at once.  The type is an array of ASCII characters
- * representing the chunk name.  The array must be at least 4 bytes in
- * length, and does not need to be null terminated.  To be safe, pass the
- * pre-defined chunk names here, and if you need a new one, define it
- * where the others are defined.  The length is the length of the data.
- * All the data must be present.  If that is not possible, use the
- * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()
- * functions instead.
- */
-void PNGAPI
-png_write_chunk(png_structp png_ptr, png_const_bytep chunk_name,
-   png_const_bytep data, png_size_t length)
-{
-   if (png_ptr == NULL)
-      return;
-
-   png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);
-   png_write_chunk_data(png_ptr, data, (png_size_t)length);
-   png_write_chunk_end(png_ptr);
-}
-
 /* Write the start of a PNG chunk.  The type is the chunk type.
  * The total_length is the sum of the lengths of all the data you will be
  * passing in png_write_chunk_data().
  */
-void PNGAPI
-png_write_chunk_start(png_structp png_ptr, png_const_bytep chunk_name,
+static void
+png_write_chunk_header(png_structp png_ptr, png_uint_32 chunk_name,
     png_uint_32 length)
 {
    png_byte buf[8];
 
-   png_debug2(0, "Writing %s chunk, length = %lu", chunk_name,
-      (unsigned long)length);
+#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
+   PNG_CSTRING_FROM_CHUNK(buf, chunk_name);
+   png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length);
+#endif
 
    if (png_ptr == NULL)
       return;
@@ -128,16 +109,16 @@ png_write_chunk_start(png_structp png_ptr, png_const_bytep chunk_name,
 
    /* Write the length and the chunk name */
    png_save_uint_32(buf, length);
-   png_memcpy(buf + 4, chunk_name, 4);
-   png_write_data(png_ptr, buf, (png_size_t)8);
+   png_save_uint_32(buf + 4, chunk_name);
+   png_write_data(png_ptr, buf, 8);
 
    /* Put the chunk name into png_ptr->chunk_name */
-   png_memcpy(png_ptr->chunk_name, chunk_name, 4);
+   png_ptr->chunk_name = chunk_name;
 
    /* Reset the crc and run it over the chunk name */
    png_reset_crc(png_ptr);
 
-   png_calculate_crc(png_ptr, chunk_name, 4);
+   png_calculate_crc(png_ptr, buf + 4, 4);
 
 #ifdef PNG_IO_STATE_SUPPORTED
    /* Inform the I/O callback that chunk data will (possibly) be written.
@@ -147,10 +128,17 @@ png_write_chunk_start(png_structp png_ptr, png_const_bytep chunk_name,
 #endif
 }
 
-/* Write the data of a PNG chunk started with png_write_chunk_start().
+void PNGAPI
+png_write_chunk_start(png_structp png_ptr, png_const_bytep chunk_string,
+    png_uint_32 length)
+{
+   png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length);
+}
+
+/* Write the data of a PNG chunk started with png_write_chunk_header().
  * Note that multiple calls to this function are allowed, and that the
  * sum of the lengths from these calls *must* add up to the total_length
- * given to png_write_chunk_start().
+ * given to png_write_chunk_header().
  */
 void PNGAPI
 png_write_chunk_data(png_structp png_ptr, png_const_bytep data,
@@ -171,7 +159,7 @@ png_write_chunk_data(png_structp png_ptr, png_const_bytep data,
    }
 }
 
-/* Finish a chunk started with png_write_chunk_start(). */
+/* Finish a chunk started with png_write_chunk_header(). */
 void PNGAPI
 png_write_chunk_end(png_structp png_ptr)
 {
@@ -192,7 +180,183 @@ png_write_chunk_end(png_structp png_ptr)
    png_write_data(png_ptr, buf, (png_size_t)4);
 }
 
-#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED)
+/* Write a PNG chunk all at once.  The type is an array of ASCII characters
+ * representing the chunk name.  The array must be at least 4 bytes in
+ * length, and does not need to be null terminated.  To be safe, pass the
+ * pre-defined chunk names here, and if you need a new one, define it
+ * where the others are defined.  The length is the length of the data.
+ * All the data must be present.  If that is not possible, use the
+ * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()
+ * functions instead.
+ */
+static void
+png_write_complete_chunk(png_structp png_ptr, png_uint_32 chunk_name,
+   png_const_bytep data, png_size_t length)
+{
+   if (png_ptr == NULL)
+      return;
+
+   /* On 64 bit architectures 'length' may not fit in a png_uint_32. */
+   if (length > PNG_UINT_32_MAX)
+      png_error(png_ptr, "length exceeds PNG maxima");
+
+   png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
+   png_write_chunk_data(png_ptr, data, length);
+   png_write_chunk_end(png_ptr);
+}
+
+/* This is the API that calls the internal function above. */
+void PNGAPI
+png_write_chunk(png_structp png_ptr, png_const_bytep chunk_string,
+   png_const_bytep data, png_size_t length)
+{
+   png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,
+      length);
+}
+
+/* Initialize the compressor for the appropriate type of compression. */
+static void
+png_zlib_claim(png_structp png_ptr, png_uint_32 state)
+{
+   if (!(png_ptr->zlib_state & PNG_ZLIB_IN_USE))
+   {
+      /* If already initialized for 'state' do not re-init. */
+      if (png_ptr->zlib_state != state)
+      {
+         int ret = Z_OK;
+         png_const_charp who = "-";
+
+         /* If actually initialized for another state do a deflateEnd. */
+         if (png_ptr->zlib_state != PNG_ZLIB_UNINITIALIZED)
+         {
+            ret = deflateEnd(&png_ptr->zstream);
+            who = "end";
+            png_ptr->zlib_state = PNG_ZLIB_UNINITIALIZED;
+         }
+
+         /* zlib itself detects an incomplete state on deflateEnd */
+         if (ret == Z_OK) switch (state)
+         {
+#           ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
+               case PNG_ZLIB_FOR_TEXT:
+                  ret = deflateInit2(&png_ptr->zstream,
+                     png_ptr->zlib_text_level, png_ptr->zlib_text_method,
+                     png_ptr->zlib_text_window_bits,
+                     png_ptr->zlib_text_mem_level, png_ptr->zlib_text_strategy);
+                  who = "text";
+                  break;
+#           endif
+
+            case PNG_ZLIB_FOR_IDAT:
+               ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
+                   png_ptr->zlib_method, png_ptr->zlib_window_bits,
+                   png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
+               who = "IDAT";
+               break;
+
+            default:
+               png_error(png_ptr, "invalid zlib state");
+         }
+
+         if (ret == Z_OK)
+            png_ptr->zlib_state = state;
+
+         else /* an error in deflateEnd or deflateInit2 */
+         {
+            size_t pos = 0;
+            char msg[64];
+
+            pos = png_safecat(msg, sizeof msg, pos,
+               "zlib failed to initialize compressor (");
+            pos = png_safecat(msg, sizeof msg, pos, who);
+
+            switch (ret)
+            {
+               case Z_VERSION_ERROR:
+                  pos = png_safecat(msg, sizeof msg, pos, ") version error");
+                  break;
+
+               case Z_STREAM_ERROR:
+                  pos = png_safecat(msg, sizeof msg, pos, ") stream error");
+                  break;
+
+               case Z_MEM_ERROR:
+                  pos = png_safecat(msg, sizeof msg, pos, ") memory error");
+                  break;
+
+               default:
+                  pos = png_safecat(msg, sizeof msg, pos, ") unknown error");
+                  break;
+            }
+
+            png_error(png_ptr, msg);
+         }
+      }
+
+      /* Here on success, claim the zstream: */
+      png_ptr->zlib_state |= PNG_ZLIB_IN_USE;
+   }
+
+   else
+      png_error(png_ptr, "zstream already in use (internal error)");
+}
+
+/* The opposite: release the stream.  It is also reset, this API will warn on
+ * error but will not fail.
+ */
+static void
+png_zlib_release(png_structp png_ptr)
+{
+   if (png_ptr->zlib_state & PNG_ZLIB_IN_USE)
+   {
+      int ret = deflateReset(&png_ptr->zstream);
+
+      png_ptr->zlib_state &= ~PNG_ZLIB_IN_USE;
+
+      if (ret != Z_OK)
+      {
+         png_const_charp err;
+         PNG_WARNING_PARAMETERS(p)
+
+         switch (ret)
+         {
+            case Z_VERSION_ERROR:
+               err = "version";
+               break;
+
+            case Z_STREAM_ERROR:
+               err = "stream";
+               break;
+
+            case Z_MEM_ERROR:
+               err = "memory";
+               break;
+
+            default:
+               err = "unknown";
+               break;
+         }
+
+         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_d, ret);
+         png_warning_parameter(p, 2, err);
+
+         if (png_ptr->zstream.msg)
+            err = png_ptr->zstream.msg;
+         else
+            err = "[no zlib message]";
+
+         png_warning_parameter(p, 3, err);
+
+         png_formatted_warning(png_ptr, p,
+            "zlib failed to reset compressor: @1(@2): @3");
+      }
+   }
+
+   else
+      png_warning(png_ptr, "zstream not in use (internal error)");
+}
+
+#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
 /* This pair of functions encapsulates the operation of (a) compressing a
  * text string, and (b) issuing it later as a series of chunk data writes.
  * The compression_state structure is shared context for these functions
@@ -220,25 +384,22 @@ png_text_compress(png_structp png_ptr,
    comp->max_output_ptr = 0;
    comp->output_ptr = NULL;
    comp->input = NULL;
-   comp->input_len = 0;
+   comp->input_len = text_len;
 
    /* We may just want to pass the text right through */
    if (compression == PNG_TEXT_COMPRESSION_NONE)
    {
       comp->input = (png_const_bytep)text;
-      comp->input_len = text_len;
       return((int)text_len);
    }
 
    if (compression >= PNG_TEXT_COMPRESSION_LAST)
    {
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-      char msg[50];
-      png_snprintf(msg, 50, "Unknown compression type %d", compression);
-      png_warning(png_ptr, msg);
-#else
-      png_warning(png_ptr, "Unknown compression type");
-#endif
+      PNG_WARNING_PARAMETERS(p)
+
+      png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_d,
+         compression);
+      png_formatted_warning(png_ptr, p, "Unknown compression type @1");
    }
 
    /* We can't write the chunk until we find out how much data we have,
@@ -255,10 +416,12 @@ png_text_compress(png_structp png_ptr,
     * data, or if the input string is incredibly large (although this
     * wouldn't cause a failure, just a slowdown due to swapping).
     */
+   png_zlib_claim(png_ptr, PNG_ZLIB_FOR_TEXT);
 
    /* Set up the compression buffers */
    /* TODO: the following cast hides a potential overflow problem. */
    png_ptr->zstream.avail_in = (uInt)text_len;
+
    /* NOTE: assume zlib doesn't overwrite the input */
    png_ptr->zstream.next_in = (Bytef *)text;
    png_ptr->zstream.avail_out = png_ptr->zbuf_size;
@@ -418,6 +581,71 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
       return;
    }
 
+#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
+   /* The zbuf_size test is because the code below doesn't work if zbuf_size is
+    * '1'; simply skip it to avoid memory overwrite.
+    */
+   if (comp->input_len >= 2 && comp->input_len < 16384 && png_ptr->zbuf_size > 1)
+   {
+      unsigned int z_cmf;  /* zlib compression method and flags */
+
+      /* Optimize the CMF field in the zlib stream.  This hack of the zlib
+       * stream is compliant to the stream specification.
+       */
+
+      if (comp->num_output_ptr)
+        z_cmf = comp->output_ptr[0][0];
+      else
+        z_cmf = png_ptr->zbuf[0];
+
+      if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
+      {
+         unsigned int z_cinfo;
+         unsigned int half_z_window_size;
+         png_size_t uncompressed_text_size = comp->input_len;
+
+         z_cinfo = z_cmf >> 4;
+         half_z_window_size = 1 << (z_cinfo + 7);
+
+         while (uncompressed_text_size <= half_z_window_size &&
+             half_z_window_size >= 256)
+         {
+            z_cinfo--;
+            half_z_window_size >>= 1;
+         }
+
+         z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);
+
+         if (comp->num_output_ptr)
+         {
+
+           if (comp->output_ptr[0][0] != z_cmf)
+           {
+              int tmp;
+
+              comp->output_ptr[0][0] = (png_byte)z_cmf;
+              tmp = comp->output_ptr[0][1] & 0xe0;
+              tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
+              comp->output_ptr[0][1] = (png_byte)tmp;
+           }
+         }
+         else
+         {
+            int tmp;
+
+            png_ptr->zbuf[0] = (png_byte)z_cmf;
+            tmp = png_ptr->zbuf[1] & 0xe0;
+            tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;
+            png_ptr->zbuf[1] = (png_byte)tmp;
+         }
+      }
+
+      else
+         png_error(png_ptr,
+             "Invalid zlib compression method or flags in non-IDAT chunk");
+   }
+#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
+
    /* Write saved output buffers, if any */
    for (i = 0; i < comp->num_output_ptr; i++)
    {
@@ -436,10 +664,9 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
           (png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out));
 
    /* Reset zlib for another zTXt/iTXt or image data */
-   deflateReset(&png_ptr->zstream);
-   png_ptr->zstream.data_type = Z_BINARY;
+   png_zlib_release(png_ptr);
 }
-#endif
+#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
 
 /* Write the IHDR chunk, and update the png_struct with the necessary
  * information.  Note that the rest of this code depends upon this
@@ -450,9 +677,6 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
     int bit_depth, int color_type, int compression_type, int filter_type,
     int interlace_type)
 {
-   PNG_IHDR;
-   int ret;
-
    png_byte buf[13]; /* Buffer to store the IHDR info */
 
    png_debug(1, "in png_write_IHDR");
@@ -594,7 +818,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
    buf[12] = (png_byte)interlace_type;
 
    /* Write the chunk */
-   png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
+   png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
 
    /* Initialize zlib with PNG info */
    png_ptr->zstream.zalloc = png_zalloc;
@@ -632,35 +856,35 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
    if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
       png_ptr->zlib_method = 8;
 
-   ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
-       png_ptr->zlib_method, png_ptr->zlib_window_bits,
-       png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
+#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
+#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
+   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_STRATEGY))
+      png_ptr->zlib_text_strategy = Z_DEFAULT_STRATEGY;
 
-   if (ret != Z_OK)
-   {
-      if (ret == Z_VERSION_ERROR)
-         png_error(png_ptr,
-            "zlib failed to initialize compressor -- version error");
+   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_LEVEL))
+      png_ptr->zlib_text_level = png_ptr->zlib_level;
 
-      if (ret == Z_STREAM_ERROR)
-         png_error(png_ptr,
-             "zlib failed to initialize compressor -- stream error");
-
-      if (ret == Z_MEM_ERROR)
-         png_error(png_ptr,
-             "zlib failed to initialize compressor -- mem error");
+   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL))
+      png_ptr->zlib_text_mem_level = png_ptr->zlib_mem_level;
 
-      png_error(png_ptr, "zlib failed to initialize compressor");
-   }
+   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS))
+      png_ptr->zlib_text_window_bits = png_ptr->zlib_window_bits;
 
-   png_ptr->zstream.next_out = png_ptr->zbuf;
-   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
-   /* libpng is not interested in zstream.data_type, so set it
-    * to a predefined value, to avoid its evaluation inside zlib
-    */
-   png_ptr->zstream.data_type = Z_BINARY;
-
-   png_ptr->mode = PNG_HAVE_IHDR;
+   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_METHOD))
+      png_ptr->zlib_text_method = png_ptr->zlib_method;
+#else
+   png_ptr->zlib_text_strategy = Z_DEFAULT_STRATEGY;
+   png_ptr->zlib_text_level = png_ptr->zlib_level;
+   png_ptr->zlib_text_mem_level = png_ptr->zlib_mem_level;
+   png_ptr->zlib_text_window_bits = png_ptr->zlib_window_bits;
+   png_ptr->zlib_text_method = png_ptr->zlib_method;
+#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
+#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
+
+   /* Record that the compressor has not yet been initialized. */
+   png_ptr->zlib_state = PNG_ZLIB_UNINITIALIZED;
+
+   png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */
 }
 
 /* Write the palette.  We are careful not to trust png_color to be in the
@@ -671,7 +895,6 @@ void /* PRIVATE */
 png_write_PLTE(png_structp png_ptr, png_const_colorp palette,
     png_uint_32 num_pal)
 {
-   PNG_PLTE;
    png_uint_32 i;
    png_const_colorp pal_ptr;
    png_byte buf[3];
@@ -707,7 +930,7 @@ png_write_PLTE(png_structp png_ptr, png_const_colorp palette,
    png_ptr->num_palette = (png_uint_16)num_pal;
    png_debug1(3, "num_palette = %d", png_ptr->num_palette);
 
-   png_write_chunk_start(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3));
+   png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3));
 #ifdef PNG_POINTER_INDEXING_SUPPORTED
 
    for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
@@ -741,16 +964,17 @@ png_write_PLTE(png_structp png_ptr, png_const_colorp palette,
 void /* PRIVATE */
 png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
 {
-   PNG_IDAT;
-
    png_debug(1, "in png_write_IDAT");
 
-   /* Optimize the CMF field in the zlib stream. */
-   /* This hack of the zlib stream is compliant to the stream specification. */
+#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
    if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
        png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
    {
+      /* Optimize the CMF field in the zlib stream.  This hack of the zlib
+       * stream is compliant to the stream specification.
+       */
       unsigned int z_cmf = data[0];  /* zlib compression method and flags */
+
       if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
       {
          /* Avoid memory underflows and multiplication overflows.
@@ -761,11 +985,29 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
          if (length >= 2 &&
              png_ptr->height < 16384 && png_ptr->width < 16384)
          {
+            /* Compute the maximum possible length of the datastream */
+
+            /* Number of pixels, plus for each row a filter byte
+             * and possibly a padding byte, so increase the maximum
+             * size to account for these.
+             */
+            unsigned int z_cinfo;
+            unsigned int half_z_window_size;
             png_uint_32 uncompressed_idat_size = png_ptr->height *
                 ((png_ptr->width *
                 png_ptr->channels * png_ptr->bit_depth + 15) >> 3);
-            unsigned int z_cinfo = z_cmf >> 4;
-            unsigned int half_z_window_size = 1 << (z_cinfo + 7);
+
+            /* If it's interlaced, each block of 8 rows is sent as up to
+             * 14 rows, i.e., 6 additional rows, each with a filter byte
+             * and possibly a padding byte
+             */
+            if (png_ptr->interlaced)
+               uncompressed_idat_size += ((png_ptr->height + 7)/8) *
+                   (png_ptr->bit_depth < 8 ? 12 : 6);
+
+            z_cinfo = z_cmf >> 4;
+            half_z_window_size = 1 << (z_cinfo + 7);
+
             while (uncompressed_idat_size <= half_z_window_size &&
                 half_z_window_size >= 256)
             {
@@ -790,20 +1032,26 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
          png_error(png_ptr,
              "Invalid zlib compression method or flags in IDAT");
    }
+#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
 
-   png_write_chunk(png_ptr, png_IDAT, data, length);
+   png_write_complete_chunk(png_ptr, png_IDAT, data, length);
    png_ptr->mode |= PNG_HAVE_IDAT;
+
+   /* Prior to 1.5.4 this code was replicated in every caller (except at the
+    * end, where it isn't technically necessary).  Since this function has
+    * flushed the data we can safely reset the zlib output buffer here.
+    */
+   png_ptr->zstream.next_out = png_ptr->zbuf;
+   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
 }
 
 /* Write an IEND chunk */
 void /* PRIVATE */
 png_write_IEND(png_structp png_ptr)
 {
-   PNG_IEND;
-
    png_debug(1, "in png_write_IEND");
 
-   png_write_chunk(png_ptr, png_IEND, NULL, (png_size_t)0);
+   png_write_complete_chunk(png_ptr, png_IEND, NULL, (png_size_t)0);
    png_ptr->mode |= PNG_HAVE_IEND;
 }
 
@@ -812,14 +1060,13 @@ png_write_IEND(png_structp png_ptr)
 void /* PRIVATE */
 png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
 {
-   PNG_gAMA;
    png_byte buf[4];
 
    png_debug(1, "in png_write_gAMA");
 
    /* file_gamma is saved in 1/100,000ths */
    png_save_uint_32(buf, (png_uint_32)file_gamma);
-   png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
+   png_write_complete_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
 }
 #endif
 
@@ -828,7 +1075,6 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
 void /* PRIVATE */
 png_write_sRGB(png_structp png_ptr, int srgb_intent)
 {
-   PNG_sRGB;
    png_byte buf[1];
 
    png_debug(1, "in png_write_sRGB");
@@ -838,7 +1084,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
           "Invalid sRGB rendering intent specified");
 
    buf[0]=(png_byte)srgb_intent;
-   png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
+   png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
 }
 #endif
 
@@ -848,7 +1094,6 @@ void /* PRIVATE */
 png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type,
     png_const_charp profile, int profile_len)
 {
-   PNG_iCCP;
    png_size_t name_len;
    png_charp new_name;
    compression_state comp;
@@ -909,7 +1154,7 @@ png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type,
           (png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp);
 
    /* Make sure we include the NULL after the name and the compression type */
-   png_write_chunk_start(png_ptr, png_iCCP,
+   png_write_chunk_header(png_ptr, png_iCCP,
        (png_uint_32)(name_len + profile_len + 2));
 
    new_name[name_len + 1] = 0x00;
@@ -918,7 +1163,10 @@ png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type,
        (png_size_t)(name_len + 2));
 
    if (profile_len)
+   {
+      comp.input_len = profile_len;
       png_write_compressed_data_out(png_ptr, &comp);
+   }
 
    png_write_chunk_end(png_ptr);
    png_free(png_ptr, new_name);
@@ -930,7 +1178,6 @@ png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type,
 void /* PRIVATE */
 png_write_sPLT(png_structp png_ptr, png_const_sPLT_tp spalette)
 {
-   PNG_sPLT;
    png_size_t name_len;
    png_charp new_name;
    png_byte entrybuf[10];
@@ -947,7 +1194,7 @@ png_write_sPLT(png_structp png_ptr, png_const_sPLT_tp spalette)
       return;
 
    /* Make sure we include the NULL after the name */
-   png_write_chunk_start(png_ptr, png_sPLT,
+   png_write_chunk_header(png_ptr, png_sPLT,
        (png_uint_32)(name_len + 2 + palette_size));
 
    png_write_chunk_data(png_ptr, (png_bytep)new_name,
@@ -1015,7 +1262,6 @@ png_write_sPLT(png_structp png_ptr, png_const_sPLT_tp spalette)
 void /* PRIVATE */
 png_write_sBIT(png_structp png_ptr, png_const_color_8p sbit, int color_type)
 {
-   PNG_sBIT;
    png_byte buf[4];
    png_size_t size;
 
@@ -1066,7 +1312,7 @@ png_write_sBIT(png_structp png_ptr, png_const_color_8p sbit, int color_type)
       buf[size++] = sbit->alpha;
    }
 
-   png_write_chunk(png_ptr, png_sBIT, buf, size);
+   png_write_complete_chunk(png_ptr, png_sBIT, buf, size);
 }
 #endif
 
@@ -1078,7 +1324,6 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
     png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x,
     png_fixed_point blue_y)
 {
-   PNG_cHRM;
    png_byte buf[32];
 
    png_debug(1, "in png_write_cHRM");
@@ -1101,7 +1346,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
       png_save_uint_32(buf + 24, (png_uint_32)blue_x);
       png_save_uint_32(buf + 28, (png_uint_32)blue_y);
 
-      png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
+      png_write_complete_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
    }
 }
 #endif
@@ -1112,7 +1357,6 @@ void /* PRIVATE */
 png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,
     png_const_color_16p tran, int num_trans, int color_type)
 {
-   PNG_tRNS;
    png_byte buf[6];
 
    png_debug(1, "in png_write_tRNS");
@@ -1126,7 +1370,7 @@ png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,
       }
 
       /* Write the chunk out as it is */
-      png_write_chunk(png_ptr, png_tRNS, trans_alpha, (png_size_t)num_trans);
+      png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, (png_size_t)num_trans);
    }
 
    else if (color_type == PNG_COLOR_TYPE_GRAY)
@@ -1141,7 +1385,7 @@ png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,
       }
 
       png_save_uint_16(buf, tran->gray);
-      png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
+      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
    }
 
    else if (color_type == PNG_COLOR_TYPE_RGB)
@@ -1161,7 +1405,7 @@ png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,
          return;
       }
 
-      png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
+      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
    }
 
    else
@@ -1176,7 +1420,6 @@ png_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,
 void /* PRIVATE */
 png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
 {
-   PNG_bKGD;
    png_byte buf[6];
 
    png_debug(1, "in png_write_bKGD");
@@ -1195,7 +1438,7 @@ png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
       }
 
       buf[0] = back->index;
-      png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
+      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
    }
 
    else if (color_type & PNG_COLOR_MASK_COLOR)
@@ -1215,7 +1458,7 @@ png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
          return;
       }
 
-      png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
+      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
    }
 
    else
@@ -1229,7 +1472,7 @@ png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
       }
 
       png_save_uint_16(buf, back->gray);
-      png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
+      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
    }
 }
 #endif
@@ -1239,7 +1482,6 @@ png_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)
 void /* PRIVATE */
 png_write_hIST(png_structp png_ptr, png_const_uint_16p hist, int num_hist)
 {
-   PNG_hIST;
    int i;
    png_byte buf[3];
 
@@ -1254,7 +1496,7 @@ png_write_hIST(png_structp png_ptr, png_const_uint_16p hist, int num_hist)
       return;
    }
 
-   png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
+   png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
 
    for (i = 0; i < num_hist; i++)
    {
@@ -1313,15 +1555,11 @@ png_check_keyword(png_structp png_ptr, png_const_charp key, png_charpp new_key)
       if ((png_byte)*ikp < 0x20 ||
          ((png_byte)*ikp > 0x7E && (png_byte)*ikp < 0xA1))
       {
-#ifdef PNG_CONSOLE_IO_SUPPORTED
-         char msg[40];
+         PNG_WARNING_PARAMETERS(p)
 
-         png_snprintf(msg, 40,
-             "invalid keyword character 0x%02X", (png_byte)*ikp);
-         png_warning(png_ptr, msg);
-#else
-         png_warning(png_ptr, "invalid character in keyword");
-#endif
+         png_warning_parameter_unsigned(p, 1, PNG_NUMBER_FORMAT_02x,
+            (png_byte)*ikp);
+         png_formatted_warning(png_ptr, p, "invalid keyword character 0x@1");
          *dp = ' ';
       }
 
@@ -1408,7 +1646,6 @@ void /* PRIVATE */
 png_write_tEXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
     png_size_t text_len)
 {
-   PNG_tEXt;
    png_size_t key_len;
    png_charp new_key;
 
@@ -1424,7 +1661,7 @@ png_write_tEXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
       text_len = png_strlen(text);
 
    /* Make sure we include the 0 after the key */
-   png_write_chunk_start(png_ptr, png_tEXt,
+   png_write_chunk_header(png_ptr, png_tEXt,
        (png_uint_32)(key_len + text_len + 1));
    /*
     * We leave it to the application to meet PNG-1.0 requirements on the
@@ -1450,7 +1687,6 @@ void /* PRIVATE */
 png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
     png_size_t text_len, int compression)
 {
-   PNG_zTXt;
    png_size_t key_len;
    png_byte buf;
    png_charp new_key;
@@ -1484,7 +1720,7 @@ png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
        &comp);
 
    /* Write start of chunk */
-   png_write_chunk_start(png_ptr, png_zTXt,
+   png_write_chunk_header(png_ptr, png_zTXt,
        (png_uint_32)(key_len+text_len + 2));
 
    /* Write key */
@@ -1499,6 +1735,7 @@ png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
    png_write_chunk_data(png_ptr, &buf, (png_size_t)1);
 
    /* Write the compressed data */
+   comp.input_len = text_len;
    png_write_compressed_data_out(png_ptr, &comp);
 
    /* Close the chunk */
@@ -1512,7 +1749,6 @@ void /* PRIVATE */
 png_write_iTXt(png_structp png_ptr, int compression, png_const_charp key,
     png_const_charp lang, png_const_charp lang_key, png_const_charp text)
 {
-   PNG_iTXt;
    png_size_t lang_len, key_len, lang_key_len, text_len;
    png_charp new_lang;
    png_charp new_key = NULL;
@@ -1557,7 +1793,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_const_charp key,
     * and the NULs after the key, lang, and lang_key parts
     */
 
-   png_write_chunk_start(png_ptr, png_iTXt, (png_uint_32)(
+   png_write_chunk_header(png_ptr, png_iTXt, (png_uint_32)(
         5 /* comp byte, comp flag, terminators for key, lang and lang_key */
         + key_len
         + lang_len
@@ -1606,7 +1842,6 @@ void /* PRIVATE */
 png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
     int unit_type)
 {
-   PNG_oFFs;
    png_byte buf[9];
 
    png_debug(1, "in png_write_oFFs");
@@ -1618,7 +1853,7 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
    png_save_int_32(buf + 4, y_offset);
    buf[8] = (png_byte)unit_type;
 
-   png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
+   png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
 }
 #endif
 #ifdef PNG_WRITE_pCAL_SUPPORTED
@@ -1628,9 +1863,8 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
     png_int_32 X1, int type, int nparams, png_const_charp units,
     png_charpp params)
 {
-   PNG_pCAL;
    png_size_t purpose_len, units_len, total_len;
-   png_uint_32p params_len;
+   png_size_tp params_len;
    png_byte buf[10];
    png_charp new_purpose;
    int i;
@@ -1646,8 +1880,8 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
    png_debug1(3, "pCAL units length = %d", (int)units_len);
    total_len = purpose_len + units_len + 10;
 
-   params_len = (png_uint_32p)png_malloc(png_ptr,
-       (png_alloc_size_t)(nparams * png_sizeof(png_uint_32)));
+   params_len = (png_size_tp)png_malloc(png_ptr,
+       (png_alloc_size_t)(nparams * png_sizeof(png_size_t)));
 
    /* Find the length of each parameter, making sure we don't count the
     * null terminator for the last parameter.
@@ -1657,13 +1891,12 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
       params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
       png_debug2(3, "pCAL parameter %d length = %lu", i,
           (unsigned long)params_len[i]);
-      total_len += (png_size_t)params_len[i];
+      total_len += params_len[i];
    }
 
    png_debug1(3, "pCAL total length = %d", (int)total_len);
-   png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
-   png_write_chunk_data(png_ptr, (png_const_bytep)new_purpose,
-       (png_size_t)purpose_len);
+   png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len);
+   png_write_chunk_data(png_ptr, (png_const_bytep)new_purpose, purpose_len);
    png_save_int_32(buf, X0);
    png_save_int_32(buf + 4, X1);
    buf[8] = (png_byte)type;
@@ -1675,8 +1908,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
 
    for (i = 0; i < nparams; i++)
    {
-      png_write_chunk_data(png_ptr, (png_const_bytep)params[i],
-          (png_size_t)params_len[i]);
+      png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]);
    }
 
    png_free(png_ptr, params_len);
@@ -1690,7 +1922,6 @@ void /* PRIVATE */
 png_write_sCAL_s(png_structp png_ptr, int unit, png_const_charp width,
     png_const_charp height)
 {
-   PNG_sCAL;
    png_byte buf[64];
    png_size_t wlen, hlen, total_len;
 
@@ -1711,7 +1942,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_const_charp width,
    png_memcpy(buf + wlen + 2, height, hlen);  /* Do NOT append the '\0' here */
 
    png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
-   png_write_chunk(png_ptr, png_sCAL, buf, total_len);
+   png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len);
 }
 #endif
 
@@ -1722,7 +1953,6 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
     png_uint_32 y_pixels_per_unit,
     int unit_type)
 {
-   PNG_pHYs;
    png_byte buf[9];
 
    png_debug(1, "in png_write_pHYs");
@@ -1734,7 +1964,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
    png_save_uint_32(buf + 4, y_pixels_per_unit);
    buf[8] = (png_byte)unit_type;
 
-   png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
+   png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
 }
 #endif
 
@@ -1745,7 +1975,6 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
 void /* PRIVATE */
 png_write_tIME(png_structp png_ptr, png_const_timep mod_time)
 {
-   PNG_tIME;
    png_byte buf[7];
 
    png_debug(1, "in png_write_tIME");
@@ -1765,7 +1994,7 @@ png_write_tIME(png_structp png_ptr, png_const_timep mod_time)
    buf[5] = mod_time->minute;
    buf[6] = mod_time->second;
 
-   png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
+   png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
 }
 #endif
 
@@ -1777,28 +2006,32 @@ png_write_start_row(png_structp png_ptr)
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 #endif
 
-   png_size_t buf_size;
+   png_alloc_size_t buf_size;
+   int usr_pixel_depth;
 
    png_debug(1, "in png_write_start_row");
 
-   buf_size = (png_size_t)(PNG_ROWBYTES(
-       png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1);
+   usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;
+   buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;
+
+   /* 1.5.6: added to allow checking in the row write code. */
+   png_ptr->transformed_pixel_depth = png_ptr->pixel_depth;
+   png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
 
    /* Set up row buffer */
-   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr,
-       (png_alloc_size_t)buf_size);
+   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
 
    png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
 
@@ -1815,8 +2048,7 @@ png_write_start_row(png_structp png_ptr)
    if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
    {
       /* Set up previous row buffer */
-      png_ptr->prev_row = (png_bytep)png_calloc(png_ptr,
-          (png_alloc_size_t)buf_size);
+      png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);
 
       if (png_ptr->do_filter & PNG_FILTER_UP)
       {
@@ -1871,6 +2103,7 @@ png_write_start_row(png_structp png_ptr)
       png_ptr->usr_width = png_ptr->width;
    }
 
+   png_zlib_claim(png_ptr, PNG_ZLIB_FOR_IDAT);
    png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
    png_ptr->zstream.next_out = png_ptr->zbuf;
 }
@@ -1883,16 +2116,16 @@ png_write_finish_row(png_structp png_ptr)
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 #endif
 
    int ret;
@@ -1992,7 +2225,7 @@ png_write_finish_row(png_structp png_ptr)
           png_ptr->zstream.avail_out);
    }
 
-   deflateReset(&png_ptr->zstream);
+   png_zlib_release(png_ptr);
    png_ptr->zstream.data_type = Z_BINARY;
 }
 
@@ -2010,10 +2243,10 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static PNG_CONST png_byte  png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    png_debug(1, "in png_do_write_interlace");
 
@@ -2181,6 +2414,9 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
  * been specified by the application, and then writes the row out with the
  * chosen filter.
  */
+static void png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row,
+   png_size_t row_bytes);
+
 #define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)
 #define PNG_HISHIFT 10
 #define PNG_LOMASK ((png_uint_32)0xffffL)
@@ -2195,7 +2431,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
    png_byte filter_to_do = png_ptr->do_filter;
    png_size_t row_bytes = row_info->rowbytes;
 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-   int num_p_filters = (int)png_ptr->num_prev_filters;
+   int num_p_filters = png_ptr->num_prev_filters;
 #endif
 
    png_debug(1, "in png_write_find_filter");
@@ -2832,9 +3068,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
       }
    }
 #endif /* PNG_WRITE_FILTER_SUPPORTED */
-   /* Do the actual writing of the filtered row data from the chosen filter. */
 
-   png_write_filtered_row(png_ptr, best_row);
+   /* Do the actual writing of the filtered row data from the chosen filter. */
+   png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
 
 #ifdef PNG_WRITE_FILTER_SUPPORTED
 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
@@ -2856,11 +3092,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
 
 
 /* Do the actual writing of a previously filtered row. */
-void /* PRIVATE */
-png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
+static void
+png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row,
+   png_size_t avail/*includes filter byte*/)
 {
-   png_size_t avail;
-
    png_debug(1, "in png_write_filtered_row");
 
    png_debug1(2, "filter = %d", filtered_row[0]);
@@ -2868,7 +3103,6 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
 
    png_ptr->zstream.next_in = filtered_row;
    png_ptr->zstream.avail_in = 0;
-   avail = png_ptr->row_info.rowbytes + 1;
    /* Repeat until we have compressed all the data */
    do
    {
@@ -2916,8 +3150,6 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
       {
          /* Write the IDAT and reset the zlib output buffer */
          png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
-         png_ptr->zstream.next_out = png_ptr->zbuf;
-         png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
       }
    /* Repeat until all data has been compressed */
    } while (avail > 0 || png_ptr->zstream.avail_in > 0);
diff --git a/thirdparty/msvc/.gitignore b/thirdparty/msvc/.gitignore
new file mode 100644 (file)
index 0000000..2460008
--- /dev/null
@@ -0,0 +1 @@
+!Makefile
diff --git a/thirdparty/msvc/Makefile b/thirdparty/msvc/Makefile
new file mode 100644 (file)
index 0000000..ab18b4d
--- /dev/null
@@ -0,0 +1,10 @@
+update: \
+       inttypes.h \
+       stdint.h
+
+%.h: FORCE
+       wget -N http://msinttypes.googlecode.com/svn/trunk/$@
+
+.PHONY: update
+
+FORCE:
index 5e7ccccb760863639e804550ebd172d9f6355b04..f79491b5c76b01d50227c57289e16fd49d069cfd 100644 (file)
@@ -1,3 +1,419 @@
+------------------------------------------------------------------------
+r60 | snappy.mirrorbot@gmail.com | 2012-02-23 18:00:36 +0100 (Thu, 23 Feb 2012) | 57 lines
+
+For 32-bit platforms, do not try to accelerate multiple neighboring
+32-bit loads with a 64-bit load during compression (it's not a win).
+
+The main target for this optimization is ARM, but 32-bit x86 gets
+a small gain, too, although there is noise in the microbenchmarks.
+It's a no-op for 64-bit x86. It does not affect decompression.
+
+Microbenchmark results on a Cortex-A9 1GHz, using g++ 4.6.2 (from
+Ubuntu/Linaro), -O2 -DNDEBUG -Wa,-march=armv7a -mtune=cortex-a9
+-mthumb-interwork, minimum 1000 iterations:
+
+  Benchmark            Time(ns)    CPU(ns) Iterations
+  ---------------------------------------------------
+  BM_ZFlat/0            1158277    1160000       1000 84.2MB/s  html (23.57 %)    [ +4.3%]
+  BM_ZFlat/1           14861782   14860000       1000 45.1MB/s  urls (50.89 %)    [ +1.1%]
+  BM_ZFlat/2             393595     390000       1000 310.5MB/s  jpg (99.88 %)    [ +0.0%]
+  BM_ZFlat/3             650583     650000       1000 138.4MB/s  pdf (82.13 %)    [ +3.1%]
+  BM_ZFlat/4            4661480    4660000       1000 83.8MB/s  html4 (23.55 %)   [ +4.3%]
+  BM_ZFlat/5             491973     490000       1000 47.9MB/s  cp (48.12 %)      [ +2.0%]
+  BM_ZFlat/6             193575     192678       1038 55.2MB/s  c (42.40 %)       [ +9.0%]
+  BM_ZFlat/7              62343      62754       3187 56.5MB/s  lsp (48.37 %)     [ +2.6%]
+  BM_ZFlat/8           17708468   17710000       1000 55.5MB/s  xls (41.34 %)     [ -0.3%]
+  BM_ZFlat/9            3755345    3760000       1000 38.6MB/s  txt1 (59.81 %)    [ +8.2%]
+  BM_ZFlat/10           3324217    3320000       1000 36.0MB/s  txt2 (64.07 %)    [ +4.2%]
+  BM_ZFlat/11          10139932   10140000       1000 40.1MB/s  txt3 (57.11 %)    [ +6.4%]
+  BM_ZFlat/12          13532109   13530000       1000 34.0MB/s  txt4 (68.35 %)    [ +5.0%]
+  BM_ZFlat/13           4690847    4690000       1000 104.4MB/s  bin (18.21 %)    [ +4.1%]
+  BM_ZFlat/14            830682     830000       1000 43.9MB/s  sum (51.88 %)     [ +1.2%]
+  BM_ZFlat/15             84784      85011       2235 47.4MB/s  man (59.36 %)     [ +1.1%]
+  BM_ZFlat/16           1293254    1290000       1000 87.7MB/s  pb (23.15 %)      [ +2.3%]
+  BM_ZFlat/17           2775155    2780000       1000 63.2MB/s  gaviota (38.27 %) [+12.2%]
+
+Core i7 in 32-bit mode (only one run and 100 iterations, though, so noisy):
+
+  Benchmark            Time(ns)    CPU(ns) Iterations
+  ---------------------------------------------------
+  BM_ZFlat/0             227582     223464       3043 437.0MB/s  html (23.57 %)    [ +7.4%]
+  BM_ZFlat/1            2982430    2918455        233 229.4MB/s  urls (50.89 %)    [ +2.9%]
+  BM_ZFlat/2              46967      46658      15217 2.5GB/s  jpg (99.88 %)       [ +0.0%]
+  BM_ZFlat/3             115298     114864       5833 783.2MB/s  pdf (82.13 %)     [ +1.5%]
+  BM_ZFlat/4             913440     899743        778 434.2MB/s  html4 (23.55 %)   [ +0.3%]
+  BM_ZFlat/5             110302     108571       7000 216.1MB/s  cp (48.12 %)      [ +0.0%]
+  BM_ZFlat/6              44409      43372      15909 245.2MB/s  c (42.40 %)       [ +0.8%]
+  BM_ZFlat/7              15713      15643      46667 226.9MB/s  lsp (48.37 %)     [ +2.7%]
+  BM_ZFlat/8            2625539    2602230        269 377.4MB/s  xls (41.34 %)     [ +1.4%]
+  BM_ZFlat/9             808884     811429        875 178.8MB/s  txt1 (59.81 %)    [ -3.9%]
+  BM_ZFlat/10            709532     700000       1000 170.5MB/s  txt2 (64.07 %)    [ +0.0%]
+  BM_ZFlat/11           2177682    2162162        333 188.2MB/s  txt3 (57.11 %)    [ -1.4%]
+  BM_ZFlat/12           2849640    2840000        250 161.8MB/s  txt4 (68.35 %)    [ -1.4%]
+  BM_ZFlat/13            849760     835476        778 585.8MB/s  bin (18.21 %)     [ +1.2%]
+  BM_ZFlat/14            165940     164571       4375 221.6MB/s  sum (51.88 %)     [ +1.4%]
+  BM_ZFlat/15             20939      20571      35000 196.0MB/s  man (59.36 %)     [ +2.1%]
+  BM_ZFlat/16            239209     236544       2917 478.1MB/s  pb (23.15 %)      [ +4.2%]
+  BM_ZFlat/17            616206     610000       1000 288.2MB/s  gaviota (38.27 %) [ -1.6%]
+
+R=sanjay
+
+------------------------------------------------------------------------
+r59 | snappy.mirrorbot@gmail.com | 2012-02-21 18:02:17 +0100 (Tue, 21 Feb 2012) | 107 lines
+
+Enable the use of unaligned loads and stores for ARM-based architectures 
+where they are available (ARMv7 and higher). This gives a significant 
+speed boost on ARM, both for compression and decompression. 
+It should not affect x86 at all. 
+There are more changes possible to speed up ARM, but it might not be 
+that easy to do without hurting x86 or making the code uglier. 
+Also, we de not try to use NEON yet. 
+Microbenchmark results on a Cortex-A9 1GHz, using g++ 4.6.2 (from Ubuntu/Linaro), 
+-O2 -DNDEBUG -Wa,-march=armv7a -mtune=cortex-a9 -mthumb-interwork: 
+Benchmark            Time(ns)    CPU(ns) Iterations
+---------------------------------------------------
+BM_UFlat/0             524806     529100        378 184.6MB/s  html            [+33.6%]
+BM_UFlat/1            5139790    5200000        100 128.8MB/s  urls            [+28.8%]
+BM_UFlat/2              86540      84166       1901 1.4GB/s  jpg               [ +0.6%]
+BM_UFlat/3             215351     210176        904 428.0MB/s  pdf             [+29.8%]
+BM_UFlat/4            2144490    2100000        100 186.0MB/s  html4           [+33.3%]
+BM_UFlat/5             194482     190000       1000 123.5MB/s  cp              [+36.2%]
+BM_UFlat/6              91843      90175       2107 117.9MB/s  c               [+38.6%]
+BM_UFlat/7              28535      28426       6684 124.8MB/s  lsp             [+34.7%]
+BM_UFlat/8            9206600    9200000        100 106.7MB/s  xls             [+42.4%]
+BM_UFlat/9            1865273    1886792        106 76.9MB/s  txt1             [+32.5%]
+BM_UFlat/10           1576809    1587301        126 75.2MB/s  txt2             [+32.3%]
+BM_UFlat/11           4968450    4900000        100 83.1MB/s  txt3             [+32.7%]
+BM_UFlat/12           6673970    6700000        100 68.6MB/s  txt4             [+32.8%]
+BM_UFlat/13           2391470    2400000        100 203.9MB/s  bin             [+29.2%]
+BM_UFlat/14            334601     344827        522 105.8MB/s  sum             [+30.6%]
+BM_UFlat/15             37404      38080       5252 105.9MB/s  man             [+33.8%]
+BM_UFlat/16            535470     540540        370 209.2MB/s  pb              [+31.2%]
+BM_UFlat/17           1875245    1886792        106 93.2MB/s  gaviota          [+37.8%]
+BM_UValidate/0         178425     179533       1114 543.9MB/s  html            [ +2.7%]
+BM_UValidate/1        2100450    2000000        100 334.8MB/s  urls            [ +5.0%]
+BM_UValidate/2           1039       1044     172413 113.3GB/s  jpg             [ +3.4%]
+BM_UValidate/3          59423      59470       3363 1.5GB/s  pdf               [ +7.8%]
+BM_UValidate/4         760716     766283        261 509.8MB/s  html4           [ +6.5%]
+BM_ZFlat/0            1204632    1204819        166 81.1MB/s  html (23.57 %)   [+32.8%]
+BM_ZFlat/1           15656190   15600000        100 42.9MB/s  urls (50.89 %)   [+27.6%]
+BM_ZFlat/2             403336     410677        487 294.8MB/s  jpg (99.88 %)   [+16.5%]
+BM_ZFlat/3             664073     671140        298 134.0MB/s  pdf (82.13 %)   [+28.4%]
+BM_ZFlat/4            4961940    4900000        100 79.7MB/s  html4 (23.55 %)  [+30.6%]
+BM_ZFlat/5             500664     501253        399 46.8MB/s  cp (48.12 %)     [+33.4%]
+BM_ZFlat/6             217276     215982        926 49.2MB/s  c (42.40 %)      [+25.0%]
+BM_ZFlat/7              64122      65487       3054 54.2MB/s  lsp (48.37 %)    [+36.1%]
+BM_ZFlat/8           18045730   18000000        100 54.6MB/s  xls (41.34 %)    [+34.4%]
+BM_ZFlat/9            4051530    4000000        100 36.3MB/s  txt1 (59.81 %)   [+25.0%]
+BM_ZFlat/10           3451800    3500000        100 34.1MB/s  txt2 (64.07 %)   [+25.7%]
+BM_ZFlat/11          11052340   11100000        100 36.7MB/s  txt3 (57.11 %)   [+24.3%]
+BM_ZFlat/12          14538690   14600000        100 31.5MB/s  txt4 (68.35 %)   [+24.7%]
+BM_ZFlat/13           5041850    5000000        100 97.9MB/s  bin (18.21 %)    [+32.0%]
+BM_ZFlat/14            908840     909090        220 40.1MB/s  sum (51.88 %)    [+22.2%]
+BM_ZFlat/15             86921      86206       1972 46.8MB/s  man (59.36 %)    [+42.2%]
+BM_ZFlat/16           1312315    1315789        152 86.0MB/s  pb (23.15 %)     [+34.5%]
+BM_ZFlat/17           3173120    3200000        100 54.9MB/s  gaviota (38.27%) [+28.1%]
+
+
+The move from 64-bit to 32-bit operations for the copies also affected 32-bit x86;
+positive on the decompression side, and slightly negative on the compression side
+(unless that is noise; I only ran once):
+
+Benchmark              Time(ns)    CPU(ns) Iterations
+-----------------------------------------------------
+BM_UFlat/0                86279      86140       7778 1.1GB/s  html             [ +7.5%]
+BM_UFlat/1               839265     822622        778 813.9MB/s  urls           [ +9.4%]
+BM_UFlat/2                 9180       9143      87500 12.9GB/s  jpg             [ +1.2%]
+BM_UFlat/3                35080      35000      20000 2.5GB/s  pdf              [+10.1%]
+BM_UFlat/4               350318     345000       2000 1.1GB/s  html4            [ +7.0%]
+BM_UFlat/5                33808      33472      21212 701.0MB/s  cp             [ +9.0%]
+BM_UFlat/6                15201      15214      46667 698.9MB/s  c              [+14.9%]
+BM_UFlat/7                 4652       4651     159091 762.9MB/s  lsp            [ +7.5%]
+BM_UFlat/8              1285551    1282528        538 765.7MB/s  xls            [+10.7%]
+BM_UFlat/9               282510     281690       2414 514.9MB/s  txt1           [+13.6%]
+BM_UFlat/10              243494     239286       2800 498.9MB/s  txt2           [+14.4%]
+BM_UFlat/11              743625     740000       1000 550.0MB/s  txt3           [+14.3%]
+BM_UFlat/12              999441     989717        778 464.3MB/s  txt4           [+16.1%]
+BM_UFlat/13              412402     410076       1707 1.2GB/s  bin              [ +7.3%]
+BM_UFlat/14               54876      54000      10000 675.3MB/s  sum            [+13.0%]
+BM_UFlat/15                6146       6100     100000 660.8MB/s  man            [+14.8%]
+BM_UFlat/16               90496      90286       8750 1.2GB/s  pb               [ +4.0%]
+BM_UFlat/17              292650     292000       2500 602.0MB/s  gaviota        [+18.1%]
+BM_UValidate/0            49620      49699      14286 1.9GB/s  html             [ +0.0%]
+BM_UValidate/1           501371     500000       1000 1.3GB/s  urls             [ +0.0%]
+BM_UValidate/2              232        227    3043478 521.5GB/s  jpg            [ +1.3%]
+BM_UValidate/3            17250      17143      43750 5.1GB/s  pdf              [ -1.3%]
+BM_UValidate/4           198643     200000       3500 1.9GB/s  html4            [ -0.9%]
+BM_ZFlat/0               227128     229415       3182 425.7MB/s  html (23.57 %) [ -1.4%]
+BM_ZFlat/1              2970089    2960000        250 226.2MB/s  urls (50.89 %) [ -1.9%]
+BM_ZFlat/2                45683      44999      15556 2.6GB/s  jpg (99.88 %)    [ +2.2%]
+BM_ZFlat/3               114661     113136       6364 795.1MB/s  pdf (82.13 %)  [ -1.5%]
+BM_ZFlat/4               919702     914286        875 427.2MB/s  html4 (23.55%) [ -1.3%]
+BM_ZFlat/5               108189     108422       6364 216.4MB/s  cp (48.12 %)   [ -1.2%]
+BM_ZFlat/6                44525      44000      15909 241.7MB/s  c (42.40 %)    [ -2.9%]
+BM_ZFlat/7                15973      15857      46667 223.8MB/s  lsp (48.37 %)  [ +0.0%]
+BM_ZFlat/8              2677888    2639405        269 372.1MB/s  xls (41.34 %)  [ -1.4%]
+BM_ZFlat/9               800715     780000       1000 186.0MB/s  txt1 (59.81 %) [ -0.4%]
+BM_ZFlat/10              700089     700000       1000 170.5MB/s  txt2 (64.07 %) [ -2.9%]
+BM_ZFlat/11             2159356    2138365        318 190.3MB/s  txt3 (57.11 %) [ -0.3%]
+BM_ZFlat/12             2796143    2779923        259 165.3MB/s  txt4 (68.35 %) [ -1.4%]
+BM_ZFlat/13              856458     835476        778 585.8MB/s  bin (18.21 %)  [ -0.1%]
+BM_ZFlat/14              166908     166857       4375 218.6MB/s  sum (51.88 %)  [ -1.4%]
+BM_ZFlat/15               21181      20857      35000 193.3MB/s  man (59.36 %)  [ -0.8%]
+BM_ZFlat/16              244009     239973       2917 471.3MB/s  pb (23.15 %)   [ -1.4%]
+BM_ZFlat/17              596362     590000       1000 297.9MB/s  gaviota (38.27%) [ +0.0%]
+
+R=sanjay
+
+------------------------------------------------------------------------
+r58 | snappy.mirrorbot@gmail.com | 2012-02-11 23:11:22 +0100 (Sat, 11 Feb 2012) | 9 lines
+
+Lower the size allocated in the "corrupted input" unit test from 256 MB
+to 2 MB. This fixes issues with running the unit test on platforms with
+little RAM (e.g. some ARM boards).
+
+Also, reactivate the 2 MB test for 64-bit platforms; there's no good
+reason why it shouldn't be.
+
+R=sanjay
+
+------------------------------------------------------------------------
+r57 | snappy.mirrorbot@gmail.com | 2012-01-08 18:55:48 +0100 (Sun, 08 Jan 2012) | 2 lines
+
+Minor refactoring to accomodate changes in Google's internal code tree.
+
+------------------------------------------------------------------------
+r56 | snappy.mirrorbot@gmail.com | 2012-01-04 14:10:46 +0100 (Wed, 04 Jan 2012) | 19 lines
+
+Fix public issue r57: Fix most warnings with -Wall, mostly signed/unsigned
+warnings. There are still some in the unit test, but the main .cc file should
+be clean. We haven't enabled -Wall for the default build, since the unit test
+is still not clean.
+
+This also fixes a real bug in the open-source implementation of
+ReadFileToStringOrDie(); it would not detect errors correctly.
+
+I had to go through some pains to avoid performance loss as the types
+were changed; I think there might still be some with 32-bit if and only if LFS
+is enabled (ie., size_t is 64-bit), but for regular 32-bit and 64-bit I can't
+see any losses, and I've diffed the generated GCC assembler between the old and
+new code without seeing any significant choices. If anything, it's ever so
+slightly faster.
+
+This may or may not enable compression of very large blocks (>2^32 bytes)
+when size_t is 64-bit, but I haven't checked, and it is still not a supported
+case.
+
+------------------------------------------------------------------------
+r55 | snappy.mirrorbot@gmail.com | 2012-01-04 11:46:39 +0100 (Wed, 04 Jan 2012) | 6 lines
+
+Add a framing format description. We do not have any implementation of this at
+the current point, but there seems to be enough of a general interest in the
+topic (cf. public bug #34).
+
+R=csilvers,sanjay
+
+------------------------------------------------------------------------
+r54 | snappy.mirrorbot@gmail.com | 2011-12-05 22:27:26 +0100 (Mon, 05 Dec 2011) | 81 lines
+
+Speed up decompression by moving the refill check to the end of the loop.
+
+This seems to work because in most of the branches, the compiler can evaluate
+“ip_limit_ - ip” in a more efficient way than reloading ip_limit_ from memory
+(either by already having the entire expression in a register, or reconstructing
+it from “avail”, or something else). Memory loads, even from L1, are seemingly
+costly in the big picture at the current decompression speeds.
+
+Microbenchmarks (64-bit, opt mode):
+
+Westmere (Intel Core i7):
+
+  Benchmark     Time(ns)    CPU(ns) Iterations
+  --------------------------------------------
+  BM_UFlat/0       74492      74491     187894 1.3GB/s  html      [ +5.9%]
+  BM_UFlat/1      712268     712263      19644 940.0MB/s  urls    [ +3.8%]
+  BM_UFlat/2       10591      10590    1000000 11.2GB/s  jpg      [ -6.8%]
+  BM_UFlat/3       29643      29643     469915 3.0GB/s  pdf       [ +7.9%]
+  BM_UFlat/4      304669     304667      45930 1.3GB/s  html4     [ +4.8%]
+  BM_UFlat/5       28508      28507     490077 823.1MB/s  cp      [ +4.0%]
+  BM_UFlat/6       12415      12415    1000000 856.5MB/s  c       [ +8.6%]
+  BM_UFlat/7        3415       3415    4084723 1039.0MB/s  lsp    [+18.0%]
+  BM_UFlat/8      979569     979563      14261 1002.5MB/s  xls    [ +5.8%]
+  BM_UFlat/9      230150     230148      60934 630.2MB/s  txt1    [ +5.2%]
+  BM_UFlat/10     197167     197166      71135 605.5MB/s  txt2    [ +4.7%]
+  BM_UFlat/11     607394     607390      23041 670.1MB/s  txt3    [ +5.6%]
+  BM_UFlat/12     808502     808496      17316 568.4MB/s  txt4    [ +5.0%]
+  BM_UFlat/13     372791     372788      37564 1.3GB/s  bin       [ +3.3%]
+  BM_UFlat/14      44541      44541     313969 818.8MB/s  sum     [ +5.7%]
+  BM_UFlat/15       4833       4833    2898697 834.1MB/s  man     [ +4.8%]
+  BM_UFlat/16      79855      79855     175356 1.4GB/s  pb        [ +4.8%]
+  BM_UFlat/17     245845     245843      56838 715.0MB/s  gaviota [ +5.8%]
+
+Clovertown (Intel Core 2):
+
+  Benchmark     Time(ns)    CPU(ns) Iterations
+  --------------------------------------------
+  BM_UFlat/0      107911     107890     100000 905.1MB/s  html    [ +2.2%]
+  BM_UFlat/1     1011237    1011041      10000 662.3MB/s  urls    [ +2.5%]
+  BM_UFlat/2       26775      26770     523089 4.4GB/s  jpg       [ +0.0%]
+  BM_UFlat/3       48103      48095     290618 1.8GB/s  pdf       [ +3.4%]
+  BM_UFlat/4      437724     437644      31937 892.6MB/s  html4   [ +2.1%]
+  BM_UFlat/5       39607      39600     358284 592.5MB/s  cp      [ +2.4%]
+  BM_UFlat/6       18227      18224     768191 583.5MB/s  c       [ +2.7%]
+  BM_UFlat/7        5171       5170    2709437 686.4MB/s  lsp     [ +3.9%]
+  BM_UFlat/8     1560291    1559989       8970 629.5MB/s  xls     [ +3.6%]
+  BM_UFlat/9      335401     335343      41731 432.5MB/s  txt1    [ +3.0%]
+  BM_UFlat/10     287014     286963      48758 416.0MB/s  txt2    [ +2.8%]
+  BM_UFlat/11     888522     888356      15752 458.1MB/s  txt3    [ +2.9%]
+  BM_UFlat/12    1186600    1186378      10000 387.3MB/s  txt4    [ +3.1%]
+  BM_UFlat/13     572295     572188      24468 855.4MB/s  bin     [ +2.1%]
+  BM_UFlat/14      64060      64049     218401 569.4MB/s  sum     [ +4.1%]
+  BM_UFlat/15       7264       7263    1916168 555.0MB/s  man     [ +1.4%]
+  BM_UFlat/16     108853     108836     100000 1039.1MB/s  pb     [ +1.7%]
+  BM_UFlat/17     364289     364223      38419 482.6MB/s  gaviota [ +4.9%]
+
+Barcelona (AMD Opteron):
+
+  Benchmark     Time(ns)    CPU(ns) Iterations
+  --------------------------------------------
+  BM_UFlat/0      103900     103871     100000 940.2MB/s  html    [ +8.3%]
+  BM_UFlat/1     1000435    1000107      10000 669.5MB/s  urls    [ +6.6%]
+  BM_UFlat/2       24659      24652     567362 4.8GB/s  jpg       [ +0.1%]
+  BM_UFlat/3       48206      48193     291121 1.8GB/s  pdf       [ +5.0%]
+  BM_UFlat/4      421980     421850      33174 926.0MB/s  html4   [ +7.3%]
+  BM_UFlat/5       40368      40357     346994 581.4MB/s  cp      [ +8.7%]
+  BM_UFlat/6       19836      19830     708695 536.2MB/s  c       [ +8.0%]
+  BM_UFlat/7        6100       6098    2292774 581.9MB/s  lsp     [ +9.0%]
+  BM_UFlat/8     1693093    1692514       8261 580.2MB/s  xls     [ +8.0%]
+  BM_UFlat/9      365991     365886      38225 396.4MB/s  txt1    [ +7.1%]
+  BM_UFlat/10     311330     311238      44950 383.6MB/s  txt2    [ +7.6%]
+  BM_UFlat/11     975037     974737      14376 417.5MB/s  txt3    [ +6.9%]
+  BM_UFlat/12    1303558    1303175      10000 352.6MB/s  txt4    [ +7.3%]
+  BM_UFlat/13     517448     517290      27144 946.2MB/s  bin     [ +5.5%]
+  BM_UFlat/14      66537      66518     210352 548.3MB/s  sum     [ +7.5%]
+  BM_UFlat/15       7976       7974    1760383 505.6MB/s  man     [ +5.6%]
+  BM_UFlat/16     103121     103092     100000 1097.0MB/s  pb     [ +8.7%]
+  BM_UFlat/17     391431     391314      35733 449.2MB/s  gaviota [ +6.5%]
+
+R=sanjay
+
+------------------------------------------------------------------------
+r53 | snappy.mirrorbot@gmail.com | 2011-11-23 12:14:17 +0100 (Wed, 23 Nov 2011) | 88 lines
+
+Speed up decompression by making the fast path for literals faster.
+
+We do the fast-path step as soon as possible; in fact, as soon as we know the
+literal length. Since we usually hit the fast path, we can then skip the checks
+for long literals and available input space (beyond what the fast path check
+already does).
+
+Note that this changes the decompression Writer API; however, it does not
+change the ABI, since writers are always templatized and as such never
+cross compilation units. The new API is slightly more general, in that it
+doesn't hard-code the value 16. Note that we also take care to check
+for len <= 16 first, since the other two checks almost always succeed
+(so we don't want to waste time checking for them until we have to).
+
+The improvements are most marked on Nehalem, but are generally positive
+on other platforms as well. All microbenchmarks are 64-bit, opt.
+
+Clovertown (Core 2):
+
+  Benchmark     Time(ns)    CPU(ns) Iterations
+  --------------------------------------------
+  BM_UFlat/0      110226     110224     100000 886.0MB/s  html    [ +1.5%]
+  BM_UFlat/1     1036523    1036508      10000 646.0MB/s  urls    [ -0.8%]
+  BM_UFlat/2       26775      26775     522570 4.4GB/s  jpg       [ +0.0%]
+  BM_UFlat/3       49738      49737     280974 1.8GB/s  pdf       [ +0.3%]
+  BM_UFlat/4      446790     446792      31334 874.3MB/s  html4   [ +0.8%]
+  BM_UFlat/5       40561      40562     350424 578.5MB/s  cp      [ +1.3%]
+  BM_UFlat/6       18722      18722     746903 568.0MB/s  c       [ +1.4%]
+  BM_UFlat/7        5373       5373    2608632 660.5MB/s  lsp     [ +8.3%]
+  BM_UFlat/8     1615716    1615718       8670 607.8MB/s  xls     [ +2.0%]
+  BM_UFlat/9      345278     345281      40481 420.1MB/s  txt1    [ +1.4%]
+  BM_UFlat/10     294855     294855      47452 404.9MB/s  txt2    [ +1.6%]
+  BM_UFlat/11     914263     914263      15316 445.2MB/s  txt3    [ +1.1%]
+  BM_UFlat/12    1222694    1222691      10000 375.8MB/s  txt4    [ +1.4%]
+  BM_UFlat/13     584495     584489      23954 837.4MB/s  bin     [ -0.6%]
+  BM_UFlat/14      66662      66662     210123 547.1MB/s  sum     [ +1.2%]
+  BM_UFlat/15       7368       7368    1881856 547.1MB/s  man     [ +4.0%]
+  BM_UFlat/16     110727     110726     100000 1021.4MB/s  pb     [ +2.3%]
+  BM_UFlat/17     382138     382141      36616 460.0MB/s  gaviota [ -0.7%]
+
+Westmere (Core i7):
+
+  Benchmark     Time(ns)    CPU(ns) Iterations
+  --------------------------------------------
+  BM_UFlat/0       78861      78853     177703 1.2GB/s  html      [ +2.1%]
+  BM_UFlat/1      739560     739491      18912 905.4MB/s  urls    [ +3.4%]
+  BM_UFlat/2        9867       9866    1419014 12.0GB/s  jpg      [ +3.4%]
+  BM_UFlat/3       31989      31986     438385 2.7GB/s  pdf       [ +0.2%]
+  BM_UFlat/4      319406     319380      43771 1.2GB/s  html4     [ +1.9%]
+  BM_UFlat/5       29639      29636     472862 791.7MB/s  cp      [ +5.2%]
+  BM_UFlat/6       13478      13477    1000000 789.0MB/s  c       [ +2.3%]
+  BM_UFlat/7        4030       4029    3475364 880.7MB/s  lsp     [ +8.7%]
+  BM_UFlat/8     1036585    1036492      10000 947.5MB/s  xls     [ +6.9%]
+  BM_UFlat/9      242127     242105      57838 599.1MB/s  txt1    [ +3.0%]
+  BM_UFlat/10     206499     206480      67595 578.2MB/s  txt2    [ +3.4%]
+  BM_UFlat/11     641635     641570      21811 634.4MB/s  txt3    [ +2.4%]
+  BM_UFlat/12     848847     848769      16443 541.4MB/s  txt4    [ +3.1%]
+  BM_UFlat/13     384968     384938      36366 1.2GB/s  bin       [ +0.3%]
+  BM_UFlat/14      47106      47101     297770 774.3MB/s  sum     [ +4.4%]
+  BM_UFlat/15       5063       5063    2772202 796.2MB/s  man     [ +7.7%]
+  BM_UFlat/16      83663      83656     167697 1.3GB/s  pb        [ +1.8%]
+  BM_UFlat/17     260224     260198      53823 675.6MB/s  gaviota [ -0.5%]
+
+Barcelona (Opteron):
+
+  Benchmark     Time(ns)    CPU(ns) Iterations
+  --------------------------------------------
+  BM_UFlat/0      112490     112457     100000 868.4MB/s  html    [ -0.4%]
+  BM_UFlat/1     1066719    1066339      10000 627.9MB/s  urls    [ +1.0%]
+  BM_UFlat/2       24679      24672     563802 4.8GB/s  jpg       [ +0.7%]
+  BM_UFlat/3       50603      50589     277285 1.7GB/s  pdf       [ +2.6%]
+  BM_UFlat/4      452982     452849      30900 862.6MB/s  html4   [ -0.2%]
+  BM_UFlat/5       43860      43848     319554 535.1MB/s  cp      [ +1.2%]
+  BM_UFlat/6       21419      21413     653573 496.6MB/s  c       [ +1.0%]
+  BM_UFlat/7        6646       6645    2105405 534.1MB/s  lsp     [ +0.3%]
+  BM_UFlat/8     1828487    1827886       7658 537.3MB/s  xls     [ +2.6%]
+  BM_UFlat/9      391824     391714      35708 370.3MB/s  txt1    [ +2.2%]
+  BM_UFlat/10     334913     334816      41885 356.6MB/s  txt2    [ +1.7%]
+  BM_UFlat/11    1042062    1041674      10000 390.7MB/s  txt3    [ +1.1%]
+  BM_UFlat/12    1398902    1398456      10000 328.6MB/s  txt4    [ +1.7%]
+  BM_UFlat/13     545706     545530      25669 897.2MB/s  bin     [ -0.4%]
+  BM_UFlat/14      71512      71505     196035 510.0MB/s  sum     [ +1.4%]
+  BM_UFlat/15       8422       8421    1665036 478.7MB/s  man     [ +2.6%]
+  BM_UFlat/16     112053     112048     100000 1009.3MB/s  pb     [ -0.4%]
+  BM_UFlat/17     416723     416713      33612 421.8MB/s  gaviota [ -2.0%]
+
+R=sanjay
+
+------------------------------------------------------------------------
+r52 | snappy.mirrorbot@gmail.com | 2011-11-08 15:46:39 +0100 (Tue, 08 Nov 2011) | 5 lines
+
+Fix public issue #53: Update the README to the API we actually open-sourced
+with.
+
+R=sanjay
+
+------------------------------------------------------------------------
+r51 | snappy.mirrorbot@gmail.com | 2011-10-05 14:27:12 +0200 (Wed, 05 Oct 2011) | 5 lines
+
+In the format description, use a clearer example to emphasize that varints are
+stored in little-endian. Patch from Christian von Roques.
+
+R=csilvers
+
+------------------------------------------------------------------------
+r50 | snappy.mirrorbot@gmail.com | 2011-09-15 21:34:06 +0200 (Thu, 15 Sep 2011) | 4 lines
+
+Release Snappy 1.0.4.
+
+R=sanjay
+
 ------------------------------------------------------------------------
 r49 | snappy.mirrorbot@gmail.com | 2011-09-15 11:50:05 +0200 (Thu, 15 Sep 2011) | 5 lines
 
@@ -173,8 +589,8 @@ Remove an unneeded goto in the decompressor; it turns out that the
 state of ip_ after decompression (or attempted decompresion) is
 completely irrelevant, so we don't need the trailer.
 
-Performance is, as expected, mostly flat -- there's a curious ~35%
-loss in the “lsp” test, but that test case is so short it is hard to say
+Performance is, as expected, mostly flat -- there's a curious ~3-5%
+loss in the "lsp" test, but that test case is so short it is hard to say
 anything definitive about why (most likely, it's some sort of
 unrelated effect).
 
@@ -195,7 +611,7 @@ performance, so changing Step() into a function that decodes as much as it can
 before it saves ip_ back and returns. (Note that Step() was already inlined,
 so it is not the manual inlining that buys the performance here.)
 
-The wins are about 3–6% for Core 2, 6–13% on Core i7 and 5–12% on Opteron
+The wins are about 3-6% for Core 2, 6-13% on Core i7 and 5-12% on Opteron
 (for plain array-to-array decompression, in 64-bit opt mode).
 
 There is a tiny difference in the behavior here; if an invalid literal is
index 11d1e955b9789c193c7feb44e8fea761a4f70e9b..60bbd17da0bbc7225dd82d3abc5c3b536639156a 100644 (file)
@@ -1,3 +1,34 @@
+Snappy v1.0.5, February 24th 2012:
+
+  * More speed improvements. Exactly how big will depend on
+    the architecture:
+
+    - 3–10% faster decompression for the base case (x86-64).
+
+    - ARMv7 and higher can now use unaligned accesses,
+      and will see about 30% faster decompression and
+      20–40% faster compression.
+
+    - 32-bit platforms (ARM and 32-bit x86) will see 2–5%
+      faster compression.
+
+    These are all cumulative (e.g., ARM gets all three speedups).
+
+  * Fixed an issue where the unit test would crash on system
+    with less than 256 MB address space available,
+    e.g. some embedded platforms.
+
+  * Added a framing format description, for use over e.g. HTTP,
+    or for a command-line compressor. We do not have any
+    implementations of this at the current point, but there seems
+    to be enough of a general interest in the topic.
+    Also make the format description slightly clearer.
+
+  * Remove some compile-time warnings in -Wall
+    (mostly signed/unsigned comparisons), for easier embedding
+    into projects that use -Wall -Werror.
+
+
 Snappy v1.0.4, September 15th 2011:
 
   * Speeded up the decompressor somewhat; typically about 2–8%
index df8f0e178e2b4c86f617256849b27cfa395f1f34..3bc8888f991b76bd5f6b69d273b2d3de34d1ad9d 100644 (file)
@@ -76,11 +76,11 @@ your calling file, and link against the compiled library.
 
 There are many ways to call Snappy, but the simplest possible is
 
-  snappy::Compress(input, &output);
+  snappy::Compress(input.data(), input.size(), &output);
 
 and similarly
 
-  snappy::Uncompress(input, &output);
+  snappy::Uncompress(input.data(), input.size(), &output);
 
 where "input" and "output" are both instances of std::string.
 
index 43d7a98238c4b3518fd63c6fc9291a4d41493e16..20db66c1f26b3f1850d7105344bc43216cbda7fb 100644 (file)
@@ -1,5 +1,5 @@
 Snappy compressed format description
-Last revised: 2011-08-09
+Last revised: 2011-10-05
 
 
 This is not a formal specification, but should suffice to explain most
@@ -21,8 +21,8 @@ The stream starts with the uncompressed length (up to a maximum of 2^32 - 1),
 stored as a little-endian varint. Varints consist of a series of bytes,
 where the lower 7 bits are data and the upper bit is set iff there are
 more bytes to be read. In other words, an uncompressed length of 64 would
-be stored as 0x40, and an uncompressed length of 2097151 (0x1FFFFF)
-would be stored as 0xFF 0xFF 0x7F.
+be stored as 0x40, and an uncompressed length of 2097150 (0x1FFFFE)
+would be stored as 0xFE 0xFF 0x7F.
 
 
 2. The compressed stream itself
diff --git a/thirdparty/snappy/framing_format.txt b/thirdparty/snappy/framing_format.txt
new file mode 100644 (file)
index 0000000..08fda03
--- /dev/null
@@ -0,0 +1,124 @@
+Snappy framing format description
+Last revised: 2011-12-15
+
+This format decribes a framing format for Snappy, allowing compressing to
+files or streams that can then more easily be decompressed without having
+to hold the entire stream in memory. It also provides data checksums to
+help verify integrity. It does not provide metadata checksums, so it does
+not protect against e.g. all forms of truncations.
+
+Implementation of the framing format is optional for Snappy compressors and
+decompressor; it is not part of the Snappy core specification.
+
+
+1. General structure
+
+The file consists solely of chunks, lying back-to-back with no padding
+in between. Each chunk consists first a single byte of chunk identifier,
+then a two-byte little-endian length of the chunk in bytes (from 0 to 65535,
+inclusive), and then the data if any. The three bytes of chunk header is not
+counted in the data length.
+
+The different chunk types are listed below. The first chunk must always
+be the stream identifier chunk (see section 4.1, below). The stream
+ends when the file ends -- there is no explicit end-of-file marker.
+
+
+2. File type identification
+
+The following identifiers for this format are recommended where appropriate.
+However, note that none have been registered officially, so this is only to
+be taken as a guideline. We use "Snappy framed" to distinguish between this
+format and raw Snappy data.
+
+  File extension:         .sz
+  MIME type:              application/x-snappy-framed
+  HTTP Content-Encoding:  x-snappy-framed
+
+
+3. Checksum format
+
+Some chunks have data protected by a checksum (the ones that do will say so
+explicitly). The checksums are always masked CRC-32Cs.
+
+A description of CRC-32C can be found in RFC 3720, section 12.1, with
+examples in section B.4.
+
+Checksums are not stored directly, but masked, as checksumming data and
+then its own checksum can be problematic. The masking is the same as used
+in Apache Hadoop: Rotate the checksum by 15 bits, then add the constant
+0xa282ead8 (using wraparound as normal for unsigned integers). This is
+equivalent to the following C code:
+
+  uint32_t mask_checksum(uint32_t x) {
+    return ((x >> 15) | (x << 17)) + 0xa282ead8;
+  }
+
+Note that the masking is reversible.
+
+The checksum is always stored as a four bytes long integer, in little-endian.
+
+
+4. Chunk types
+
+The currently supported chunk types are described below. The list may
+be extended in the future.
+
+
+4.1. Stream identifier (chunk type 0xff)
+
+The stream identifier is always the first element in the stream.
+It is exactly six bytes long and contains "sNaPpY" in ASCII. This means that
+a valid Snappy framed stream always starts with the bytes
+
+  0xff 0x06 0x00 0x73 0x4e 0x61 0x50 0x70 0x59
+
+The stream identifier chunk can come multiple times in the stream besides
+the first; if such a chunk shows up, it should simply be ignored, assuming
+it has the right length and contents. This allows for easy concatenation of
+compressed files without the need for re-framing.
+
+
+4.2. Compressed data (chunk type 0x00)
+
+Compressed data chunks contain a normal Snappy compressed bitstream;
+see the compressed format specification. The compressed data is preceded by
+the CRC-32C (see section 3) of the _uncompressed_ data.
+
+Note that the data portion of the chunk, i.e., the compressed contents,
+can be at most 65531 bytes (2^16 - 1, minus the checksum).
+However, we place an additional restriction that the uncompressed data
+in a chunk must be no longer than 32768 bytes. This allows consumers to
+easily use small fixed-size buffers.
+
+
+4.3. Uncompressed data (chunk type 0x01)
+
+Uncompressed data chunks allow a compressor to send uncompressed,
+raw data; this is useful if, for instance, uncompressible or
+near-incompressible data is detected, and faster decompression is desired.
+
+As in the compressed chunks, the data is preceded by its own masked
+CRC-32C (see section 3).
+
+An uncompressed data chunk, like compressed data chunks, should contain
+no more than 32768 data bytes, so the maximum legal chunk length with the
+checksum is 32772.
+
+
+4.4. Reserved unskippable chunks (chunk types 0x02-0x7f)
+
+These are reserved for future expansion. A decoder that sees such a chunk
+should immediately return an error, as it must assume it cannot decode the
+stream correctly.
+
+Future versions of this specification may define meanings for these chunks.
+
+
+4.5. Reserved skippable chunks (chunk types 0x80-0xfe)
+
+These are also reserved for future expansion, but unlike the chunks
+described in 4.4, a decoder seeing these must skip them and continue
+decoding.
+
+Future versions of this specification may define meanings for these chunks.
index 1017895f962d6ad536893f804a4cd0bf0bdd673e..5844552cb7e1bb7739cacb1d359360fa6a5620b4 100644 (file)
@@ -68,5 +68,4 @@ char* UncheckedByteArraySink::GetAppendBuffer(size_t len, char* scratch) {
   return dest_;
 }
 
-
 }
index 430baeabb0ed98e3e0c3137f73a2fd574d65abf9..faabfa1e6f1fd8f397fc9c5ee8de966c52c0c880 100644 (file)
@@ -60,6 +60,7 @@ class Sink {
   // The default implementation always returns the scratch buffer.
   virtual char* GetAppendBuffer(size_t length, char* scratch);
 
+
  private:
   // No copying
   Sink(const Sink&);
index 021528893357ae5b610788a8763e6b27bc1910fc..6033cdfb41a10df6424dbb478aaa1e149f7203cc 100644 (file)
@@ -86,10 +86,9 @@ using namespace std;
 // version (anyone who wants to regenerate it can just do the call
 // themselves within main()).
 #define DEFINE_bool(flag_name, default_value, description) \
-  bool FLAGS_ ## flag_name = default_value;
+  bool FLAGS_ ## flag_name = default_value
 #define DECLARE_bool(flag_name) \
-  extern bool FLAGS_ ## flag_name;
-#define REGISTER_MODULE_INITIALIZER(name, code)
+  extern bool FLAGS_ ## flag_name
 
 namespace snappy {
 
@@ -179,6 +178,8 @@ class LogMessageVoidify {
 
 // Potentially unaligned loads and stores.
 
+// x86 and PowerPC can simply do these loads and stores native.
+
 #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__)
 
 #define UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))
@@ -189,6 +190,47 @@ class LogMessageVoidify {
 #define UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val))
 #define UNALIGNED_STORE64(_p, _val) (*reinterpret_cast<uint64 *>(_p) = (_val))
 
+// ARMv7 and newer support native unaligned accesses, but only of 16-bit
+// and 32-bit values (not 64-bit); older versions either raise a fatal signal,
+// do an unaligned read and rotate the words around a bit, or do the reads very
+// slowly (trip through kernel mode). There's no simple #define that says just
+// “ARMv7 or higher”, so we have to filter away all ARMv5 and ARMv6
+// sub-architectures.
+//
+// This is a mess, but there's not much we can do about it.
+
+#elif defined(__arm__) && \
+      !defined(__ARM_ARCH_5__) && \
+      !defined(__ARM_ARCH_5T__) && \
+      !defined(__ARM_ARCH_5TE__) && \
+      !defined(__ARM_ARCH_5TEJ__) && \
+      !defined(__ARM_ARCH_6__) && \
+      !defined(__ARM_ARCH_6J__) && \
+      !defined(__ARM_ARCH_6K__) && \
+      !defined(__ARM_ARCH_6Z__) && \
+      !defined(__ARM_ARCH_6ZK__) && \
+      !defined(__ARM_ARCH_6T2__)
+
+#define UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))
+#define UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))
+
+#define UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16 *>(_p) = (_val))
+#define UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val))
+
+// TODO(user): NEON supports unaligned 64-bit loads and stores.
+// See if that would be more efficient on platforms supporting it,
+// at least for copies.
+
+inline uint64 UNALIGNED_LOAD64(const void *p) {
+  uint64 t;
+  memcpy(&t, p, sizeof t);
+  return t;
+}
+
+inline void UNALIGNED_STORE64(void *p, uint64 v) {
+  memcpy(p, &v, sizeof v);
+}
+
 #else
 
 // These functions are provided for architectures that don't support
@@ -226,6 +268,20 @@ inline void UNALIGNED_STORE64(void *p, uint64 v) {
 
 #endif
 
+// This can be more efficient than UNALIGNED_LOAD64 + UNALIGNED_STORE64
+// on some platforms, in particular ARM.
+inline void UnalignedCopy64(const void *src, void *dst) {
+  if (sizeof(void *) == 8) {
+    UNALIGNED_STORE64(dst, UNALIGNED_LOAD64(src));
+  } else {
+    const char *src_char = reinterpret_cast<const char *>(src);
+    char *dst_char = reinterpret_cast<char *>(dst);
+
+    UNALIGNED_STORE32(dst_char, UNALIGNED_LOAD32(src_char));
+    UNALIGNED_STORE32(dst_char + 4, UNALIGNED_LOAD32(src_char + 4));
+  }
+}
+
 // The following guarantees declaration of the byte swap functions.
 #ifdef WORDS_BIGENDIAN
 
index d439cb4dee1cdd831939fcf6227acc4a8f7d4d26..9ee4ca52b357503b7d706008e30e5886af8658b2 100644 (file)
@@ -46,7 +46,7 @@
 
 #define SNAPPY_MAJOR 1
 #define SNAPPY_MINOR 0
-#define SNAPPY_PATCHLEVEL 4
+#define SNAPPY_PATCHLEVEL 5
 #define SNAPPY_VERSION \
     ((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
 
index 2c503886e47f4d66892d012cc6f0860d06392247..223cd92d5ba334761e2540cdfd1a472685ce9ab2 100644 (file)
@@ -353,7 +353,6 @@ int ZLib::CompressAtMostOrAll(Bytef *dest, uLongf *destLen,
   // compression.
   err = deflate(&comp_stream_, flush_mode);
 
-  const uLong source_bytes_consumed = *sourceLen - comp_stream_.avail_in;
   *sourceLen = comp_stream_.avail_in;
 
   if ((err == Z_STREAM_END || err == Z_OK)
@@ -397,7 +396,6 @@ int ZLib::CompressChunkOrAll(Bytef *dest, uLongf *destLen,
 int ZLib::Compress(Bytef *dest, uLongf *destLen,
                    const Bytef *source, uLong sourceLen) {
   int err;
-  const uLongf orig_destLen = *destLen;
   if ( (err=CompressChunkOrAll(dest, destLen, source, sourceLen,
                                Z_FINISH)) != Z_OK )
     return err;
index 649f26e7ac1fd2608aeb23f93bf7ab8101525829..ef6a95539d1e454091f5a9be82f2d84b62073a79 100644 (file)
@@ -135,7 +135,7 @@ namespace File {
     while (!feof(fp)) {
       char buf[4096];
       size_t ret = fread(buf, 1, 4096, fp);
-      if (ret == -1) {
+      if (ret == 0 && ferror(fp)) {
         perror("fread");
         exit(1);
       }
index c79edb58a7fe50db0d35ff724d042f369fa99570..4d4eb42a4998e819bf91078c9878e5ff95d80608 100644 (file)
@@ -140,12 +140,12 @@ const int kMaxIncrementCopyOverflow = 10;
 
 static inline void IncrementalCopyFastPath(const char* src, char* op, int len) {
   while (op - src < 8) {
-    UNALIGNED_STORE64(op, UNALIGNED_LOAD64(src));
+    UnalignedCopy64(src, op);
     len -= op - src;
     op += op - src;
   }
   while (len > 0) {
-    UNALIGNED_STORE64(op, UNALIGNED_LOAD64(src));
+    UnalignedCopy64(src, op);
     src += 8;
     op += 8;
     len -= 8;
@@ -172,8 +172,8 @@ static inline char* EmitLiteral(char* op,
     //   - The output will always have 32 spare bytes (see
     //     MaxCompressedLength).
     if (allow_fast_path && len <= 16) {
-      UNALIGNED_STORE64(op, UNALIGNED_LOAD64(literal));
-      UNALIGNED_STORE64(op + 8, UNALIGNED_LOAD64(literal + 8));
+      UnalignedCopy64(literal, op);
+      UnalignedCopy64(literal + 8, op + 8);
       return op + len;
     }
   } else {
@@ -194,13 +194,13 @@ static inline char* EmitLiteral(char* op,
   return op + len;
 }
 
-static inline char* EmitCopyLessThan64(char* op, int offset, int len) {
+static inline char* EmitCopyLessThan64(char* op, size_t offset, int len) {
   DCHECK_LE(len, 64);
   DCHECK_GE(len, 4);
   DCHECK_LT(offset, 65536);
 
   if ((len < 12) && (offset < 2048)) {
-    int len_minus_4 = len - 4;
+    size_t len_minus_4 = len - 4;
     assert(len_minus_4 < 8);            // Must fit in 3 bits
     *op++ = COPY_1_BYTE_OFFSET | ((len_minus_4) << 2) | ((offset >> 8) << 5);
     *op++ = offset & 0xff;
@@ -212,7 +212,7 @@ static inline char* EmitCopyLessThan64(char* op, int offset, int len) {
   return op;
 }
 
-static inline char* EmitCopy(char* op, int offset, int len) {
+static inline char* EmitCopy(char* op, size_t offset, int len) {
   // Emit 64 byte copies but make sure to keep at least four bytes reserved
   while (len >= 68) {
     op = EmitCopyLessThan64(op, offset, 64);
@@ -249,7 +249,7 @@ uint16* WorkingMemory::GetHashTable(size_t input_size, int* table_size) {
   // compression, and if the input is short, we won't need that
   // many hash table entries anyway.
   assert(kMaxHashTableSize >= 256);
-  int htsize = 256;
+  size_t htsize = 256;
   while (htsize < kMaxHashTableSize && htsize < input_size) {
     htsize <<= 1;
   }
@@ -272,16 +272,49 @@ uint16* WorkingMemory::GetHashTable(size_t input_size, int* table_size) {
 }
 }  // end namespace internal
 
-// For 0 <= offset <= 4, GetUint32AtOffset(UNALIGNED_LOAD64(p), offset) will
+// For 0 <= offset <= 4, GetUint32AtOffset(GetEightBytesAt(p), offset) will
 // equal UNALIGNED_LOAD32(p + offset).  Motivation: On x86-64 hardware we have
 // empirically found that overlapping loads such as
 //  UNALIGNED_LOAD32(p) ... UNALIGNED_LOAD32(p+1) ... UNALIGNED_LOAD32(p+2)
 // are slower than UNALIGNED_LOAD64(p) followed by shifts and casts to uint32.
+//
+// We have different versions for 64- and 32-bit; ideally we would avoid the
+// two functions and just inline the UNALIGNED_LOAD64 call into
+// GetUint32AtOffset, but GCC (at least not as of 4.6) is seemingly not clever
+// enough to avoid loading the value multiple times then. For 64-bit, the load
+// is done when GetEightBytesAt() is called, whereas for 32-bit, the load is
+// done at GetUint32AtOffset() time.
+
+#ifdef ARCH_K8
+
+typedef uint64 EightBytesReference;
+
+static inline EightBytesReference GetEightBytesAt(const char* ptr) {
+  return UNALIGNED_LOAD64(ptr);
+}
+
 static inline uint32 GetUint32AtOffset(uint64 v, int offset) {
-  DCHECK(0 <= offset && offset <= 4) << offset;
+  DCHECK_GE(offset, 0);
+  DCHECK_LE(offset, 4);
   return v >> (LittleEndian::IsLittleEndian() ? 8 * offset : 32 - 8 * offset);
 }
 
+#else
+
+typedef const char* EightBytesReference;
+
+static inline EightBytesReference GetEightBytesAt(const char* ptr) {
+  return ptr;
+}
+
+static inline uint32 GetUint32AtOffset(const char* v, int offset) {
+  DCHECK_GE(offset, 0);
+  DCHECK_LE(offset, 4);
+  return UNALIGNED_LOAD32(v + offset);
+}
+
+#endif
+
 // Flat array compression that does not emit the "uncompressed length"
 // prefix. Compresses "input" string to the "*op" buffer.
 //
@@ -304,14 +337,14 @@ char* CompressFragment(const char* input,
   CHECK_LE(input_size, kBlockSize);
   CHECK_EQ(table_size & (table_size - 1), 0) << ": table must be power of two";
   const int shift = 32 - Bits::Log2Floor(table_size);
-  DCHECK_EQ(kuint32max >> shift, table_size - 1);
+  DCHECK_EQ(static_cast<int>(kuint32max >> shift), table_size - 1);
   const char* ip_end = input + input_size;
   const char* base_ip = ip;
   // Bytes in [next_emit, ip) will be emitted as literal bytes.  Or
   // [next_emit, ip_end) after the main loop.
   const char* next_emit = ip;
 
-  const int kInputMarginBytes = 15;
+  const size_t kInputMarginBytes = 15;
   if (PREDICT_TRUE(input_size >= kInputMarginBytes)) {
     const char* ip_limit = input + input_size - kInputMarginBytes;
 
@@ -378,7 +411,7 @@ char* CompressFragment(const char* input,
       // though we don't yet know how big the literal will be.  We handle that
       // by proceeding to the next iteration of the main loop.  We also can exit
       // this loop via goto if we get close to exhausting the input.
-      uint64 input_bytes = 0;
+      EightBytesReference input_bytes;
       uint32 candidate_bytes = 0;
 
       do {
@@ -387,7 +420,7 @@ char* CompressFragment(const char* input,
         const char* base = ip;
         int matched = 4 + FindMatchLength(candidate + 4, ip + 4, ip_end);
         ip += matched;
-        int offset = base - candidate;
+        size_t offset = base - candidate;
         DCHECK_EQ(0, memcmp(base, candidate, matched));
         op = EmitCopy(op, offset, matched);
         // We could immediately start working at ip now, but to improve
@@ -397,7 +430,7 @@ char* CompressFragment(const char* input,
         if (PREDICT_FALSE(ip >= ip_limit)) {
           goto emit_remainder;
         }
-        input_bytes = UNALIGNED_LOAD64(insert_tail);
+        input_bytes = GetEightBytesAt(insert_tail);
         uint32 prev_hash = HashBytes(GetUint32AtOffset(input_bytes, 0), shift);
         table[prev_hash] = ip - base_ip - 1;
         uint32 cur_hash = HashBytes(GetUint32AtOffset(input_bytes, 1), shift);
@@ -435,12 +468,26 @@ char* CompressFragment(const char* input,
 //   bool CheckLength() const;
 //
 //   // Called repeatedly during decompression
-//   bool Append(const char* ip, uint32 length, bool allow_fast_path);
-//   bool AppendFromSelf(uint32 offset, uint32 length);
-// };
+//   bool Append(const char* ip, size_t length);
+//   bool AppendFromSelf(uint32 offset, size_t length);
 //
-// "allow_fast_path" is a parameter that says if there is at least 16
-// readable bytes in "ip". It is currently only used by SnappyArrayWriter.
+//   // The difference between TryFastAppend and Append is that TryFastAppend
+//   // is allowed to read up to <available> bytes from the input buffer,
+//   // whereas Append is allowed to read <length>.
+//   //
+//   // Also, TryFastAppend is allowed to return false, declining the append,
+//   // without it being a fatal error -- just "return false" would be
+//   // a perfectly legal implementation of TryFastAppend. The intention
+//   // is for TryFastAppend to allow a fast path in the common case of
+//   // a small append.
+//   //
+//   // NOTE(user): TryFastAppend must always return decline (return false)
+//   // if <length> is 61 or more, as in this case the literal length is not
+//   // decoded fully. In practice, this should not be a big problem,
+//   // as it is unlikely that one would implement a fast path accepting
+//   // this much data.
+//   bool TryFastAppend(const char* ip, size_t available, size_t length);
+// };
 
 // -----------------------------------------------------------------------
 // Lookup table for decompression code.  Generated by ComputeTable() below.
@@ -587,7 +634,6 @@ static void ComputeTable() {
     CHECK_EQ(dst[i], char_table[i]);
   }
 }
-REGISTER_MODULE_INITIALIZER(snappy, ComputeTable());
 #endif /* !NDEBUG */
 
 // Helper class for decompression
@@ -655,29 +701,41 @@ class SnappyDecompressor {
   template <class Writer>
   void DecompressAllTags(Writer* writer) {
     const char* ip = ip_;
-    for ( ;; ) {
-      if (ip_limit_ - ip < 5) {
-        ip_ = ip;
-        if (!RefillTag()) return;
-        ip = ip_;
-      }
 
+    // We could have put this refill fragment only at the beginning of the loop.
+    // However, duplicating it at the end of each branch gives the compiler more
+    // scope to optimize the <ip_limit_ - ip> expression based on the local
+    // context, which overall increases speed.
+    #define MAYBE_REFILL() \
+        if (ip_limit_ - ip < 5) { \
+          ip_ = ip; \
+          if (!RefillTag()) return; \
+          ip = ip_; \
+        }
+
+    MAYBE_REFILL();
+    for ( ;; ) {
       const unsigned char c = *(reinterpret_cast<const unsigned char*>(ip++));
 
       if ((c & 0x3) == LITERAL) {
-        uint32 literal_length = c >> 2;
-        if (PREDICT_FALSE(literal_length >= 60)) {
+        size_t literal_length = (c >> 2) + 1u;
+        if (writer->TryFastAppend(ip, ip_limit_ - ip, literal_length)) {
+          DCHECK_LT(literal_length, 61);
+          ip += literal_length;
+          MAYBE_REFILL();
+          continue;
+        }
+        if (PREDICT_FALSE(literal_length >= 61)) {
           // Long literal.
-          const uint32 literal_length_length = literal_length - 59;
+          const size_t literal_length_length = literal_length - 60;
           literal_length =
-              LittleEndian::Load32(ip) & wordmask[literal_length_length];
+              (LittleEndian::Load32(ip) & wordmask[literal_length_length]) + 1;
           ip += literal_length_length;
         }
-        ++literal_length;
 
-        uint32 avail = ip_limit_ - ip;
+        size_t avail = ip_limit_ - ip;
         while (avail < literal_length) {
-          if (!writer->Append(ip, avail, false)) return;
+          if (!writer->Append(ip, avail)) return;
           literal_length -= avail;
           reader_->Skip(peeked_);
           size_t n;
@@ -687,11 +745,11 @@ class SnappyDecompressor {
           if (avail == 0) return;  // Premature end of input
           ip_limit_ = ip + avail;
         }
-        bool allow_fast_path = (avail >= 16);
-        if (!writer->Append(ip, literal_length, allow_fast_path)) {
+        if (!writer->Append(ip, literal_length)) {
           return;
         }
         ip += literal_length;
+        MAYBE_REFILL();
       } else {
         const uint32 entry = char_table[c];
         const uint32 trailer = LittleEndian::Load32(ip) & wordmask[entry >> 11];
@@ -705,8 +763,11 @@ class SnappyDecompressor {
         if (!writer->AppendFromSelf(copy_offset + trailer, length)) {
           return;
         }
+        MAYBE_REFILL();
       }
     }
+
+#undef MAYBE_REFILL
   }
 };
 
@@ -777,6 +838,15 @@ static bool InternalUncompress(Source* r,
   SnappyDecompressor decompressor(r);
   uint32 uncompressed_len = 0;
   if (!decompressor.ReadUncompressedLength(&uncompressed_len)) return false;
+  return InternalUncompressAllTags(
+      &decompressor, writer, uncompressed_len, max_len);
+}
+
+template <typename Writer>
+static bool InternalUncompressAllTags(SnappyDecompressor* decompressor,
+                                      Writer* writer,
+                                      uint32 uncompressed_len,
+                                      uint32 max_len) {
   // Protect against possible DoS attack
   if (static_cast<uint64>(uncompressed_len) > max_len) {
     return false;
@@ -785,8 +855,8 @@ static bool InternalUncompress(Source* r,
   writer->SetExpectedLength(uncompressed_len);
 
   // Process the entire input
-  decompressor.DecompressAllTags(writer);
-  return (decompressor.eof() && writer->CheckLength());
+  decompressor->DecompressAllTags(writer);
+  return (decompressor->eof() && writer->CheckLength());
 }
 
 bool GetUncompressedLength(Source* source, uint32* result) {
@@ -796,7 +866,7 @@ bool GetUncompressedLength(Source* source, uint32* result) {
 
 size_t Compress(Source* reader, Sink* writer) {
   size_t written = 0;
-  int N = reader->Available();
+  size_t N = reader->Available();
   char ulength[Varint::kMax32];
   char* p = Varint::Encode32(ulength, N);
   writer->Append(ulength, p-ulength);
@@ -811,10 +881,10 @@ size_t Compress(Source* reader, Sink* writer) {
     size_t fragment_size;
     const char* fragment = reader->Peek(&fragment_size);
     DCHECK_NE(fragment_size, 0) << ": premature end of input";
-    const int num_to_read = min(N, kBlockSize);
+    const size_t num_to_read = min(N, kBlockSize);
     size_t bytes_read = fragment_size;
 
-    int pending_advance = 0;
+    size_t pending_advance = 0;
     if (bytes_read >= num_to_read) {
       // Buffer returned by reader is large enough
       pending_advance = num_to_read;
@@ -902,34 +972,42 @@ class SnappyArrayWriter {
     return op_ == op_limit_;
   }
 
-  inline bool Append(const char* ip, uint32 len, bool allow_fast_path) {
+  inline bool Append(const char* ip, size_t len) {
     char* op = op_;
-    const int space_left = op_limit_ - op;
-    if (allow_fast_path && len <= 16 && space_left >= 16) {
-      // Fast path, used for the majority (about 90%) of dynamic invocations.
-      UNALIGNED_STORE64(op, UNALIGNED_LOAD64(ip));
-      UNALIGNED_STORE64(op + 8, UNALIGNED_LOAD64(ip + 8));
-    } else {
-      if (space_left < len) {
-        return false;
-      }
-      memcpy(op, ip, len);
+    const size_t space_left = op_limit_ - op;
+    if (space_left < len) {
+      return false;
     }
+    memcpy(op, ip, len);
     op_ = op + len;
     return true;
   }
 
-  inline bool AppendFromSelf(uint32 offset, uint32 len) {
+  inline bool TryFastAppend(const char* ip, size_t available, size_t len) {
     char* op = op_;
-    const int space_left = op_limit_ - op;
+    const size_t space_left = op_limit_ - op;
+    if (len <= 16 && available >= 16 && space_left >= 16) {
+      // Fast path, used for the majority (about 95%) of invocations.
+      UnalignedCopy64(ip, op);
+      UnalignedCopy64(ip + 8, op + 8);
+      op_ = op + len;
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  inline bool AppendFromSelf(size_t offset, size_t len) {
+    char* op = op_;
+    const size_t space_left = op_limit_ - op;
 
     if (op - base_ <= offset - 1u) {  // -1u catches offset==0
       return false;
     }
     if (len <= 16 && offset >= 8 && space_left >= 16) {
       // Fast path, used for the majority (70-80%) of dynamic invocations.
-      UNALIGNED_STORE64(op, UNALIGNED_LOAD64(op - offset));
-      UNALIGNED_STORE64(op + 8, UNALIGNED_LOAD64(op - offset + 8));
+      UnalignedCopy64(op - offset, op);
+      UnalignedCopy64(op - offset + 8, op + 8);
     } else {
       if (space_left >= len + kMaxIncrementCopyOverflow) {
         IncrementalCopyFastPath(op - offset, op, len);
@@ -985,11 +1063,14 @@ class SnappyDecompressionValidator {
   inline bool CheckLength() const {
     return expected_ == produced_;
   }
-  inline bool Append(const char* ip, uint32 len, bool allow_fast_path) {
+  inline bool Append(const char* ip, size_t len) {
     produced_ += len;
     return produced_ <= expected_;
   }
-  inline bool AppendFromSelf(uint32 offset, uint32 len) {
+  inline bool TryFastAppend(const char* ip, size_t available, size_t length) {
+    return false;
+  }
+  inline bool AppendFromSelf(size_t offset, size_t len) {
     if (produced_ <= offset - 1u) return false;  // -1u catches offset==0
     produced_ += len;
     return produced_ <= expected_;
index 8d6ef2294f55aadc92a60de8b2d9b11eed542498..8c2075fefa5d5835bbf4cb9510da85505a606410 100644 (file)
@@ -144,10 +144,10 @@ namespace snappy {
   // decompression code should not rely on this guarantee since older
   // compression code may not obey it.
   static const int kBlockLog = 15;
-  static const int kBlockSize = 1 << kBlockLog;
+  static const size_t kBlockSize = 1 << kBlockLog;
 
   static const int kMaxHashTableBits = 14;
-  static const int kMaxHashTableSize = 1 << kMaxHashTableBits;
+  static const size_t kMaxHashTableSize = 1 << kMaxHashTableBits;
 
 }  // end namespace snappy
 
index 6fff333ad1398374e85d9df357eb479edba2f62f..f3b9c83c04935cdd96df1bef7da9efc1ee24a7dc 100644 (file)
@@ -300,7 +300,7 @@ static bool Uncompress(const string& compressed, CompressorType comp,
           reinterpret_cast<const Bytef*>(compressed.data()),
           compressed.size());
       CHECK_EQ(Z_OK, ret);
-      CHECK_EQ(destlen, size);
+      CHECK_EQ(static_cast<uLongf>(size), destlen);
       break;
     }
 #endif  // ZLIB_VERSION
@@ -316,7 +316,7 @@ static bool Uncompress(const string& compressed, CompressorType comp,
           &destlen,
           NULL);
       CHECK_EQ(LZO_E_OK, ret);
-      CHECK_EQ(destlen, size);
+      CHECK_EQ(static_cast<lzo_uint>(size), destlen);
       break;
     }
 #endif  // LZO_VERSION
@@ -591,22 +591,24 @@ TYPED_TEST(CorruptedTest, VerifyCorrupted) {
     // Another security check; check a crazy big length can't DoS us with an
     // over-allocation.
     // Currently this is done only for 32-bit builds.  On 64-bit builds,
-    // where 3GBytes might be an acceptable allocation size, Uncompress()
+    // where 3 GB might be an acceptable allocation size, Uncompress()
     // attempts to decompress, and sometimes causes the test to run out of
     // memory.
     dest[0] = dest[1] = dest[2] = dest[3] = 0xff;
-    // This decodes to a really large size, i.e., 3221225471 bytes
+    // This decodes to a really large size, i.e., about 3 GB.
     dest[4] = 'k';
     CHECK(!IsValidCompressedBuffer(TypeParam(dest)));
     CHECK(!Uncompress(TypeParam(dest), &uncmp));
-    dest[0] = dest[1] = dest[2] = 0xff;
-    dest[3] = 0x7f;
-    CHECK(!IsValidCompressedBuffer(TypeParam(dest)));
-    CHECK(!Uncompress(TypeParam(dest), &uncmp));
   } else {
     LOG(WARNING) << "Crazy decompression lengths not checked on 64-bit build";
   }
 
+  // This decodes to about 2 MB; much smaller, but should still fail.
+  dest[0] = dest[1] = dest[2] = 0xff;
+  dest[3] = 0x00;
+  CHECK(!IsValidCompressedBuffer(TypeParam(dest)));
+  CHECK(!Uncompress(TypeParam(dest), &uncmp));
+
   // try reading stuff in from a bad file.
   for (int i = 1; i <= 3; ++i) {
     string data = ReadTestDataFile(StringPrintf("baddata%d.snappy", i).c_str());
index 55423c8b59b5fe439f3d5e34aacf7fe13fada1d8..b1e953d12bac221e6da86380bc4221c9129dd02a 100644 (file)
@@ -5,6 +5,8 @@ add_definitions (-DNO_VIZ)
 # adjust warnings
 if (MSVC)
     add_definitions (-wd4131) # uses old-style declarator
+else ()
+    add_definitions (-DHAVE_UNISTD_H)
 endif ()
 
 add_library (z_bundled STATIC
index f310bb0fcdb176111b1ded729adf39484a0e9551..6fa5d4411ac9a9c728206987b267c9f91e3b4b22 100644 (file)
 
                 ChangeLog file for zlib
 
+Changes in 1.2.6 (29 Jan 2012)
+- Update the Pascal interface in contrib/pascal
+- Fix function numbers for gzgetc_ in zlibvc.def files
+- Fix configure.ac for contrib/minizip [Schiffer]
+- Fix large-entry detection in minizip on 64-bit systems [Schiffer]
+- Have ./configure use the compiler return code for error indication
+- Fix CMakeLists.txt for cross compilation [McClure]
+- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes]
+- Fix compilation of contrib/minizip on FreeBSD [Marquez]
+- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath]
+- Include io.h for Turbo C / Borland C on all platforms [Truta]
+- Make version explicit in contrib/minizip/configure.ac [Bosmans]
+- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant]
+- Minor cleanup up contrib/minizip/unzip.c [Vollant]
+- Fix bug when compiling minizip with C++ [Vollant]
+- Protect for long name and extra fields in contrib/minizip [Vollant]
+- Avoid some warnings in contrib/minizip [Vollant]
+- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip
+- Add missing libs to minizip linker command
+- Add support for VPATH builds in contrib/minizip
+- Add an --enable-demos option to contrib/minizip/configure
+- Add the generation of configure.log by ./configure
+- Exit when required parameters not provided to win32/Makefile.gcc
+- Have gzputc return the character written instead of the argument
+- Use the -m option on ldconfig for BSD systems [Tobias]
+- Correct in zlib.map when deflateResetKeep was added
+
+Changes in 1.2.5.3 (15 Jan 2012)
+- Restore gzgetc function for binary compatibility
+- Do not use _lseeki64 under Borland C++ [Truta]
+- Update win32/Makefile.msc to build test/*.c [Truta]
+- Remove old/visualc6 given CMakefile and other alternatives
+- Update AS400 build files and documentation [Monnerat]
+- Update win32/Makefile.gcc to build test/*.c [Truta]
+- Permit stronger flushes after Z_BLOCK flushes
+- Avoid extraneous empty blocks when doing empty flushes
+- Permit Z_NULL arguments to deflatePending
+- Allow deflatePrime() to insert bits in the middle of a stream
+- Remove second empty static block for Z_PARTIAL_FLUSH
+- Write out all of the available bits when using Z_BLOCK
+- Insert the first two strings in the hash table after a flush
+
+Changes in 1.2.5.2 (17 Dec 2011)
+- fix ld error: unable to find version dependency 'ZLIB_1.2.5'
+- use relative symlinks for shared libs
+- Avoid searching past window for Z_RLE strategy
+- Assure that high-water mark initialization is always applied in deflate
+- Add assertions to fill_window() in deflate.c to match comments
+- Update python link in README
+- Correct spelling error in gzread.c
+- Fix bug in gzgets() for a concatenated empty gzip stream
+- Correct error in comment for gz_make()
+- Change gzread() and related to ignore junk after gzip streams
+- Allow gzread() and related to continue after gzclearerr()
+- Allow gzrewind() and gzseek() after a premature end-of-file
+- Simplify gzseek() now that raw after gzip is ignored
+- Change gzgetc() to a macro for speed (~40% speedup in testing)
+- Fix gzclose() to return the actual error last encountered
+- Always add large file support for windows
+- Include zconf.h for windows large file support
+- Include zconf.h.cmakein for windows large file support
+- Update zconf.h.cmakein on make distclean
+- Merge vestigial vsnprintf determination from zutil.h to gzguts.h
+- Clarify how gzopen() appends in zlib.h comments
+- Correct documentation of gzdirect() since junk at end now ignored
+- Add a transparent write mode to gzopen() when 'T' is in the mode
+- Update python link in zlib man page
+- Get inffixed.h and MAKEFIXED result to match
+- Add a ./config --solo option to make zlib subset with no libary use
+- Add undocumented inflateResetKeep() function for CAB file decoding
+- Add --cover option to ./configure for gcc coverage testing
+- Add #define ZLIB_CONST option to use const in the z_stream interface
+- Add comment to gzdopen() in zlib.h to use dup() when using fileno()
+- Note behavior of uncompress() to provide as much data as it can
+- Add files in contrib/minizip to aid in building libminizip
+- Split off AR options in Makefile.in and configure
+- Change ON macro to Z_ARG to avoid application conflicts
+- Facilitate compilation with Borland C++ for pragmas and vsnprintf
+- Include io.h for Turbo C / Borland C++
+- Move example.c and minigzip.c to test/
+- Simplify incomplete code table filling in inflate_table()
+- Remove code from inflate.c and infback.c that is impossible to execute
+- Test the inflate code with full coverage
+- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw)
+- Add deflateResetKeep and fix inflateResetKeep to retain dictionary
+- Fix gzwrite.c to accommodate reduced memory zlib compilation
+- Have inflate() with Z_FINISH avoid the allocation of a window
+- Do not set strm->adler when doing raw inflate
+- Fix gzeof() to behave just like feof() when read is not past end of file
+- Fix bug in gzread.c when end-of-file is reached
+- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF
+- Document gzread() capability to read concurrently written files
+- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo]
+
+Changes in 1.2.5.1 (10 Sep 2011)
+- Update FAQ entry on shared builds (#13)
+- Avoid symbolic argument to chmod in Makefile.in
+- Fix bug and add consts in contrib/puff [Oberhumer]
+- Update contrib/puff/zeros.raw test file to have all block types
+- Add full coverage test for puff in contrib/puff/Makefile
+- Fix static-only-build install in Makefile.in
+- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno]
+- Add libz.a dependency to shared in Makefile.in for parallel builds
+- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out
+- Replace $(...) with `...` in configure for non-bash sh [Bowler]
+- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen]
+- Add solaris* to Linux* in configure to allow gcc use [Groffen]
+- Add *bsd* to Linux* case in configure [Bar-Lev]
+- Add inffast.obj to dependencies in win32/Makefile.msc
+- Correct spelling error in deflate.h [Kohler]
+- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc
+- Add test to configure for GNU C looking for gcc in output of $cc -v
+- Add zlib.pc generation to win32/Makefile.gcc [Weigelt]
+- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not
+- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense
+- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser)
+- Make stronger test in zconf.h to include unistd.h for LFS
+- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack]
+- Fix zlib.h LFS support when Z_PREFIX used
+- Add updated as400 support (removed from old) [Monnerat]
+- Avoid deflate sensitivity to volatile input data
+- Avoid division in adler32_combine for NO_DIVIDE
+- Clarify the use of Z_FINISH with deflateBound() amount of space
+- Set binary for output file in puff.c
+- Use u4 type for crc_table to avoid conversion warnings
+- Apply casts in zlib.h to avoid conversion warnings
+- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
+- Improve inflateSync() documentation to note indeterminancy
+- Add deflatePending() function to return the amount of pending output
+- Correct the spelling of "specification" in FAQ [Randers-Pehrson]
+- Add a check in configure for stdarg.h, use for gzprintf()
+- Check that pointers fit in ints when gzprint() compiled old style
+- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
+- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
+- Add debug records in assmebler code [Londer]
+- Update RFC references to use http://tools.ietf.org/html/... [Li]
+- Add --archs option, use of libtool to configure for Mac OS X [Borstel]
+
 Changes in 1.2.5 (19 Apr 2010)
 - Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
 - Default to libdir as sharedlibdir in configure [Nieder]
 - Update copyright dates on modified source files
 - Update trees.c to be able to generate modified trees.h
 - Exit configure for MinGW, suggesting win32/Makefile.gcc
+- Check for NULL path in gz_open [Homurlu]
 
 Changes in 1.2.4.5 (18 Apr 2010)
 - Set sharedlibdir in configure [Torok]
@@ -261,7 +400,7 @@ Changes in 1.2.3.4 (21 Dec 2009)
 - Clear bytes after deflate lookahead to avoid use of uninitialized data
 - Change a limit in inftrees.c to be more transparent to Coverity Prevent
 - Update win32/zlib.def with exported symbols from zlib.h
-- Correct spelling error in zlib.h [Willem]
+- Correct spelling errors in zlib.h [Willem, Sobrado]
 - Allow Z_BLOCK for deflate() to force a new block
 - Allow negative bits in inflatePrime() to delete existing bit buffer
 - Add Z_TREES flush option to inflate() to return at end of trees
index d4219bf889f5bb7e8bc70ea7d092a9974dcbcf8d..09070e2c04d2a8ac1f0e929fbb82976ef8279492 100644 (file)
@@ -1,22 +1,22 @@
 ZLIB DATA COMPRESSION LIBRARY
 
-zlib 1.2.5 is a general purpose data compression library.  All the code is
+zlib 1.2.6 is a general purpose data compression library.  All the code is
 thread safe.  The data format used by the zlib library is described by RFCs
 (Request for Comments) 1950 to 1952 in the files
-http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
-and rfc1952.txt (gzip format).
+http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
+rfc1952 (gzip format).
 
 All functions of the compression library are documented in the file zlib.h
 (volunteer to write man pages welcome, contact zlib@gzip.org).  A usage example
-of the library is given in the file example.c which also tests that the library
-is working correctly.  Another example is given in the file minigzip.c.  The
-compression library itself is composed of all source files except example.c and
-minigzip.c.
+of the library is given in the file test/example.c which also tests that
+the library is working correctly.  Another example is given in the file
+test/minigzip.c.  The compression library itself is composed of all source
+files in the root directory.
 
 To compile all files and run the test program, follow the instructions given at
 the top of Makefile.in.  In short "./configure; make test", and if that goes
-well, "make install" should work for most flavors of Unix.  For Windows, use one
-of the special makefiles in win32/ or contrib/vstudio/ .  For VMS, use
+well, "make install" should work for most flavors of Unix.  For Windows, use
+one of the special makefiles in win32/ or contrib/vstudio/ .  For VMS, use
 make_vms.com.
 
 Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
@@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan.  1997
 issue of Dr.  Dobb's Journal; a copy of the article is available at
 http://marknelson.us/1997/01/01/zlib-engine/ .
 
-The changes made in version 1.2.5 are documented in the file ChangeLog.
+The changes made in version 1.2.6 are documented in the file ChangeLog.
 
 Unsupported third party contributions are provided in directory contrib/ .
 
@@ -44,7 +44,7 @@ http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
 
 A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
 available in Python 1.5 and later versions, see
-http://www.python.org/doc/lib/module-zlib.html .
+http://docs.python.org/library/zlib.html .
 
 zlib is built into tcl: http://wiki.tcl.tk/4610 .
 
@@ -84,7 +84,7 @@ Acknowledgments:
 
 Copyright notice:
 
- (C) 1995-2010 Jean-loup Gailly and Mark Adler
+ (C) 1995-2012 Jean-loup Gailly and Mark Adler
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
index 65ad6a5adc44c00428b35eb15ff26d16f9ef209b..a868f073d8a0e35dcb3ec812b41b1d3f0acdd84d 100644 (file)
@@ -1,5 +1,5 @@
 /* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2007 Mark Adler
+ * Copyright (C) 1995-2011 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -9,9 +9,9 @@
 
 #define local static
 
-local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
+local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
 
-#define BASE 65521UL    /* largest prime smaller than 65536 */
+#define BASE 65521      /* largest prime smaller than 65536 */
 #define NMAX 5552
 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
 
@@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
 #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
 #define DO16(buf)   DO8(buf,0); DO8(buf,8);
 
-/* use NO_DIVIDE if your processor does not do division in hardware */
+/* use NO_DIVIDE if your processor does not do division in hardware --
+   try it both ways to see which is faster */
 #ifdef NO_DIVIDE
-#  define MOD(a) \
+/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
+   (thank you to John Reiser for pointing this out) */
+#  define CHOP(a) \
+    do { \
+        unsigned long tmp = a >> 16; \
+        a &= 0xffffUL; \
+        a += (tmp << 4) - tmp; \
+    } while (0)
+#  define MOD28(a) \
     do { \
-        if (a >= (BASE << 16)) a -= (BASE << 16); \
-        if (a >= (BASE << 15)) a -= (BASE << 15); \
-        if (a >= (BASE << 14)) a -= (BASE << 14); \
-        if (a >= (BASE << 13)) a -= (BASE << 13); \
-        if (a >= (BASE << 12)) a -= (BASE << 12); \
-        if (a >= (BASE << 11)) a -= (BASE << 11); \
-        if (a >= (BASE << 10)) a -= (BASE << 10); \
-        if (a >= (BASE << 9)) a -= (BASE << 9); \
-        if (a >= (BASE << 8)) a -= (BASE << 8); \
-        if (a >= (BASE << 7)) a -= (BASE << 7); \
-        if (a >= (BASE << 6)) a -= (BASE << 6); \
-        if (a >= (BASE << 5)) a -= (BASE << 5); \
-        if (a >= (BASE << 4)) a -= (BASE << 4); \
-        if (a >= (BASE << 3)) a -= (BASE << 3); \
-        if (a >= (BASE << 2)) a -= (BASE << 2); \
-        if (a >= (BASE << 1)) a -= (BASE << 1); \
+        CHOP(a); \
         if (a >= BASE) a -= BASE; \
     } while (0)
-#  define MOD4(a) \
+#  define MOD(a) \
     do { \
-        if (a >= (BASE << 4)) a -= (BASE << 4); \
-        if (a >= (BASE << 3)) a -= (BASE << 3); \
-        if (a >= (BASE << 2)) a -= (BASE << 2); \
-        if (a >= (BASE << 1)) a -= (BASE << 1); \
+        CHOP(a); \
+        MOD28(a); \
+    } while (0)
+#  define MOD63(a) \
+    do { /* this assumes a is not negative */ \
+        z_off64_t tmp = a >> 32; \
+        a &= 0xffffffffL; \
+        a += (tmp << 8) - (tmp << 5) + tmp; \
+        tmp = a >> 16; \
+        a &= 0xffffL; \
+        a += (tmp << 4) - tmp; \
+        tmp = a >> 16; \
+        a &= 0xffffL; \
+        a += (tmp << 4) - tmp; \
         if (a >= BASE) a -= BASE; \
     } while (0)
 #else
 #  define MOD(a) a %= BASE
-#  define MOD4(a) a %= BASE
+#  define MOD28(a) a %= BASE
+#  define MOD63(a) a %= BASE
 #endif
 
 /* ========================================================================= */
@@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len)
         }
         if (adler >= BASE)
             adler -= BASE;
-        MOD4(sum2);             /* only added so many BASE's */
+        MOD28(sum2);            /* only added so many BASE's */
         return adler | (sum2 << 16);
     }
 
@@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adler2, len2)
     unsigned long sum2;
     unsigned rem;
 
+    /* for negative len, return invalid adler32 as a clue for debugging */
+    if (len2 < 0)
+        return 0xffffffffUL;
+
     /* the derivation of this formula is left as an exercise for the reader */
-    rem = (unsigned)(len2 % BASE);
+    MOD63(len2);                /* assumes len2 >= 0 */
+    rem = (unsigned)len2;
     sum1 = adler1 & 0xffff;
     sum2 = rem * sum1;
     MOD(sum2);
index 91be372d224da6833c03bd24d7158ff622ece35f..c12471e6171594a691ab26a1a790e5eaf3fea63c 100644 (file)
@@ -1,5 +1,5 @@
 /* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2006, 2010 Mark Adler
+ * Copyright (C) 1995-2006, 2010, 2011 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  *
  * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -17,6 +17,8 @@
   of the crc tables.  Therefore, if you #define DYNAMIC_CRC_TABLE, you should
   first call get_crc_table() to initialize the tables before allowing more than
   one thread to use crc32().
+
+  DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
  */
 
 #ifdef MAKECRCH
@@ -53,6 +55,7 @@
 
 /* Definitions for doing the crc four data bytes at a time. */
 #ifdef BYFOUR
+   typedef u4 crc_table_t;
 #  define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
                 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
    local unsigned long crc32_little OF((unsigned long,
@@ -61,6 +64,7 @@
                         const unsigned char FAR *, unsigned));
 #  define TBLS 8
 #else
+   typedef unsigned long crc_table_t;
 #  define TBLS 1
 #endif /* BYFOUR */
 
 local unsigned long gf2_matrix_times OF((unsigned long *mat,
                                          unsigned long vec));
 local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
-local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
+local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
 
 
 #ifdef DYNAMIC_CRC_TABLE
 
 local volatile int crc_table_empty = 1;
-local unsigned long FAR crc_table[TBLS][256];
+local crc_table_t FAR crc_table[TBLS][256];
 local void make_crc_table OF((void));
 #ifdef MAKECRCH
-   local void write_table OF((FILE *, const unsigned long FAR *));
+   local void write_table OF((FILE *, const crc_table_t FAR *));
 #endif /* MAKECRCH */
 /*
   Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
@@ -107,9 +111,9 @@ local void make_crc_table OF((void));
 */
 local void make_crc_table()
 {
-    unsigned long c;
+    crc_table_t c;
     int n, k;
-    unsigned long poly;                 /* polynomial exclusive-or pattern */
+    crc_table_t poly;                   /* polynomial exclusive-or pattern */
     /* terms of polynomial defining this crc (except x^32): */
     static volatile int first = 1;      /* flag to limit concurrent making */
     static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
@@ -121,13 +125,13 @@ local void make_crc_table()
         first = 0;
 
         /* make exclusive-or pattern from polynomial (0xedb88320UL) */
-        poly = 0UL;
-        for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
-            poly |= 1UL << (31 - p[n]);
+        poly = 0;
+        for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
+            poly |= (crc_table_t)1 << (31 - p[n]);
 
         /* generate a crc for every 8-bit value */
         for (n = 0; n < 256; n++) {
-            c = (unsigned long)n;
+            c = (crc_table_t)n;
             for (k = 0; k < 8; k++)
                 c = c & 1 ? poly ^ (c >> 1) : c >> 1;
             crc_table[0][n] = c;
@@ -164,7 +168,7 @@ local void make_crc_table()
         if (out == NULL) return;
         fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
         fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
-        fprintf(out, "local const unsigned long FAR ");
+        fprintf(out, "local const crc_table_t FAR ");
         fprintf(out, "crc_table[TBLS][256] =\n{\n  {\n");
         write_table(out, crc_table[0]);
 #  ifdef BYFOUR
@@ -184,12 +188,13 @@ local void make_crc_table()
 #ifdef MAKECRCH
 local void write_table(out, table)
     FILE *out;
-    const unsigned long FAR *table;
+    const crc_table_t FAR *table;
 {
     int n;
 
     for (n = 0; n < 256; n++)
-        fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : "    ", table[n],
+        fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : "    ",
+                (unsigned long)(table[n]),
                 n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
 }
 #endif /* MAKECRCH */
index 8053b6117c023f64554ea783b23fa06985acff7b..c3e7171c5015b16cb4954d0e425b1d832b60c29e 100644 (file)
@@ -2,7 +2,7 @@
  * Generated automatically by crc32.c
  */
 
-local const unsigned long FAR crc_table[TBLS][256] =
+local const crc_table_t FAR crc_table[TBLS][256] =
 {
   {
     0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
index 5c4022f3d4774b98bb22104890b04a7d3f7f4aec..8bd480eb685d3278451e9992a2d61b37408418a8 100644 (file)
@@ -1,5 +1,5 @@
 /* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+ * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -37,7 +37,7 @@
  *  REFERENCES
  *
  *      Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- *      Available in http://www.ietf.org/rfc/rfc1951.txt
+ *      Available in http://tools.ietf.org/html/rfc1951
  *
  *      A description of the Rabin and Karp algorithm is given in the book
  *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
@@ -52,7 +52,7 @@
 #include "deflate.h"
 
 const char deflate_copyright[] =
-   " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
+   " deflate 1.2.6 Copyright 1995-2012 Jean-loup Gailly and Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -155,6 +155,9 @@ local const config configuration_table[10] = {
 struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
 #endif
 
+/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
+#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
+
 /* ===========================================================================
  * Update a hash value with the given input byte
  * IN  assertion: all calls to to UPDATE_HASH are made with consecutive
@@ -235,10 +238,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
 
     strm->msg = Z_NULL;
     if (strm->zalloc == (alloc_func)0) {
+#ifdef Z_SOLO
+        return Z_STREAM_ERROR;
+#else
         strm->zalloc = zcalloc;
         strm->opaque = (voidpf)0;
+#endif
     }
-    if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+    if (strm->zfree == (free_func)0)
+#ifdef Z_SOLO
+        return Z_STREAM_ERROR;
+#else
+        strm->zfree = zcfree;
+#endif
 
 #ifdef FASTEST
     if (level != 0) level = 1;
@@ -314,43 +326,70 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
     uInt  dictLength;
 {
     deflate_state *s;
-    uInt length = dictLength;
-    uInt n;
-    IPos hash_head = 0;
+    uInt str, n;
+    int wrap;
+    unsigned avail;
+    unsigned char *next;
 
-    if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
-        strm->state->wrap == 2 ||
-        (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
+    if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
         return Z_STREAM_ERROR;
-
     s = strm->state;
-    if (s->wrap)
-        strm->adler = adler32(strm->adler, dictionary, dictLength);
+    wrap = s->wrap;
+    if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
+        return Z_STREAM_ERROR;
 
-    if (length < MIN_MATCH) return Z_OK;
-    if (length > s->w_size) {
-        length = s->w_size;
-        dictionary += dictLength - length; /* use the tail of the dictionary */
+    /* when using zlib wrappers, compute Adler-32 for provided dictionary */
+    if (wrap == 1)
+        strm->adler = adler32(strm->adler, dictionary, dictLength);
+    s->wrap = 0;                    /* avoid computing Adler-32 in read_buf */
+
+    /* if dictionary would fill window, just replace the history */
+    if (dictLength >= s->w_size) {
+        if (wrap == 0) {            /* already empty otherwise */
+            CLEAR_HASH(s);
+            s->strstart = 0;
+            s->block_start = 0L;
+            s->insert = 0;
+        }
+        dictionary += dictLength - s->w_size;  /* use the tail */
+        dictLength = s->w_size;
     }
-    zmemcpy(s->window, dictionary, length);
-    s->strstart = length;
-    s->block_start = (long)length;
 
-    /* Insert all strings in the hash table (except for the last two bytes).
-     * s->lookahead stays null, so s->ins_h will be recomputed at the next
-     * call of fill_window.
-     */
-    s->ins_h = s->window[0];
-    UPDATE_HASH(s, s->ins_h, s->window[1]);
-    for (n = 0; n <= length - MIN_MATCH; n++) {
-        INSERT_STRING(s, n, hash_head);
+    /* insert dictionary into window and hash */
+    avail = strm->avail_in;
+    next = strm->next_in;
+    strm->avail_in = dictLength;
+    strm->next_in = (Bytef *)dictionary;
+    fill_window(s);
+    while (s->lookahead >= MIN_MATCH) {
+        str = s->strstart;
+        n = s->lookahead - (MIN_MATCH-1);
+        do {
+            UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
+#ifndef FASTEST
+            s->prev[str & s->w_mask] = s->head[s->ins_h];
+#endif
+            s->head[s->ins_h] = (Pos)str;
+            str++;
+        } while (--n);
+        s->strstart = str;
+        s->lookahead = MIN_MATCH-1;
+        fill_window(s);
     }
-    if (hash_head) hash_head = 0;  /* to make compiler happy */
+    s->strstart += s->lookahead;
+    s->block_start = (long)s->strstart;
+    s->insert = s->lookahead;
+    s->lookahead = 0;
+    s->match_length = s->prev_length = MIN_MATCH-1;
+    s->match_available = 0;
+    strm->next_in = next;
+    strm->avail_in = avail;
+    s->wrap = wrap;
     return Z_OK;
 }
 
 /* ========================================================================= */
-int ZEXPORT deflateReset (strm)
+int ZEXPORT deflateResetKeep (strm)
     z_streamp strm;
 {
     deflate_state *s;
@@ -380,11 +419,22 @@ int ZEXPORT deflateReset (strm)
     s->last_flush = Z_NO_FLUSH;
 
     _tr_init(s);
-    lm_init(s);
 
     return Z_OK;
 }
 
+/* ========================================================================= */
+int ZEXPORT deflateReset (strm)
+    z_streamp strm;
+{
+    int ret;
+
+    ret = deflateResetKeep(strm);
+    if (ret == Z_OK)
+        lm_init(strm->state);
+    return ret;
+}
+
 /* ========================================================================= */
 int ZEXPORT deflateSetHeader (strm, head)
     z_streamp strm;
@@ -396,15 +446,43 @@ int ZEXPORT deflateSetHeader (strm, head)
     return Z_OK;
 }
 
+/* ========================================================================= */
+int ZEXPORT deflatePending (strm, pending, bits)
+    unsigned *pending;
+    int *bits;
+    z_streamp strm;
+{
+    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    if (pending != Z_NULL)
+        *pending = strm->state->pending;
+    if (bits != Z_NULL)
+        *bits = strm->state->bi_valid;
+    return Z_OK;
+}
+
 /* ========================================================================= */
 int ZEXPORT deflatePrime (strm, bits, value)
     z_streamp strm;
     int bits;
     int value;
 {
+    deflate_state *s;
+    int put;
+
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-    strm->state->bi_valid = bits;
-    strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
+    s = strm->state;
+    if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
+        return Z_BUF_ERROR;
+    do {
+        put = Buf_size - s->bi_valid;
+        if (put > bits)
+            put = bits;
+        s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
+        s->bi_valid += put;
+        _tr_flush_bits(s);
+        value >>= put;
+        bits -= put;
+    } while (bits);
     return Z_OK;
 }
 
@@ -562,19 +640,22 @@ local void putShortMSB (s, b)
 local void flush_pending(strm)
     z_streamp strm;
 {
-    unsigned len = strm->state->pending;
+    unsigned len;
+    deflate_state *s = strm->state;
 
+    _tr_flush_bits(s);
+    len = s->pending;
     if (len > strm->avail_out) len = strm->avail_out;
     if (len == 0) return;
 
-    zmemcpy(strm->next_out, strm->state->pending_out, len);
+    zmemcpy(strm->next_out, s->pending_out, len);
     strm->next_out  += len;
-    strm->state->pending_out  += len;
+    s->pending_out  += len;
     strm->total_out += len;
     strm->avail_out  -= len;
-    strm->state->pending -= len;
-    if (strm->state->pending == 0) {
-        strm->state->pending_out = strm->state->pending_buf;
+    s->pending -= len;
+    if (s->pending == 0) {
+        s->pending_out = s->pending_buf;
     }
 }
 
@@ -801,7 +882,7 @@ int ZEXPORT deflate (strm, flush)
      * flushes. For repeated and useless calls with Z_FINISH, we keep
      * returning Z_STREAM_END instead of Z_BUF_ERROR.
      */
-    } else if (strm->avail_in == 0 && flush <= old_flush &&
+    } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
                flush != Z_FINISH) {
         ERR_RETURN(strm, Z_BUF_ERROR);
     }
@@ -850,6 +931,7 @@ int ZEXPORT deflate (strm, flush)
                     if (s->lookahead == 0) {
                         s->strstart = 0;
                         s->block_start = 0L;
+                        s->insert = 0;
                     }
                 }
             }
@@ -945,12 +1027,12 @@ int ZEXPORT deflateCopy (dest, source)
 
     ss = source->state;
 
-    zmemcpy(dest, source, sizeof(z_stream));
+    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
 
     ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
     if (ds == Z_NULL) return Z_MEM_ERROR;
     dest->state = (struct internal_state FAR *) ds;
-    zmemcpy(ds, ss, sizeof(deflate_state));
+    zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
     ds->strm = dest;
 
     ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
@@ -966,8 +1048,8 @@ int ZEXPORT deflateCopy (dest, source)
     }
     /* following zmemcpy do not work for 16-bit MSDOS */
     zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
-    zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
-    zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
+    zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
+    zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
     zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
 
     ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
@@ -1001,15 +1083,15 @@ local int read_buf(strm, buf, size)
 
     strm->avail_in  -= len;
 
+    zmemcpy(buf, strm->next_in, len);
     if (strm->state->wrap == 1) {
-        strm->adler = adler32(strm->adler, strm->next_in, len);
+        strm->adler = adler32(strm->adler, buf, len);
     }
 #ifdef GZIP
     else if (strm->state->wrap == 2) {
-        strm->adler = crc32(strm->adler, strm->next_in, len);
+        strm->adler = crc32(strm->adler, buf, len);
     }
 #endif
-    zmemcpy(buf, strm->next_in, len);
     strm->next_in  += len;
     strm->total_in += len;
 
@@ -1036,6 +1118,7 @@ local void lm_init (s)
     s->strstart = 0;
     s->block_start = 0L;
     s->lookahead = 0;
+    s->insert = 0;
     s->match_length = s->prev_length = MIN_MATCH-1;
     s->match_available = 0;
     s->ins_h = 0;
@@ -1310,6 +1393,8 @@ local void fill_window(s)
     unsigned more;    /* Amount of free space at the end of the window. */
     uInt wsize = s->w_size;
 
+    Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
+
     do {
         more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
 
@@ -1362,7 +1447,7 @@ local void fill_window(s)
 #endif
             more += wsize;
         }
-        if (s->strm->avail_in == 0) return;
+        if (s->strm->avail_in == 0) break;
 
         /* If there was no sliding:
          *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
@@ -1381,12 +1466,24 @@ local void fill_window(s)
         s->lookahead += n;
 
         /* Initialize the hash value now that we have some input: */
-        if (s->lookahead >= MIN_MATCH) {
-            s->ins_h = s->window[s->strstart];
-            UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
+        if (s->lookahead + s->insert >= MIN_MATCH) {
+            uInt str = s->strstart - s->insert;
+            s->ins_h = s->window[str];
+            UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
 #if MIN_MATCH != 3
             Call UPDATE_HASH() MIN_MATCH-3 more times
 #endif
+            while (s->insert) {
+                UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
+#ifndef FASTEST
+                s->prev[str & s->w_mask] = s->head[s->ins_h];
+#endif
+                s->head[s->ins_h] = (Pos)str;
+                str++;
+                s->insert--;
+                if (s->lookahead + s->insert < MIN_MATCH)
+                    break;
+            }
         }
         /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
          * but this is not important since only literal bytes will be emitted.
@@ -1427,6 +1524,9 @@ local void fill_window(s)
             s->high_water += init;
         }
     }
+
+    Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
+           "not enough room for search");
 }
 
 /* ===========================================================================
@@ -1506,8 +1606,14 @@ local block_state deflate_stored(s, flush)
             FLUSH_BLOCK(s, 0);
         }
     }
-    FLUSH_BLOCK(s, flush == Z_FINISH);
-    return flush == Z_FINISH ? finish_done : block_done;
+    s->insert = 0;
+    if (flush == Z_FINISH) {
+        FLUSH_BLOCK(s, 1);
+        return finish_done;
+    }
+    if ((long)s->strstart > s->block_start)
+        FLUSH_BLOCK(s, 0);
+    return block_done;
 }
 
 /* ===========================================================================
@@ -1603,8 +1709,14 @@ local block_state deflate_fast(s, flush)
         }
         if (bflush) FLUSH_BLOCK(s, 0);
     }
-    FLUSH_BLOCK(s, flush == Z_FINISH);
-    return flush == Z_FINISH ? finish_done : block_done;
+    s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
+    if (flush == Z_FINISH) {
+        FLUSH_BLOCK(s, 1);
+        return finish_done;
+    }
+    if (s->last_lit)
+        FLUSH_BLOCK(s, 0);
+    return block_done;
 }
 
 #ifndef FASTEST
@@ -1728,8 +1840,14 @@ local block_state deflate_slow(s, flush)
         _tr_tally_lit(s, s->window[s->strstart-1], bflush);
         s->match_available = 0;
     }
-    FLUSH_BLOCK(s, flush == Z_FINISH);
-    return flush == Z_FINISH ? finish_done : block_done;
+    s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
+    if (flush == Z_FINISH) {
+        FLUSH_BLOCK(s, 1);
+        return finish_done;
+    }
+    if (s->last_lit)
+        FLUSH_BLOCK(s, 0);
+    return block_done;
 }
 #endif /* FASTEST */
 
@@ -1749,11 +1867,11 @@ local block_state deflate_rle(s, flush)
     for (;;) {
         /* Make sure that we always have enough lookahead, except
          * at the end of the input file. We need MAX_MATCH bytes
-         * for the longest encodable run.
+         * for the longest run, plus one for the unrolled loop.
          */
-        if (s->lookahead < MAX_MATCH) {
+        if (s->lookahead <= MAX_MATCH) {
             fill_window(s);
-            if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
+            if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
                 return need_more;
             }
             if (s->lookahead == 0) break; /* flush the current block */
@@ -1776,6 +1894,7 @@ local block_state deflate_rle(s, flush)
                 if (s->match_length > s->lookahead)
                     s->match_length = s->lookahead;
             }
+            Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
         }
 
         /* Emit match if have run of MIN_MATCH or longer, else emit literal */
@@ -1796,8 +1915,14 @@ local block_state deflate_rle(s, flush)
         }
         if (bflush) FLUSH_BLOCK(s, 0);
     }
-    FLUSH_BLOCK(s, flush == Z_FINISH);
-    return flush == Z_FINISH ? finish_done : block_done;
+    s->insert = 0;
+    if (flush == Z_FINISH) {
+        FLUSH_BLOCK(s, 1);
+        return finish_done;
+    }
+    if (s->last_lit)
+        FLUSH_BLOCK(s, 0);
+    return block_done;
 }
 
 /* ===========================================================================
@@ -1829,6 +1954,12 @@ local block_state deflate_huff(s, flush)
         s->strstart++;
         if (bflush) FLUSH_BLOCK(s, 0);
     }
-    FLUSH_BLOCK(s, flush == Z_FINISH);
-    return flush == Z_FINISH ? finish_done : block_done;
+    s->insert = 0;
+    if (flush == Z_FINISH) {
+        FLUSH_BLOCK(s, 1);
+        return finish_done;
+    }
+    if (s->last_lit)
+        FLUSH_BLOCK(s, 0);
+    return block_done;
 }
index cbf0d1ea5d966e572c4d3ae24d334c1ff1789169..fbac44d908ec2b0fee1dce12432cdf33886a5cda 100644 (file)
@@ -1,5 +1,5 @@
 /* deflate.h -- internal compression state
- * Copyright (C) 1995-2010 Jean-loup Gailly
+ * Copyright (C) 1995-2012 Jean-loup Gailly
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -48,6 +48,9 @@
 #define MAX_BITS 15
 /* All codes must not exceed MAX_BITS bits */
 
+#define Buf_size 16
+/* size of bit buffer in bi_buf */
+
 #define INIT_STATE    42
 #define EXTRA_STATE   69
 #define NAME_STATE    73
@@ -188,7 +191,7 @@ typedef struct internal_state {
     int nice_match; /* Stop searching when current match exceeds this */
 
                 /* used by trees.c: */
-    /* Didn't use ct_data typedef below to supress compiler warning */
+    /* Didn't use ct_data typedef below to suppress compiler warning */
     struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */
     struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
     struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */
@@ -244,7 +247,7 @@ typedef struct internal_state {
     ulg opt_len;        /* bit length of current block with optimal trees */
     ulg static_len;     /* bit length of current block with static trees */
     uInt matches;       /* number of string matches in current block */
-    int last_eob_len;   /* bit length of EOB code for last block */
+    uInt insert;        /* bytes at end of window left to insert */
 
 #ifdef DEBUG
     ulg compressed_len; /* total bit length of compressed file mod 2^32 */
@@ -294,6 +297,7 @@ void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
 int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
 void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
                         ulg stored_len, int last));
+void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
 void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
 void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
                         ulg stored_len, int last));
diff --git a/thirdparty/zlib/example.c b/thirdparty/zlib/example.c
deleted file mode 100644 (file)
index 604736f..0000000
+++ /dev/null
@@ -1,565 +0,0 @@
-/* example.c -- usage example of the zlib compression library
- * Copyright (C) 1995-2006 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zlib.h"
-#include <stdio.h>
-
-#ifdef STDC
-#  include <string.h>
-#  include <stdlib.h>
-#endif
-
-#if defined(VMS) || defined(RISCOS)
-#  define TESTFILE "foo-gz"
-#else
-#  define TESTFILE "foo.gz"
-#endif
-
-#define CHECK_ERR(err, msg) { \
-    if (err != Z_OK) { \
-        fprintf(stderr, "%s error: %d\n", msg, err); \
-        exit(1); \
-    } \
-}
-
-const char hello[] = "hello, hello!";
-/* "hello world" would be more standard, but the repeated "hello"
- * stresses the compression code better, sorry...
- */
-
-const char dictionary[] = "hello";
-uLong dictId; /* Adler32 value of the dictionary */
-
-void test_compress      OF((Byte *compr, uLong comprLen,
-                            Byte *uncompr, uLong uncomprLen));
-void test_gzio          OF((const char *fname,
-                            Byte *uncompr, uLong uncomprLen));
-void test_deflate       OF((Byte *compr, uLong comprLen));
-void test_inflate       OF((Byte *compr, uLong comprLen,
-                            Byte *uncompr, uLong uncomprLen));
-void test_large_deflate OF((Byte *compr, uLong comprLen,
-                            Byte *uncompr, uLong uncomprLen));
-void test_large_inflate OF((Byte *compr, uLong comprLen,
-                            Byte *uncompr, uLong uncomprLen));
-void test_flush         OF((Byte *compr, uLong *comprLen));
-void test_sync          OF((Byte *compr, uLong comprLen,
-                            Byte *uncompr, uLong uncomprLen));
-void test_dict_deflate  OF((Byte *compr, uLong comprLen));
-void test_dict_inflate  OF((Byte *compr, uLong comprLen,
-                            Byte *uncompr, uLong uncomprLen));
-int  main               OF((int argc, char *argv[]));
-
-/* ===========================================================================
- * Test compress() and uncompress()
- */
-void test_compress(compr, comprLen, uncompr, uncomprLen)
-    Byte *compr, *uncompr;
-    uLong comprLen, uncomprLen;
-{
-    int err;
-    uLong len = (uLong)strlen(hello)+1;
-
-    err = compress(compr, &comprLen, (const Bytef*)hello, len);
-    CHECK_ERR(err, "compress");
-
-    strcpy((char*)uncompr, "garbage");
-
-    err = uncompress(uncompr, &uncomprLen, compr, comprLen);
-    CHECK_ERR(err, "uncompress");
-
-    if (strcmp((char*)uncompr, hello)) {
-        fprintf(stderr, "bad uncompress\n");
-        exit(1);
-    } else {
-        printf("uncompress(): %s\n", (char *)uncompr);
-    }
-}
-
-/* ===========================================================================
- * Test read/write of .gz files
- */
-void test_gzio(fname, uncompr, uncomprLen)
-    const char *fname; /* compressed file name */
-    Byte *uncompr;
-    uLong uncomprLen;
-{
-#ifdef NO_GZCOMPRESS
-    fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
-#else
-    int err;
-    int len = (int)strlen(hello)+1;
-    gzFile file;
-    z_off_t pos;
-
-    file = gzopen(fname, "wb");
-    if (file == NULL) {
-        fprintf(stderr, "gzopen error\n");
-        exit(1);
-    }
-    gzputc(file, 'h');
-    if (gzputs(file, "ello") != 4) {
-        fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
-        exit(1);
-    }
-    if (gzprintf(file, ", %s!", "hello") != 8) {
-        fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
-        exit(1);
-    }
-    gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
-    gzclose(file);
-
-    file = gzopen(fname, "rb");
-    if (file == NULL) {
-        fprintf(stderr, "gzopen error\n");
-        exit(1);
-    }
-    strcpy((char*)uncompr, "garbage");
-
-    if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
-        fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
-        exit(1);
-    }
-    if (strcmp((char*)uncompr, hello)) {
-        fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
-        exit(1);
-    } else {
-        printf("gzread(): %s\n", (char*)uncompr);
-    }
-
-    pos = gzseek(file, -8L, SEEK_CUR);
-    if (pos != 6 || gztell(file) != pos) {
-        fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
-                (long)pos, (long)gztell(file));
-        exit(1);
-    }
-
-    if (gzgetc(file) != ' ') {
-        fprintf(stderr, "gzgetc error\n");
-        exit(1);
-    }
-
-    if (gzungetc(' ', file) != ' ') {
-        fprintf(stderr, "gzungetc error\n");
-        exit(1);
-    }
-
-    gzgets(file, (char*)uncompr, (int)uncomprLen);
-    if (strlen((char*)uncompr) != 7) { /* " hello!" */
-        fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
-        exit(1);
-    }
-    if (strcmp((char*)uncompr, hello + 6)) {
-        fprintf(stderr, "bad gzgets after gzseek\n");
-        exit(1);
-    } else {
-        printf("gzgets() after gzseek: %s\n", (char*)uncompr);
-    }
-
-    gzclose(file);
-#endif
-}
-
-/* ===========================================================================
- * Test deflate() with small buffers
- */
-void test_deflate(compr, comprLen)
-    Byte *compr;
-    uLong comprLen;
-{
-    z_stream c_stream; /* compression stream */
-    int err;
-    uLong len = (uLong)strlen(hello)+1;
-
-    c_stream.zalloc = (alloc_func)0;
-    c_stream.zfree = (free_func)0;
-    c_stream.opaque = (voidpf)0;
-
-    err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
-    CHECK_ERR(err, "deflateInit");
-
-    c_stream.next_in  = (Bytef*)hello;
-    c_stream.next_out = compr;
-
-    while (c_stream.total_in != len && c_stream.total_out < comprLen) {
-        c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
-        err = deflate(&c_stream, Z_NO_FLUSH);
-        CHECK_ERR(err, "deflate");
-    }
-    /* Finish the stream, still forcing small buffers: */
-    for (;;) {
-        c_stream.avail_out = 1;
-        err = deflate(&c_stream, Z_FINISH);
-        if (err == Z_STREAM_END) break;
-        CHECK_ERR(err, "deflate");
-    }
-
-    err = deflateEnd(&c_stream);
-    CHECK_ERR(err, "deflateEnd");
-}
-
-/* ===========================================================================
- * Test inflate() with small buffers
- */
-void test_inflate(compr, comprLen, uncompr, uncomprLen)
-    Byte *compr, *uncompr;
-    uLong comprLen, uncomprLen;
-{
-    int err;
-    z_stream d_stream; /* decompression stream */
-
-    strcpy((char*)uncompr, "garbage");
-
-    d_stream.zalloc = (alloc_func)0;
-    d_stream.zfree = (free_func)0;
-    d_stream.opaque = (voidpf)0;
-
-    d_stream.next_in  = compr;
-    d_stream.avail_in = 0;
-    d_stream.next_out = uncompr;
-
-    err = inflateInit(&d_stream);
-    CHECK_ERR(err, "inflateInit");
-
-    while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
-        d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
-        err = inflate(&d_stream, Z_NO_FLUSH);
-        if (err == Z_STREAM_END) break;
-        CHECK_ERR(err, "inflate");
-    }
-
-    err = inflateEnd(&d_stream);
-    CHECK_ERR(err, "inflateEnd");
-
-    if (strcmp((char*)uncompr, hello)) {
-        fprintf(stderr, "bad inflate\n");
-        exit(1);
-    } else {
-        printf("inflate(): %s\n", (char *)uncompr);
-    }
-}
-
-/* ===========================================================================
- * Test deflate() with large buffers and dynamic change of compression level
- */
-void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
-    Byte *compr, *uncompr;
-    uLong comprLen, uncomprLen;
-{
-    z_stream c_stream; /* compression stream */
-    int err;
-
-    c_stream.zalloc = (alloc_func)0;
-    c_stream.zfree = (free_func)0;
-    c_stream.opaque = (voidpf)0;
-
-    err = deflateInit(&c_stream, Z_BEST_SPEED);
-    CHECK_ERR(err, "deflateInit");
-
-    c_stream.next_out = compr;
-    c_stream.avail_out = (uInt)comprLen;
-
-    /* At this point, uncompr is still mostly zeroes, so it should compress
-     * very well:
-     */
-    c_stream.next_in = uncompr;
-    c_stream.avail_in = (uInt)uncomprLen;
-    err = deflate(&c_stream, Z_NO_FLUSH);
-    CHECK_ERR(err, "deflate");
-    if (c_stream.avail_in != 0) {
-        fprintf(stderr, "deflate not greedy\n");
-        exit(1);
-    }
-
-    /* Feed in already compressed data and switch to no compression: */
-    deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
-    c_stream.next_in = compr;
-    c_stream.avail_in = (uInt)comprLen/2;
-    err = deflate(&c_stream, Z_NO_FLUSH);
-    CHECK_ERR(err, "deflate");
-
-    /* Switch back to compressing mode: */
-    deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
-    c_stream.next_in = uncompr;
-    c_stream.avail_in = (uInt)uncomprLen;
-    err = deflate(&c_stream, Z_NO_FLUSH);
-    CHECK_ERR(err, "deflate");
-
-    err = deflate(&c_stream, Z_FINISH);
-    if (err != Z_STREAM_END) {
-        fprintf(stderr, "deflate should report Z_STREAM_END\n");
-        exit(1);
-    }
-    err = deflateEnd(&c_stream);
-    CHECK_ERR(err, "deflateEnd");
-}
-
-/* ===========================================================================
- * Test inflate() with large buffers
- */
-void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
-    Byte *compr, *uncompr;
-    uLong comprLen, uncomprLen;
-{
-    int err;
-    z_stream d_stream; /* decompression stream */
-
-    strcpy((char*)uncompr, "garbage");
-
-    d_stream.zalloc = (alloc_func)0;
-    d_stream.zfree = (free_func)0;
-    d_stream.opaque = (voidpf)0;
-
-    d_stream.next_in  = compr;
-    d_stream.avail_in = (uInt)comprLen;
-
-    err = inflateInit(&d_stream);
-    CHECK_ERR(err, "inflateInit");
-
-    for (;;) {
-        d_stream.next_out = uncompr;            /* discard the output */
-        d_stream.avail_out = (uInt)uncomprLen;
-        err = inflate(&d_stream, Z_NO_FLUSH);
-        if (err == Z_STREAM_END) break;
-        CHECK_ERR(err, "large inflate");
-    }
-
-    err = inflateEnd(&d_stream);
-    CHECK_ERR(err, "inflateEnd");
-
-    if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
-        fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
-        exit(1);
-    } else {
-        printf("large_inflate(): OK\n");
-    }
-}
-
-/* ===========================================================================
- * Test deflate() with full flush
- */
-void test_flush(compr, comprLen)
-    Byte *compr;
-    uLong *comprLen;
-{
-    z_stream c_stream; /* compression stream */
-    int err;
-    uInt len = (uInt)strlen(hello)+1;
-
-    c_stream.zalloc = (alloc_func)0;
-    c_stream.zfree = (free_func)0;
-    c_stream.opaque = (voidpf)0;
-
-    err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
-    CHECK_ERR(err, "deflateInit");
-
-    c_stream.next_in  = (Bytef*)hello;
-    c_stream.next_out = compr;
-    c_stream.avail_in = 3;
-    c_stream.avail_out = (uInt)*comprLen;
-    err = deflate(&c_stream, Z_FULL_FLUSH);
-    CHECK_ERR(err, "deflate");
-
-    compr[3]++; /* force an error in first compressed block */
-    c_stream.avail_in = len - 3;
-
-    err = deflate(&c_stream, Z_FINISH);
-    if (err != Z_STREAM_END) {
-        CHECK_ERR(err, "deflate");
-    }
-    err = deflateEnd(&c_stream);
-    CHECK_ERR(err, "deflateEnd");
-
-    *comprLen = c_stream.total_out;
-}
-
-/* ===========================================================================
- * Test inflateSync()
- */
-void test_sync(compr, comprLen, uncompr, uncomprLen)
-    Byte *compr, *uncompr;
-    uLong comprLen, uncomprLen;
-{
-    int err;
-    z_stream d_stream; /* decompression stream */
-
-    strcpy((char*)uncompr, "garbage");
-
-    d_stream.zalloc = (alloc_func)0;
-    d_stream.zfree = (free_func)0;
-    d_stream.opaque = (voidpf)0;
-
-    d_stream.next_in  = compr;
-    d_stream.avail_in = 2; /* just read the zlib header */
-
-    err = inflateInit(&d_stream);
-    CHECK_ERR(err, "inflateInit");
-
-    d_stream.next_out = uncompr;
-    d_stream.avail_out = (uInt)uncomprLen;
-
-    inflate(&d_stream, Z_NO_FLUSH);
-    CHECK_ERR(err, "inflate");
-
-    d_stream.avail_in = (uInt)comprLen-2;   /* read all compressed data */
-    err = inflateSync(&d_stream);           /* but skip the damaged part */
-    CHECK_ERR(err, "inflateSync");
-
-    err = inflate(&d_stream, Z_FINISH);
-    if (err != Z_DATA_ERROR) {
-        fprintf(stderr, "inflate should report DATA_ERROR\n");
-        /* Because of incorrect adler32 */
-        exit(1);
-    }
-    err = inflateEnd(&d_stream);
-    CHECK_ERR(err, "inflateEnd");
-
-    printf("after inflateSync(): hel%s\n", (char *)uncompr);
-}
-
-/* ===========================================================================
- * Test deflate() with preset dictionary
- */
-void test_dict_deflate(compr, comprLen)
-    Byte *compr;
-    uLong comprLen;
-{
-    z_stream c_stream; /* compression stream */
-    int err;
-
-    c_stream.zalloc = (alloc_func)0;
-    c_stream.zfree = (free_func)0;
-    c_stream.opaque = (voidpf)0;
-
-    err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
-    CHECK_ERR(err, "deflateInit");
-
-    err = deflateSetDictionary(&c_stream,
-                               (const Bytef*)dictionary, sizeof(dictionary));
-    CHECK_ERR(err, "deflateSetDictionary");
-
-    dictId = c_stream.adler;
-    c_stream.next_out = compr;
-    c_stream.avail_out = (uInt)comprLen;
-
-    c_stream.next_in = (Bytef*)hello;
-    c_stream.avail_in = (uInt)strlen(hello)+1;
-
-    err = deflate(&c_stream, Z_FINISH);
-    if (err != Z_STREAM_END) {
-        fprintf(stderr, "deflate should report Z_STREAM_END\n");
-        exit(1);
-    }
-    err = deflateEnd(&c_stream);
-    CHECK_ERR(err, "deflateEnd");
-}
-
-/* ===========================================================================
- * Test inflate() with a preset dictionary
- */
-void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
-    Byte *compr, *uncompr;
-    uLong comprLen, uncomprLen;
-{
-    int err;
-    z_stream d_stream; /* decompression stream */
-
-    strcpy((char*)uncompr, "garbage");
-
-    d_stream.zalloc = (alloc_func)0;
-    d_stream.zfree = (free_func)0;
-    d_stream.opaque = (voidpf)0;
-
-    d_stream.next_in  = compr;
-    d_stream.avail_in = (uInt)comprLen;
-
-    err = inflateInit(&d_stream);
-    CHECK_ERR(err, "inflateInit");
-
-    d_stream.next_out = uncompr;
-    d_stream.avail_out = (uInt)uncomprLen;
-
-    for (;;) {
-        err = inflate(&d_stream, Z_NO_FLUSH);
-        if (err == Z_STREAM_END) break;
-        if (err == Z_NEED_DICT) {
-            if (d_stream.adler != dictId) {
-                fprintf(stderr, "unexpected dictionary");
-                exit(1);
-            }
-            err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
-                                       sizeof(dictionary));
-        }
-        CHECK_ERR(err, "inflate with dict");
-    }
-
-    err = inflateEnd(&d_stream);
-    CHECK_ERR(err, "inflateEnd");
-
-    if (strcmp((char*)uncompr, hello)) {
-        fprintf(stderr, "bad inflate with dict\n");
-        exit(1);
-    } else {
-        printf("inflate with dictionary: %s\n", (char *)uncompr);
-    }
-}
-
-/* ===========================================================================
- * Usage:  example [output.gz  [input.gz]]
- */
-
-int main(argc, argv)
-    int argc;
-    char *argv[];
-{
-    Byte *compr, *uncompr;
-    uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
-    uLong uncomprLen = comprLen;
-    static const char* myVersion = ZLIB_VERSION;
-
-    if (zlibVersion()[0] != myVersion[0]) {
-        fprintf(stderr, "incompatible zlib version\n");
-        exit(1);
-
-    } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
-        fprintf(stderr, "warning: different zlib version\n");
-    }
-
-    printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
-            ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
-
-    compr    = (Byte*)calloc((uInt)comprLen, 1);
-    uncompr  = (Byte*)calloc((uInt)uncomprLen, 1);
-    /* compr and uncompr are cleared to avoid reading uninitialized
-     * data and to ensure that uncompr compresses well.
-     */
-    if (compr == Z_NULL || uncompr == Z_NULL) {
-        printf("out of memory\n");
-        exit(1);
-    }
-    test_compress(compr, comprLen, uncompr, uncomprLen);
-
-    test_gzio((argc > 1 ? argv[1] : TESTFILE),
-              uncompr, uncomprLen);
-
-    test_deflate(compr, comprLen);
-    test_inflate(compr, comprLen, uncompr, uncomprLen);
-
-    test_large_deflate(compr, comprLen, uncompr, uncomprLen);
-    test_large_inflate(compr, comprLen, uncompr, uncomprLen);
-
-    test_flush(compr, &comprLen);
-    test_sync(compr, comprLen, uncompr, uncomprLen);
-    comprLen = uncomprLen;
-
-    test_dict_deflate(compr, comprLen);
-    test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
-
-    free(compr);
-    free(uncompr);
-
-    return 0;
-}
index 0f8fb79f87d4f65e7f5667129c763e3a361199f2..3107c363b25484684302dc2dc4d298a7bd8df601 100644 (file)
@@ -1,5 +1,5 @@
 /* gzguts.h -- zlib internal header definitions for gz* operations
- * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
 #endif
 #include <fcntl.h>
 
+#ifdef __TURBOC__
+#  include <io.h>
+#endif
+
 #ifdef NO_DEFLATE       /* for compatibility with old definition */
 #  define NO_GZCOMPRESS
 #endif
 
-#ifdef _MSC_VER
-#  include <io.h>
-#  define vsnprintf _vsnprintf
+#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
+#  ifndef HAVE_VSNPRINTF
+#    define HAVE_VSNPRINTF
+#  endif
+#endif
+
+#if defined(__CYGWIN__)
+#  ifndef HAVE_VSNPRINTF
+#    define HAVE_VSNPRINTF
+#  endif
+#endif
+
+#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
+#  ifndef HAVE_VSNPRINTF
+#    define HAVE_VSNPRINTF
+#  endif
+#endif
+
+#ifndef HAVE_VSNPRINTF
+#  ifdef MSDOS
+/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
+ but for now we just assume it doesn't. */
+#    define NO_vsnprintf
+#  endif
+#  ifdef __TURBOC__
+#    define NO_vsnprintf
+#  endif
+#  ifdef WIN32
+/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
+#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
+#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
+#         include <io.h>
+#         define vsnprintf _vsnprintf
+#      endif
+#    endif
+#  endif
+#  ifdef __SASC
+#    define NO_vsnprintf
+#  endif
+#  ifdef VMS
+#    define NO_vsnprintf
+#  endif
+#  ifdef __OS400__
+#    define NO_vsnprintf
+#  endif
+#  ifdef __MVS__
+#    define NO_vsnprintf
+#  endif
 #endif
 
 #ifndef local
     ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
 #endif
 
+/* default memLevel */
+#if MAX_MEM_LEVEL >= 8
+#  define DEF_MEM_LEVEL 8
+#else
+#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
+#endif
+
 /* default i/o buffer size -- double this for output when reading */
 #define GZBUFSIZE 8192
 
 
 /* internal gzip file state data structure */
 typedef struct {
+        /* exposed contents for gzgetc() macro */
+    struct gzFile_s x;      /* "x" for exposed */
+                            /* x.have: number of bytes available at x.next */
+                            /* x.next: next output data to deliver or write */
+                            /* x.pos: current position in uncompressed data */
         /* used for both reading and writing */
     int mode;               /* see gzip modes above */
     int fd;                 /* file descriptor */
     char *path;             /* path or fd for error messages */
-    z_off64_t pos;          /* current position in uncompressed data */
     unsigned size;          /* buffer size, zero if not allocated yet */
     unsigned want;          /* requested buffer size, default is GZBUFSIZE */
     unsigned char *in;      /* input buffer */
     unsigned char *out;     /* output buffer (double-sized when reading) */
-    unsigned char *next;    /* next output data to deliver or write */
+    int direct;             /* 0 if processing gzip, 1 if transparent */
         /* just for reading */
-    unsigned have;          /* amount of output data unused at next */
-    int eof;                /* true if end of input file reached */
-    z_off64_t start;        /* where the gzip data started, for rewinding */
-    z_off64_t raw;          /* where the raw data started, for seeking */
     int how;                /* 0: get header, 1: copy, 2: decompress */
-    int direct;             /* true if last read direct, false if gzip */
+    z_off64_t start;        /* where the gzip data started, for rewinding */
+    int eof;                /* true if end of input file reached */
+    int past;               /* true if read requested past end */
         /* just for writing */
     int level;              /* compression level */
     int strategy;           /* compression strategy */
index 603e60ed5444e0e7a2ed9590a9d9a73ce7cc97bf..7aedab8e2dfda81b938116fab42857f0a9d49a12 100644 (file)
@@ -1,15 +1,19 @@
 /* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004, 2010 Mark Adler
+ * Copyright (C) 2004, 2010, 2011 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
 #include "gzguts.h"
 
+#if defined(_WIN32) && !defined(__BORLANDC__)
+#  define LSEEK _lseeki64
+#else
 #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
 #  define LSEEK lseek64
 #else
 #  define LSEEK lseek
 #endif
+#endif
 
 /* Local functions */
 local void gz_reset OF((gz_statep));
@@ -71,15 +75,15 @@ char ZLIB_INTERNAL *gz_strwinerror (error)
 local void gz_reset(state)
     gz_statep state;
 {
+    state->x.have = 0;              /* no output data available */
     if (state->mode == GZ_READ) {   /* for reading ... */
-        state->have = 0;            /* no output data available */
         state->eof = 0;             /* not at end of file */
+        state->past = 0;            /* have not read past end yet */
         state->how = LOOK;          /* look for gzip header */
-        state->direct = 1;          /* default for empty file */
     }
     state->seek = 0;                /* no seek request pending */
     gz_error(state, Z_OK, NULL);    /* clear error */
-    state->pos = 0;                 /* no uncompressed data yet */
+    state->x.pos = 0;               /* no uncompressed data yet */
     state->strm.avail_in = 0;       /* no input data yet */
 }
 
@@ -91,6 +95,10 @@ local gzFile gz_open(path, fd, mode)
 {
     gz_statep state;
 
+    /* check input */
+    if (path == NULL)
+        return NULL;
+
     /* allocate gzFile structure to return */
     state = malloc(sizeof(gz_state));
     if (state == NULL)
@@ -103,6 +111,7 @@ local gzFile gz_open(path, fd, mode)
     state->mode = GZ_NONE;
     state->level = Z_DEFAULT_COMPRESSION;
     state->strategy = Z_DEFAULT_STRATEGY;
+    state->direct = 0;
     while (*mode) {
         if (*mode >= '0' && *mode <= '9')
             state->level = *mode - '0';
@@ -135,6 +144,8 @@ local gzFile gz_open(path, fd, mode)
                 break;
             case 'F':
                 state->strategy = Z_FIXED;
+            case 'T':
+                state->direct = 1;
             default:        /* could consider as an error, but just ignore */
                 ;
             }
@@ -147,6 +158,15 @@ local gzFile gz_open(path, fd, mode)
         return NULL;
     }
 
+    /* can't force transparent read */
+    if (state->mode == GZ_READ) {
+        if (state->direct) {
+            free(state);
+            return NULL;
+        }
+        state->direct = 1;      /* for empty file */
+    }
+
     /* save the path name for error messages */
     state->path = malloc(strlen(path) + 1);
     if (state->path == NULL) {
@@ -243,8 +263,8 @@ int ZEXPORT gzbuffer(file, size)
         return -1;
 
     /* check and set requested size */
-    if (size == 0)
-        return -1;
+    if (size < 2)
+        size = 2;               /* need two bytes to check magic header */
     state->want = size;
     return 0;
 }
@@ -261,7 +281,8 @@ int ZEXPORT gzrewind(file)
     state = (gz_statep)file;
 
     /* check that we're reading and that there's no error */
-    if (state->mode != GZ_READ || state->err != Z_OK)
+    if (state->mode != GZ_READ ||
+            (state->err != Z_OK && state->err != Z_BUF_ERROR))
         return -1;
 
     /* back up and start over */
@@ -289,7 +310,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
         return -1;
 
     /* check that there's no error */
-    if (state->err != Z_OK)
+    if (state->err != Z_OK && state->err != Z_BUF_ERROR)
         return -1;
 
     /* can only seek from start or relative to current position */
@@ -298,31 +319,32 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
 
     /* normalize offset to a SEEK_CUR specification */
     if (whence == SEEK_SET)
-        offset -= state->pos;
+        offset -= state->x.pos;
     else if (state->seek)
         offset += state->skip;
     state->seek = 0;
 
     /* if within raw area while reading, just go there */
     if (state->mode == GZ_READ && state->how == COPY &&
-        state->pos + offset >= state->raw) {
-        ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
+            state->x.pos + offset >= 0) {
+        ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
         if (ret == -1)
             return -1;
-        state->have = 0;
+        state->x.have = 0;
         state->eof = 0;
+        state->past = 0;
         state->seek = 0;
         gz_error(state, Z_OK, NULL);
         state->strm.avail_in = 0;
-        state->pos += offset;
-        return state->pos;
+        state->x.pos += offset;
+        return state->x.pos;
     }
 
     /* calculate skip amount, rewinding if needed for back seek when reading */
     if (offset < 0) {
         if (state->mode != GZ_READ)         /* writing -- can't go backwards */
             return -1;
-        offset += state->pos;
+        offset += state->x.pos;
         if (offset < 0)                     /* before start of file! */
             return -1;
         if (gzrewind(file) == -1)           /* rewind, then skip to offset */
@@ -331,11 +353,11 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
 
     /* if reading, skip what's in output buffer (one less gzgetc() check) */
     if (state->mode == GZ_READ) {
-        n = GT_OFF(state->have) || (z_off64_t)state->have > offset ?
-            (unsigned)offset : state->have;
-        state->have -= n;
-        state->next += n;
-        state->pos += n;
+        n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?
+            (unsigned)offset : state->x.have;
+        state->x.have -= n;
+        state->x.next += n;
+        state->x.pos += n;
         offset -= n;
     }
 
@@ -344,7 +366,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
         state->seek = 1;
         state->skip = offset;
     }
-    return state->pos + offset;
+    return state->x.pos + offset;
 }
 
 /* -- see zlib.h -- */
@@ -373,7 +395,7 @@ z_off64_t ZEXPORT gztell64(file)
         return -1;
 
     /* return position */
-    return state->pos + (state->seek ? state->skip : 0);
+    return state->x.pos + (state->seek ? state->skip : 0);
 }
 
 /* -- see zlib.h -- */
@@ -433,8 +455,7 @@ int ZEXPORT gzeof(file)
         return 0;
 
     /* return end-of-file state */
-    return state->mode == GZ_READ ?
-        (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0;
+    return state->mode == GZ_READ ? state->past : 0;
 }
 
 /* -- see zlib.h -- */
@@ -471,8 +492,10 @@ void ZEXPORT gzclearerr(file)
         return;
 
     /* clear error and end-of-file */
-    if (state->mode == GZ_READ)
+    if (state->mode == GZ_READ) {
         state->eof = 0;
+        state->past = 0;
+    }
     gz_error(state, Z_OK, NULL);
 }
 
@@ -494,6 +517,10 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
         state->msg = NULL;
     }
 
+    /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
+    if (err != Z_OK && err != Z_BUF_ERROR)
+        state->x.have = 0;
+
     /* set error code, and if no message, then done */
     state->err = err;
     if (msg == NULL)
index 3a6ba9f0fbc975f2ddb11cf80bfa42cf12140a4e..46d40e0bb8d2982145e97729d320be4959e86189 100644 (file)
@@ -1,5 +1,5 @@
 /* gzread.c -- zlib functions for reading gzip files
- * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -8,10 +8,9 @@
 /* Local functions */
 local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
 local int gz_avail OF((gz_statep));
-local int gz_next4 OF((gz_statep, unsigned long *));
-local int gz_head OF((gz_statep));
+local int gz_look OF((gz_statep));
 local int gz_decomp OF((gz_statep));
-local int gz_make OF((gz_statep));
+local int gz_fetch OF((gz_statep));
 local int gz_skip OF((gz_statep, z_off64_t));
 
 /* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
@@ -46,67 +45,42 @@ local int gz_load(state, buf, len, have)
    error, 0 otherwise.  Note that the eof flag is set when the end of the input
    file is reached, even though there may be unused data in the buffer.  Once
    that data has been used, no more attempts will be made to read the file.
-   gz_avail() assumes that strm->avail_in == 0. */
+   If strm->avail_in != 0, then the current data is moved to the beginning of
+   the input buffer, and then the remainder of the buffer is loaded with the
+   available data from the input file. */
 local int gz_avail(state)
     gz_statep state;
 {
+    unsigned got;
     z_streamp strm = &(state->strm);
 
-    if (state->err != Z_OK)
+    if (state->err != Z_OK && state->err != Z_BUF_ERROR)
         return -1;
     if (state->eof == 0) {
-        if (gz_load(state, state->in, state->size,
-                (unsigned *)&(strm->avail_in)) == -1)
+        if (strm->avail_in)
+            memmove(state->in, strm->next_in, strm->avail_in);
+        if (gz_load(state, state->in + strm->avail_in,
+                    state->size - strm->avail_in, &got) == -1)
             return -1;
+        strm->avail_in += got;
         strm->next_in = state->in;
     }
     return 0;
 }
 
-/* Get next byte from input, or -1 if end or error. */
-#define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \
-                (strm->avail_in == 0 ? -1 : \
-                 (strm->avail_in--, *(strm->next_in)++)))
-
-/* Get a four-byte little-endian integer and return 0 on success and the value
-   in *ret.  Otherwise -1 is returned and *ret is not modified. */
-local int gz_next4(state, ret)
-    gz_statep state;
-    unsigned long *ret;
-{
-    int ch;
-    unsigned long val;
-    z_streamp strm = &(state->strm);
-
-    val = NEXT();
-    val += (unsigned)NEXT() << 8;
-    val += (unsigned long)NEXT() << 16;
-    ch = NEXT();
-    if (ch == -1)
-        return -1;
-    val += (unsigned long)ch << 24;
-    *ret = val;
-    return 0;
-}
-
-/* Look for gzip header, set up for inflate or copy.  state->have must be zero.
+/* Look for gzip header, set up for inflate or copy.  state->x.have must be 0.
    If this is the first time in, allocate required memory.  state->how will be
    left unchanged if there is no more input data available, will be set to COPY
    if there is no gzip header and direct copying will be performed, or it will
-   be set to GZIP for decompression, and the gzip header will be skipped so
-   that the next available input data is the raw deflate stream.  If direct
-   copying, then leftover input data from the input buffer will be copied to
-   the output buffer.  In that case, all further file reads will be directly to
-   either the output buffer or a user buffer.  If decompressing, the inflate
-   state and the check value will be initialized.  gz_head() will return 0 on
-   success or -1 on failure.  Failures may include read errors or gzip header
-   errors.  */
-local int gz_head(state)
+   be set to GZIP for decompression.  If direct copying, then leftover input
+   data from the input buffer will be copied to the output buffer.  In that
+   case, all further file reads will be directly to either the output buffer or
+   a user buffer.  If decompressing, the inflate state will be initialized.
+   gz_look() will return 0 on success or -1 on failure. */
+local int gz_look(state)
     gz_statep state;
 {
     z_streamp strm = &(state->strm);
-    int flags;
-    unsigned len;
 
     /* allocate read buffers and inflate memory */
     if (state->size == 0) {
@@ -129,7 +103,7 @@ local int gz_head(state)
         state->strm.opaque = Z_NULL;
         state->strm.avail_in = 0;
         state->strm.next_in = Z_NULL;
-        if (inflateInit2(&(state->strm), -15) != Z_OK) {    /* raw inflate */
+        if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) {    /* gunzip */
             free(state->out);
             free(state->in);
             state->size = 0;
@@ -138,83 +112,45 @@ local int gz_head(state)
         }
     }
 
-    /* get some data in the input buffer */
-    if (strm->avail_in == 0) {
+    /* get at least the magic bytes in the input buffer */
+    if (strm->avail_in < 2) {
         if (gz_avail(state) == -1)
             return -1;
         if (strm->avail_in == 0)
             return 0;
     }
 
-    /* look for the gzip magic header bytes 31 and 139 */
-    if (strm->next_in[0] == 31) {
-        strm->avail_in--;
-        strm->next_in++;
-        if (strm->avail_in == 0 && gz_avail(state) == -1)
-            return -1;
-        if (strm->avail_in && strm->next_in[0] == 139) {
-            /* we have a gzip header, woo hoo! */
-            strm->avail_in--;
-            strm->next_in++;
-
-            /* skip rest of header */
-            if (NEXT() != 8) {      /* compression method */
-                gz_error(state, Z_DATA_ERROR, "unknown compression method");
-                return -1;
-            }
-            flags = NEXT();
-            if (flags & 0xe0) {     /* reserved flag bits */
-                gz_error(state, Z_DATA_ERROR, "unknown header flags set");
-                return -1;
-            }
-            NEXT();                 /* modification time */
-            NEXT();
-            NEXT();
-            NEXT();
-            NEXT();                 /* extra flags */
-            NEXT();                 /* operating system */
-            if (flags & 4) {        /* extra field */
-                len = (unsigned)NEXT();
-                len += (unsigned)NEXT() << 8;
-                while (len--)
-                    if (NEXT() < 0)
-                        break;
-            }
-            if (flags & 8)          /* file name */
-                while (NEXT() > 0)
-                    ;
-            if (flags & 16)         /* comment */
-                while (NEXT() > 0)
-                    ;
-            if (flags & 2) {        /* header crc */
-                NEXT();
-                NEXT();
-            }
-            /* an unexpected end of file is not checked for here -- it will be
-               noticed on the first request for uncompressed data */
-
-            /* set up for decompression */
-            inflateReset(strm);
-            strm->adler = crc32(0L, Z_NULL, 0);
-            state->how = GZIP;
-            state->direct = 0;
-            return 0;
-        }
-        else {
-            /* not a gzip file -- save first byte (31) and fall to raw i/o */
-            state->out[0] = 31;
-            state->have = 1;
-        }
+    /* look for gzip magic bytes -- if there, do gzip decoding (note: there is
+       a logical dilemma here when considering the case of a partially written
+       gzip file, to wit, if a single 31 byte is written, then we cannot tell
+       whether this is a single-byte file, or just a partially written gzip
+       file -- for here we assume that if a gzip file is being written, then
+       the header will be written in a single operation, so that reading a
+       single byte is sufficient indication that it is not a gzip file) */
+    if (strm->avail_in > 1 &&
+            strm->next_in[0] == 31 && strm->next_in[1] == 139) {
+        inflateReset(strm);
+        state->how = GZIP;
+        state->direct = 0;
+        return 0;
+    }
+
+    /* no gzip header -- if we were decoding gzip before, then this is trailing
+       garbage.  Ignore the trailing garbage and finish. */
+    if (state->direct == 0) {
+        strm->avail_in = 0;
+        state->eof = 1;
+        state->x.have = 0;
+        return 0;
     }
 
-    /* doing raw i/o, save start of raw data for seeking, copy any leftover
-       input to output -- this assumes that the output buffer is larger than
-       the input buffer, which also assures space for gzungetc() */
-    state->raw = state->pos;
-    state->next = state->out;
+    /* doing raw i/o, copy any leftover input to output -- this assumes that
+       the output buffer is larger than the input buffer, which also assures
+       space for gzungetc() */
+    state->x.next = state->out;
     if (strm->avail_in) {
-        memcpy(state->next + state->have, strm->next_in, strm->avail_in);
-        state->have += strm->avail_in;
+        memcpy(state->x.next, strm->next_in, strm->avail_in);
+        state->x.have = strm->avail_in;
         strm->avail_in = 0;
     }
     state->how = COPY;
@@ -223,19 +159,15 @@ local int gz_head(state)
 }
 
 /* Decompress from input to the provided next_out and avail_out in the state.
-   If the end of the compressed data is reached, then verify the gzip trailer
-   check value and length (modulo 2^32).  state->have and state->next are set
-   to point to the just decompressed data, and the crc is updated.  If the
-   trailer is verified, state->how is reset to LOOK to look for the next gzip
-   stream or raw data, once state->have is depleted.  Returns 0 on success, -1
-   on failure.  Failures may include invalid compressed data or a failed gzip
-   trailer verification. */
+   On return, state->x.have and state->x.next point to the just decompressed
+   data.  If the gzip stream completes, state->how is reset to LOOK to look for
+   the next gzip stream or raw data, once state->x.have is depleted.  Returns 0
+   on success, -1 on failure. */
 local int gz_decomp(state)
     gz_statep state;
 {
-    int ret;
+    int ret = Z_OK;
     unsigned had;
-    unsigned long crc, len;
     z_streamp strm = &(state->strm);
 
     /* fill output buffer up to end of deflate stream */
@@ -245,21 +177,15 @@ local int gz_decomp(state)
         if (strm->avail_in == 0 && gz_avail(state) == -1)
             return -1;
         if (strm->avail_in == 0) {
-#if 0
-            gz_error(state, Z_DATA_ERROR, "unexpected end of file");
-            return -1;
-#else
-            /* APITRACE: Ignore unexpected end of file. */
-            ret = 0;
+            gz_error(state, Z_BUF_ERROR, "unexpected end of file");
             break;
-#endif
         }
 
         /* decompress and handle errors */
         ret = inflate(strm, Z_NO_FLUSH);
         if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
             gz_error(state, Z_STREAM_ERROR,
-                      "internal error: inflate stream corrupt");
+                     "internal error: inflate stream corrupt");
             return -1;
         }
         if (ret == Z_MEM_ERROR) {
@@ -268,67 +194,55 @@ local int gz_decomp(state)
         }
         if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */
             gz_error(state, Z_DATA_ERROR,
-                      strm->msg == NULL ? "compressed data error" : strm->msg);
+                     strm->msg == NULL ? "compressed data error" : strm->msg);
             return -1;
         }
     } while (strm->avail_out && ret != Z_STREAM_END);
 
-    /* update available output and crc check value */
-    state->have = had - strm->avail_out;
-    state->next = strm->next_out - state->have;
-    strm->adler = crc32(strm->adler, state->next, state->have);
+    /* update available output */
+    state->x.have = had - strm->avail_out;
+    state->x.next = strm->next_out - state->x.have;
 
-    /* check gzip trailer if at end of deflate stream */
-    if (ret == Z_STREAM_END) {
-        if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) {
-            gz_error(state, Z_DATA_ERROR, "unexpected end of file");
-            return -1;
-        }
-        if (crc != strm->adler) {
-            gz_error(state, Z_DATA_ERROR, "incorrect data check");
-            return -1;
-        }
-        if (len != (strm->total_out & 0xffffffffL)) {
-            gz_error(state, Z_DATA_ERROR, "incorrect length check");
-            return -1;
-        }
-        state->how = LOOK;      /* ready for next stream, once have is 0 (leave
-                                   state->direct unchanged to remember how) */
-    }
+    /* if the gzip stream completed successfully, look for another */
+    if (ret == Z_STREAM_END)
+        state->how = LOOK;
 
     /* good decompression */
     return 0;
 }
 
-/* Make data and put in the output buffer.  Assumes that state->have == 0.
+/* Fetch data and put it in the output buffer.  Assumes state->x.have is 0.
    Data is either copied from the input file or decompressed from the input
    file depending on state->how.  If state->how is LOOK, then a gzip header is
-   looked for (and skipped if found) to determine wither to copy or decompress.
-   Returns -1 on error, otherwise 0.  gz_make() will leave state->have as COPY
-   or GZIP unless the end of the input file has been reached and all data has
-   been processed.  */
-local int gz_make(state)
+   looked for to determine whether to copy or decompress.  Returns -1 on error,
+   otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the
+   end of the input file has been reached and all data has been processed.  */
+local int gz_fetch(state)
     gz_statep state;
 {
     z_streamp strm = &(state->strm);
 
-    if (state->how == LOOK) {           /* look for gzip header */
-        if (gz_head(state) == -1)
-            return -1;
-        if (state->have)                /* got some data from gz_head() */
+    do {
+        switch(state->how) {
+        case LOOK:      /* -> LOOK, COPY (only if never GZIP), or GZIP */
+            if (gz_look(state) == -1)
+                return -1;
+            if (state->how == LOOK)
+                return 0;
+            break;
+        case COPY:      /* -> COPY */
+            if (gz_load(state, state->out, state->size << 1, &(state->x.have))
+                    == -1)
+                return -1;
+            state->x.next = state->out;
             return 0;
-    }
-    if (state->how == COPY) {           /* straight copy */
-        if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
-            return -1;
-        state->next = state->out;
-    }
-    else if (state->how == GZIP) {      /* decompress */
-        strm->avail_out = state->size << 1;
-        strm->next_out = state->out;
-        if (gz_decomp(state) == -1)
-            return -1;
-    }
+        case GZIP:      /* -> GZIP or LOOK (if end of gzip stream) */
+            strm->avail_out = state->size << 1;
+            strm->next_out = state->out;
+            if (gz_decomp(state) == -1)
+                return -1;
+        }
+    } while (state->x.have == 0 && (!state->eof || strm->avail_in));
     return 0;
 }
 
@@ -342,12 +256,12 @@ local int gz_skip(state, len)
     /* skip over len bytes or reach end-of-file, whichever comes first */
     while (len)
         /* skip over whatever is in output buffer */
-        if (state->have) {
-            n = GT_OFF(state->have) || (z_off64_t)state->have > len ?
-                (unsigned)len : state->have;
-            state->have -= n;
-            state->next += n;
-            state->pos += n;
+        if (state->x.have) {
+            n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
+                (unsigned)len : state->x.have;
+            state->x.have -= n;
+            state->x.next += n;
+            state->x.pos += n;
             len -= n;
         }
 
@@ -358,7 +272,7 @@ local int gz_skip(state, len)
         /* need more data to skip -- load up output buffer */
         else {
             /* get more output, looking for header if required */
-            if (gz_make(state) == -1)
+            if (gz_fetch(state) == -1)
                 return -1;
         }
     return 0;
@@ -380,14 +294,15 @@ int ZEXPORT gzread(file, buf, len)
     state = (gz_statep)file;
     strm = &(state->strm);
 
-    /* check that we're reading and that there's no error */
-    if (state->mode != GZ_READ || state->err != Z_OK)
+    /* check that we're reading and that there's no (serious) error */
+    if (state->mode != GZ_READ ||
+            (state->err != Z_OK && state->err != Z_BUF_ERROR))
         return -1;
 
     /* since an int is returned, make sure len fits in one, otherwise return
        with an error (this avoids the flaw in the interface) */
     if ((int)len < 0) {
-        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
         return -1;
     }
 
@@ -406,22 +321,24 @@ int ZEXPORT gzread(file, buf, len)
     got = 0;
     do {
         /* first just try copying data from the output buffer */
-        if (state->have) {
-            n = state->have > len ? len : state->have;
-            memcpy(buf, state->next, n);
-            state->next += n;
-            state->have -= n;
+        if (state->x.have) {
+            n = state->x.have > len ? len : state->x.have;
+            memcpy(buf, state->x.next, n);
+            state->x.next += n;
+            state->x.have -= n;
         }
 
         /* output buffer empty -- return if we're at the end of the input */
-        else if (state->eof && strm->avail_in == 0)
+        else if (state->eof && strm->avail_in == 0) {
+            state->past = 1;        /* tried to read past end */
             break;
+        }
 
         /* need output data -- for small len or new stream load up our output
            buffer */
         else if (state->how == LOOK || len < (state->size << 1)) {
             /* get more output, looking for header if required */
-            if (gz_make(state) == -1)
+            if (gz_fetch(state) == -1)
                 return -1;
             continue;       /* no progress yet -- go back to memcpy() above */
             /* the copy above assures that we will leave with space in the
@@ -440,15 +357,15 @@ int ZEXPORT gzread(file, buf, len)
             strm->next_out = buf;
             if (gz_decomp(state) == -1)
                 return -1;
-            n = state->have;
-            state->have = 0;
+            n = state->x.have;
+            state->x.have = 0;
         }
 
         /* update progress */
         len -= n;
         buf = (char *)buf + n;
         got += n;
-        state->pos += n;
+        state->x.pos += n;
     } while (len);
 
     /* return number of bytes read into user buffer (will fit in int) */
@@ -456,7 +373,7 @@ int ZEXPORT gzread(file, buf, len)
 }
 
 /* -- see zlib.h -- */
-int ZEXPORT gzgetc(file)
+int ZEXPORT gzgetc_(file)
     gzFile file;
 {
     int ret;
@@ -468,15 +385,16 @@ int ZEXPORT gzgetc(file)
         return -1;
     state = (gz_statep)file;
 
-    /* check that we're reading and that there's no error */
-    if (state->mode != GZ_READ || state->err != Z_OK)
+    /* check that we're reading and that there's no (serious) error */
+    if (state->mode != GZ_READ ||
+        (state->err != Z_OK && state->err != Z_BUF_ERROR))
         return -1;
 
     /* try output buffer (no need to check for skip request) */
-    if (state->have) {
-        state->have--;
-        state->pos++;
-        return *(state->next)++;
+    if (state->x.have) {
+        state->x.have--;
+        state->x.pos++;
+        return *(state->x.next)++;
     }
 
     /* nothing there -- try gzread() */
@@ -484,6 +402,13 @@ int ZEXPORT gzgetc(file)
     return ret < 1 ? -1 : buf[0];
 }
 
+#undef gzgetc
+int ZEXPORT gzgetc(file)
+gzFile file;
+{
+    return gzgetc_(file);
+}    
+
 /* -- see zlib.h -- */
 int ZEXPORT gzungetc(c, file)
     int c;
@@ -496,8 +421,9 @@ int ZEXPORT gzungetc(c, file)
         return -1;
     state = (gz_statep)file;
 
-    /* check that we're reading and that there's no error */
-    if (state->mode != GZ_READ || state->err != Z_OK)
+    /* check that we're reading and that there's no (serious) error */
+    if (state->mode != GZ_READ ||
+        (state->err != Z_OK && state->err != Z_BUF_ERROR))
         return -1;
 
     /* process a skip request */
@@ -512,32 +438,34 @@ int ZEXPORT gzungetc(c, file)
         return -1;
 
     /* if output buffer empty, put byte at end (allows more pushing) */
-    if (state->have == 0) {
-        state->have = 1;
-        state->next = state->out + (state->size << 1) - 1;
-        state->next[0] = c;
-        state->pos--;
+    if (state->x.have == 0) {
+        state->x.have = 1;
+        state->x.next = state->out + (state->size << 1) - 1;
+        state->x.next[0] = c;
+        state->x.pos--;
+        state->past = 0;
         return c;
     }
 
     /* if no room, give up (must have already done a gzungetc()) */
-    if (state->have == (state->size << 1)) {
-        gz_error(state, Z_BUF_ERROR, "out of room to push characters");
+    if (state->x.have == (state->size << 1)) {
+        gz_error(state, Z_DATA_ERROR, "out of room to push characters");
         return -1;
     }
 
     /* slide output data if needed and insert byte before existing data */
-    if (state->next == state->out) {
-        unsigned char *src = state->out + state->have;
+    if (state->x.next == state->out) {
+        unsigned char *src = state->out + state->x.have;
         unsigned char *dest = state->out + (state->size << 1);
         while (src > state->out)
             *--dest = *--src;
-        state->next = dest;
+        state->x.next = dest;
     }
-    state->have++;
-    state->next--;
-    state->next[0] = c;
-    state->pos--;
+    state->x.have++;
+    state->x.next--;
+    state->x.next[0] = c;
+    state->x.pos--;
+    state->past = 0;
     return c;
 }
 
@@ -557,8 +485,9 @@ char * ZEXPORT gzgets(file, buf, len)
         return NULL;
     state = (gz_statep)file;
 
-    /* check that we're reading and that there's no error */
-    if (state->mode != GZ_READ || state->err != Z_OK)
+    /* check that we're reading and that there's no (serious) error */
+    if (state->mode != GZ_READ ||
+        (state->err != Z_OK && state->err != Z_BUF_ERROR))
         return NULL;
 
     /* process a skip request */
@@ -575,32 +504,31 @@ char * ZEXPORT gzgets(file, buf, len)
     left = (unsigned)len - 1;
     if (left) do {
         /* assure that something is in the output buffer */
-        if (state->have == 0) {
-            if (gz_make(state) == -1)
-                return NULL;            /* error */
-            if (state->have == 0) {     /* end of file */
-                if (buf == str)         /* got bupkus */
-                    return NULL;
-                break;                  /* got something -- return it */
-            }
+        if (state->x.have == 0 && gz_fetch(state) == -1)
+            return NULL;                /* error */
+        if (state->x.have == 0) {       /* end of file */
+            state->past = 1;            /* read past end */
+            break;                      /* return what we have */
         }
 
         /* look for end-of-line in current output buffer */
-        n = state->have > left ? left : state->have;
-        eol = memchr(state->next, '\n', n);
+        n = state->x.have > left ? left : state->x.have;
+        eol = memchr(state->x.next, '\n', n);
         if (eol != NULL)
-            n = (unsigned)(eol - state->next) + 1;
+            n = (unsigned)(eol - state->x.next) + 1;
 
         /* copy through end-of-line, or remainder if not found */
-        memcpy(buf, state->next, n);
-        state->have -= n;
-        state->next += n;
-        state->pos += n;
+        memcpy(buf, state->x.next, n);
+        state->x.have -= n;
+        state->x.next += n;
+        state->x.pos += n;
         left -= n;
         buf += n;
     } while (left && eol == NULL);
 
-    /* found end-of-line or out of space -- terminate string and return it */
+    /* return terminated string, or if nothing, end of file */
+    if (buf == str)
+        return NULL;
     buf[0] = 0;
     return str;
 }
@@ -616,16 +544,12 @@ int ZEXPORT gzdirect(file)
         return 0;
     state = (gz_statep)file;
 
-    /* check that we're reading */
-    if (state->mode != GZ_READ)
-        return 0;
-
     /* if the state is not known, but we can find out, then do so (this is
        mainly for right after a gzopen() or gzdopen()) */
-    if (state->how == LOOK && state->have == 0)
-        (void)gz_head(state);
+    if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
+        (void)gz_look(state);
 
-    /* return 1 if reading direct, 0 if decompressing a gzip stream */
+    /* return 1 if transparent, 0 if processing a gzip stream */
     return state->direct;
 }
 
@@ -633,7 +557,7 @@ int ZEXPORT gzdirect(file)
 int ZEXPORT gzclose_r(file)
     gzFile file;
 {
-    int ret;
+    int ret, err;
     gz_statep state;
 
     /* get internal structure */
@@ -651,9 +575,10 @@ int ZEXPORT gzclose_r(file)
         free(state->out);
         free(state->in);
     }
+    err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK;
     gz_error(state, Z_OK, NULL);
     free(state->path);
     ret = close(state->fd);
     free(state);
-    return ret ? Z_ERRNO : Z_OK;
+    return ret ? Z_ERRNO : err;
 }
index e8defc6887a186055f17597968c4fc5791332811..caa35b61ad9d834fe5a7a0b66cc23b4a5f4e386a 100644 (file)
@@ -1,5 +1,5 @@
 /* gzwrite.c -- zlib functions for writing gzip files
- * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -18,44 +18,55 @@ local int gz_init(state)
     int ret;
     z_streamp strm = &(state->strm);
 
-    /* allocate input and output buffers */
+    /* allocate input buffer */
     state->in = malloc(state->want);
-    state->out = malloc(state->want);
-    if (state->in == NULL || state->out == NULL) {
-        if (state->out != NULL)
-            free(state->out);
-        if (state->in != NULL)
-            free(state->in);
+    if (state->in == NULL) {
         gz_error(state, Z_MEM_ERROR, "out of memory");
         return -1;
     }
 
-    /* allocate deflate memory, set up for gzip compression */
-    strm->zalloc = Z_NULL;
-    strm->zfree = Z_NULL;
-    strm->opaque = Z_NULL;
-    ret = deflateInit2(strm, state->level, Z_DEFLATED,
-                       15 + 16, 8, state->strategy);
-    if (ret != Z_OK) {
-        free(state->in);
-        gz_error(state, Z_MEM_ERROR, "out of memory");
-        return -1;
+    /* only need output buffer and deflate state if compressing */
+    if (!state->direct) {
+        /* allocate output buffer */
+        state->out = malloc(state->want);
+        if (state->out == NULL) {
+            free(state->in);
+            gz_error(state, Z_MEM_ERROR, "out of memory");
+            return -1;
+        }
+
+        /* allocate deflate memory, set up for gzip compression */
+        strm->zalloc = Z_NULL;
+        strm->zfree = Z_NULL;
+        strm->opaque = Z_NULL;
+        ret = deflateInit2(strm, state->level, Z_DEFLATED,
+                           MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
+        if (ret != Z_OK) {
+            free(state->out);
+            free(state->in);
+            gz_error(state, Z_MEM_ERROR, "out of memory");
+            return -1;
+        }
     }
 
     /* mark state as initialized */
     state->size = state->want;
 
-    /* initialize write buffer */
-    strm->avail_out = state->size;
-    strm->next_out = state->out;
-    state->next = strm->next_out;
+    /* initialize write buffer if compressing */
+    if (!state->direct) {
+        strm->avail_out = state->size;
+        strm->next_out = state->out;
+        state->x.next = strm->next_out;
+    }
     return 0;
 }
 
 /* Compress whatever is at avail_in and next_in and write to the output file.
    Return -1 if there is an error writing to the output file, otherwise 0.
    flush is assumed to be a valid deflate() flush value.  If flush is Z_FINISH,
-   then the deflate() state is reset to start a new gzip stream. */
+   then the deflate() state is reset to start a new gzip stream.  If gz->direct
+   is true, then simply write to the output file without compressing, and
+   ignore flush. */
 local int gz_comp(state, flush)
     gz_statep state;
     int flush;
@@ -68,6 +79,17 @@ local int gz_comp(state, flush)
     if (state->size == 0 && gz_init(state) == -1)
         return -1;
 
+    /* write directly if requested */
+    if (state->direct) {
+        got = write(state->fd, strm->next_in, strm->avail_in);
+        if (got < 0 || (unsigned)got != strm->avail_in) {
+            gz_error(state, Z_ERRNO, zstrerror());
+            return -1;
+        }
+        strm->avail_in = 0;
+        return 0;
+    }
+
     /* run deflate() on provided input until it produces no more output */
     ret = Z_OK;
     do {
@@ -75,8 +97,8 @@ local int gz_comp(state, flush)
            doing Z_FINISH then don't write until we get to Z_STREAM_END */
         if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
             (flush != Z_FINISH || ret == Z_STREAM_END))) {
-            have = (unsigned)(strm->next_out - state->next);
-            if (have && ((got = write(state->fd, state->next, have)) < 0 ||
+            have = (unsigned)(strm->next_out - state->x.next);
+            if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
                          (unsigned)got != have)) {
                 gz_error(state, Z_ERRNO, zstrerror());
                 return -1;
@@ -85,7 +107,7 @@ local int gz_comp(state, flush)
                 strm->avail_out = state->size;
                 strm->next_out = state->out;
             }
-            state->next = strm->next_out;
+            state->x.next = strm->next_out;
         }
 
         /* compress */
@@ -131,7 +153,7 @@ local int gz_zero(state, len)
         }
         strm->avail_in = n;
         strm->next_in = state->in;
-        state->pos += n;
+        state->x.pos += n;
         if (gz_comp(state, Z_NO_FLUSH) == -1)
             return -1;
         len -= n;
@@ -163,7 +185,7 @@ int ZEXPORT gzwrite(file, buf, len)
     /* since an int is returned, make sure len fits in one, otherwise return
        with an error (this avoids the flaw in the interface) */
     if ((int)len < 0) {
-        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+        gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
         return 0;
     }
 
@@ -193,7 +215,7 @@ int ZEXPORT gzwrite(file, buf, len)
                 n = len;
             memcpy(strm->next_in + strm->avail_in, buf, n);
             strm->avail_in += n;
-            state->pos += n;
+            state->x.pos += n;
             buf = (char *)buf + n;
             len -= n;
             if (len && gz_comp(state, Z_NO_FLUSH) == -1)
@@ -208,7 +230,7 @@ int ZEXPORT gzwrite(file, buf, len)
         /* directly compress user buffer to file */
         strm->avail_in = len;
         strm->next_in = (voidp)buf;
-        state->pos += len;
+        state->x.pos += len;
         if (gz_comp(state, Z_NO_FLUSH) == -1)
             return 0;
     }
@@ -249,15 +271,15 @@ int ZEXPORT gzputc(file, c)
         if (strm->avail_in == 0)
             strm->next_in = state->in;
         strm->next_in[strm->avail_in++] = c;
-        state->pos++;
-        return c;
+        state->x.pos++;
+        return c & 0xff;
     }
 
     /* no room in buffer or not initialized, use gz_write() */
     buf[0] = c;
     if (gzwrite(file, buf, 1) != 1)
         return -1;
-    return c;
+    return c & 0xff;
 }
 
 /* -- see zlib.h -- */
@@ -274,7 +296,7 @@ int ZEXPORT gzputs(file, str)
     return ret == 0 && len != 0 ? -1 : ret;
 }
 
-#ifdef STDC
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
 #include <stdarg.h>
 
 /* -- see zlib.h -- */
@@ -342,11 +364,11 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
     /* update buffer and position, defer compression until needed */
     strm->avail_in = (unsigned)len;
     strm->next_in = state->in;
-    state->pos += len;
+    state->x.pos += len;
     return len;
 }
 
-#else /* !STDC */
+#else /* !STDC && !Z_HAVE_STDARG_H */
 
 /* -- see zlib.h -- */
 int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
@@ -366,6 +388,10 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
     state = (gz_statep)file;
     strm = &(state->strm);
 
+    /* check that can really pass pointer in ints */
+    if (sizeof(int) != sizeof(void *))
+        return 0;
+
     /* check that we're writing and that there's no error */
     if (state->mode != GZ_WRITE || state->err != Z_OK)
         return 0;
@@ -416,7 +442,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
     /* update buffer and position, defer compression until needed */
     strm->avail_in = (unsigned)len;
     strm->next_in = state->in;
-    state->pos += len;
+    state->x.pos += len;
     return len;
 }
 
@@ -500,7 +526,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
 int ZEXPORT gzclose_w(file)
     gzFile file;
 {
-    int ret = 0;
+    int ret = Z_OK;
     gz_statep state;
 
     /* get internal structure */
@@ -515,17 +541,53 @@ int ZEXPORT gzclose_w(file)
     /* check for seek request */
     if (state->seek) {
         state->seek = 0;
-        ret += gz_zero(state, state->skip);
+        if (gz_zero(state, state->skip) == -1)
+            ret = state->err;
     }
 
     /* flush, free memory, and close file */
-    ret += gz_comp(state, Z_FINISH);
-    (void)deflateEnd(&(state->strm));
-    free(state->out);
+    if (gz_comp(state, Z_FINISH) == -1)
+        ret = state->err;
+    if (!state->direct) {
+        (void)deflateEnd(&(state->strm));
+        free(state->out);
+    }
     free(state->in);
     gz_error(state, Z_OK, NULL);
     free(state->path);
-    ret += close(state->fd);
+    if (close(state->fd) == -1)
+        ret = Z_ERRNO;
     free(state);
-    return ret ? Z_ERRNO : Z_OK;
+    return ret;
+}
+
+/* used by zlibVersion() to get the vsnprintf story from the horse's mouth */
+unsigned long ZEXPORT gzflags()
+{
+    unsigned long flags = 0;
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+#  ifdef NO_vsnprintf
+    flags += 1L << 25;
+#    ifdef HAS_vsprintf_void
+    flags += 1L << 26;
+#    endif
+#  else
+#    ifdef HAS_vsnprintf_void
+    flags += 1L << 26;
+#    endif
+#  endif
+#else
+    flags += 1L << 24;
+#  ifdef NO_snprintf
+    flags += 1L << 25;
+#    ifdef HAS_sprintf_void
+    flags += 1L << 26;
+#    endif
+#  else
+#    ifdef HAS_snprintf_void
+    flags += 1L << 26;
+#    endif
+#  endif
+#endif
+    return flags;
 }
index af3a8c965d50cc6ac05c6c844a8f79e2cdc9f3c1..981aff17c2d4ab0f157e503219e4ca9bd68eaf3a 100644 (file)
@@ -1,5 +1,5 @@
 /* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2009 Mark Adler
+ * Copyright (C) 1995-2011 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -42,10 +42,19 @@ int stream_size;
         return Z_STREAM_ERROR;
     strm->msg = Z_NULL;                 /* in case we return an error */
     if (strm->zalloc == (alloc_func)0) {
+#ifdef Z_SOLO
+        return Z_STREAM_ERROR;
+#else
         strm->zalloc = zcalloc;
         strm->opaque = (voidpf)0;
+#endif
     }
-    if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+    if (strm->zfree == (free_func)0)
+#ifdef Z_SOLO
+        return Z_STREAM_ERROR;
+#else
+    strm->zfree = zcfree;
+#endif
     state = (struct inflate_state FAR *)ZALLOC(strm, 1,
                                                sizeof(struct inflate_state));
     if (state == Z_NULL) return Z_MEM_ERROR;
@@ -394,7 +403,6 @@ void FAR *out_desc;
                     PULLBYTE();
                 }
                 if (here.val < 16) {
-                    NEEDBITS(here.bits);
                     DROPBITS(here.bits);
                     state->lens[state->have++] = here.val;
                 }
index 75ed4b5978de4be3c44ad48a060b75500f17a0a2..d6283277694802ce7938f537f12990d6eead4924 100644 (file)
@@ -2,9 +2,9 @@
      * Generated automatically by makefixed().
      */
 
-    /* WARNING: this file should *not* be used by applications. It
-       is part of the implementation of the compression library and
-       is subject to change. Applications should only use zlib.h.
+    /* WARNING: this file should *not* be used by applications.
+       It is part of the implementation of this library and is
+       subject to change. Applications should only use zlib.h.
      */
 
     static const code lenfix[512] = {
index a8431abeacffd97e5028a9e54135a5f173528960..cc89517bc893a59bcc3cc4b5d30e18955961d399 100644 (file)
@@ -1,5 +1,5 @@
 /* inflate.c -- zlib decompression
- * Copyright (C) 1995-2010 Mark Adler
+ * Copyright (C) 1995-2011 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -100,7 +100,7 @@ local int updatewindow OF((z_streamp strm, unsigned out));
 local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
                               unsigned len));
 
-int ZEXPORT inflateReset(strm)
+int ZEXPORT inflateResetKeep(strm)
 z_streamp strm;
 {
     struct inflate_state FAR *state;
@@ -109,15 +109,13 @@ z_streamp strm;
     state = (struct inflate_state FAR *)strm->state;
     strm->total_in = strm->total_out = state->total = 0;
     strm->msg = Z_NULL;
-    strm->adler = 1;        /* to support ill-conceived Java test suite */
+    if (state->wrap)        /* to support ill-conceived Java test suite */
+        strm->adler = state->wrap & 1;
     state->mode = HEAD;
     state->last = 0;
     state->havedict = 0;
     state->dmax = 32768U;
     state->head = Z_NULL;
-    state->wsize = 0;
-    state->whave = 0;
-    state->wnext = 0;
     state->hold = 0;
     state->bits = 0;
     state->lencode = state->distcode = state->next = state->codes;
@@ -127,6 +125,19 @@ z_streamp strm;
     return Z_OK;
 }
 
+int ZEXPORT inflateReset(strm)
+z_streamp strm;
+{
+    struct inflate_state FAR *state;
+
+    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    state = (struct inflate_state FAR *)strm->state;
+    state->wsize = 0;
+    state->whave = 0;
+    state->wnext = 0;
+    return inflateResetKeep(strm);
+}
+
 int ZEXPORT inflateReset2(strm, windowBits)
 z_streamp strm;
 int windowBits;
@@ -180,10 +191,19 @@ int stream_size;
     if (strm == Z_NULL) return Z_STREAM_ERROR;
     strm->msg = Z_NULL;                 /* in case we return an error */
     if (strm->zalloc == (alloc_func)0) {
+#ifdef Z_SOLO
+        return Z_STREAM_ERROR;
+#else
         strm->zalloc = zcalloc;
         strm->opaque = (voidpf)0;
+#endif
     }
-    if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+    if (strm->zfree == (free_func)0)
+#ifdef Z_SOLO
+        return Z_STREAM_ERROR;
+#else
+        strm->zfree = zcfree;
+#endif
     state = (struct inflate_state FAR *)
             ZALLOC(strm, 1, sizeof(struct inflate_state));
     if (state == Z_NULL) return Z_MEM_ERROR;
@@ -321,8 +341,8 @@ void makefixed()
     low = 0;
     for (;;) {
         if ((low % 7) == 0) printf("\n        ");
-        printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
-               state.lencode[low].val);
+        printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
+               state.lencode[low].bits, state.lencode[low].val);
         if (++low == size) break;
         putchar(',');
     }
@@ -925,7 +945,6 @@ int flush;
                     PULLBYTE();
                 }
                 if (here.val < 16) {
-                    NEEDBITS(here.bits);
                     DROPBITS(here.bits);
                     state->lens[state->have++] = here.val;
                 }
@@ -1214,7 +1233,8 @@ int flush;
      */
   inf_leave:
     RESTORE();
-    if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
+    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
+            (state->mode < CHECK || flush != Z_FINISH)))
         if (updatewindow(strm, out)) {
             state->mode = MEM;
             return Z_MEM_ERROR;
@@ -1256,6 +1276,9 @@ uInt dictLength;
 {
     struct inflate_state FAR *state;
     unsigned long id;
+    unsigned char *next;
+    unsigned avail;
+    int ret;
 
     /* check state */
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
@@ -1271,21 +1294,19 @@ uInt dictLength;
             return Z_DATA_ERROR;
     }
 
-    /* copy dictionary to window */
-    if (updatewindow(strm, strm->avail_out)) {
+    /* copy dictionary to window using updatewindow(), which will amend the
+       existing dictionary if appropriate */
+    next = strm->next_out;
+    avail = strm->avail_out;
+    strm->next_out = (Bytef *)dictionary + dictLength;
+    strm->avail_out = 0;
+    ret = updatewindow(strm, dictLength);
+    strm->avail_out = avail;
+    strm->next_out = next;
+    if (ret) {
         state->mode = MEM;
         return Z_MEM_ERROR;
     }
-    if (dictLength > state->wsize) {
-        zmemcpy(state->window, dictionary + dictLength - state->wsize,
-                state->wsize);
-        state->whave = state->wsize;
-    }
-    else {
-        zmemcpy(state->window + state->wsize - dictLength, dictionary,
-                dictLength);
-        state->whave = dictLength;
-    }
     state->havedict = 1;
     Tracev((stderr, "inflate:   dictionary set\n"));
     return Z_OK;
@@ -1433,8 +1454,8 @@ z_streamp source;
     }
 
     /* copy state */
-    zmemcpy(dest, source, sizeof(z_stream));
-    zmemcpy(copy, state, sizeof(struct inflate_state));
+    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
+    zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
     if (state->lencode >= state->codes &&
         state->lencode <= state->codes + ENOUGH - 1) {
         copy->lencode = copy->codes + (state->lencode - state->codes);
index 11e9c52accbe8e2cf4e502f88ce89ccfa4f992e5..60bbd58bfb0dba8b66b138363f307bef3c06e427 100644 (file)
@@ -1,5 +1,5 @@
 /* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2010 Mark Adler
+ * Copyright (C) 1995-2012 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -9,7 +9,7 @@
 #define MAXBITS 15
 
 const char inflate_copyright[] =
-   " inflate 1.2.5 Copyright 1995-2010 Mark Adler ";
+   " inflate 1.2.6 Copyright 1995-2012 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -62,7 +62,7 @@ unsigned short FAR *work;
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
     static const unsigned short lext[31] = { /* Length codes 257..285 extra */
         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
-        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
+        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 69};
     static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -289,38 +289,14 @@ unsigned short FAR *work;
         }
     }
 
-    /*
-       Fill in rest of table for incomplete codes.  This loop is similar to the
-       loop above in incrementing huff for table indices.  It is assumed that
-       len is equal to curr + drop, so there is no loop needed to increment
-       through high index bits.  When the current sub-table is filled, the loop
-       drops back to the root table to fill in any remaining entries there.
-     */
-    here.op = (unsigned char)64;                /* invalid code marker */
-    here.bits = (unsigned char)(len - drop);
-    here.val = (unsigned short)0;
-    while (huff != 0) {
-        /* when done with sub-table, drop back to root table */
-        if (drop != 0 && (huff & mask) != low) {
-            drop = 0;
-            len = root;
-            next = *table;
-            here.bits = (unsigned char)len;
-        }
-
-        /* put invalid code marker in table */
-        next[huff >> drop] = here;
-
-        /* backwards increment the len-bit code huff */
-        incr = 1U << (len - 1);
-        while (huff & incr)
-            incr >>= 1;
-        if (incr != 0) {
-            huff &= incr - 1;
-            huff += incr;
-        }
-        else
-            huff = 0;
+    /* fill in remaining table entry if code is incomplete (guaranteed to have
+       at most one remaining entry, since if the code is incomplete, the
+       maximum code length that was allowed to get this far is one bit) */
+    if (huff != 0) {
+        here.op = (unsigned char)64;            /* invalid code marker */
+        here.bits = (unsigned char)(len - drop);
+        here.val = (unsigned short)0;
+        next[huff] = here;
     }
 
     /* set return parameters */
diff --git a/thirdparty/zlib/minigzip.c b/thirdparty/zlib/minigzip.c
deleted file mode 100644 (file)
index 9825ccc..0000000
+++ /dev/null
@@ -1,440 +0,0 @@
-/* minigzip.c -- simulate gzip using the zlib compression library
- * Copyright (C) 1995-2006, 2010 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * minigzip is a minimal implementation of the gzip utility. This is
- * only an example of using zlib and isn't meant to replace the
- * full-featured gzip. No attempt is made to deal with file systems
- * limiting names to 14 or 8+3 characters, etc... Error checking is
- * very limited. So use minigzip only for testing; use gzip for the
- * real thing. On MSDOS, use only on file names without extension
- * or in pipe mode.
- */
-
-/* @(#) $Id$ */
-
-#include "zlib.h"
-#include <stdio.h>
-
-#ifdef STDC
-#  include <string.h>
-#  include <stdlib.h>
-#endif
-
-#ifdef USE_MMAP
-#  include <sys/types.h>
-#  include <sys/mman.h>
-#  include <sys/stat.h>
-#endif
-
-#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
-#  include <fcntl.h>
-#  include <io.h>
-#  ifdef UNDER_CE
-#    include <stdlib.h>
-#  endif
-#  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
-#else
-#  define SET_BINARY_MODE(file)
-#endif
-
-#ifdef VMS
-#  define unlink delete
-#  define GZ_SUFFIX "-gz"
-#endif
-#ifdef RISCOS
-#  define unlink remove
-#  define GZ_SUFFIX "-gz"
-#  define fileno(file) file->__file
-#endif
-#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-#  include <unix.h> /* for fileno */
-#endif
-
-#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
-#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
-  extern int unlink OF((const char *));
-#endif
-#endif
-
-#if defined(UNDER_CE)
-#  include <windows.h>
-#  define perror(s) pwinerror(s)
-
-/* Map the Windows error number in ERROR to a locale-dependent error
-   message string and return a pointer to it.  Typically, the values
-   for ERROR come from GetLastError.
-
-   The string pointed to shall not be modified by the application,
-   but may be overwritten by a subsequent call to strwinerror
-
-   The strwinerror function does not change the current setting
-   of GetLastError.  */
-
-static char *strwinerror (error)
-     DWORD error;
-{
-    static char buf[1024];
-
-    wchar_t *msgbuf;
-    DWORD lasterr = GetLastError();
-    DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
-        | FORMAT_MESSAGE_ALLOCATE_BUFFER,
-        NULL,
-        error,
-        0, /* Default language */
-        (LPVOID)&msgbuf,
-        0,
-        NULL);
-    if (chars != 0) {
-        /* If there is an \r\n appended, zap it.  */
-        if (chars >= 2
-            && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
-            chars -= 2;
-            msgbuf[chars] = 0;
-        }
-
-        if (chars > sizeof (buf) - 1) {
-            chars = sizeof (buf) - 1;
-            msgbuf[chars] = 0;
-        }
-
-        wcstombs(buf, msgbuf, chars + 1);
-        LocalFree(msgbuf);
-    }
-    else {
-        sprintf(buf, "unknown win32 error (%ld)", error);
-    }
-
-    SetLastError(lasterr);
-    return buf;
-}
-
-static void pwinerror (s)
-    const char *s;
-{
-    if (s && *s)
-        fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ()));
-    else
-        fprintf(stderr, "%s\n", strwinerror(GetLastError ()));
-}
-
-#endif /* UNDER_CE */
-
-#ifndef GZ_SUFFIX
-#  define GZ_SUFFIX ".gz"
-#endif
-#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
-
-#define BUFLEN      16384
-#define MAX_NAME_LEN 1024
-
-#ifdef MAXSEG_64K
-#  define local static
-   /* Needed for systems with limitation on stack size. */
-#else
-#  define local
-#endif
-
-char *prog;
-
-void error            OF((const char *msg));
-void gz_compress      OF((FILE   *in, gzFile out));
-#ifdef USE_MMAP
-int  gz_compress_mmap OF((FILE   *in, gzFile out));
-#endif
-void gz_uncompress    OF((gzFile in, FILE   *out));
-void file_compress    OF((char  *file, char *mode));
-void file_uncompress  OF((char  *file));
-int  main             OF((int argc, char *argv[]));
-
-/* ===========================================================================
- * Display error message and exit
- */
-void error(msg)
-    const char *msg;
-{
-    fprintf(stderr, "%s: %s\n", prog, msg);
-    exit(1);
-}
-
-/* ===========================================================================
- * Compress input to output then close both files.
- */
-
-void gz_compress(in, out)
-    FILE   *in;
-    gzFile out;
-{
-    local char buf[BUFLEN];
-    int len;
-    int err;
-
-#ifdef USE_MMAP
-    /* Try first compressing with mmap. If mmap fails (minigzip used in a
-     * pipe), use the normal fread loop.
-     */
-    if (gz_compress_mmap(in, out) == Z_OK) return;
-#endif
-    for (;;) {
-        len = (int)fread(buf, 1, sizeof(buf), in);
-        if (ferror(in)) {
-            perror("fread");
-            exit(1);
-        }
-        if (len == 0) break;
-
-        if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
-    }
-    fclose(in);
-    if (gzclose(out) != Z_OK) error("failed gzclose");
-}
-
-#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
-
-/* Try compressing the input file at once using mmap. Return Z_OK if
- * if success, Z_ERRNO otherwise.
- */
-int gz_compress_mmap(in, out)
-    FILE   *in;
-    gzFile out;
-{
-    int len;
-    int err;
-    int ifd = fileno(in);
-    caddr_t buf;    /* mmap'ed buffer for the entire input file */
-    off_t buf_len;  /* length of the input file */
-    struct stat sb;
-
-    /* Determine the size of the file, needed for mmap: */
-    if (fstat(ifd, &sb) < 0) return Z_ERRNO;
-    buf_len = sb.st_size;
-    if (buf_len <= 0) return Z_ERRNO;
-
-    /* Now do the actual mmap: */
-    buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
-    if (buf == (caddr_t)(-1)) return Z_ERRNO;
-
-    /* Compress the whole file at once: */
-    len = gzwrite(out, (char *)buf, (unsigned)buf_len);
-
-    if (len != (int)buf_len) error(gzerror(out, &err));
-
-    munmap(buf, buf_len);
-    fclose(in);
-    if (gzclose(out) != Z_OK) error("failed gzclose");
-    return Z_OK;
-}
-#endif /* USE_MMAP */
-
-/* ===========================================================================
- * Uncompress input to output then close both files.
- */
-void gz_uncompress(in, out)
-    gzFile in;
-    FILE   *out;
-{
-    local char buf[BUFLEN];
-    int len;
-    int err;
-
-    for (;;) {
-        len = gzread(in, buf, sizeof(buf));
-        if (len < 0) error (gzerror(in, &err));
-        if (len == 0) break;
-
-        if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
-            error("failed fwrite");
-        }
-    }
-    if (fclose(out)) error("failed fclose");
-
-    if (gzclose(in) != Z_OK) error("failed gzclose");
-}
-
-
-/* ===========================================================================
- * Compress the given file: create a corresponding .gz file and remove the
- * original.
- */
-void file_compress(file, mode)
-    char  *file;
-    char  *mode;
-{
-    local char outfile[MAX_NAME_LEN];
-    FILE  *in;
-    gzFile out;
-
-    if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) {
-        fprintf(stderr, "%s: filename too long\n", prog);
-        exit(1);
-    }
-
-    strcpy(outfile, file);
-    strcat(outfile, GZ_SUFFIX);
-
-    in = fopen(file, "rb");
-    if (in == NULL) {
-        perror(file);
-        exit(1);
-    }
-    out = gzopen(outfile, mode);
-    if (out == NULL) {
-        fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
-        exit(1);
-    }
-    gz_compress(in, out);
-
-    unlink(file);
-}
-
-
-/* ===========================================================================
- * Uncompress the given file and remove the original.
- */
-void file_uncompress(file)
-    char  *file;
-{
-    local char buf[MAX_NAME_LEN];
-    char *infile, *outfile;
-    FILE  *out;
-    gzFile in;
-    size_t len = strlen(file);
-
-    if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) {
-        fprintf(stderr, "%s: filename too long\n", prog);
-        exit(1);
-    }
-
-    strcpy(buf, file);
-
-    if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
-        infile = file;
-        outfile = buf;
-        outfile[len-3] = '\0';
-    } else {
-        outfile = file;
-        infile = buf;
-        strcat(infile, GZ_SUFFIX);
-    }
-    in = gzopen(infile, "rb");
-    if (in == NULL) {
-        fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
-        exit(1);
-    }
-    out = fopen(outfile, "wb");
-    if (out == NULL) {
-        perror(file);
-        exit(1);
-    }
-
-    gz_uncompress(in, out);
-
-    unlink(infile);
-}
-
-
-/* ===========================================================================
- * Usage:  minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...]
- *   -c : write to standard output
- *   -d : decompress
- *   -f : compress with Z_FILTERED
- *   -h : compress with Z_HUFFMAN_ONLY
- *   -r : compress with Z_RLE
- *   -1 to -9 : compression level
- */
-
-int main(argc, argv)
-    int argc;
-    char *argv[];
-{
-    int copyout = 0;
-    int uncompr = 0;
-    gzFile file;
-    char *bname, outmode[20];
-
-    strcpy(outmode, "wb6 ");
-
-    prog = argv[0];
-    bname = strrchr(argv[0], '/');
-    if (bname)
-      bname++;
-    else
-      bname = argv[0];
-    argc--, argv++;
-
-    if (!strcmp(bname, "gunzip"))
-      uncompr = 1;
-    else if (!strcmp(bname, "zcat"))
-      copyout = uncompr = 1;
-
-    while (argc > 0) {
-      if (strcmp(*argv, "-c") == 0)
-        copyout = 1;
-      else if (strcmp(*argv, "-d") == 0)
-        uncompr = 1;
-      else if (strcmp(*argv, "-f") == 0)
-        outmode[3] = 'f';
-      else if (strcmp(*argv, "-h") == 0)
-        outmode[3] = 'h';
-      else if (strcmp(*argv, "-r") == 0)
-        outmode[3] = 'R';
-      else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
-               (*argv)[2] == 0)
-        outmode[2] = (*argv)[1];
-      else
-        break;
-      argc--, argv++;
-    }
-    if (outmode[3] == ' ')
-        outmode[3] = 0;
-    if (argc == 0) {
-        SET_BINARY_MODE(stdin);
-        SET_BINARY_MODE(stdout);
-        if (uncompr) {
-            file = gzdopen(fileno(stdin), "rb");
-            if (file == NULL) error("can't gzdopen stdin");
-            gz_uncompress(file, stdout);
-        } else {
-            file = gzdopen(fileno(stdout), outmode);
-            if (file == NULL) error("can't gzdopen stdout");
-            gz_compress(stdin, file);
-        }
-    } else {
-        if (copyout) {
-            SET_BINARY_MODE(stdout);
-        }
-        do {
-            if (uncompr) {
-                if (copyout) {
-                    file = gzopen(*argv, "rb");
-                    if (file == NULL)
-                        fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
-                    else
-                        gz_uncompress(file, stdout);
-                } else {
-                    file_uncompress(*argv);
-                }
-            } else {
-                if (copyout) {
-                    FILE * in = fopen(*argv, "rb");
-
-                    if (in == NULL) {
-                        perror(*argv);
-                    } else {
-                        file = gzdopen(fileno(stdout), outmode);
-                        if (file == NULL) error("can't gzdopen stdout");
-
-                        gz_compress(in, file);
-                    }
-
-                } else {
-                    file_compress(*argv, outmode);
-                }
-            }
-        } while (argv++, --argc);
-    }
-    return 0;
-}
index 56e9bb1c115e81082f58a89b003b766760e12a12..8c32b214b1d496690964ac2a297f2db419a4bce4 100644 (file)
@@ -1,5 +1,5 @@
 /* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2010 Jean-loup Gailly
+ * Copyright (C) 1995-2012 Jean-loup Gailly
  * detect_data_type() function provided freely by Cosmin Truta, 2006
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
@@ -74,11 +74,6 @@ local const uch bl_order[BL_CODES]
  * probability, to avoid transmitting the lengths for unused bit length codes.
  */
 
-#define Buf_size (8 * 2*sizeof(char))
-/* Number of bits used within bi_buf. (bi_buf might be implemented on
- * more than 16 bits on some systems.)
- */
-
 /* ===========================================================================
  * Local data. These are initialized only once.
  */
@@ -399,7 +394,6 @@ void ZLIB_INTERNAL _tr_init(s)
 
     s->bi_buf = 0;
     s->bi_valid = 0;
-    s->last_eob_len = 8; /* enough lookahead for inflate */
 #ifdef DEBUG
     s->compressed_len = 0L;
     s->bits_sent = 0L;
@@ -882,16 +876,18 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
     copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
 }
 
+/* ===========================================================================
+ * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
+ */
+void ZLIB_INTERNAL _tr_flush_bits(s)
+    deflate_state *s;
+{
+    bi_flush(s);
+}
+
 /* ===========================================================================
  * Send one empty static block to give enough lookahead for inflate.
  * This takes 10 bits, of which 7 may remain in the bit buffer.
- * The current inflate code requires 9 bits of lookahead. If the
- * last two codes for the previous block (real code plus EOB) were coded
- * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
- * the last real code. In this case we send two empty static blocks instead
- * of one. (There are no problems if the previous block is stored or fixed.)
- * To simplify the code, we assume the worst case of last real code encoded
- * on one bit only.
  */
 void ZLIB_INTERNAL _tr_align(s)
     deflate_state *s;
@@ -902,20 +898,6 @@ void ZLIB_INTERNAL _tr_align(s)
     s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
 #endif
     bi_flush(s);
-    /* Of the 10 bits for the empty block, we have already sent
-     * (10 - bi_valid) bits. The lookahead for the last real code (before
-     * the EOB of the previous block) was thus at least one plus the length
-     * of the EOB plus what we have just sent of the empty static block.
-     */
-    if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
-        send_bits(s, STATIC_TREES<<1, 3);
-        send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
-        s->compressed_len += 10L;
-#endif
-        bi_flush(s);
-    }
-    s->last_eob_len = 7;
 }
 
 /* ===========================================================================
@@ -1118,7 +1100,6 @@ local void compress_block(s, ltree, dtree)
     } while (lx < s->last_lit);
 
     send_code(s, END_BLOCK, ltree);
-    s->last_eob_len = ltree[END_BLOCK].Len;
 }
 
 /* ===========================================================================
@@ -1226,7 +1207,6 @@ local void copy_block(s, buf, len, header)
     int      header;  /* true if block header must be written */
 {
     bi_windup(s);        /* align on byte boundary */
-    s->last_eob_len = 8; /* enough lookahead for inflate */
 
     if (header) {
         put_short(s, (ush)len);
index ced649e20263def778815c81f997390be20ba205..51c80ac144306f547ae7d10a02f9dc41d67572a0 100644 (file)
@@ -1,5 +1,5 @@
 /* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2010 Jean-loup Gailly.
+ * Copyright (C) 1995-2011 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -15,6 +15,7 @@
  * this permanently in zconf.h using "./configure --zprefix".
  */
 #ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
+#  define Z_PREFIX_SET
 
 /* all linked symbols */
 #  define _dist_code            z__dist_code
 #  define adler32               z_adler32
 #  define adler32_combine       z_adler32_combine
 #  define adler32_combine64     z_adler32_combine64
-#  define compress              z_compress
-#  define compress2             z_compress2
-#  define compressBound         z_compressBound
+#  ifndef Z_SOLO
+#    define compress              z_compress
+#    define compress2             z_compress2
+#    define compressBound         z_compressBound
+#  endif
 #  define crc32                 z_crc32
 #  define crc32_combine         z_crc32_combine
 #  define crc32_combine64       z_crc32_combine64
 #  define deflateInit2_         z_deflateInit2_
 #  define deflateInit_          z_deflateInit_
 #  define deflateParams         z_deflateParams
+#  define deflatePending        z_deflatePending
 #  define deflatePrime          z_deflatePrime
 #  define deflateReset          z_deflateReset
+#  define deflateResetKeep      z_deflateResetKeep
 #  define deflateSetDictionary  z_deflateSetDictionary
 #  define deflateSetHeader      z_deflateSetHeader
 #  define deflateTune           z_deflateTune
 #  define deflate_copyright     z_deflate_copyright
 #  define get_crc_table         z_get_crc_table
-#  define gz_error              z_gz_error
-#  define gz_intmax             z_gz_intmax
-#  define gz_strwinerror        z_gz_strwinerror
-#  define gzbuffer              z_gzbuffer
-#  define gzclearerr            z_gzclearerr
-#  define gzclose               z_gzclose
-#  define gzclose_r             z_gzclose_r
-#  define gzclose_w             z_gzclose_w
-#  define gzdirect              z_gzdirect
-#  define gzdopen               z_gzdopen
-#  define gzeof                 z_gzeof
-#  define gzerror               z_gzerror
-#  define gzflush               z_gzflush
-#  define gzgetc                z_gzgetc
-#  define gzgets                z_gzgets
-#  define gzoffset              z_gzoffset
-#  define gzoffset64            z_gzoffset64
-#  define gzopen                z_gzopen
-#  define gzopen64              z_gzopen64
-#  define gzprintf              z_gzprintf
-#  define gzputc                z_gzputc
-#  define gzputs                z_gzputs
-#  define gzread                z_gzread
-#  define gzrewind              z_gzrewind
-#  define gzseek                z_gzseek
-#  define gzseek64              z_gzseek64
-#  define gzsetparams           z_gzsetparams
-#  define gztell                z_gztell
-#  define gztell64              z_gztell64
-#  define gzungetc              z_gzungetc
-#  define gzwrite               z_gzwrite
+#  ifndef Z_SOLO
+#    define gz_error              z_gz_error
+#    define gz_intmax             z_gz_intmax
+#    define gz_strwinerror        z_gz_strwinerror
+#    define gzbuffer              z_gzbuffer
+#    define gzclearerr            z_gzclearerr
+#    define gzclose               z_gzclose
+#    define gzclose_r             z_gzclose_r
+#    define gzclose_w             z_gzclose_w
+#    define gzdirect              z_gzdirect
+#    define gzdopen               z_gzdopen
+#    define gzeof                 z_gzeof
+#    define gzerror               z_gzerror
+#    define gzflags               z_gzflags
+#    define gzflush               z_gzflush
+#    define gzgetc                z_gzgetc
+#    define gzgetc_               z_gzgetc_
+#    define gzgets                z_gzgets
+#    define gzoffset              z_gzoffset
+#    define gzoffset64            z_gzoffset64
+#    define gzopen                z_gzopen
+#    define gzopen64              z_gzopen64
+#    define gzprintf              z_gzprintf
+#    define gzputc                z_gzputc
+#    define gzputs                z_gzputs
+#    define gzread                z_gzread
+#    define gzrewind              z_gzrewind
+#    define gzseek                z_gzseek
+#    define gzseek64              z_gzseek64
+#    define gzsetparams           z_gzsetparams
+#    define gztell                z_gztell
+#    define gztell64              z_gztell64
+#    define gzungetc              z_gzungetc
+#    define gzwrite               z_gzwrite
+#  endif
 #  define inflate               z_inflate
 #  define inflateBack           z_inflateBack
 #  define inflateBackEnd        z_inflateBackEnd
 #  define inflateSync           z_inflateSync
 #  define inflateSyncPoint      z_inflateSyncPoint
 #  define inflateUndermine      z_inflateUndermine
+#  define inflateResetKeep      z_inflateResetKeep
 #  define inflate_copyright     z_inflate_copyright
 #  define inflate_fast          z_inflate_fast
 #  define inflate_table         z_inflate_table
-#  define uncompress            z_uncompress
+#  ifndef Z_SOLO
+#    define uncompress            z_uncompress
+#  endif
 #  define zError                z_zError
-#  define zcalloc               z_zcalloc
-#  define zcfree                z_zcfree
+#  ifndef Z_SOLO
+#    define zcalloc               z_zcalloc
+#    define zcfree                z_zcfree
+#  endif
 #  define zlibCompileFlags      z_zlibCompileFlags
 #  define zlibVersion           z_zlibVersion
 
 #  define alloc_func            z_alloc_func
 #  define charf                 z_charf
 #  define free_func             z_free_func
-#  define gzFile                z_gzFile
-#  define gz_header             z_gz_header
-#  define gz_headerp            z_gz_headerp
+#  ifndef Z_SOLO
+#    define gzFile                z_gzFile
+#    define gz_header             z_gz_header
+#    define gz_headerp            z_gz_headerp
+#  endif
 #  define in_func               z_in_func
 #  define intf                  z_intf
 #  define out_func              z_out_func
 #  define voidpf                z_voidpf
 
 /* all zlib structs in zlib.h and zconf.h */
-#  define gz_header_s           z_gz_header_s
+#  ifndef Z_SOLO
+#    define gz_header_s           z_gz_header_s
+#  endif
 #  define internal_state        z_internal_state
 
 #endif
 #  endif
 #endif
 
+#if defined(ZLIB_CONST) && !defined(z_const)
+#  define z_const const
+#else
+#  define z_const
+#endif
+
 /* Some Mac compilers merge all .h files incorrectly: */
 #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
 #  define NO_DUMMY_DECL
 #  endif
 #endif
 
+#ifndef Z_ARG /* function prototypes for stdarg */
+#  if defined(STDC) || defined(Z_HAVE_STDARG_H)
+#    define Z_ARG(args)  args
+#  else
+#    define Z_ARG(args)  ()
+#  endif
+#endif
+
 /* The following definitions for FAR are needed only for MSDOS mixed
  * model programming (small or medium model with some far allocations).
  * This was tested only with MSC; for other MSDOS compilers you may have
@@ -356,12 +388,18 @@ typedef uLong FAR uLongf;
    typedef Byte       *voidp;
 #endif
 
-#if !defined(_MSC_VER)
+#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
 #  define Z_HAVE_UNISTD_H
 #endif
 
+#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */
+#  define Z_HAVE_STDARG_H
+#endif
+
 #ifdef STDC
-#  include <sys/types.h>    /* for off_t */
+#  ifndef Z_SOLO
+#    include <sys/types.h>      /* for off_t */
+#  endif
 #endif
 
 /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
@@ -374,7 +412,11 @@ typedef uLong FAR uLongf;
 #  undef _LARGEFILE64_SOURCE
 #endif
 
-#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+#  define Z_LARGE
+#endif
+
+#if (defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)) && !defined(Z_SOLO)
 #  include <unistd.h>       /* for SEEK_* and off_t */
 #  ifdef VMS
 #    include <unixio.h>     /* for off_t */
@@ -384,7 +426,7 @@ typedef uLong FAR uLongf;
 #  endif
 #endif
 
-#ifndef SEEK_SET
+#if !defined(SEEK_SET) && !defined(Z_SOLO)
 #  define SEEK_SET        0       /* Seek from beginning of file.  */
 #  define SEEK_CUR        1       /* Seek from current position.  */
 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
@@ -394,18 +436,14 @@ typedef uLong FAR uLongf;
 #  define z_off_t long
 #endif
 
-#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+#if !defined(_WIN32) && (defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0)
 #  define z_off64_t off64_t
 #else
+#  if defined(_WIN32)
+#    define z_off64_t __int64
+#  else
 #  define z_off64_t z_off_t
 #endif
-
-#if defined(__OS400__)
-#  define NO_vsnprintf
-#endif
-
-#if defined(__MVS__)
-#  define NO_vsnprintf
 #endif
 
 /* MVS linker does not support external names larger than 8 bytes */
index bfbba83e8ee0902abe8bcbfab8bdebbbc07dca69..79142d1172e8760ac89ac7b2ad92a79928af737c 100644 (file)
@@ -1,7 +1,7 @@
 /* zlib.h -- interface of the 'zlib' general purpose compression library
-  version 1.2.5, April 19th, 2010
+  version 1.2.6, January 29th, 2012
 
-  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+  Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -24,8 +24,8 @@
 
 
   The data format used by the zlib library is described by RFCs (Request for
-  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
-  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
+  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
+  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
 */
 
 #ifndef ZLIB_H
 extern "C" {
 #endif
 
-#define ZLIB_VERSION "1.2.5"
-#define ZLIB_VERNUM 0x1250
+#define ZLIB_VERSION "1.2.6"
+#define ZLIB_VERNUM 0x1260
 #define ZLIB_VER_MAJOR 1
 #define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 5
+#define ZLIB_VER_REVISION 6
 #define ZLIB_VER_SUBREVISION 0
 
 /*
@@ -83,15 +83,15 @@ typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
 struct internal_state;
 
 typedef struct z_stream_s {
-    Bytef    *next_in;  /* next input byte */
+    z_const Bytef *next_in;     /* next input byte */
     uInt     avail_in;  /* number of bytes available at next_in */
-    uLong    total_in;  /* total nb of input bytes read so far */
+    uLong    total_in;  /* total number of input bytes read so far */
 
     Bytef    *next_out; /* next output byte should be put there */
     uInt     avail_out; /* remaining free space at next_out */
-    uLong    total_out; /* total nb of bytes output so far */
+    uLong    total_out; /* total number of bytes output so far */
 
-    char     *msg;      /* last error message, NULL if no error */
+    z_const char *msg;  /* last error message, NULL if no error */
     struct internal_state FAR *state; /* not visible by applications */
 
     alloc_func zalloc;  /* used to allocate the internal state */
@@ -327,8 +327,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
 
     Z_FINISH can be used immediately after deflateInit if all the compression
   is to be done in a single step.  In this case, avail_out must be at least the
-  value returned by deflateBound (see below).  If deflate does not return
-  Z_STREAM_END, then it must be called again as described above.
+  value returned by deflateBound (see below).  Then deflate is guaranteed to
+  return Z_STREAM_END.  If not enough output space is provided, deflate will
+  not return Z_STREAM_END, and it must be called again as described above.
 
     deflate() sets strm->adler to the adler32 checksum of all input read
   so far (that is, total_in bytes).
@@ -454,20 +455,23 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   avail_out must be large enough to hold all the uncompressed data.  (The size
   of the uncompressed data may have been saved by the compressor for this
   purpose.) The next operation on this stream must be inflateEnd to deallocate
-  the decompression state.  The use of Z_FINISH is never required, but can be
-  used to inform inflate that a faster approach may be used for the single
-  inflate() call.
+  the decompression state.  The use of Z_FINISH is not required to perform an
+  inflation in one step.  However it may be used to inform inflate that a
+  faster approach can be used for the single inflate() call.  Z_FINISH also
+  informs inflate to not maintain a sliding window if the stream completes,
+  which reduces inflate's memory footprint.
 
      In this implementation, inflate() always flushes as much output as
   possible to the output buffer, and always uses the faster approach on the
-  first call.  So the only effect of the flush parameter in this implementation
-  is on the return value of inflate(), as noted below, or when it returns early
-  because Z_BLOCK or Z_TREES is used.
+  first call.  So the effects of the flush parameter in this implementation are
+  on the return value of inflate() as noted below, when inflate() returns early
+  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
+  memory for a sliding window when Z_FINISH is used.
 
      If a preset dictionary is needed after this call (see inflateSetDictionary
-  below), inflate sets strm->adler to the adler32 checksum of the dictionary
+  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
   chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
-  strm->adler to the adler32 checksum of all output produced so far (that is,
+  strm->adler to the Adler-32 checksum of all output produced so far (that is,
   total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
   below.  At the end of the stream, inflate() checks that its computed adler32
   checksum is equal to that saved by the compressor and returns Z_STREAM_END
@@ -478,7 +482,9 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
   initializing with inflateInit2().  Any information contained in the gzip
   header is not retained, so applications that need that information should
   instead use raw inflate, see inflateInit2() below, or inflateBack() and
-  perform their own processing of the gzip header and trailer.
+  perform their own processing of the gzip header and trailer.  When processing
+  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
+  producted so far.  The CRC-32 is checked against the gzip trailer.
 
     inflate() returns Z_OK if some progress has been made (more input processed
   or more output produced), Z_STREAM_END if the end of the compressed data has
@@ -580,10 +586,15 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
                                              uInt  dictLength));
 /*
      Initializes the compression dictionary from the given byte sequence
-   without producing any compressed output.  This function must be called
-   immediately after deflateInit, deflateInit2 or deflateReset, before any call
-   of deflate.  The compressor and decompressor must use exactly the same
-   dictionary (see inflateSetDictionary).
+   without producing any compressed output.  When using the zlib format, this
+   function must be called immediately after deflateInit, deflateInit2 or
+   deflateReset, and before any call of deflate.  When doing raw deflate, this
+   function must be called either before any call of deflate, or immediately
+   after the completion of a deflate block, i.e. after all input has been
+   consumed and all output has been delivered when using any of the flush
+   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The
+   compressor and decompressor must use exactly the same dictionary (see
+   inflateSetDictionary).
 
      The dictionary should consist of strings (byte sequences) that are likely
    to be encountered later in the data to be compressed, with the most commonly
@@ -610,8 +621,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
    parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
    inconsistent (for example if deflate has already been called for this stream
-   or if the compression method is bsort).  deflateSetDictionary does not
-   perform any compression: this will be done by deflate().
+   or if not at a block boundary for raw deflate).  deflateSetDictionary does
+   not perform any compression: this will be done by deflate().
 */
 
 ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
@@ -688,8 +699,28 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
    deflation of sourceLen bytes.  It must be called after deflateInit() or
    deflateInit2(), and after deflateSetHeader(), if used.  This would be used
    to allocate an output buffer for deflation in a single pass, and so would be
-   called before deflate().
-*/
+   called before deflate().  If that first deflate() call is provided the
+   sourceLen input bytes, an output buffer allocated to the size returned by
+   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
+   to return Z_STREAM_END.  Note that it is possible for the compressed size to
+   be larger than the value returned by deflateBound() if flush options other
+   than Z_FINISH or Z_NO_FLUSH are used.
+*/
+
+ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
+                                       unsigned *pending,
+                                       int *bits));
+/*
+     deflatePending() returns the number of bytes and bits of output that have
+   been generated, but not yet provided in the available output.  The bytes not
+   provided would be due to the available output space having being consumed.
+   The number of bits of output not provided are between 0 and 7, where they
+   await more bits to join them in order to fill out a full byte.  If pending
+   or bits are Z_NULL, then those values are not set.
+
+     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+ */
 
 ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
                                      int bits,
@@ -703,8 +734,9 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
    than or equal to 16, and that many of the least significant bits of value
    will be inserted in the output.
 
-     deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
+     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
+   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
+   source stream state was inconsistent.
 */
 
 ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
@@ -790,10 +822,11 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
    if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor
    can be determined from the adler32 value returned by that call of inflate.
    The compressor and decompressor must use exactly the same dictionary (see
-   deflateSetDictionary).  For raw inflate, this function can be called
-   immediately after inflateInit2() or inflateReset() and before any call of
-   inflate() to set the dictionary.  The application must insure that the
-   dictionary that was used for compression is provided.
+   deflateSetDictionary).  For raw inflate, this function can be called at any
+   time to set the dictionary.  If the provided dictionary is smaller than the
+   window and there is already data in the window, then the provided dictionary
+   will amend what's there.  The application must insure that the dictionary
+   that was used for compression is provided.
 
      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
    parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
@@ -805,17 +838,21 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
 
 ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
 /*
-     Skips invalid compressed data until a full flush point (see above the
-   description of deflate with Z_FULL_FLUSH) can be found, or until all
+     Skips invalid compressed data until a possible full flush point (see above
+   for the description of deflate with Z_FULL_FLUSH) can be found, or until all
    available input is skipped.  No output is provided.
 
-     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
-   if no more input was provided, Z_DATA_ERROR if no flush point has been
-   found, or Z_STREAM_ERROR if the stream structure was inconsistent.  In the
-   success case, the application may save the current current value of total_in
-   which indicates where valid compressed data was found.  In the error case,
-   the application may repeatedly call inflateSync, providing more input each
-   time, until success or end of the input data.
+     inflateSync searches for a 00 00 FF FF pattern in the compressed data.
+   All full flush points have this pattern, but not all occurences of this
+   pattern are full flush points.
+
+     inflateSync returns Z_OK if a possible full flush point has been found,
+   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
+   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
+   In the success case, the application may save the current current value of
+   total_in which indicates where valid compressed data was found.  In the
+   error case, the application may repeatedly call inflateSync, providing more
+   input each time, until success or end of the input data.
 */
 
 ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
@@ -962,7 +999,7 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
      See inflateBack() for the usage of these routines.
 
      inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
-   the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
+   the parameters are invalid, Z_MEM_ERROR if the internal state could not be
    allocated, or Z_VERSION_ERROR if the version of the library does not match
    the version of the header file.
 */
@@ -1088,6 +1125,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
      27-31: 0 (reserved)
  */
 
+#ifndef Z_SOLO
 
                         /* utility functions */
 
@@ -1149,10 +1187,11 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
 
      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_BUF_ERROR if there was not enough room in the output
-   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
+   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In
+   the case where there is not enough room, uncompress() will fill the output
+   buffer with the uncompressed data up to that point.
 */
 
-
                         /* gzip file access functions */
 
 /*
@@ -1162,7 +1201,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
    wrapper, documented in RFC 1952, wrapped around a deflate stream.
 */
 
-typedef voidp gzFile;       /* opaque gzip file descriptor */
+typedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */
 
 /*
 ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
@@ -1172,13 +1211,25 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
    a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
    compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
    for fixed code compression as in "wb9F".  (See the description of
-   deflateInit2 for more information about the strategy parameter.) Also "a"
-   can be used instead of "w" to request that the gzip stream that will be
-   written be appended to the file.  "+" will result in an error, since reading
-   and writing to the same gzip file is not supported.
+   deflateInit2 for more information about the strategy parameter.)  'T' will
+   request transparent writing or appending with no compression and not using
+   the gzip format.
+
+     "a" can be used instead of "w" to request that the gzip stream that will
+   be written be appended to the file.  "+" will result in an error, since
+   reading and writing to the same gzip file is not supported.
+
+     These functions, as well as gzip, will read and decode a sequence of gzip
+   streams in a file.  The append function of gzopen() can be used to create
+   such a file.  (Also see gzflush() for another way to do this.)  When
+   appending, gzopen does not test whether the file begins with a gzip stream,
+   nor does it look for the end of the gzip streams to begin appending.  gzopen
+   will simply append a gzip stream to the existing file.
 
      gzopen can be used to read a file which is not in gzip format; in this
-   case gzread will directly read from the file without decompression.
+   case gzread will directly read from the file without decompression.  When
+   reading, this will be detected automatically by looking for the magic two-
+   byte gzip header.
 
      gzopen returns NULL if the file could not be opened, if there was
    insufficient memory to allocate the gzFile state, or if an invalid mode was
@@ -1197,7 +1248,11 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
    descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
    fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
    mode);.  The duplicated descriptor should be saved to avoid a leak, since
-   gzdopen does not close fd if it fails.
+   gzdopen does not close fd if it fails.  If you are using fileno() to get the
+   file descriptor from a FILE *, then you will have to use dup() to avoid
+   double-close()ing the file descriptor.  Both gzclose() and fclose() will
+   close the associated file descriptor, so they need to have different file
+   descriptors.
 
      gzdopen returns NULL if there was insufficient memory to allocate the
    gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
@@ -1235,14 +1290,26 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
 ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
 /*
      Reads the given number of uncompressed bytes from the compressed file.  If
-   the input file was not in gzip format, gzread copies the given number of
-   bytes into the buffer.
+   the input file is not in gzip format, gzread copies the given number of
+   bytes into the buffer directly from the file.
 
      After reaching the end of a gzip stream in the input, gzread will continue
-   to read, looking for another gzip stream, or failing that, reading the rest
-   of the input file directly without decompression.  The entire input file
-   will be read if gzread is called until it returns less than the requested
-   len.
+   to read, looking for another gzip stream.  Any number of gzip streams may be
+   concatenated in the input file, and will all be decompressed by gzread().
+   If something other than a gzip stream is encountered after a gzip stream,
+   that remaining trailing garbage is ignored (and no error is returned).
+
+     gzread can be used to read a gzip file that is being concurrently written.
+   Upon reaching the end of the input, gzread will return with the available
+   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
+   gzclearerr can be used to clear the end of file indicator in order to permit
+   gzread to be tried again.  Z_OK indicates that a gzip stream was completed
+   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the
+   middle of a gzip stream.  Note that gzread does not return -1 in the event
+   of an incomplete gzip stream.  This error is deferred until gzclose(), which
+   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
+   stream.  Alternatively, gzerror can be used before gzclose to detect this
+   case.
 
      gzread returns the number of uncompressed bytes actually read, less than
    len for end of file, or -1 for error.
@@ -1256,7 +1323,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
    error.
 */
 
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
+ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
 /*
      Converts, formats, and writes the arguments to the compressed file under
    control of the format string, as in fprintf.  gzprintf returns the number of
@@ -1301,7 +1368,10 @@ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
 ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
 /*
      Reads one byte from the compressed file.  gzgetc returns this byte or -1
-   in case of end of file or error.
+   in case of end of file or error.  This is implemented as a macro for speed.
+   As such, it does not do all of the checking the other functions do.  I.e.
+   it does not check to see if file is NULL, nor whether the structure file
+   points to has been clobbered or not.
 */
 
 ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
@@ -1397,9 +1467,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
 ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
 /*
      Returns true (1) if file is being copied directly while reading, or false
-   (0) if file is a gzip stream being decompressed.  This state can change from
-   false to true while reading the input file if the end of a gzip stream is
-   reached, but is followed by data that is not another gzip stream.
+   (0) if file is a gzip stream being decompressed.
 
      If the input file is empty, gzdirect() will return true, since the input
    does not contain a gzip stream.
@@ -1408,6 +1476,13 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
    cause buffers to be allocated to allow reading the file to determine if it
    is a gzip file.  Therefore if gzbuffer() is used, it should be called before
    gzdirect().
+
+     When writing, gzdirect() returns true (1) if transparent writing was
+   requested ("wT" for the gzopen() mode), or false (0) otherwise.  (Note:
+   gzdirect() is not needed when writing.  Transparent writing must be
+   explicitly requested, so the application already knows the answer.  When
+   linking statically, using gzdirect() will include all of the zlib code for
+   gzip file reading and decompression, which may not be desired.)
 */
 
 ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
@@ -1419,7 +1494,8 @@ ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
    must not be called more than once on the same allocation.
 
      gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
-   file operation error, or Z_OK on success.
+   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
+   last read ended in the middle of a gzip stream, or Z_OK on success.
 */
 
 ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
@@ -1457,6 +1533,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
    file that is being written concurrently.
 */
 
+#endif /* !Z_SOLO */
 
                         /* checksum functions */
 
@@ -1492,7 +1569,9 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
      Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
    and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
    each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
-   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
+   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note
+   that the z_off_t type (like off_t) is a signed integer.  If len2 is
+   negative, the result has no meaning or utility.
 */
 
 ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
@@ -1544,17 +1623,36 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
                                          const char *version,
                                          int stream_size));
 #define deflateInit(strm, level) \
-        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
+        deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
 #define inflateInit(strm) \
-        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
+        inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
 #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
         deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
-                      (strategy),           ZLIB_VERSION, sizeof(z_stream))
+                      (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
 #define inflateInit2(strm, windowBits) \
-        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
+        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+                      (int)sizeof(z_stream))
 #define inflateBackInit(strm, windowBits, window) \
         inflateBackInit_((strm), (windowBits), (window), \
-                                            ZLIB_VERSION, sizeof(z_stream))
+                      ZLIB_VERSION, (int)sizeof(z_stream))
+
+#ifndef Z_SOLO
+
+/* gzgetc() macro and its supporting function and exposed data structure.  Note
+ * that the real internal state is much larger than the exposed structure.
+ * This abbreviated structure exposes just enough for the gzgetc() macro.  The
+ * user should not mess with these exposed elements, since their names or
+ * behavior could change in the future, perhaps even capriciously.  They can
+ * only be used by the gzgetc() macro.  You have been warned.
+ */
+struct gzFile_s {
+    unsigned have;
+    unsigned char *next;
+    z_off64_t pos;
+};
+ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
+#define gzgetc(g) \
+    ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc_(g))
 
 /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
  * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
@@ -1572,13 +1670,22 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
 #endif
 
 #if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
-#  define gzopen gzopen64
-#  define gzseek gzseek64
-#  define gztell gztell64
-#  define gzoffset gzoffset64
-#  define adler32_combine adler32_combine64
-#  define crc32_combine crc32_combine64
-#  ifdef _LARGEFILE64_SOURCE
+#  ifdef Z_PREFIX_SET
+#    define z_gzopen z_gzopen64
+#    define z_gzseek z_gzseek64
+#    define z_gztell z_gztell64
+#    define z_gzoffset z_gzoffset64
+#    define z_adler32_combine z_adler32_combine64
+#    define z_crc32_combine z_crc32_combine64
+#  else
+#    define gzopen gzopen64
+#    define gzseek gzseek64
+#    define gztell gztell64
+#    define gzoffset gzoffset64
+#    define adler32_combine adler32_combine64
+#    define crc32_combine crc32_combine64
+#  endif
+#  ifndef _LARGEFILE64_SOURCE
      ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
      ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
      ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
@@ -1595,6 +1702,13 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
    ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
 #endif
 
+#else /* Z_SOLO */
+
+   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+
+#endif /* !Z_SOLO */
+
 /* hack for buggy compilers */
 #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
     struct internal_state {int dummy;};
@@ -1605,6 +1719,11 @@ ZEXTERN const char   * ZEXPORT zError           OF((int));
 ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
 ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
 ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
+ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
+ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
+#ifndef Z_SOLO
+  ZEXTERN unsigned long  ZEXPORT gzflags          OF((void));
+#endif
 
 #ifdef __cplusplus
 }
index 898ed345b0e3ef23ce5aaba1eb6307b5b113d6b1..8a1d2420937f91bdb9fe82f3fccef7d7263aa9a6 100644 (file)
@@ -1,5 +1,5 @@
 /* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
+ * Copyright (C) 1995-2005, 2010, 2011 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -85,31 +85,11 @@ uLong ZEXPORT zlibCompileFlags()
 #ifdef FASTEST
     flags += 1L << 21;
 #endif
-#ifdef STDC
-#  ifdef NO_vsnprintf
-        flags += 1L << 25;
-#    ifdef HAS_vsprintf_void
-        flags += 1L << 26;
-#    endif
-#  else
-#    ifdef HAS_vsnprintf_void
-        flags += 1L << 26;
-#    endif
-#  endif
+#ifdef Z_SOLO
+    return flags;
 #else
-        flags += 1L << 24;
-#  ifdef NO_snprintf
-        flags += 1L << 25;
-#    ifdef HAS_sprintf_void
-        flags += 1L << 26;
-#    endif
-#  else
-#    ifdef HAS_snprintf_void
-        flags += 1L << 26;
-#    endif
-#  endif
+    return flags + gzflags();
 #endif
-    return flags;
 }
 
 #ifdef DEBUG
@@ -181,6 +161,7 @@ void ZLIB_INTERNAL zmemzero(dest, len)
 }
 #endif
 
+#ifndef Z_SOLO
 
 #ifdef SYS16BIT
 
@@ -316,3 +297,5 @@ void ZLIB_INTERNAL zcfree (opaque, ptr)
 }
 
 #endif /* MY_ZCALLOC */
+
+#endif /* !Z_SOLO */
index 258fa88799ad1d97e44fe1ac9df77948e82ea5c0..dff1112febd2ce4cd4fed3ed5db8ee1fef6aaa13 100644 (file)
@@ -1,5 +1,5 @@
 /* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2010 Jean-loup Gailly.
+ * Copyright (C) 1995-2011 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -21,7 +21,7 @@
 
 #include "zlib.h"
 
-#ifdef STDC
+#if defined(STDC) && !defined(Z_SOLO)
 #  if !(defined(_WIN32_WCE) && defined(_MSC_VER))
 #    include <stddef.h>
 #  endif
 #  include <stdlib.h>
 #endif
 
+#ifdef Z_SOLO
+   typedef long ptrdiff_t;  /* guess -- will be caught if guess is wrong */
+#endif
+
 #ifndef local
 #  define local static
 #endif
@@ -78,16 +82,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 
 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
 #  define OS_CODE  0x00
-#  if defined(__TURBOC__) || defined(__BORLANDC__)
-#    if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
-       /* Allow compilation with ANSI keywords only enabled */
-       void _Cdecl farfree( void *block );
-       void *_Cdecl farmalloc( unsigned long nbytes );
-#    else
-#      include <alloc.h>
+#  ifndef Z_SOLO
+#    if defined(__TURBOC__) || defined(__BORLANDC__)
+#      if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
+         /* Allow compilation with ANSI keywords only enabled */
+         void _Cdecl farfree( void *block );
+         void *_Cdecl farmalloc( unsigned long nbytes );
+#      else
+#        include <alloc.h>
+#      endif
+#    else /* MSC or DJGPP */
+#      include <malloc.h>
 #    endif
-#  else /* MSC or DJGPP */
-#    include <malloc.h>
 #  endif
 #endif
 
@@ -107,18 +113,20 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 
 #ifdef OS2
 #  define OS_CODE  0x06
-#  ifdef M_I86
+#  if defined(M_I86) && !defined(Z_SOLO)
 #    include <malloc.h>
 #  endif
 #endif
 
 #if defined(MACOS) || defined(TARGET_OS_MAC)
 #  define OS_CODE  0x07
-#  if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-#    include <unix.h> /* for fdopen */
-#  else
-#    ifndef fdopen
-#      define fdopen(fd,mode) NULL /* No fdopen() */
+#  ifndef Z_SOLO
+#    if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
+#      include <unix.h> /* for fdopen */
+#    else
+#      ifndef fdopen
+#        define fdopen(fd,mode) NULL /* No fdopen() */
+#      endif
 #    endif
 #  endif
 #endif
@@ -153,14 +161,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #  endif
 #endif
 
-#if defined(__BORLANDC__)
+#if defined(__BORLANDC__) && !defined(MSDOS)
   #pragma warn -8004
   #pragma warn -8008
   #pragma warn -8066
 #endif
 
 /* provide prototypes for these when building zlib without LFS */
-#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
+#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
 #endif
@@ -177,42 +185,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 
          /* functions */
 
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
-#  ifndef HAVE_VSNPRINTF
-#    define HAVE_VSNPRINTF
-#  endif
-#endif
-#if defined(__CYGWIN__)
-#  ifndef HAVE_VSNPRINTF
-#    define HAVE_VSNPRINTF
-#  endif
-#endif
-#ifndef HAVE_VSNPRINTF
-#  ifdef MSDOS
-     /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
-        but for now we just assume it doesn't. */
-#    define NO_vsnprintf
-#  endif
-#  ifdef __TURBOC__
-#    define NO_vsnprintf
-#  endif
-#  ifdef WIN32
-     /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
-#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
-#         define vsnprintf _vsnprintf
-#      endif
-#    endif
-#  endif
-#  ifdef __SASC
-#    define NO_vsnprintf
-#  endif
-#endif
-#ifdef VMS
-#  define NO_vsnprintf
-#endif
-
-#if defined(pyr)
+#if defined(pyr) || defined(Z_SOLO)
 #  define NO_MEMCPY
 #endif
 #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
@@ -261,10 +234,11 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #  define Tracecv(c,x)
 #endif
 
-
-voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
-                        unsigned size));
-void ZLIB_INTERNAL zcfree  OF((voidpf opaque, voidpf ptr));
+#ifndef Z_SOLO
+   voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
+                                    unsigned size));
+   void ZLIB_INTERNAL zcfree  OF((voidpf opaque, voidpf ptr));
+#endif
 
 #define ZALLOC(strm, items, size) \
            (*((strm)->zalloc))((strm)->opaque, (items), (size))
diff --git a/trace.py b/trace.py
deleted file mode 100644 (file)
index bd97772..0000000
--- a/trace.py
+++ /dev/null
@@ -1,589 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2010 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-"""Common trace code generation."""
-
-
-import specs.stdapi as stdapi
-
-
-def getWrapperInterfaceName(interface):
-    return "Wrap" + interface.expr
-
-
-class ComplexValueSerializer(stdapi.OnceVisitor):
-    '''Type visitors which generates serialization functions for
-    complex types.
-    
-    Simple types are serialized inline.
-    '''
-
-    def __init__(self, serializer):
-        stdapi.OnceVisitor.__init__(self)
-        self.serializer = serializer
-
-    def visitVoid(self, literal):
-        pass
-
-    def visitLiteral(self, literal):
-        pass
-
-    def visitString(self, string):
-        pass
-
-    def visitConst(self, const):
-        self.visit(const.type)
-
-    def visitStruct(self, struct):
-        for type, name in struct.members:
-            self.visit(type)
-        print 'static void _write__%s(const %s &value) {' % (struct.tag, struct.expr)
-        print '    static const char * members[%u] = {' % (len(struct.members),)
-        for type, name,  in struct.members:
-            print '        "%s",' % (name,)
-        print '    };'
-        print '    static const trace::StructSig sig = {'
-        print '       %u, "%s", %u, members' % (struct.id, struct.name, len(struct.members))
-        print '    };'
-        print '    trace::localWriter.beginStruct(&sig);'
-        for type, name in struct.members:
-            self.serializer.visit(type, 'value.%s' % (name,))
-        print '    trace::localWriter.endStruct();'
-        print '}'
-        print
-
-    def visitArray(self, array):
-        self.visit(array.type)
-
-    def visitBlob(self, array):
-        pass
-
-    def visitEnum(self, enum):
-        print 'static const trace::EnumValue __enum%s_values[] = {' % (enum.tag)
-        for value in enum.values:
-            print '   {"%s", %s},' % (value, value)
-        print '};'
-        print
-        print 'static const trace::EnumSig __enum%s_sig = {' % (enum.tag)
-        print '   %u, %u, __enum%s_values' % (enum.id, len(enum.values), enum.tag)
-        print '};'
-        print
-
-    def visitBitmask(self, bitmask):
-        print 'static const trace::BitmaskFlag __bitmask%s_flags[] = {' % (bitmask.tag)
-        for value in bitmask.values:
-            print '   {"%s", %s},' % (value, value)
-        print '};'
-        print
-        print 'static const trace::BitmaskSig __bitmask%s_sig = {' % (bitmask.tag)
-        print '   %u, %u, __bitmask%s_flags' % (bitmask.id, len(bitmask.values), bitmask.tag)
-        print '};'
-        print
-
-    def visitPointer(self, pointer):
-        self.visit(pointer.type)
-
-    def visitIntPointer(self, pointer):
-        pass
-
-    def visitLinearPointer(self, pointer):
-        self.visit(pointer.type)
-
-    def visitHandle(self, handle):
-        self.visit(handle.type)
-
-    def visitAlias(self, alias):
-        self.visit(alias.type)
-
-    def visitOpaque(self, opaque):
-        pass
-
-    def visitInterface(self, interface):
-        pass
-
-    def visitPolymorphic(self, polymorphic):
-        print 'static void _write__%s(int selector, const %s & value) {' % (polymorphic.tag, polymorphic.expr)
-        print '    switch (selector) {'
-        for cases, type in polymorphic.iterSwitch():
-            for case in cases:
-                print '    %s:' % case
-            self.serializer.visit(type, 'static_cast<%s>(value)' % (type,))
-            print '        break;'
-        print '    }'
-        print '}'
-        print
-
-
-class ValueSerializer(stdapi.Visitor):
-    '''Visitor which generates code to serialize any type.
-    
-    Simple types are serialized inline here, whereas the serialization of
-    complex types is dispatched to the serialization functions generated by
-    ComplexValueSerializer visitor above.
-    '''
-
-    def visitLiteral(self, literal, instance):
-        print '    trace::localWriter.write%s(%s);' % (literal.kind, instance)
-
-    def visitString(self, string, instance):
-        if string.kind == 'String':
-            cast = 'const char *'
-        elif string.kind == 'WString':
-            cast = 'const wchar_t *'
-        else:
-            assert False
-        if cast != string.expr:
-            # reinterpret_cast is necessary for GLubyte * <=> char *
-            instance = 'reinterpret_cast<%s>(%s)' % (cast, instance)
-        if string.length is not None:
-            length = ', %s' % string.length
-        else:
-            length = ''
-        print '    trace::localWriter.write%s(%s%s);' % (string.kind, instance, length)
-
-    def visitConst(self, const, instance):
-        self.visit(const.type, instance)
-
-    def visitStruct(self, struct, instance):
-        print '    _write__%s(%s);' % (struct.tag, instance)
-
-    def visitArray(self, array, instance):
-        length = '__c' + array.type.tag
-        index = '__i' + array.type.tag
-        print '    if (%s) {' % instance
-        print '        size_t %s = %s;' % (length, array.length)
-        print '        trace::localWriter.beginArray(%s);' % length
-        print '        for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index)
-        print '            trace::localWriter.beginElement();'
-        self.visit(array.type, '(%s)[%s]' % (instance, index))
-        print '            trace::localWriter.endElement();'
-        print '        }'
-        print '        trace::localWriter.endArray();'
-        print '    } else {'
-        print '        trace::localWriter.writeNull();'
-        print '    }'
-
-    def visitBlob(self, blob, instance):
-        print '    trace::localWriter.writeBlob(%s, %s);' % (instance, blob.size)
-
-    def visitEnum(self, enum, instance):
-        print '    trace::localWriter.writeEnum(&__enum%s_sig, %s);' % (enum.tag, instance)
-
-    def visitBitmask(self, bitmask, instance):
-        print '    trace::localWriter.writeBitmask(&__bitmask%s_sig, %s);' % (bitmask.tag, instance)
-
-    def visitPointer(self, pointer, instance):
-        print '    if (%s) {' % instance
-        print '        trace::localWriter.beginArray(1);'
-        print '        trace::localWriter.beginElement();'
-        self.visit(pointer.type, "*" + instance)
-        print '        trace::localWriter.endElement();'
-        print '        trace::localWriter.endArray();'
-        print '    } else {'
-        print '        trace::localWriter.writeNull();'
-        print '    }'
-
-    def visitIntPointer(self, pointer, instance):
-        print '    trace::localWriter.writeOpaque((const void *)%s);' % instance
-
-    def visitLinearPointer(self, pointer, instance):
-        print '    trace::localWriter.writeOpaque((const void *)%s);' % instance
-
-    def visitHandle(self, handle, instance):
-        self.visit(handle.type, instance)
-
-    def visitAlias(self, alias, instance):
-        self.visit(alias.type, instance)
-
-    def visitOpaque(self, opaque, instance):
-        print '    trace::localWriter.writeOpaque((const void *)%s);' % instance
-
-    def visitInterface(self, interface, instance):
-        print '    trace::localWriter.writeOpaque((const void *)&%s);' % instance
-
-    def visitPolymorphic(self, polymorphic, instance):
-        print '    _write__%s(%s, %s);' % (polymorphic.tag, polymorphic.switchExpr, instance)
-
-
-class ValueWrapper(stdapi.Visitor):
-    '''Type visitor which will generate the code to wrap an instance.
-    
-    Wrapping is necessary mostly for interfaces, however interface pointers can
-    appear anywhere inside complex types.
-    '''
-
-    def visitVoid(self, type, instance):
-        raise NotImplementedError
-
-    def visitLiteral(self, type, instance):
-        pass
-
-    def visitString(self, type, instance):
-        pass
-
-    def visitConst(self, type, instance):
-        pass
-
-    def visitStruct(self, struct, instance):
-        for type, name in struct.members:
-            self.visit(type, "(%s).%s" % (instance, name))
-
-    def visitArray(self, array, instance):
-        # XXX: actually it is possible to return an array of pointers
-        pass
-
-    def visitBlob(self, blob, instance):
-        pass
-
-    def visitEnum(self, enum, instance):
-        pass
-
-    def visitBitmask(self, bitmask, instance):
-        pass
-
-    def visitPointer(self, pointer, instance):
-        print "    if (%s) {" % instance
-        self.visit(pointer.type, "*" + instance)
-        print "    }"
-    
-    def visitIntPointer(self, pointer, instance):
-        pass
-
-    def visitLinearPointer(self, pointer, instance):
-        pass
-
-    def visitHandle(self, handle, instance):
-        self.visit(handle.type, instance)
-
-    def visitAlias(self, alias, instance):
-        self.visit(alias.type, instance)
-
-    def visitOpaque(self, opaque, instance):
-        pass
-    
-    def visitInterface(self, interface, instance):
-        assert instance.startswith('*')
-        instance = instance[1:]
-        print "    if (%s) {" % instance
-        print "        %s = new %s(%s);" % (instance, getWrapperInterfaceName(interface), instance)
-        print "    }"
-    
-    def visitPolymorphic(self, type, instance):
-        # XXX: There might be polymorphic values that need wrapping in the future
-        pass
-
-
-class ValueUnwrapper(ValueWrapper):
-    '''Reverse of ValueWrapper.'''
-
-    def visitInterface(self, interface, instance):
-        assert instance.startswith('*')
-        instance = instance[1:]
-        print r'    if (%s) {' % instance
-        print r'        %s *pWrapper = static_cast<%s*>(%s);' % (getWrapperInterfaceName(interface), getWrapperInterfaceName(interface), instance)
-        print r'        if (pWrapper && pWrapper->m_dwMagic == 0xd8365d6c) {'
-        print r'            %s = pWrapper->m_pInstance;' % (instance,)
-        print r'        } else {'
-        print r'            os::log("apitrace: warning: %%s: unexpected %%s pointer\n", __FUNCTION__, "%s");' % interface.name
-        print r'        }'
-        print r'    }'
-
-
-class Tracer:
-    '''Base class to orchestrate the code generation of API tracing.'''
-
-    def __init__(self):
-        self.api = None
-
-    def serializerFactory(self):
-        '''Create a serializer.
-        
-        Can be overriden by derived classes to inject their own serialzer.
-        '''
-
-        return ValueSerializer()
-
-    def trace_api(self, api):
-        self.api = api
-
-        self.header(api)
-
-        # Includes
-        for header in api.headers:
-            print header
-        print
-
-        # Generate the serializer functions
-        types = api.getAllTypes()
-        visitor = ComplexValueSerializer(self.serializerFactory())
-        map(visitor.visit, types)
-        print
-
-        # Interfaces wrapers
-        interfaces = api.getAllInterfaces()
-        map(self.declareWrapperInterface, interfaces)
-        map(self.implementWrapperInterface, interfaces)
-        print
-
-        # Function wrappers
-        map(self.traceFunctionDecl, api.functions)
-        map(self.traceFunctionImpl, api.functions)
-        print
-
-        self.footer(api)
-
-    def header(self, api):
-        pass
-
-    def footer(self, api):
-        pass
-
-    def traceFunctionDecl(self, function):
-        # Per-function declarations
-
-        if function.args:
-            print 'static const char * __%s_args[%u] = {%s};' % (function.name, len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args]))
-        else:
-            print 'static const char ** __%s_args = NULL;' % (function.name,)
-        print 'static const trace::FunctionSig __%s_sig = {%u, "%s", %u, __%s_args};' % (function.name, function.id, function.name, len(function.args), function.name)
-        print
-
-    def isFunctionPublic(self, function):
-        return True
-
-    def traceFunctionImpl(self, function):
-        if self.isFunctionPublic(function):
-            print 'extern "C" PUBLIC'
-        else:
-            print 'extern "C" PRIVATE'
-        print function.prototype() + ' {'
-        if function.type is not stdapi.Void:
-            print '    %s __result;' % function.type
-        self.traceFunctionImplBody(function)
-        if function.type is not stdapi.Void:
-            self.wrapRet(function, "__result")
-            print '    return __result;'
-        print '}'
-        print
-
-    def traceFunctionImplBody(self, function):
-        print '    unsigned __call = trace::localWriter.beginEnter(&__%s_sig);' % (function.name,)
-        for arg in function.args:
-            if not arg.output:
-                self.unwrapArg(function, arg)
-                self.serializeArg(function, arg)
-        print '    trace::localWriter.endEnter();'
-        self.invokeFunction(function)
-        print '    trace::localWriter.beginLeave(__call);'
-        for arg in function.args:
-            if arg.output:
-                self.serializeArg(function, arg)
-                self.wrapArg(function, arg)
-        if function.type is not stdapi.Void:
-            self.serializeRet(function, "__result")
-        print '    trace::localWriter.endLeave();'
-
-    def invokeFunction(self, function, prefix='__', suffix=''):
-        if function.type is stdapi.Void:
-            result = ''
-        else:
-            result = '__result = '
-        dispatch = prefix + function.name + suffix
-        print '    %s%s(%s);' % (result, dispatch, ', '.join([str(arg.name) for arg in function.args]))
-
-    def serializeArg(self, function, arg):
-        print '    trace::localWriter.beginArg(%u);' % (arg.index,)
-        self.serializeArgValue(function, arg)
-        print '    trace::localWriter.endArg();'
-
-    def serializeArgValue(self, function, arg):
-        self.serializeValue(arg.type, arg.name)
-
-    def wrapArg(self, function, arg):
-        self.wrapValue(arg.type, arg.name)
-
-    def unwrapArg(self, function, arg):
-        self.unwrapValue(arg.type, arg.name)
-
-    def serializeRet(self, function, instance):
-        print '    trace::localWriter.beginReturn();'
-        self.serializeValue(function.type, instance)
-        print '    trace::localWriter.endReturn();'
-
-    def serializeValue(self, type, instance):
-        serializer = self.serializerFactory()
-        serializer.visit(type, instance)
-
-    def wrapRet(self, function, instance):
-        self.wrapValue(function.type, instance)
-
-    def unwrapRet(self, function, instance):
-        self.unwrapValue(function.type, instance)
-
-    def wrapValue(self, type, instance):
-        visitor = ValueWrapper()
-        visitor.visit(type, instance)
-
-    def unwrapValue(self, type, instance):
-        visitor = ValueUnwrapper()
-        visitor.visit(type, instance)
-
-    def declareWrapperInterface(self, interface):
-        print "class %s : public %s " % (getWrapperInterfaceName(interface), interface.name)
-        print "{"
-        print "public:"
-        print "    %s(%s * pInstance);" % (getWrapperInterfaceName(interface), interface.name)
-        print "    virtual ~%s();" % getWrapperInterfaceName(interface)
-        print
-        for method in interface.iterMethods():
-            print "    " + method.prototype() + ";"
-        print
-        self.declareWrapperInterfaceVariables(interface)
-        print "};"
-        print
-
-    def declareWrapperInterfaceVariables(self, interface):
-        #print "private:"
-        print "    DWORD m_dwMagic;"
-        print "    %s * m_pInstance;" % (interface.name,)
-
-    def implementWrapperInterface(self, interface):
-        print '%s::%s(%s * pInstance) {' % (getWrapperInterfaceName(interface), getWrapperInterfaceName(interface), interface.name)
-        print '    m_dwMagic = 0xd8365d6c;'
-        print '    m_pInstance = pInstance;'
-        print '}'
-        print
-        print '%s::~%s() {' % (getWrapperInterfaceName(interface), getWrapperInterfaceName(interface))
-        print '}'
-        print
-        for base, method in interface.iterBaseMethods():
-            self.implementWrapperInterfaceMethod(interface, base, method)
-        print
-
-    def implementWrapperInterfaceMethod(self, interface, base, method):
-        print method.prototype(getWrapperInterfaceName(interface) + '::' + method.name) + ' {'
-        if method.type is not stdapi.Void:
-            print '    %s __result;' % method.type
-    
-        self.implementWrapperInterfaceMethodBody(interface, base, method)
-    
-        if method.type is not stdapi.Void:
-            print '    return __result;'
-        print '}'
-        print
-
-    def implementWrapperInterfaceMethodBody(self, interface, base, method):
-        print '    static const char * __args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args]))
-        print '    static const trace::FunctionSig __sig = {%u, "%s", %u, __args};' % (method.id, interface.name + '::' + method.name, len(method.args) + 1)
-        print '    unsigned __call = trace::localWriter.beginEnter(&__sig);'
-        print '    trace::localWriter.beginArg(0);'
-        print '    trace::localWriter.writeOpaque((const void *)m_pInstance);'
-        print '    trace::localWriter.endArg();'
-
-        from specs.winapi import REFIID
-        from specs.stdapi import Pointer, Opaque, Interface
-
-        riid = None
-        for arg in method.args:
-            if not arg.output:
-                self.unwrapArg(method, arg)
-                self.serializeArg(method, arg)
-                if arg.type is REFIID:
-                    riid = arg
-        print '    trace::localWriter.endEnter();'
-        
-        self.invokeMethod(interface, base, method)
-
-        print '    trace::localWriter.beginLeave(__call);'
-        for arg in method.args:
-            if arg.output:
-                self.serializeArg(method, arg)
-                self.wrapArg(method, arg)
-                if riid is not None and isinstance(arg.type, Pointer):
-                    if isinstance(arg.type.type, Opaque):
-                        self.wrapIid(riid, arg)
-                    else:
-                        assert isinstance(arg.type.type, Pointer)
-                        assert isinstance(arg.type.type.type, Interface)
-
-        if method.type is not stdapi.Void:
-            print '    trace::localWriter.beginReturn();'
-            self.serializeValue(method.type, "__result")
-            print '    trace::localWriter.endReturn();'
-            self.wrapValue(method.type, '__result')
-        print '    trace::localWriter.endLeave();'
-        if method.name == 'Release':
-            assert method.type is not stdapi.Void
-            print '    if (!__result)'
-            print '        delete this;'
-
-    def wrapIid(self, riid, out):
-            print '    if (%s && *%s) {' % (out.name, out.name)
-            print '        if (*%s == m_pInstance) {' % (out.name,)
-            print '            AddRef();'
-            print '            m_pInstance->Release();'
-            print '            *%s = this;' % (out.name,)
-            print '        }'
-            for iface in self.api.getAllInterfaces():
-                print r'        else if (%s == IID_%s) {' % (riid.name, iface.name)
-                print r'            *%s = new Wrap%s((%s *) *%s);' % (out.name, iface.name, iface.name, out.name)
-                print r'        }'
-            print r'        else {'
-            print r'            os::log("apitrace: warning: %s: unknown REFIID {0x%08lX,0x%04X,0x%04X,{0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X}}\n",'
-            print r'                    __FUNCTION__,'
-            print r'                    %s.Data1, %s.Data2, %s.Data3,' % (riid.name, riid.name, riid.name)
-            print r'                    %s.Data4[0],' % (riid.name,)
-            print r'                    %s.Data4[1],' % (riid.name,)
-            print r'                    %s.Data4[2],' % (riid.name,)
-            print r'                    %s.Data4[3],' % (riid.name,)
-            print r'                    %s.Data4[4],' % (riid.name,)
-            print r'                    %s.Data4[5],' % (riid.name,)
-            print r'                    %s.Data4[6],' % (riid.name,)
-            print r'                    %s.Data4[7]);' % (riid.name,)
-            print r'        }'
-            print '    }'
-
-    def invokeMethod(self, interface, base, method):
-        if method.type is stdapi.Void:
-            result = ''
-        else:
-            result = '__result = '
-        print '    %sstatic_cast<%s *>(m_pInstance)->%s(%s);' % (result, base, method.name, ', '.join([str(arg.name) for arg in method.args]))
-    
-    def emit_memcpy(self, dest, src, length):
-        print '        unsigned __call = trace::localWriter.beginEnter(&trace::memcpy_sig);'
-        print '        trace::localWriter.beginArg(0);'
-        print '        trace::localWriter.writeOpaque(%s);' % dest
-        print '        trace::localWriter.endArg();'
-        print '        trace::localWriter.beginArg(1);'
-        print '        trace::localWriter.writeBlob(%s, %s);' % (src, length)
-        print '        trace::localWriter.endArg();'
-        print '        trace::localWriter.beginArg(2);'
-        print '        trace::localWriter.writeUInt(%s);' % length
-        print '        trace::localWriter.endArg();'
-        print '        trace::localWriter.endEnter();'
-        print '        trace::localWriter.beginLeave(__call);'
-        print '        trace::localWriter.endLeave();'
-       
diff --git a/wgltrace.py b/wgltrace.py
deleted file mode 100644 (file)
index 4dfd0f4..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-##########################################################################
-#
-# Copyright 2008-2009 VMware, Inc.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-##########################################################################/
-
-
-"""WGL tracing code generator."""
-
-
-from specs.stdapi import API
-from specs.glapi import glapi
-from specs.wglapi import wglapi
-from dispatch import function_pointer_type, function_pointer_value
-from gltrace import GlTracer
-from codegen import *
-
-
-class WglTracer(GlTracer):
-
-    def wrapRet(self, function, instance):
-        GlTracer.wrapRet(self, function, instance)
-
-        if function.name == "wglGetProcAddress":
-            print '    if (%s) {' % instance
-        
-            func_dict = dict([(f.name, f) for f in glapi.functions + wglapi.functions])
-
-            def handle_case(function_name):
-                f = func_dict[function_name]
-                ptype = function_pointer_type(f)
-                pvalue = function_pointer_value(f)
-                print '    %s = (%s)%s;' % (pvalue, ptype, instance)
-                print '    %s = (%s)&%s;' % (instance, function.type, f.name);
-        
-            def handle_default():
-                print '    os::log("apitrace: warning: unknown function \\"%s\\"\\n", lpszProc);'
-
-            string_switch('lpszProc', func_dict.keys(), handle_case, handle_default)
-            print '    }'
-
-
-if __name__ == '__main__':
-    print
-    print '#define _GDI32_'
-    print
-    print '#include <string.h>'
-    print '#include <windows.h>'
-    print
-    print '#include "trace_writer_local.hpp"'
-    print '#include "os.hpp"'
-    print
-    print '// To validate our prototypes'
-    print '#define GL_GLEXT_PROTOTYPES'
-    print '#define WGL_GLXEXT_PROTOTYPES'
-    print
-    print '#include "glproc.hpp"'
-    print '#include "glsize.hpp"'
-    print
-    api = API()
-    api.addApi(glapi)
-    api.addApi(wglapi)
-    tracer = WglTracer()
-    tracer.trace_api(api)
diff --git a/wrappers/.gitignore b/wrappers/.gitignore
new file mode 100644 (file)
index 0000000..38fd57f
--- /dev/null
@@ -0,0 +1,14 @@
+cgltrace.cpp
+d2d1trace.cpp
+d3d10_1trace.cpp
+d3d10trace.cpp
+d3d11trace.cpp
+d3d8trace.cpp
+d3d9trace.cpp
+ddrawtrace.cpp
+dlltrace.cpp
+dwritetrace.cpp
+egltrace.cpp
+gltrace.cpp
+glxtrace.cpp
+wgltrace.cpp
diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cc817d5
--- /dev/null
@@ -0,0 +1,470 @@
+##############################################################################
+# API tracers
+
+
+include_directories (
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_SOURCE_DIR}/helpers
+    ${CMAKE_BINARY_DIR}/dispatch
+    ${CMAKE_SOURCE_DIR}/dispatch
+)
+
+add_library (common_trace STATIC
+    trace.cpp
+)
+
+set_target_properties (common_trace PROPERTIES
+    # Ensure it can be statically linked in shared libraries
+    COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
+)
+
+if (WIN32)
+    if (MINGW)
+        # Silence warnings about @nn suffix mismatch
+        set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--enable-stdcall-fixup")
+    endif ()
+
+    # ddraw.dll
+    if (DirectX_D3D_INCLUDE_DIR)
+        include_directories (SYSTEM ${DirectX_D3D_INCLUDE_DIR})
+        add_custom_command (
+            OUTPUT ddrawtrace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ddrawtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/ddrawtrace.cpp
+            DEPENDS
+                ddrawtrace.py
+                dlltrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d.py
+                ${CMAKE_SOURCE_DIR}/specs/d3dtypes.py
+                ${CMAKE_SOURCE_DIR}/specs/d3dcaps.py
+                ${CMAKE_SOURCE_DIR}/specs/ddraw.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (ddrawtrace MODULE ddraw.def ddrawtrace.cpp)
+        target_link_libraries (ddrawtrace
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (ddrawtrace PROPERTIES
+            PREFIX ""
+            OUTPUT_NAME ddraw
+        )
+        install (TARGETS ddrawtrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+    endif ()
+
+    # d3d8.dll
+    if (DirectX_D3D8_INCLUDE_DIR AND DirectX_D3DX9_INCLUDE_DIR)
+        include_directories (SYSTEM ${DirectX_D3D8_INCLUDE_DIR} ${DirectX_D3DX9_INCLUDE_DIR})
+        add_custom_command (
+            OUTPUT d3d8trace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d8trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d8trace.cpp
+            DEPENDS
+                d3d8trace.py
+                dlltrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d8.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d8types.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d8caps.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (d3d8trace MODULE d3d8.def d3d8trace.cpp d3d9shader.cpp)
+        target_link_libraries (d3d8trace
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (d3d8trace PROPERTIES
+            PREFIX ""
+            OUTPUT_NAME d3d8
+        )
+        install (TARGETS d3d8trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+    endif ()
+
+    # d3d9.dll
+    if (DirectX_D3DX9_INCLUDE_DIR)
+        include_directories (SYSTEM ${DirectX_D3DX9_INCLUDE_DIR})
+        add_custom_command (
+            OUTPUT d3d9trace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d9trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d9trace.cpp
+            DEPENDS
+                d3d9trace.py
+                dlltrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d9.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d9types.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d9caps.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (d3d9trace MODULE d3d9.def d3d9trace.cpp d3d9shader.cpp)
+        target_link_libraries (d3d9trace
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (d3d9trace PROPERTIES
+            PREFIX ""
+            OUTPUT_NAME d3d9
+        )
+        install (TARGETS d3d9trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+    endif ()
+
+    # d3d10.dll
+    if (DirectX_D3D10_INCLUDE_DIR)
+        include_directories (SYSTEM ${DirectX_D3D10_INCLUDE_DIR})
+        add_custom_command (
+            OUTPUT d3d10trace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10trace.cpp
+            DEPENDS
+                d3d10trace.py
+                dlltrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10misc.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10shader.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10effect.py
+                ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgi.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (d3d10trace MODULE d3d10.def d3d10trace.cpp d3d10shader.cpp)
+        target_link_libraries (d3d10trace
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (d3d10trace PROPERTIES
+            PREFIX ""
+            OUTPUT_NAME d3d10
+        )
+        install (TARGETS d3d10trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+    endif ()
+
+    # d3d10_1.dll
+    if (DirectX_D3D10_1_INCLUDE_DIR)
+        include_directories (SYSTEM ${DirectX_D3D10_1_INCLUDE_DIR})
+        add_custom_command (
+            OUTPUT d3d10_1trace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d10_1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3d10_1trace.cpp
+            DEPENDS
+                d3d10_1trace.py
+                dlltrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10_1.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d10sdklayers.py
+                ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgi.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (d3d10_1trace MODULE d3d10_1.def d3d10_1trace.cpp)
+        target_link_libraries (d3d10_1trace
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (d3d10_1trace
+            PROPERTIES PREFIX ""
+            OUTPUT_NAME d3d10_1
+        )
+        install (TARGETS d3d10_1trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+    endif ()
+
+    # d3d11.dll
+    if (DirectX_D3D11_INCLUDE_DIR)
+        if (DirectX_D3D11_1_INCLUDE_DIR)
+            set (HAVE_D3D11_1 1)
+        else ()
+            set (HAVE_D3D11_1 0)
+        endif ()
+
+        include_directories (SYSTEM ${DirectX_D3D11_INCLUDE_DIR})
+        add_custom_command (
+            OUTPUT d3d11trace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3d11trace.py ${HAVE_D3D11_1} > ${CMAKE_CURRENT_BINARY_DIR}/d3d11trace.cpp
+            DEPENDS
+                d3d11trace.py
+                dlltrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d11_1.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d11.py
+                ${CMAKE_SOURCE_DIR}/specs/d3d11sdklayers.py
+                ${CMAKE_SOURCE_DIR}/specs/d3dcommon.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgi.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (d3d11trace MODULE d3d11.def d3d11trace.cpp)
+        target_link_libraries (d3d11trace
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (d3d11trace
+            PROPERTIES PREFIX ""
+            OUTPUT_NAME d3d11
+        )
+        install (TARGETS d3d11trace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+    endif ()
+
+    # d2d1.dll, dwrite.dll
+    if (DirectX_D2D1_INCLUDE_DIR)
+        include_directories (SYSTEM ${DirectX_D2D1_INCLUDE_DIR})
+
+        add_custom_command (
+            OUTPUT d2d1trace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d2d1trace.py > ${CMAKE_CURRENT_BINARY_DIR}/d2d1trace.cpp
+            DEPENDS
+                d2d1trace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/specs/d2d1.py
+                ${CMAKE_SOURCE_DIR}/specs/d2d1.py
+                ${CMAKE_SOURCE_DIR}/specs/d2dbasetypes.py
+                ${CMAKE_SOURCE_DIR}/specs/d2derr.py
+                ${CMAKE_SOURCE_DIR}/specs/dwrite.py
+                ${CMAKE_SOURCE_DIR}/specs/dcommon.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgi.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (d2d1 MODULE d2d1.def d2d1trace.cpp)
+        target_link_libraries (d2d1
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (d2d1
+            PROPERTIES PREFIX ""
+            OUTPUT_NAME d2d1
+        )
+        install (TARGETS d2d1 LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+
+        add_custom_command (
+            OUTPUT dwritetrace.cpp
+            COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dwritetrace.py > ${CMAKE_CURRENT_BINARY_DIR}/dwritetrace.cpp
+            DEPENDS
+                dwritetrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/specs/d2d1.py
+                ${CMAKE_SOURCE_DIR}/specs/d2d1.py
+                ${CMAKE_SOURCE_DIR}/specs/d2dbasetypes.py
+                ${CMAKE_SOURCE_DIR}/specs/d2derr.py
+                ${CMAKE_SOURCE_DIR}/specs/dwrite.py
+                ${CMAKE_SOURCE_DIR}/specs/dcommon.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgi.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgitype.py
+                ${CMAKE_SOURCE_DIR}/specs/dxgiformat.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+        )
+        add_library (dwrite MODULE dwrite.def dwritetrace.cpp)
+        target_link_libraries (dwrite
+            common_trace
+            common
+            ${ZLIB_LIBRARIES}
+            ${SNAPPY_LIBRARIES}
+        )
+        set_target_properties (dwrite
+            PROPERTIES PREFIX ""
+            OUTPUT_NAME dwrite
+        )
+        install (TARGETS dwrite LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+    endif (DirectX_D2D1_INCLUDE_DIR)
+
+    # opengl32.dll
+    add_custom_command (
+        OUTPUT wgltrace.cpp
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/wgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/wgltrace.cpp
+        DEPENDS
+                wgltrace.py
+                gltrace.py
+                trace.py
+                ${CMAKE_SOURCE_DIR}/dispatch/dispatch.py
+                ${CMAKE_SOURCE_DIR}/specs/wglapi.py
+                ${CMAKE_SOURCE_DIR}/specs/wglenum.py
+                ${CMAKE_SOURCE_DIR}/specs/glapi.py
+                ${CMAKE_SOURCE_DIR}/specs/glparams.py
+                ${CMAKE_SOURCE_DIR}/specs/gltypes.py
+                ${CMAKE_SOURCE_DIR}/specs/winapi.py
+                ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+    )
+    add_library (wgltrace MODULE opengl32.def
+        wgltrace.cpp
+        glcaps.cpp
+        gltrace_state.cpp
+    )
+    add_dependencies (wgltrace glproc)
+    target_link_libraries (wgltrace
+        glproc_gl
+        common_trace
+        common
+        ${ZLIB_LIBRARIES}
+        ${SNAPPY_LIBRARIES}
+    )
+    set_target_properties (wgltrace PROPERTIES
+        PREFIX ""
+        OUTPUT_NAME opengl32
+    )
+    install (TARGETS wgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+
+elseif (APPLE)
+    # OpenGL framework
+    add_custom_command (
+        OUTPUT cgltrace.cpp
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cgltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/cgltrace.cpp
+        DEPENDS
+            cgltrace.py
+            gltrace.py
+            trace.py
+            ${CMAKE_SOURCE_DIR}/specs/cglapi.py
+            ${CMAKE_SOURCE_DIR}/specs/glapi.py
+            ${CMAKE_SOURCE_DIR}/specs/glparams.py
+            ${CMAKE_SOURCE_DIR}/specs/gltypes.py
+            ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+    )
+
+    add_library (cgltrace SHARED
+        cgltrace.cpp
+        glcaps.cpp
+        gltrace_state.cpp
+    )
+
+    add_dependencies (cgltrace glproc)
+
+    set_target_properties (cgltrace PROPERTIES
+        # OpenGL framework name
+        PREFIX "" OUTPUT_NAME "OpenGL" SUFFIX ""
+        # Specificy the version and reexport GLU symbols
+        LINK_FLAGS "-compatibility_version 1 -current_version 1.0.0 -Wl,-reexport_library,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib"
+    )
+
+    target_link_libraries (cgltrace
+        glproc_gl
+        common_trace
+        common
+        ${ZLIB_LIBRARIES}
+        ${SNAPPY_LIBRARIES}
+        ${CMAKE_THREAD_LIBS_INIT}
+        dl
+    )
+
+    install (TARGETS cgltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+elseif (X11_FOUND)
+    # libGL.so
+    add_custom_command (
+        OUTPUT glxtrace.cpp
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glxtrace.py > ${CMAKE_CURRENT_BINARY_DIR}/glxtrace.cpp
+        DEPENDS
+            glxtrace.py
+            gltrace.py
+            trace.py
+            ${CMAKE_SOURCE_DIR}/specs/glxapi.py
+            ${CMAKE_SOURCE_DIR}/specs/glapi.py
+            ${CMAKE_SOURCE_DIR}/specs/glparams.py
+            ${CMAKE_SOURCE_DIR}/specs/gltypes.py
+            ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+    )
+
+    add_library (glxtrace SHARED
+        glxtrace.cpp
+        glcaps.cpp
+        gltrace_state.cpp
+    )
+
+    add_dependencies (glxtrace glproc)
+
+    set_target_properties (glxtrace PROPERTIES
+        # avoid the default "lib" prefix
+        PREFIX ""
+        # Prevent symbol relocations internal to our wrapper library to be
+        # overwritten by the application.
+        LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
+    )
+
+    target_link_libraries (glxtrace
+        glproc_gl
+        common_trace
+        common
+        ${ZLIB_LIBRARIES}
+        ${SNAPPY_LIBRARIES}
+        ${X11_X11_LIB}
+        ${CMAKE_THREAD_LIBS_INIT}
+        dl
+    )
+
+    install (TARGETS glxtrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+endif ()
+
+
+if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)
+    # libEGL.so/libGL.so
+    add_custom_command (
+        OUTPUT egltrace.cpp
+        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/egltrace.py > ${CMAKE_CURRENT_BINARY_DIR}/egltrace.cpp
+        DEPENDS
+            egltrace.py
+            gltrace.py
+            trace.py
+            ${CMAKE_SOURCE_DIR}/specs/eglapi.py
+            ${CMAKE_SOURCE_DIR}/specs/glesapi.py
+            ${CMAKE_SOURCE_DIR}/specs/glapi.py
+            ${CMAKE_SOURCE_DIR}/specs/glparams.py
+            ${CMAKE_SOURCE_DIR}/specs/gltypes.py
+            ${CMAKE_SOURCE_DIR}/specs/stdapi.py
+    )
+
+    add_library (egltrace SHARED
+        egltrace.cpp
+        glcaps.cpp
+        gltrace_state.cpp
+        ${CMAKE_SOURCE_DIR}/helpers/eglsize.cpp
+    )
+
+    add_dependencies (egltrace glproc)
+
+    set_target_properties (egltrace PROPERTIES
+        # avoid the default "lib" prefix
+        PREFIX ""
+        # Prevent symbol relocations internal to our wrapper library to be
+        # overwritten by the application.
+        LINK_FLAGS "-Wl,-Bsymbolic -Wl,-Bsymbolic-functions"
+    )
+
+    target_link_libraries (egltrace
+        glproc_egl
+        common_trace
+        common
+        ${ZLIB_LIBRARIES}
+        ${SNAPPY_LIBRARIES}
+        ${CMAKE_THREAD_LIBS_INIT}
+        dl
+    )
+
+    install (TARGETS egltrace LIBRARY DESTINATION ${WRAPPER_INSTALL_DIR})
+endif ()
diff --git a/wrappers/cgltrace.py b/wrappers/cgltrace.py
new file mode 100644 (file)
index 0000000..e7cbd7b
--- /dev/null
@@ -0,0 +1,107 @@
+##########################################################################
+#
+# Copyright 2011 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""CGL tracing generator."""
+
+
+from gltrace import GlTracer
+from specs.stdapi import API
+from specs.glapi import glapi
+from specs.cglapi import cglapi
+
+
+class CglTracer(GlTracer):
+
+    def isFunctionPublic(self, function):
+        # all OpenGL symbols are visible on MacOSX
+        return True
+
+    def traceFunctionImplBody(self, function):
+        if function.name == 'CGLReleaseContext':
+            # Unlike other GL APIs like EGL or GLX, CGL will make the context
+            # not current if it's the current context.
+            print '    if (_CGLGetContextRetainCount(ctx) == 1) {'
+            print '        if (gltrace::releaseContext((uintptr_t)ctx)) {'
+            print '            if (_CGLGetCurrentContext() == ctx) {'
+            print '                gltrace::clearContext();'
+            print '            }'
+            print '        }'
+            print '    }'
+
+        if function.name == 'CGLDestroyContext':
+            # The same rule applies here about the  as for CGLReleaseContext.
+            print '    if (gltrace::releaseContext((uintptr_t)ctx)) {'
+            print '        if (_CGLGetCurrentContext() == ctx) {'
+            print '            gltrace::clearContext();'
+            print '        }'
+            print '    }'
+
+        GlTracer.traceFunctionImplBody(self, function)
+
+        if function.name == 'CGLCreateContext':
+            print '    if (_result == kCGLNoError) {'
+            print '        gltrace::createContext((uintptr_t)*ctx);'
+            print '    }'
+
+        if function.name == 'CGLSetCurrentContext':
+            print '    if (_result == kCGLNoError) {'
+            print '        if (ctx != NULL) {'
+            print '            gltrace::setContext((uintptr_t)ctx);'
+            print '        } else {'
+            print '            gltrace::clearContext();'
+            print '        }'
+            print '    }'
+
+        if function.name == 'CGLRetainContext':
+            print '    gltrace::retainContext((uintptr_t)ctx);'
+
+
+if __name__ == '__main__':
+    print
+    print '#include <stdlib.h>'
+    print '#include <string.h>'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print
+    print '// To validate our prototypes'
+    print '#define GL_GLEXT_PROTOTYPES'
+    print
+    print '#include "glproc.hpp"'
+    print '#include "glsize.hpp"'
+    print
+
+    api = API()
+    api.addApi(cglapi)
+    api.addApi(glapi)
+    tracer = CglTracer()
+    tracer.traceApi(api)
+
+    print r'''
+
+PUBLIC
+void * gll_noop = 0;
+
+'''
diff --git a/wrappers/d2d1.def b/wrappers/d2d1.def
new file mode 100644 (file)
index 0000000..58c897b
--- /dev/null
@@ -0,0 +1,8 @@
+LIBRARY "d2d1"
+
+EXPORTS
+       D2D1CreateFactory
+       D2D1InvertMatrix
+       D2D1IsMatrixInvertible
+       D2D1MakeRotateMatrix
+       D2D1MakeSkewMatrix
diff --git a/wrappers/d2d1trace.py b/wrappers/d2d1trace.py
new file mode 100644 (file)
index 0000000..a614285
--- /dev/null
@@ -0,0 +1,55 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dlltrace import DllTracer
+from specs.d2d1 import d2d1
+
+
+class D2D1Tracer(DllTracer):
+
+    def wrapArg(self, function, arg):
+        if function.name == 'D2D1CreateFactory' and arg.output:
+            print '    if (*%s) {' % arg.name
+            for iface in d2d1.interfaces:
+                print '        if (riid == IID_%s) {' % iface.name
+                print '            *%s = (LPVOID) new Wrap%s((%s *)*%s);' % (arg.name, iface.name, iface.name, arg.name)
+                print '        }'
+            print '    }'
+        else:
+            DllTracer.wrapArg(self, function, arg)
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '#include "d2dimports.hpp"'
+    print
+
+    tracer = D2D1Tracer('d2d1.dll')
+    tracer.traceApi(d2d1)
diff --git a/wrappers/d3d10.def b/wrappers/d3d10.def
new file mode 100644 (file)
index 0000000..65d9786
--- /dev/null
@@ -0,0 +1,31 @@
+LIBRARY "d3d10.dll"
+EXPORTS
+       D3D10CompileEffectFromMemory
+       D3D10CompileShader
+       D3D10CreateBlob
+       D3D10CreateDevice
+       D3D10CreateDeviceAndSwapChain
+       D3D10CreateEffectFromMemory
+       D3D10CreateEffectPoolFromMemory
+       D3D10CreateStateBlock
+       D3D10DisassembleEffect
+       D3D10DisassembleShader
+       D3D10GetGeometryShaderProfile
+       D3D10GetInputAndOutputSignatureBlob
+       D3D10GetInputSignatureBlob
+       D3D10GetOutputSignatureBlob
+       D3D10GetPixelShaderProfile
+       D3D10GetShaderDebugInfo
+       D3D10GetVersion
+       D3D10GetVertexShaderProfile
+       D3D10PreprocessShader
+       D3D10ReflectShader
+       D3D10RegisterLayers
+       D3D10StateBlockMaskDifference
+       D3D10StateBlockMaskDisableAll
+       D3D10StateBlockMaskDisableCapture
+       D3D10StateBlockMaskEnableAll
+       D3D10StateBlockMaskEnableCapture
+       D3D10StateBlockMaskGetSetting
+       D3D10StateBlockMaskIntersect
+       D3D10StateBlockMaskUnion
diff --git a/wrappers/d3d10_1.def b/wrappers/d3d10_1.def
new file mode 100644 (file)
index 0000000..48bfe14
--- /dev/null
@@ -0,0 +1,6 @@
+LIBRARY        "d3d10_1"
+
+EXPORTS
+        D3D10CreateDevice1
+        D3D10CreateDeviceAndSwapChain1
+        D3D10CreateBlob
diff --git a/wrappers/d3d10_1trace.py b/wrappers/d3d10_1trace.py
new file mode 100644 (file)
index 0000000..485ec32
--- /dev/null
@@ -0,0 +1,40 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dlltrace import DllTracer
+from specs.d3d10_1 import d3d10_1
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '#include "d3d10_1imports.hpp"'
+    print
+    tracer = DllTracer('d3d10_1.dll')
+    tracer.traceApi(d3d10_1)
diff --git a/wrappers/d3d10shader.cpp b/wrappers/d3d10shader.cpp
new file mode 100644 (file)
index 0000000..3670f2f
--- /dev/null
@@ -0,0 +1,115 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * Copyright 2008-2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <stdio.h>
+
+#include "d3d10shader.hpp"
+
+
+struct ID3D10Blob : public IUnknown {
+public:
+    virtual LPVOID STDMETHODCALLTYPE GetBufferPointer( void) = 0;
+    virtual SIZE_T STDMETHODCALLTYPE GetBufferSize( void) = 0;
+};
+
+typedef ID3D10Blob ID3DBlob;
+typedef ID3DBlob* LPD3DBLOB;
+
+#define D3D_DISASM_ENABLE_COLOR_CODE            0x00000001
+#define D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS  0x00000002
+#define D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING 0x00000004
+#define D3D_DISASM_ENABLE_INSTRUCTION_CYCLE     0x00000008
+#define D3D_DISASM_DISABLE_DEBUG_INFO           0x00000010
+#define D3D_DISASM_ENABLE_INSTRUCTION_OFFSET    0x00000020
+#define D3D_DISASM_INSTRUCTION_ONLY             0x00000040
+
+typedef HRESULT
+(WINAPI *PFND3DDISASSEMBLE)(
+    LPCVOID pSrcData,
+    SIZE_T SrcDataSize,
+    UINT Flags,
+    LPCSTR szComments,
+    ID3DBlob **ppDisassembly
+);
+
+
+static HMODULE hD3DCompilerModule = NULL;
+static PFND3DDISASSEMBLE pfnD3DDisassemble = NULL;
+
+
+void DumpShader(trace::Writer &writer, const void *pShaderBytecode, SIZE_T BytecodeLength)
+{
+    static BOOL firsttime = TRUE;
+
+    if (firsttime) {
+        if (!hD3DCompilerModule) {
+            int version;
+            for (version = 44; version >= 33; --version) {
+                char filename[256];
+                _snprintf(filename, sizeof(filename), "d3dcompiler_%u.dll", version);
+                hD3DCompilerModule = LoadLibraryA(filename);
+                if (hD3DCompilerModule) {
+                    break;
+                }
+            }
+        }
+
+        if (hD3DCompilerModule) {
+            if (!pfnD3DDisassemble) {
+                pfnD3DDisassemble = (PFND3DDISASSEMBLE)GetProcAddress(hD3DCompilerModule, "D3DDisassemble");
+            }
+        }
+
+        firsttime = FALSE;
+    }
+
+    /*
+     * TODO: Fallback to D3D10DisassembleShader, which should be always present.
+     */
+
+    LPD3DBLOB pDisassembly = NULL;
+    HRESULT hr = E_FAIL;
+
+    if (pfnD3DDisassemble) {
+        hr = pfnD3DDisassemble(pShaderBytecode, BytecodeLength, 0, NULL, &pDisassembly);
+    }
+
+    if (SUCCEEDED(hr)) {
+        writer.beginRepr();
+        writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize());
+    }
+
+    writer.writeBlob(pShaderBytecode, BytecodeLength);
+
+    if (pDisassembly) {
+        pDisassembly->Release();
+    }
+    
+    if (SUCCEEDED(hr)) {
+        writer.endRepr();
+    }
+}
diff --git a/wrappers/d3d10shader.hpp b/wrappers/d3d10shader.hpp
new file mode 100644 (file)
index 0000000..b447b48
--- /dev/null
@@ -0,0 +1,38 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * Copyright 2008-2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _D3D10SHADER_HPP_
+#define _D3D10SHADER_HPP_
+
+
+#include <windows.h>
+
+#include "trace_writer.hpp"
+
+void DumpShader(trace::Writer &writer, const void *pShaderBytecode, SIZE_T BytecodeLength);
+
+
+#endif /* _D3D10SHADER_HPP_ */
diff --git a/wrappers/d3d10trace.py b/wrappers/d3d10trace.py
new file mode 100644 (file)
index 0000000..d43f042
--- /dev/null
@@ -0,0 +1,52 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dlltrace import DllTracer
+from specs import stdapi
+from specs.d3d10misc import d3d10
+
+
+class D3D10Tracer(DllTracer):
+
+    def serializeArgValue(self, function, arg):
+        # Dump shaders as strings
+        if isinstance(arg.type, stdapi.Blob) and arg.name.startswith('pShaderBytecode'):
+            print '    DumpShader(trace::localWriter, %s, %s);' % (arg.name, arg.type.size)
+            return
+
+        DllTracer.serializeArgValue(self, function, arg)
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '#include "d3d10imports.hpp"'
+    print '#include "d3d10shader.hpp"'
+    print
+    tracer = D3D10Tracer('d3d10.dll')
+    tracer.traceApi(d3d10)
diff --git a/wrappers/d3d11.def b/wrappers/d3d11.def
new file mode 100644 (file)
index 0000000..49333b6
--- /dev/null
@@ -0,0 +1,9 @@
+LIBRARY        "d3d11"
+
+EXPORTS
+        D3D11CoreCreateDevice
+        D3D11CoreCreateLayeredDevice
+        D3D11CoreGetLayeredDeviceSize
+        D3D11CoreRegisterLayers
+        D3D11CreateDevice
+        D3D11CreateDeviceAndSwapChain
diff --git a/wrappers/d3d11trace.py b/wrappers/d3d11trace.py
new file mode 100644 (file)
index 0000000..80e855f
--- /dev/null
@@ -0,0 +1,48 @@
+##########################################################################
+#
+# Copyright 2008-2012 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+import sys
+
+from dlltrace import DllTracer
+from specs.d3d11 import d3d11
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '#include "d3d11imports.hpp"'
+    print
+
+    if int(sys.argv[1]):
+        import specs.d3d11_1
+        print '#include <d3d11_1.h>'
+        print
+
+    tracer = DllTracer('d3d11.dll')
+    tracer.traceApi(d3d11)
diff --git a/wrappers/d3d8.def b/wrappers/d3d8.def
new file mode 100644 (file)
index 0000000..5134cb8
--- /dev/null
@@ -0,0 +1,4 @@
+LIBRARY        "d3d8"
+
+EXPORTS
+        Direct3DCreate8 @1
diff --git a/wrappers/d3d8trace.py b/wrappers/d3d8trace.py
new file mode 100644 (file)
index 0000000..0bf4bb8
--- /dev/null
@@ -0,0 +1,54 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dlltrace import DllTracer
+from specs.d3d8 import d3d8
+
+
+class D3D8Tracer(DllTracer):
+
+    def serializeArgValue(self, function, arg):
+        # Dump shaders as strings
+        if function.name in ('CreateVertexShader', 'CreatePixelShader') and arg.name == 'pFunction':
+            print '    DumpShader(trace::localWriter, %s);' % (arg.name)
+            return
+
+        DllTracer.serializeArgValue(self, function, arg)
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include <windows.h>'
+    print '#include <d3d8.h>'
+    print '#include "d3d9shader.hpp"'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    tracer = D3D8Tracer('d3d8.dll')
+    tracer.traceApi(d3d8)
+
diff --git a/wrappers/d3d9.def b/wrappers/d3d9.def
new file mode 100644 (file)
index 0000000..dbbb029
--- /dev/null
@@ -0,0 +1,12 @@
+LIBRARY        "d3d9"
+
+EXPORTS
+        Direct3DCreate9
+        Direct3DCreate9Ex
+        D3DPERF_BeginEvent
+        D3DPERF_EndEvent
+        D3DPERF_SetMarker
+        D3DPERF_SetRegion
+        D3DPERF_QueryRepeatFrame
+        D3DPERF_SetOptions
+        D3DPERF_GetStatus
diff --git a/wrappers/d3d9shader.cpp b/wrappers/d3d9shader.cpp
new file mode 100644 (file)
index 0000000..f44cad3
--- /dev/null
@@ -0,0 +1,105 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * Copyright 2008-2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <stdio.h>
+
+#include "d3d9shader.hpp"
+#include "d3d9imports.hpp"
+#include "d3dsize.hpp"
+
+
+typedef HRESULT
+(WINAPI *PD3DXDISASSEMBLESHADER)(
+    CONST DWORD *pShader,
+    BOOL EnableColorCode,
+    LPCSTR pComments,
+    LPD3DXBUFFER *ppDisassembly
+);
+
+
+void DumpShader(trace::Writer &writer, const DWORD *tokens)
+{
+    static BOOL firsttime = TRUE;
+
+    /*
+     * TODO: Consider using d3dcompile_xx.dll per
+     * http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx
+     */
+
+    static HMODULE hD3DXModule = NULL;
+    static PD3DXDISASSEMBLESHADER pfnD3DXDisassembleShader = NULL;
+
+    if (firsttime) {
+        if (!hD3DXModule) {
+            unsigned release;
+            int version;
+            for (release = 0; release <= 1; ++release) {
+                /* Version 41 corresponds to Mar 2009 version of DirectX Runtime / SDK */
+                for (version = 41; version >= 0; --version) {
+                    char filename[256];
+                    _snprintf(filename, sizeof(filename),
+                              "d3dx9%s%s%u.dll", release ? "" : "d", version ? "_" : "", version);
+                    hD3DXModule = LoadLibraryA(filename);
+                    if (hD3DXModule)
+                        goto found;
+                }
+            }
+found:
+            ;
+        }
+
+        if (hD3DXModule) {
+            if (!pfnD3DXDisassembleShader) {
+                pfnD3DXDisassembleShader = (PD3DXDISASSEMBLESHADER)GetProcAddress(hD3DXModule, "D3DXDisassembleShader");
+            }
+        }
+
+        firsttime = FALSE;
+    }
+
+    LPD3DXBUFFER pDisassembly = NULL;
+    HRESULT hr = E_FAIL;
+
+    if (pfnD3DXDisassembleShader) {
+        hr = pfnD3DXDisassembleShader(tokens, FALSE, NULL, &pDisassembly);
+    }
+
+    if (SUCCEEDED(hr)) {
+        writer.beginRepr();
+        writer.writeString((const char *)pDisassembly->GetBufferPointer(), pDisassembly->GetBufferSize());
+    }
+
+    writer.writeBlob(tokens, _shaderSize(tokens));
+
+    if (pDisassembly) {
+        pDisassembly->Release();
+    }
+    
+    if (SUCCEEDED(hr)) {
+        writer.endRepr();
+    }
+}
diff --git a/wrappers/d3d9shader.hpp b/wrappers/d3d9shader.hpp
new file mode 100644 (file)
index 0000000..340f03b
--- /dev/null
@@ -0,0 +1,38 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * Copyright 2008-2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _D3D9SHADER_HPP_
+#define _D3D9SHADER_HPP_
+
+
+#include <windows.h>
+
+#include "trace_writer.hpp"
+
+void DumpShader(trace::Writer &writer, const DWORD *tokens);
+
+
+#endif /* _D3D9SHADER_HPP_ */
diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py
new file mode 100644 (file)
index 0000000..6ee059f
--- /dev/null
@@ -0,0 +1,95 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dlltrace import DllTracer
+from specs.d3d9 import d3d9, D3DSHADER9
+
+
+class D3D9Tracer(DllTracer):
+
+    def serializeArgValue(self, function, arg):
+        # Dump shaders as strings
+        if arg.type is D3DSHADER9:
+            print '    DumpShader(trace::localWriter, %s);' % (arg.name)
+            return
+
+        DllTracer.serializeArgValue(self, function, arg)
+
+    def enumWrapperInterfaceVariables(self, interface):
+        variables = DllTracer.enumWrapperInterfaceVariables(self, interface)
+        
+        if interface.getMethodByName('Lock') is not None or \
+           interface.getMethodByName('LockRect') is not None or \
+           interface.getMethodByName('LockBox') is not None:
+            variables += [
+                ('size_t', '_LockedSize', '0'),
+                ('VOID *', 'm_pbData', '0'),
+            ]
+
+        return variables
+
+    def implementWrapperInterfaceMethodBody(self, interface, base, method):
+        if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'):
+            print '    if (_LockedSize && m_pbData) {'
+            self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', '_LockedSize')
+            print '    }'
+
+        DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method)
+
+        if method.name in ('Lock', 'LockRect', 'LockBox'):
+            # FIXME: handle recursive locks
+            print '    if (SUCCEEDED(_result) && !(Flags & D3DLOCK_READONLY)) {'
+            print '        _getLockInfo(_this, %s, m_pbData, _LockedSize);' % ', '.join(method.argNames()[:-1])
+            print '    } else {'
+            print '        m_pbData = NULL;'
+            print '        _LockedSize = 0;'
+            print '    }'
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '#include "d3d9imports.hpp"'
+    print '#include "d3dsize.hpp"'
+    print '#include "d3d9shader.hpp"'
+    print
+    print '''
+static inline size_t
+_declCount(const D3DVERTEXELEMENT9 *pVertexElements) {
+    size_t count = 0;
+    if (pVertexElements) {
+        while (pVertexElements[count++].Stream != 0xff)
+            ;
+    }
+    return count;
+}
+'''
+    tracer = D3D9Tracer('d3d9.dll')
+    tracer.traceApi(d3d9)
+
diff --git a/wrappers/ddraw.def b/wrappers/ddraw.def
new file mode 100644 (file)
index 0000000..6186c60
--- /dev/null
@@ -0,0 +1,23 @@
+EXPORTS
+        AcquireDDThreadLock
+        CompleteCreateSysmemSurface
+        D3DParseUnknownCommand
+        DDGetAttachedSurfaceLcl
+        DDInternalLock
+        DDInternalUnlock
+        DirectDrawCreate
+        DirectDrawCreateClipper
+        DirectDrawCreateEx
+        DirectDrawEnumerateA
+        DirectDrawEnumerateExA
+        DirectDrawEnumerateExW
+        DirectDrawEnumerateW
+        DllCanUnloadNow PRIVATE
+        DllGetClassObject PRIVATE
+        DSoundHelp
+        GetDDSurfaceLocal
+        GetOLEThunkData
+        GetSurfaceFromDC
+        RegisterSpecialCase
+        ReleaseDDThreadLock
+        ;SetAppCompatData
diff --git a/wrappers/ddrawtrace.py b/wrappers/ddrawtrace.py
new file mode 100644 (file)
index 0000000..b575c77
--- /dev/null
@@ -0,0 +1,70 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dlltrace import DllTracer
+from specs.d3d import ddraw, interfaces
+
+
+class DDrawTracer(DllTracer):
+
+    def traceFunctionImplBody(self, function):
+        if function.name in ('AcquireDDThreadLock', 'ReleaseDDThreadLock'):
+            self.invokeFunction(function)
+            return
+
+        DllTracer.traceFunctionImplBody(self, function)
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print '#include <windows.h>'
+    print '#include <ddraw.h>'
+    print '#include <d3d.h>'
+    print
+    print '''
+
+#ifndef DDBLT_EXTENDED_FLAGS
+#define DDBLT_EXTENDED_FLAGS 0x40000000l
+#endif
+
+#ifndef DDBLT_EXTENDED_LINEAR_CONTENT
+#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l
+#endif
+
+#ifndef D3DLIGHT_PARALLELPOINT
+#define D3DLIGHT_PARALLELPOINT (D3DLIGHTTYPE)4
+#endif
+
+#ifndef D3DLIGHT_GLSPOT
+#define D3DLIGHT_GLSPOT (D3DLIGHTTYPE)5
+#endif
+
+'''
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    tracer = DDrawTracer('ddraw.dll')
+    tracer.traceApi(ddraw)
diff --git a/wrappers/dlltrace.py b/wrappers/dlltrace.py
new file mode 100644 (file)
index 0000000..8456d5f
--- /dev/null
@@ -0,0 +1,69 @@
+##########################################################################
+#
+# Copyright 2008-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+"""Trace code generation for Windows DLLs."""
+
+
+from trace import Tracer
+from dispatch import Dispatcher
+
+
+class DllTracer(Tracer):
+
+    def __init__(self, dllname):
+        self.dllname = dllname
+    
+    def header(self, api):
+        print '''
+static HMODULE g_hDll = NULL;
+
+static PROC
+_getPublicProcAddress(LPCSTR lpProcName)
+{
+    if (!g_hDll) {
+        char szDll[MAX_PATH] = {0};
+        
+        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
+            return NULL;
+        }
+        
+        strcat(szDll, "\\\\%s");
+        
+        g_hDll = LoadLibraryA(szDll);
+        if (!g_hDll) {
+            return NULL;
+        }
+    }
+        
+    return GetProcAddress(g_hDll, lpProcName);
+}
+
+''' % self.dllname
+
+        dispatcher = Dispatcher()
+        dispatcher.dispatchApi(api)
+
+        Tracer.header(self, api)
+
diff --git a/wrappers/dwrite.def b/wrappers/dwrite.def
new file mode 100644 (file)
index 0000000..4cc6785
--- /dev/null
@@ -0,0 +1,4 @@
+LIBRARY "d2d1"
+
+EXPORTS
+       DWriteCreateFactory
diff --git a/wrappers/dwritetrace.py b/wrappers/dwritetrace.py
new file mode 100644 (file)
index 0000000..7fb77e2
--- /dev/null
@@ -0,0 +1,58 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from dlltrace import DllTracer
+from specs.dwrite import dwrite
+from specs.d2d1 import d2d1 # cyclic dependency
+
+
+class DWriteTracer(DllTracer):
+
+    def wrapArg(self, function, arg):
+        if function.name == 'DWriteCreateFactory' and arg.output:
+            print '    if (*%s) {' % arg.name
+            for iface in dwrite.interfaces:
+                print '        if (iid == IID_%s) {' % iface.name
+                print '            *%s = new Wrap%s(static_cast<%s *>(*%s));' % (arg.name, iface.name, iface.name, arg.name)
+                print '        }'
+            print '    }'
+        else:
+            DllTracer.wrapArg(self, function, arg)
+
+
+if __name__ == '__main__':
+    print '#define INITGUID'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '#define DWRITE_EXPORT WINAPI'
+    print
+    print '#include "d2dimports.hpp"'
+    print
+
+    tracer = DWriteTracer('dwrite.dll')
+    tracer.traceApi(dwrite)
diff --git a/wrappers/egltrace.py b/wrappers/egltrace.py
new file mode 100644 (file)
index 0000000..a6ff17f
--- /dev/null
@@ -0,0 +1,281 @@
+##########################################################################
+#
+# Copyright 2011 LunarG, Inc.
+# All Rights Reserved.
+#
+# Based on glxtrace.py, which has
+#
+#   Copyright 2011 Jose Fonseca
+#   Copyright 2008-2010 VMware, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""EGL tracing generator."""
+
+
+from gltrace import GlTracer
+from specs.stdapi import API
+from specs.glapi import glapi
+from specs.eglapi import eglapi
+from specs.glesapi import glesapi
+
+
+class EglTracer(GlTracer):
+
+    def isFunctionPublic(self, function):
+        # The symbols visible in libEGL.so can vary, so expose them all
+        return True
+
+    getProcAddressFunctionNames = [
+        "eglGetProcAddress",
+    ]
+
+    def traceFunctionImplBody(self, function):
+        GlTracer.traceFunctionImplBody(self, function)
+
+        if function.name == 'eglCreateContext':
+            print '    if (_result != EGL_NO_CONTEXT)'
+            print '        gltrace::createContext((uintptr_t)_result);'
+
+        if function.name == 'eglMakeCurrent':
+            print '    if (_result) {'
+            print '        // update the profile'
+            print '        if (ctx != EGL_NO_CONTEXT) {'
+            print '            EGLint api = EGL_OPENGL_ES_API, version = 1;'
+            print '            gltrace::setContext((uintptr_t)ctx);'
+            print '            gltrace::Context *tr = gltrace::getContext();'
+            print '            _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);'
+            print '            _eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &version);'
+            print '            if (api == EGL_OPENGL_API)'
+            print '                tr->profile = gltrace::PROFILE_COMPAT;'
+            print '            else if (version == 1)'
+            print '                tr->profile = gltrace::PROFILE_ES1;'
+            print '            else'
+            print '                tr->profile = gltrace::PROFILE_ES2;'
+            print '        } else {'
+            print '            gltrace::clearContext();'
+            print '        }'
+            print '    }'
+
+        if function.name == 'eglDestroyContext':
+            print '    if (_result) {'
+            print '        gltrace::releaseContext((uintptr_t)ctx);'
+            print '    }'
+
+        if function.name == 'glEGLImageTargetTexture2DOES':
+            print '    image_info *info = _EGLImageKHR_get_image_info(target, image);'
+            print '    if (info) {'
+            print '        GLint level = 0;'
+            print '        GLint internalformat = info->internalformat;'
+            print '        GLsizei width = info->width;'
+            print '        GLsizei height = info->height;'
+            print '        GLint border = 0;'
+            print '        GLenum format = info->format;'
+            print '        GLenum type = info->type;'
+            print '        const GLvoid * pixels = info->pixels;'
+            self.emitFakeTexture2D()
+            print '        _EGLImageKHR_free_image_info(info);'
+            print '    }'
+
+    def emitFakeTexture2D(self):
+        function = glapi.getFunctionByName('glTexImage2D')
+        instances = function.argNames()
+        print '        unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
+        for arg in function.args:
+            assert not arg.output
+            self.serializeArg(function, arg)
+        print '        trace::localWriter.endEnter();'
+        print '        trace::localWriter.beginLeave(_fake_call);'
+        print '        trace::localWriter.endLeave();'
+
+
+
+if __name__ == '__main__':
+    print '#include <stdlib.h>'
+    print '#include <string.h>'
+    print '#include <dlfcn.h>'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print
+    print '// To validate our prototypes'
+    print '#define GL_GLEXT_PROTOTYPES'
+    print '#define EGL_EGLEXT_PROTOTYPES'
+    print
+    print '#include "glproc.hpp"'
+    print '#include "glsize.hpp"'
+    print '#include "eglsize.hpp"'
+    print
+    
+    api = API()
+    api.addApi(eglapi)
+    api.addApi(glapi)
+    api.addApi(glesapi)
+    tracer = EglTracer()
+    tracer.traceApi(api)
+
+    print r'''
+
+
+/*
+ * Android does not support LD_PRELOAD.
+ */
+#if !defined(ANDROID)
+
+
+/*
+ * Invoke the true dlopen() function.
+ */
+static void *_dlopen(const char *filename, int flag)
+{
+    typedef void * (*PFN_DLOPEN)(const char *, int);
+    static PFN_DLOPEN dlopen_ptr = NULL;
+
+    if (!dlopen_ptr) {
+        dlopen_ptr = (PFN_DLOPEN)dlsym(RTLD_NEXT, "dlopen");
+        if (!dlopen_ptr) {
+            os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n");
+            return NULL;
+        }
+    }
+
+    return dlopen_ptr(filename, flag);
+}
+
+
+/*
+ * Several applications, such as Quake3, use dlopen("libGL.so.1"), but
+ * LD_PRELOAD does not intercept symbols obtained via dlopen/dlsym, therefore
+ * we need to intercept the dlopen() call here, and redirect to our wrapper
+ * shared object.
+ */
+extern "C" PUBLIC
+void * dlopen(const char *filename, int flag)
+{
+    bool intercept = false;
+
+    if (filename) {
+        intercept =
+            strcmp(filename, "libEGL.so") == 0 ||
+            strcmp(filename, "libEGL.so.1") == 0 ||
+            strcmp(filename, "libGLESv1_CM.so") == 0 ||
+            strcmp(filename, "libGLESv1_CM.so.1") == 0 ||
+            strcmp(filename, "libGLESv2.so") == 0 ||
+            strcmp(filename, "libGLESv2.so.2") == 0 ||
+            strcmp(filename, "libGL.so") == 0 ||
+            strcmp(filename, "libGL.so.1") == 0;
+
+        if (intercept) {
+            os::log("apitrace: redirecting dlopen(\"%s\", 0x%x)\n", filename, flag);
+
+            /* The current dispatch implementation relies on core entry-points to be globally available, so force this.
+             *
+             * TODO: A better approach would be note down the entry points here and
+             * use them latter. Another alternative would be to reopen the library
+             * with RTLD_NOLOAD | RTLD_GLOBAL.
+             */
+            flag &= ~RTLD_LOCAL;
+            flag |= RTLD_GLOBAL;
+        }
+    }
+
+    void *handle = _dlopen(filename, flag);
+
+    if (intercept) {
+        // Get the file path for our shared object, and use it instead
+        static int dummy = 0xdeedbeef;
+        Dl_info info;
+        if (dladdr(&dummy, &info)) {
+            handle = _dlopen(info.dli_fname, flag);
+        } else {
+            os::log("apitrace: warning: dladdr() failed\n");
+        }
+    }
+
+    return handle;
+}
+
+
+#endif /* !ANDROID */
+
+
+#if defined(ANDROID)
+
+/*
+ * Undocumented Android extensions used by Dalvik which have bound information
+ * passed to it, but is currently ignored, so probably unreliable.
+ *
+ * See:
+ * https://github.com/android/platform_frameworks_base/blob/master/opengl/libs/GLES_CM/gl.cpp
+ */
+
+extern "C" PUBLIC
+void APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer, GLsizei count) {
+    (void)count;
+    glColorPointer(size, type, stride, pointer);
+}
+
+extern "C" PUBLIC
+void APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride, const GLvoid * pointer, GLsizei count) {
+    (void)count;
+    glNormalPointer(type, stride, pointer);
+}
+
+extern "C" PUBLIC
+void APIENTRY glTexCoordPointerBounds(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer, GLsizei count) {
+    (void)count;
+    glTexCoordPointer(size, type, stride, pointer);
+}
+
+extern "C" PUBLIC
+void APIENTRY glVertexPointerBounds(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer, GLsizei count) {
+    (void)count;
+    glVertexPointer(size, type, stride, pointer);
+}
+
+extern "C" PUBLIC
+void GL_APIENTRY glPointSizePointerOESBounds(GLenum type, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    (void)count;
+    glPointSizePointerOES(type, stride, pointer);
+}
+
+extern "C" PUBLIC
+void APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    (void)count;
+    glMatrixIndexPointerOES(size, type, stride, pointer);
+}
+
+extern "C" PUBLIC
+void APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    (void)count;
+    glWeightPointerOES(size, type, stride, pointer);
+}
+
+/*
+ * There is also a glVertexAttribPointerBounds in
+ * https://github.com/android/platform_frameworks_base/blob/master/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp
+ * but is it not exported.
+ */
+
+#endif /* ANDROID */
+
+
+'''
diff --git a/wrappers/glcaps.cpp b/wrappers/glcaps.cpp
new file mode 100644 (file)
index 0000000..1f2bbe6
--- /dev/null
@@ -0,0 +1,226 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/*
+ * Manipulation of GL extensions.
+ *
+ * So far we insert GREMEDY extensions, but in the future we could also clamp
+ * the GL extensions to core GL versions here.
+ */
+
+
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <string>
+#include <map>
+
+#include "glproc.hpp"
+#include "gltrace.hpp"
+
+
+namespace gltrace {
+
+
+typedef std::map<std::string, const char *> ExtensionsMap;
+
+// Cache of the translated extensions strings
+static ExtensionsMap extensionsMap;
+
+
+// Additional extensions to be advertised
+static const char *
+extraExtension_stringsFull[] = {
+    "GL_GREMEDY_string_marker",
+    "GL_GREMEDY_frame_terminator",
+};
+
+static const char *
+extraExtension_stringsES[] = {
+    "GL_EXT_debug_marker",
+};
+
+// Description of additional extensions we want to advertise
+struct ExtensionsDesc
+{
+    unsigned numStrings;
+    const char **strings;
+};
+
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
+
+const struct ExtensionsDesc
+extraExtensionsFull = {
+    ARRAY_SIZE(extraExtension_stringsFull),
+    extraExtension_stringsFull
+};
+
+const struct ExtensionsDesc
+extraExtensionsES = {
+    ARRAY_SIZE(extraExtension_stringsES),
+    extraExtension_stringsES
+};
+
+
+const struct ExtensionsDesc *
+getExtraExtensions(void)
+{
+    Context *ctx = getContext();
+
+    switch (ctx->profile) {
+    case PROFILE_COMPAT:
+        return &extraExtensionsFull;
+    case PROFILE_ES1:
+    case PROFILE_ES2:
+        return &extraExtensionsES;
+    default:
+        assert(0);
+        return &extraExtensionsFull;
+    }
+}
+
+
+/**
+ * Translate the GL extensions string, adding new extensions.
+ */
+static const char *
+overrideExtensionsString(const char *extensions)
+{
+    const ExtensionsDesc *desc = getExtraExtensions();
+    size_t i;
+
+    ExtensionsMap::const_iterator it = extensionsMap.find(extensions);
+    if (it != extensionsMap.end()) {
+        return it->second;
+    }
+
+    size_t extensionsLen = strlen(extensions);
+
+    size_t extraExtensionsLen = 0;
+    for (i = 0; i < desc->numStrings; ++i) {
+        const char * extraExtension = desc->strings[i];
+        size_t extraExtensionLen = strlen(extraExtension);
+        extraExtensionsLen += extraExtensionLen + 1;
+    }
+
+    // We use malloc memory instead of a std::string because we need to ensure
+    // that extensions strings will not move in memory as the extensionsMap is
+    // updated.
+    size_t newExtensionsLen = extensionsLen + 1 + extraExtensionsLen + 1;
+    char *newExtensions = (char *)malloc(newExtensionsLen);
+    if (!newExtensions) {
+        return extensions;
+    }
+
+    if (extensionsLen) {
+        memcpy(newExtensions, extensions, extensionsLen);
+
+        // Add space separator if necessary
+        if (newExtensions[extensionsLen - 1] != ' ') {
+            newExtensions[extensionsLen++] = ' ';
+        }
+    }
+
+    for (i = 0; i < desc->numStrings; ++i) {
+        const char * extraExtension = desc->strings[i];
+        size_t extraExtensionLen = strlen(extraExtension);
+        memcpy(newExtensions + extensionsLen, extraExtension, extraExtensionLen);
+        extensionsLen += extraExtensionLen;
+        newExtensions[extensionsLen++] = ' ';
+    }
+    newExtensions[extensionsLen++] = '\0';
+    assert(extensionsLen <= newExtensionsLen);
+
+    extensionsMap[extensions] = newExtensions;
+
+    return newExtensions;
+}
+
+
+const GLubyte *
+_glGetString_override(GLenum name)
+{
+    const GLubyte *result = _glGetString(name);
+
+    if (result) {
+        switch (name) {
+        case GL_EXTENSIONS:
+            result = (const GLubyte *)overrideExtensionsString((const char *)result);
+            break;
+        default:
+            break;
+        }
+    }
+
+    return result;
+}
+
+
+void
+_glGetIntegerv_override(GLenum pname, GLint *params)
+{
+    _glGetIntegerv(pname, params);
+
+    if (params) {
+        switch (pname) {
+        case GL_NUM_EXTENSIONS:
+            {
+                const ExtensionsDesc *desc = getExtraExtensions();
+                *params += desc->numStrings;
+            }
+            break;
+        default:
+            break;
+        }
+    }
+}
+
+
+const GLubyte *
+_glGetStringi_override(GLenum name, GLuint index)
+{
+    switch (name) {
+    case GL_EXTENSIONS:
+        {
+            const ExtensionsDesc *desc = getExtraExtensions();
+            GLint numExtensions = 0;
+            _glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
+            if ((GLuint)numExtensions <= index && index < (GLuint)numExtensions + desc->numStrings) {
+                return (const GLubyte *)desc->strings[index - (GLuint)numExtensions];
+            }
+        }
+        break;
+    default:
+        break;
+    }
+
+    return _glGetStringi(name, index);
+}
+
+
+} /* namespace gltrace */
+
diff --git a/wrappers/gltrace.hpp b/wrappers/gltrace.hpp
new file mode 100644 (file)
index 0000000..db824bb
--- /dev/null
@@ -0,0 +1,90 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _GLTRACE_HPP_
+#define _GLTRACE_HPP_
+
+
+#include "glimports.hpp"
+
+
+namespace gltrace {
+
+
+enum Profile {
+    PROFILE_COMPAT,
+    PROFILE_ES1,
+    PROFILE_ES2,
+};
+
+class Context {
+public:
+    enum Profile profile;
+    bool user_arrays;
+    bool user_arrays_arb;
+    bool user_arrays_nv;
+    unsigned retain_count;
+
+    Context(void) :
+        profile(PROFILE_COMPAT),
+        user_arrays(false),
+        user_arrays_arb(false),
+        user_arrays_nv(false),
+        retain_count(0)
+    { }
+};
+
+void
+createContext(uintptr_t context_id);
+
+void
+retainContext(uintptr_t context_id);
+
+bool
+releaseContext(uintptr_t context_id);
+
+void
+setContext(uintptr_t context_id);
+
+void
+clearContext(void);
+
+gltrace::Context *
+getContext(void);
+
+const GLubyte *
+_glGetString_override(GLenum name);
+
+void
+_glGetIntegerv_override(GLenum pname, GLint *params);
+
+const GLubyte *
+_glGetStringi_override(GLenum name, GLuint index);
+
+
+} /* namespace gltrace */
+
+
+#endif /* _GLRETRACE_HPP_ */
diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py
new file mode 100644 (file)
index 0000000..411a19b
--- /dev/null
@@ -0,0 +1,1029 @@
+##########################################################################
+#
+# Copyright 2008-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""GL tracing generator."""
+
+
+from trace import Tracer
+from dispatch import function_pointer_type, function_pointer_value
+import specs.stdapi as stdapi
+import specs.glapi as glapi
+import specs.glparams as glparams
+from specs.glxapi import glxapi
+
+
+class TypeGetter(stdapi.Visitor):
+    '''Determine which glGet*v function that matches the specified type.'''
+
+    def __init__(self, prefix = 'glGet', long_suffix = True, ext_suffix = ''):
+        self.prefix = prefix
+        self.long_suffix = long_suffix
+        self.ext_suffix = ext_suffix
+
+    def visitConst(self, const):
+        return self.visit(const.type)
+
+    def visitAlias(self, alias):
+        if alias.expr == 'GLboolean':
+            if self.long_suffix:
+                suffix = 'Booleanv'
+                arg_type = alias.expr
+            else:
+                suffix = 'iv'
+                arg_type = 'GLint'
+        elif alias.expr == 'GLdouble':
+            if self.long_suffix:
+                suffix = 'Doublev'
+                arg_type = alias.expr
+            else:
+                suffix = 'dv'
+                arg_type = alias.expr
+        elif alias.expr == 'GLfloat':
+            if self.long_suffix:
+                suffix = 'Floatv'
+                arg_type = alias.expr
+            else:
+                suffix = 'fv'
+                arg_type = alias.expr
+        elif alias.expr in ('GLint', 'GLuint', 'GLsizei'):
+            if self.long_suffix:
+                suffix = 'Integerv'
+                arg_type = 'GLint'
+            else:
+                suffix = 'iv'
+                arg_type = 'GLint'
+        else:
+            print alias.expr
+            assert False
+        function_name = self.prefix + suffix + self.ext_suffix
+        return function_name, arg_type
+    
+    def visitEnum(self, enum):
+        return self.visit(glapi.GLint)
+
+    def visitBitmask(self, bitmask):
+        return self.visit(glapi.GLint)
+
+    def visitOpaque(self, pointer):
+        return self.prefix + 'Pointerv' + self.ext_suffix, 'GLvoid *'
+
+
+class GlTracer(Tracer):
+
+    arrays = [
+        ("Vertex", "VERTEX"),
+        ("Normal", "NORMAL"),
+        ("Color", "COLOR"),
+        ("Index", "INDEX"),
+        ("TexCoord", "TEXTURE_COORD"),
+        ("EdgeFlag", "EDGE_FLAG"),
+        ("FogCoord", "FOG_COORD"),
+        ("SecondaryColor", "SECONDARY_COLOR"),
+    ]
+    arrays.reverse()
+
+    # arrays available in PROFILE_ES1
+    arrays_es1 = ("Vertex", "Normal", "Color", "TexCoord")
+
+    def header(self, api):
+        Tracer.header(self, api)
+
+        print '#include "gltrace.hpp"'
+        print
+        
+        # Which glVertexAttrib* variant to use
+        print 'enum vertex_attrib {'
+        print '    VERTEX_ATTRIB,'
+        print '    VERTEX_ATTRIB_ARB,'
+        print '    VERTEX_ATTRIB_NV,'
+        print '};'
+        print
+        print 'static vertex_attrib _get_vertex_attrib(void) {'
+        print '    gltrace::Context *ctx = gltrace::getContext();'
+        print '    if (ctx->user_arrays_arb || ctx->user_arrays_nv) {'
+        print '        GLboolean _vertex_program = GL_FALSE;'
+        print '        _glGetBooleanv(GL_VERTEX_PROGRAM_ARB, &_vertex_program);'
+        print '        if (_vertex_program) {'
+        print '            if (ctx->user_arrays_nv) {'
+        print '                GLint _vertex_program_binding_nv = 0;'
+        print '                _glGetIntegerv(GL_VERTEX_PROGRAM_BINDING_NV, &_vertex_program_binding_nv);'
+        print '                if (_vertex_program_binding_nv) {'
+        print '                    return VERTEX_ATTRIB_NV;'
+        print '                }'
+        print '            }'
+        print '            return VERTEX_ATTRIB_ARB;'
+        print '        }'
+        print '    }'
+        print '    return VERTEX_ATTRIB;'
+        print '}'
+        print
+
+        # Whether we need user arrays
+        print 'static inline bool _need_user_arrays(void)'
+        print '{'
+        print '    gltrace::Context *ctx = gltrace::getContext();'
+        print '    if (!ctx->user_arrays) {'
+        print '        return false;'
+        print '    }'
+        print
+
+        for camelcase_name, uppercase_name in self.arrays:
+            # in which profile is the array available?
+            profile_check = 'ctx->profile == gltrace::PROFILE_COMPAT'
+            if camelcase_name in self.arrays_es1:
+                profile_check = '(' + profile_check + ' || ctx->profile == gltrace::PROFILE_ES1)';
+
+            function_name = 'gl%sPointer' % camelcase_name
+            enable_name = 'GL_%s_ARRAY' % uppercase_name
+            binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name
+            print '    // %s' % function_name
+            print '  if (%s) {' % profile_check
+            self.array_prolog(api, uppercase_name)
+            print '    if (_glIsEnabled(%s)) {' % enable_name
+            print '        GLint _binding = 0;'
+            print '        _glGetIntegerv(%s, &_binding);' % binding_name
+            print '        if (!_binding) {'
+            self.array_cleanup(api, uppercase_name)
+            print '            return true;'
+            print '        }'
+            print '    }'
+            self.array_epilog(api, uppercase_name)
+            print '  }'
+            print
+
+        print '    // ES1 does not support generic vertex attributes'
+        print '    if (ctx->profile == gltrace::PROFILE_ES1)'
+        print '        return false;'
+        print
+        print '    vertex_attrib _vertex_attrib = _get_vertex_attrib();'
+        print
+        print '    // glVertexAttribPointer'
+        print '    if (_vertex_attrib == VERTEX_ATTRIB) {'
+        print '        GLint _max_vertex_attribs = 0;'
+        print '        _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &_max_vertex_attribs);'
+        print '        for (GLint index = 0; index < _max_vertex_attribs; ++index) {'
+        print '            GLint _enabled = 0;'
+        print '            _glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &_enabled);'
+        print '            if (_enabled) {'
+        print '                GLint _binding = 0;'
+        print '                _glGetVertexAttribiv(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &_binding);'
+        print '                if (!_binding) {'
+        print '                    return true;'
+        print '                }'
+        print '            }'
+        print '        }'
+        print '    }'
+        print
+        print '    // glVertexAttribPointerARB'
+        print '    if (_vertex_attrib == VERTEX_ATTRIB_ARB) {'
+        print '        GLint _max_vertex_attribs = 0;'
+        print '        _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &_max_vertex_attribs);'
+        print '        for (GLint index = 0; index < _max_vertex_attribs; ++index) {'
+        print '            GLint _enabled = 0;'
+        print '            _glGetVertexAttribivARB(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB, &_enabled);'
+        print '            if (_enabled) {'
+        print '                GLint _binding = 0;'
+        print '                _glGetVertexAttribivARB(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB, &_binding);'
+        print '                if (!_binding) {'
+        print '                    return true;'
+        print '                }'
+        print '            }'
+        print '        }'
+        print '    }'
+        print
+        print '    // glVertexAttribPointerNV'
+        print '    if (_vertex_attrib == VERTEX_ATTRIB_NV) {'
+        print '        for (GLint index = 0; index < 16; ++index) {'
+        print '            GLint _enabled = 0;'
+        print '            _glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &_enabled);'
+        print '            if (_enabled) {'
+        print '                return true;'
+        print '            }'
+        print '        }'
+        print '    }'
+        print
+
+        print '    return false;'
+        print '}'
+        print
+
+        print 'static void _trace_user_arrays(GLuint count);'
+        print
+
+        # Buffer mappings
+        print '// whether glMapBufferRange(GL_MAP_WRITE_BIT) has ever been called'
+        print 'static bool _checkBufferMapRange = false;'
+        print
+        print '// whether glBufferParameteriAPPLE(GL_BUFFER_FLUSHING_UNMAP_APPLE, GL_FALSE) has ever been called'
+        print 'static bool _checkBufferFlushingUnmapAPPLE = false;'
+        print
+        # Buffer mapping information, necessary for old Mesa 2.1 drivers which
+        # do not support glGetBufferParameteriv(GL_BUFFER_ACCESS_FLAGS/GL_BUFFER_MAP_LENGTH)
+        print 'struct buffer_mapping {'
+        print '    void *map;'
+        print '    GLint length;'
+        print '    bool write;'
+        print '    bool explicit_flush;'
+        print '};'
+        print
+        for target in self.buffer_targets:
+            print 'struct buffer_mapping _%s_mapping;' % target.lower();
+        print
+        print 'static inline struct buffer_mapping *'
+        print 'get_buffer_mapping(GLenum target) {'
+        print '    switch (target) {'
+        for target in self.buffer_targets:
+            print '    case GL_%s:' % target
+            print '        return & _%s_mapping;' % target.lower()
+        print '    default:'
+        print '        os::log("apitrace: warning: unknown buffer target 0x%04X\\n", target);'
+        print '        return NULL;'
+        print '    }'
+        print '}'
+        print
+
+        # Generate a helper function to determine whether a parameter name
+        # refers to a symbolic value or not
+        print 'static bool'
+        print 'is_symbolic_pname(GLenum pname) {'
+        print '    switch (pname) {'
+        for function, type, count, name in glparams.parameters:
+            if type is glapi.GLenum:
+                print '    case %s:' % name
+        print '        return true;'
+        print '    default:'
+        print '        return false;'
+        print '    }'
+        print '}'
+        print
+        
+        # Generate a helper function to determine whether a parameter value is
+        # potentially symbolic or not; i.e., if the value can be represented in
+        # an enum or not
+        print 'template<class T>'
+        print 'static inline bool'
+        print 'is_symbolic_param(T param) {'
+        print '    return static_cast<T>(static_cast<GLenum>(param)) == param;'
+        print '}'
+        print
+
+        # Generate a helper function to know how many elements a parameter has
+        print 'static size_t'
+        print '_gl_param_size(GLenum pname) {'
+        print '    switch (pname) {'
+        for function, type, count, name in glparams.parameters:
+            if type is not None:
+                print '    case %s: return %u;' % (name, count)
+        print '    case GL_COMPRESSED_TEXTURE_FORMATS: {'
+        print '            GLint num_compressed_texture_formats = 0;'
+        print '            _glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num_compressed_texture_formats);'
+        print '            return num_compressed_texture_formats;'
+        print '        }'
+        print '    default:'
+        print r'        os::log("apitrace: warning: %s: unknown GLenum 0x%04X\n", __FUNCTION__, pname);'
+        print '        return 1;'
+        print '    }'
+        print '}'
+        print
+
+        # states such as GL_UNPACK_ROW_LENGTH are not available in GLES
+        print 'static inline bool'
+        print 'can_unpack_subimage(void) {'
+        print '    gltrace::Context *ctx = gltrace::getContext();'
+        print '    return (ctx->profile == gltrace::PROFILE_COMPAT);'
+        print '}'
+        print
+
+    getProcAddressFunctionNames = []
+
+    def traceApi(self, api):
+        if self.getProcAddressFunctionNames:
+            # Generate a function to wrap proc addresses
+            getProcAddressFunction = api.getFunctionByName(self.getProcAddressFunctionNames[0])
+            argType = getProcAddressFunction.args[0].type
+            retType = getProcAddressFunction.type
+            
+            print 'static %s _wrapProcAddress(%s procName, %s procPtr);' % (retType, argType, retType)
+            print
+            
+            Tracer.traceApi(self, api)
+            
+            print 'static %s _wrapProcAddress(%s procName, %s procPtr) {' % (retType, argType, retType)
+            print '    if (!procPtr) {'
+            print '        return procPtr;'
+            print '    }'
+            for function in api.functions:
+                ptype = function_pointer_type(function)
+                pvalue = function_pointer_value(function)
+                print '    if (strcmp("%s", (const char *)procName) == 0) {' % function.name
+                print '        %s = (%s)procPtr;' % (pvalue, ptype)
+                print '        return (%s)&%s;' % (retType, function.name,)
+                print '    }'
+            print '    os::log("apitrace: warning: unknown function \\"%s\\"\\n", (const char *)procName);'
+            print '    return procPtr;'
+            print '}'
+            print
+        else:
+            Tracer.traceApi(self, api)
+
+    array_pointer_function_names = set((
+        "glVertexPointer",
+        "glNormalPointer",
+        "glColorPointer",
+        "glIndexPointer",
+        "glTexCoordPointer",
+        "glEdgeFlagPointer",
+        "glFogCoordPointer",
+        "glSecondaryColorPointer",
+        
+        "glInterleavedArrays",
+
+        "glVertexPointerEXT",
+        "glNormalPointerEXT",
+        "glColorPointerEXT",
+        "glIndexPointerEXT",
+        "glTexCoordPointerEXT",
+        "glEdgeFlagPointerEXT",
+        "glFogCoordPointerEXT",
+        "glSecondaryColorPointerEXT",
+
+        "glVertexAttribPointer",
+        "glVertexAttribPointerARB",
+        "glVertexAttribPointerNV",
+        "glVertexAttribIPointer",
+        "glVertexAttribIPointerEXT",
+        "glVertexAttribLPointer",
+        "glVertexAttribLPointerEXT",
+        
+        #"glMatrixIndexPointerARB",
+    ))
+
+    draw_function_names = set((
+        'glDrawArrays',
+        'glDrawElements',
+        'glDrawRangeElements',
+        'glMultiDrawArrays',
+        'glMultiDrawElements',
+        'glDrawArraysInstanced',
+        "glDrawArraysInstancedBaseInstance",
+        'glDrawElementsInstanced',
+        'glDrawArraysInstancedARB',
+        'glDrawElementsInstancedARB',
+        'glDrawElementsBaseVertex',
+        'glDrawRangeElementsBaseVertex',
+        'glDrawElementsInstancedBaseVertex',
+        "glDrawElementsInstancedBaseInstance",
+        "glDrawElementsInstancedBaseVertexBaseInstance",
+        'glMultiDrawElementsBaseVertex',
+        'glDrawArraysIndirect',
+        'glDrawElementsIndirect',
+        'glDrawArraysEXT',
+        'glDrawRangeElementsEXT',
+        'glDrawRangeElementsEXT_size',
+        'glMultiDrawArraysEXT',
+        'glMultiDrawElementsEXT',
+        'glMultiModeDrawArraysIBM',
+        'glMultiModeDrawElementsIBM',
+        'glDrawArraysInstancedEXT',
+        'glDrawElementsInstancedEXT',
+    ))
+
+    interleaved_formats = [
+         'GL_V2F',
+         'GL_V3F',
+         'GL_C4UB_V2F',
+         'GL_C4UB_V3F',
+         'GL_C3F_V3F',
+         'GL_N3F_V3F',
+         'GL_C4F_N3F_V3F',
+         'GL_T2F_V3F',
+         'GL_T4F_V4F',
+         'GL_T2F_C4UB_V3F',
+         'GL_T2F_C3F_V3F',
+         'GL_T2F_N3F_V3F',
+         'GL_T2F_C4F_N3F_V3F',
+         'GL_T4F_C4F_N3F_V4F',
+    ]
+
+    def traceFunctionImplBody(self, function):
+        # Defer tracing of user array pointers...
+        if function.name in self.array_pointer_function_names:
+            print '    GLint _array_buffer = 0;'
+            print '    _glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &_array_buffer);'
+            print '    if (!_array_buffer) {'
+            print '        gltrace::Context *ctx = gltrace::getContext();'
+            print '        ctx->user_arrays = true;'
+            if function.name == "glVertexAttribPointerARB":
+                print '        ctx->user_arrays_arb = true;'
+            if function.name == "glVertexAttribPointerNV":
+                print '        ctx->user_arrays_nv = true;'
+            self.invokeFunction(function)
+
+            # And also break down glInterleavedArrays into the individual calls
+            if function.name == 'glInterleavedArrays':
+                print
+
+                # Initialize the enable flags
+                for camelcase_name, uppercase_name in self.arrays:
+                    flag_name = '_' + uppercase_name.lower()
+                    print '        GLboolean %s = GL_FALSE;' % flag_name
+                print
+
+                # Switch for the interleaved formats
+                print '        switch (format) {'
+                for format in self.interleaved_formats:
+                    print '            case %s:' % format
+                    for camelcase_name, uppercase_name in self.arrays:
+                        flag_name = '_' + uppercase_name.lower()
+                        if format.find('_' + uppercase_name[0]) >= 0:
+                            print '                %s = GL_TRUE;' % flag_name
+                    print '                break;'
+                print '            default:'
+                print '               return;'
+                print '        }'
+                print
+
+                # Emit fake glEnableClientState/glDisableClientState flags
+                for camelcase_name, uppercase_name in self.arrays:
+                    flag_name = '_' + uppercase_name.lower()
+                    enable_name = 'GL_%s_ARRAY' % uppercase_name
+
+                    # Emit a fake function
+                    print '        {'
+                    print '            static const trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name
+                    print '            unsigned _call = trace::localWriter.beginEnter(&_sig);'
+                    print '            trace::localWriter.beginArg(0);'
+                    self.serializeValue(glapi.GLenum, enable_name)
+                    print '            trace::localWriter.endArg();'
+                    print '            trace::localWriter.endEnter();'
+                    print '            trace::localWriter.beginLeave(_call);'
+                    print '            trace::localWriter.endLeave();'
+                    print '        }'
+
+            print '        return;'
+            print '    }'
+
+        # ... to the draw calls
+        if function.name in self.draw_function_names:
+            print '    if (_need_user_arrays()) {'
+            arg_names = ', '.join([arg.name for arg in function.args[1:]])
+            print '        GLuint _count = _%s_count(%s);' % (function.name, arg_names)
+            print '        _trace_user_arrays(_count);'
+            print '    }'
+        
+        # Emit a fake memcpy on buffer uploads
+        if function.name == 'glBufferParameteriAPPLE':
+            print '    if (pname == GL_BUFFER_FLUSHING_UNMAP_APPLE && param == GL_FALSE) {'
+            print '        _checkBufferFlushingUnmapAPPLE = true;'
+            print '    }'
+        if function.name in ('glUnmapBuffer', 'glUnmapBufferARB'):
+            if function.name.endswith('ARB'):
+                suffix = 'ARB'
+            else:
+                suffix = ''
+            print '    GLint access = 0;'
+            print '    _glGetBufferParameteriv%s(target, GL_BUFFER_ACCESS, &access);' % suffix
+            print '    if (access != GL_READ_ONLY) {'
+            print '        GLvoid *map = NULL;'
+            print '        _glGetBufferPointerv%s(target, GL_BUFFER_MAP_POINTER, &map);'  % suffix
+            print '        if (map) {'
+            print '            GLint length = -1;'
+            print '            bool flush = true;'
+            print '            if (_checkBufferMapRange) {'
+            print '                _glGetBufferParameteriv%s(target, GL_BUFFER_MAP_LENGTH, &length);' % suffix
+            print '                GLint access_flags = 0;'
+            print '                _glGetBufferParameteriv(target, GL_BUFFER_ACCESS_FLAGS, &access_flags);'
+            print '                flush = flush && !(access_flags & GL_MAP_FLUSH_EXPLICIT_BIT);'
+            print '                if (length == -1) {'
+            print '                    // Mesa drivers refuse GL_BUFFER_MAP_LENGTH without GL 3.0'
+            print '                    static bool warned = false;'
+            print '                    if (!warned) {'
+            print '                        os::log("apitrace: warning: glGetBufferParameteriv%s(GL_BUFFER_MAP_LENGTH) failed\\n");' % suffix
+            print '                        warned = true;'
+            print '                    }'
+            print '                    struct buffer_mapping *mapping = get_buffer_mapping(target);'
+            print '                    if (mapping) {'
+            print '                        length = mapping->length;'
+            print '                        flush = flush && !mapping->explicit_flush;'
+            print '                    } else {'
+            print '                        length = 0;'
+            print '                        flush = false;'
+            print '                    }'
+            print '                }'
+            print '            } else {'
+            print '                length = 0;'
+            print '                _glGetBufferParameteriv%s(target, GL_BUFFER_SIZE, &length);' % suffix
+            print '            }'
+            print '            if (_checkBufferFlushingUnmapAPPLE) {'
+            print '                GLint flushing_unmap = GL_TRUE;'
+            print '                _glGetBufferParameteriv%s(target, GL_BUFFER_FLUSHING_UNMAP_APPLE, &flushing_unmap);' % suffix
+            print '                flush = flush && flushing_unmap;'
+            print '            }'
+            print '            if (flush && length > 0) {'
+            self.emit_memcpy('map', 'map', 'length')
+            print '            }'
+            print '        }'
+            print '    }'
+        if function.name == 'glUnmapBufferOES':
+            print '    GLint access = 0;'
+            print '    _glGetBufferParameteriv(target, GL_BUFFER_ACCESS_OES, &access);'
+            print '    if (access == GL_WRITE_ONLY_OES) {'
+            print '        GLvoid *map = NULL;'
+            print '        _glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &map);'
+            print '        GLint size = 0;'
+            print '        _glGetBufferParameteriv(target, GL_BUFFER_SIZE, &size);'
+            print '        if (map && size > 0) {'
+            self.emit_memcpy('map', 'map', 'size')
+            print '        }'
+            print '    }'
+        if function.name == 'glUnmapNamedBufferEXT':
+            print '    GLint access_flags = 0;'
+            print '    _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_ACCESS_FLAGS, &access_flags);'
+            print '    if ((access_flags & GL_MAP_WRITE_BIT) && !(access_flags & GL_MAP_FLUSH_EXPLICIT_BIT)) {'
+            print '        GLvoid *map = NULL;'
+            print '        _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);'
+            print '        GLint length = 0;'
+            print '        _glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_MAP_LENGTH, &length);'
+            print '        if (map && length > 0) {'
+            self.emit_memcpy('map', 'map', 'length')
+            print '        }'
+            print '    }'
+        if function.name == 'glFlushMappedBufferRange':
+            print '    GLvoid *map = NULL;'
+            print '    _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);'
+            print '    if (map && length > 0) {'
+            self.emit_memcpy('(char *)map + offset', '(const char *)map + offset', 'length')
+            print '    }'
+        if function.name == 'glFlushMappedBufferRangeAPPLE':
+            print '    GLvoid *map = NULL;'
+            print '    _glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &map);'
+            print '    if (map && size > 0) {'
+            self.emit_memcpy('(char *)map + offset', '(const char *)map + offset', 'size')
+            print '    }'
+        if function.name == 'glFlushMappedNamedBufferRangeEXT':
+            print '    GLvoid *map = NULL;'
+            print '    _glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &map);'
+            print '    if (map && length > 0) {'
+            self.emit_memcpy('(char *)map + offset', '(const char *)map + offset', 'length')
+            print '    }'
+
+        # Don't leave vertex attrib locations to chance.  Instead emit fake
+        # glBindAttribLocation calls to ensure that the same locations will be
+        # used when retracing.  Trying to remap locations after the fact would
+        # be an herculian task given that vertex attrib locations appear in
+        # many entry-points, including non-shader related ones.
+        if function.name == 'glLinkProgram':
+            Tracer.invokeFunction(self, function)
+            print '    GLint active_attributes = 0;'
+            print '    _glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active_attributes);'
+            print '    for (GLint attrib = 0; attrib < active_attributes; ++attrib) {'
+            print '        GLint size = 0;'
+            print '        GLenum type = 0;'
+            print '        GLchar name[256];'
+            # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256
+            print '        _glGetActiveAttrib(program, attrib, sizeof name, NULL, &size, &type, name);'
+            print "        if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {"
+            print '            GLint location = _glGetAttribLocation(program, name);'
+            print '            if (location >= 0) {'
+            bind_function = glapi.glapi.getFunctionByName('glBindAttribLocation')
+            self.fake_call(bind_function, ['program', 'location', 'name'])
+            print '            }'
+            print '        }'
+            print '    }'
+        if function.name == 'glLinkProgramARB':
+            Tracer.invokeFunction(self, function)
+            print '    GLint active_attributes = 0;'
+            print '    _glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &active_attributes);'
+            print '    for (GLint attrib = 0; attrib < active_attributes; ++attrib) {'
+            print '        GLint size = 0;'
+            print '        GLenum type = 0;'
+            print '        GLcharARB name[256];'
+            # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256
+            print '        _glGetActiveAttribARB(programObj, attrib, sizeof name, NULL, &size, &type, name);'
+            print "        if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {"
+            print '            GLint location = _glGetAttribLocationARB(programObj, name);'
+            print '            if (location >= 0) {'
+            bind_function = glapi.glapi.getFunctionByName('glBindAttribLocationARB')
+            self.fake_call(bind_function, ['programObj', 'location', 'name'])
+            print '            }'
+            print '        }'
+            print '    }'
+
+        Tracer.traceFunctionImplBody(self, function)
+
+    marker_functions = [
+        # GL_GREMEDY_string_marker
+        'glStringMarkerGREMEDY',
+        # GL_GREMEDY_frame_terminator
+        'glFrameTerminatorGREMEDY',
+        # GL_EXT_debug_marker
+        'glInsertEventMarkerEXT',
+        'glPushGroupMarkerEXT',
+        'glPopGroupMarkerEXT',
+    ]
+
+    def invokeFunction(self, function):
+        if function.name in ('glLinkProgram', 'glLinkProgramARB'):
+            # These functions have been dispatched already
+            return
+
+        # We implement GL_EXT_debug_marker, GL_GREMEDY_*, etc., and not the
+        # driver
+        if function.name in self.marker_functions:
+            return
+
+        if function.name in ('glXGetProcAddress', 'glXGetProcAddressARB', 'wglGetProcAddress'):
+            else_ = ''
+            for marker_function in self.marker_functions:
+                if self.api.getFunctionByName(marker_function):
+                    print '    %sif (strcmp("%s", (const char *)%s) == 0) {' % (else_, marker_function, function.args[0].name)
+                    print '        _result = (%s)&%s;' % (function.type, marker_function)
+                    print '    }'
+                else_ = 'else '
+            print '    %s{' % else_
+            Tracer.invokeFunction(self, function)
+            print '    }'
+            return
+
+        # Override GL extensions
+        if function.name in ('glGetString', 'glGetIntegerv', 'glGetStringi'):
+            Tracer.invokeFunction(self, function, prefix = 'gltrace::_', suffix = '_override')
+            return
+
+        Tracer.invokeFunction(self, function)
+
+    buffer_targets = [
+        'ARRAY_BUFFER',
+        'ELEMENT_ARRAY_BUFFER',
+        'PIXEL_PACK_BUFFER',
+        'PIXEL_UNPACK_BUFFER',
+        'UNIFORM_BUFFER',
+        'TEXTURE_BUFFER',
+        'TRANSFORM_FEEDBACK_BUFFER',
+        'COPY_READ_BUFFER',
+        'COPY_WRITE_BUFFER',
+        'DRAW_INDIRECT_BUFFER',
+        'ATOMIC_COUNTER_BUFFER',
+    ]
+
+    def wrapRet(self, function, instance):
+        Tracer.wrapRet(self, function, instance)
+
+        # Replace function addresses with ours
+        if function.name in self.getProcAddressFunctionNames:
+            print '    %s = _wrapProcAddress(%s, %s);' % (instance, function.args[0].name, instance)
+
+        # Keep track of buffer mappings
+        if function.name in ('glMapBuffer', 'glMapBufferARB'):
+            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
+            print '    if (mapping) {'
+            print '        mapping->map = %s;' % (instance)
+            print '        mapping->length = 0;'
+            print '        _glGetBufferParameteriv(target, GL_BUFFER_SIZE, &mapping->length);'
+            print '        mapping->write = (access != GL_READ_ONLY);'
+            print '        mapping->explicit_flush = false;'
+            print '    }'
+        if function.name == 'glMapBufferRange':
+            print '    if (access & GL_MAP_WRITE_BIT) {'
+            print '        _checkBufferMapRange = true;'
+            print '    }'
+            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
+            print '    if (mapping) {'
+            print '        mapping->map = %s;' % (instance)
+            print '        mapping->length = length;'
+            print '        mapping->write = access & GL_MAP_WRITE_BIT;'
+            print '        mapping->explicit_flush = access & GL_MAP_FLUSH_EXPLICIT_BIT;'
+            print '    }'
+
+    boolean_names = [
+        'GL_FALSE',
+        'GL_TRUE',
+    ]
+
+    def gl_boolean(self, value):
+        return self.boolean_names[int(bool(value))]
+
+    # Names of the functions that unpack from a pixel buffer object.  See the
+    # ARB_pixel_buffer_object specification.
+    unpack_function_names = set([
+        'glBitmap',
+        'glColorSubTable',
+        'glColorTable',
+        'glCompressedTexImage1D',
+        'glCompressedTexImage2D',
+        'glCompressedTexImage3D',
+        'glCompressedTexSubImage1D',
+        'glCompressedTexSubImage2D',
+        'glCompressedTexSubImage3D',
+        'glConvolutionFilter1D',
+        'glConvolutionFilter2D',
+        'glDrawPixels',
+        'glMultiTexImage1DEXT',
+        'glMultiTexImage2DEXT',
+        'glMultiTexImage3DEXT',
+        'glMultiTexSubImage1DEXT',
+        'glMultiTexSubImage2DEXT',
+        'glMultiTexSubImage3DEXT',
+        'glPixelMapfv',
+        'glPixelMapuiv',
+        'glPixelMapusv',
+        'glPolygonStipple',
+        'glSeparableFilter2D',
+        'glTexImage1D',
+        'glTexImage1DEXT',
+        'glTexImage2D',
+        'glTexImage2DEXT',
+        'glTexImage3D',
+        'glTexImage3DEXT',
+        'glTexSubImage1D',
+        'glTexSubImage1DEXT',
+        'glTexSubImage2D',
+        'glTexSubImage2DEXT',
+        'glTexSubImage3D',
+        'glTexSubImage3DEXT',
+        'glTextureImage1DEXT',
+        'glTextureImage2DEXT',
+        'glTextureImage3DEXT',
+        'glTextureSubImage1DEXT',
+        'glTextureSubImage2DEXT',
+        'glTextureSubImage3DEXT',
+    ])
+
+    def serializeArgValue(self, function, arg):
+        if function.name in self.draw_function_names and arg.name == 'indices':
+            print '    GLint _element_array_buffer = 0;'
+            print '    _glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &_element_array_buffer);'
+            print '    if (!_element_array_buffer) {'
+            if isinstance(arg.type, stdapi.Array):
+                print '        trace::localWriter.beginArray(%s);' % arg.type.length
+                print '        for(GLsizei i = 0; i < %s; ++i) {' % arg.type.length
+                print '            trace::localWriter.beginElement();'
+                print '            trace::localWriter.writeBlob(%s[i], count[i]*_gl_type_size(type));' % (arg.name)
+                print '            trace::localWriter.endElement();'
+                print '        }'
+                print '        trace::localWriter.endArray();'
+            else:
+                print '        trace::localWriter.writeBlob(%s, count*_gl_type_size(type));' % (arg.name)
+            print '    } else {'
+            Tracer.serializeArgValue(self, function, arg)
+            print '    }'
+            return
+
+        # Recognize offsets instead of blobs when a PBO is bound
+        if function.name in self.unpack_function_names \
+           and (isinstance(arg.type, stdapi.Blob) \
+                or (isinstance(arg.type, stdapi.Const) \
+                    and isinstance(arg.type.type, stdapi.Blob))):
+            print '    {'
+            print '        gltrace::Context *ctx = gltrace::getContext();'
+            print '        GLint _unpack_buffer = 0;'
+            print '        if (ctx->profile == gltrace::PROFILE_COMPAT)'
+            print '            _glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &_unpack_buffer);'
+            print '        if (_unpack_buffer) {'
+            print '            trace::localWriter.writePointer((uintptr_t)%s);' % arg.name
+            print '        } else {'
+            Tracer.serializeArgValue(self, function, arg)
+            print '        }'
+            print '    }'
+            return
+
+        # Several GL state functions take GLenum symbolic names as
+        # integer/floats; so dump the symbolic name whenever possible
+        if function.name.startswith('gl') \
+           and arg.type in (glapi.GLint, glapi.GLfloat, glapi.GLdouble) \
+           and arg.name == 'param':
+            assert arg.index > 0
+            assert function.args[arg.index - 1].name == 'pname'
+            assert function.args[arg.index - 1].type == glapi.GLenum
+            print '    if (is_symbolic_pname(pname) && is_symbolic_param(%s)) {' % arg.name
+            self.serializeValue(glapi.GLenum, arg.name)
+            print '    } else {'
+            Tracer.serializeArgValue(self, function, arg)
+            print '    }'
+            return
+
+        Tracer.serializeArgValue(self, function, arg)
+
+    def footer(self, api):
+        Tracer.footer(self, api)
+
+        # A simple state tracker to track the pointer values
+        # update the state
+        print 'static void _trace_user_arrays(GLuint count)'
+        print '{'
+        print '    gltrace::Context *ctx = gltrace::getContext();'
+
+        for camelcase_name, uppercase_name in self.arrays:
+            # in which profile is the array available?
+            profile_check = 'ctx->profile == gltrace::PROFILE_COMPAT'
+            if camelcase_name in self.arrays_es1:
+                profile_check = '(' + profile_check + ' || ctx->profile == gltrace::PROFILE_ES1)';
+
+            function_name = 'gl%sPointer' % camelcase_name
+            enable_name = 'GL_%s_ARRAY' % uppercase_name
+            binding_name = 'GL_%s_ARRAY_BUFFER_BINDING' % uppercase_name
+            function = api.getFunctionByName(function_name)
+
+            print '    // %s' % function.prototype()
+            print '  if (%s) {' % profile_check
+            self.array_trace_prolog(api, uppercase_name)
+            self.array_prolog(api, uppercase_name)
+            print '    if (_glIsEnabled(%s)) {' % enable_name
+            print '        GLint _binding = 0;'
+            print '        _glGetIntegerv(%s, &_binding);' % binding_name
+            print '        if (!_binding) {'
+
+            # Get the arguments via glGet*
+            for arg in function.args:
+                arg_get_enum = 'GL_%s_ARRAY_%s' % (uppercase_name, arg.name.upper())
+                arg_get_function, arg_type = TypeGetter().visit(arg.type)
+                print '            %s %s = 0;' % (arg_type, arg.name)
+                print '            _%s(%s, &%s);' % (arg_get_function, arg_get_enum, arg.name)
+            
+            arg_names = ', '.join([arg.name for arg in function.args[:-1]])
+            print '            size_t _size = _%s_size(%s, count);' % (function.name, arg_names)
+
+            # Emit a fake function
+            self.array_trace_intermezzo(api, uppercase_name)
+            print '            unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
+            for arg in function.args:
+                assert not arg.output
+                print '            trace::localWriter.beginArg(%u);' % (arg.index,)
+                if arg.name != 'pointer':
+                    self.serializeValue(arg.type, arg.name)
+                else:
+                    print '            trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name)
+                print '            trace::localWriter.endArg();'
+            
+            print '            trace::localWriter.endEnter();'
+            print '            trace::localWriter.beginLeave(_call);'
+            print '            trace::localWriter.endLeave();'
+            print '        }'
+            print '    }'
+            self.array_epilog(api, uppercase_name)
+            self.array_trace_epilog(api, uppercase_name)
+            print '  }'
+            print
+
+        # Samething, but for glVertexAttribPointer*
+        #
+        # Some variants of glVertexAttribPointer alias conventional and generic attributes:
+        # - glVertexAttribPointer: no
+        # - glVertexAttribPointerARB: implementation dependent
+        # - glVertexAttribPointerNV: yes
+        #
+        # This means that the implementations of these functions do not always
+        # alias, and they need to be considered independently.
+        #
+        print '    // ES1 does not support generic vertex attributes'
+        print '    if (ctx->profile == gltrace::PROFILE_ES1)'
+        print '        return;'
+        print
+        print '    vertex_attrib _vertex_attrib = _get_vertex_attrib();'
+        print
+        for suffix in ['', 'ARB', 'NV']:
+            if suffix:
+                SUFFIX = '_' + suffix
+            else:
+                SUFFIX = suffix
+            function_name = 'glVertexAttribPointer' + suffix
+            function = api.getFunctionByName(function_name)
+
+            print '    // %s' % function.prototype()
+            print '    if (_vertex_attrib == VERTEX_ATTRIB%s) {' % SUFFIX
+            if suffix == 'NV':
+                print '        GLint _max_vertex_attribs = 16;'
+            else:
+                print '        GLint _max_vertex_attribs = 0;'
+                print '        _glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &_max_vertex_attribs);'
+            print '        for (GLint index = 0; index < _max_vertex_attribs; ++index) {'
+            print '            GLint _enabled = 0;'
+            if suffix == 'NV':
+                print '            _glGetIntegerv(GL_VERTEX_ATTRIB_ARRAY0_NV + index, &_enabled);'
+            else:
+                print '            _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_ENABLED%s, &_enabled);' % (suffix, SUFFIX)
+            print '            if (_enabled) {'
+            print '                GLint _binding = 0;'
+            if suffix != 'NV':
+                # It doesn't seem possible to use VBOs with NV_vertex_program.
+                print '                _glGetVertexAttribiv%s(index, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING%s, &_binding);' % (suffix, SUFFIX)
+            print '                if (!_binding) {'
+
+            # Get the arguments via glGet*
+            for arg in function.args[1:]:
+                if suffix == 'NV':
+                    arg_get_enum = 'GL_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX)
+                else:
+                    arg_get_enum = 'GL_VERTEX_ATTRIB_ARRAY_%s%s' % (arg.name.upper(), SUFFIX)
+                arg_get_function, arg_type = TypeGetter('glGetVertexAttrib', False, suffix).visit(arg.type)
+                print '                    %s %s = 0;' % (arg_type, arg.name)
+                print '                    _%s(index, %s, &%s);' % (arg_get_function, arg_get_enum, arg.name)
+            
+            arg_names = ', '.join([arg.name for arg in function.args[1:-1]])
+            print '                    size_t _size = _%s_size(%s, count);' % (function.name, arg_names)
+
+            # Emit a fake function
+            print '                    unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
+            for arg in function.args:
+                assert not arg.output
+                print '                    trace::localWriter.beginArg(%u);' % (arg.index,)
+                if arg.name != 'pointer':
+                    self.serializeValue(arg.type, arg.name)
+                else:
+                    print '                    trace::localWriter.writeBlob((const void *)%s, _size);' % (arg.name)
+                print '                    trace::localWriter.endArg();'
+            
+            print '                    trace::localWriter.endEnter();'
+            print '                    trace::localWriter.beginLeave(_call);'
+            print '                    trace::localWriter.endLeave();'
+            print '                }'
+            print '            }'
+            print '        }'
+            print '    }'
+            print
+
+        print '}'
+        print
+
+    #
+    # Hooks for glTexCoordPointer, which is identical to the other array
+    # pointers except the fact that it is indexed by glClientActiveTexture.
+    #
+
+    def array_prolog(self, api, uppercase_name):
+        if uppercase_name == 'TEXTURE_COORD':
+            print '    GLint client_active_texture = 0;'
+            print '    _glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &client_active_texture);'
+            print '    GLint max_texture_coords = 0;'
+            print '    if (ctx->profile == gltrace::PROFILE_COMPAT)'
+            print '        _glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);'
+            print '    else'
+            print '        _glGetIntegerv(GL_MAX_TEXTURE_UNITS, &max_texture_coords);'
+            print '    for (GLint unit = 0; unit < max_texture_coords; ++unit) {'
+            print '        GLint texture = GL_TEXTURE0 + unit;'
+            print '        _glClientActiveTexture(texture);'
+
+    def array_trace_prolog(self, api, uppercase_name):
+        if uppercase_name == 'TEXTURE_COORD':
+            print '    bool client_active_texture_dirty = false;'
+
+    def array_epilog(self, api, uppercase_name):
+        if uppercase_name == 'TEXTURE_COORD':
+            print '    }'
+        self.array_cleanup(api, uppercase_name)
+
+    def array_cleanup(self, api, uppercase_name):
+        if uppercase_name == 'TEXTURE_COORD':
+            print '    _glClientActiveTexture(client_active_texture);'
+        
+    def array_trace_intermezzo(self, api, uppercase_name):
+        if uppercase_name == 'TEXTURE_COORD':
+            print '    if (texture != client_active_texture || client_active_texture_dirty) {'
+            print '        client_active_texture_dirty = true;'
+            self.fake_glClientActiveTexture_call(api, "texture");
+            print '    }'
+
+    def array_trace_epilog(self, api, uppercase_name):
+        if uppercase_name == 'TEXTURE_COORD':
+            print '    if (client_active_texture_dirty) {'
+            self.fake_glClientActiveTexture_call(api, "client_active_texture");
+            print '    }'
+
+    def fake_glClientActiveTexture_call(self, api, texture):
+        function = api.getFunctionByName('glClientActiveTexture')
+        self.fake_call(function, [texture])
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wrappers/gltrace_state.cpp b/wrappers/gltrace_state.cpp
new file mode 100644 (file)
index 0000000..cb8e08b
--- /dev/null
@@ -0,0 +1,156 @@
+/*********************************************************************
+ *
+ * Copyright 2012 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+#include <assert.h>
+
+#include <map>
+#if defined(_MSC_VER)
+#include <memory>
+#else
+#include <tr1/memory>
+#endif
+
+#include <gltrace.hpp>
+#include <os_thread.hpp>
+
+namespace gltrace {
+
+typedef std::tr1::shared_ptr<Context> context_ptr_t;
+static std::map<uintptr_t, context_ptr_t> context_map;
+static os::recursive_mutex context_map_mutex;
+
+class ThreadState {
+public:
+    context_ptr_t current_context;
+    context_ptr_t dummy_context;     /*
+                                      * For cases when there is no current
+                                      * context, but the app still calls some
+                                      * GL function that expects one.
+                                      */
+    ThreadState() : dummy_context(new Context)
+    {
+        current_context = dummy_context;
+    }
+};
+
+static os::thread_specific_ptr<struct ThreadState> thread_state;
+
+static ThreadState *get_ts(void)
+{
+    ThreadState *ts = thread_state.get();
+
+    if (!ts) {
+        ts = new ThreadState;
+        thread_state.reset(ts);
+    }
+
+    return ts;
+}
+
+static void _retainContext(context_ptr_t ctx)
+{
+    ctx->retain_count++;
+}
+
+void retainContext(uintptr_t context_id)
+{
+    context_map_mutex.lock();
+    if (context_map.find(context_id) != context_map.end())
+        _retainContext(context_map[context_id]);
+    context_map_mutex.unlock();
+}
+
+static bool _releaseContext(context_ptr_t ctx)
+{
+    return !(--ctx->retain_count);
+}
+
+/*
+ * return true if the context was destroyed, false if only its refcount
+ * got decreased. Note that even if the context was destroyed it may
+ * still live, if it's the currently selected context (by setContext).
+ */
+bool releaseContext(uintptr_t context_id)
+{
+    bool res;
+
+    context_map_mutex.lock();
+    /*
+     * This can potentially called (from glX) with an invalid context_id,
+     * so don't assert on it being valid.
+     */
+    if (context_map.find(context_id) != context_map.end()) {
+        res = _releaseContext(context_map[context_id]);
+        if (res)
+            context_map.erase(context_id);
+    }
+    context_map_mutex.unlock();
+
+    return res;
+}
+
+void createContext(uintptr_t context_id)
+{
+    context_ptr_t ctx(new Context);
+
+    context_map_mutex.lock();
+
+    _retainContext(ctx);
+    assert(context_map.find(context_id) == context_map.end());
+    context_map[context_id] = ctx;
+
+    context_map_mutex.unlock();
+}
+
+void setContext(uintptr_t context_id)
+{
+    ThreadState *ts = get_ts();
+    context_ptr_t ctx;
+
+    context_map_mutex.lock();
+
+    assert(context_map.find(context_id) != context_map.end());
+    ctx = context_map[context_id];
+
+    context_map_mutex.unlock();
+
+    ts->current_context = ctx;
+}
+
+void clearContext(void)
+{
+    ThreadState *ts = get_ts();
+
+    ts->current_context = ts->dummy_context;
+}
+
+Context *getContext(void)
+{
+    return get_ts()->current_context.get();
+}
+
+}
diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py
new file mode 100644 (file)
index 0000000..670f8f3
--- /dev/null
@@ -0,0 +1,177 @@
+##########################################################################
+#
+# Copyright 2011 Jose Fonseca
+# Copyright 2008-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""GLX tracing generator."""
+
+
+from gltrace import GlTracer
+from specs.stdapi import API
+from specs.glapi import glapi
+from specs.glxapi import glxapi
+
+
+class GlxTracer(GlTracer):
+
+    def isFunctionPublic(self, function):
+        # The symbols visible in libGL.so can vary, so expose them all
+        return True
+
+    getProcAddressFunctionNames = [
+        "glXGetProcAddress",
+        "glXGetProcAddressARB",
+    ]
+
+    createContextFunctionNames = [
+        'glXCreateContext',
+        'glXCreateContextAttribsARB',
+        'glXCreateContextWithConfigSGIX',
+        'glXCreateNewContext',
+    ]
+
+    destroyContextFunctionNames = [
+        'glXDestroyContext',
+    ]
+
+    makeCurrentFunctionNames = [
+        'glXMakeCurrent',
+        'glXMakeContextCurrent',
+        'glXMakeCurrentReadSGI',
+    ]
+
+    def traceFunctionImplBody(self, function):
+        if function.name in self.destroyContextFunctionNames:
+            print '    gltrace::releaseContext((uintptr_t)ctx);'
+
+        GlTracer.traceFunctionImplBody(self, function)
+
+        if function.name in self.createContextFunctionNames:
+            print '    if (_result != NULL)'
+            print '        gltrace::createContext((uintptr_t)_result);'
+
+        if function.name in self.makeCurrentFunctionNames:
+            print '    if (_result) {'
+            print '        if (ctx != NULL)'
+            print '            gltrace::setContext((uintptr_t)ctx);'
+            print '        else'
+            print '            gltrace::clearContext();'
+            print '    }'
+
+
+if __name__ == '__main__':
+    print
+    print '#include <stdlib.h>'
+    print '#include <string.h>'
+    print
+    print '#ifndef _GNU_SOURCE'
+    print '#define _GNU_SOURCE // for dladdr'
+    print '#endif'
+    print '#include <dlfcn.h>'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print
+    print '// To validate our prototypes'
+    print '#define GL_GLEXT_PROTOTYPES'
+    print '#define GLX_GLXEXT_PROTOTYPES'
+    print
+    print '#include "glproc.hpp"'
+    print '#include "glsize.hpp"'
+    print
+
+    api = API()
+    api.addApi(glxapi)
+    api.addApi(glapi)
+    tracer = GlxTracer()
+    tracer.traceApi(api)
+
+    print r'''
+
+
+/*
+ * Invoke the true dlopen() function.
+ */
+static void *_dlopen(const char *filename, int flag)
+{
+    typedef void * (*PFN_DLOPEN)(const char *, int);
+    static PFN_DLOPEN dlopen_ptr = NULL;
+
+    if (!dlopen_ptr) {
+        dlopen_ptr = (PFN_DLOPEN)dlsym(RTLD_NEXT, "dlopen");
+        if (!dlopen_ptr) {
+            os::log("apitrace: error: dlsym(RTLD_NEXT, \"dlopen\") failed\n");
+            return NULL;
+        }
+    }
+
+    return dlopen_ptr(filename, flag);
+}
+
+
+/*
+ * Several applications, such as Quake3, use dlopen("libGL.so.1"), but
+ * LD_PRELOAD does not intercept symbols obtained via dlopen/dlsym, therefore
+ * we need to intercept the dlopen() call here, and redirect to our wrapper
+ * shared object.
+ */
+extern "C" PUBLIC
+void * dlopen(const char *filename, int flag)
+{
+    void *handle;
+
+    handle = _dlopen(filename, flag);
+
+    const char * libgl_filename = getenv("TRACE_LIBGL");
+
+    if (filename && handle && !libgl_filename) {
+        if (0) {
+            os::log("apitrace: warning: dlopen(\"%s\", 0x%x)\n", filename, flag);
+        }
+
+        // FIXME: handle absolute paths and other versions
+        if (strcmp(filename, "libGL.so") == 0 ||
+            strcmp(filename, "libGL.so.1") == 0) {
+
+            // Use the true libGL.so handle instead of RTLD_NEXT from now on
+            _libGlHandle = handle;
+
+            // Get the file path for our shared object, and use it instead
+            static int dummy = 0xdeedbeef;
+            Dl_info info;
+            if (dladdr(&dummy, &info)) {
+                os::log("apitrace: redirecting dlopen(\"%s\", 0x%x)\n", filename, flag);
+                handle = _dlopen(info.dli_fname, flag);
+            } else {
+                os::log("apitrace: warning: dladdr() failed\n");
+            }
+        }
+    }
+
+    return handle;
+}
+
+
+
+'''
diff --git a/wrappers/opengl32.def b/wrappers/opengl32.def
new file mode 100644 (file)
index 0000000..9e717a7
--- /dev/null
@@ -0,0 +1,371 @@
+LIBRARY opengl32
+
+EXPORTS
+;      GlmfBeginGlsBlock
+;      GlmfCloseMetaFile
+;      GlmfEndGlsBlock
+;      GlmfEndPlayback
+;      GlmfInitPlayback
+;      GlmfPlayGlsRecord
+       glAccum
+       glAlphaFunc
+       glAreTexturesResident
+       glArrayElement
+       glBegin
+       glBindTexture
+       glBitmap
+       glBlendFunc
+       glCallList
+       glCallLists
+       glClear
+       glClearAccum
+       glClearColor
+       glClearDepth
+       glClearIndex
+       glClearStencil
+       glClipPlane
+       glColor3b
+       glColor3bv
+       glColor3d
+       glColor3dv
+       glColor3f
+       glColor3fv
+       glColor3i
+       glColor3iv
+       glColor3s
+       glColor3sv
+       glColor3ub
+       glColor3ubv
+       glColor3ui
+       glColor3uiv
+       glColor3us
+       glColor3usv
+       glColor4b
+       glColor4bv
+       glColor4d
+       glColor4dv
+       glColor4f
+       glColor4fv
+       glColor4i
+       glColor4iv
+       glColor4s
+       glColor4sv
+       glColor4ub
+       glColor4ubv
+       glColor4ui
+       glColor4uiv
+       glColor4us
+       glColor4usv
+       glColorMask
+       glColorMaterial
+       glColorPointer
+       glCopyPixels
+       glCopyTexImage1D
+       glCopyTexImage2D
+       glCopyTexSubImage1D
+       glCopyTexSubImage2D
+       glCullFace
+;      glDebugEntry
+       glDeleteLists
+       glDeleteTextures
+       glDepthFunc
+       glDepthMask
+       glDepthRange
+       glDisable
+       glDisableClientState
+       glDrawArrays
+       glDrawBuffer
+       glDrawElements
+       glDrawPixels
+       glEdgeFlag
+       glEdgeFlagPointer
+       glEdgeFlagv
+       glEnable
+       glEnableClientState
+       glEnd
+       glEndList
+       glEvalCoord1d
+       glEvalCoord1dv
+       glEvalCoord1f
+       glEvalCoord1fv
+       glEvalCoord2d
+       glEvalCoord2dv
+       glEvalCoord2f
+       glEvalCoord2fv
+       glEvalMesh1
+       glEvalMesh2
+       glEvalPoint1
+       glEvalPoint2
+       glFeedbackBuffer
+       glFinish
+       glFlush
+       glFogf
+       glFogfv
+       glFogi
+       glFogiv
+       glFrontFace
+       glFrustum
+       glGenLists
+       glGenTextures
+       glGetBooleanv
+       glGetClipPlane
+       glGetDoublev
+       glGetError
+       glGetFloatv
+       glGetIntegerv
+       glGetLightfv
+       glGetLightiv
+       glGetMapdv
+       glGetMapfv
+       glGetMapiv
+       glGetMaterialfv
+       glGetMaterialiv
+       glGetPixelMapfv
+       glGetPixelMapuiv
+       glGetPixelMapusv
+       glGetPointerv
+       glGetPolygonStipple
+       glGetString
+       glGetTexEnvfv
+       glGetTexEnviv
+       glGetTexGendv
+       glGetTexGenfv
+       glGetTexGeniv
+       glGetTexImage
+       glGetTexLevelParameterfv
+       glGetTexLevelParameteriv
+       glGetTexParameterfv
+       glGetTexParameteriv
+       glHint
+       glIndexMask
+       glIndexPointer
+       glIndexd
+       glIndexdv
+       glIndexf
+       glIndexfv
+       glIndexi
+       glIndexiv
+       glIndexs
+       glIndexsv
+       glIndexub
+       glIndexubv
+       glInitNames
+       glInterleavedArrays
+       glIsEnabled
+       glIsList
+       glIsTexture
+       glLightModelf
+       glLightModelfv
+       glLightModeli
+       glLightModeliv
+       glLightf
+       glLightfv
+       glLighti
+       glLightiv
+       glLineStipple
+       glLineWidth
+       glListBase
+       glLoadIdentity
+       glLoadMatrixd
+       glLoadMatrixf
+       glLoadName
+       glLogicOp
+       glMap1d
+       glMap1f
+       glMap2d
+       glMap2f
+       glMapGrid1d
+       glMapGrid1f
+       glMapGrid2d
+       glMapGrid2f
+       glMaterialf
+       glMaterialfv
+       glMateriali
+       glMaterialiv
+       glMatrixMode
+       glMultMatrixd
+       glMultMatrixf
+       glNewList
+       glNormal3b
+       glNormal3bv
+       glNormal3d
+       glNormal3dv
+       glNormal3f
+       glNormal3fv
+       glNormal3i
+       glNormal3iv
+       glNormal3s
+       glNormal3sv
+       glNormalPointer
+       glOrtho
+       glPassThrough
+       glPixelMapfv
+       glPixelMapuiv
+       glPixelMapusv
+       glPixelStoref
+       glPixelStorei
+       glPixelTransferf
+       glPixelTransferi
+       glPixelZoom
+       glPointSize
+       glPolygonMode
+       glPolygonOffset
+       glPolygonStipple
+       glPopAttrib
+       glPopClientAttrib
+       glPopMatrix
+       glPopName
+       glPrioritizeTextures
+       glPushAttrib
+       glPushClientAttrib
+       glPushMatrix
+       glPushName
+       glRasterPos2d
+       glRasterPos2dv
+       glRasterPos2f
+       glRasterPos2fv
+       glRasterPos2i
+       glRasterPos2iv
+       glRasterPos2s
+       glRasterPos2sv
+       glRasterPos3d
+       glRasterPos3dv
+       glRasterPos3f
+       glRasterPos3fv
+       glRasterPos3i
+       glRasterPos3iv
+       glRasterPos3s
+       glRasterPos3sv
+       glRasterPos4d
+       glRasterPos4dv
+       glRasterPos4f
+       glRasterPos4fv
+       glRasterPos4i
+       glRasterPos4iv
+       glRasterPos4s
+       glRasterPos4sv
+       glReadBuffer
+       glReadPixels
+       glRectd
+       glRectdv
+       glRectf
+       glRectfv
+       glRecti
+       glRectiv
+       glRects
+       glRectsv
+       glRenderMode
+       glRotated
+       glRotatef
+       glScaled
+       glScalef
+       glScissor
+       glSelectBuffer
+       glShadeModel
+       glStencilFunc
+       glStencilMask
+       glStencilOp
+       glTexCoord1d
+       glTexCoord1dv
+       glTexCoord1f
+       glTexCoord1fv
+       glTexCoord1i
+       glTexCoord1iv
+       glTexCoord1s
+       glTexCoord1sv
+       glTexCoord2d
+       glTexCoord2dv
+       glTexCoord2f
+       glTexCoord2fv
+       glTexCoord2i
+       glTexCoord2iv
+       glTexCoord2s
+       glTexCoord2sv
+       glTexCoord3d
+       glTexCoord3dv
+       glTexCoord3f
+       glTexCoord3fv
+       glTexCoord3i
+       glTexCoord3iv
+       glTexCoord3s
+       glTexCoord3sv
+       glTexCoord4d
+       glTexCoord4dv
+       glTexCoord4f
+       glTexCoord4fv
+       glTexCoord4i
+       glTexCoord4iv
+       glTexCoord4s
+       glTexCoord4sv
+       glTexCoordPointer
+       glTexEnvf
+       glTexEnvfv
+       glTexEnvi
+       glTexEnviv
+       glTexGend
+       glTexGendv
+       glTexGenf
+       glTexGenfv
+       glTexGeni
+       glTexGeniv
+       glTexImage1D
+       glTexImage2D
+       glTexParameterf
+       glTexParameterfv
+       glTexParameteri
+       glTexParameteriv
+       glTexSubImage1D
+       glTexSubImage2D
+       glTranslated
+       glTranslatef
+       glVertex2d
+       glVertex2dv
+       glVertex2f
+       glVertex2fv
+       glVertex2i
+       glVertex2iv
+       glVertex2s
+       glVertex2sv
+       glVertex3d
+       glVertex3dv
+       glVertex3f
+       glVertex3fv
+       glVertex3i
+       glVertex3iv
+       glVertex3s
+       glVertex3sv
+       glVertex4d
+       glVertex4dv
+       glVertex4f
+       glVertex4fv
+       glVertex4i
+       glVertex4iv
+       glVertex4s
+       glVertex4sv
+       glVertexPointer
+       glViewport
+       wglChoosePixelFormat
+       wglCopyContext
+       wglCreateContext
+       wglCreateLayerContext
+       wglDeleteContext
+       wglDescribeLayerPlane
+       wglDescribePixelFormat
+       wglGetCurrentContext
+       wglGetCurrentDC
+       wglGetDefaultProcAddress
+       wglGetLayerPaletteEntries
+       wglGetPixelFormat
+       wglGetProcAddress
+       wglMakeCurrent
+       wglRealizeLayerPalette
+       wglSetLayerPaletteEntries
+       wglSetPixelFormat
+       wglShareLists
+       wglSwapBuffers
+       wglSwapLayerBuffers
+       wglSwapMultipleBuffers
+       wglUseFontBitmapsA
+       wglUseFontBitmapsW
+       wglUseFontOutlinesA
+       wglUseFontOutlinesW
diff --git a/wrappers/trace.cpp b/wrappers/trace.cpp
new file mode 100644 (file)
index 0000000..eb68934
--- /dev/null
@@ -0,0 +1,115 @@
+/**************************************************************************
+ *
+ * Copyright 2010-2011 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef ANDROID
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/system_properties.h>
+#endif
+
+#include "os.hpp"
+#include "os_string.hpp"
+#include "trace.hpp"
+
+
+namespace trace {
+
+
+#ifdef ANDROID
+
+static bool
+isZygoteProcess(void)
+{
+    os::String proc_name;
+
+    proc_name = os::getProcessName();
+    proc_name.trimDirectory();
+
+    return strcmp(proc_name, "app_process") == 0;
+}
+
+static os::String
+getZygoteProcessName(void)
+{
+    os::String path;
+    size_t size = PATH_MAX;
+    char *buf = path.buf(size);
+    ssize_t len;
+
+    int fd = open("/proc/self/cmdline", O_RDONLY);
+
+    assert(fd >= 0);
+    len = read(fd, buf, size - 1);
+    close(fd);
+    path.truncate(len);
+
+    return path;
+}
+
+bool
+isTracingEnabled(void)
+{
+    static pid_t cached_pid;
+    static bool enabled;
+    pid_t pid;
+
+    pid = getpid();
+    if (cached_pid == pid)
+        return enabled;
+    cached_pid = pid;
+
+    if (!isZygoteProcess()) {
+        os::log("apitrace[%d]: enabled for standalone %s",
+                pid, (const char *)os::getProcessName());
+        enabled = true;
+        return true;
+    }
+
+    char target_proc_name[PROP_VALUE_MAX] = "";
+    os::String proc_name;
+
+    proc_name = getZygoteProcessName();
+    proc_name.trimDirectory();
+
+    __system_property_get("debug.apitrace.procname", target_proc_name);
+    enabled = !strcmp(target_proc_name, proc_name);
+    os::log("apitrace[%d]: %s for %s",
+            pid, enabled ? "enabled" : "disabled", (const char *)proc_name);
+
+    return enabled;
+}
+
+#endif /* ANDROID */
+
+
+} /* namespace trace */
+
diff --git a/wrappers/trace.hpp b/wrappers/trace.hpp
new file mode 100644 (file)
index 0000000..997617e
--- /dev/null
@@ -0,0 +1,56 @@
+/**************************************************************************
+ *
+ * Copyright 2011 Jose Fonseca
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+/*
+ * Comon definitions for all tracers.
+ */
+
+
+#ifndef _TRACE_HPP_
+#define _TRACE_HPP_
+
+
+namespace trace {
+
+
+#ifdef ANDROID
+
+bool isTracingEnabled(void);
+
+#else /* !ANDROID */
+
+static inline bool
+isTracingEnabled(void) {
+    return true;
+}
+
+#endif /* !ANDROID */
+
+
+} /* namespace trace */
+
+
+#endif /* _TRACE_HPP_ */
diff --git a/wrappers/trace.py b/wrappers/trace.py
new file mode 100644 (file)
index 0000000..4e52cf6
--- /dev/null
@@ -0,0 +1,728 @@
+##########################################################################
+#
+# Copyright 2008-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+"""Common trace code generation."""
+
+
+# Adjust path
+import os.path
+import sys
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
+
+
+import specs.stdapi as stdapi
+
+
+def getWrapperInterfaceName(interface):
+    return "Wrap" + interface.expr
+
+
+class ComplexValueSerializer(stdapi.OnceVisitor):
+    '''Type visitors which generates serialization functions for
+    complex types.
+    
+    Simple types are serialized inline.
+    '''
+
+    def __init__(self, serializer):
+        stdapi.OnceVisitor.__init__(self)
+        self.serializer = serializer
+
+    def visitVoid(self, literal):
+        pass
+
+    def visitLiteral(self, literal):
+        pass
+
+    def visitString(self, string):
+        pass
+
+    def visitConst(self, const):
+        self.visit(const.type)
+
+    def visitStruct(self, struct):
+        for type, name in struct.members:
+            self.visit(type)
+        print 'static void _write__%s(const %s &value) {' % (struct.tag, struct.expr)
+        print '    static const char * members[%u] = {' % (len(struct.members),)
+        for type, name,  in struct.members:
+            print '        "%s",' % (name,)
+        print '    };'
+        print '    static const trace::StructSig sig = {'
+        print '       %u, "%s", %u, members' % (struct.id, struct.name, len(struct.members))
+        print '    };'
+        print '    trace::localWriter.beginStruct(&sig);'
+        for type, name in struct.members:
+            self.serializer.visit(type, 'value.%s' % (name,))
+        print '    trace::localWriter.endStruct();'
+        print '}'
+        print
+
+    def visitArray(self, array):
+        self.visit(array.type)
+
+    def visitBlob(self, array):
+        pass
+
+    def visitEnum(self, enum):
+        print 'static const trace::EnumValue _enum%s_values[] = {' % (enum.tag)
+        for value in enum.values:
+            print '   {"%s", %s},' % (value, value)
+        print '};'
+        print
+        print 'static const trace::EnumSig _enum%s_sig = {' % (enum.tag)
+        print '   %u, %u, _enum%s_values' % (enum.id, len(enum.values), enum.tag)
+        print '};'
+        print
+
+    def visitBitmask(self, bitmask):
+        print 'static const trace::BitmaskFlag _bitmask%s_flags[] = {' % (bitmask.tag)
+        for value in bitmask.values:
+            print '   {"%s", %s},' % (value, value)
+        print '};'
+        print
+        print 'static const trace::BitmaskSig _bitmask%s_sig = {' % (bitmask.tag)
+        print '   %u, %u, _bitmask%s_flags' % (bitmask.id, len(bitmask.values), bitmask.tag)
+        print '};'
+        print
+
+    def visitPointer(self, pointer):
+        self.visit(pointer.type)
+
+    def visitIntPointer(self, pointer):
+        pass
+
+    def visitObjPointer(self, pointer):
+        self.visit(pointer.type)
+
+    def visitLinearPointer(self, pointer):
+        self.visit(pointer.type)
+
+    def visitHandle(self, handle):
+        self.visit(handle.type)
+
+    def visitReference(self, reference):
+        self.visit(reference.type)
+
+    def visitAlias(self, alias):
+        self.visit(alias.type)
+
+    def visitOpaque(self, opaque):
+        pass
+
+    def visitInterface(self, interface):
+        pass
+
+    def visitPolymorphic(self, polymorphic):
+        if not polymorphic.contextLess:
+            return
+        print 'static void _write__%s(int selector, const %s & value) {' % (polymorphic.tag, polymorphic.expr)
+        print '    switch (selector) {'
+        for cases, type in polymorphic.iterSwitch():
+            for case in cases:
+                print '    %s:' % case
+            self.serializer.visit(type, 'static_cast<%s>(value)' % (type,))
+            print '        break;'
+        print '    }'
+        print '}'
+        print
+
+
+class ValueSerializer(stdapi.Visitor):
+    '''Visitor which generates code to serialize any type.
+    
+    Simple types are serialized inline here, whereas the serialization of
+    complex types is dispatched to the serialization functions generated by
+    ComplexValueSerializer visitor above.
+    '''
+
+    def visitLiteral(self, literal, instance):
+        print '    trace::localWriter.write%s(%s);' % (literal.kind, instance)
+
+    def visitString(self, string, instance):
+        if not string.wide:
+            cast = 'const char *'
+            suffix = 'String'
+        else:
+            cast = 'const wchar_t *'
+            suffix = 'WString'
+        if cast != string.expr:
+            # reinterpret_cast is necessary for GLubyte * <=> char *
+            instance = 'reinterpret_cast<%s>(%s)' % (cast, instance)
+        if string.length is not None:
+            length = ', %s' % string.length
+        else:
+            length = ''
+        print '    trace::localWriter.write%s(%s%s);' % (suffix, instance, length)
+
+    def visitConst(self, const, instance):
+        self.visit(const.type, instance)
+
+    def visitStruct(self, struct, instance):
+        print '    _write__%s(%s);' % (struct.tag, instance)
+
+    def visitArray(self, array, instance):
+        length = '_c' + array.type.tag
+        index = '_i' + array.type.tag
+        print '    if (%s) {' % instance
+        print '        size_t %s = %s > 0 ? %s : 0;' % (length, array.length, array.length)
+        print '        trace::localWriter.beginArray(%s);' % length
+        print '        for (size_t %s = 0; %s < %s; ++%s) {' % (index, index, length, index)
+        print '            trace::localWriter.beginElement();'
+        self.visit(array.type, '(%s)[%s]' % (instance, index))
+        print '            trace::localWriter.endElement();'
+        print '        }'
+        print '        trace::localWriter.endArray();'
+        print '    } else {'
+        print '        trace::localWriter.writeNull();'
+        print '    }'
+
+    def visitBlob(self, blob, instance):
+        print '    trace::localWriter.writeBlob(%s, %s);' % (instance, blob.size)
+
+    def visitEnum(self, enum, instance):
+        print '    trace::localWriter.writeEnum(&_enum%s_sig, %s);' % (enum.tag, instance)
+
+    def visitBitmask(self, bitmask, instance):
+        print '    trace::localWriter.writeBitmask(&_bitmask%s_sig, %s);' % (bitmask.tag, instance)
+
+    def visitPointer(self, pointer, instance):
+        print '    if (%s) {' % instance
+        print '        trace::localWriter.beginArray(1);'
+        print '        trace::localWriter.beginElement();'
+        self.visit(pointer.type, "*" + instance)
+        print '        trace::localWriter.endElement();'
+        print '        trace::localWriter.endArray();'
+        print '    } else {'
+        print '        trace::localWriter.writeNull();'
+        print '    }'
+
+    def visitIntPointer(self, pointer, instance):
+        print '    trace::localWriter.writePointer((uintptr_t)%s);' % instance
+
+    def visitObjPointer(self, pointer, instance):
+        print '    trace::localWriter.writePointer((uintptr_t)%s);' % instance
+
+    def visitLinearPointer(self, pointer, instance):
+        print '    trace::localWriter.writePointer((uintptr_t)%s);' % instance
+
+    def visitReference(self, reference, instance):
+        self.visit(reference.type, instance)
+
+    def visitHandle(self, handle, instance):
+        self.visit(handle.type, instance)
+
+    def visitAlias(self, alias, instance):
+        self.visit(alias.type, instance)
+
+    def visitOpaque(self, opaque, instance):
+        print '    trace::localWriter.writePointer((uintptr_t)%s);' % instance
+
+    def visitInterface(self, interface, instance):
+        assert False
+
+    def visitPolymorphic(self, polymorphic, instance):
+        if polymorphic.contextLess:
+            print '    _write__%s(%s, %s);' % (polymorphic.tag, polymorphic.switchExpr, instance)
+        else:
+            print '    switch (%s) {' % polymorphic.switchExpr
+            for cases, type in polymorphic.iterSwitch():
+                for case in cases:
+                    print '    %s:' % case
+                self.visit(type, 'static_cast<%s>(%s)' % (type, instance))
+                print '        break;'
+            print '    }'
+
+
+class WrapDecider(stdapi.Traverser):
+    '''Type visitor which will decide wheter this type will need wrapping or not.
+    
+    For complex types (arrays, structures), we need to know this before hand.
+    '''
+
+    def __init__(self):
+        self.needsWrapping = False
+
+    def visitLinearPointer(self, void):
+        pass
+
+    def visitInterface(self, interface):
+        self.needsWrapping = True
+
+
+class ValueWrapper(stdapi.Traverser):
+    '''Type visitor which will generate the code to wrap an instance.
+    
+    Wrapping is necessary mostly for interfaces, however interface pointers can
+    appear anywhere inside complex types.
+    '''
+
+    def visitStruct(self, struct, instance):
+        for type, name in struct.members:
+            self.visit(type, "(%s).%s" % (instance, name))
+
+    def visitArray(self, array, instance):
+        print "    if (%s) {" % instance
+        print "        for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array.length
+        self.visit(array.type, instance + "[_i]")
+        print "        }"
+        print "    }"
+
+    def visitPointer(self, pointer, instance):
+        print "    if (%s) {" % instance
+        self.visit(pointer.type, "*" + instance)
+        print "    }"
+    
+    def visitObjPointer(self, pointer, instance):
+        elem_type = pointer.type.mutable()
+        if isinstance(elem_type, stdapi.Interface):
+            self.visitInterfacePointer(elem_type, instance)
+        elif isinstance(elem_type, stdapi.Alias) and isinstance(elem_type.type, stdapi.Interface):
+            self.visitInterfacePointer(elem_type.type, instance)
+        else:
+            self.visitPointer(pointer, instance)
+    
+    def visitInterface(self, interface, instance):
+        raise NotImplementedError
+
+    def visitInterfacePointer(self, interface, instance):
+        print "    if (%s) {" % instance
+        print "        %s = new %s(%s);" % (instance, getWrapperInterfaceName(interface), instance)
+        print "    }"
+    
+    def visitPolymorphic(self, type, instance):
+        # XXX: There might be polymorphic values that need wrapping in the future
+        raise NotImplementedError
+
+
+class ValueUnwrapper(ValueWrapper):
+    '''Reverse of ValueWrapper.'''
+
+    allocated = False
+
+    def visitStruct(self, struct, instance):
+        if not self.allocated:
+            # Argument is constant. We need to create a non const
+            print '    {'
+            print "        %s * _t = static_cast<%s *>(alloca(sizeof *_t));" % (struct, struct)
+            print '        *_t = %s;' % (instance,)
+            assert instance.startswith('*')
+            print '        %s = _t;' % (instance[1:],)
+            instance = '*_t'
+            self.allocated = True
+            try:
+                return ValueWrapper.visitStruct(self, struct, instance)
+            finally:
+                print '    }'
+        else:
+            return ValueWrapper.visitStruct(self, struct, instance)
+
+    def visitArray(self, array, instance):
+        if self.allocated or isinstance(instance, stdapi.Interface):
+            return ValueWrapper.visitArray(self, array, instance)
+        elem_type = array.type.mutable()
+        print "    if (%s && %s) {" % (instance, array.length)
+        print "        %s * _t = static_cast<%s *>(alloca(%s * sizeof *_t));" % (elem_type, elem_type, array.length)
+        print "        for (size_t _i = 0, _s = %s; _i < _s; ++_i) {" % array.length
+        print "            _t[_i] = %s[_i];" % instance 
+        self.allocated = True
+        self.visit(array.type, "_t[_i]")
+        print "        }"
+        print "        %s = _t;" % instance
+        print "    }"
+
+    def visitInterfacePointer(self, interface, instance):
+        print r'    if (%s) {' % instance
+        print r'        const %s *pWrapper = static_cast<const %s*>(%s);' % (getWrapperInterfaceName(interface), getWrapperInterfaceName(interface), instance)
+        print r'        if (pWrapper && pWrapper->m_dwMagic == 0xd8365d6c) {'
+        print r'            %s = pWrapper->m_pInstance;' % (instance,)
+        print r'        } else {'
+        print r'            os::log("apitrace: warning: %%s: unexpected %%s pointer\n", __FUNCTION__, "%s");' % interface.name
+        print r'        }'
+        print r'    }'
+
+
+class Tracer:
+    '''Base class to orchestrate the code generation of API tracing.'''
+
+    def __init__(self):
+        self.api = None
+
+    def serializerFactory(self):
+        '''Create a serializer.
+        
+        Can be overriden by derived classes to inject their own serialzer.
+        '''
+
+        return ValueSerializer()
+
+    def traceApi(self, api):
+        self.api = api
+
+        self.header(api)
+
+        # Includes
+        for header in api.headers:
+            print header
+        print
+
+        # Generate the serializer functions
+        types = api.getAllTypes()
+        visitor = ComplexValueSerializer(self.serializerFactory())
+        map(visitor.visit, types)
+        print
+
+        # Interfaces wrapers
+        self.traceInterfaces(api)
+
+        # Function wrappers
+        self.interface = None
+        self.base = None
+        map(self.traceFunctionDecl, api.functions)
+        map(self.traceFunctionImpl, api.functions)
+        print
+
+        self.footer(api)
+
+    def header(self, api):
+        print '#ifdef _WIN32'
+        print '#  include <malloc.h> // alloca'
+        print '#  ifndef alloca'
+        print '#    define alloca _alloca'
+        print '#  endif'
+        print '#else'
+        print '#  include <alloca.h> // alloca'
+        print '#endif'
+        print
+        print '#include "trace.hpp"'
+        print
+
+    def footer(self, api):
+        pass
+
+    def traceFunctionDecl(self, function):
+        # Per-function declarations
+
+        if not function.internal:
+            if function.args:
+                print 'static const char * _%s_args[%u] = {%s};' % (function.name, len(function.args), ', '.join(['"%s"' % arg.name for arg in function.args]))
+            else:
+                print 'static const char ** _%s_args = NULL;' % (function.name,)
+            print 'static const trace::FunctionSig _%s_sig = {%u, "%s", %u, _%s_args};' % (function.name, function.id, function.name, len(function.args), function.name)
+            print
+
+    def isFunctionPublic(self, function):
+        return True
+
+    def traceFunctionImpl(self, function):
+        if self.isFunctionPublic(function):
+            print 'extern "C" PUBLIC'
+        else:
+            print 'extern "C" PRIVATE'
+        print function.prototype() + ' {'
+        if function.type is not stdapi.Void:
+            print '    %s _result;' % function.type
+
+        # No-op if tracing is disabled
+        print '    if (!trace::isTracingEnabled()) {'
+        Tracer.invokeFunction(self, function)
+        if function.type is not stdapi.Void:
+            print '        return _result;'
+        else:
+            print '        return;'
+        print '    }'
+
+        self.traceFunctionImplBody(function)
+        if function.type is not stdapi.Void:
+            print '    return _result;'
+        print '}'
+        print
+
+    def traceFunctionImplBody(self, function):
+        if not function.internal:
+            print '    unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
+            for arg in function.args:
+                if not arg.output:
+                    self.unwrapArg(function, arg)
+                    self.serializeArg(function, arg)
+            print '    trace::localWriter.endEnter();'
+        self.invokeFunction(function)
+        if not function.internal:
+            print '    trace::localWriter.beginLeave(_call);'
+            for arg in function.args:
+                if arg.output:
+                    self.serializeArg(function, arg)
+                    self.wrapArg(function, arg)
+            if function.type is not stdapi.Void:
+                self.serializeRet(function, "_result")
+            print '    trace::localWriter.endLeave();'
+            if function.type is not stdapi.Void:
+                self.wrapRet(function, "_result")
+
+    def invokeFunction(self, function, prefix='_', suffix=''):
+        if function.type is stdapi.Void:
+            result = ''
+        else:
+            result = '_result = '
+        dispatch = prefix + function.name + suffix
+        print '    %s%s(%s);' % (result, dispatch, ', '.join([str(arg.name) for arg in function.args]))
+
+    def serializeArg(self, function, arg):
+        print '    trace::localWriter.beginArg(%u);' % (arg.index,)
+        self.serializeArgValue(function, arg)
+        print '    trace::localWriter.endArg();'
+
+    def serializeArgValue(self, function, arg):
+        self.serializeValue(arg.type, arg.name)
+
+    def wrapArg(self, function, arg):
+        assert not isinstance(arg.type, stdapi.ObjPointer)
+
+        from specs.winapi import REFIID
+        riid = None
+        for other_arg in function.args:
+            if not other_arg.output and other_arg.type is REFIID:
+                riid = other_arg
+        if riid is not None \
+           and isinstance(arg.type, stdapi.Pointer) \
+           and isinstance(arg.type.type, stdapi.ObjPointer):
+            self.wrapIid(function, riid, arg)
+            return
+
+        self.wrapValue(arg.type, arg.name)
+
+    def unwrapArg(self, function, arg):
+        self.unwrapValue(arg.type, arg.name)
+
+    def serializeRet(self, function, instance):
+        print '    trace::localWriter.beginReturn();'
+        self.serializeValue(function.type, instance)
+        print '    trace::localWriter.endReturn();'
+
+    def serializeValue(self, type, instance):
+        serializer = self.serializerFactory()
+        serializer.visit(type, instance)
+
+    def wrapRet(self, function, instance):
+        self.wrapValue(function.type, instance)
+
+    def unwrapRet(self, function, instance):
+        self.unwrapValue(function.type, instance)
+
+    def needsWrapping(self, type):
+        visitor = WrapDecider()
+        visitor.visit(type)
+        return visitor.needsWrapping
+
+    def wrapValue(self, type, instance):
+        if self.needsWrapping(type):
+            visitor = ValueWrapper()
+            visitor.visit(type, instance)
+
+    def unwrapValue(self, type, instance):
+        if self.needsWrapping(type):
+            visitor = ValueUnwrapper()
+            visitor.visit(type, instance)
+
+    def traceInterfaces(self, api):
+        interfaces = api.getAllInterfaces()
+        if not interfaces:
+            return
+        map(self.declareWrapperInterface, interfaces)
+        self.implementIidWrapper(api)
+        map(self.implementWrapperInterface, interfaces)
+        print
+
+    def declareWrapperInterface(self, interface):
+        print "class %s : public %s " % (getWrapperInterfaceName(interface), interface.name)
+        print "{"
+        print "public:"
+        print "    %s(%s * pInstance);" % (getWrapperInterfaceName(interface), interface.name)
+        print "    virtual ~%s();" % getWrapperInterfaceName(interface)
+        print
+        for method in interface.iterMethods():
+            print "    " + method.prototype() + ";"
+        print
+        #print "private:"
+        for type, name, value in self.enumWrapperInterfaceVariables(interface):
+            print '    %s %s;' % (type, name)
+        print "};"
+        print
+
+    def enumWrapperInterfaceVariables(self, interface):
+        return [
+            ("DWORD", "m_dwMagic", "0xd8365d6c"),
+            ("%s *" % interface.name, "m_pInstance", "pInstance"),
+        ] 
+
+    def implementWrapperInterface(self, interface):
+        self.interface = interface
+
+        print '%s::%s(%s * pInstance) {' % (getWrapperInterfaceName(interface), getWrapperInterfaceName(interface), interface.name)
+        for type, name, value in self.enumWrapperInterfaceVariables(interface):
+            print '    %s = %s;' % (name, value)
+        print '}'
+        print
+        print '%s::~%s() {' % (getWrapperInterfaceName(interface), getWrapperInterfaceName(interface))
+        print '}'
+        print
+        
+        for base, method in interface.iterBaseMethods():
+            self.base = base
+            self.implementWrapperInterfaceMethod(interface, base, method)
+
+        print
+
+    def implementWrapperInterfaceMethod(self, interface, base, method):
+        print method.prototype(getWrapperInterfaceName(interface) + '::' + method.name) + ' {'
+        if method.type is not stdapi.Void:
+            print '    %s _result;' % method.type
+    
+        self.implementWrapperInterfaceMethodBody(interface, base, method)
+    
+        if method.type is not stdapi.Void:
+            print '    return _result;'
+        print '}'
+        print
+
+    def implementWrapperInterfaceMethodBody(self, interface, base, method):
+        assert not method.internal
+
+        print '    static const char * _args[%u] = {%s};' % (len(method.args) + 1, ', '.join(['"this"'] + ['"%s"' % arg.name for arg in method.args]))
+        print '    static const trace::FunctionSig _sig = {%u, "%s", %u, _args};' % (method.id, interface.name + '::' + method.name, len(method.args) + 1)
+
+        print '    %s *_this = static_cast<%s *>(m_pInstance);' % (base, base)
+
+        print '    unsigned _call = trace::localWriter.beginEnter(&_sig);'
+        print '    trace::localWriter.beginArg(0);'
+        print '    trace::localWriter.writePointer((uintptr_t)m_pInstance);'
+        print '    trace::localWriter.endArg();'
+        for arg in method.args:
+            if not arg.output:
+                self.unwrapArg(method, arg)
+                self.serializeArg(method, arg)
+        print '    trace::localWriter.endEnter();'
+        
+        self.invokeMethod(interface, base, method)
+
+        print '    trace::localWriter.beginLeave(_call);'
+        for arg in method.args:
+            if arg.output:
+                self.serializeArg(method, arg)
+                self.wrapArg(method, arg)
+
+        if method.type is not stdapi.Void:
+            self.serializeRet(method, '_result')
+        print '    trace::localWriter.endLeave();'
+        if method.type is not stdapi.Void:
+            self.wrapRet(method, '_result')
+
+        if method.name == 'Release':
+            assert method.type is not stdapi.Void
+            print '    if (!_result)'
+            print '        delete this;'
+
+    def implementIidWrapper(self, api):
+        print r'static void'
+        print r'warnIID(const char *functionName, REFIID riid, const char *reason) {'
+        print r'    os::log("apitrace: warning: %s: %s IID {0x%08lX,0x%04X,0x%04X,{0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X,0x%02X}}\n",'
+        print r'            functionName, reason,'
+        print r'            riid.Data1, riid.Data2, riid.Data3,'
+        print r'            riid.Data4[0], riid.Data4[1], riid.Data4[2], riid.Data4[3], riid.Data4[4], riid.Data4[5], riid.Data4[6], riid.Data4[7]);'
+        print r'}'
+        print 
+        print r'static void'
+        print r'wrapIID(const char *functionName, REFIID riid, void * * ppvObj) {'
+        print r'    if (!ppvObj || !*ppvObj) {'
+        print r'        return;'
+        print r'    }'
+        else_ = ''
+        for iface in api.getAllInterfaces():
+            print r'    %sif (riid == IID_%s) {' % (else_, iface.name)
+            print r'        *ppvObj = new Wrap%s((%s *) *ppvObj);' % (iface.name, iface.name)
+            print r'    }'
+            else_ = 'else '
+        print r'    %s{' % else_
+        print r'        warnIID(functionName, riid, "unknown");'
+        print r'    }'
+        print r'}'
+        print
+
+    def wrapIid(self, function, riid, out):
+        # Cast output arg to `void **` if necessary
+        out_name = out.name
+        obj_type = out.type.type.type
+        if not obj_type is stdapi.Void:
+            assert isinstance(obj_type, stdapi.Interface)
+            out_name = 'reinterpret_cast<void * *>(%s)' % out_name
+
+        print r'    if (%s && *%s) {' % (out.name, out.name)
+        functionName = function.name
+        else_ = ''
+        if self.interface is not None:
+            functionName = self.interface.name + '::' + functionName
+            print r'        if (*%s == m_pInstance &&' % (out_name,)
+            print r'            (%s)) {' % ' || '.join('%s == IID_%s' % (riid.name, iface.name) for iface in self.interface.iterBases())
+            print r'            *%s = this;' % (out_name,)
+            print r'        }'
+            else_ = 'else '
+        print r'        %s{' % else_
+        print r'             wrapIID("%s", %s, %s);' % (functionName, riid.name, out_name)
+        print r'        }'
+        print r'    }'
+
+    def invokeMethod(self, interface, base, method):
+        if method.type is stdapi.Void:
+            result = ''
+        else:
+            result = '_result = '
+        print '    %s_this->%s(%s);' % (result, method.name, ', '.join([str(arg.name) for arg in method.args]))
+    
+    def emit_memcpy(self, dest, src, length):
+        print '        unsigned _call = trace::localWriter.beginEnter(&trace::memcpy_sig);'
+        print '        trace::localWriter.beginArg(0);'
+        print '        trace::localWriter.writePointer((uintptr_t)%s);' % dest
+        print '        trace::localWriter.endArg();'
+        print '        trace::localWriter.beginArg(1);'
+        print '        trace::localWriter.writeBlob(%s, %s);' % (src, length)
+        print '        trace::localWriter.endArg();'
+        print '        trace::localWriter.beginArg(2);'
+        print '        trace::localWriter.writeUInt(%s);' % length
+        print '        trace::localWriter.endArg();'
+        print '        trace::localWriter.endEnter();'
+        print '        trace::localWriter.beginLeave(_call);'
+        print '        trace::localWriter.endLeave();'
+    
+    def fake_call(self, function, args):
+        print '            unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
+        for arg, instance in zip(function.args, args):
+            assert not arg.output
+            print '            trace::localWriter.beginArg(%u);' % (arg.index,)
+            self.serializeValue(arg.type, instance)
+            print '            trace::localWriter.endArg();'
+        print '            trace::localWriter.endEnter();'
+        print '            trace::localWriter.beginLeave(_fake_call);'
+        print '            trace::localWriter.endLeave();'
+       
diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py
new file mode 100644 (file)
index 0000000..317c542
--- /dev/null
@@ -0,0 +1,103 @@
+##########################################################################
+#
+# Copyright 2008-2009 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+"""WGL tracing code generator."""
+
+
+from gltrace import GlTracer
+from specs.stdapi import API
+from specs.glapi import glapi
+from specs.wglapi import wglapi
+
+
+class WglTracer(GlTracer):
+
+    getProcAddressFunctionNames = [
+        "wglGetProcAddress",
+    ]
+
+    createContextFunctionNames = [
+        'wglCreateContext',
+        'wglCreateContextAttribsARB',
+        'wglCreateLayerContext',
+    ]
+
+    destroyContextFunctionNames = [
+        'wglDeleteContext',
+    ]
+
+    makeCurrentFunctionNames = [
+        'wglMakeCurrent',
+        'wglMakeContextCurrentARB',
+        'wglMakeContextCurrentEXT',
+    ]
+
+    def traceFunctionImplBody(self, function):
+        if function.name in self.destroyContextFunctionNames:
+            # Unlike other GL APIs like EGL or GLX, WGL will make the context
+            # inactive if it's currently the active context.
+            print '    if (_wglGetCurrentContext() == hglrc) {'
+            print '        gltrace::clearContext();'
+            print '    }'
+            print '    gltrace::releaseContext((uintptr_t)hglrc);'
+
+        GlTracer.traceFunctionImplBody(self, function)
+
+        if function.name in self.createContextFunctionNames:
+            print '    if (_result)'
+            print '        gltrace::createContext((uintptr_t)_result);'
+
+        if function.name in self.makeCurrentFunctionNames:
+            print '    if (_result) {'
+            print '        if (hglrc != NULL)'
+            print '            gltrace::setContext((uintptr_t)hglrc);'
+            print '        else'
+            print '            gltrace::clearContext();'
+            print '    }'
+
+
+if __name__ == '__main__':
+    print
+    print '#define _GDI32_'
+    print
+    print '#include <string.h>'
+    print '#include <windows.h>'
+    print
+    print '#include "trace_writer_local.hpp"'
+    print '#include "os.hpp"'
+    print
+    print '// To validate our prototypes'
+    print '#define GL_GLEXT_PROTOTYPES'
+    print '#define WGL_GLXEXT_PROTOTYPES'
+    print
+    print '#include "glproc.hpp"'
+    print '#include "glsize.hpp"'
+    print
+    api = API()
+    api.addApi(glapi)
+    api.addApi(wglapi)
+    tracer = WglTracer()
+    tracer.traceApi(api)