Restore the legacy PowerVR SDK 'BasicTnL' OpenGL ES 1.1 sample
OpenGL ES 1.1 will be removed from the main branch, but this sample can
remain available as basic test of a legacy OpenGL ES 1.1 build.
This partially reverts https://swiftshader-review.googlesource.com/c/SwiftShader/+/43190
Bug: b/147516027
Change-Id: I344b5c591e6560317c53cfa2da9f092e948e3cfa
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45709
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 899f676..ce17b8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,7 +117,8 @@
option_if_not_defined(SWIFTSHADER_USE_GROUP_SOURCES "Group the source files in a folder tree for Visual Studio" TRUE)
-option_if_not_defined(SWIFTSHADER_BUILD_TESTS "Build unit tests" TRUE)
+option_if_not_defined(SWIFTSHADER_BUILD_SAMPLES "Build sample programs" TRUE)
+option_if_not_defined(SWIFTSHADER_BUILD_TESTS "Build test programs" TRUE)
option_if_not_defined(SWIFTSHADER_BUILD_BENCHMARKS "Build benchmarks" FALSE)
option_if_not_defined(SWIFTSHADER_MSAN "Build with memory sanitizer" FALSE)
@@ -179,6 +180,7 @@
set(SOURCE_DIR ${SWIFTSHADER_DIR}/src)
set(THIRD_PARTY_DIR ${SWIFTSHADER_DIR}/third_party)
set(TESTS_DIR ${SWIFTSHADER_DIR}/tests)
+set(POWERVR_DIR ${THIRD_PARTY_DIR}/PowerVR_SDK)
###########################################################
# Initialize submodules
@@ -733,6 +735,51 @@
# Sample programs and tests
###########################################################
+if(SWIFTSHADER_BUILD_SAMPLES)
+ if(WIN32)
+ add_executable(BasicTnL
+ ${POWERVR_DIR}/Examples/Beginner/04_BasicTnL/OGLES/OGLESBasicTnL.cpp
+ ${POWERVR_DIR}/Shell/PVRShell.cpp
+ ${POWERVR_DIR}/Shell/OS/Windows/PVRShellOS.cpp
+ ${POWERVR_DIR}/Shell/API/KEGL/PVRShellAPI.cpp
+ )
+ target_include_directories(BasicTnL PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${POWERVR_DIR}/Shell
+ ${POWERVR_DIR}/Shell/OS/Windows
+ ${POWERVR_DIR}/Shell/API/KEGL
+ ${POWERVR_DIR}/Builds/Include
+ )
+ set_target_properties(BasicTnL PROPERTIES
+ COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+ FOLDER "Samples"
+ )
+ target_link_libraries(BasicTnL libEGL libGLES_CM)
+ set_property(TARGET BasicTnL APPEND_STRING PROPERTY LINK_FLAGS "/SUBSYSTEM:WINDOWS")
+ set(CMAKE_DEFAULT_STARTUP_PROJECT BasicTnL)
+ elseif(LINUX)
+ add_executable(BasicTnL
+ ${POWERVR_DIR}/Examples/Beginner/04_BasicTnL/OGLES/OGLESBasicTnL.cpp
+ ${POWERVR_DIR}/Shell/PVRShell.cpp
+ ${POWERVR_DIR}/Shell/OS/LinuxX11/PVRShellOS.cpp
+ ${POWERVR_DIR}/Shell/API/KEGL/PVRShellAPI.cpp
+ )
+ target_include_directories(BasicTnL PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${POWERVR_DIR}/Shell
+ ${POWERVR_DIR}/Shell/OS/LinuxX11
+ ${POWERVR_DIR}/Shell/API/KEGL
+ ${POWERVR_DIR}/Builds/Include
+ )
+ set_target_properties(BasicTnL PROPERTIES
+ COMPILE_OPTIONS "${SWIFTSHADER_COMPILE_OPTIONS}"
+ COMPILE_DEFINITIONS "GL_GLEXT_PROTOTYPES"
+ LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
+ )
+ target_link_libraries(BasicTnL dl ${X11} libEGL libGLES_CM) # Explicitly link our "lib*" targets, not the platform provided "EGL" and "GLES_CM"
+ endif()
+endif(SWIFTSHADER_BUILD_SAMPLES)
+
if(HAVE_PVR_SUBMODULE AND SWIFTSHADER_BUILD_PVR)
if(UNIX AND NOT APPLE)
set(PVR_WINDOW_SYSTEM XCB)
diff --git a/third_party/PowerVR_SDK/Builds/Include/EGL/egl.h b/third_party/PowerVR_SDK/Builds/Include/EGL/egl.h
new file mode 100644
index 0000000..9c78e85
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/EGL/egl.h
@@ -0,0 +1,330 @@
+/* -*- 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_PRESERVED_RESOURCES 0x3030
+#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/third_party/PowerVR_SDK/Builds/Include/EGL/eglext.h b/third_party/PowerVR_SDK/Builds/Include/EGL/eglext.h
new file mode 100644
index 0000000..13ed9d4
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/EGL/eglext.h
@@ -0,0 +1,565 @@
+#ifndef __eglext_h_
+#define __eglext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2013 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: 20690 $ on $Date: 2013-02-22 17:15:05 -0800 (Fri, 22 Feb 2013) $ */
+#define EGL_EGLEXT_VERSION 15
+
+#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
+#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
+#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 EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
+typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
+#endif
+#endif
+
+#ifndef EGL_EXT_multiview_window
+#define EGL_EXT_multiview_window 1
+#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
+#endif
+
+#ifndef EGL_KHR_wait_sync
+#define EGL_KHR_wait_sync 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+#endif
+
+#ifndef EGL_NV_post_convert_rounding
+#define EGL_NV_post_convert_rounding 1
+/* No tokens or entry points, just relaxes behavior of SwapBuffers */
+#endif
+
+#ifndef EGL_NV_native_query
+#define EGL_NV_native_query 1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);
+#endif
+
+#ifndef EGL_NV_3dvision_surface
+#define EGL_NV_3dvision_surface 1
+#define EGL_AUTO_STEREO_NV 0x3136
+#endif
+
+#ifndef EGL_ANDROID_framebuffer_target
+#define EGL_ANDROID_framebuffer_target 1
+#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147
+#endif
+
+#ifndef EGL_ANDROID_blob_cache
+#define EGL_ANDROID_blob_cache 1
+typedef khronos_ssize_t EGLsizeiANDROID;
+typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);
+typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);
+#endif
+
+#ifndef EGL_ANDROID_image_native_buffer
+#define EGL_ANDROID_image_native_buffer 1
+#define EGL_NATIVE_BUFFER_ANDROID 0x3140
+#endif
+
+#ifndef EGL_ANDROID_native_fence_sync
+#define EGL_ANDROID_native_fence_sync 1
+#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
+#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
+#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146
+#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR);
+#endif
+
+#ifndef EGL_ANDROID_recordable
+#define EGL_ANDROID_recordable 1
+#define EGL_RECORDABLE_ANDROID 0x3142
+#endif
+
+#ifndef EGL_EXT_buffer_age
+#define EGL_EXT_buffer_age 1
+#define EGL_BUFFER_AGE_EXT 0x313D
+#endif
+
+#ifndef EGL_EXT_image_dma_buf_import
+#define EGL_EXT_image_dma_buf_import 1
+#define EGL_LINUX_DMA_BUF_EXT 0x3270
+#define EGL_LINUX_DRM_FOURCC_EXT 0x3271
+#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272
+#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273
+#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274
+#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275
+#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276
+#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277
+#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278
+#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279
+#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A
+#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B
+#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C
+#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D
+#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E
+#define EGL_ITU_REC601_EXT 0x327F
+#define EGL_ITU_REC709_EXT 0x3280
+#define EGL_ITU_REC2020_EXT 0x3281
+#define EGL_YUV_FULL_RANGE_EXT 0x3282
+#define EGL_YUV_NARROW_RANGE_EXT 0x3283
+#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284
+#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __eglext_h_ */
diff --git a/third_party/PowerVR_SDK/Builds/Include/EGL/eglplatform.h b/third_party/PowerVR_SDK/Builds/Include/EGL/eglplatform.h
new file mode 100644
index 0000000..6cabd79
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/EGL/eglplatform.h
@@ -0,0 +1,129 @@
+#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(SUPPORT_X11)
+
+/* X11 (tentative) */
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+typedef Display *EGLNativeDisplayType;
+typedef Pixmap EGLNativePixmapType;
+typedef Window EGLNativeWindowType;
+
+
+#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;
+
+#else
+
+#if defined(_WIN64) || __WORDSIZE == 64
+typedef khronos_int64_t EGLNativeDisplayType;
+#else
+typedef int EGLNativeDisplayType;
+#endif
+
+typedef void *EGLNativeWindowType;
+typedef void *EGLNativePixmapType;
+
+#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/third_party/PowerVR_SDK/Builds/Include/GLES/egl.h b/third_party/PowerVR_SDK/Builds/Include/GLES/egl.h
new file mode 100644
index 0000000..37bb02a
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/GLES/egl.h
@@ -0,0 +1,15 @@
+/*
+ * Skeleton egl.h to provide compatibility for early GLES 1.0
+ * applications. Several early implementations included gl.h
+ * in egl.h leading applications to include only egl.h
+ *
+ * $Revision: 6252 $ on $Date:: 2008-08-06 16:35:08 -0700 #$
+ */
+
+#ifndef __legacy_egl_h_
+#define __legacy_egl_h_
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+#endif /* __legacy_egl_h_ */
diff --git a/third_party/PowerVR_SDK/Builds/Include/GLES/gl.h b/third_party/PowerVR_SDK/Builds/Include/GLES/gl.h
new file mode 100644
index 0000000..c95ddb0
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/GLES/gl.h
@@ -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/third_party/PowerVR_SDK/Builds/Include/GLES/glext.h b/third_party/PowerVR_SDK/Builds/Include/GLES/glext.h
new file mode 100644
index 0000000..295e6eb
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/GLES/glext.h
@@ -0,0 +1,1278 @@
+#ifndef __glext_h_
+#define __glext_h_
+
+/* $Revision: 20798 $ on $Date:: 2013-03-07 01:19:34 -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_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_copy_texture_levels */
+/* 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_sync */
+#ifndef GL_APPLE_sync
+
+/* These types are defined with reference to <inttypes.h>
+ * in the Apple extension spec, but here we use the Khronos
+ * portable types in khrplatform.h, and assume those types
+ * are always defined.
+ * If any other extensions using these types are defined,
+ * the typedefs must move out of this block and be shared.
+ */
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+
+#define GL_SYNC_OBJECT_APPLE 0x8A53
+#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
+#define GL_OBJECT_TYPE_APPLE 0x9112
+#define GL_SYNC_CONDITION_APPLE 0x9113
+#define GL_SYNC_STATUS_APPLE 0x9114
+#define GL_SYNC_FLAGS_APPLE 0x9115
+#define GL_SYNC_FENCE_APPLE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
+#define GL_UNSIGNALED_APPLE 0x9118
+#define GL_SIGNALED_APPLE 0x9119
+#define GL_ALREADY_SIGNALED_APPLE 0x911A
+#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
+#define GL_CONDITION_SATISFIED_APPLE 0x911C
+#define GL_WAIT_FAILED_APPLE 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
+#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
+#endif
+
+/* GL_APPLE_texture_2D_limited_npot */
+/* No new tokens introduced by this extension. */
+
+/* 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_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_MAP_READ_BIT_EXT 0x0001
+#define GL_MAP_WRITE_BIT_EXT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
+#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_copy_texture_levels */
+#ifndef GL_APPLE_copy_texture_levels
+#define GL_APPLE_copy_texture_levels 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#endif
+typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
+#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 target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+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_sync */
+#ifndef GL_APPLE_sync
+#define GL_APPLE_sync 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
+GL_API GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
+GL_API void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync);
+GL_API GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_API void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_API void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
+GL_API void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
+typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
+typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+#endif
+
+/* GL_APPLE_texture_2D_limited_npot */
+#ifndef GL_APPLE_texture_2D_limited_npot
+#define GL_APPLE_texture_2D_limited_npot 1
+#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_map_buffer_range */
+#ifndef GL_EXT_map_buffer_range
+#define GL_EXT_map_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_API void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#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 target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#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 mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const 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 p, const GLfloat *eqn);
+GL_API void GL_APIENTRY glClipPlanexIMG (GLenum p, const GLfixed *eqn);
+#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 target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#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 n, const GLuint *fences);
+GL_API void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
+GL_API GLboolean GL_APIENTRY glIsFenceNV (GLuint fence);
+GL_API GLboolean GL_APIENTRY glTestFenceNV (GLuint fence);
+GL_API void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glFinishFenceNV (GLuint fence);
+GL_API void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
+#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/third_party/PowerVR_SDK/Builds/Include/GLES/glplatform.h b/third_party/PowerVR_SDK/Builds/Include/GLES/glplatform.h
new file mode 100644
index 0000000..71d6a0d
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/GLES/glplatform.h
@@ -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/third_party/PowerVR_SDK/Builds/Include/KHR/khrplatform.h b/third_party/PowerVR_SDK/Builds/Include/KHR/khrplatform.h
new file mode 100644
index 0000000..bbe179d
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/KHR/khrplatform.h
@@ -0,0 +1,272 @@
+#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: 1.6 $ on $Date: 2011/06/01 14:18:13 $
+ *
+ * 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(__VC32__)) && !defined(__SCITECH_SNAP__)
+# if defined (_DLL_EXPORTS)
+# define KHRONOS_APICALL __declspec(dllexport)
+# else
+# define KHRONOS_APICALL __declspec(dllimport)
+# endif
+#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/third_party/PowerVR_SDK/Builds/Include/sdkver.h b/third_party/PowerVR_SDK/Builds/Include/sdkver.h
new file mode 100644
index 0000000..4d4d7a0
--- /dev/null
+++ b/third_party/PowerVR_SDK/Builds/Include/sdkver.h
@@ -0,0 +1,39 @@
+/*!***************************************************************************
+ @File sdkver.h
+
+ @Title Version numbers and strings.
+
+ @Date 08/11/2011
+
+ @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
+
+ @Platform Independant
+
+ @Description Version numbers and strings for SDK components.
+
+*****************************************************************************/
+
+#ifndef __SDKVER_H_
+#define __SDKVER_H_
+
+/*!***************************************************************************
+ Defines
+*****************************************************************************/
+
+#define PVRSDK_VERSION "3.2@2654748"
+#define PVRVERSION_MAJ "3"
+#define PVRVERSION_MIN "2"
+#define PVRVERSION_BRANCH "32"
+#define PVRVERSION_BRANCH_DEC "3.2"
+#define PVRVERSION_BRANCH_NAME "REL/3.2"
+#define PVRVERSION_BUILD "2654748"
+#define PVRVERSION_BUILD_HI "265"
+#define PVRVERSION_BUILD_LO "4748"
+
+#define PVRSDK_COPYRIGHT_TXT "Copyright (c) Imagination Technologies Ltd. All Rights Reserved."
+
+#endif /* __SDKVER_H_ */
+
+/*****************************************************************************
+ End of file (sdkver.h)
+*****************************************************************************/
diff --git a/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/BasicTnL.png b/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/BasicTnL.png
new file mode 100644
index 0000000..307b1aa
--- /dev/null
+++ b/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/BasicTnL.png
Binary files differ
diff --git a/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/BasicTnL.txt b/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/BasicTnL.txt
new file mode 100644
index 0000000..467314c
--- /dev/null
+++ b/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/BasicTnL.txt
@@ -0,0 +1,20 @@
+:Title:
+BasicTnL
+
+:ShortDescription:
+This training course consists of a demonstration of basic transformation and lighting.
+
+:FullDescription:
+This training course consists of a demonstration of basic transformation and lighting, growing on the basic drawing techniques learnt in HelloTriangle.
+
+Controls:
+ - Esc - Close the application
+
+:VGP:
+Not Required
+
+:PolyCount:
+1
+
+:VertexCount:
+3
diff --git a/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/OGLES/OGLESBasicTnL.cpp b/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/OGLES/OGLESBasicTnL.cpp
new file mode 100644
index 0000000..26ffd98
--- /dev/null
+++ b/third_party/PowerVR_SDK/Examples/Beginner/04_BasicTnL/OGLES/OGLESBasicTnL.cpp
@@ -0,0 +1,265 @@
+/******************************************************************************
+
+ @File OGLESBasicTnL.cpp
+
+ @Title Shows basic transformations and lighting
+
+ @Version
+
+ @Copyright Copyright (c) Imagination Technologies Limited.
+
+ @Platform Independant
+
+ @Description Shows basic transformations and lighting
+
+******************************************************************************/
+#include "PVRShell.h"
+#include <math.h>
+
+#if defined(__APPLE__) && defined (TARGET_OS_IPHONE)
+#import <OpenGLES/ES1/gl.h>
+#import <OpenGLES/ES1/glext.h>
+#else
+#include <GLES/gl.h>
+#endif
+
+/******************************************************************************
+ Defines
+******************************************************************************/
+// Size of the texture we create
+const int g_i32TexSize = 128;
+
+/*!****************************************************************************
+ Class implementing the PVRShell functions.
+******************************************************************************/
+class OGLESBasicTnL : public PVRShell
+{
+ // Texture handle
+ GLuint m_ui32Texture;
+
+ // Angle to rotate the triangle
+ float m_fAngle;
+
+ // Vertex Buffer Object (VBO) handle
+ GLuint m_ui32Vbo;
+
+public:
+ virtual bool InitApplication();
+ virtual bool InitView();
+ virtual bool ReleaseView();
+ virtual bool QuitApplication();
+ virtual bool RenderScene();
+};
+
+
+/*!****************************************************************************
+ @Function InitApplication
+ @Return bool true if no error occured
+ @Description Code in InitApplication() will be called by PVRShell once per
+ run, before the rendering context is created.
+ Used to initialize variables that are not dependant on it
+ (e.g. external modules, loading meshes, etc.)
+ If the rendering context is lost, InitApplication() will
+ not be called again.
+******************************************************************************/
+bool OGLESBasicTnL::InitApplication()
+{
+ m_fAngle = 0;
+ return true;
+}
+
+/*!****************************************************************************
+ @Function QuitApplication
+ @Return bool true if no error occured
+ @Description Code in QuitApplication() will be called by PVRShell once per
+ run, just before exiting the program.
+ If the rendering context is lost, QuitApplication() will
+ not be called.
+******************************************************************************/
+bool OGLESBasicTnL::QuitApplication()
+{
+ return true;
+}
+
+/*!****************************************************************************
+ @Function InitView
+ @Return bool true if no error occured
+ @Description Code in InitView() will be called by PVRShell upon
+ initialization or after a change in the rendering context.
+ Used to initialize variables that are dependant on the rendering
+ context (e.g. textures, vertex buffers, etc.)
+******************************************************************************/
+bool OGLESBasicTnL::InitView()
+{
+ // Sets the clear color
+ glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
+
+ // Enables texturing
+ glEnable(GL_TEXTURE_2D);
+
+ /*
+ Creates the texture.
+ Please refer to the training course "Texturing" for a detailed explanation.
+ */
+ glGenTextures(1, &m_ui32Texture);
+ glBindTexture(GL_TEXTURE_2D, m_ui32Texture);
+ GLuint* pTexData = new GLuint[g_i32TexSize*g_i32TexSize];
+
+ for(int i = 0; i < g_i32TexSize; ++i)
+ {
+ for(int j = 0; j < g_i32TexSize; ++j)
+ {
+ GLuint col = (255<<24) + ((255-j*2)<<16) + ((255-i)<<8) + (255-i*2);
+
+ if ( ((i*j)/8) % 2 )
+ col = 0xffff00ff;
+
+ pTexData[j*g_i32TexSize+i] = col;
+ }
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_i32TexSize, g_i32TexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
+ delete[] pTexData;
+
+ // Enables lighting and light 0
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+
+ /*
+ Specifies the light direction.
+ If the 4th component is 0, it's a parallel light (the case here).
+ If the 4th component is not 0, it's a point light.
+ */
+ float aLightPosition[] = {0.0f,0.0f,1.0f,0.0f};
+
+ /*
+ Assigns the light direction to the light number 0.
+ This function allows you to set also the ambiant, diffuse,
+ specular, emission colors of the light as well as attenuation parameters.
+ We keep the other parameters to their default value in this demo.
+ */
+ glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, aLightPosition);
+
+ // Create VBO for the triangle from our data
+
+ // Interleaved vertex data
+ float afVertices[] = { -0.4f,-0.4f,0.0f, // Position
+ 0.0f,0.0f, // UV
+ 0,0,1, // Normal
+ 0.4f,-0.4f,0.0f,
+ 1.0f,0.0f,
+ 0,0,1,
+ 0.0f,0.4f,0.0f,
+ 0.5f,1.0f,
+ 0,0,1};
+
+ glGenBuffers(1, &m_ui32Vbo);
+
+ unsigned int uiSize = 3 * (sizeof(float) * 8); // 3 vertices * stride (8 verttypes per vertex)
+
+ // Bind the VBO
+ glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);
+
+ // Set the buffer's data
+ glBufferData(GL_ARRAY_BUFFER, uiSize, afVertices, GL_STATIC_DRAW);
+
+ // Unbind the VBO
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ return true;
+}
+
+/*!****************************************************************************
+ @Function ReleaseView
+ @Return bool true if no error occured
+ @Description Code in ReleaseView() will be called by PVRShell when the
+ application quits or before a change in the rendering context.
+******************************************************************************/
+bool OGLESBasicTnL::ReleaseView()
+{
+ // Frees the texture
+ glDeleteTextures(1, &m_ui32Texture);
+
+ return true;
+}
+
+/*!****************************************************************************
+ @Function RenderScene
+ @Return bool true if no error occured
+ @Description Main rendering loop function of the program. The shell will
+ call this function every frame.
+ eglSwapBuffers() will be performed by PVRShell automatically.
+ PVRShell will also manage important OS events.
+ Will also manage relevent OS events. The user has access to
+ these events through an abstraction layer provided by PVRShell.
+******************************************************************************/
+bool OGLESBasicTnL::RenderScene()
+{
+ // Clears the color and depth buffer
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ // Model view matrix
+ float aModelView[] =
+ {
+ (float)cos(m_fAngle), 0, (float)sin(m_fAngle), 0,
+ 0, 1, 0, 0,
+ -(float)sin(m_fAngle), 0, (float)cos(m_fAngle), 0,
+ 0, 0, 0, 1
+ };
+
+ // Sets the matrix mode to modify the Model View matrix
+ glMatrixMode(GL_MODELVIEW);
+
+ // Loads our matrix into OpenGL Model View matrix
+ glLoadMatrixf(aModelView);
+
+ // Increments the angle of the view
+ m_fAngle += .02f;
+
+ /*
+ Draw a triangle.
+ Please refer to the training course IntroducingPVRShell for a detailed explanation.
+ */
+
+ // bind the VBO for the triangle
+ glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3,GL_FLOAT,sizeof(float) * 8, 0);
+
+ // Pass the texture coordinates data
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glTexCoordPointer(2,GL_FLOAT,sizeof(float) * 8, (unsigned char*) (sizeof(float) * 3));
+
+ // Pass the normals data
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glNormalPointer(GL_FLOAT,sizeof(float) * 8, (unsigned char*) (sizeof(float) * 5));
+
+ // Draws a non-indexed triangle array
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+
+ // unbind the vertex buffer as we don't need it bound anymore
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ return true;
+}
+
+/*!****************************************************************************
+ @Function NewDemo
+ @Return PVRShell* The demo supplied by the user
+ @Description This function must be implemented by the user of the shell.
+ The user should return its PVRShell object defining the
+ behaviour of the application.
+******************************************************************************/
+PVRShell* NewDemo()
+{
+ return new OGLESBasicTnL();
+}
+
+/******************************************************************************
+ End of file (OGLESBasicTnL.cpp)
+******************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/License.txt b/third_party/PowerVR_SDK/License.txt
new file mode 100644
index 0000000..1689541
--- /dev/null
+++ b/third_party/PowerVR_SDK/License.txt
@@ -0,0 +1,56 @@
+SDK END USER LICENSE AGREEMENT
+
+PLEASE READ THIS AGREEMENT CAREFULLY. BY USING ANY PORTION OF THE SDK YOU WILL BE LEGALLY BOUND TO THESE TERMS.
+Imagination Technologies Limited ("Imagination") provides this Software Development Kit subject to the terms of this Agreement. If you do not agree with any of these terms, then do not install or otherwise use the SDK.
+
+1. Definitions
+"SDK" means all or any component of software in source or binary form, tools, code examples, drivers, files, libraries, utilities, reference manuals, documentation, or other materials, and including any related updates or upgrades made available by Imagination under this Agreement from time to time.
+
+2. Licence Grant
+Subject to your compliance with the terms of this Agreement, Imagination grants to you a non-exclusive, non-assignable licence to:
+(a) use the SDK for the sole purpose of developing, profiling, or assisting in the optimisation of internal, commercial, or non-commercial applications ("Development License");
+(b) distribute the SDK in source code, object file, or compiled binary form as a component of your application, provided that:
+ i. you do not distribute the SDK on a stand alone basis;
+ ii. you distribute such components under terms no less restrictive than those in this Agreement;
+ iii. you comply with the attribution requirements set out in Appendix 1;
+ iv. you are solely responsible for any update, support obligation or other liability that may arise from such distribution;
+ v. you do not make any statements that your application or its performance are certified, guaranteed or otherwise endorsed by Imagination ("Production License")
+(c) Use the SDK as expressly authorised by Imagination in writing, on the payment and/or support terms set out in Appendix 2 (if applicable) ("Custom License").
+
+3. Restrictions
+Other than as expressly permitted herein, you may not: (i) use the SDK for any unauthorised purpose; (ii) modify, disassemble, decompile, reverse engineer, revise or enhance the SDK, create derivative works or attempt to discover the source code for any element of the SDK not already provided in source code form; (iii) remove any proprietary or copyright notices on or accompanying the SDK; or (iv) incorporate or combine the SDK, with any open source software in such a way that would cause the SDK, or any portion thereof, to be subject to all or part of the licence obligations or other intellectual property related terms with respect to such open source software.
+
+4. Ownership
+Imagination retains all ownership of the SDK, including without limitation all copyrights and other intellectual property rights therein.
+
+5. Warranty Disclaimer
+THE SDK IS PROVIDED "AS IS". Imagination HEREBY DISCLAIMS ALL EXPRESS OR IMPLIED WARRANTIES AND CONDITIONS WITH REGARD TO THE SDK, INCLUDING ALL WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.
+
+6. Limitation of Liability
+IN NO EVENT WILL Imagination BE LIABLE TO YOU FOR ANY DAMAGES, CLAIMS OR COSTS WHATSOEVER ARISING FROM THIS AGREEMENT AND/OR YOUR USE OF THE SDK OR ANY COMPONENT THEREOF, INCLUDING WITHOUT LIMITATION ANY CONSEQUENTIAL, INDIRECT, INCIDENTAL DAMAGES, OR ANY LOST PROFITS OR LOST SAVINGS, EVEN IF Imagination HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS, DAMAGES, CLAIMS OR COSTS OR FOR ANY CLAIM BY ANY THIRD PARTY. THE FOREGOING LIMITATIONS AND EXCLUSIONS APPLY TO THE EXTENT PERMITTED BY APPLICABLE LAW IN YOUR JURISDICTION.
+
+7. Third Party Materials
+All third party materials found on this SDK, including without limitation, artwork, graphics, game demos and patches, are the sole and exclusive property of such third parties. Imagination makes no representations or warranties about the accuracy, usability or validity of any third party materials, and disclaims all liabilities in connection with such third party materials.
+
+8. Term
+This Agreement is effective until terminated. Imagination has the right to terminate this Agreement immediately if you fail to comply with any term of this Agreement. You may terminate this Agreement by destroying or returning to Imagination all copies of the SDK in your possession.
+
+9. Governing Law
+This Agreement is governed by and shall be construed in accordance with English law and each party agrees to submit to the exclusive jurisdiction of the courts of England.
+
+
+APPENDIX 1: ATTRIBUTION REQUIREMENTS
+
+If source code is released as it is, the Copyright notice should be kept in a visible position.
+If object code is bundled with a product, all branding should be kept as it was originally, and the following acknowledgement should be displayed clearly in any associated documentation or other collateral in printed or electronic form distributed with the product incorporating the SDK component: "This product includes components of the PowerVR SDK from Imagination Technologies Limited"
+If source code is used to compile a product, the following acknowledgement should be displayed clearly in any associated documentation or other collateral in printed or electronic form distributed with the product incorporating the SDK component: "This product includes components of the PowerVR SDK from Imagination Technologies Limited"
+
+
+APPENDIX 2: FEES
+
+LICENCE FEES:
+nil
+ROYALTY FEES:
+nil
+SUPPORT AND MAINTENANCE TERMS AND FEES:
+nil
\ No newline at end of file
diff --git a/third_party/PowerVR_SDK/Shell/API/KEGL/PVRShellAPI.cpp b/third_party/PowerVR_SDK/Shell/API/KEGL/PVRShellAPI.cpp
new file mode 100644
index 0000000..6a0878e
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/API/KEGL/PVRShellAPI.cpp
@@ -0,0 +1,1009 @@
+/******************************************************************************
+
+ @File KEGL/PVRShellAPI.cpp
+
+ @Title KEGL/PVRShellAPI
+
+ @Version
+
+ @Copyright Copyright (c) Imagination Technologies Limited.
+
+ @Platform Independent
+
+ @Description Makes programming for 3D APIs easier by wrapping surface
+ initialization, Texture allocation and other functions for use by a demo.
+
+******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "PVRShell.h"
+#include "PVRShellAPI.h"
+#include "PVRShellOS.h"
+#include "PVRShellImpl.h"
+
+// No Doxygen for CPP files, due to documentation duplication
+/// @cond NO_DOXYGEN
+
+#ifndef EGL_CONTEXT_LOST_IMG
+/*! Extended error code EGL_CONTEXT_LOST_IMG generated when power management event has occurred. */
+#define EGL_CONTEXT_LOST_IMG 0x300E
+#endif
+
+#ifndef EGL_CONTEXT_PRIORITY_LEVEL_IMG
+/*! An extensions added to the list of attributes for the context to give it a priority hint */
+#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100
+/*! Request the context is created with high priority */
+#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
+/*! Request the context is created with medium priority */
+#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
+/*! Request the context is created with low priority */
+#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
+#endif
+
+/*****************************************************************************
+ Declarations
+*****************************************************************************/
+static bool PVRShellIsExtensionSupported(EGLDisplay dpy, const char *extension);
+
+#if defined GL_ES_VERSION_2_0 && !defined EGL_VERSION_1_3
+#error OpenGL ES 2 requires egl.h version 1.3 or higher
+#endif
+
+/****************************************************************************
+** Class: PVRShellInitAPI
+****************************************************************************/
+
+/*****************************************************************************
+* Function Name : ActivatePreferences
+* Description : Activates the user set preferences (like v-sync)
+*****************************************************************************/
+void PVRShellInit::ApiActivatePreferences()
+{
+
+#ifdef EGL_VERSION_1_1
+ eglSwapInterval(m_EGLDisplay, m_pShell->m_pShellData->nSwapInterval);
+#endif
+}
+
+/*****************************************************************************
+* Function Name : ApiInitAPI
+* Returns : true for success
+* Description : Initialise the 3D API
+*****************************************************************************/
+bool PVRShellInit::ApiInitAPI()
+{
+ int bDone;
+
+ m_NDT = (EGLNativeDisplayType)OsGetNativeDisplayType();
+ m_NPT = (EGLNativePixmapType) OsGetNativePixmapType();
+ m_NWT = (EGLNativeWindowType) OsGetNativeWindowType();
+
+ m_EGLContext = 0;
+
+ do
+ {
+ bDone = true;
+
+ m_EGLDisplay = eglGetDisplay(m_NDT);
+
+ if(m_EGLDisplay == EGL_NO_DISPLAY)
+ {
+#if defined(BUILD_OGLES2) || defined(BUILD_OGLES3)
+ m_EGLDisplay = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
+#else
+ m_EGLDisplay = eglGetDisplay((NativeDisplayType)EGL_DEFAULT_DISPLAY);
+#endif
+ }
+
+ if(!eglInitialize(m_EGLDisplay, &m_MajorVersion, &m_MinorVersion))
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Unable to initialise EGL\n");
+ m_pShell->PVRShellOutputDebug("PVRShell: EGL Error (%s)\n", StringFrom_eglGetError());
+ return false;
+ }
+
+ m_pShell->PVRShellOutputDebug("PVRShell: EGL %d.%d initialized\n", m_MajorVersion, m_MinorVersion);
+
+ // Check Extension availability after EGL initialization
+ if (m_MajorVersion > 1 || (m_MajorVersion == 1 && m_MinorVersion >= 1))
+ {
+ m_bPowerManagementSupported = true;
+ }
+ else
+ {
+ m_bPowerManagementSupported = PVRShellIsExtensionSupported(m_EGLDisplay,"EGL_IMG_power_management");
+ }
+
+ do
+ {
+#if defined(BUILD_OGL)
+ if(!eglBindAPI(EGL_OPENGL_API))
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Failed to bind OpenGL API\n");
+ return false;
+ }
+#else
+#if defined EGL_VERSION_1_3 && defined GL_ES_VERSION_2_0
+ if(!eglBindAPI(EGL_OPENGL_ES_API))
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Failed to bind OpenGL ES API\n");
+ return false;
+ }
+#endif
+#endif
+ // Find an EGL config
+ m_EGLConfig = SelectEGLConfiguration(m_pShell->m_pShellData);
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_CONFIG_ID, &m_iConfig);
+
+ // Destroy the context if we already created one
+ if (m_EGLContext)
+ {
+ eglDestroyContext(m_EGLDisplay, m_EGLContext);
+ }
+
+ // Attempt to create a context
+ EGLint ai32ContextAttribs[48];
+ int i = 0;
+
+#if defined(BUILD_OGLES3)
+ ai32ContextAttribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
+ ai32ContextAttribs[i++] = 3;
+#else
+#if defined(EGL_VERSION_1_3) && defined(GL_ES_VERSION_2_0)
+ ai32ContextAttribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
+ ai32ContextAttribs[i++] = 2;
+#endif
+#endif
+
+#if defined(BUILD_OGL)
+ //Attempt to create an OpenGL 3.2 context.
+ if (PVRShellIsExtensionSupported(m_EGLDisplay, "EGL_KHR_create_context"))
+ {
+ ai32ContextAttribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
+ ai32ContextAttribs[i++] = 3;
+ ai32ContextAttribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
+ ai32ContextAttribs[i++] = 2;
+ ai32ContextAttribs[i++] = EGL_CONTEXT_FLAGS_KHR;
+ ai32ContextAttribs[i++] = EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
+ ai32ContextAttribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+ ai32ContextAttribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+ }
+#endif
+
+#if defined(BUILD_OGLES) || defined(BUILD_OGLES2) || defined(BUILD_OGLES3)
+ if(PVRShellIsExtensionSupported(m_EGLDisplay,"EGL_IMG_context_priority"))
+ {
+ ai32ContextAttribs[i++] = EGL_CONTEXT_PRIORITY_LEVEL_IMG;
+ switch(m_pShell->PVRShellGet(prefPriority))
+ {
+ case 0: ai32ContextAttribs[i++] = EGL_CONTEXT_PRIORITY_LOW_IMG; break;
+ case 1: ai32ContextAttribs[i++] = EGL_CONTEXT_PRIORITY_MEDIUM_IMG; break;
+ default:ai32ContextAttribs[i++] = EGL_CONTEXT_PRIORITY_HIGH_IMG; break;
+ }
+ }
+#endif
+ ai32ContextAttribs[i] = EGL_NONE;
+
+ if (m_EGLContext == EGL_NO_CONTEXT)
+ {
+ m_EGLContext = eglCreateContext(m_EGLDisplay, m_EGLConfig, NULL, ai32ContextAttribs);
+ }
+
+ if(m_EGLContext == EGL_NO_CONTEXT)
+ {
+ if(m_iRequestedConfig > 0)
+ {
+ // We failed to create a context
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Unable to create a context\n");
+ return false;
+ }
+ else if(m_pShell->m_pShellData->bNeedPbuffer)
+ {
+ // Disable P-buffer and try again
+ m_pShell->m_pShellData->bNeedPbuffer = false;
+ }
+ else if(m_pShell->m_pShellData->bNeedStencilBuffer)
+ {
+ // Disable Stencil Buffer and try again
+ m_pShell->m_pShellData->bNeedStencilBuffer = false;
+ }
+ else if(m_pShell->m_pShellData->nAASamples > 0)
+ {
+ // Still failing, reduce the AA samples and try again
+ --m_pShell->m_pShellData->nAASamples;
+ }
+ else
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Unable to create a context\n");
+ return false;
+ }
+ }
+ } while(m_EGLContext == EGL_NO_CONTEXT);
+
+#if defined(__QNXNTO__)
+ int format = SCREEN_FORMAT_RGBX8888;
+ if(screen_set_window_property_iv((_screen_window*) m_NWT, SCREEN_PROPERTY_FORMAT, &format))
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Failed to set window property SCREEN_PROPERTY_FORMAT\n");
+ return false;
+ }
+
+#if defined(BUILD_OGLES2)
+ int usage = SCREEN_USAGE_OPENGL_ES2;
+#else
+#if defined(BUILD_OGLES)
+ int usage = SCREEN_USAGE_OPENGL_ES1;
+#endif
+#endif
+ if(screen_set_window_property_iv((_screen_window*) m_NWT, SCREEN_PROPERTY_USAGE, &usage))
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Failed to set window property SCREEN_PROPERTY_USAGE\n");
+ return false;
+ }
+
+ if(screen_create_window_buffers((_screen_window*) m_NWT, 2))
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Failed to create window buffers\n");
+ return false;
+ }
+#endif
+ EGLint attrib_list[16];
+ int i = 0;
+#if defined(EGL_VERSION_1_2)
+ if(m_pShell->m_pShellData->bNeedAlphaFormatPre) // The default is EGL_ALPHA_FORMAT_NONPRE
+ {
+ attrib_list[i++] = EGL_ALPHA_FORMAT;
+ attrib_list[i++] = EGL_ALPHA_FORMAT_PRE;
+ }
+#endif
+ // Terminate the attribute list with EGL_NONE
+ attrib_list[i] = EGL_NONE;
+
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ {
+ m_pShell->PVRShellOutputDebug("InitAPI() Using pixmaps, about to create egl surface\n");
+ m_EGLWindow = eglCreatePixmapSurface(m_EGLDisplay, m_EGLConfig, m_NPT, attrib_list);
+ }
+ else
+ {
+#if defined(ANDROID)
+ EGLint visualID;
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_NATIVE_VISUAL_ID, &visualID);
+
+ // Change the format of our window to match our config
+ ANativeWindow_setBuffersGeometry(m_NWT, 0, 0, visualID);
+#endif
+ m_EGLWindow = eglCreateWindowSurface(m_EGLDisplay, m_EGLConfig, m_NWT, attrib_list);
+
+ // If we have failed to create a surface then try using Null
+ if(m_EGLWindow == EGL_NO_SURFACE)
+ {
+ m_EGLWindow = eglCreateWindowSurface(m_EGLDisplay, m_EGLConfig, NULL, attrib_list);
+ }
+ }
+
+ if (m_EGLWindow == EGL_NO_SURFACE)
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Unable to create surface\n");
+ return false;
+ }
+
+ if (!eglMakeCurrent(m_EGLDisplay, m_EGLWindow, m_EGLWindow, m_EGLContext))
+ {
+#ifdef EGL_VERSION_1_3
+ if((eglGetError() == EGL_CONTEXT_LOST))
+#else
+ if((eglGetError() == EGL_CONTEXT_LOST_IMG) && m_bPowerManagementSupported)
+#endif
+ {
+ bDone = false;
+ }
+ else
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "PVRShell: Unable to make context current\n");
+ return false;
+ }
+ }
+ } while(!bDone);
+
+ /*
+ Get correct screen width and height and
+ save them into
+ m_pShell->m_pShellData->nShellDimX and
+ m_pShell->m_pShellData->nShellDimY
+ */
+ eglQuerySurface(m_EGLDisplay, m_EGLWindow,
+ EGL_WIDTH, (EGLint*)&m_pShell->m_pShellData->nShellDimX
+ );
+ eglQuerySurface(m_EGLDisplay, m_EGLWindow,
+ EGL_HEIGHT, (EGLint*)&m_pShell->m_pShellData->nShellDimY
+ );
+
+#if defined(ANDROID)
+ glViewport(0, 0, m_pShell->m_pShellData->nShellDimX, m_pShell->m_pShellData->nShellDimY);
+#endif
+ /*
+ Done - activate requested features
+ */
+
+#if defined(BUILD_OGLES) || defined(BUILD_OGLES2)
+ //Get the discardframebufferEXT function.
+ {
+ //Get the gl extension string
+ const char* strExtensions = (const char*)glGetString(GL_EXTENSIONS);
+
+ //Get the length of the string we're searching for
+ const size_t strLength = strlen("GL_EXT_discard_framebuffer");
+
+ //Get the string position
+ const char* position = strstr(strExtensions,"GL_EXT_discard_framebuffer");
+
+ //Loop through until we find the actual extension, avoiding substrings.
+ while (position!=NULL && position[strLength]!='\0' && position[strLength]!=' ')
+ {
+ position = strstr(position+strLength,"GL_EXT_discard_framebuffer");
+ }
+
+ //Initialise the extension if it's found.
+ if (position != NULL)
+ {
+ glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC)eglGetProcAddress("glDiscardFramebufferEXT");
+ }
+ else
+ {
+ glDiscardFramebufferEXT = NULL;
+ }
+ }
+#endif
+ ApiActivatePreferences();
+ return true;
+}
+
+/*!***********************************************************************
+@Function OutputAPIInfo
+@description When prefOutputInfo is set to true this function outputs
+ various pieces of API dependent information via
+ PVRShellOutputDebug.
+*************************************************************************/
+void PVRShellInit::OutputAPIInfo()
+{
+ // Output API dependent information
+ if(m_pShell->PVRShellGet(prefOutputInfo))
+ {
+ EGLint i32Values[5];
+
+ m_pShell->PVRShellOutputDebug("\n");
+
+ m_pShell->PVRShellOutputDebug("GL:\n");
+ m_pShell->PVRShellOutputDebug(" Vendor: %s\n", (char*) glGetString(GL_VENDOR));
+ m_pShell->PVRShellOutputDebug(" Renderer: %s\n", (char*) glGetString(GL_RENDERER));
+ m_pShell->PVRShellOutputDebug(" Version: %s\n", (char*) glGetString(GL_VERSION));
+ m_pShell->PVRShellOutputDebug(" Extensions: ");
+
+#if defined(BUILD_OGL)
+ //Get the glGetString process.
+ typedef const GLubyte* (KHRONOS_APIENTRY * PFNGLGETSTRINGIPROC)(GLenum name, GLuint index);
+ PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC)eglGetProcAddress("glGetStringi");
+
+ //If we've successfully got the new way to query the string, then go ahead and use this.
+ if (glGetStringi)
+ {
+#ifndef GL_NUM_EXTENSIONS
+#define GL_NUM_EXTENSIONS 0x821D
+#endif
+ GLint numExtensions;
+ glGetIntegerv(GL_NUM_EXTENSIONS,&numExtensions);
+
+ for (GLint i=0; i<numExtensions; ++i)
+ {
+ m_pShell->PVRShellOutputDebug((const char*)glGetStringi(GL_EXTENSIONS,i));
+ m_pShell->PVRShellOutputDebug(" ");
+ }
+ }
+#else
+ m_pShell->PVRShellOutputDebug("%s\n", (char*) glGetString(GL_EXTENSIONS));
+#endif
+
+ m_pShell->PVRShellOutputDebug("\n");
+
+ m_pShell->PVRShellOutputDebug("\n");
+ m_pShell->PVRShellOutputDebug("EGL:\n");
+ m_pShell->PVRShellOutputDebug(" Vendor: %s\n" , (char*) eglQueryString(m_EGLDisplay, EGL_VENDOR));
+ m_pShell->PVRShellOutputDebug(" Version: %s\n" , (char*) eglQueryString(m_EGLDisplay, EGL_VERSION));
+ m_pShell->PVRShellOutputDebug(" Extensions: %s\n" , (char*) eglQueryString(m_EGLDisplay, EGL_EXTENSIONS));
+
+ if(eglQueryContext(m_EGLDisplay, m_EGLContext, EGL_CONTEXT_PRIORITY_LEVEL_IMG, &i32Values[0]))
+ {
+ switch(i32Values[0])
+ {
+ case EGL_CONTEXT_PRIORITY_HIGH_IMG: m_pShell->PVRShellOutputDebug(" Context priority: High\n"); break;
+ case EGL_CONTEXT_PRIORITY_MEDIUM_IMG: m_pShell->PVRShellOutputDebug(" Context priority: Medium\n");break;
+ case EGL_CONTEXT_PRIORITY_LOW_IMG: m_pShell->PVRShellOutputDebug(" Context priority: Low\n"); break;
+ default: m_pShell->PVRShellOutputDebug(" Context priority: Unrecognised.\n"); break;
+ }
+ }
+ else
+ {
+ eglGetError(); // Clear error
+ m_pShell->PVRShellOutputDebug(" Context priority: Unsupported\n");
+ }
+
+#ifdef EGL_VERSION_1_2
+ m_pShell->PVRShellOutputDebug(" Client APIs: %s\n" , (char*) eglQueryString(m_EGLDisplay, EGL_CLIENT_APIS));
+#endif
+
+ m_pShell->PVRShellOutputDebug("\n");
+ m_pShell->PVRShellOutputDebug("Window Width: %i\n" , m_pShell->PVRShellGet(prefWidth));
+ m_pShell->PVRShellOutputDebug("Window Height: %i\n" , m_pShell->PVRShellGet(prefHeight));
+ m_pShell->PVRShellOutputDebug("Is Rotated: %s\n", m_pShell->PVRShellGet(prefIsRotated) ? "Yes" : "No");
+ m_pShell->PVRShellOutputDebug("\n");
+
+ // EGLSurface details
+ m_pShell->PVRShellOutputDebug("EGL Surface:\n");
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_CONFIG_ID , &i32Values[0]);
+ m_pShell->PVRShellOutputDebug(" Config ID: %i\n", i32Values[0]);
+
+ // Colour buffer
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_BUFFER_SIZE , &i32Values[0]);
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_RED_SIZE , &i32Values[1]);
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_GREEN_SIZE , &i32Values[2]);
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_BLUE_SIZE , &i32Values[3]);
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_ALPHA_SIZE , &i32Values[4]);
+ m_pShell->PVRShellOutputDebug(" Colour Buffer: %i bits (R%i G%i B%i A%i)\n", i32Values[0],i32Values[1],i32Values[2],i32Values[3],i32Values[4]);
+
+ // Depth buffer
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_DEPTH_SIZE , &i32Values[0]);
+ m_pShell->PVRShellOutputDebug(" Depth Buffer: %i bits\n", i32Values[0]);
+
+ // Stencil Buffer
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_STENCIL_SIZE , &i32Values[0]);
+ m_pShell->PVRShellOutputDebug(" Stencil Buffer: %i bits\n", i32Values[0]);
+
+ // EGL surface bits support
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_SURFACE_TYPE , &i32Values[0]);
+ m_pShell->PVRShellOutputDebug(" Surface type: %s%s%s\n", i32Values[0] & EGL_WINDOW_BIT ? "WINDOW " : "",
+ i32Values[1] & EGL_PBUFFER_BIT ? "PBUFFER " : "",
+ i32Values[2] & EGL_PIXMAP_BIT ? "PIXMAP " : "");
+ // EGL renderable type
+#ifdef EGL_VERSION_1_2
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_RENDERABLE_TYPE , &i32Values[0]);
+ m_pShell->PVRShellOutputDebug(" Renderable type: %s%s%s%s\n", i32Values[0] & EGL_OPENVG_BIT ? "OPENVG " : "",
+ i32Values[0] & EGL_OPENGL_ES_BIT ? "OPENGL_ES " : "",
+#ifdef EGL_OPENGL_BIT
+ i32Values[0] & EGL_OPENGL_BIT ? "OPENGL " :
+#endif
+ "",
+ i32Values[0] & EGL_OPENGL_ES2_BIT ? "OPENGL_ES2 " : "");
+#endif
+
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_SAMPLE_BUFFERS , &i32Values[0]);
+ eglGetConfigAttrib(m_EGLDisplay, m_EGLConfig, EGL_SAMPLES , &i32Values[1]);
+ m_pShell->PVRShellOutputDebug(" Sample buffer No.: %i\n", i32Values[0]);
+ m_pShell->PVRShellOutputDebug(" Samples per pixel: %i\n", i32Values[1]);
+ }
+}
+
+/*!***********************************************************************
+ @Function ApiReleaseAPI
+ @description Releases all resources allocated by the API.
+*************************************************************************/
+void PVRShellInit::ApiReleaseAPI()
+{
+ eglSwapBuffers(m_EGLDisplay, m_EGLWindow);
+ eglMakeCurrent(m_EGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ eglDestroyContext(m_EGLDisplay, m_EGLContext);
+ eglDestroySurface(m_EGLDisplay, m_EGLWindow);
+ eglTerminate(m_EGLDisplay);
+}
+
+/*******************************************************************************
+ * Function Name : SelectEGLConfiguration
+ * Inputs : pData
+ * Returns : EGLConfig
+ * Description : Find the config to use for EGL initialisation
+ *******************************************************************************/
+EGLConfig PVRShellInitAPI::SelectEGLConfiguration(const PVRShellData * const pData)
+{
+ EGLint num_config;
+ EGLint conflist[32];
+ EGLConfig conf = (EGLConfig) 0;
+ int i = 0;
+
+ // Specific config ID requested?
+ if (m_iRequestedConfig > 0)
+ {
+ conflist[i++] = EGL_CONFIG_ID;
+ conflist[i++] = m_iRequestedConfig;
+ conflist[i++] = EGL_NONE;
+ if(!eglChooseConfig(m_EGLDisplay, conflist, &conf, 1, &num_config) || num_config != 1)
+ {
+ return 0;
+ }
+ return conf;
+ }
+
+ // Select default configuration
+#if defined(ANDROID)
+ if(pData->nColorBPP == 32)
+ {
+ conflist[i++] = EGL_RED_SIZE;
+ conflist[i++] = 8;
+ conflist[i++] = EGL_GREEN_SIZE;
+ conflist[i++] = 8;
+ conflist[i++] = EGL_BLUE_SIZE;
+ conflist[i++] = 8;
+ conflist[i++] = EGL_ALPHA_SIZE;
+ conflist[i++] = 8;
+ }
+ else
+ {
+ conflist[i++] = EGL_RED_SIZE;
+ conflist[i++] = 5;
+ conflist[i++] = EGL_GREEN_SIZE;
+ conflist[i++] = 6;
+ conflist[i++] = EGL_BLUE_SIZE;
+ conflist[i++] = 5;
+ conflist[i++] = EGL_ALPHA_SIZE;
+ conflist[i++] = 0;
+ }
+#else
+ conflist[i++] = EGL_BUFFER_SIZE;
+ conflist[i++] = pData->nColorBPP;
+#endif
+
+ if(pData->bNeedZbuffer || pData->nDepthBPP > 0)
+ {
+ conflist[i++] = EGL_DEPTH_SIZE;
+ conflist[i++] = (pData->nDepthBPP > 0) ? pData->nDepthBPP : 16;
+ }
+
+ if(pData->bNeedStencilBuffer)
+ {
+ conflist[i++] = EGL_STENCIL_SIZE;
+ conflist[i++] = 8;
+ }
+
+ conflist[i++] = EGL_SURFACE_TYPE;
+ conflist[i] = EGL_WINDOW_BIT;
+
+ if(pData->bNeedPbuffer)
+ {
+ conflist[i] |= EGL_PBUFFER_BIT;
+ }
+
+ if(pData->bNeedPixmap)
+ {
+ conflist[i] |= EGL_PIXMAP_BIT;
+ }
+
+ ++i;
+
+#if defined(BUILD_OGL)
+ conflist[i++] = EGL_RENDERABLE_TYPE;
+ conflist[i++] = EGL_OPENGL_BIT;
+#elif defined(EGL_VERSION_1_3) && defined(GL_ES_VERSION_2_0)
+ conflist[i++] = EGL_RENDERABLE_TYPE;
+ conflist[i++] = EGL_OPENGL_ES2_BIT;
+#endif
+
+ // Append number of number of samples depending on AA samples value set
+ if(pData->nAASamples > 0)
+ {
+ conflist[i++] = EGL_SAMPLE_BUFFERS;
+ conflist[i++] = 1;
+ conflist[i++] = EGL_SAMPLES;
+ conflist[i++] = pData->nAASamples;
+ }
+ else
+ {
+ conflist[i++] = EGL_SAMPLE_BUFFERS;
+ conflist[i++] = 0;
+ }
+
+#if defined(EWS) || defined(__QNXNTO__)
+ if(m_NWT != NULL)
+ {
+ EGLint r,g,b,a, value;
+ EGLint i32Total_num_configs, j;
+ EGLConfig *pConfigs;
+
+ // Some platforms require an egl config to have the same pixel format as the native window because
+ // pixel format conversion is prohibited.
+#if defined(EWS)
+ int format = EWS_PIXEL_FORMAT_RGB_565;
+ r = 5; g = 6; b = 5; a = 0;
+#else
+ r = g = b = a = 8;
+#endif
+
+ conflist[i++] = EGL_RED_SIZE;
+ conflist[i++] = r;
+
+ conflist[i++] = EGL_GREEN_SIZE;
+ conflist[i++] = g;
+
+ conflist[i++] = EGL_BLUE_SIZE;
+ conflist[i++] = b;
+
+ conflist[i++] = EGL_ALPHA_SIZE;
+ conflist[i++] = a;
+
+ // Terminate the list with EGL_NONE
+ conflist[i++] = EGL_NONE;
+
+ // Find out how many configs there are in total that match our criteria
+ if(!eglChooseConfig(m_EGLDisplay, conflist, NULL, 0, &i32Total_num_configs) || i32Total_num_configs == 0)
+ return 0;
+
+ // Allocate an array large enough to store all the possible configs that may be returned
+ pConfigs = new EGLConfig[i32Total_num_configs];
+
+ if(!pConfigs)
+ return 0;
+
+ // Get all the configs that match our criteria
+ if(!eglChooseConfig(m_EGLDisplay, conflist, pConfigs, i32Total_num_configs, &num_config))
+ {
+ delete[] pConfigs;
+ return 0;
+ }
+
+ // Go through the returned configs and try and find a suitable match
+ for(j = 0; j < num_config; ++j)
+ {
+#if defined(__QNXNTO__)
+ if((eglGetConfigAttrib(m_EGLDisplay, pConfigs[j], EGL_RED_SIZE, &value) && value == r)
+ && (eglGetConfigAttrib(m_EGLDisplay, pConfigs[j], EGL_GREEN_SIZE, &value) && value == g)
+ && (eglGetConfigAttrib(m_EGLDisplay, pConfigs[j], EGL_BLUE_SIZE, &value) && value == b)
+ && (eglGetConfigAttrib(m_EGLDisplay, pConfigs[j], EGL_ALPHA_SIZE, &value) && value == a))
+ {
+ conf = pConfigs[j];
+ break;
+ }
+#else
+#if defined (EWS)
+ eglGetConfigAttrib(m_EGLDisplay, pConfigs[j], EGL_NATIVE_VISUAL_ID, &value);
+ if (value == format)
+ {
+ conf = pConfigs[j];
+ break;
+ }
+#endif
+#endif
+ }
+
+ // Tidy up
+ delete[] pConfigs;
+ }
+ else
+#endif
+ {
+ // Terminate the list with EGL_NONE
+ conflist[i++] = EGL_NONE;
+
+ // Return null config if config is not found
+ if(!eglChooseConfig(m_EGLDisplay, conflist, &conf, 1, &num_config) || num_config != 1)
+ {
+ return 0;
+ }
+ }
+
+ // Return config index
+ return conf;
+}
+
+/*******************************************************************************
+ * Function Name : StringFrom_eglGetError
+ * Returns : A string
+ * Description : Returns a string representation of an egl error
+ *******************************************************************************/
+const char *PVRShellInitAPI::StringFrom_eglGetError() const
+{
+ EGLint nErr = eglGetError();
+
+ switch(nErr)
+ {
+ case EGL_SUCCESS:
+ return "EGL_SUCCESS";
+ case EGL_BAD_DISPLAY:
+ return "EGL_BAD_DISPLAY";
+ case EGL_NOT_INITIALIZED:
+ return "EGL_NOT_INITIALIZED";
+ case EGL_BAD_ACCESS:
+ return "EGL_BAD_ACCESS";
+ case EGL_BAD_ALLOC:
+ return "EGL_BAD_ALLOC";
+ case EGL_BAD_ATTRIBUTE:
+ return "EGL_BAD_ATTRIBUTE";
+ case EGL_BAD_CONFIG:
+ return "EGL_BAD_CONFIG";
+ case EGL_BAD_CONTEXT:
+ return "EGL_BAD_CONTEXT";
+ case EGL_BAD_CURRENT_SURFACE:
+ return "EGL_BAD_CURRENT_SURFACE";
+ case EGL_BAD_MATCH:
+ return "EGL_BAD_MATCH";
+ case EGL_BAD_NATIVE_PIXMAP:
+ return "EGL_BAD_NATIVE_PIXMAP";
+ case EGL_BAD_NATIVE_WINDOW:
+ return "EGL_BAD_NATIVE_WINDOW";
+ case EGL_BAD_PARAMETER:
+ return "EGL_BAD_PARAMETER";
+ case EGL_BAD_SURFACE:
+ return "EGL_BAD_SURFACE";
+ default:
+ return "unknown";
+ }
+}
+
+/*!***********************************************************************
+@Function ApiScreenCaptureBuffer
+@Input Width Width of the region to capture
+@Input Height Height of the region to capture
+@Input pBuf A buffer to put the screen capture into
+@description API-specific function to store the current content of the
+ FrameBuffer into the memory allocated by the user.
+*************************************************************************/
+bool PVRShellInit::ApiScreenCaptureBuffer(int Width,int Height,unsigned char *pBuf)
+{
+ unsigned char *pLines2;
+ int i, j;
+ bool bRet = true;
+
+ /* Allocate memory for line */
+ pLines2 = (unsigned char *)calloc(4 * Width * Height, sizeof(unsigned char));
+ if (!pLines2) return false;
+
+ while (glGetError());
+ /* Read line from frame buffer */
+ glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, pLines2);
+
+ if(glGetError())
+ {
+ bRet = false;
+ }
+ else
+ {
+ /* Convert RGB to BGR in line */
+ for (j = 0, i = 0; j < 4 * Width * Height; j += 4, i += 3)
+ {
+ pBuf[i] = pLines2[j+2];
+ pBuf[i+1] = pLines2[j+1];
+ pBuf[i+2] = pLines2[j];
+ }
+ }
+
+ free(pLines2);
+ return bRet;
+}
+
+/*!***********************************************************************
+ @Function ApiRenderComplete
+ @description Perform API operations required after a frame has finished (e.g., flipping).
+*************************************************************************/
+void PVRShellInit::ApiRenderComplete()
+{
+
+#if defined(BUILD_OGLES) || defined(BUILD_OGLES2) || defined(BUILD_OGLES3)
+ //Discard the framebuffer if set.
+#if !defined(BUILD_OGLES3)
+ if (glDiscardFramebufferEXT)
+#endif
+ {
+ const GLint numAttachments=3;
+ GLenum attachments[numAttachments];
+ GLint currentAttachment=0;
+ if (m_pShell->PVRShellGet(prefDiscardColor))
+ {
+ attachments[currentAttachment] = GL_COLOR_EXT;
+ currentAttachment++;
+ }
+ if (m_pShell->PVRShellGet(prefDiscardDepth))
+ {
+ attachments[currentAttachment] = GL_DEPTH_EXT;
+ currentAttachment++;
+ }
+ if (m_pShell->PVRShellGet(prefDiscardStencil))
+ {
+ attachments[currentAttachment] = GL_STENCIL_EXT;
+ currentAttachment++;
+ }
+ //Assuming some attachments have been chosen, discard/invalidate them.
+ if (currentAttachment!=0)
+ {
+#if defined(BUILD_OGLES)
+ glDiscardFramebufferEXT(GL_FRAMEBUFFER_OES, currentAttachment, attachments);
+#elif defined(BUILD_OGLES2)
+ glDiscardFramebufferEXT(GL_FRAMEBUFFER, currentAttachment, attachments);
+#elif defined(BUILD_OGLES3)
+ glInvalidateFramebuffer(GL_FRAMEBUFFER, currentAttachment, attachments);
+#endif
+ }
+ }
+#endif
+
+ bool bRes;
+
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ {
+ /*
+ "Clients rendering to single buffered surfaces (e.g. pixmap surfaces)
+ should call eglWaitGL before accessing the native pixmap from the client."
+ */
+ eglWaitGL();
+
+ // Pixmap support: Copy the rendered pixmap to the display
+ if(m_pShell->m_pShellData->bNeedPixmapDisableCopy)
+ {
+ bRes = true;
+ }
+ else
+ {
+ bRes = OsPixmapCopy();
+ }
+ }
+ else
+ {
+ if(m_pShell->m_pShellData->bNoShellSwapBuffer)
+ return;
+
+ bRes = (eglSwapBuffers (m_EGLDisplay, m_EGLWindow) == EGL_TRUE);
+ }
+
+ if(!bRes)
+ {
+ // check for context loss
+#ifdef EGL_VERSION_1_3
+ if(eglGetError() == EGL_CONTEXT_LOST)
+#else
+ if((eglGetError() == EGL_CONTEXT_LOST_IMG) && m_bPowerManagementSupported)
+#endif
+ {
+ m_pShell->ReleaseView();
+
+ OsDoReleaseAPI();
+ if(ApiInitAPI())
+ {
+ m_pShell->InitView();
+ }
+ }
+ else
+ {
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ m_pShell->PVRShellOutputDebug("failed to copy pixmap\n");
+ else
+ m_pShell->PVRShellOutputDebug("eglSwapBuffers failed\n");
+ }
+ }
+}
+
+/*!***********************************************************************
+ @Function ApiSet
+ @Input prefName Name of value to set
+ @Modified i32Value Value to set it to
+ @description Set parameters which are specific to the API.
+*************************************************************************/
+bool PVRShellInit::ApiSet(const prefNameIntEnum prefName, const int i32Value)
+{
+ switch(prefName)
+ {
+#ifdef EGL_VERSION_1_1
+ case prefSwapInterval:
+ m_pShell->m_pShellData->nSwapInterval = i32Value;
+ return true;
+#endif
+#if defined(BUILD_OGLES) || defined(BUILD_OGLES2) || defined(BUILD_OGLES3)
+ case prefPriority:
+ m_pShell->m_pShellData->nPriority = i32Value;
+ return true;
+#endif
+ case prefRequestedConfig:
+ m_iRequestedConfig = (EGLint) i32Value;
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+/*!***********************************************************************
+ @Function ApiGet
+ @Input prefName Name of value to get
+ @Modified pn A pointer set to the value asked for
+ @description Get parameters which are specific to the API.
+*************************************************************************/
+bool PVRShellInit::ApiGet(const prefNameIntEnum prefName, int *pn)
+{
+ switch(prefName)
+ {
+ case prefEGLMajorVersion:
+ *pn = (int) m_MajorVersion;
+ return true;
+
+ case prefEGLMinorVersion:
+ *pn = (int) m_MinorVersion;
+ return true;
+
+ case prefRequestedConfig:
+ *pn = (int) m_iRequestedConfig;
+ return true;
+
+ case prefConfig:
+ *pn = (int) m_iConfig;
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+/*!***********************************************************************
+ @Function ApiGet
+ @Input prefName Name of value to get
+ @Modified pp A pointer set to the value asked for
+ @description Get parameters which are specific to the API.
+*************************************************************************/
+bool PVRShellInit::ApiGet(const prefNamePtrEnum prefName, void **pp)
+{
+ switch(prefName)
+ {
+ case prefEGLDisplay:
+ *pp = (void*)m_EGLDisplay;
+ return true;
+ case prefEGLSurface:
+ *pp = (void*)m_EGLWindow;
+ return true;
+ default:
+ return false;
+ }
+}
+
+/****************************************************************************
+** Local code
+****************************************************************************/
+
+// The recommended technique for querying OpenGL extensions;
+// adapted from http://opengl.org/resources/features/OGLextensions/
+static bool PVRShellIsExtensionSupported(EGLDisplay dpy, const char *extension)
+{
+ // The recommended technique for querying EGL extensions matches OpenGLES;
+ // from http://opengl.org/resources/features/OGLextensions/
+ const char *extensions = NULL;
+ const char *start;
+ char *terminator;
+
+ /* Extension names should not have spaces. */
+ char* where = (char *) strchr(extension, ' ');
+ if (where || *extension == '\0')
+ return 0;
+
+ extensions = eglQueryString(dpy, EGL_EXTENSIONS);
+ if(!extensions)
+ return false;
+
+ /* It takes a bit of care to be fool-proof about parsing the
+ OpenGL extensions string. Don't be fooled by sub-strings, etc. */
+ start = extensions;
+ for (;;) {
+ where = (char *) strstr((const char *) start, extension);
+ if (!where)
+ break;
+ terminator = where + strlen(extension);
+ if (where == start || *(where - 1) == ' ')
+ if (*terminator == ' ' || *terminator == '\0')
+ return true;
+ start = terminator;
+ }
+ return false;
+}
+
+/// @endcond
+
+/*****************************************************************************
+ End of file (PVRShellAPI.cpp)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/API/KEGL/PVRShellAPI.h b/third_party/PowerVR_SDK/Shell/API/KEGL/PVRShellAPI.h
new file mode 100644
index 0000000..e132f38
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/API/KEGL/PVRShellAPI.h
@@ -0,0 +1,92 @@
+/*!****************************************************************************
+
+ @file KEGL/PVRShellAPI.h
+ @ingroup API_KEGL
+ @copyright Copyright (c) Imagination Technologies Limited.
+ @brief 3D API context management for KEGL.
+ @details Makes programming for 3D APIs easier by wrapping surface
+ initialization, Texture allocation and other functions for use by a demo.
+
+******************************************************************************/
+
+#ifndef __PVRSHELLAPI_H_
+#define __PVRSHELLAPI_H_
+
+/****************************************************************************
+** 3D API header files
+****************************************************************************/
+#if defined(BUILD_OGLES2)
+ #include <GLES2/gl2.h>
+ #include <GLES2/gl2ext.h>
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+#elif defined(BUILD_OGLES3)
+ #include <GLES3/gl3.h>
+ #include <GLES2/gl2ext.h>
+ #include <GLES3/gl3ext.h>
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+#elif defined(BUILD_OGL)
+#define SUPPORT_OPENGL
+#if defined(_WIN32)
+ #include <windows.h>
+#endif
+ #include <GL/gl.h>
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+#else
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ #include <GLES/gl.h>
+ #include <GLES/glext.h>
+ #include <GLES/glplatform.h>
+#endif
+
+/*!***************************************************************************
+ @addtogroup API_KEGL
+ @brief KEGL API
+ @{
+****************************************************************************/
+
+/*!***************************************************************************
+ @class PVRShellInitAPI
+ @brief Initialisation interface with specific API.
+****************************************************************************/
+class PVRShellInitAPI
+{
+public:
+ EGLDisplay m_EGLDisplay;
+ EGLSurface m_EGLWindow;
+ EGLContext m_EGLContext;
+ EGLConfig m_EGLConfig;
+ EGLint m_MajorVersion, m_MinorVersion;
+ bool m_bPowerManagementSupported;
+ EGLint m_iRequestedConfig;
+ EGLint m_iConfig;
+
+ EGLNativeDisplayType m_NDT;
+ EGLNativePixmapType m_NPT;
+ EGLNativeWindowType m_NWT;
+
+
+public:
+ PVRShellInitAPI() : m_bPowerManagementSupported(false), m_iRequestedConfig(0), m_iConfig(0) {}
+ EGLConfig SelectEGLConfiguration(const PVRShellData * const pData);
+ const char *StringFrom_eglGetError() const;
+
+#if defined(BUILD_OGLES) || defined(BUILD_OGLES2)
+protected:
+ typedef void (GL_APIENTRY * PFNGLDISCARDFRAMEBUFFEREXT)(GLenum target, GLsizei numAttachments, const GLenum *attachments);
+ PFNGLDISCARDFRAMEBUFFEREXT glDiscardFramebufferEXT;
+#endif
+
+};
+
+/*! @} */
+
+#endif // __PVRSHELLAPI_H_
+
+/*****************************************************************************
+ End of file (PVRShellAPI.h)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/OS/LinuxX11/PVRShellOS.cpp b/third_party/PowerVR_SDK/Shell/OS/LinuxX11/PVRShellOS.cpp
new file mode 100644
index 0000000..f9a03b7
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/OS/LinuxX11/PVRShellOS.cpp
@@ -0,0 +1,755 @@
+/******************************************************************************
+
+ @File LinuxX11/PVRShellOS.cpp
+
+ @Title LinuxX11/PVRShellOS
+
+ @Version
+
+ @Copyright Copyright (c) Imagination Technologies Limited.
+
+ @Platform X11
+
+ @Description Makes programming for 3D APIs easier by wrapping window creation
+ and other functions for use by a demo.
+
+******************************************************************************/
+
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <time.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "PVRShell.h"
+#include "PVRShellAPI.h"
+#include "PVRShellOS.h"
+#include "PVRShellImpl.h"
+
+// No Doxygen for CPP files, due to documentation duplication
+/// @cond NO_DOXYGEN
+
+/*!***************************************************************************
+ Defines
+*****************************************************************************/
+
+/*****************************************************************************
+ Declarations
+*****************************************************************************/
+static Bool WaitForMapNotify( Display *d, XEvent *e, char *arg );
+
+/*!***************************************************************************
+ Class: PVRShellInit
+*****************************************************************************/
+
+/*!***********************************************************************
+@Function PVRShellOutputDebug
+@Input format printf style format followed by arguments it requires
+@Description Writes the resultant string to the debug output (e.g. using
+ printf(), OutputDebugString(), ...). Check the SDK release notes for
+ details on how the string is output.
+*************************************************************************/
+void PVRShell::PVRShellOutputDebug(char const * const format, ...) const
+{
+ if(!format)
+ return;
+
+ va_list arg;
+ char buf[1024];
+
+ va_start(arg, format);
+ vsnprintf(buf, 1024, format, arg);
+ va_end(arg);
+
+ // Passes the data to a platform dependant function
+ m_pShellInit->OsDisplayDebugString(buf);
+}
+
+/*!***********************************************************************
+ @Function OsInit
+ @description Initialisation for OS-specific code.
+*************************************************************************/
+void PVRShellInit::OsInit()
+{
+ XInitThreads();
+
+ // set values to negative to mark that these are default values
+ m_pShell->m_pShellData->nShellDimX = -240;
+ m_pShell->m_pShellData->nShellDimY = -320;
+
+ m_X11Display = NULL;
+ m_X11Visual = NULL;
+
+ // Pixmap support: init variables to 0
+ m_X11Pixmap = BadValue;
+
+ /*
+ Construct the binary path for GetReadPath() and GetWritePath()
+ */
+ // Get PID (Process ID)
+ pid_t ourPid = getpid();
+ char *pszExePath, pszSrcLink[64];
+ int len = 64;
+ int res;
+
+ sprintf(pszSrcLink, "/proc/%d/exe", ourPid);
+ pszExePath = 0;
+
+ do
+ {
+ len *= 2;
+ delete[] pszExePath;
+ pszExePath = new char[len];
+ res = readlink(pszSrcLink, pszExePath, len);
+
+ if(res < 0)
+ {
+ m_pShell->PVRShellOutputDebug("Warning Readlink %s failed. The application name, read path and write path have not been set.\n", pszExePath);
+ break;
+ }
+ } while(res >= len);
+
+ if(res >= 0)
+ {
+ pszExePath[res] = '\0'; // Null-terminate readlink's result
+ SetReadPath(pszExePath);
+ SetWritePath(pszExePath);
+ SetAppName(pszExePath);
+ }
+
+ delete[] pszExePath;
+
+ m_u32ButtonState = 0;
+
+ gettimeofday(&m_StartTime,NULL);
+}
+
+/*!***********************************************************************
+ @Function OsInitOS
+ @description Saves instance handle and creates main window
+ In this function, we save the instance handle in a global variable and
+ create and display the main program window.
+*************************************************************************/
+bool PVRShellInit::OsInitOS()
+{
+ m_X11Display = XOpenDisplay( NULL );
+
+ if(!m_X11Display)
+ {
+ m_pShell->PVRShellOutputDebug( "Unable to open X display\n");
+ return false;
+ }
+
+ m_X11Screen = XDefaultScreen( m_X11Display );
+
+ /*
+ If there is a full screen request then
+ set the window size to the display size.
+ If there is no full screen request then reduce window size while keeping
+ the same aspect by dividing the dims by two until it fits inside the display area.
+ If the position has not changed from its default value, set it to the middle of the screen.
+ */
+
+ int display_width = XDisplayWidth(m_X11Display,m_X11Screen);
+ int display_height = XDisplayHeight(m_X11Display,m_X11Screen);
+
+ if(m_pShell->m_pShellData->bFullScreen)
+ {
+ // For OGL we do real fullscreen for others API set a window of fullscreen size
+ if(m_pShell->m_pShellData->nShellDimX < 0) {
+ m_pShell->m_pShellData->nShellDimX = display_width;
+ }
+ if(m_pShell->m_pShellData->nShellDimY < 0) {
+ m_pShell->m_pShellData->nShellDimY = display_height;
+ }
+ }
+ else
+ {
+ if(m_pShell->m_pShellData->nShellDimX < 0)
+ m_pShell->m_pShellData->nShellDimX = (display_width > display_height) ? 800 : 600;
+
+ if(m_pShell->m_pShellData->nShellDimY < 0)
+ m_pShell->m_pShellData->nShellDimY = (display_width > display_height) ? 600 : 800;
+
+ if(m_pShell->m_pShellData->nShellDimX > display_width)
+ m_pShell->m_pShellData->nShellDimX = display_width;
+
+ if(m_pShell->m_pShellData->nShellDimY > display_height)
+ m_pShell->m_pShellData->nShellDimY = display_height;
+ }
+
+ // Create the window
+ if(!OpenX11Window(*m_pShell))
+ {
+ m_pShell->PVRShellOutputDebug( "Unable to open X11 window\n" );
+ return false;
+ }
+
+ // Pixmap support: create the pixmap
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ {
+ int depth = DefaultDepth(m_X11Display, m_X11Screen);
+ m_X11Pixmap = XCreatePixmap(m_X11Display,m_X11Window,m_pShell->m_pShellData->nShellDimX,m_pShell->m_pShellData->nShellDimY,depth);
+ m_X11GC = XCreateGC(m_X11Display,m_X11Window,0,0);
+ }
+
+ return true;
+}
+
+/*!***********************************************************************
+ @Function OsReleaseOS
+ @description Destroys main window
+*************************************************************************/
+void PVRShellInit::OsReleaseOS()
+{
+ XCloseDisplay( m_X11Display );
+}
+
+/*!***********************************************************************
+ @Function OsExit
+ @description Destroys main window
+*************************************************************************/
+void PVRShellInit::OsExit()
+{
+ // Show the exit message to the user
+ m_pShell->PVRShellOutputDebug((const char*)m_pShell->PVRShellGet(prefExitMessage));
+}
+
+/*!***********************************************************************
+ @Function OsDoInitAPI
+ @Return true on success
+ @description Perform API initialisation and bring up window / fullscreen
+*************************************************************************/
+bool PVRShellInit::OsDoInitAPI()
+{
+ if(!ApiInitAPI())
+ {
+ return false;
+ }
+
+ // No problem occured
+ return true;
+}
+
+/*!***********************************************************************
+ @Function OsDoReleaseAPI
+ @description Clean up after we're done
+*************************************************************************/
+void PVRShellInit::OsDoReleaseAPI()
+{
+ ApiReleaseAPI();
+
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ {
+ // Pixmap support: free the pixmap
+ XFreePixmap(m_X11Display,m_X11Pixmap);
+ XFreeGC(m_X11Display,m_X11GC);
+ }
+
+ CloseX11Window();
+}
+
+/*!***********************************************************************
+ @Function OsRenderComplete
+ @Returns false when the app should quit
+ @description Main message loop / render loop
+*************************************************************************/
+void PVRShellInit::OsRenderComplete()
+{
+ int numMessages;
+ XEvent event;
+ char* atoms;
+
+ // Are there messages waiting, maybe this should be a while loop
+ numMessages = XPending( m_X11Display );
+ for( int i = 0; i < numMessages; i++ )
+ {
+ XNextEvent( m_X11Display, &event );
+
+ switch( event.type )
+ {
+ case ClientMessage:
+ atoms = XGetAtomName(m_X11Display, event.xclient.message_type);
+ if (*atoms == *"WM_PROTOCOLS")
+ {
+ gShellDone = true;
+ }
+ XFree(atoms);
+ break;
+
+ case ButtonRelease:
+ {
+ XButtonEvent *button_event = ((XButtonEvent *) &event);
+ switch( button_event->button )
+ {
+ case 1 :
+ {
+ m_u32ButtonState &= ~1;
+
+ // Set the current pointer location
+ float vec2PointerLocation[2];
+ vec2PointerLocation[0] = (float)button_event->x / (float)m_pShell->m_pShellData->nShellDimX;
+ vec2PointerLocation[1] = (float)button_event->y / (float)m_pShell->m_pShellData->nShellDimY;
+ TouchEnded(vec2PointerLocation);
+ }
+ break;
+ case 2 : m_u32ButtonState &= ~4; break;
+ case 3 : m_u32ButtonState &= ~2; break;
+ default : break;
+ }
+ break;
+ }
+ case ButtonPress:
+ {
+ XButtonEvent *button_event = ((XButtonEvent *) &event);
+ switch( button_event->button )
+ {
+ case 1 :
+ {
+ m_u32ButtonState |= 1;
+
+ // Set the current pointer location
+ float vec2PointerLocation[2];
+ vec2PointerLocation[0] = (float)button_event->x / (float)m_pShell->m_pShellData->nShellDimX;
+ vec2PointerLocation[1] = (float)button_event->y / (float)m_pShell->m_pShellData->nShellDimY;
+ TouchBegan(vec2PointerLocation);
+ }
+ break;
+ case 2 : m_u32ButtonState |= 4; break;
+ case 3 : m_u32ButtonState |= 2; break;
+ default : break;
+ }
+ break;
+ }
+ case MotionNotify:
+ {
+ XMotionEvent *motion_event = ((XMotionEvent *) &event);
+
+ // Set the current pointer location
+ float vec2PointerLocation[2];
+ vec2PointerLocation[0] = (float)motion_event->x / (float)m_pShell->m_pShellData->nShellDimX;
+ vec2PointerLocation[1] = (float)motion_event->y / (float)m_pShell->m_pShellData->nShellDimY;
+ TouchMoved(vec2PointerLocation);
+ break;
+ }
+ // should SDK handle these?
+ case MapNotify:
+ case UnmapNotify:
+ break;
+
+ case KeyPress:
+ {
+ XKeyEvent *key_event = ((XKeyEvent *) &event);
+
+ switch(key_event->keycode)
+ {
+ case 9: nLastKeyPressed = PVRShellKeyNameQUIT; break; // Esc
+ case 95: nLastKeyPressed = PVRShellKeyNameScreenshot; break; // F11
+ case 36: nLastKeyPressed = PVRShellKeyNameSELECT; break; // Enter
+ case 10: nLastKeyPressed = PVRShellKeyNameACTION1; break; // number 1
+ case 11: nLastKeyPressed = PVRShellKeyNameACTION2; break; // number 2
+ case 98:
+ case 111: nLastKeyPressed = m_eKeyMapUP; break;
+ case 104:
+ case 116: nLastKeyPressed = m_eKeyMapDOWN; break;
+ case 100:
+ case 113: nLastKeyPressed = m_eKeyMapLEFT; break;
+ case 102:
+ case 114: nLastKeyPressed = m_eKeyMapRIGHT; break;
+ default:
+ break;
+ }
+ }
+ break;
+
+ case KeyRelease:
+ {
+// char buf[10];
+// XLookupString(&event.xkey,buf,10,NULL,NULL);
+// charsPressed[ (int) *buf ] = 0;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+/*!***********************************************************************
+ @Function OsPixmapCopy
+ @Return true if the copy succeeded
+ @description When using pixmaps, copy the render to the display
+*************************************************************************/
+bool PVRShellInit::OsPixmapCopy()
+{
+ XCopyArea(m_X11Display,m_X11Pixmap,m_X11Window,m_X11GC,0,0,m_pShell->m_pShellData->nShellDimX,m_pShell->m_pShellData->nShellDimY,0,0);
+ return true;
+}
+
+/*!***********************************************************************
+ @Function OsGetNativeDisplayType
+ @Return The 'NativeDisplayType' for EGL
+ @description Called from InitAPI() to get the NativeDisplayType
+*************************************************************************/
+void *PVRShellInit::OsGetNativeDisplayType()
+{
+ return m_X11Display;
+}
+
+/*!***********************************************************************
+ @Function OsGetNativePixmapType
+ @Return The 'NativePixmapType' for EGL
+ @description Called from InitAPI() to get the NativePixmapType
+*************************************************************************/
+void *PVRShellInit::OsGetNativePixmapType()
+{
+ // Pixmap support: return the pixmap
+ return (void*)m_X11Pixmap;
+}
+
+/*!***********************************************************************
+ @Function OsGetNativeWindowType
+ @Return The 'NativeWindowType' for EGL
+ @description Called from InitAPI() to get the NativeWindowType
+*************************************************************************/
+void *PVRShellInit::OsGetNativeWindowType()
+{
+ return (void*)m_X11Window;
+}
+
+/*!***********************************************************************
+ @Function OsGet
+ @Input prefName Name of value to get
+ @Modified pn A pointer set to the value asked for
+ @Returns true on success
+ @Description Retrieves OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsGet(const prefNameIntEnum prefName, int *pn)
+{
+ switch( prefName )
+ {
+ case prefButtonState:
+ *pn = m_u32ButtonState;
+ return true;
+ default:
+ return false;
+ };
+
+ return false;
+}
+
+/*!***********************************************************************
+ @Function OsGet
+ @Input prefName Name of value to get
+ @Modified pp A pointer set to the value asked for
+ @Returns true on success
+ @Description Retrieves OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsGet(const prefNamePtrEnum prefName, void **pp)
+{
+ return false;
+}
+
+/*!***********************************************************************
+ @Function OsSet
+ @Input prefName Name of preference to set to value
+ @Input value Value
+ @Return true for success
+ @Description Sets OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsSet(const prefNameBoolEnum prefName, const bool value)
+{
+ return false;
+}
+
+/*!***********************************************************************
+ @Function OsSet
+ @Input prefName Name of value to set
+ @Input i32Value The value to set our named value to
+ @Returns true on success
+ @Description Sets OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsSet(const prefNameIntEnum prefName, const int i32Value)
+{
+ return false;
+}
+
+/*!***********************************************************************
+ @Function OsDisplayDebugString
+ @Input str string to output
+ @Description Prints a debug string
+*************************************************************************/
+void PVRShellInit::OsDisplayDebugString(char const * const str)
+{
+ fprintf(stderr, "%s", str);
+}
+
+/*!***********************************************************************
+ @Function OsGetTime
+ @Return An incrementing time value measured in milliseconds
+ @Description Returns an incrementing time value measured in milliseconds
+*************************************************************************/
+unsigned long PVRShellInit::OsGetTime()
+{
+ timeval tv;
+ gettimeofday(&tv,NULL);
+
+ if(tv.tv_sec < m_StartTime.tv_sec)
+ m_StartTime.tv_sec = 0;
+
+ unsigned long sec = tv.tv_sec - m_StartTime.tv_sec;
+ return (unsigned long)((sec*(unsigned long)1000) + (tv.tv_usec/1000.0));
+}
+
+/*****************************************************************************
+ Class: PVRShellInitOS
+*****************************************************************************/
+
+/*!***********************************************************************
+ @Function OpenX11Window
+ @Return true on success
+ @Description Opens an X11 window. This must be called after
+ SelectEGLConfiguration() for gEglConfig to be valid
+*************************************************************************/
+int PVRShellInitOS::OpenX11Window(const PVRShell &shell)
+{
+ XSetWindowAttributes WinAttibutes;
+ XSizeHints sh;
+ XEvent event;
+ unsigned long mask;
+
+#ifdef BUILD_OGL
+ XF86VidModeModeInfo **modes; // modes of display
+ int numModes; // number of modes of display
+ int chosenMode;
+ int edimx,edimy; //established width and height of the chosen modeline
+ int i;
+#endif
+
+ int depth = DefaultDepth(m_X11Display, m_X11Screen);
+ m_X11Visual = new XVisualInfo;
+ XMatchVisualInfo( m_X11Display, m_X11Screen, depth, TrueColor, m_X11Visual);
+
+ if( !m_X11Visual )
+ {
+ shell.PVRShellOutputDebug( "Unable to acquire visual" );
+ return false;
+ }
+
+ m_X11ColorMap = XCreateColormap( m_X11Display, RootWindow(m_X11Display, m_X11Screen), m_X11Visual->visual, AllocNone );
+
+#ifdef BUILD_OGL
+ m_i32OriginalModeDotClock = XF86VidModeBadClock;
+ if(shell.m_pShellData->bFullScreen)
+ {
+ // Get mode lines to see if there is requested modeline
+ XF86VidModeGetAllModeLines(m_X11Display, m_X11Screen, &numModes, &modes);
+
+ // look for mode with requested resolution
+ chosenMode = -1;
+ i=0;
+ while((chosenMode == -1)&&(i<numModes))
+ {
+ if ((modes[i]->hdisplay == shell.m_pShellData->nShellDimX) && (modes[i]->vdisplay == shell.m_pShellData->nShellDimY))
+ {
+ chosenMode = i;
+ }
+ ++i;
+ }
+
+ // If there is no requested resolution among modelines then terminate
+ if(chosenMode == -1)
+ {
+ shell.PVRShellOutputDebug( "Chosen resolution for full screen mode does not match any modeline available.\n" );
+ return false;
+ }
+
+ // save desktop-resolution before switching modes
+ XF86VidModeGetModeLine(m_X11Display,m_X11Screen, &m_i32OriginalModeDotClock, &m_OriginalMode );
+
+ XF86VidModeSwitchToMode(m_X11Display, m_X11Screen, modes[chosenMode]);
+ XF86VidModeSetViewPort(m_X11Display, m_X11Screen, 0, 0);
+ edimx = modes[chosenMode]->hdisplay;
+ edimy = modes[chosenMode]->vdisplay;
+ printf("Fullscreen Resolution %dx%d (chosen mode = %d)\n", edimx, edimy,chosenMode);
+ XFree(modes);
+
+ WinAttibutes.colormap = m_X11ColorMap;
+ WinAttibutes.background_pixel = 0xFFFFFFFF;
+ WinAttibutes.border_pixel = 0;
+ WinAttibutes.override_redirect = true;
+
+ // add to these for handling other events
+ WinAttibutes.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | KeyPressMask | KeyReleaseMask;
+
+ // The diffrence is that we want to ignore influence of window manager for our fullscreen window
+ mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap | CWOverrideRedirect;
+
+ m_X11Window = XCreateWindow( m_X11Display, RootWindow(m_X11Display, m_X11Screen), 0, 0, edimx, edimy, 0,
+ CopyFromParent, InputOutput, CopyFromParent, mask, &WinAttibutes);
+
+ // keeping the pointer of mouse and keyboard in window to prevent from scrolling the virtual screen
+ XWarpPointer(m_X11Display, None ,m_X11Window, 0, 0, 0, 0, 0, 0);
+
+ // Map and then wait till mapped, grabbing should be after mapping the window
+ XMapWindow( m_X11Display, m_X11Window );
+ XGrabKeyboard(m_X11Display, m_X11Window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XGrabPointer(m_X11Display, m_X11Window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, m_X11Window, None, CurrentTime);
+ XIfEvent( m_X11Display, &event, WaitForMapNotify, (char*)m_X11Window );
+
+ }
+ else
+#endif
+ {
+ // For OGLES we assume that chaning of video mode is not available (freedesktop does not allow to do it)
+ // so if requested resolution differs from the display dims then we quit
+ #ifndef BUILD_OGL
+ int display_width = XDisplayWidth(m_X11Display,m_X11Screen);
+ int display_height = XDisplayHeight(m_X11Display,m_X11Screen);
+ if((shell.m_pShellData->bFullScreen)&&((shell.m_pShellData->nShellDimX != display_width)||(shell.m_pShellData->nShellDimY != display_height)) ) {
+ shell.PVRShellOutputDebug( "Chosen resolution for full screen mode does not match available modeline.\n" );
+ return false;
+ }
+ #endif
+
+
+ WinAttibutes.colormap = m_X11ColorMap;
+ WinAttibutes.background_pixel = 0xFFFFFFFF;
+ WinAttibutes.border_pixel = 0;
+
+ // add to these for handling other events
+ WinAttibutes.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | KeyPressMask | KeyReleaseMask;
+
+ // The attribute mask
+ mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap ;
+
+ m_X11Window = XCreateWindow( m_X11Display, // Display
+ RootWindow(m_X11Display, m_X11Screen), // Parent
+ shell.m_pShellData->nShellPosX, // X position of window
+ shell.m_pShellData->nShellPosY, // Y position of window
+ shell.m_pShellData->nShellDimX, // Window width
+ shell.m_pShellData->nShellDimY, // Window height
+ 0, // Border width
+ CopyFromParent, // Depth (taken from parent)
+ InputOutput, // Window class
+ CopyFromParent, // Visual type (taken from parent)
+ mask, // Attributes mask
+ &WinAttibutes); // Attributes
+
+ // Set the window position
+ sh.flags = USPosition;
+ sh.x = shell.m_pShellData->nShellPosX;
+ sh.y = shell.m_pShellData->nShellPosY;
+ XSetStandardProperties( m_X11Display, m_X11Window, shell.m_pShellData->pszAppName, shell.m_pShellData->pszAppName, None, 0, 0, &sh );
+
+ // Map and then wait till mapped
+ XMapWindow( m_X11Display, m_X11Window );
+ XIfEvent( m_X11Display, &event, WaitForMapNotify, (char*)m_X11Window );
+
+ // An attempt to hide a border for fullscreen on non OGL apis (OGLES,OGLES2)
+ if(shell.m_pShellData->bFullScreen)
+ {
+ XEvent xev;
+ Atom wmState = XInternAtom(m_X11Display, "_NET_WM_STATE", False);
+ Atom wmStateFullscreen = XInternAtom(m_X11Display, "_NET_WM_STATE_FULLSCREEN", False);
+
+ memset(&xev, 0, sizeof(XEvent));
+ xev.type = ClientMessage;
+ xev.xclient.window = m_X11Window;
+ xev.xclient.message_type = wmState;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1;
+ xev.xclient.data.l[1] = wmStateFullscreen;
+ xev.xclient.data.l[2] = 0;
+ XSendEvent(m_X11Display, RootWindow(m_X11Display, m_X11Screen), False, SubstructureNotifyMask, &xev);
+ }
+
+ Atom wmDelete = XInternAtom(m_X11Display, "WM_DELETE_WINDOW", True);
+ XSetWMProtocols(m_X11Display, m_X11Window, &wmDelete, 1);
+ XSetWMColormapWindows( m_X11Display, m_X11Window, &m_X11Window, 1 );
+ }
+
+ XFlush( m_X11Display );
+
+ return true;
+}
+
+/*!***********************************************************************
+ @Function CloseX11Window
+ @Return void
+ @Description destroy the instance of a window, and release all relevent memory
+*************************************************************************/
+void PVRShellInitOS::CloseX11Window()
+{
+ // revert introductional resolution (full screen case, bad clock is default value meaning that good was not acquired)
+#ifdef BUILD_OGL
+ XF86VidModeModeInfo tmpmi;
+
+ if(m_i32OriginalModeDotClock != XF86VidModeBadClock)
+ {
+ // revert desktop-resolution (stored previously) before exiting
+ tmpmi.dotclock = m_i32OriginalModeDotClock;
+ tmpmi.c_private = m_OriginalMode.c_private;
+ tmpmi.flags = m_OriginalMode.flags;
+ tmpmi.hdisplay = m_OriginalMode.hdisplay;
+ tmpmi.hskew = m_OriginalMode.hskew;
+ tmpmi.hsyncend = m_OriginalMode.hsyncend;
+ tmpmi.hsyncstart = m_OriginalMode.hsyncstart;
+ tmpmi.htotal = m_OriginalMode.htotal;
+ tmpmi.privsize = m_OriginalMode.privsize;
+ tmpmi.vdisplay = m_OriginalMode.vdisplay;
+ tmpmi.vsyncend = m_OriginalMode.vsyncend;
+ tmpmi.vsyncstart = m_OriginalMode.vsyncstart;
+ tmpmi.vtotal = m_OriginalMode.vtotal;
+
+ XF86VidModeSwitchToMode(m_X11Display,m_X11Screen,&tmpmi);
+ }
+#endif
+
+ XDestroyWindow( m_X11Display, m_X11Window );
+ XFreeColormap( m_X11Display, m_X11ColorMap );
+
+ if(m_X11Visual)
+ delete m_X11Visual;
+}
+
+/*****************************************************************************
+ Global code
+*****************************************************************************/
+
+static Bool WaitForMapNotify( Display *d, XEvent *e, char *arg )
+{
+ return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
+}
+
+/*!***************************************************************************
+@function main
+@input argc count of args from OS
+@input argv array of args from OS
+@returns result code to OS
+@description Main function of the program
+*****************************************************************************/
+int main(int argc, char **argv)
+{
+ PVRShellInit init;
+
+ // Initialise the demo, process the command line, create the OS initialiser.
+ if(!init.Init())
+ return EXIT_ERR_CODE;
+
+ init.CommandLine((argc-1),&argv[1]);
+
+ // Initialise/run/shutdown
+ while(init.Run());
+
+ return EXIT_NOERR_CODE;
+}
+
+/// @endcond
+
+/*****************************************************************************
+ End of file (PVRShellOS.cpp)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/OS/LinuxX11/PVRShellOS.h b/third_party/PowerVR_SDK/Shell/OS/LinuxX11/PVRShellOS.h
new file mode 100644
index 0000000..0217433
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/OS/LinuxX11/PVRShellOS.h
@@ -0,0 +1,77 @@
+/*!****************************************************************************
+
+ @file LinuxX11/PVRShellOS.h
+ @ingroup OS_LinuxX11
+ @copyright Copyright (c) Imagination Technologies Limited.
+ @brief Initialization for the shell for LinuxX11.
+ @details Makes programming for 3D APIs easier by wrapping surface
+ initialization, Texture allocation and other functions for use by a demo.
+
+******************************************************************************/
+#ifndef _PVRSHELLOS_
+#define _PVRSHELLOS_
+
+#include "X11/Xlib.h"
+#include "X11/Xutil.h"
+#ifdef BUILD_OGL
+#include "X11/extensions/xf86vmode.h"
+#endif
+
+#define PVRSHELL_DIR_SYM '/'
+#define _stricmp strcasecmp
+
+/*!
+ @addtogroup OS_LinuxX11
+ @brief LinuxX11 OS
+ @details The following table illustrates how key codes are mapped in LinuxX11:
+ <table>
+ <tr><th> Key code </th><th> nLastKeyPressed (PVRShell) </th></tr>
+ <tr><td> Esc </td><td> PVRShellKeyNameQUIT </td></tr>
+ <tr><td> F11 </td><td> PVRShellKeyNameScreenshot </td></tr>
+ <tr><td> Enter </td><td> PVRShellKeyNameSELECT </td></tr>
+ <tr><td> '1' </td><td> PVRShellKeyNameACTION1 </td></tr>
+ <tr><td> '2' </td><td> PVRShellKeyNameACTION2 </td></tr>
+ <tr><td> Up arrow </td><td> m_eKeyMapUP </td></tr>
+ <tr><td> Down arrow </td><td> m_eKeyMapDOWN </td></tr>
+ <tr><td> Left arrow </td><td> m_eKeyMapLEFT </td></tr>
+ <tr><td> Right arrow </td><td> m_eKeyMapRIGHT </td></tr>
+ </table>
+ @{
+*/
+
+/*!***************************************************************************
+ @class PVRShellInitOS
+ @brief Interface with specific Operative System.
+*****************************************************************************/
+class PVRShellInitOS
+{
+public:
+ Display* m_X11Display;
+ long m_X11Screen;
+ XVisualInfo* m_X11Visual;
+ Colormap m_X11ColorMap;
+ Window m_X11Window;
+ timeval m_StartTime;
+#ifdef BUILD_OGL
+ XF86VidModeModeLine m_OriginalMode; // modeline that was active at the starting point of this aplication
+ int m_i32OriginalModeDotClock;
+#endif
+
+ // Pixmap support: variables for the pixmap
+ Pixmap m_X11Pixmap;
+ GC m_X11GC;
+
+ unsigned int m_u32ButtonState; // 1 = left, 2 = right, 4 = middle
+
+public:
+ int OpenX11Window(const PVRShell &shell);
+ void CloseX11Window();
+};
+
+/*! @} */
+
+#endif /* _PVRSHELLOS_ */
+/*****************************************************************************
+ End of file (PVRShellOS.h)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/OS/Windows/PVRShellOS.cpp b/third_party/PowerVR_SDK/Shell/OS/Windows/PVRShellOS.cpp
new file mode 100644
index 0000000..31ab9fa
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/OS/Windows/PVRShellOS.cpp
@@ -0,0 +1,805 @@
+/******************************************************************************
+
+ @File PVRShellOS.cpp
+
+ @Title Windows/PVRShellOS
+
+ @Version
+
+ @Copyright Copyright (c) Imagination Technologies Limited.
+
+ @Platform WinCE/Windows
+
+ @Description Makes programming for 3D APIs easier by wrapping window creation
+ and other functions for use by a demo.
+
+******************************************************************************/
+
+/****************************************************************************
+ ** INCLUDES **
+ ****************************************************************************/
+#include <windows.h>
+#include <TCHAR.H>
+#include <stdio.h>
+
+#include "PVRShell.h"
+#include "PVRShellAPI.h"
+#include "PVRShellOS.h"
+#include "PVRShellImpl.h"
+
+// No Doxygen for CPP files, due to documentation duplication
+/// @cond NO_DOXYGEN
+
+#if !(WINVER >= 0x0500)
+ #define COMPILE_MULTIMON_STUBS
+ #include <multimon.h>
+#endif
+
+/****************************************************************************
+ Defines
+*****************************************************************************/
+/*! The class name for the window */
+#define WINDOW_CLASS _T("PVRShellClass")
+
+/*! Maximum size to create string array for determining the read/write paths */
+#define DIR_BUFFER_LEN (10240)
+
+/*! X dimension of the window that is created */
+#define SHELL_DISPLAY_DIM_X 800
+/*! Y dimension of the window that is created */
+#define SHELL_DISPLAY_DIM_Y 600
+
+/*****************************************************************************
+ Declarations
+*****************************************************************************/
+LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+
+/*!***************************************************************************
+ Class: PVRShellInit
+*****************************************************************************/
+
+/*!***********************************************************************
+@Function PVRShellOutputDebug
+@Input format printf style format followed by arguments it requires
+@Description Writes the resultant string to the debug output (e.g. using
+ printf(), OutputDebugString(), ...). Check the SDK release notes for
+ details on how the string is output.
+*************************************************************************/
+void PVRShell::PVRShellOutputDebug(char const * const format, ...) const
+{
+ va_list arg;
+ char buf[1024];
+
+ va_start(arg, format);
+ vsnprintf(buf, 1024, format, arg);
+ va_end(arg);
+
+ // Passes the data to a platform dependant function
+ m_pShellInit->OsDisplayDebugString(buf);
+}
+
+/*!***********************************************************************
+ @Function OsInit
+ @description Initialisation for OS-specific code.
+*************************************************************************/
+void PVRShellInit::OsInit()
+{
+ m_hAccelTable = 0;
+
+ m_pShell->m_pShellData->nShellDimX = SHELL_DISPLAY_DIM_X;
+ m_pShell->m_pShellData->nShellDimY = SHELL_DISPLAY_DIM_Y;
+
+ m_hDC = 0;
+ m_hWnd = 0;
+
+ // Pixmap support: init variables to 0
+ m_hBmPixmap = 0;
+ m_hBmPixmapOld = 0;
+ m_hDcPixmap = 0;
+
+ /*
+ Construct the binary path for GetReadPath() and GetWritePath()
+ */
+ {
+ /* Allocate memory for strings and return 0 if allocation failed */
+ TCHAR* exeNameTCHAR = new TCHAR[DIR_BUFFER_LEN];
+ char* exeName = new char[DIR_BUFFER_LEN];
+ if(exeNameTCHAR && exeName)
+ {
+ DWORD retSize;
+
+ /*
+ Get the data path and a default application name
+ */
+
+ // Get full path of executable
+ retSize = GetModuleFileName(NULL, exeNameTCHAR, DIR_BUFFER_LEN);
+
+ if (DIR_BUFFER_LEN > (int)retSize)
+ {
+ /* Get string length in char */
+ retSize = (DWORD)_tcslen(exeNameTCHAR);
+
+ /* Convert TChar to char */
+ for (DWORD i = 0; i <= retSize; i++)
+ {
+ exeName[i] = (char)exeNameTCHAR[i];
+ }
+
+ SetAppName(exeName);
+ SetReadPath(exeName);
+ SetWritePath(exeName);
+ }
+ }
+
+ delete [] exeName;
+ delete [] exeNameTCHAR;
+ }
+
+ m_u32ButtonState = 0; // clear mouse button state at startup
+}
+
+/*!***********************************************************************
+ @Function OsInitOS
+ @description Saves instance handle and creates main window
+ In this function, we save the instance handle in a global variable and
+ create and display the main program window.
+*************************************************************************/
+bool PVRShellInit::OsInitOS()
+{
+ MONITORINFO sMInfo;
+ TCHAR *appName;
+ RECT winRect;
+ POINT p;
+
+ MyRegisterClass();
+
+ /*
+ Build the window title
+ */
+ {
+ const char *pszName, *pszSeparator, *pszVersion;
+ size_t len;
+ unsigned int out, in;
+
+ pszName = (const char*)m_pShell->PVRShellGet(prefAppName);
+ pszSeparator = STR_WNDTITLE;
+ pszVersion = (const char*)m_pShell->PVRShellGet(prefVersion);
+
+ len = strlen(pszName)+strlen(pszSeparator)+strlen(pszVersion)+1;
+ appName = new TCHAR[len];
+
+ for(out = 0; (appName[out] = pszName[out]) != 0; ++out);
+ for(in = 0; (appName[out] = pszSeparator[in]) != 0; ++in, ++out);
+ for(in = 0; (appName[out] = pszVersion[in]) != 0; ++in, ++out);
+ _ASSERT(out == len-1);
+ }
+
+ /*
+ Retrieve the monitor information.
+
+ MonitorFromWindow() doesn't work, because the window hasn't been
+ created yet.
+ */
+ {
+ HMONITOR hMonitor;
+ BOOL bRet;
+
+ p.x = m_pShell->m_pShellData->nShellPosX;
+ p.y = m_pShell->m_pShellData->nShellPosY;
+ hMonitor = MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
+ sMInfo.cbSize = sizeof(sMInfo);
+ bRet = GetMonitorInfo(hMonitor, &sMInfo);
+ _ASSERT(bRet);
+ }
+
+ /*
+ Reduce the window size until it fits on screen
+ */
+ while(
+ (m_pShell->m_pShellData->nShellDimX > (sMInfo.rcMonitor.right - sMInfo.rcMonitor.left)) ||
+ (m_pShell->m_pShellData->nShellDimY > (sMInfo.rcMonitor.bottom - sMInfo.rcMonitor.top)))
+ {
+ m_pShell->m_pShellData->nShellDimX >>= 1;
+ m_pShell->m_pShellData->nShellDimY >>= 1;
+ }
+
+
+ /*
+ Create the window
+ */
+
+ if(m_pShell->m_pShellData->bFullScreen)
+ {
+ m_hWnd = CreateWindow(WINDOW_CLASS, appName, WS_VISIBLE | WS_SYSMENU,CW_USEDEFAULT, CW_USEDEFAULT, m_pShell->m_pShellData->nShellDimX, m_pShell->m_pShellData->nShellDimY,
+ NULL, NULL, m_hInstance, this);
+
+ SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) &~ WS_CAPTION);
+ SetWindowPos(m_hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
+ }
+ else
+ {
+ int x, y;
+
+ SetRect(&winRect,
+ m_pShell->m_pShellData->nShellPosX,
+ m_pShell->m_pShellData->nShellPosY,
+ m_pShell->m_pShellData->nShellPosX+m_pShell->m_pShellData->nShellDimX,
+ m_pShell->m_pShellData->nShellPosY+m_pShell->m_pShellData->nShellDimY);
+ AdjustWindowRectEx(&winRect, WS_CAPTION|WS_SYSMENU, false, 0);
+
+ x = m_pShell->m_pShellData->nShellPosX - winRect.left;
+ winRect.left += x;
+ winRect.right += x;
+
+ y = m_pShell->m_pShellData->nShellPosY - winRect.top;
+ winRect.top += y;
+ winRect.bottom += y;
+
+ if(m_pShell->m_pShellData->bShellPosWasDefault)
+ {
+ x = CW_USEDEFAULT;
+ y = CW_USEDEFAULT;
+ }
+ else
+ {
+ x = winRect.left;
+ y = winRect.top;
+ }
+
+ m_hWnd = CreateWindow(WINDOW_CLASS, appName, WS_VISIBLE|WS_CAPTION|WS_SYSMENU,
+ x, y, winRect.right-winRect.left, winRect.bottom-winRect.top, NULL, NULL, m_hInstance, this);
+
+ }
+
+ if(!m_hWnd)
+ return false;
+
+ if(m_pShell->m_pShellData->bFullScreen)
+ {
+ m_pShell->m_pShellData->nShellDimX = sMInfo.rcMonitor.right;
+ m_pShell->m_pShellData->nShellDimY = sMInfo.rcMonitor.bottom;
+ SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,m_pShell->m_pShellData->nShellDimX,m_pShell->m_pShellData->nShellDimY,0);
+ }
+
+ m_hDC = GetDC(m_hWnd);
+ ShowWindow(m_hWnd, m_nCmdShow);
+ UpdateWindow(m_hWnd);
+
+ delete [] appName;
+ return true;
+}
+
+/*!***********************************************************************
+ @Function OsReleaseOS
+ @description Destroys main window
+*************************************************************************/
+void PVRShellInit::OsReleaseOS()
+{
+ ReleaseDC(m_hWnd, m_hDC);
+ DestroyWindow(m_hWnd);
+}
+
+/*!***********************************************************************
+ @Function OsExit
+ @description Destroys main window
+*************************************************************************/
+void PVRShellInit::OsExit()
+{
+ const char *szText;
+
+ /*
+ Show the exit message to the user
+ */
+ szText = (const char*)m_pShell->PVRShellGet(prefExitMessage);
+
+ int i, nT, nC;
+ const char *szCaption;
+ TCHAR *tzText, *tzCaption;
+
+ szCaption = (const char*)m_pShell->PVRShellGet(prefAppName);
+
+ if(!szText || !szCaption)
+ return;
+
+ nT = (int)strlen(szText) + 1;
+ nC = (int)strlen(szCaption) + 1;
+
+ tzText = (TCHAR*)malloc(nT * sizeof(*tzText));
+ tzCaption = (TCHAR*)malloc(nC * sizeof(*tzCaption));
+
+ for(i = 0; (tzText[i] = szText[i]) != 0; ++i);
+ for(i = 0; (tzCaption[i] = szCaption[i]) != 0; ++i);
+
+ MessageBox(NULL, tzText, tzCaption, MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND);
+
+ FREE(tzText);
+ FREE(tzCaption);
+}
+
+/*!***********************************************************************
+ @Function OsDoInitAPI
+ @Return true on success
+ @description Perform API initialisation and bring up window / fullscreen
+*************************************************************************/
+bool PVRShellInit::OsDoInitAPI()
+{
+
+ // Pixmap support: create the pixmap
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ {
+ m_hDcPixmap = CreateCompatibleDC(m_hDC);
+ m_hBmPixmap = CreateCompatibleBitmap(m_hDC, 640, 480);
+ }
+
+ if(!ApiInitAPI())
+ {
+ return false;
+ }
+
+ // Pixmap support: select the pixmap into a device context (DC) ready for blitting
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ {
+ m_hBmPixmapOld = (HBITMAP)SelectObject(m_hDcPixmap, m_hBmPixmap);
+ }
+
+ SetForegroundWindow(m_hWnd);
+
+ /* No problem occured */
+ return true;
+}
+
+/*!***********************************************************************
+ @Function OsDoReleaseAPI
+ @description Clean up after we're done
+*************************************************************************/
+void PVRShellInit::OsDoReleaseAPI()
+{
+ ApiReleaseAPI();
+
+ if(m_pShell->m_pShellData->bNeedPixmap)
+ {
+ // Pixmap support: free the pixmap
+ SelectObject(m_hDcPixmap, m_hBmPixmapOld);
+ DeleteDC(m_hDcPixmap);
+ DeleteObject(m_hBmPixmap);
+ }
+}
+
+/*!***********************************************************************
+ @Function OsRenderComplete
+ @Returns false when the app should quit
+ @description Main message loop / render loop
+*************************************************************************/
+void PVRShellInit::OsRenderComplete()
+{
+ MSG msg;
+
+ /*
+ Process the message queue
+ */
+ while(PeekMessage(&msg, m_hWnd, 0, 0, PM_REMOVE))
+ {
+ if (!TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+}
+
+/*!***********************************************************************
+ @Function OsPixmapCopy
+ @Return true if the copy succeeded
+ @description When using pixmaps, copy the render to the display
+*************************************************************************/
+bool PVRShellInit::OsPixmapCopy()
+{
+ return (BitBlt(m_hDC, 0, 0, 640, 480, m_hDcPixmap, 0, 0, SRCCOPY) == TRUE);
+}
+
+/*!***********************************************************************
+ @Function OsGetNativeDisplayType
+ @Return The 'NativeDisplayType' for EGL
+ @description Called from InitAPI() to get the NativeDisplayType
+*************************************************************************/
+void *PVRShellInit::OsGetNativeDisplayType()
+{
+ return m_hDC;
+}
+
+/*!***********************************************************************
+ @Function OsGetNativePixmapType
+ @Return The 'NativePixmapType' for EGL
+ @description Called from InitAPI() to get the NativePixmapType
+*************************************************************************/
+void *PVRShellInit::OsGetNativePixmapType()
+{
+ // Pixmap support: return the pixmap
+ return m_hBmPixmap;
+}
+
+/*!***********************************************************************
+ @Function OsGetNativeWindowType
+ @Return The 'NativeWindowType' for EGL
+ @description Called from InitAPI() to get the NativeWindowType
+*************************************************************************/
+void *PVRShellInit::OsGetNativeWindowType()
+{
+ return m_hWnd;
+}
+
+/*!***********************************************************************
+ @Function OsGet
+ @Input prefName Name of value to get
+ @Modified pn A pointer set to the value asked for
+ @Returns true on success
+ @Description Retrieves OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsGet(const prefNameIntEnum prefName, int *pn)
+{
+ switch(prefName)
+ {
+ case prefButtonState:
+ *pn = m_u32ButtonState;
+ return true;
+ };
+ return false;
+}
+
+/*!***********************************************************************
+ @Function OsSet
+ @Input prefName Name of preference to set to value
+ @Input value Value
+ @Return true for success
+ @Description Sets OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsSet(const prefNameBoolEnum prefName, const bool value)
+{
+ switch(prefName)
+ {
+ case prefShowCursor:
+ ShowCursor(value ? TRUE : FALSE);
+ return true;
+ }
+
+ return false;
+}
+
+/*!***********************************************************************
+ @Function OsSet
+ @Input prefName Name of value to set
+ @Input i32Value The value to set our named value to
+ @Returns true on success
+ @Description Sets OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsSet(const prefNameIntEnum prefName, const int i32Value)
+{
+ PVRSHELL_UNREFERENCED_PARAMETER(prefName);
+ PVRSHELL_UNREFERENCED_PARAMETER(i32Value);
+ return false;
+}
+
+/*!***********************************************************************
+ @Function OsGet
+ @Input prefName Name of value to get
+ @Modified pp A pointer set to the value asked for
+ @Returns true on success
+ @Description Retrieves OS-specific data
+*************************************************************************/
+bool PVRShellInit::OsGet(const prefNamePtrEnum prefName, void **pp)
+{
+ switch(prefName)
+ {
+ case prefHINSTANCE:
+ *pp = m_hInstance;
+ return true;
+ default:
+ return false;
+ }
+}
+
+/*!***********************************************************************
+ @Function OsDisplayDebugString
+ @Input str string to output
+ @Description Prints a debug string
+*************************************************************************/
+void PVRShellInit::OsDisplayDebugString(char const * const str)
+{
+ if(str)
+ {
+#if defined(UNICODE)
+ wchar_t strc[1024];
+ int i;
+
+ for(i = 0; (str[i] != '\0') && (i < (sizeof(strc) / sizeof(*strc))); ++i)
+ {
+ strc[i] = (wchar_t)str[i];
+ }
+
+ strc[i] = '\0';
+
+ OutputDebugString(strc);
+#else
+ OutputDebugString(str);
+#endif
+ }
+}
+
+/*!***********************************************************************
+ @Function OsGetTime
+ @Return An incrementing time value measured in milliseconds
+ @Description Returns an incrementing time value measured in milliseconds
+*************************************************************************/
+unsigned long PVRShellInit::OsGetTime()
+{
+ return (unsigned long)GetTickCount();
+}
+
+/*****************************************************************************
+ Class: PVRShellInitOS
+*****************************************************************************/
+
+/*!******************************************************************************************
+@function MyRegisterClass()
+@description Registers the window class.
+ This function and its usage is only necessary if you want this code
+ to be compatible with Win32 systems prior to the 'RegisterClassEx'
+ function that was added to Windows 95. It is important to call this function
+ so that the application will get 'well formed' small icons associated
+ with it.
+**********************************************************************************************/
+ATOM PVRShellInitOS::MyRegisterClass()
+{
+ WNDCLASS wc;
+
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = m_hInstance;
+ wc.hIcon = LoadIcon(m_hInstance, _T("ICON"));
+ wc.hCursor = 0;
+ wc.lpszMenuName = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszClassName = WINDOW_CLASS;
+
+ return RegisterClass(&wc);
+}
+
+/*****************************************************************************
+ Global code
+*****************************************************************************/
+void doButtonDown(HWND hWnd, PVRShellInit *pData, EPVRShellButtonState eButton, LPARAM lParam)
+{
+ RECT rcWinDimensions;
+ GetClientRect(hWnd,&rcWinDimensions);
+ float vec2TouchPosition[2] = { (float)(short)LOWORD(lParam)/(float)(rcWinDimensions.right), (float)(short)HIWORD(lParam)/(float)(rcWinDimensions.bottom) };
+ pData->TouchBegan(vec2TouchPosition);
+ SetCapture(hWnd); // must be within window so capture
+ pData->m_u32ButtonState |= eButton;
+}
+
+bool doButtonUp(HWND hWnd, PVRShellInit *pData, EPVRShellButtonState eButton, LPARAM lParam)
+{
+ RECT rcWinDimensions;
+ GetClientRect(hWnd,&rcWinDimensions);
+ float vec2TouchPosition[2] = { (float)(short)LOWORD(lParam)/(float)(rcWinDimensions.right), (float)(short)HIWORD(lParam)/(float)(rcWinDimensions.bottom) };
+ pData->TouchEnded(vec2TouchPosition);
+ pData->m_u32ButtonState &= (~eButton);
+
+ if(vec2TouchPosition[0] < 0.f || vec2TouchPosition[0] > 1.f || vec2TouchPosition[1] < 0.f || vec2TouchPosition[1] > 1.f)
+ { // pointer has left window
+ if(pData->m_u32ButtonState==0)
+ { // only release capture if mouse buttons have been released
+ ReleaseCapture();
+ }
+
+ return false;
+ }
+ return true;
+}
+
+/*!***************************************************************************
+@function WndProc
+@input hWnd Handle to the window
+@input message Specifies the message
+@input wParam Additional message information
+@input lParam Additional message information
+@returns result code to OS
+@description Processes messages for the main window.
+*****************************************************************************/
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ PVRShellInit *pData = (PVRShellInit*) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+
+ switch (message)
+ {
+ case WM_CREATE:
+ {
+ CREATESTRUCT *pCreate = (CREATESTRUCT*)lParam;
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pCreate->lpCreateParams);
+ break;
+ }
+ case WM_PAINT:
+ break;
+ case WM_DESTROY:
+ return 0;
+ case WM_CLOSE:
+ pData->gShellDone = true;
+ return 0;
+ case WM_QUIT:
+ return 0;
+ case WM_MOVE:
+ pData->m_pShell->PVRShellSet(prefPositionX, (int)LOWORD(lParam));
+ pData->m_pShell->PVRShellSet(prefPositionY, (int)HIWORD(lParam));
+ break;
+ case WM_LBUTTONDOWN:
+ {
+ doButtonDown(hWnd,pData,ePVRShellButtonLeft,lParam);
+ break;
+ }
+ case WM_LBUTTONUP:
+ {
+ if(!doButtonUp(hWnd,pData,ePVRShellButtonLeft,lParam))
+ return false;
+ break;
+ }
+ case WM_RBUTTONDOWN:
+ {
+ doButtonDown(hWnd,pData,ePVRShellButtonRight,lParam);
+ break;
+ }
+ case WM_RBUTTONUP:
+ {
+ if(!doButtonUp(hWnd,pData,ePVRShellButtonRight,lParam))
+ return false;
+ break;
+ }
+ case WM_MBUTTONDOWN:
+ {
+ doButtonDown(hWnd,pData,ePVRShellButtonMiddle,lParam);
+ break;
+ }
+ case WM_MBUTTONUP:
+ {
+ if(!doButtonUp(hWnd,pData,ePVRShellButtonMiddle,lParam))
+ return false;
+ break;
+ }
+ case WM_MOUSEMOVE:
+ {
+ RECT rcWinDimensions;
+ GetClientRect(hWnd,&rcWinDimensions);
+ float vec2TouchPosition[2] = { (float)(short)LOWORD(lParam)/(float)(rcWinDimensions.right), (float)(short)HIWORD(lParam)/(float)(rcWinDimensions.bottom) };
+
+ if(vec2TouchPosition[0] < 0.f || vec2TouchPosition[0] > 1.f || vec2TouchPosition[1] < 0.f || vec2TouchPosition[1] > 1.f)
+ {
+ // pointer has left window
+ if(pData->m_u32ButtonState==0)
+ { // only release capture if mouse buttons have been released
+ ReleaseCapture();
+ }
+
+ pData->TouchEnded(vec2TouchPosition);
+ return false;
+ }
+ else
+ { // pointer is inside window
+ pData->TouchMoved(vec2TouchPosition);
+ }
+ break;
+ }
+ case WM_SETFOCUS:
+ pData->m_bHaveFocus = true;
+ return 0;
+ case WM_KILLFOCUS:
+ pData->m_bHaveFocus = false;
+ return 0;
+ case WM_KEYDOWN:
+ {
+ switch(wParam)
+ {
+ case VK_ESCAPE:
+ case 0xC1:
+ pData->KeyPressed(PVRShellKeyNameQUIT);
+ break;
+ case VK_UP:
+ case 0x35:
+ pData->KeyPressed(pData->m_eKeyMapUP);
+ break;
+ case VK_DOWN:
+ case 0x30:
+ pData->KeyPressed(pData->m_eKeyMapDOWN);
+ break;
+ case VK_LEFT:
+ case 0x37:
+ pData->KeyPressed(pData->m_eKeyMapLEFT);
+ break;
+ case VK_RIGHT:
+ case 0x39:
+ pData->KeyPressed(pData->m_eKeyMapRIGHT);
+ break;
+ case VK_SPACE:
+ case 0x38:
+ pData->KeyPressed(PVRShellKeyNameSELECT);
+ break;
+ case '1':
+ case 0x34:
+ pData->KeyPressed(PVRShellKeyNameACTION1);
+ break;
+ case '2':
+ case 0x36:
+ pData->KeyPressed(PVRShellKeyNameACTION2);
+ break;
+ case VK_F11:
+ case 0xC2:
+ pData->KeyPressed(PVRShellKeyNameScreenshot);
+ break;
+ }
+ }
+ default:
+ break;
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+/*!***************************************************************************
+@function WinMain
+@input hInstance Application instance from OS
+@input hPrevInstance Always NULL
+@input lpCmdLine command line from OS
+@input nCmdShow Specifies how the window is to be shown
+@returns result code to OS
+@description Main function of the program
+*****************************************************************************/
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLine, int nCmdShow)
+{
+ size_t i;
+ char *pszCmdLine;
+ PVRShellInit init;
+
+ PVRSHELL_UNREFERENCED_PARAMETER(hPrevInstance);
+
+#if defined(_WIN32)
+ // Enable memory-leak reports
+ _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
+#endif
+
+ // Get a char-array command line as the input may be UNICODE
+ i = _tcslen(lpCmdLine) + 1;
+ pszCmdLine = new char[i];
+
+ while(i)
+ {
+ --i;
+ pszCmdLine[i] = (char)lpCmdLine[i];
+ }
+
+ // Init the demo, process the command line, create the OS initialiser.
+ if(!init.Init())
+ {
+ delete[] pszCmdLine;
+ return EXIT_ERR_CODE;
+ }
+
+ init.CommandLine(pszCmdLine);
+ init.m_hInstance = hInstance;
+ init.m_nCmdShow = nCmdShow;
+
+ // Initialise/run/shutdown
+ while(init.Run());
+
+ delete[] pszCmdLine;
+
+ return EXIT_NOERR_CODE;
+}
+
+/// @endcond
+
+/*****************************************************************************
+ End of file (PVRShellOS.cpp)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/OS/Windows/PVRShellOS.h b/third_party/PowerVR_SDK/Shell/OS/Windows/PVRShellOS.h
new file mode 100644
index 0000000..6268b99
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/OS/Windows/PVRShellOS.h
@@ -0,0 +1,77 @@
+/*!****************************************************************************
+
+ @file Windows/PVRShellOS.h
+ @ingroup OS_Windows
+ @copyright Copyright (c) Imagination Technologies Limited.
+ @brief Initialization for the shell for the Windows OS.
+ @details Makes programming for 3D APIs easier by wrapping surface
+ initialization, Texture allocation and other functions for use by a demo.
+
+******************************************************************************/
+#ifndef _PVRSHELLOS_
+#define _PVRSHELLOS_
+
+#include <windows.h>
+
+// The following defines are for Windows PC platforms only
+#if defined(_WIN32)
+// Enable the following 2 lines for memory leak checking - also see WinMain()
+#define _CRTDBG_MAP_ALLOC
+#include <crtdbg.h>
+#endif
+
+#define PVRSHELL_DIR_SYM '\\'
+#define vsnprintf _vsnprintf
+
+/*!
+ @addtogroup OS_Windows
+ @brief Windows OS
+ @details The following table illustrates how key codes are mapped in Windows:
+ <table>
+ <tr><th> Key code </th><th> KeyPressed (PVRShell) </th></tr>
+ <tr><td> ESCAPE </td><td> PVRShellKeyNameQUIT </td></tr>
+ <tr><td> UP </td><td> m_eKeyMapUP </td></tr>
+ <tr><td> DOWN </td><td> m_eKeyMapDOWN </td></tr>
+ <tr><td> LEFT </td><td> m_eKeyMapLEFT </td></tr>
+ <tr><td> RIGHT </td><td> m_eKeyMapRIGHT </td></tr>
+ <tr><td> SPACE </td><td> PVRShellKeyNameSELECT </td></tr>
+ <tr><td> '1' </td><td> PVRShellKeyNameACTION1 </td></tr>
+ <tr><td> '2' </td><td> PVRShellKeyNameACTION2 </td></tr>
+ <tr><td> F11 </td><td> PVRShellKeyNameScreenshot </td></tr>
+ </table>
+ @{
+*/
+
+/*!***************************************************************************
+ @class PVRShellInitOS
+ @brief Interface with specific Operating System.
+*****************************************************************************/
+class PVRShellInitOS
+{
+public:
+ HDC m_hDC;
+ HWND m_hWnd;
+
+ // Pixmap support: variables for the pixmap
+ HBITMAP m_hBmPixmap, m_hBmPixmapOld;
+ HDC m_hDcPixmap;
+
+ HACCEL m_hAccelTable;
+ HINSTANCE m_hInstance;
+ int m_nCmdShow;
+
+ bool m_bHaveFocus;
+
+ unsigned int m_u32ButtonState;
+
+public:
+ ATOM MyRegisterClass();
+};
+
+/*! @} */
+
+#endif /* _PVRSHELLOS_ */
+/*****************************************************************************
+ End of file (PVRShellOS.h)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/PVRShell.cpp b/third_party/PowerVR_SDK/Shell/PVRShell.cpp
new file mode 100644
index 0000000..d29b625
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/PVRShell.cpp
@@ -0,0 +1,1777 @@
+/******************************************************************************
+
+ @file Shell/PVRShell.cpp
+ @copyright Copyright (c) Imagination Technologies Limited.
+ @brief Makes programming for 3D APIs easier by wrapping surface
+ initialization, Texture allocation and other functions for use by a demo.
+
+******************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <math.h>
+
+#include "PVRShell.h"
+#include "PVRShellOS.h"
+#include "PVRShellAPI.h"
+#include "PVRShellImpl.h"
+
+/*! This file simply defines a version string. It can be commented out. */
+#include "sdkver.h"
+#ifndef PVRSDK_VERSION
+#define PVRSDK_VERSION "n.nn.nn.nnnn"
+#endif
+
+/*! Define to automatically stop the app after x frames. If negative, run forever. */
+#ifndef PVRSHELL_QUIT_AFTER_FRAME
+#define PVRSHELL_QUIT_AFTER_FRAME -1
+#endif
+
+/*! Define to automatically stop the app after x amount of seconds. If negative, run forever. */
+#ifndef PVRSHELL_QUIT_AFTER_TIME
+#define PVRSHELL_QUIT_AFTER_TIME -1
+#endif
+
+/*! Define for the screen shot file name. */
+#define PVRSHELL_SCREENSHOT_NAME "PVRShell"
+
+#if defined(_WIN32)
+#define snprintf _snprintf
+#endif
+
+// No Doxygen for CPP files, due to documentation duplication
+/// @cond NO_DOXYGEN
+
+// Define DISABLE_SWIPE_MAPPING to disable the PVRShell's simple mapping of swipes to key commands.
+//#define DISABLE_SWIPE_MAPPING 1
+/*****************************************************************************
+** Prototypes
+*****************************************************************************/
+static bool StringCopy(char *&pszStr, const char * const pszSrc);
+
+/****************************************************************************
+** Class: PVRShell
+****************************************************************************/
+
+/*!***********************************************************************
+ @brief Constructor
+*************************************************************************/
+PVRShell::PVRShell()
+{
+ m_pShellInit = NULL;
+ m_pShellData = new PVRShellData;
+
+ m_pShellData->nShellPosX=0;
+ m_pShellData->nShellPosY=0;
+
+ m_pShellData->bFullScreen = false; // note this may be overridden by some OS versions of PVRShell
+
+ m_pShellData->nAASamples= 0;
+ m_pShellData->nColorBPP = 0;
+ m_pShellData->nDepthBPP = 0;
+
+ m_pShellData->nDieAfterFrames = PVRSHELL_QUIT_AFTER_FRAME;
+ m_pShellData->fDieAfterTime = PVRSHELL_QUIT_AFTER_TIME;
+
+ m_pShellData->bNeedPbuffer = false;
+ m_pShellData->bNeedPixmap = false;
+ m_pShellData->bNeedPixmapDisableCopy = false;
+ m_pShellData->bNeedZbuffer = true;
+ m_pShellData->bLockableBackBuffer = false;
+ m_pShellData->bSoftwareRender = false;
+ m_pShellData->bNeedStencilBuffer = false;
+
+ m_pShellData->bNeedAlphaFormatPre = false;
+ m_pShellData->bUsingPowerSaving = true;
+ m_pShellData->bOutputInfo = false;
+ m_pShellData->bNoShellSwapBuffer = false;
+
+ m_pShellData->pszAppName = 0;
+ m_pShellData->pszExitMessage = 0;
+
+ m_pShellData->nSwapInterval = 1;
+ m_pShellData->nInitRepeats = 0;
+
+ m_pShellData->nCaptureFrameStart = -1;
+ m_pShellData->nCaptureFrameStop = -1;
+ m_pShellData->nCaptureFrameScale = 1;
+
+ m_pShellData->nPriority = 2;
+
+ m_pShellData->bForceFrameTime = false;
+ m_pShellData->nFrameTime = 33;
+
+ // Internal Data
+ m_pShellData->bShellPosWasDefault = true;
+ m_pShellData->nShellCurFrameNum = 0;
+#ifdef PVRSHELL_FPS_OUTPUT
+ m_pShellData->bOutputFPS = false;
+#endif
+ m_pShellData->bDiscardFrameColor=false;
+ m_pShellData->bDiscardFrameDepth=true;
+ m_pShellData->bDiscardFrameStencil=true;
+}
+
+/*!***********************************************************************
+ @brief Destructor
+*************************************************************************/
+PVRShell::~PVRShell()
+{
+ delete m_pShellData;
+ m_pShellData = NULL;
+}
+
+// Allow user to set preferences from within InitApplication
+
+/*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+*************************************************************************/
+
+bool PVRShell::PVRShellSet(const prefNameBoolEnum prefName, const bool value)
+{
+ switch(prefName)
+ {
+ case prefFullScreen:
+ m_pShellData->bFullScreen = value;
+ return true;
+
+ case prefPBufferContext:
+ m_pShellData->bNeedPbuffer = value;
+ return true;
+
+ case prefPixmapContext:
+ m_pShellData->bNeedPixmap = value;
+ return true;
+
+ case prefPixmapDisableCopy:
+ m_pShellData->bNeedPixmapDisableCopy = value;
+ return true;
+
+ case prefZbufferContext:
+ m_pShellData->bNeedZbuffer = value;
+ return true;
+
+ case prefLockableBackBuffer:
+ m_pShellData->bLockableBackBuffer = value;
+ return true;
+
+ case prefSoftwareRendering:
+ m_pShellData->bSoftwareRender = value;
+ return true;
+
+ case prefStencilBufferContext:
+ m_pShellData->bNeedStencilBuffer = value;
+ return true;
+
+ case prefAlphaFormatPre:
+ m_pShellData->bNeedAlphaFormatPre = value;
+ return true;
+
+ case prefPowerSaving:
+ m_pShellData->bUsingPowerSaving = value;
+ return true;
+
+ case prefOutputInfo:
+ m_pShellData->bOutputInfo = value;
+ return true;
+
+ case prefNoShellSwapBuffer:
+ m_pShellData->bNoShellSwapBuffer = value;
+ return true;
+
+ case prefForceFrameTime:
+ m_pShellData->bForceFrameTime = value;
+ return true;
+
+#ifdef PVRSHELL_FPS_OUTPUT
+ case prefOutputFPS:
+ m_pShellData->bOutputFPS = value;
+ return true;
+#endif
+
+ case prefDiscardColor:
+ m_pShellData->bDiscardFrameColor = value;
+ return true;
+ case prefDiscardDepth:
+ m_pShellData->bDiscardFrameDepth = value;
+ return true;
+ case prefDiscardStencil:
+ m_pShellData->bDiscardFrameStencil = value;
+ return true;
+ default:
+ return m_pShellInit->OsSet(prefName, value);
+ }
+}
+
+/*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+*************************************************************************/
+
+bool PVRShell::PVRShellGet(const prefNameBoolEnum prefName) const
+{
+ switch(prefName)
+ {
+ case prefFullScreen: return m_pShellData->bFullScreen;
+ case prefIsRotated: return (m_pShellData->nShellDimY > m_pShellData->nShellDimX);
+ case prefPBufferContext: return m_pShellData->bNeedPbuffer;
+ case prefPixmapContext: return m_pShellData->bNeedPixmap;
+ case prefPixmapDisableCopy: return m_pShellData->bNeedPixmapDisableCopy;
+ case prefZbufferContext: return m_pShellData->bNeedZbuffer;
+ case prefLockableBackBuffer: return m_pShellData->bLockableBackBuffer;
+ case prefSoftwareRendering: return m_pShellData->bSoftwareRender;
+ case prefNoShellSwapBuffer: return m_pShellData->bNoShellSwapBuffer;
+ case prefStencilBufferContext: return m_pShellData->bNeedStencilBuffer;
+ case prefAlphaFormatPre: return m_pShellData->bNeedAlphaFormatPre;
+ case prefPowerSaving: return m_pShellData->bUsingPowerSaving;
+ case prefOutputInfo: return m_pShellData->bOutputInfo;
+ case prefForceFrameTime: return m_pShellData->bForceFrameTime;
+#ifdef PVRSHELL_FPS_OUTPUT
+ case prefOutputFPS: return m_pShellData->bOutputFPS;
+#endif
+ case prefDiscardColor: return m_pShellData->bDiscardFrameColor;
+ case prefDiscardDepth: return m_pShellData->bDiscardFrameDepth;
+ case prefDiscardStencil: return m_pShellData->bDiscardFrameStencil;
+ default: return false;
+ }
+}
+
+/*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+*************************************************************************/
+
+bool PVRShell::PVRShellSet(const prefNameFloatEnum prefName, const float value)
+{
+ switch(prefName)
+ {
+ case prefQuitAfterTime:
+ m_pShellData->fDieAfterTime = value;
+ return true;
+
+ default:
+ break;
+ }
+ return false;
+}
+
+/*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+*************************************************************************/
+float PVRShell::PVRShellGet(const prefNameFloatEnum prefName) const
+{
+ switch(prefName)
+ {
+ case prefQuitAfterTime: return m_pShellData->fDieAfterTime;
+ default: return -1;
+ }
+}
+
+/*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+*************************************************************************/
+bool PVRShell::PVRShellSet(const prefNameIntEnum prefName, const int value)
+{
+ switch(prefName)
+ {
+ case prefWidth:
+ if(value > 0)
+ {
+ m_pShellData->nShellDimX = value;
+ return true;
+ }
+ return false;
+
+ case prefHeight:
+ if(value > 0)
+ {
+ m_pShellData->nShellDimY = value;
+ return true;
+ }
+ return false;
+
+ case prefPositionX:
+ m_pShellData->bShellPosWasDefault = false;
+ m_pShellData->nShellPosX = value;
+ return true;
+
+ case prefPositionY:
+ m_pShellData->bShellPosWasDefault = false;
+ m_pShellData->nShellPosY = value;
+ return true;
+
+ case prefQuitAfterFrame:
+ m_pShellData->nDieAfterFrames = value;
+ return true;
+
+ case prefInitRepeats:
+ m_pShellData->nInitRepeats = value;
+ return true;
+
+ case prefAASamples:
+ if(value >= 0)
+ {
+ m_pShellData->nAASamples = value;
+ return true;
+ }
+ return false;
+
+ case prefColorBPP:
+ if(value >= 0)
+ {
+ m_pShellData->nColorBPP = value;
+ return true;
+ }
+ return false;
+
+ case prefDepthBPP:
+ if(value >= 0)
+ {
+ m_pShellData->nDepthBPP = value;
+ return true;
+ }
+ return false;
+
+ case prefRotateKeys:
+ {
+ switch((PVRShellKeyRotate)value)
+ {
+ case PVRShellKeyRotateNone:
+ m_pShellInit->m_eKeyMapUP = PVRShellKeyNameUP;
+ m_pShellInit->m_eKeyMapLEFT = PVRShellKeyNameLEFT;
+ m_pShellInit->m_eKeyMapDOWN = PVRShellKeyNameDOWN;
+ m_pShellInit->m_eKeyMapRIGHT = PVRShellKeyNameRIGHT;
+ break;
+ case PVRShellKeyRotate90:
+ m_pShellInit->m_eKeyMapUP = PVRShellKeyNameLEFT;
+ m_pShellInit->m_eKeyMapLEFT = PVRShellKeyNameDOWN;
+ m_pShellInit->m_eKeyMapDOWN = PVRShellKeyNameRIGHT;
+ m_pShellInit->m_eKeyMapRIGHT = PVRShellKeyNameUP;
+ break;
+ case PVRShellKeyRotate180:
+ m_pShellInit->m_eKeyMapUP = PVRShellKeyNameDOWN;
+ m_pShellInit->m_eKeyMapLEFT = PVRShellKeyNameRIGHT;
+ m_pShellInit->m_eKeyMapDOWN = PVRShellKeyNameUP;
+ m_pShellInit->m_eKeyMapRIGHT = PVRShellKeyNameLEFT;
+ break;
+ case PVRShellKeyRotate270:
+ m_pShellInit->m_eKeyMapUP = PVRShellKeyNameRIGHT;
+ m_pShellInit->m_eKeyMapLEFT = PVRShellKeyNameUP;
+ m_pShellInit->m_eKeyMapDOWN = PVRShellKeyNameLEFT;
+ m_pShellInit->m_eKeyMapRIGHT = PVRShellKeyNameDOWN;
+ break;
+ default:
+ return false;
+ }
+ }
+ return true;
+ case prefCaptureFrameStart:
+ m_pShellData->nCaptureFrameStart = value;
+ return true;
+ case prefCaptureFrameStop:
+ m_pShellData->nCaptureFrameStop = value;
+ return true;
+ case prefCaptureFrameScale:
+ m_pShellData->nCaptureFrameScale = value;
+ return true;
+ case prefFrameTimeValue:
+ m_pShellData->nFrameTime = value;
+ return true;
+ default:
+ {
+ if(m_pShellInit->ApiSet(prefName, value))
+ return true;
+
+ return m_pShellInit->OsSet(prefName, value);
+ }
+ }
+}
+
+/*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+*************************************************************************/
+int PVRShell::PVRShellGet(const prefNameIntEnum prefName) const
+{
+ switch(prefName)
+ {
+ case prefWidth: return m_pShellData->nShellDimX;
+ case prefHeight: return m_pShellData->nShellDimY;
+ case prefPositionX: return m_pShellData->nShellPosX;
+ case prefPositionY: return m_pShellData->nShellPosY;
+ case prefQuitAfterFrame: return m_pShellData->nDieAfterFrames;
+ case prefSwapInterval: return m_pShellData->nSwapInterval;
+ case prefInitRepeats: return m_pShellData->nInitRepeats;
+ case prefAASamples: return m_pShellData->nAASamples;
+ case prefCommandLineOptNum: return m_pShellInit->m_CommandLine.m_nOptLen;
+ case prefColorBPP: return m_pShellData->nColorBPP;
+ case prefDepthBPP: return m_pShellData->nDepthBPP;
+ case prefCaptureFrameStart: return m_pShellData->nCaptureFrameStart;
+ case prefCaptureFrameStop: return m_pShellData->nCaptureFrameStop;
+ case prefCaptureFrameScale: return m_pShellData->nCaptureFrameScale;
+ case prefFrameTimeValue: return m_pShellData->nFrameTime;
+ case prefPriority: return m_pShellData->nPriority;
+ default:
+ {
+ int n;
+
+ if(m_pShellInit->ApiGet(prefName, &n))
+ return n;
+ if(m_pShellInit->OsGet(prefName, &n))
+ return n;
+ return -1;
+ }
+ }
+}
+
+/*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+*************************************************************************/
+bool PVRShell::PVRShellSet(const prefNamePtrEnum prefName, const void * const ptrValue)
+{
+ PVRSHELL_UNREFERENCED_PARAMETER(prefName);
+ PVRSHELL_UNREFERENCED_PARAMETER(ptrValue);
+ return false;
+}
+
+/*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+*************************************************************************/
+void *PVRShell::PVRShellGet(const prefNamePtrEnum prefName) const
+{
+ switch(prefName)
+ {
+ case prefNativeWindowType: return m_pShellInit->OsGetNativeWindowType();
+ case prefPointerLocation:
+ if (m_pShellInit->m_bTouching)
+ return m_pShellInit->m_vec2PointerLocation;
+ break;
+ default:
+ {
+ void *p;
+
+ if(m_pShellInit->ApiGet(prefName, &p))
+ return p;
+ if(m_pShellInit->OsGet(prefName, &p))
+ return p;
+ }
+ }
+ return NULL;
+}
+
+/*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+*************************************************************************/
+bool PVRShell::PVRShellSet(const prefNameConstPtrEnum prefName, const void * const ptrValue)
+{
+ switch(prefName)
+ {
+ case prefAppName:
+ StringCopy(m_pShellData->pszAppName, (char*)ptrValue);
+ return true;
+ case prefExitMessage:
+ StringCopy(m_pShellData->pszExitMessage, (char*)ptrValue);
+ PVRShellOutputDebug("Exit message has been set to: \"%s\".\n", ptrValue);
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+/*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+*************************************************************************/
+const void *PVRShell::PVRShellGet(const prefNameConstPtrEnum prefName) const
+{
+ switch(prefName)
+ {
+ case prefAppName:
+ return m_pShellData->pszAppName;
+ case prefExitMessage:
+ return m_pShellData->pszExitMessage;
+ case prefReadPath:
+ return m_pShellInit->GetReadPath();
+ case prefWritePath:
+ return m_pShellInit->GetWritePath();
+ case prefCommandLine:
+ return m_pShellInit->m_CommandLine.m_psOrig;
+ case prefCommandLineOpts:
+ return m_pShellInit->m_CommandLine.m_pOpt;
+ case prefVersion:
+ return PVRSDK_VERSION;
+ default:
+ return 0;
+ }
+}
+
+/*!***********************************************************************
+ @brief It will be stored as 24-bit per pixel, 8-bit per chanel RGB.
+ The memory should be freed with free() when no longer needed.
+ @param[in] Width size of image to capture (relative to 0,0)
+ @param[in] Height size of image to capture (relative to 0,0)
+ @param[out] pLines receives a pointer to an area of memory containing the screen buffer.
+ @return true for success
+*************************************************************************/
+bool PVRShell::PVRShellScreenCaptureBuffer(const int Width, const int Height, unsigned char **pLines)
+{
+ /* Allocate memory for line */
+ *pLines=(unsigned char *)calloc(Width*Height*3, sizeof(unsigned char));
+ if (!(*pLines)) return false;
+
+ return m_pShellInit->ApiScreenCaptureBuffer(Width, Height, *pLines);
+}
+
+/*!***********************************************************************
+ @brief Writes out the image data to a BMP file with basename fname.
+ @details The file written will be fname suffixed with a number to make the file unique.
+ For example, if fname is "abc", this function will attempt
+ to save to "abc0000.bmp"; if that file already exists, it
+ will try "abc0001.bmp", repeating until a new filename is
+ found. The final filename used is returned in ofname.
+ @param[in] fname base of file to save screen to
+ @param[in] Width size of image to capture (relative to 0,0)
+ @param[in] Height size of image to capture (relative to 0,0)
+ @param[in] pLines image data to write out (24bpp, 8-bit per channel RGB)
+ @param[in] ui32PixelReplicate expand pixels through replication (1 = no scale)
+ @param[out] ofname If non-NULL, receives the filename actually used
+ @return true for success
+*************************************************************************/
+int PVRShell::PVRShellScreenSave(
+ const char * const fname,
+ const int Width,
+ const int Height,
+ const unsigned char * const pLines,
+ const unsigned int ui32PixelReplicate,
+ char * const ofname)
+{
+ char *pszFileName;
+
+ /*
+ Choose a filename
+ */
+ {
+ FILE *file = 0;
+ const char *pszWritePath;
+ int nScreenshotCount;
+
+ pszWritePath = (const char*)PVRShellGet(prefWritePath);
+
+ size_t nFileNameSize = strlen(pszWritePath) + 200;
+ pszFileName = (char*)malloc(nFileNameSize);
+
+ /* Look for the first file name that doesn't already exist */
+ for(nScreenshotCount = 0; nScreenshotCount < 10000; ++nScreenshotCount)
+ {
+ snprintf(pszFileName, nFileNameSize, "%s%s%04d.bmp", pszWritePath, fname, nScreenshotCount);
+
+ file = fopen(pszFileName,"r");
+ if(!file)
+ break;
+ fclose(file);
+ }
+
+ /* If all files already exist, replace the first one */
+ if (nScreenshotCount==10000)
+ {
+ snprintf(pszFileName, nFileNameSize, "%s%s0000.bmp", pszWritePath, fname);
+ PVRShellOutputDebug("PVRShell: *WARNING* : Overwriting %s\n", pszFileName);
+ }
+
+ if(ofname) // requested the output file name
+ {
+ strcpy(ofname, pszFileName);
+ }
+ }
+
+ const int err = PVRShellWriteBMPFile(pszFileName, Width, Height, pLines, ui32PixelReplicate);
+ FREE(pszFileName);
+ if (err)
+ {
+ return 10*err+1;
+ }
+ else
+ {
+ // No problem occurred
+ return 0;
+ }
+}
+
+/*!***********************************************************************
+ @brief Swaps the bytes in pBytes from little to big endian (or vice versa)
+ @param[in] pBytes The bytes to swap
+ @param[in] i32ByteNo The number of bytes to swap
+*************************************************************************/
+inline void PVRShellByteSwap(unsigned char* pBytes, int i32ByteNo)
+{
+ int i = 0, j = i32ByteNo - 1;
+
+ while(i < j)
+ {
+ unsigned char cTmp = pBytes[i];
+ pBytes[i] = pBytes[j];
+ pBytes[j] = cTmp;
+
+ ++i;
+ --j;
+ }
+}
+
+/*!***********************************************************************
+ @brief Writes out the image data to a BMP file with name fname.
+ @param[in] pszFilename file to save screen to
+ @param[in] ui32Width the width of the data
+ @param[in] ui32Height the height of the data
+ @param[in] pImageData image data to write out (24bpp, 8-bit per channel RGB)
+ @return 0 on success
+*************************************************************************/
+int PVRShell::PVRShellWriteBMPFile(
+ const char * const pszFilename,
+ const unsigned int ui32Width,
+ const unsigned int ui32Height,
+ const void * const pImageData,
+ const unsigned int ui32PixelReplicate)
+{
+#define ByteSwap(x) PVRShellByteSwap((unsigned char*) &x, sizeof(x))
+
+ const int i32BMPHeaderSize = 14; /* The size of a BMP header */
+ const int i32BMPInfoSize = 40; /* The size of a BMP info header */
+ int Result = 1;
+ FILE* fpDumpfile = 0;
+
+ fpDumpfile = fopen(pszFilename, "wb");
+
+ if (fpDumpfile != 0)
+ {
+ const short int word = 0x0001;
+ const char * const byte = (char*) &word;
+ bool bLittleEndian = byte[0] ? true : false;
+
+ unsigned int i32OutBytesPerLine = ui32Width * 3 * ui32PixelReplicate;
+ unsigned int i32OutAlign = 0;
+
+ // round up to a dword boundary
+ if(i32OutBytesPerLine & 3)
+ {
+ i32OutBytesPerLine |= 3;
+ ++i32OutBytesPerLine;
+ i32OutAlign = i32OutBytesPerLine - ui32Width * 3 * ui32PixelReplicate;
+ }
+
+ unsigned char *pData = (unsigned char*) pImageData;
+
+ {
+ int ui32RealSize = i32OutBytesPerLine * ui32Height * ui32PixelReplicate;
+
+ // BMP Header
+ unsigned short bfType = 0x4D42;
+ unsigned int bfSize = i32BMPHeaderSize + i32BMPInfoSize + ui32RealSize;
+ unsigned short bfReserved1 = 0;
+ unsigned short bfReserved2 = 0;
+ unsigned int bfOffBits = i32BMPHeaderSize + i32BMPInfoSize;
+
+ // BMP Info Header
+ unsigned int biSize = i32BMPInfoSize;
+ unsigned int biWidth = ui32Width * ui32PixelReplicate;
+ unsigned int biHeight = ui32Height * ui32PixelReplicate;
+ unsigned short biPlanes = 1;
+ unsigned short biBitCount = 24;
+ unsigned int biCompression = 0L;
+ unsigned int biSizeImage = ui32RealSize;
+ unsigned int biXPelsPerMeter = 0;
+ unsigned int biYPelsPerMeter = 0;
+ unsigned int biClrUsed = 0;
+ unsigned int biClrImportant = 0;
+
+ if(!bLittleEndian)
+ {
+ for(unsigned int i = 0; i < ui32Width * ui32Height; ++i)
+ PVRShellByteSwap(pData + (3 * i), 3);
+
+ ByteSwap(bfType);
+ ByteSwap(bfSize);
+ ByteSwap(bfOffBits);
+ ByteSwap(biSize);
+ ByteSwap(biWidth);
+ ByteSwap(biHeight);
+ ByteSwap(biPlanes);
+ ByteSwap(biBitCount);
+ ByteSwap(biCompression);
+ ByteSwap(biSizeImage);
+ }
+
+ // Write Header.
+ fwrite(&bfType , 1, sizeof(bfType) , fpDumpfile);
+ fwrite(&bfSize , 1, sizeof(bfSize) , fpDumpfile);
+ fwrite(&bfReserved1 , 1, sizeof(bfReserved1), fpDumpfile);
+ fwrite(&bfReserved2 , 1, sizeof(bfReserved2), fpDumpfile);
+ fwrite(&bfOffBits , 1, sizeof(bfOffBits) , fpDumpfile);
+
+ // Write info header.
+ fwrite(&biSize , 1, sizeof(biSize) , fpDumpfile);
+ fwrite(&biWidth , 1, sizeof(biWidth) , fpDumpfile);
+ fwrite(&biHeight , 1, sizeof(biHeight) , fpDumpfile);
+ fwrite(&biPlanes , 1, sizeof(biPlanes) , fpDumpfile);
+ fwrite(&biBitCount , 1, sizeof(biBitCount) , fpDumpfile);
+ fwrite(&biCompression , 1, sizeof(biCompression) , fpDumpfile);
+ fwrite(&biSizeImage , 1, sizeof(biSizeImage) , fpDumpfile);
+ fwrite(&biXPelsPerMeter , 1, sizeof(biXPelsPerMeter), fpDumpfile);
+ fwrite(&biYPelsPerMeter , 1, sizeof(biYPelsPerMeter), fpDumpfile);
+ fwrite(&biClrUsed , 1, sizeof(biClrUsed) , fpDumpfile);
+ fwrite(&biClrImportant , 1, sizeof(biClrImportant) , fpDumpfile);
+ }
+
+ // Write image.
+ for(unsigned int nY = 0; nY < ui32Height; ++nY)
+ {
+ const unsigned char * pRow = &pData[3 * ui32Width * nY];
+ for(unsigned int nRepY = 0; nRepY < ui32PixelReplicate; ++nRepY)
+ {
+ for(unsigned int nX = 0; nX < ui32Width; ++nX)
+ {
+ const unsigned char * pPixel = &pRow[3 * nX];
+ for(unsigned int nRepX = 0; nRepX < ui32PixelReplicate; ++nRepX)
+ {
+ fwrite(pPixel, 1, 3, fpDumpfile);
+ }
+ }
+
+ fwrite("\0\0\0\0", i32OutAlign, 1, fpDumpfile);
+ }
+ }
+
+ // Last but not least close the file.
+ fclose(fpDumpfile);
+
+ Result = 0;
+ }
+ else
+ {
+ PVRShellOutputDebug("PVRShell: Failed to open \"%s\" for writing screen dump.\n", pszFilename);
+ }
+
+ return Result;
+}
+
+/*!***********************************************************************
+ @brief The number itself should be considered meaningless; an
+ application should use this function to determine how much
+ time has passed between two points (e.g. between each
+ frame).
+ @return A value which increments once per millisecond.
+*************************************************************************/
+unsigned long PVRShell::PVRShellGetTime()
+{
+ if(m_pShellData->bForceFrameTime)
+ {
+ // Return a "time" value based on the current frame number
+ return (unsigned long) m_pShellData->nShellCurFrameNum * m_pShellData->nFrameTime;
+ }
+ else
+ {
+ // Read timer from a platform dependant function
+ return m_pShellInit->OsGetTime();
+ }
+}
+
+/*!***********************************************************************
+ @brief Check if a key was pressed. The keys on various devices
+ are mapped to the PVRShell-supported keys (listed in @a PVRShellKeyName) in
+ a platform-dependent manner, since most platforms have different input
+ devices. Check the <a href="modules.html">Modules page</a> for your OS
+ for details on how the enum values map to your device's key code input.
+ @param[in] key Code of the key to test
+ @return true if key was pressed
+*************************************************************************/
+bool PVRShell::PVRShellIsKeyPressed(const PVRShellKeyName key)
+{
+ if(!m_pShellInit)
+ return false;
+
+ return m_pShellInit->DoIsKeyPressed(key);
+}
+
+// class PVRShellCommandLine
+
+/*!***********************************************************************
+ @brief Constructor
+*************************************************************************/
+PVRShellCommandLine::PVRShellCommandLine()
+{
+ memset(this, 0, sizeof(*this));
+}
+
+/*!***********************************************************************
+@brief Destructor
+*************************************************************************/
+PVRShellCommandLine::~PVRShellCommandLine()
+{
+ delete [] m_psOrig;
+ delete [] m_psSplit;
+ FREE(m_pOpt);
+}
+
+/*!***********************************************************************
+ @brief Set command-line options to pStr
+ @param[in] pStr Input string
+*************************************************************************/
+void PVRShellCommandLine::Set(const char *pStr)
+{
+ delete [] m_psOrig;
+ m_psOrig = 0;
+
+ if(pStr)
+ {
+ size_t len = strlen(pStr)+1;
+ m_psOrig = new char[len];
+ strcpy(m_psOrig, pStr);
+ }
+}
+
+/*!***********************************************************************
+ @brief Prepend command-line options to m_psOrig
+ @param[in] pStr Input string
+*************************************************************************/
+void PVRShellCommandLine::Prefix(const char *pStr)
+{
+ if(!m_psOrig)
+ Set(pStr);
+ else if(!pStr)
+ return;
+ else
+ {
+ char *pstmp = m_psOrig;
+ size_t lenA = strlen(pStr);
+ size_t TotalLen = lenA + 1 + strlen(m_psOrig);
+
+ m_psOrig = new char[TotalLen + 1];
+
+ strcpy(m_psOrig, pStr);
+ m_psOrig[lenA] = ' ';
+ strcpy(m_psOrig + lenA + 1, pstmp);
+ m_psOrig[TotalLen] = '\0';
+
+ delete[] pstmp;
+ }
+}
+
+/*!***********************************************************************
+ @brief Prepend command-line options to m_psOrig from a file
+ @param[in] pFileName Input string
+*************************************************************************/
+bool PVRShellCommandLine::PrefixFromFile(const char *pFileName)
+{
+ char* nl;
+ FILE *pFile = fopen(pFileName, "rb");
+
+ if(pFile)
+ {
+ // Get the file size
+ fseek(pFile, 0, SEEK_END);
+ long m_Size = ftell(pFile) + 2;
+ fseek(pFile, 0, SEEK_SET);
+
+ char *pFullFile = new char[m_Size];
+
+ if(pFullFile)
+ {
+ size_t offset = 0;
+ while(fgets(pFullFile + offset, (int) (m_Size - offset), pFile))
+ {
+ offset = strlen(pFullFile);
+
+ // Replace new lines with spaces
+ nl = strrchr(pFullFile, '\r');
+ if(nl) *nl = ' ';
+
+ nl = strrchr(pFullFile, '\n');
+ if(nl) *nl = ' ';
+ }
+
+ pFullFile[offset] = '\0';
+ Prefix(pFullFile);
+
+ delete[] pFullFile;
+ fclose(pFile);
+ return true;
+ }
+
+ fclose(pFile);
+ }
+
+ return false;
+}
+
+/*!***********************************************************************
+ @brief Parse m_psOrig for command-line options and store them in m_pOpt
+*************************************************************************/
+void PVRShellCommandLine::Parse()
+{
+ size_t len;
+ int nIn, nOut;
+ bool bInQuotes;
+ SCmdLineOpt opt;
+
+ if(!m_psOrig)
+ return;
+
+ // Delete/free up any options we may have parsed recently
+ delete [] m_psSplit;
+ FREE(m_pOpt);
+
+ // Take a copy to be edited
+ len = strlen(m_psOrig) + 1;
+ m_psSplit = new char[len];
+
+ // Break the command line into options
+ bInQuotes = false;
+ opt.pArg = NULL;
+ opt.pVal = NULL;
+ nIn = -1;
+ nOut = 0;
+
+ do
+ {
+ ++nIn;
+ if(m_psOrig[nIn] == '"')
+ {
+ bInQuotes = !bInQuotes;
+ }
+ else
+ {
+ if(bInQuotes && m_psOrig[nIn] != 0)
+ {
+ if(!opt.pArg)
+ opt.pArg = &m_psSplit[nOut];
+
+ m_psSplit[nOut++] = m_psOrig[nIn];
+ }
+ else
+ {
+ switch(m_psOrig[nIn])
+ {
+ case '=':
+ m_psSplit[nOut++] = 0;
+ opt.pVal = &m_psSplit[nOut];
+ break;
+
+ case ' ':
+ case '\t':
+ case '\0':
+ m_psSplit[nOut++] = 0;
+ if(opt.pArg || opt.pVal)
+ {
+ // Increase list length if necessary
+ if(m_nOptLen == m_nOptMax)
+ m_nOptMax = m_nOptMax * 2 + 1;
+ SCmdLineOpt* pTmp = (SCmdLineOpt*)realloc(m_pOpt, m_nOptMax * sizeof(*m_pOpt));
+ if(!pTmp)
+ {
+ FREE(m_pOpt);
+ return;
+ }
+
+ m_pOpt = pTmp;
+
+ // Add option to list
+ m_pOpt[m_nOptLen++] = opt;
+ opt.pArg = NULL;
+ opt.pVal = NULL;
+ }
+ break;
+
+ default:
+ if(!opt.pArg)
+ opt.pArg = &m_psSplit[nOut];
+
+ m_psSplit[nOut++] = m_psOrig[nIn];
+ break;
+ }
+ }
+ }
+ } while(m_psOrig[nIn]);
+}
+
+/*!***********************************************************************
+ @brief Apply the command-line options to shell
+ @param[in] shell
+*************************************************************************/
+void PVRShellCommandLine::Apply(PVRShell &shell)
+{
+ int i;
+ const char *arg, *val;
+
+ for(i = 0; i < m_nOptLen; ++i)
+ {
+ arg = m_pOpt[i].pArg;
+ val = m_pOpt[i].pVal;
+
+ if(!arg)
+ continue;
+
+ if(val)
+ {
+ if(_stricmp(arg, "-width") == 0)
+ {
+ shell.PVRShellSet(prefWidth, atoi(val));
+ }
+ else if(_stricmp(arg, "-height") == 0)
+ {
+ shell.PVRShellSet(prefHeight, atoi(val));
+ }
+ else if(_stricmp(arg, "-aasamples") == 0)
+ {
+ shell.PVRShellSet(prefAASamples, atoi(val));
+ }
+ else if(_stricmp(arg, "-fullscreen") == 0)
+ {
+ shell.PVRShellSet(prefFullScreen, (atoi(val) != 0));
+ }
+ else if(_stricmp(arg, "-sw") == 0)
+ {
+ shell.PVRShellSet(prefSoftwareRendering, (atoi(val) != 0));
+ }
+ else if(_stricmp(arg, "-quitafterframe") == 0 || _stricmp(arg, "-qaf") == 0)
+ {
+ shell.PVRShellSet(prefQuitAfterFrame, atoi(val));
+ }
+ else if(_stricmp(arg, "-quitaftertime") == 0 || _stricmp(arg, "-qat") == 0)
+ {
+ shell.PVRShellSet(prefQuitAfterTime, (float)atof(val));
+ }
+ else if(_stricmp(arg, "-posx") == 0)
+ {
+ shell.PVRShellSet(prefPositionX, atoi(val));
+ }
+ else if(_stricmp(arg, "-posy") == 0)
+ {
+ shell.PVRShellSet(prefPositionY, atoi(val));
+ }
+ else if(_stricmp(arg, "-vsync") == 0)
+ {
+ shell.PVRShellSet(prefSwapInterval, atoi(val));
+ }
+ else if(_stricmp(arg, "-powersaving") == 0 || _stricmp(arg, "-ps") == 0)
+ {
+ shell.PVRShellSet(prefPowerSaving, (atoi(val) != 0));
+ }
+ else if(_stricmp(arg, "-colourbpp") == 0 || _stricmp(arg, "-colorbpp") == 0 ||_stricmp(arg, "-cbpp") == 0)
+ {
+ shell.PVRShellSet(prefColorBPP, atoi(val));
+ }
+ else if(_stricmp(arg, "-depthbpp") == 0 || _stricmp(arg, "-dbpp") == 0)
+ {
+ shell.PVRShellSet(prefDepthBPP, atoi(val));
+ }
+ else if(_stricmp(arg, "-rotatekeys") == 0)
+ {
+ shell.PVRShellSet(prefRotateKeys, atoi(val));
+ }
+ else if(_stricmp(arg, "-c") == 0)
+ {
+ const char* pDash = strchr(val, '-');
+
+ shell.PVRShellSet(prefCaptureFrameStart, atoi(val));
+
+ if(!pDash)
+ shell.PVRShellSet(prefCaptureFrameStop, atoi(val));
+ else
+ shell.PVRShellSet(prefCaptureFrameStop, atoi(pDash + 1));
+ }
+ else if(_stricmp(arg, "-screenshotscale") == 0)
+ {
+ shell.PVRShellSet(prefCaptureFrameScale, atoi(val));
+ }
+ else if(_stricmp(arg, "-priority") == 0)
+ {
+ shell.PVRShellSet(prefPriority, atoi(val));
+ }
+ else if(_stricmp(arg, "-config") == 0)
+ {
+ shell.PVRShellSet(prefRequestedConfig, atoi(val));
+ }
+ else if(_stricmp(arg, "-display") == 0)
+ {
+ shell.PVRShellSet(prefNativeDisplay, atoi(val));
+ }
+ else if(_stricmp(arg, "-forceframetime") == 0 || _stricmp(arg, "-fft") == 0)
+ {
+ shell.PVRShellSet(prefForceFrameTime, true);
+ shell.PVRShellSet(prefFrameTimeValue, atoi(val));
+ }
+ else if(_stricmp(arg, "-discardframeall") == 0)
+ {
+ shell.PVRShellSet(prefDiscardColor, (atoi(val) != 0));
+ shell.PVRShellSet(prefDiscardDepth, (atoi(val) != 0));
+ shell.PVRShellSet(prefDiscardStencil, (atoi(val) != 0));
+ }
+ else if(_stricmp(arg, "-discardframecolor") == 0 || _stricmp(arg, "-discardframecolour") == 0)
+ {
+ shell.PVRShellSet(prefDiscardColor, (atoi(val) != 0));
+ }
+ else if(_stricmp(arg, "-discardframedepth") == 0)
+ {
+ shell.PVRShellSet(prefDiscardDepth, (atoi(val) != 0));
+ }
+ else if(_stricmp(arg, "-discardframestencil") == 0)
+ {
+ shell.PVRShellSet(prefDiscardStencil, (atoi(val) != 0));
+ }
+ }
+ else
+ {
+ if(_stricmp(arg, "-version") == 0)
+ {
+ shell.PVRShellOutputDebug("Version: \"%s\"\n", shell.PVRShellGet(prefVersion));
+ }
+#ifdef PVRSHELL_FPS_OUTPUT
+ else if(_stricmp(arg, "-fps") == 0)
+ {
+ shell.PVRShellSet(prefOutputFPS, true);
+ }
+#endif
+ else if(_stricmp(arg, "-info") == 0)
+ {
+ shell.PVRShellSet(prefOutputInfo, true);
+ }
+ else if(_stricmp(arg, "-forceframetime") == 0 || _stricmp(arg, "-fft") == 0)
+ {
+ shell.PVRShellSet(prefForceFrameTime, true);
+ }
+ }
+ }
+}
+
+// @Class PVRShellInit
+
+/*!***********************************************************************
+ @brief Constructor
+*************************************************************************/
+PVRShellInit::PVRShellInit()
+{
+ memset(this, 0, sizeof(*this));
+}
+
+/*!***********************************************************************
+ @brief Destructor
+*************************************************************************/
+PVRShellInit::~PVRShellInit()
+{
+ Deinit();
+
+ delete [] m_pReadPath;
+ m_pReadPath = NULL;
+
+ delete [] m_pWritePath;
+ m_pWritePath = NULL;
+}
+
+/*!***********************************************************************
+ @brief PVRShell deinitialisation.
+ @param[in] Shell
+*************************************************************************/
+void PVRShellInit::Deinit()
+{
+ if(m_pShell)
+ {
+ // Is the App currently running?
+ if(m_eState > ePVRShellInitApp && m_eState < ePVRShellExit)
+ {
+ // If so force it to go through the exit procedure
+ if(m_eState < ePVRShellReleaseView)
+ m_eState = ePVRShellReleaseView;
+
+ // Class the App as done
+ gShellDone = true;
+
+ // Run through the exiting states
+ while(Run()){};
+ }
+
+ delete m_pShell;
+ m_pShell = 0;
+ }
+}
+
+/*!***********************************************************************
+ @brief PVRShell Initialisation.
+ @Function Init
+ @param[in] Shell
+ @return True on success and false on failure
+*************************************************************************/
+bool PVRShellInit::Init()
+{
+ Deinit();
+
+ m_pShell = NewDemo();
+
+ if(!m_pShell)
+ return false;
+
+ m_pShell->m_pShellInit = this;
+
+ // set default direction key mappings
+ m_eKeyMapDOWN = PVRShellKeyNameDOWN;
+ m_eKeyMapLEFT = PVRShellKeyNameLEFT;
+ m_eKeyMapUP = PVRShellKeyNameUP;
+ m_eKeyMapRIGHT = PVRShellKeyNameRIGHT;
+ nLastKeyPressed = PVRShellKeyNameNull;
+
+ OsInit();
+
+ gShellDone = false;
+ m_eState = ePVRShellInitApp;
+ return true;
+}
+
+/*!***********************************************************************
+ @brief Receives the command-line from the application.
+ @param[in] str A string containing the command-line
+*************************************************************************/
+void PVRShellInit::CommandLine(const char *str)
+{
+ m_CommandLine.Set(str);
+}
+
+/*!***********************************************************************
+ @brief Receives the command-line from the application.
+ @param[in] argc Number of strings in argv
+ @param[in] argv An array of strings
+*************************************************************************/
+void PVRShellInit::CommandLine(int argc, char **argv)
+{
+ size_t tot, len;
+ char *buf;
+ int i;
+
+ tot = 0;
+ for(i = 0; i < argc; ++i)
+ tot += strlen(argv[i]);
+
+ if(!tot)
+ {
+ CommandLine((char*) "");
+ return;
+ }
+
+ // Add room for spaces and the \0
+ tot += argc;
+
+ buf = new char[tot];
+ tot = 0;
+ for(i = 0; i < argc; ++i)
+ {
+ len = strlen(argv[i]);
+ strncpy(&buf[tot], argv[i], len);
+ tot += len;
+ buf[tot++] = ' ';
+ }
+ buf[tot-1] = 0;
+
+ CommandLine(buf);
+
+ delete [] buf;
+}
+
+/*!***********************************************************************
+ @brief Return 'true' if the specific key has been pressed.
+ @param[in] key The key we're querying for
+*************************************************************************/
+bool PVRShellInit::DoIsKeyPressed(const PVRShellKeyName key)
+{
+ if(key == nLastKeyPressed)
+ {
+ nLastKeyPressed = PVRShellKeyNameNull;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+/*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell that a key has been pressed.
+ @param[in] nKey The key that has been pressed
+*************************************************************************/
+void PVRShellInit::KeyPressed(PVRShellKeyName nKey)
+{
+ nLastKeyPressed = nKey;
+}
+
+/*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell that a touch has began at a location.
+ @param[in] vec2Location The position of a click/touch on the screen when it first touches
+*************************************************************************/
+void PVRShellInit::TouchBegan(const float vec2Location[2])
+{
+ m_bTouching = true;
+ m_vec2PointerLocationStart[0] = m_vec2PointerLocation[0] = vec2Location[0];
+ m_vec2PointerLocationStart[1] = m_vec2PointerLocation[1] = vec2Location[1];
+}
+
+/*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell that a touch has began at a location.
+ @param[in] vec2Location The position of the pointer/touch pressed on the screen
+*************************************************************************/
+void PVRShellInit::TouchMoved(const float vec2Location[2])
+{
+ if(m_bTouching)
+ {
+ m_vec2PointerLocation[0] = vec2Location[0];
+ m_vec2PointerLocation[1] = vec2Location[1];
+ }
+}
+
+/*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell that the current touch has ended at a location.
+ @param[in] vec2Location The position of the pointer/touch on the screen when it is released
+*************************************************************************/
+void PVRShellInit::TouchEnded(const float vec2Location[2])
+{
+ if(m_bTouching)
+ {
+ m_bTouching = false;
+ m_vec2PointerLocationEnd[0] = m_vec2PointerLocation[0] = vec2Location[0];
+ m_vec2PointerLocationEnd[1] = m_vec2PointerLocation[1] = vec2Location[1];
+
+#if !defined(DISABLE_SWIPE_MAPPING)
+ float fX = m_vec2PointerLocationEnd[0] - m_vec2PointerLocationStart[0];
+ float fY = m_vec2PointerLocationEnd[1] - m_vec2PointerLocationStart[1];
+ float fTmp = fX * fX + fY * fY;
+
+ if(fTmp > 0.005f)
+ {
+ fTmp = 1.0f / sqrt(fTmp);
+ fY *= fTmp;
+ float fAngle = acos(fY);
+
+ const float pi = 3.1415f;
+ const float pi_half = pi * 0.5f;
+ const float error = 0.25f;
+
+ if(fAngle < error)
+ KeyPressed(m_eKeyMapDOWN);
+ else if(fAngle > (pi - error))
+ KeyPressed(m_eKeyMapUP);
+ else if(fAngle > (pi_half - error) && fAngle < (pi_half + error))
+ KeyPressed((fX < 0) ? m_eKeyMapLEFT : m_eKeyMapRIGHT);
+ }
+ else if(fTmp < 0.09f)
+ {
+ if (m_vec2PointerLocationEnd[0] <= 0.3f) // Left half of the screen
+ KeyPressed(PVRShellKeyNameACTION1);
+ else if (m_vec2PointerLocationEnd[0] >= 0.7f) // Right half of the screen
+ KeyPressed(PVRShellKeyNameACTION2);
+ }
+#endif
+ }
+}
+
+/*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell where to read external files from
+ @return A path the application is capable of reading from
+*************************************************************************/
+const char* PVRShellInit::GetReadPath() const
+{
+ return m_pReadPath;
+}
+
+/*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell where to write to
+ @return A path the applications is capable of writing to
+*************************************************************************/
+const char* PVRShellInit::GetWritePath() const
+{
+ return m_pWritePath;
+}
+
+/*!****************************************************************************
+ @brief Sets the default app name (to be displayed by the OS)
+ @param[in] str The application name
+*******************************************************************************/
+void PVRShellInit::SetAppName(const char * const str)
+{
+ const char *pName = strrchr(str, PVRSHELL_DIR_SYM);
+
+ if(pName)
+ {
+ ++pName;
+ }
+ else
+ {
+ pName = str;
+ }
+ m_pShell->PVRShellSet(prefAppName, pName);
+}
+
+/*!***********************************************************************
+ @brief Set the path to where the application expects to read from.
+ @param[in] str The read path
+*************************************************************************/
+void PVRShellInit::SetReadPath(const char * const str)
+{
+ m_pReadPath = new char[strlen(str)+1];
+
+ if(m_pReadPath)
+ {
+ strcpy(m_pReadPath, str);
+ char* lastSlash = strrchr(m_pReadPath, PVRSHELL_DIR_SYM);
+
+ if(lastSlash)
+ lastSlash[1] = 0;
+ }
+}
+
+/*!***********************************************************************
+ @brief Set the path to where the application expects to write to.
+ @param[in] str The write path
+*************************************************************************/
+void PVRShellInit::SetWritePath(const char * const str)
+{
+ m_pWritePath = new char[strlen(str)+1];
+
+ if(m_pWritePath)
+ {
+ strcpy(m_pWritePath, str);
+ char* lastSlash = strrchr(m_pWritePath, PVRSHELL_DIR_SYM);
+
+ if(lastSlash)
+ lastSlash[1] = 0;
+ }
+}
+
+#ifdef PVRSHELL_FPS_OUTPUT
+/*****************************************************************************
+ @fn FpsUpdate
+ @brief Calculates a value for frames-per-second (FPS).
+ @details This is only compiled in to the application if PVRSHELL_FPS_OUTPUT is defined.
+*****************************************************************************/
+void PVRShellInit::FpsUpdate()
+{
+ unsigned int ui32TimeDelta, ui32Time;
+
+ ui32Time = m_pShell->PVRShellGetTime();
+ ++m_i32FpsFrameCnt;
+ ui32TimeDelta = ui32Time - m_i32FpsTimePrev;
+
+ if(ui32TimeDelta >= 1000)
+ {
+ float fFPS = 1000.0f * (float) m_i32FpsFrameCnt / (float) ui32TimeDelta;
+
+ m_pShell->PVRShellOutputDebug("PVRShell: frame %d, FPS %.1f.\n",
+ m_pShell->m_pShellData->nShellCurFrameNum, fFPS);
+
+ m_i32FpsFrameCnt = 0;
+ m_i32FpsTimePrev = ui32Time;
+ }
+}
+#endif
+
+/*****************************************************************************
+ @brief Main message loop / render loop
+ @return false when the app should quit
+*****************************************************************************/
+bool PVRShellInit::Run()
+{
+ static unsigned long StartTime = 0;
+
+ switch(m_eState)
+ {
+ case ePVRShellInitApp:
+ {
+ // Make sure the shell isn't done
+ gShellDone = false;
+
+ // Prepend command-line options from PVRShellCL.txt
+ const char * const pCL = "PVRShellCL.txt";
+ const char *pPath = (const char*) m_pShell->PVRShellGet(prefReadPath);
+ size_t nSize = strlen(pPath) + strlen(pCL) + 1;
+ char *pString = new char[nSize];
+
+ if(pString)
+ {
+ snprintf(pString, nSize, "%s%s", pPath, pCL);
+
+ if(!m_CommandLine.PrefixFromFile(pString))
+ {
+ delete[] pString;
+ pPath = (const char*) m_pShell->PVRShellGet(prefWritePath);
+ nSize = strlen(pPath) + strlen(pCL) + 1;
+ pString = new char[nSize];
+
+ snprintf(pString, nSize, "%s%s", pPath, pCL);
+
+ if(m_CommandLine.PrefixFromFile(pString))
+ m_pShell->PVRShellOutputDebug("Loaded command-line options from %s.\n", pString);
+ }
+ else
+ m_pShell->PVRShellOutputDebug("Loaded command-line options from %s.\n", pString);
+
+ delete[] pString;
+ }
+
+ // Parse the command-line
+ m_CommandLine.Parse();
+
+#if defined(_DEBUG)
+ m_pShell->PVRShellOutputDebug("PVRShell command line: %d/%d\n", m_CommandLine.m_nOptLen, m_CommandLine.m_nOptMax);
+ for(int i = 0; i < m_CommandLine.m_nOptLen; ++i)
+ {
+ m_pShell->PVRShellOutputDebug("CL %d: \"%s\"\t= \"%s\".\n", i,
+ m_CommandLine.m_pOpt[i].pArg ? m_CommandLine.m_pOpt[i].pArg : "",
+ m_CommandLine.m_pOpt[i].pVal ? m_CommandLine.m_pOpt[i].pVal : "");
+ }
+#endif
+ // Call InitApplication
+ if(!m_pShell->InitApplication())
+ {
+ m_eState = ePVRShellExit;
+ return true;
+ }
+
+ m_eState = ePVRShellInitInstance;
+ return true;
+ }
+ case ePVRShellInitInstance:
+ {
+ m_CommandLine.Apply(*m_pShell);
+
+ // Output non-api specific data if required
+ OutputInfo();
+
+ // Perform OS initialisation
+ if(!OsInitOS())
+ {
+ m_pShell->PVRShellOutputDebug("InitOS failed!\n");
+ m_eState = ePVRShellQuitApp;
+ return true;
+ }
+
+ // Initialize the 3D API
+ if(!OsDoInitAPI())
+ {
+ m_pShell->PVRShellOutputDebug("InitAPI failed!\n");
+ m_eState = ePVRShellReleaseOS;
+ gShellDone = true;
+ return true;
+ }
+
+ // Output api specific data if required
+ OutputAPIInfo();
+
+ // Initialise the app
+ if(!m_pShell->InitView())
+ {
+ m_pShell->PVRShellOutputDebug("InitView failed!\n");
+ m_eState = ePVRShellReleaseAPI;
+ gShellDone = true;
+ return true;
+ }
+
+ if(StartTime==0)
+ {
+ StartTime = OsGetTime();
+ }
+
+ m_eState = ePVRShellRender;
+ return true;
+ }
+ case ePVRShellRender:
+ {
+ // Main message loop:
+ if(!m_pShell->RenderScene())
+ break;
+
+ ApiRenderComplete();
+ OsRenderComplete();
+
+#ifdef PVRSHELL_FPS_OUTPUT
+ if(m_pShell->m_pShellData->bOutputFPS)
+ FpsUpdate();
+#endif
+ int nCurrentFrame = m_pShell->m_pShellData->nShellCurFrameNum;
+
+ if(DoIsKeyPressed(PVRShellKeyNameScreenshot) || (nCurrentFrame >= m_pShell->m_pShellData->nCaptureFrameStart && nCurrentFrame <= m_pShell->m_pShellData->nCaptureFrameStop))
+ {
+ unsigned char *pBuf;
+ const int nWidth = m_pShell->PVRShellGet(prefWidth);
+ const int nHeight = m_pShell->PVRShellGet(prefHeight);
+ if(m_pShell->PVRShellScreenCaptureBuffer(nWidth, nHeight, &pBuf))
+ {
+ if(m_pShell->PVRShellScreenSave(PVRSHELL_SCREENSHOT_NAME, nWidth, nHeight, pBuf, m_pShell->m_pShellData->nCaptureFrameScale) != 0)
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "Screen-shot save failed.\n");
+ }
+ }
+ else
+ {
+ m_pShell->PVRShellSet(prefExitMessage, "Screen capture failed.\n");
+ }
+ FREE(pBuf);
+ }
+
+ if(DoIsKeyPressed(PVRShellKeyNameQUIT))
+ gShellDone = true;
+
+ if(gShellDone)
+ break;
+
+ /* Quit if maximum number of allowed frames is reached */
+ if((m_pShell->m_pShellData->nDieAfterFrames>=0) && (nCurrentFrame >= m_pShell->m_pShellData->nDieAfterFrames))
+ break;
+
+ /* Quit if maximum time is reached */
+ if((m_pShell->m_pShellData->fDieAfterTime>=0.0f) && (((OsGetTime()-StartTime)*0.001f) >= m_pShell->m_pShellData->fDieAfterTime))
+ break;
+
+ m_pShell->m_pShellData->nShellCurFrameNum++;
+ return true;
+ }
+
+ case ePVRShellReleaseView:
+ m_pShell->ReleaseView();
+
+ case ePVRShellReleaseAPI:
+ OsDoReleaseAPI();
+
+ case ePVRShellReleaseOS:
+ OsReleaseOS();
+
+ if(!gShellDone && m_pShell->m_pShellData->nInitRepeats)
+ {
+ --m_pShell->m_pShellData->nInitRepeats;
+ m_eState = ePVRShellInitInstance;
+ return true;
+ }
+
+ m_eState = ePVRShellQuitApp;
+ return true;
+
+ case ePVRShellQuitApp:
+ // Final app tidy-up
+ m_pShell->QuitApplication();
+ m_eState = ePVRShellExit;
+
+ case ePVRShellExit:
+ OsExit();
+ StringCopy(m_pShell->m_pShellData->pszAppName, 0);
+ StringCopy(m_pShell->m_pShellData->pszExitMessage, 0);
+ return false;
+ }
+
+ m_eState = (EPVRShellState)(m_eState + 1);
+ return true;
+}
+
+/*!***********************************************************************
+@brief When prefOutputInfo is set to true this function outputs
+ various pieces of non-API dependent information via
+ PVRShellOutputDebug.
+*************************************************************************/
+void PVRShellInit::OutputInfo()
+{
+ if(m_pShell->PVRShellGet(prefOutputInfo))
+ {
+ m_pShell->PVRShellOutputDebug("\n");
+ m_pShell->PVRShellOutputDebug("App name: %s\n" , m_pShell->PVRShellGet(prefAppName));
+ m_pShell->PVRShellOutputDebug("SDK version: %s\n" , m_pShell->PVRShellGet(prefVersion));
+ m_pShell->PVRShellOutputDebug("\n");
+ m_pShell->PVRShellOutputDebug("Read path: %s\n" , m_pShell->PVRShellGet(prefReadPath));
+ m_pShell->PVRShellOutputDebug("Write path: %s\n" , m_pShell->PVRShellGet(prefWritePath));
+ m_pShell->PVRShellOutputDebug("\n");
+ m_pShell->PVRShellOutputDebug("Command-line: %s\n" , m_pShell->PVRShellGet(prefCommandLine));
+ m_pShell->PVRShellOutputDebug("\n");
+ m_pShell->PVRShellOutputDebug("Power saving: %s\n" , m_pShell->PVRShellGet(prefPowerSaving) ? "On" : "Off");
+ m_pShell->PVRShellOutputDebug("AA Samples requested: %i\n", m_pShell->PVRShellGet(prefAASamples));
+ m_pShell->PVRShellOutputDebug("Fullscreen: %s\n", m_pShell->PVRShellGet(prefFullScreen) ? "Yes" : "No");
+ m_pShell->PVRShellOutputDebug("PBuffer requested: %s\n", m_pShell->PVRShellGet(prefPBufferContext) ? "Yes" : "No");
+ m_pShell->PVRShellOutputDebug("ZBuffer requested: %s\n", m_pShell->PVRShellGet(prefZbufferContext) ? "Yes" : "No");
+ m_pShell->PVRShellOutputDebug("Stencil buffer requested: %s\n", m_pShell->PVRShellGet(prefStencilBufferContext) ? "Yes" : "No");
+
+ if(m_pShell->PVRShellGet(prefColorBPP) > 0)
+ m_pShell->PVRShellOutputDebug("Colour buffer size requested: %i\n", m_pShell->PVRShellGet(prefColorBPP));
+ if(m_pShell->PVRShellGet(prefDepthBPP) > 0)
+ m_pShell->PVRShellOutputDebug("Depth buffer size requested: %i\n", m_pShell->PVRShellGet(prefDepthBPP));
+
+ m_pShell->PVRShellOutputDebug("Software rendering requested: %s\n", m_pShell->PVRShellGet(prefSoftwareRendering) ? "Yes" : "No");
+ m_pShell->PVRShellOutputDebug("Swap Interval requested: %i\n", m_pShell->PVRShellGet(prefSwapInterval));
+
+ if(m_pShell->PVRShellGet(prefInitRepeats) > 0)
+ m_pShell->PVRShellOutputDebug("No of Init repeats: %i\n", m_pShell->PVRShellGet(prefInitRepeats));
+
+ if(m_pShell->PVRShellGet(prefQuitAfterFrame) != -1)
+ m_pShell->PVRShellOutputDebug("Quit after frame: %i\n", m_pShell->PVRShellGet(prefQuitAfterFrame));
+
+ if(m_pShell->PVRShellGet(prefQuitAfterTime) != -1.0f)
+ m_pShell->PVRShellOutputDebug("Quit after time: %f\n", m_pShell->PVRShellGet(prefQuitAfterTime));
+ }
+}
+
+/****************************************************************************
+** Local code
+****************************************************************************/
+/*!***********************************************************************
+ @brief This function copies pszSrc into pszStr.
+ @param[out] pszStr The string to copy pszSrc into
+ @param[in] pszSrc The source string to copy
+*************************************************************************/
+static bool StringCopy(char *&pszStr, const char * const pszSrc)
+{
+ size_t len;
+
+ FREE(pszStr);
+
+ if(!pszSrc)
+ return true;
+
+ len = strlen(pszSrc)+1;
+ pszStr = (char*)malloc(len);
+ if(!pszStr)
+ return false;
+
+ strcpy(pszStr, pszSrc);
+ return true;
+}
+
+/// @endcond
+//NO_DOXYGEN
+
+/*****************************************************************************
+End of file (PVRShell.cpp)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/PVRShell.h b/third_party/PowerVR_SDK/Shell/PVRShell.h
new file mode 100644
index 0000000..886fd3e
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/PVRShell.h
@@ -0,0 +1,667 @@
+/*!****************************************************************************
+
+ @file Shell/PVRShell.h
+ @copyright Copyright (c) Imagination Technologies Limited.
+ @brief Makes programming for 3D APIs easier by wrapping surface
+ initialization, Texture allocation and other functions for use by a demo.
+
+******************************************************************************/
+
+#ifndef __PVRSHELL_H_
+#define __PVRSHELL_H_
+
+/*****************************************************************************/
+/*! @mainpage PVRShell
+******************************************************************************
+
+ @tableofcontents
+
+ @section overview Overview
+ *****************************
+
+ PVRShell is a C++ class used to make programming for PowerVR platforms easier and more portable.
+ PVRShell takes care of all API and OS initialisation for the user and handles adapters, devices, screen/windows modes,
+ resolution, buffering, depth-buffer, viewport creation & clearing, etc...
+
+ PVRShell consists of 3 files: PVRShell.cpp, PVRShellOS.cpp and PVRShellAPI.cpp.
+
+ PVRShellOS.cpp and PVRShellAPI.cpp are supplied per platform and contain all the code to initialise the specific
+ API (OpenGL ES, Direct3D Mobile, etc.) and the OS (Windows, Linux, WinCE, etc.).
+ PVRShell.cpp is where the common code resides and it interacts with the user application through an abstraction layer.
+
+ A new application must link to these three files and must create a class that will inherit the PVRShell class.
+ This class will provide five virtual functions to interface with the user.
+
+ The user also needs to register his application class through the NewDemo function:
+
+ @code
+ class MyApplication: public PVRShell
+ {
+ public:
+ virtual bool InitApplication();
+ virtual bool InitView();
+ virtual bool ReleaseView();
+ virtual bool QuitApplication();
+ virtual bool RenderScene();
+ };
+
+ PVRShell* NewDemo()
+ {
+ return new MyApplication();
+ }
+ @endcode
+
+
+ @section interface Interface
+ ******************************
+
+ There are two functions for initialisation, two functions to release allocated resources and a render function:
+
+ InitApplication() will be called by PVRShell once per run, before the graphic context is created.
+ It is used to initialise variables that are not dependant on the rendering context (e.g. external modules, loading user data, etc.).
+ QuitApplication() will be called by PVRShell once per run, just before exiting the program.
+ If the graphic context is lost, QuitApplication() will not be called.
+
+ InitView() will be called by PVRShell upon creation or change in the rendering context.
+ It is used to initialise variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.).
+ ReleaseView() will be called by PVRShell before changing to a new rendering context or
+ when finalising the application (before calling QuitApplication).
+
+ RenderScene() is the main rendering loop function of the program. This function must return FALSE when the user wants to terminate the application.
+ PVRShell will call this function every frame and will manage relevant OS events.
+
+ There are other PVRShell functions which allow the user to set his/her preferences and get data back from the devices:
+
+ PVRShellSet() and PVRShellGet() are used to pass data to and from PVRShell. PVRShellSet() is recommended to be used
+ in InitApplication() so the user preferences are applied at the API initialisation.
+ There is a definition of these functions per type of data passed or returned. Please check the prefNameBoolEnum, prefNameFloatEnum,
+ prefNameIntEnum, prefNamePtrEnum and prefNameConstPtrEnum enumerations for a full list of the data available.
+
+ This is an example:
+
+ @code
+ bool MyApplication::InitApplication()
+ {
+ PVRShellSet (prefFullScreen, true);
+ }
+
+ bool MyApplication::RenderScene()
+ {
+ int dwCurrentWidth = PVRShellGet (prefHeight);
+ int dwCurrentHeight = PVRShellGet (prefWidth);
+
+ return true;
+ }
+ @endcode
+
+
+ @section helper Helper functions
+ *************************************
+
+ The user input is abstracted with the PVRShellIsKeyPressed() function. It will not work in all devices, but we have tried to map the most
+ relevant keys when possible. See PVRShellKeyName enumeration for the list of keys supported. This function will return true or false depending on
+ the specified key being pressed.
+
+ There are a few other helper functions supplied by PVRShell as well. These functions allow you to read the timer, to output debug information and to
+ save a screen-shot of the current frame:
+
+ PVRShellGetTime() returns time in milliseconds.
+
+ PVRShellOutputDebug() will write a debug string (same format as printf) to the platform debug output.
+
+ PVRShellScreenCaptureBuffer() and PVRShellWriteBMPFile() will be used to save the current frame as a BMP file. PVRShellScreenCaptureBuffer()
+ receives a pointer to an area of memory containing the screen buffer. The memory should be freed with free() when not needed any longer.
+
+ Example of screenshot:
+
+ @code
+ bool MyApplication::RenderScene()
+ {
+ [...]
+
+ unsigned char *pLines;
+
+ PVRShellScreenCaptureBuffer(PVRShellGet (prefWidth), PVRShellGet (prefHeight), &pLines);
+
+ PVRShellScreenSave("myfile", pLines, NULL);
+
+ free (pLines);
+
+ return true;
+ }
+ @endcode
+
+
+ @section cmd Command-line
+ *************************************
+
+ Across all platforms, PVRShell takes a set of command-line arguments which allow things like the position and size of the demo
+ to be controlled. The list below shows these options.
+
+ \b -width=N Sets the horizontal viewport width to N.
+
+ \b -height=N Sets the vertical viewport height to N.
+
+ \b -posx=N Sets the x coordinate of the viewport.
+
+ \b -posy=N Sets the y coordinate of the viewport.
+
+ \b -aasamples=N Sets the number of samples to use for full screen anti-aliasing. e.g 0, 2, 4, 8
+
+ \b -fullscreen=N Enable/Disable fullscreen mode. N can be: 0=Windowed 1=Fullscreen.
+
+ \b -qat=N Quits after N seconds.
+
+ \b -qaf=N Quits after N frames.
+
+ \b -powersaving=N Where available enable/disable power saving. N can be: 0=Disable power saving 1=Enable power saving.
+
+ \b -vsync=N Where available modify the apps vsync parameters.
+
+ \b -version Output the SDK version to the debug output.
+
+ \b -info Output setup information (e.g. window width) to the debug output.
+
+ \b -rotatekeys=N Sets the orientation of the keyboard input. N can be: 0-3, 0 is no rotation.
+
+ \b -c=N Save a single screenshot or a range. e.g. -c=1-10, -c=14.
+
+ \b -priority=N EGL only. Sets the priority of the EGL context.
+
+ \b -colourbpp=N EGL only. When choosing an EGL config N will be used as the value for EGL_BUFFER_SIZE.
+
+ \b -depthbpp=N EGL only. When choosing an EGL config N will be used as the value for EGL_DEPTH_SIZE.
+
+ \b -config=N EGL only. Force the shell to use the EGL config with ID N.
+
+ \b -forceframetime=N Alter the behaviour of PVRShellGetTime so its returned value is frame based (N denotes how many ms a frame should pretend to last). You can also use the shortened version of -fft and the command can be used without N being defined, e.g. just -forceframetime. This option is provided to aid in debugging time-based applications.
+
+ Example:
+ @code
+ Demo -width=160 -height=120 -qaf=300
+ @endcode
+
+ @section APIsOSs APIs and Operating Systems
+ *****************************
+ For information specific to each 3D API and Operating System, see the list of supported APIs and OSs on the <a href="modules.html">Modules</a> page.
+
+******************************************************************************/
+// Uncomment to enable the -fps command-line option
+// #define PVRSHELL_FPS_OUTPUT
+
+/*****************************************************************************
+** Includes
+*****************************************************************************/
+#include <stdlib.h>
+
+#define EXIT_NOERR_CODE 0
+#define EXIT_ERR_CODE (!EXIT_NOERR_CODE)
+
+// avoid warning about unused parameter
+#define PVRSHELL_UNREFERENCED_PARAMETER(x) ((void) x)
+
+// Keyboard mapping. //
+
+/*!***********************************************************************
+ @enum PVRShellKeyName
+ @brief Key name.
+ ************************************************************************/
+enum PVRShellKeyName
+{
+ PVRShellKeyNameNull, /*!< Null key value */
+ PVRShellKeyNameQUIT, /*!< QUIT key value */
+ PVRShellKeyNameSELECT, /*!< SELECT key value */
+ PVRShellKeyNameACTION1, /*!< ACTION1 key value */
+ PVRShellKeyNameACTION2, /*!< ACTION2 key value */
+ PVRShellKeyNameUP, /*!< UP key */
+ PVRShellKeyNameDOWN, /*!< DOWN key */
+ PVRShellKeyNameLEFT, /*!< LEFT key */
+ PVRShellKeyNameRIGHT, /*!< RIGHT key */
+ PVRShellKeyNameScreenshot /*!< SCREENSHOT key */
+};
+
+/*!***********************************************************************
+ @enum PVRShellKeyRotate
+ @brief Key rotate.
+ ************************************************************************/
+enum PVRShellKeyRotate
+{
+ PVRShellKeyRotateNone=0, /*!< Rotate key none = 0. */
+ PVRShellKeyRotate90, /*!< Rotate key 90 */
+ PVRShellKeyRotate180, /*!< Rotate key 180 */
+ PVRShellKeyRotate270 /*!< Rotate key 270 */
+};
+
+// Pointer button mapping. //
+
+/*!***********************************************************************
+ @enum EPVRShellButtonState
+ @brief Pointer button mapping.
+ ************************************************************************/
+enum EPVRShellButtonState
+{
+ ePVRShellButtonLeft = 0x1, /*!< Left button */
+ ePVRShellButtonRight = 0x2, /*!< Right button */
+ ePVRShellButtonMiddle = 0x4 /*!< Middle button */
+};
+
+/*!***********************************************************************
+ @enum prefNameBoolEnum
+ @brief Boolean Shell preferences.
+ ************************************************************************/
+enum prefNameBoolEnum
+{
+ prefFullScreen, /*!< Set to: 1 for full-screen rendering; 0 for windowed */
+ prefIsRotated, /*!< Query this to learn whether screen is rotated */
+ prefPBufferContext, /*!< 1 if you need pbuffer support (default is pbuffer not needed) */
+ prefPixmapContext, /*!< 1 to use a pixmap as a render-target (default off) */
+ prefPixmapDisableCopy, /*!< 1 to disable the copy if pixmaps are used */
+ prefZbufferContext, /*!< 1 if you wish to have zbuffer support (default to on) */
+ prefLockableBackBuffer, /*!< DX9 only: true to use D3DPRESENTFLAG_LOCKABLE_BACKBUFFER (default: false) */
+ prefSoftwareRendering, /*!< 1 to select software rendering (default: off, i.e. use hardware) */
+ prefStencilBufferContext, /*!< 1 if you wish to have stencil support (default: off) */
+ prefAlphaFormatPre, /*!< EGL only: 1 to create the EGL surface with EGL_ALPHA_FORMAT_PRE (default: 0) */
+ prefPowerSaving, /*!< If true then the app will go into powersaving mode (if available) when not in use. */
+#ifdef PVRSHELL_FPS_OUTPUT
+ prefOutputFPS, /*!< If true then the FPS are output using PVRShellOutputdebug */
+#endif
+ prefOutputInfo, /*!< If true then the app will output helpful information such as colour buffer format via PVRShellOutputDebug. */
+ prefNoShellSwapBuffer, /*!< EGL: If true then the shell won't call eglswapbuffers at the end of each frame. */
+ prefShowCursor, /*!< Set to: 1 to show the cursor; 0 to hide it. */
+ prefForceFrameTime, /*!< If true will alter PVRShellGetTime behaviour to be frame based. This is for debugging purposes. */
+ prefDiscardColor, /*!< GLES: Whether or not to discard color data at the end of a render, to save bandwidth. Requires specific functionality. (default: false) */
+ prefDiscardDepth, /*!< GLES: Whether or not to discard depth data at the end of a render, to save bandwidth. Requires specific functionality. (default: true) */
+ prefDiscardStencil /*!< GLES: Whether or not to discard stencil data at the end of a render, to save bandwidth. Requires specific functionality. (default: true) */
+};
+
+/*!***********************************************************************
+ @enum prefNameFloatEnum
+ @brief Float Shell preferences.
+ ************************************************************************/
+enum prefNameFloatEnum
+{
+ prefQuitAfterTime /*!< Shell will quit after this number of seconds (-1 to disable) */
+};
+
+/*!***********************************************************************
+ @enum prefNameIntEnum
+ @brief Integer Shell preferences.
+ ************************************************************************/
+enum prefNameIntEnum
+{
+ prefEGLMajorVersion, /*!< EGL: returns the major version as returned by eglInitialize() */
+ prefEGLMinorVersion, /*!< EGL: returns the minor version as returned by eglInitialize() */
+ prefWidth, /*!< Width of render target */
+ prefHeight, /*!< Height of render target */
+ prefPositionX, /*!< X position of the window */
+ prefPositionY, /*!< Y position of the window */
+ prefQuitAfterFrame, /*!< Shell will quit after this number of frames (-1 to disable) */
+ prefSwapInterval, /*!< 0 to preventing waiting for monitor vertical syncs */
+ prefInitRepeats, /*!< Number of times to reinitialise (if >0 when app returns false from RenderScene(), shell will ReleaseView(), InitView() then re-enter RenderScene() loop). Decrements on each initialisation. */
+ prefAASamples, /*!< Set to: 0 to disable full-screen anti-aliasing; 2 for 2x; 4 for 4x; 8 for 8x. */
+ prefCommandLineOptNum, /*!< Returns the length of the array returned by prefCommandLineOpts */
+ prefColorBPP, /*!< Allows you to specify a desired color buffer size e.g. 16, 32. */
+ prefDepthBPP, /*!< Allows you to specify a desired depth buffer size e.g. 16, 24. */
+ prefRotateKeys, /*!< Allows you to specify and retrieve how the keyboard input is transformed */
+ prefButtonState, /*!< pointer button state */
+ prefCaptureFrameStart, /*!< The frame to start capturing screenshots from */
+ prefCaptureFrameStop, /*!< The frame to stop capturing screenshots at */
+ prefCaptureFrameScale, /*!< Pixel-replicate saved screenshots this many times; default 1 for no scale */
+ prefPriority, /*!< EGL: If supported will set the egl context priority; 0 for low, 1 for med and 2 for high. */
+ prefConfig, /*!< EGL: Get the chosen EGL config. */
+ prefRequestedConfig, /*!< EGL: Force the shell to use a particular EGL config. */
+ prefNativeDisplay, /*!< EGL: Allows you to specify the native display to use if the device has more that one. */
+ prefFrameTimeValue /*!< An integer value to say how long you wish one frame to last for (in ms) when force frame time is enabled. */
+};
+
+/*!***********************************************************************
+ @enum prefNamePtrEnum
+ @brief Pointers/Handlers Shell preferences.
+ ************************************************************************/
+enum prefNamePtrEnum
+{
+ prefD3DDevice, /*!< D3D: returns the device pointer */
+ prefEGLDisplay, /*!< EGL: returns the EGLDisplay */
+ prefEGLSurface, /*!< EGL: returns the EGLSurface */
+ prefHINSTANCE, /*!< Windows: returns the application instance handle */
+ prefNativeWindowType, /*!< Returns the window handle */
+ prefAccelerometer, /*!< Accelerometer values */
+ prefPointerLocation, /*!< Mouse pointer/touch location values */
+ prefPVR2DContext, /*!< PVR2D: returns the PVR2D context */
+ prefLoadFileFunc, /*!< A pointer to a function that can be used to load external files on platforms that don't allow the use of fopen.
+ The ptr returned is of the type PFNLoadFileFunc defined below. */
+ prefReleaseFileFunc, /*!< A pointer to a function that is used to release any data allocated by the load file function.
+ The ptr returned is of the type PFNReleaseFileFunc defined below. */
+ prefAndroidNativeActivity /*!< Android: A pointer to the ANativeActivity struct for the application. Your application will need to include android_native_app_glue.h to cast the pointer to ANativeActivity. */
+};
+
+/*!***********************************************************************
+ @typedef PFNLoadFileFunc
+ @brief The LoadFileFunc function pointer template.
+ ************************************************************************/
+typedef void* (*PFNLoadFileFunc)(const char*, char** pData, size_t &size);
+
+/*!***********************************************************************
+ @typedef PFNReleaseFileFunc
+ @brief The ReleaseFileFunc function pointer template.
+ ************************************************************************/
+typedef bool (*PFNReleaseFileFunc)(void* handle);
+
+/*!***********************************************************************
+ @enum prefNameConstPtrEnum
+ @brief Constant pointers Shell preferences.
+ ************************************************************************/
+enum prefNameConstPtrEnum
+{
+ prefAppName, /*!< ptrValue is char* */
+ prefReadPath, /*!< ptrValue is char*; will include a trailing slash */
+ prefWritePath, /*!< ptrValue is char*; will include a trailing slash */
+ prefCommandLine, /*!< used to retrieve the entire application command line */
+ prefCommandLineOpts, /*!< ptrValue is SCmdLineOpt*; retrieves an array of arg/value pairs (parsed from the command line) */
+ prefExitMessage, /*!< ptrValue is char*; gives the shell a message to show on exit, typically an error */
+ prefVersion /*!< ptrValue is char* */
+};
+
+/*!**************************************************************************
+ @struct PVRShellData
+ @brief PVRShell implementation Prototypes and definitions
+*****************************************************************************/
+struct PVRShellData;
+
+/*!***************************************************************************
+ @class PVRShellInit
+ *****************************************************************************/
+class PVRShellInit;
+
+/*!***********************************************************************
+ @struct SCmdLineOpt
+ @brief Stores a variable name/value pair for an individual command-line option.
+ ************************************************************************/
+struct SCmdLineOpt
+{
+ const char *pArg, *pVal;
+};
+
+/*!***************************************************************************
+ @class PVRShell
+ @brief Inherited by the application; responsible for abstracting the OS and API.
+ @details PVRShell is the main Shell class that an application uses. An
+ application should supply a class which inherits PVRShell and supplies
+ implementations of the virtual functions of PVRShell (InitApplication(),
+ QuitApplication(), InitView(), ReleaseView(), RenderScene()). Default stub
+ functions are supplied; this means that an application is not
+ required to supply a particular function if it does not need to do anything
+ in it.
+ The other, non-virtual, functions of PVRShell are utility functions that the
+ application may call.
+ *****************************************************************************/
+class PVRShell
+{
+private:
+ friend class PVRShellInitOS;
+ friend class PVRShellInit;
+
+ PVRShellData *m_pShellData;
+ PVRShellInit *m_pShellInit;
+
+public:
+ /*!***********************************************************************
+ @brief Constructor
+ *************************************************************************/
+ PVRShell();
+
+ /*!***********************************************************************
+ @brief Destructor
+ *************************************************************************/
+ virtual ~PVRShell();
+
+ /*
+ PVRShell functions that the application should implement.
+ */
+
+ /*!***********************************************************************
+ @brief Initialise the application.
+ @details This function can be overloaded by the application. It
+ will be called by PVRShell once, only at the beginning of
+ the PVRShell WinMain()/main() function. This function
+ enables the user to perform any initialisation before the
+ render API is initialised. From this function the user can
+ call PVRShellSet() to change default values, e.g.
+ requesting a particular resolution or device setting.
+ @return true for success, false to exit the application
+ *************************************************************************/
+ virtual bool InitApplication() { return true; };
+
+ /*!***********************************************************************
+ @brief Quit the application.
+ @details This function can be overloaded by the application. It
+ will be called by PVRShell just before finishing the
+ program. It enables the application to release any
+ memory/resources acquired in InitApplication().
+ @return true for success, false to exit the application
+ *************************************************************************/
+ virtual bool QuitApplication() { return true; };
+
+ /*!***********************************************************************
+ @brief Initialise the view.
+ @details This function can be overloaded by the application. It
+ will be called by PVRShell after the OS and rendering API
+ are initialised, before entering the RenderScene() loop.
+ It is called any time the rendering API is initialised,
+ i.e. once at the beginning, and possibly again if the
+ resolution changes, or a power management even occurs, or
+ if the app requests a re-initialisation.
+ The application should check here the configuration of
+ the rendering API; it is possible that requests made in
+ InitApplication() were not successful.
+ Since everything is initialised when this function is
+ called, you can load textures and perform rendering API functions.
+ @return true for success, false to exit the application
+ *************************************************************************/
+ virtual bool InitView() { return true; };
+
+ /*!***********************************************************************
+ @brief Release the view.
+ @details This function can be overloaded by the application. It
+ will be called after the RenderScene() loop, before
+ shutting down the render API. It enables the application
+ to release any memory/resources acquired in InitView().
+ @return true for success, false to exit the application
+ *************************************************************************/
+ virtual bool ReleaseView() { return true; };
+
+ /*!***********************************************************************
+ @brief Render the scene
+ @details This function can be overloaded by the application.
+ It is main application function in which you have to do your own rendering. Will be
+ called repeatedly until the application exits.
+ @return true for success, false to exit the application
+ *************************************************************************/
+ virtual bool RenderScene() { return true; };
+
+ /*
+ PVRShell functions available for the application to use.
+ */
+
+ /*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+ *************************************************************************/
+ bool PVRShellSet(const prefNameBoolEnum prefName, const bool value);
+
+ /*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+ *************************************************************************/
+ bool PVRShellSet(const prefNameFloatEnum prefName, const float value);
+
+ /*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+ *************************************************************************/
+ bool PVRShellSet(const prefNameIntEnum prefName, const int value);
+
+ /*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this funciton must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] ptrValue Value
+ @return true for success
+ *************************************************************************/
+ bool PVRShellSet(const prefNamePtrEnum prefName, const void * const ptrValue);
+
+ /*!***********************************************************************
+ @brief This function is used to pass preferences to the PVRShell.
+ If used, this function must be called from InitApplication().
+ @param[in] prefName Name of preference to set to value
+ @param[in] ptrValue Value
+ @return true for success
+ *************************************************************************/
+ bool PVRShellSet(const prefNameConstPtrEnum prefName, const void * const ptrValue);
+
+ /*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+ *************************************************************************/
+ bool PVRShellGet(const prefNameBoolEnum prefName) const;
+
+ /*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+ *************************************************************************/
+ float PVRShellGet(const prefNameFloatEnum prefName) const;
+
+ /*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+ *************************************************************************/
+ int PVRShellGet(const prefNameIntEnum prefName) const;
+
+ /*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell.
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+ *************************************************************************/
+ void *PVRShellGet(const prefNamePtrEnum prefName) const;
+
+ /*!***********************************************************************
+ @brief This function is used to get parameters from the PVRShell
+ It can be called from anywhere in the program.
+ @param[in] prefName Name of preference to set to value
+ @return The requested value.
+ *************************************************************************/
+ const void *PVRShellGet(const prefNameConstPtrEnum prefName) const;
+
+ /*!***********************************************************************
+ @brief It will be stored as 24-bit per pixel, 8-bit per chanel RGB.
+ The memory should be freed using the free() function when no longer needed.
+ @param[in] Width size of image to capture (relative to 0,0)
+ @param[in] Height size of image to capture (relative to 0,0)
+ @param[out] pLines receives a pointer to an area of memory containing the screen buffer.
+ @return true for success
+ *************************************************************************/
+ bool PVRShellScreenCaptureBuffer(const int Width, const int Height, unsigned char **pLines);
+
+ /*!***********************************************************************
+ @brief Writes out the image data to a BMP file with basename fname.
+ @details The file written will be fname suffixed with a
+ number to make the file unique.
+ For example, if fname is "abc", this function will attempt
+ to save to "abc0000.bmp"; if that file already exists, it
+ will try "abc0001.bmp", repeating until a new filename is
+ found. The final filename used is returned in ofname.
+ @param[in] fname base of file to save screen to
+ @param[in] Width size of image
+ @param[in] Height size of image
+ @param[in] pLines image data to write out (24bpp, 8-bit per channel RGB)
+ @param[in] ui32PixelReplicate expand pixels through replication (1 = no scale)
+ @param[out] ofname If non-NULL, receives the filename actually used
+ @return true for success
+ *************************************************************************/
+ int PVRShellScreenSave(
+ const char * const fname,
+ const int Width,
+ const int Height,
+ const unsigned char * const pLines,
+ const unsigned int ui32PixelReplicate = 1,
+ char * const ofname = NULL);
+
+ /*!***********************************************************************
+ @brief Writes out the image data to a BMP file with name fname.
+ @param[in] pszFilename file to save screen to
+ @param[in] ui32Width the width of the data
+ @param[in] ui32Height the height of the data
+ @param[in] pImageData image data to write out (24bpp, 8-bit per channel RGB)
+ @param[in] ui32PixelReplicate expand pixels through replication (1 = no scale)
+ @return 0 on success
+ *************************************************************************/
+ int PVRShellWriteBMPFile(
+ const char * const pszFilename,
+ const unsigned int ui32Width,
+ const unsigned int ui32Height,
+ const void * const pImageData,
+ const unsigned int ui32PixelReplicate = 1);
+
+ /*!***********************************************************************
+ @brief Writes the resultant string to the debug output (e.g. using
+ printf(), OutputDebugString(), ...). Check the SDK release notes for
+ details on how the string is output.
+ @param[in] format printf style format followed by arguments it requires
+ *************************************************************************/
+ void PVRShellOutputDebug(char const * const format, ...) const;
+
+ /*!***********************************************************************
+ @brief The number itself should be considered meaningless; an
+ application should use this function to determine how much
+ time has passed between two points (e.g. between each frame).
+ @return A value which increments once per millisecond.
+ *************************************************************************/
+ unsigned long PVRShellGetTime();
+
+ /*!***********************************************************************
+ @brief Check if a key was pressed.
+ @details The keys on various devices
+ are mapped to the PVRShell-supported keys (listed in @a PVRShellKeyName) in
+ a platform-dependent manner, since most platforms have different input
+ devices. Check the <a href="modules.html">Modules page</a> for your OS
+ for details on how the enum values map to your device's key code input.
+ @param[in] key Code of the key to test
+ @return true if key was pressed
+ *************************************************************************/
+ bool PVRShellIsKeyPressed(const PVRShellKeyName key);
+};
+
+/****************************************************************************
+** Declarations for functions that the scene file must supply
+****************************************************************************/
+
+/*!***************************************************************************
+ @brief This function must be implemented by the user of the shell.
+ @details The user should return its PVRShell object defining the
+ behaviour of the application.
+ @return The demo supplied by the user
+*****************************************************************************/
+PVRShell* NewDemo();
+
+#endif /* __PVRSHELL_H_ */
+
+/*****************************************************************************
+ End of file (PVRShell.h)
+*****************************************************************************/
+
diff --git a/third_party/PowerVR_SDK/Shell/PVRShellImpl.h b/third_party/PowerVR_SDK/Shell/PVRShellImpl.h
new file mode 100644
index 0000000..ef7a50c
--- /dev/null
+++ b/third_party/PowerVR_SDK/Shell/PVRShellImpl.h
@@ -0,0 +1,484 @@
+/*!****************************************************************************
+
+ @file Shell/PVRShellImpl.h
+ @copyright Copyright (c) Imagination Technologies Limited.
+ @brief Makes programming for 3D APIs easier by wrapping surface
+ initialization, texture allocation and other functions for use by a demo.
+
+******************************************************************************/
+
+#ifndef __PVRSHELLIMPL_H_
+#define __PVRSHELLIMPL_H_
+
+/*****************************************************************************
+** Build options
+*****************************************************************************/
+
+
+/*****************************************************************************
+** Macros
+*****************************************************************************/
+#define FREE(X) { if(X) { free(X); (X)=0; } }
+
+#ifndef _ASSERT
+#define _ASSERT(X) /**/
+#endif
+
+/*****************************************************************************
+** Defines
+*****************************************************************************/
+#define STR_WNDTITLE (" - Build ")
+
+/*!***************************************************************************
+ @struct PVRShellData
+ @brief Holds PVRShell internal data.
+*****************************************************************************/
+struct PVRShellData
+{
+ // Shell Interface Data
+ char *pszAppName; /*!< Application name string. */
+ char *pszExitMessage; /*!< Exit message string. */
+ int nShellDimX; /*!< Width in pixels. */
+ int nShellDimY; /*!< Height in pixels. */
+ int nShellPosX; /*!< X position of the window. */
+ int nShellPosY; /*!< Y position of the window. */
+ bool bFullScreen; /*!< Fullscreen boolean. */
+ bool bLandscape; /*!< Landscape orientation boolean. false = portrait orientation. */
+ bool bNeedPbuffer; /*!< True if pixel buffer is needed. */
+ bool bNeedZbuffer; /*!< True if Z buffer is needed. */
+ bool bNeedStencilBuffer; /*!< True if stencil buffer is needed. */
+ bool bNeedPixmap; /*!< True if pixmap is needed. */
+ bool bNeedPixmapDisableCopy; /*!< Disables copy if true, because pixmaps are used. */
+ bool bLockableBackBuffer; /*!< DX9 only. Enable the use of D3DPRESENTFLAG_LOCKABLE_BACKBUFFER. */
+ bool bSoftwareRender; /*!< Enable the use of software rendering. */
+ bool bNeedAlphaFormatPre; /*!< EGL only: If true, creates the EGL surface with EGL_ALPHA_FORMAT_PRE. */
+ bool bUsingPowerSaving; /*!< Use power saving mode when device is not in use. */
+ bool bOutputInfo; /*!< Enable information to be output via PVRShellOutputDebug. For example,
+ the depth of the colour surface created, extenstions supported and
+ dimensions of the surface created. */
+ bool bNoShellSwapBuffer; /*!< Disable eglswapbuffers at the end of each frame. */
+ int nSwapInterval; /*!< Interval to wait for monitor vertical sync. */
+ int nInitRepeats; /*!< Number of times to reinitialise. */
+ int nDieAfterFrames; /*!< Set shell to quit after this number of frames (-1 to disable) */
+ float fDieAfterTime; /*!< Set shell to quit after this number of seconds (-1 to disable). */
+ int nAASamples; /*!< Number of anti-aliasing samples to have. 0 disables anti-aliasing. */
+ int nColorBPP; /*!< Color buffer size. */
+ int nDepthBPP; /*!< Depth buffer size. */
+ int nCaptureFrameStart; /*!< The frame to start capturing screenshots from. */
+ int nCaptureFrameStop; /*!< The frame to stop capturing screenshots from. */
+ int nCaptureFrameScale; /*!< Save screenshots scale factor. 1 for no scaling. */
+ int nPriority; /*!< EGL: If supported sets the egl context priority;
+ 0 for low, 1 for med and 2 for high. */
+ bool bForceFrameTime; /*!< Overrides PVRShellGetTime to force specified frame time. May cause
+ problems if PVRShellGetTime is called multiple times in a frame. */
+ int nFrameTime; /*!< How long for each frame time to last (in ms). */
+ bool bDiscardFrameColor; /*!< Discard color data at the end of a render. */
+ bool bDiscardFrameDepth; /*!< Discard depth data at the end of a render. */
+ bool bDiscardFrameStencil; /*!< Discard stencil data at the end of a render. */
+
+ // Internal Data
+ bool bShellPosWasDefault; /*!< Internal. Default position for the shell was used. */
+ int nShellCurFrameNum; /*!< Internal. Current frame number. */
+#ifdef PVRSHELL_FPS_OUTPUT
+ bool bOutputFPS; /*!< Output frames per second. */
+#endif
+};
+
+/*!***************************************************************************
+ @class PVRShellCommandLine
+ @brief Command-line interpreter
+*****************************************************************************/
+class PVRShellCommandLine
+{
+public:
+ char *m_psOrig, *m_psSplit;
+ SCmdLineOpt *m_pOpt;
+ int m_nOptLen, m_nOptMax;
+
+public:
+ /*!***********************************************************************
+ @brief Constructor
+ *************************************************************************/
+ PVRShellCommandLine();
+
+ /*!***********************************************************************
+ @brief Destructor
+ *************************************************************************/
+ ~PVRShellCommandLine();
+
+ /*!***********************************************************************
+ @brief Set command-line options to pStr
+ @param[in] pStr Input string
+ *************************************************************************/
+ void Set(const char *pStr);
+
+ /*!***********************************************************************
+ @brief Prepend command-line options to m_psOrig
+ @param[in] pStr Input string
+ *************************************************************************/
+ void Prefix(const char *pStr);
+
+ /*!***********************************************************************
+ @brief Prepend command-line options to m_psOrig from a file
+ @param[in] pFileName Input string
+ *************************************************************************/
+ bool PrefixFromFile(const char *pFileName);
+
+ /*!***********************************************************************
+ @brief Parse m_psOrig for command-line options and store them in m_pOpt
+ *************************************************************************/
+ void Parse();
+
+ /*!***********************************************************************
+ @brief Apply the command-line options to shell
+ @param[in] shell
+ *************************************************************************/
+ void Apply(PVRShell &shell);
+};
+
+/*!****************************************************************************
+ @enum EPVRShellState
+ @brief Current Shell state
+*****************************************************************************/
+enum EPVRShellState {
+ ePVRShellInitApp, /*!< Initialise app */
+ ePVRShellInitInstance, /*!< Initialise instance */
+ ePVRShellRender, /*!< Render */
+ ePVRShellReleaseView, /*!< Release View */
+ ePVRShellReleaseAPI, /*!< Release API */
+ ePVRShellReleaseOS, /*!< Release Operating System */
+ ePVRShellQuitApp, /*!< Quit App */
+ ePVRShellExit /*!< Exit */
+};
+
+/*!***************************************************************************
+ @class PVRShellInit
+ @brief The PVRShell initialisation class
+ ****************************************************************************/
+class PVRShellInit : public PVRShellInitAPI, public PVRShellInitOS
+{
+public:
+ friend class PVRShell;
+ friend class PVRShellInitOS;
+ friend class PVRShellInitAPI;
+
+ PVRShell *m_pShell; /*!< Our PVRShell class */
+ PVRShellCommandLine m_CommandLine; /*!< Our Command-line class */
+
+ bool gShellDone; /*!< Indicates that the application has finished */
+ EPVRShellState m_eState; /*!< Current PVRShell state */
+
+ // Key handling
+ PVRShellKeyName nLastKeyPressed; /*!< Holds the last key pressed */
+ PVRShellKeyName m_eKeyMapLEFT; /*!< Holds the value to be returned when PVRShellKeyNameLEFT is requested */
+ PVRShellKeyName m_eKeyMapUP; /*!< Holds the value to be returned when PVRShellKeyNameUP is requested */
+ PVRShellKeyName m_eKeyMapRIGHT; /*!< Holds the value to be returned when PVRShellKeyNameRIGHT is requested */
+ PVRShellKeyName m_eKeyMapDOWN; /*!< Holds the value to be returned when PVRShellKeyNameDOWN is requested */
+
+ // Read and Write path
+ char *m_pReadPath; /*!<Holds the path where the application will read the data from */
+ char *m_pWritePath; /*!<Holds the path where the application will write the data to */
+
+#ifdef PVRSHELL_FPS_OUTPUT
+ // Frames per second (FPS)
+ int m_i32FpsFrameCnt, m_i32FpsTimePrev;
+#endif
+
+public:
+
+protected:
+ float m_vec2PointerLocation[2];
+ float m_vec2PointerLocationStart[2];
+ float m_vec2PointerLocationEnd[2];
+
+ // Touch handling
+ bool m_bTouching;
+
+public:
+ /*!***********************************************************************
+ @brief Constructor
+ *************************************************************************/
+ PVRShellInit();
+
+ /*!***********************************************************************
+ @brief Destructor
+ *************************************************************************/
+ ~PVRShellInit();
+
+ /*!***********************************************************************
+ @brief PVRShell Initialisation.
+ @return True on success and false on failure
+ *************************************************************************/
+ bool Init();
+
+ /*!***********************************************************************
+ @brief PVRShell Deinitialisation.
+ *************************************************************************/
+ void Deinit();
+
+ /*!***********************************************************************
+ @param[in] str A string containing the command-line
+ @brief Receives the command-line from the application.
+ *************************************************************************/
+ void CommandLine(const char *str);
+
+ /*!***********************************************************************
+ @brief Receives the command-line from the application.
+ @param[in] argc Number of strings in argv
+ @param[in] argv An array of strings
+ *************************************************************************/
+ void CommandLine(int argc, char **argv);
+
+ /*!***********************************************************************
+ @brief Return 'true' if the specific key has been pressed.
+ @param[in] key The key we're querying for
+ *************************************************************************/
+ bool DoIsKeyPressed(const PVRShellKeyName key);
+
+ /*!***********************************************************************
+ @param[in] key The key that has been pressed
+ @brief Used by the OS-specific code to tell the Shell that a key has been pressed.
+ *************************************************************************/
+ void KeyPressed(PVRShellKeyName key);
+
+ /*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell that a touch has began at a location.
+ @param[in] vec2Location The position of a click/touch on the screen when it first touches.
+ *************************************************************************/
+ void TouchBegan(const float vec2Location[2]);
+
+ /*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell that a touch has began at a location.
+ @param[in] vec2Location The position of the pointer/touch pressed on the screen.
+ *************************************************************************/
+ void TouchMoved(const float vec2Location[2]);
+
+ /*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell that the current touch has ended at a location.
+ @param[in] vec2Location The position of the pointer/touch on the screen when it is released.
+ *************************************************************************/
+ void TouchEnded(const float vec2Location[2]);
+
+ /*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell where to read external files from.
+ @return A path the application is capable of reading from.
+ *************************************************************************/
+ const char *GetReadPath() const;
+
+ /*!***********************************************************************
+ @brief Used by the OS-specific code to tell the Shell where to write to.
+ @return A path the applications is capable of writing to
+ *************************************************************************/
+ const char *GetWritePath() const;
+
+ /*!******************************************************************************
+ @brief Sets the default app name (to be displayed by the OS)
+ @param[in] str The application name
+ *******************************************************************************/
+ void SetAppName(const char * const str);
+
+ /*!***********************************************************************
+ @brief Set the path to where the application expects to read from.
+ @param[in] str The read path
+ *************************************************************************/
+ void SetReadPath(const char * const str);
+
+ /*!***********************************************************************
+ @brief Set the path to where the application expects to write to.
+ @param[in] str The write path
+ *************************************************************************/
+ void SetWritePath(const char * const str);
+
+ /*!***********************************************************************
+ @brief Called from the OS-specific code to perform the render.
+ When this function fails the application will quit.
+ *************************************************************************/
+ bool Run();
+
+ /*!***********************************************************************
+ @brief When prefOutputInfo is set to true this function outputs
+ various pieces of non-API dependent information via
+ PVRShellOutputDebug.
+ *************************************************************************/
+ void OutputInfo();
+
+ /*!***********************************************************************
+ @brief When prefOutputInfo is set to true this function outputs
+ various pieces of API dependent information via
+ PVRShellOutputDebug.
+ *************************************************************************/
+ void OutputAPIInfo();
+
+#ifdef PVRSHELL_FPS_OUTPUT
+ /*!****************************************************************************
+ @brief Calculates a value for frames-per-second (FPS).
+ *****************************************************************************/
+ void FpsUpdate();
+#endif
+
+ /*
+ OS functionality
+ */
+
+ /*!***********************************************************************
+ @brief Initialisation for OS-specific code.
+ *************************************************************************/
+ void OsInit();
+
+ /*!***********************************************************************
+ @brief Saves instance handle and creates main window
+ In this function, we save the instance handle in a global variable and
+ create and display the main program window.
+ *************************************************************************/
+ bool OsInitOS();
+
+ /*!***********************************************************************
+ @brief Destroys main window
+ *************************************************************************/
+ void OsReleaseOS();
+
+ /*!***********************************************************************
+ @brief Destroys main window
+ *************************************************************************/
+ void OsExit();
+
+ /*!***********************************************************************
+ @brief Perform API initialization and bring up window / fullscreen
+ *************************************************************************/
+ bool OsDoInitAPI();
+
+ /*!***********************************************************************
+ @brief Clean up after we're done
+ *************************************************************************/
+ void OsDoReleaseAPI();
+
+ /*!***********************************************************************
+ @brief Main message loop / render loop
+ *************************************************************************/
+ void OsRenderComplete();
+
+ /*!***********************************************************************
+ @brief When using pixmaps, copy the render to the display
+ *************************************************************************/
+ bool OsPixmapCopy();
+
+ /*!***********************************************************************
+ @brief Called from InitAPI() to get the NativeDisplayType
+ *************************************************************************/
+ void *OsGetNativeDisplayType();
+
+ /*!***********************************************************************
+ @brief Called from InitAPI() to get the NativePixmapType
+ *************************************************************************/
+ void *OsGetNativePixmapType();
+
+ /*!***********************************************************************
+ @brief Called from InitAPI() to get the NativeWindowType
+ *************************************************************************/
+ void *OsGetNativeWindowType();
+
+ /*!***********************************************************************
+ @brief Retrieves OS-specific data
+ @param[in] prefName Name of preference to get
+ @param[out] pn A pointer set to the preference.
+ @return true on success
+ *************************************************************************/
+ bool OsGet(const prefNameIntEnum prefName, int *pn);
+
+ /*!***********************************************************************
+ @brief Retrieves OS-specific data
+ @param[in] prefName Name of value to get
+ @param[out] pp A pointer set to the value asked for
+ @return true on success
+ *************************************************************************/
+ bool OsGet(const prefNamePtrEnum prefName, void **pp);
+
+ /*!***********************************************************************
+ @brief Sets OS-specific data
+ @param[in] prefName Name of preference to set to value
+ @param[in] value Value
+ @return true for success
+ *************************************************************************/
+ bool OsSet(const prefNameBoolEnum prefName, const bool value);
+
+ /*!***********************************************************************
+ @brief Sets OS-specific data
+ @param[in] prefName Name of value to set
+ @param[in] i32Value The value to set our named value to
+ @return true on success
+ *************************************************************************/
+ bool OsSet(const prefNameIntEnum prefName, const int i32Value);
+
+ /*!***********************************************************************
+ @brief Prints a debug string
+ @param[in] str The debug string to display
+ *************************************************************************/
+ void OsDisplayDebugString(char const * const str);
+
+ /*!***********************************************************************
+ @brief Gets the time in milliseconds
+ *************************************************************************/
+ unsigned long OsGetTime();
+
+ /*
+ API functionality
+ */
+ /*!***********************************************************************
+ @brief Initialisation for API-specific code.
+ *************************************************************************/
+ bool ApiInitAPI();
+
+ /*!***********************************************************************
+ @brief Releases all resources allocated by the API.
+ *************************************************************************/
+ void ApiReleaseAPI();
+
+ /*!***********************************************************************
+ @brief API-specific function to store the current content of the
+ FrameBuffer into the memory allocated by the user.
+ @param[in] Width Width of the region to capture
+ @param[in] Height Height of the region to capture
+ @param[out] pBuf A buffer to put the screen capture into
+ @return true on success
+ *************************************************************************/
+ bool ApiScreenCaptureBuffer(int Width,int Height,unsigned char *pBuf);
+
+ /*!***********************************************************************
+ @brief Perform API operations required after a frame has finished (e.g., flipping).
+ *************************************************************************/
+ void ApiRenderComplete();
+
+ /*!***********************************************************************
+ @brief Set preferences which are specific to the API.
+ @param[in] prefName Name of preference to set
+ @param[out] i32Value Value to set it to
+ *************************************************************************/
+ bool ApiSet(const prefNameIntEnum prefName, const int i32Value);
+
+ /*!***********************************************************************
+ @brief Get parameters which are specific to the API.
+ @param[in] prefName Name of value to get
+ @param[out] pn A pointer set to the value asked for
+ *************************************************************************/
+ bool ApiGet(const prefNameIntEnum prefName, int *pn);
+
+ /*!***********************************************************************
+ @brief Get parameters which are specific to the API.
+ @param[in] prefName Name of value to get
+ @param[out] pp A pointer set to the value asked for
+ *************************************************************************/
+ bool ApiGet(const prefNamePtrEnum prefName, void **pp);
+
+
+ /*!***********************************************************************
+ @brief Run specific API code to perform the operations requested in preferences.
+ *************************************************************************/
+ void ApiActivatePreferences();
+};
+
+#endif /* __PVRSHELLIMPL_H_ */
+
+/*****************************************************************************
+ End of file (PVRShellImpl.h)
+*****************************************************************************/
+