Merged default into iOS-improvements iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Wed, 20 Aug 2014 17:20:22 -0300
branchiOS-improvements
changeset 9515 63f5d07c7d70
parent 9514 5b56ab9ff5fe (current diff)
parent 9100 441e6cee6d14 (diff)
child 9516 77867123589c
Merged default into iOS-improvements
include/SDL_hints.h
include/SDL_syswm.h
src/file/cocoa/SDL_rwopsbundlesupport.m
src/filesystem/cocoa/SDL_sysfilesystem.m
--- a/Android.mk	Fri Aug 08 15:14:09 2014 -0300
+++ b/Android.mk	Wed Aug 20 17:20:22 2014 -0300
@@ -34,7 +34,7 @@
 	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/filesystem/android/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/render/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
--- a/CMakeLists.txt	Fri Aug 08 15:14:09 2014 -0300
+++ b/CMakeLists.txt	Wed Aug 20 17:20:22 2014 -0300
@@ -237,6 +237,7 @@
 set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
 set_option(VIDEO_WAYLAND       "Use Wayland video driver" ${UNIX_SYS})
 set_option(VIDEO_MIR           "Use Mir video driver" ${UNIX_SYS})
+set_option(VIDEO_RPI           "Use Raspberry Pi video driver" ${UNIX_SYS})
 dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
 set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
 foreach(_SUB ${SDL_X11_OPTIONS})
@@ -330,11 +331,22 @@
 
   check_c_compiler_flag(-Wall HAVE_GCC_WALL)
   if(HAVE_GCC_WALL)
+    list(APPEND EXTRA_CFLAGS "-Wall")
     if(HAIKU)
       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
     endif()
   endif()
-  #check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
+  check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
+  if(HAVE_GCC_WSHADOW)
+    list(APPEND EXTRA_CFLAGS "-Wshadow")
+  endif()
+
+  set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
+  check_c_compiler_flag("" HAVE_NO_UNDEFINED)
+  set(CMAKE_REQUIRED_FLAGS)
+  if(HAVE_NO_UNDEFINED)
+    list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
+  endif()
 endif()
 
 if(ASSEMBLY)
@@ -658,6 +670,8 @@
   endif()
 
   if(SDL_VIDEO)
+    # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
+    CheckRPI()
     CheckX11()
     CheckMir()
     CheckDirectFB()
@@ -805,6 +819,7 @@
     check_include_file(dsound.h HAVE_DSOUND_H)
     check_include_file(dinput.h HAVE_DINPUT_H)
     check_include_file(xaudio2.h HAVE_XAUDIO2_H)
+    check_include_file(xinput.h HAVE_XINPUT_H)
     check_include_file(dxgi.h HAVE_DXGI_H)
     if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
       set(HAVE_DIRECTX TRUE)
@@ -910,21 +925,31 @@
   endif()
 
   if(SDL_JOYSTICK)
+    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c)
+    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
     if(HAVE_DINPUT_H)
       set(SDL_JOYSTICK_DINPUT 1)
-      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_dxjoystick.c)
       list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
-    else()
+    endif()
+    if(HAVE_XINPUT_H)
+      set(SDL_JOYSTICK_XINPUT 1)
+    endif()
+    if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H)
       set(SDL_JOYSTICK_WINMM 1)
-      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_mmjoystick.c)
     endif()
     set(HAVE_SDL_JOYSTICK TRUE)
-  endif()
 
-  if(SDL_HAPTIC AND HAVE_DINPUT_H)
-    set(SDL_HAPTIC_DINPUT 1)
-    set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/haptic/windows/SDL_syshaptic.c)
-    set(HAVE_SDL_HAPTIC TRUE)
+    if(SDL_HAPTIC)
+      file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/windows/*.c)
+      set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
+      if(HAVE_DINPUT_H)
+        set(SDL_HAPTIC_DINPUT 1)
+      endif()
+      if(HAVE_XINPUT_H)
+        set(SDL_HAPTIC_XINPUT 1)
+      endif()
+      set(HAVE_SDL_HAPTIC TRUE)
+    endif()
   endif()
 
   file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
@@ -1306,7 +1331,9 @@
   # TODO: what about the .spec file? Is it only needed for RPM creation?
   install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "share/aclocal")
 else()
-  install(TARGETS SDL2 RUNTIME DESTINATION bin)
+  if(SDL_SHARED)
+    install(TARGETS SDL2 RUNTIME DESTINATION bin)
+  endif()
 endif()
 
 ##### Uninstall target #####
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Fri Aug 08 15:14:09 2014 -0300
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Aug 20 17:20:22 2014 -0300
@@ -543,11 +543,14 @@
     /** com.android.vending.expansion.zipfile.ZipResourceFile's getInputStream() or null. */
     private Method expansionFileMethod;
 
+    /**
+     * This method is called by SDL using JNI.
+     */
     public InputStream openAPKExtensionInputStream(String fileName) throws IOException {
         // Get a ZipResourceFile representing a merger of both the main and patch files
         if (expansionFile == null) {
-            Integer mainVersion = Integer.parseInt(nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"));
-            Integer patchVersion = Integer.parseInt(nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"));
+            Integer mainVersion = Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"));
+            Integer patchVersion = Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"));
 
             try {
                 // To avoid direct dependency on Google APK extension library that is
--- a/build-scripts/checker-buildbot.sh	Fri Aug 08 15:14:09 2014 -0300
+++ b/build-scripts/checker-buildbot.sh	Wed Aug 20 17:20:22 2014 -0300
@@ -61,13 +61,13 @@
 cd checker-buildbot
 
 # You might want to do this for CMake-backed builds instead...
-#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CHECKERDIR/libexec/ccc-analyzer" ..
+PATH="$CHECKERDIR:$PATH" scan-build -o analysis cmake -DCMAKE_BUILD_TYPE=Debug ..
 
 # ...or run configure without the scan-build wrapper...
 #CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0" ../configure
 
-# ...but this works for our buildbots just fine.
-CFLAGS="-O0" PATH="$CHECKERDIR:$PATH" scan-build -o analysis ../configure
+# ...but this works for our buildbots just fine (EXCEPT ON LATEST MAC OS X).
+#CFLAGS="-O0" PATH="$CHECKERDIR:$PATH" scan-build -o analysis ../configure
 
 rm -rf analysis
 PATH="$CHECKERDIR:$PATH" scan-build -o analysis $MAKE
--- a/cmake/sdlchecks.cmake	Fri Aug 08 15:14:09 2014 -0300
+++ b/cmake/sdlchecks.cmake	Wed Aug 20 17:20:22 2014 -0300
@@ -917,3 +917,32 @@
     set(CMAKE_REQUIRED_FLAGS)
   endif(HAVE_USBHID)
 endmacro(CheckUSBHID)
+
+# Requires:
+# - n/a
+macro(CheckRPI)
+  if(VIDEO_RPI)
+    set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
+    set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
+    set(VIDEO_RPI_LIBS bcm_host )
+    listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
+    listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
+
+    set(CMAKE_REQUIRED_FLAGS "${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
+    set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBS}")
+    check_c_source_compiles("
+        #include <bcm_host.h>
+        int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
+    set(CMAKE_REQUIRED_FLAGS)
+    set(CMAKE_REQUIRED_LIBRARIES)
+
+    if(SDL_VIDEO AND HAVE_VIDEO_RPI)
+      set(HAVE_SDL_VIDEO TRUE)
+      set(SDL_VIDEO_DRIVER_RPI 1)
+      file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
+      set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES})
+      list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBS})
+      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
+    endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
+  endif(VIDEO_RPI)
+endmacro(CheckRPI)
--- a/docs/README-android.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-android.md	Wed Aug 20 17:20:22 2014 -0300
@@ -18,9 +18,9 @@
 
 - Android applications are Java-based, optionally with parts written in C
 - As SDL apps are C-based, we use a small Java shim that uses JNI to talk to 
-the SDL library
+  the SDL library
 - This means that your application C code must be placed inside an Android 
-Java project, along with some C support code that communicates with Java
+  Java project, along with some C support code that communicates with Java
 - This eventually produces a standard Android .apk package
 
 The Android Java code implements an "Activity" and can be found in:
@@ -42,15 +42,15 @@
 
 There's two ways of using it:
 
-androidbuild.sh com.yourcompany.yourapp < sources.list
-androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
+    androidbuild.sh com.yourcompany.yourapp < sources.list
+    androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
 
 sources.list should be a text file with a source file name in each line
 Filenames should be specified relative to the current directory, for example if
 you are in the build-scripts directory and want to create the testgles.c test, you'll
 run:
-    
-./androidbuild.sh org.libsdl.testgles ../test/testgles.c
+
+    ./androidbuild.sh org.libsdl.testgles ../test/testgles.c
 
 One limitation of this script is that all sources provided will be aggregated into
 a single directory, thus all your source files should have a unique name.
@@ -74,40 +74,42 @@
 If you want to use the Eclipse IDE, skip to the Eclipse section below.
 
 5. Create <project>/local.properties and use that to point to the Android SDK directory, by writing a line with the following form:
-sdk.dir=PATH_TO_ANDROID_SDK
+
+       sdk.dir=PATH_TO_ANDROID_SDK
+
 6. Run 'ant debug' in android/project. This compiles the .java and eventually 
    creates a .apk with the native code embedded
 7. 'ant debug install' will push the apk to the device or emulator (if connected)
 
 Here's an explanation of the files in the Android project, so you can customize them:
 
-android-project/
-	AndroidManifest.xml	- package manifest. Among others, it contains the class name
-				  of the main Activity and the package name of the application.
-	build.properties	- empty
-	build.xml		- build description file, used by ant. The actual application name
-				  is specified here.
-	default.properties	- holds the target ABI for the application, android-10 and up
-	project.properties	- holds the target ABI for the application, android-10 and up
-	local.properties	- holds the SDK path, you should change this to the path to your SDK
-	jni/			- directory holding native code
-	jni/Android.mk		- Android makefile that can call recursively the Android.mk files
-				  in all subdirectories
-	jni/SDL/		- (symlink to) directory holding the SDL library files
-	jni/SDL/Android.mk	- Android makefile for creating the SDL shared library
-	jni/src/		- directory holding your C/C++ source
-	jni/src/Android.mk	- Android makefile that you should customize to include your 
+    android-project/
+        AndroidManifest.xml	- package manifest. Among others, it contains the class name
+        			  of the main Activity and the package name of the application.
+        build.properties	- empty
+        build.xml		- build description file, used by ant. The actual application name
+        			  is specified here.
+        default.properties	- holds the target ABI for the application, android-10 and up
+        project.properties	- holds the target ABI for the application, android-10 and up
+        local.properties	- holds the SDK path, you should change this to the path to your SDK
+        jni/			- directory holding native code
+        jni/Android.mk		- Android makefile that can call recursively the Android.mk files
+        			  in all subdirectories
+        jni/SDL/		- (symlink to) directory holding the SDL library files
+        jni/SDL/Android.mk	- Android makefile for creating the SDL shared library
+        jni/src/		- directory holding your C/C++ source
+        jni/src/Android.mk	- Android makefile that you should customize to include your 
                                   source code and any library references
-	res/			- directory holding resources for your application
-	res/drawable-*		- directories holding icons for different phone hardware. Could be
-				  one dir called "drawable".
-	res/layout/main.xml	- Usually contains a file main.xml, which declares the screen layout.
-				  We don't need it because we use the SDL video output.
-	res/values/strings.xml	- strings used in your application, including the application name
-				  shown on the phone.
-	src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding
-				  to SDL.  Be very careful changing this, as the SDL library relies
-				  on this implementation.
+        res/			- directory holding resources for your application
+        res/drawable-*		- directories holding icons for different phone hardware. Could be
+        			  one dir called "drawable".
+        res/layout/main.xml	- Usually contains a file main.xml, which declares the screen layout.
+        			  We don't need it because we use the SDL video output.
+        res/values/strings.xml	- strings used in your application, including the application name
+        			  shown on the phone.
+        src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding
+        			  to SDL.  Be very careful changing this, as the SDL library relies
+        			  on this implementation.
 
 
 ================================================================================
@@ -125,10 +127,10 @@
 4. create and export an environment variable named NDK_MODULE_PATH that points
    to the parent directory of this SDL directory. e.g.:
 
-   export NDK_MODULE_PATH="$PWD"/..
+       export NDK_MODULE_PATH="$PWD"/..
 
 5. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to
-   System.loadLibrary("SDL2") line 42.
+   System.loadLibrary("SDL2").
 6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
 
 
@@ -141,21 +143,23 @@
 
 Then create a Java class extending SDLActivity and place it in a directory
 under src matching your package, e.g.
-	src/com/gamemaker/game/MyGame.java
+
+    src/com/gamemaker/game/MyGame.java
 
 Here's an example of a minimal class file:
---- MyGame.java --------------------------
-package com.gamemaker.game;
 
-import org.libsdl.app.SDLActivity; 
-
-/* 
- * A sample wrapper class that just calls SDLActivity 
- */ 
-
-public class MyGame extends SDLActivity { }
-
-------------------------------------------
+    --- MyGame.java --------------------------
+    package com.gamemaker.game;
+    
+    import org.libsdl.app.SDLActivity; 
+    
+    /**
+     * A sample wrapper class that just calls SDLActivity 
+     */ 
+    
+    public class MyGame extends SDLActivity { }
+    
+    ------------------------------------------
 
 Then replace "SDLActivity" in AndroidManifest.xml with the name of your
 class, .e.g. "MyGame"
@@ -182,9 +186,9 @@
 
 There are also a few Android specific functions that allow you to get other
 useful paths for saving and loading data:
-SDL_AndroidGetInternalStoragePath()
-SDL_AndroidGetExternalStorageState()
-SDL_AndroidGetExternalStoragePath()
+* SDL_AndroidGetInternalStoragePath()
+* SDL_AndroidGetExternalStorageState()
+* SDL_AndroidGetExternalStoragePath()
 
 See SDL_system.h for more details on these functions.
 
@@ -226,11 +230,12 @@
 
 For a quick tour on how Linux native threads interoperate with the Java VM, take
 a look here: http://developer.android.com/guide/practices/jni.html
+
 If you want to use threads in your SDL app, it's strongly recommended that you
 do so by creating them using SDL functions. This way, the required attach/detach
 handling is managed by SDL automagically. If you have threads created by other
 means and they make calls to SDL functions, make sure that you call
-Android_JNI_SetupThread before doing anything else otherwise SDL will attach
+Android_JNI_SetupThread() before doing anything else otherwise SDL will attach
 your thread automatically anyway (when you make an SDL call), but it'll never
 detach it.
 
@@ -240,7 +245,8 @@
 
 You can use STL in your project by creating an Application.mk file in the jni
 folder and adding the following line:
-APP_STL := stlport_static
+
+    APP_STL := stlport_static
 
 For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
 
@@ -266,7 +272,7 @@
  * Select the Android -> Android Project wizard and click Next
  * Enter the name you'd like your project to have
  * Select "Create project from existing source" and browse for your project directory
- * Make sure the Build Target is set to Android 2.0
+ * Make sure the Build Target is set to Android 3.1 (API 12)
  * Click Finish
 
 
@@ -290,49 +296,61 @@
  * Window -> Android SDK and AVD Manager
 
 You can see if adb can see any devices with the following command:
-	adb devices
+
+    adb devices
 
 You can see the output of log messages on the default device with:
-	adb logcat
+
+    adb logcat
 
 You can push files to the device with:
-	adb push local_file remote_path_and_file
+
+    adb push local_file remote_path_and_file
 
 You can push files to the SD Card at /sdcard, for example:
-	adb push moose.dat /sdcard/moose.dat
+
+    adb push moose.dat /sdcard/moose.dat
 
 You can see the files on the SD card with a shell command:
-	adb shell ls /sdcard/
+
+    adb shell ls /sdcard/
 
 You can start a command shell on the default device with:
-	adb shell
+
+    adb shell
 
 You can remove the library files of your project (and not the SDL lib files) with:
-	ndk-build clean
+
+    ndk-build clean
 
 You can do a build with the following command:
-	ndk-build
+
+    ndk-build
 
 You can see the complete command line that ndk-build is using by passing V=1 on the command line:
-	ndk-build V=1
+
+    ndk-build V=1
 
 If your application crashes in native code, you can use addr2line to convert the
 addresses in the stack trace to lines in your code.
 
 For example, if your crash looks like this:
-I/DEBUG   (   31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
-I/DEBUG   (   31):  r0 00000000  r1 00001000  r2 00000003  r3 400085d4
-I/DEBUG   (   31):  r4 400085d0  r5 40008000  r6 afd41504  r7 436c6a7c
-I/DEBUG   (   31):  r8 436c6b30  r9 435c6fb0  10 435c6f9c  fp 4168d82c
-I/DEBUG   (   31):  ip 8346aff0  sp 436c6a60  lr afd1c8ff  pc afd1c902  cpsr 60000030
-I/DEBUG   (   31):          #00  pc 0001c902  /system/lib/libc.so
-I/DEBUG   (   31):          #01  pc 0001ccf6  /system/lib/libc.so
-I/DEBUG   (   31):          #02  pc 000014bc  /data/data/org.libsdl.app/lib/libmain.so
-I/DEBUG   (   31):          #03  pc 00001506  /data/data/org.libsdl.app/lib/libmain.so
+
+    I/DEBUG   (   31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
+    I/DEBUG   (   31):  r0 00000000  r1 00001000  r2 00000003  r3 400085d4
+    I/DEBUG   (   31):  r4 400085d0  r5 40008000  r6 afd41504  r7 436c6a7c
+    I/DEBUG   (   31):  r8 436c6b30  r9 435c6fb0  10 435c6f9c  fp 4168d82c
+    I/DEBUG   (   31):  ip 8346aff0  sp 436c6a60  lr afd1c8ff  pc afd1c902  cpsr 60000030
+    I/DEBUG   (   31):          #00  pc 0001c902  /system/lib/libc.so
+    I/DEBUG   (   31):          #01  pc 0001ccf6  /system/lib/libc.so
+    I/DEBUG   (   31):          #02  pc 000014bc  /data/data/org.libsdl.app/lib/libmain.so
+    I/DEBUG   (   31):          #03  pc 00001506  /data/data/org.libsdl.app/lib/libmain.so
 
 You can see that there's a crash in the C library being called from the main code.
 I run addr2line with the debug version of my code:
-	arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
+
+    arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
+
 and then paste in the number after "pc" in the call stack, from the line that I care about:
 000014bc
 
@@ -340,13 +358,14 @@
 
 You can add logging to your code to help show what's happening:
 
-#include <android/log.h>
-
-	__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
+    #include <android/log.h>
+    
+    __android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
 
 If you need to build without optimization turned on, you can create a file called
 "Application.mk" in the jni directory, with the following line in it:
-APP_OPTIM := debug
+
+    APP_OPTIM := debug
 
 
 ================================================================================
@@ -355,7 +374,9 @@
 
 The best (and slowest) way to debug memory issues on Android is valgrind.
 Valgrind has support for Android out of the box, just grab code using:
-	svn co svn://svn.valgrind.org/valgrind/trunk valgrind
+
+    svn co svn://svn.valgrind.org/valgrind/trunk valgrind
+
 ... and follow the instructions in the file README.android to build it.
 
 One thing I needed to do on Mac OS X was change the path to the toolchain,
@@ -364,20 +385,24 @@
 
 Once valgrind is built, you can create a wrapper script to launch your
 application with it, changing org.libsdl.app to your package identifier:
---- start_valgrind_app -------------------
-#!/system/bin/sh
-export TMPDIR=/data/data/org.libsdl.app
-exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
-------------------------------------------
+
+    --- start_valgrind_app -------------------
+    #!/system/bin/sh
+    export TMPDIR=/data/data/org.libsdl.app
+    exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
+    ------------------------------------------
 
 Then push it to the device:
-	adb push start_valgrind_app /data/local
+
+    adb push start_valgrind_app /data/local
 
 and make it executable:
-	adb shell chmod 755 /data/local/start_valgrind_app
+
+    adb shell chmod 755 /data/local/start_valgrind_app
 
 and tell Android to use the script to launch your application:
-	adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
+
+    adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
 
 If the setprop command says "could not set property", it's likely that
 your package name is too long and you should make it shorter by changing
@@ -387,10 +412,12 @@
 You can monitor the startup process with the logcat command above, and
 when it's done (or even while it's running) you can grab the valgrind
 output file:
-	adb pull /sdcard/valgrind.log
+
+    adb pull /sdcard/valgrind.log
 
 When you're done instrumenting with valgrind, you can disable the wrapper:
-	adb shell setprop wrap.org.libsdl.app ""
+
+    adb shell setprop wrap.org.libsdl.app ""
 
 ================================================================================
  Why is API level 10 the minimum required?
--- a/docs/README-cmake.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-cmake.md	Wed Aug 20 17:20:22 2014 -0300
@@ -10,22 +10,23 @@
 without complication.
 While still experimental, the build system should be usable on the following
 platforms:
-    
-    * FreeBSD
-    * Linux
-    * VS.NET 2010
-    * MinGW and Msys
-    * OS X with support for XCode
-    
+
+* FreeBSD
+* Linux
+* VS.NET 2010
+* MinGW and Msys
+* OS X with support for XCode
+
+
 ================================================================================
 Usage
 ================================================================================
 
 Assuming the source for SDL is located at ~/sdl
 
-cd ~
-mkdir build
-cd build
-cmake ../sdl
+    cd ~
+    mkdir build
+    cd build
+    cmake ../sdl
 
 This will build the static and dynamic versions of SDL in the ~/build directory.
--- a/docs/README-directfb.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-directfb.md	Wed Aug 20 17:20:22 2014 -0300
@@ -11,9 +11,9 @@
 
 What you need:
 
-DirectFB 1.0.1, 1.2.x, 1.3.0
-Kernel-Framebuffer support: required: vesafb, radeonfb .... 
-Mesa 7.0.x	   - optional for OpenGL
+* DirectFB 1.0.1, 1.2.x, 1.3.0
+* Kernel-Framebuffer support: required: vesafb, radeonfb .... 
+* Mesa 7.0.x	   - optional for OpenGL
 
 /etc/directfbrc
 
--- a/docs/README-gesture.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-gesture.md	Wed Aug 20 17:20:22 2014 -0300
@@ -14,18 +14,18 @@
 Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
 A SDL_DOLLARRECORD event is a dgesture with the following fields:
 
-event.dgesture.touchId   - the Id of the touch used to record the gesture.
-event.dgesture.gestureId - the unique id of the recorded gesture.
+* event.dgesture.touchId   - the Id of the touch used to record the gesture.
+* event.dgesture.gestureId - the unique id of the recorded gesture.
 
 
 Performing:
 -----------
 As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
 
-event.dgesture.touchId    - the Id of the touch which performed the gesture.
-event.dgesture.gestureId  - the unique id of the closest gesture to the performed stroke.
-event.dgesture.error      - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
-event.dgesture.numFingers - the number of fingers used to draw the stroke.
+* event.dgesture.touchId    - the Id of the touch which performed the gesture.
+* event.dgesture.gestureId  - the unique id of the closest gesture to the performed stroke.
+* event.dgesture.error      - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
+* event.dgesture.numFingers - the number of fingers used to draw the stroke.
 
 Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
 
@@ -54,12 +54,12 @@
 SDL provides simple support for pinch/rotate/swipe gestures. 
 Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
 
-event.mgesture.touchId - the Id of the touch on which the gesture was performed.
-event.mgesture.x       - the normalized x coordinate of the gesture. (0..1)
-event.mgesture.y       - the normalized y coordinate of the gesture. (0..1)
-event.mgesture.dTheta  - the amount that the fingers rotated during this motion.
-event.mgesture.dDist   - the amount that the fingers pinched during this motion.
-event.mgesture.numFingers - the number of fingers used in the gesture.
+* event.mgesture.touchId - the Id of the touch on which the gesture was performed.
+* event.mgesture.x       - the normalized x coordinate of the gesture. (0..1)
+* event.mgesture.y       - the normalized y coordinate of the gesture. (0..1)
+* event.mgesture.dTheta  - the amount that the fingers rotated during this motion.
+* event.mgesture.dDist   - the amount that the fingers pinched during this motion.
+* event.mgesture.numFingers - the number of fingers used in the gesture.
 
 
 ===========================================================================
--- a/docs/README-hg.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-hg.md	Wed Aug 20 17:20:22 2014 -0300
@@ -9,7 +9,7 @@
 information on using hg, where you can also download software for
 Mac OS X, Windows, and Unix systems.
 
-  hg clone http://hg.libsdl.org/SDL
+    hg clone http://hg.libsdl.org/SDL
 
 If you are building SDL with an IDE, you will need to copy the file
 include/SDL_config.h.default to include/SDL_config.h before building.
@@ -18,7 +18,6 @@
 before running configure.
 
 There is a web interface to the subversion repository at:
-
 	http://hg.libsdl.org/SDL/
 
 There is an RSS feed available at that URL, for those that want to
--- a/docs/README-ios.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-ios.md	Wed Aug 20 17:20:22 2014 -0300
@@ -14,11 +14,12 @@
 There are three build targets:
 - libSDL.a:
 	Build SDL as a statically linked library
-- testsdl
+- testsdl:
 	Build a test program (there are known test failures which are fine)
 - Template:
 	Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers.  The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen.
 
+
 ==============================================================================
 Build SDL for iOS from the command line
 ==============================================================================
@@ -47,8 +48,8 @@
 
 Here is the easiest method:
 1.  Build the SDL libraries (libSDL.a and libSDLSimulator.a) and the iPhone SDL Application template.
-1.  Install the iPhone SDL Application template by copying it to one of XCode's template directories.  I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/XCode/Project Templates/" and placing it there.
-2.  Start a new project using the template.  The project should be immediately ready for use with SDL.
+2.  Install the iPhone SDL Application template by copying it to one of XCode's template directories.  I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/XCode/Project Templates/" and placing it there.
+3.  Start a new project using the template.  The project should be immediately ready for use with SDL.
 
 Here is a more manual method:
 1.  Create a new iPhone view based application.
@@ -57,6 +58,7 @@
 4.  Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iPhone provides its own UIApplicationDelegate.  Remove MainWindow.xib -- SDL for iPhone produces its user interface programmatically.
 5.  Delete the contents of main.m and program your app as a regular SDL program instead.  You may replace main.m with your own main.c, but you must tell XCode not to use the project prefix file, as it includes Objective-C code.
 
+
 ==============================================================================
 Notes -- Application events
 ==============================================================================
@@ -68,56 +70,56 @@
 
 e.g.
 
-int HandleAppEvents(void *userdata, SDL_Event *event)
-{
-    switch (event->type)
+    int HandleAppEvents(void *userdata, SDL_Event *event)
     {
-    case SDL_APP_TERMINATING:
-        /* Terminate the app.
-           Shut everything down before returning from this function.
-        */
-        return 0;
-    case SDL_APP_LOWMEMORY:
-        /* You will get this when your app is paused and iOS wants more memory.
-           Release as much memory as possible.
-        */
-        return 0;
-    case SDL_APP_WILLENTERBACKGROUND:
-        /* Prepare your app to go into the background.  Stop loops, etc.
-           This gets called when the user hits the home button, or gets a call.
-        */
+        switch (event->type)
+        {
+        case SDL_APP_TERMINATING:
+            /* Terminate the app.
+               Shut everything down before returning from this function.
+            */
+            return 0;
+        case SDL_APP_LOWMEMORY:
+            /* You will get this when your app is paused and iOS wants more memory.
+               Release as much memory as possible.
+            */
+            return 0;
+        case SDL_APP_WILLENTERBACKGROUND:
+            /* Prepare your app to go into the background.  Stop loops, etc.
+               This gets called when the user hits the home button, or gets a call.
+            */
+            return 0;
+        case SDL_APP_DIDENTERBACKGROUND:
+            /* This will get called if the user accepted whatever sent your app to the background.
+               If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
+               When you get this, you have 5 seconds to save all your state or the app will be terminated.
+               Your app is NOT active at this point.
+            */
+            return 0;
+        case SDL_APP_WILLENTERFOREGROUND:
+            /* This call happens when your app is coming back to the foreground.
+               Restore all your state here.
+            */
+            return 0;
+        case SDL_APP_DIDENTERFOREGROUND:
+            /* Restart your loops here.
+               Your app is interactive and getting CPU again.
+            */
+            return 0;
+        default:
+            /* No special processing, add it to the event queue */
+            return 1;
+        }
+    }
+    
+    int main(int argc, char *argv[])
+    {
+        SDL_SetEventFilter(HandleAppEvents, NULL);
+    
+        ... run your main loop
+    
         return 0;
-    case SDL_APP_DIDENTERBACKGROUND:
-        /* This will get called if the user accepted whatever sent your app to the background.
-           If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
-           When you get this, you have 5 seconds to save all your state or the app will be terminated.
-           Your app is NOT active at this point.
-        */
-        return 0;
-    case SDL_APP_WILLENTERFOREGROUND:
-        /* This call happens when your app is coming back to the foreground.
-           Restore all your state here.
-        */
-        return 0;
-    case SDL_APP_DIDENTERFOREGROUND:
-        /* Restart your loops here.
-           Your app is interactive and getting CPU again.
-        */
-        return 0;
-    default:
-        /* No special processing, add it to the event queue */
-        return 1;
     }
-}
-
-int main(int argc, char *argv[])
-{
-    SDL_SetEventFilter(HandleAppEvents, NULL);
-
-    ... run your main loop
-
-    return 0;
-}
 
     
 ==============================================================================
@@ -148,11 +150,14 @@
 
 void SDL_StartTextInput()
 	-- enables text events and reveals the onscreen keyboard.
+
 void SDL_StopTextInput()
 	-- disables text events and hides the onscreen keyboard.
+
 SDL_bool SDL_IsTextInputActive()
 	-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
 
+
 ==============================================================================
 Notes -- Reading and Writing files
 ==============================================================================
@@ -161,12 +166,12 @@
 
 Once your application is installed its directory tree looks like:
 
-MySDLApp Home/
-	MySDLApp.app
-	Documents/
-	Library/
-		Preferences/
-	tmp/
+    MySDLApp Home/
+        MySDLApp.app
+        Documents/
+        Library/
+            Preferences/
+        tmp/
 
 When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored.  You cannot write to this directory.  Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".  
 
@@ -191,35 +196,35 @@
 ==============================================================================
 
 Game Center integration requires that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
-    
-int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
+
+    int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
 
 This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
 
 e.g.
 
-extern "C"
-void ShowFrame(void*)
-{
-    ... do event handling, frame logic and rendering
-}
-
-int main(int argc, char *argv[])
-{
-   ... initialize game ...
-
-#if __IPHONEOS__
+    extern "C"
+    void ShowFrame(void*)
+    {
+        ... do event handling, frame logic and rendering ...
+    }
+    
+    int main(int argc, char *argv[])
+    {
+        ... initialize game ...
+    
+    #if __IPHONEOS__
         // Initialize the Game Center for scoring and matchmaking
         InitGameCenter();
-
+    
         // Set up the game to run in the window animation callback on iOS
         // so that Game Center and so forth works correctly.
         SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
-#else
+    #else
         while ( running ) {
-                ShowFrame(0);
-                DelayFrame();
+            ShowFrame(0);
+            DelayFrame();
         }
-#endif
+    #endif
         return 0;
-}
+    }
--- a/docs/README-macosx.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-macosx.md	Wed Aug 20 17:20:22 2014 -0300
@@ -45,28 +45,29 @@
   file with the app. To solve these issues, put the following code in your 
   NSApplicationDelegate implementation:
 
-  - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
-  {
-      if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
-          SDL_Event event;
-          event.type = SDL_QUIT;
-          SDL_PushEvent(&event);
-      }
 
-      return NSTerminateCancel;
-  }
-
-  - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
-  {
-      if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
-          SDL_Event event;
-          event.type = SDL_DROPFILE;
-          event.drop.file = SDL_strdup([filename UTF8String]);
-          return (SDL_PushEvent(&event) > 0);
-      }
-
-      return NO;
-  }
+    - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
+    {
+        if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
+            SDL_Event event;
+            event.type = SDL_QUIT;
+            SDL_PushEvent(&event);
+        }
+    
+        return NSTerminateCancel;
+    }
+    
+    - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
+    {
+        if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
+            SDL_Event event;
+            event.type = SDL_DROPFILE;
+            event.drop.file = SDL_strdup([filename UTF8String]);
+            return (SDL_PushEvent(&event) > 0);
+        }
+    
+        return NO;
+    }
 
 ==============================================================================
 Using the Simple DirectMedia Layer with a traditional Makefile
--- a/docs/README-nacl.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-nacl.md	Wed Aug 20 17:20:22 2014 -0300
@@ -2,9 +2,9 @@
 ================================================================================
 
 Requirements: 
-    
-    * Native Client SDK (https://developer.chrome.com/native-client), 
-      (tested with Pepper version 33 or higher).
+
+* Native Client SDK (https://developer.chrome.com/native-client), 
+  (tested with Pepper version 33 or higher).
 
 The SDL backend for Chrome's Native Client has been tested only with the PNaCl
 toolchain, which generates binaries designed to run on ARM and x86_32/64 
@@ -91,9 +91,9 @@
 
 And add to manifest.json :
 
-  "permissions": [
-     "unlimitedStorage"
-  ]
+    "permissions": [
+        "unlimitedStorage"
+    ]
 
 ================================================================================
 TODO - Known Issues
--- a/docs/README-platforms.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-platforms.md	Wed Aug 20 17:20:22 2014 -0300
@@ -8,27 +8,27 @@
 ==============================
 (code compiles, and thoroughly tested for release)
 ==============================
-Windows XP/Vista/7/8
-Mac OS X 10.5+
-Linux 2.6+
-iOS 5.1.1+
-Android 2.3.3+
+* Windows XP/Vista/7/8
+* Mac OS X 10.5+
+* Linux 2.6+
+* iOS 5.1.1+
+* Android 2.3.3+
 
 Unofficially supported platforms
 ================================
 (code compiles, but not thoroughly tested)
 ================================
-FreeBSD
-NetBSD
-OpenBSD
-Solaris
+* FreeBSD
+* NetBSD
+* OpenBSD
+* Solaris
 
 Platforms supported by volunteers
 =================================
-Haiku - maintained by Axel Dörfler <axeld@pinc-software.de>
-PSP - maintained by 527721088@qq.com
-Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
-NaCl - maintained by Gabriel Jacobo <gabomdq@gmail.com>
+* Haiku - maintained by Axel Dörfler <axeld@pinc-software.de>
+* PSP - maintained by 527721088@qq.com
+* Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
+* NaCl - maintained by Gabriel Jacobo <gabomdq@gmail.com>
 
 Platforms that need maintainers
 ===============================
--- a/docs/README-raspberrypi.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-raspberrypi.md	Wed Aug 20 17:20:22 2014 -0300
@@ -15,6 +15,7 @@
 * Input (mouse/keyboard/joystick) via EVDEV
 * Hotplugging of input devices via UDEV
 
+
 ================================================================================
  Raspbian Build Dependencies
 ================================================================================
--- a/docs/README-touch.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README-touch.md	Wed Aug 20 17:20:22 2014 -0300
@@ -20,18 +20,18 @@
 SDL_FINGERDOWN:
 Sent when a finger (or stylus) is placed on a touch device.
 Fields:
-event.tfinger.touchId  - the Id of the touch device.
-event.tfinger.fingerId - the Id of the finger which just went down.
-event.tfinger.x        - the x coordinate of the touch (0..1)
-event.tfinger.y        - the y coordinate of the touch (0..1)
-event.tfinger.pressure - the pressure of the touch (0..1)
+* event.tfinger.touchId  - the Id of the touch device.
+* event.tfinger.fingerId - the Id of the finger which just went down.
+* event.tfinger.x        - the x coordinate of the touch (0..1)
+* event.tfinger.y        - the y coordinate of the touch (0..1)
+* event.tfinger.pressure - the pressure of the touch (0..1)
 
 SDL_FINGERMOTION:
 Sent when a finger (or stylus) is moved on the touch device.
 Fields:
 Same as SDL_FINGERDOWN but with additional:
-event.tfinger.dx       - change in x coordinate during this motion event.
-event.tfinger.dy       - change in y coordinate during this motion event.
+* event.tfinger.dx       - change in x coordinate during this motion event.
+* event.tfinger.dy       - change in y coordinate during this motion event.
 
 SDL_FINGERUP:
 Sent when a finger (or stylus) is lifted from the touch device.
@@ -70,11 +70,12 @@
 As a result, be very careful to check for NULL return values.
 
 A SDL_Finger has the following fields:
->x,y,pressure:
+* x,y,pressure:
 	The current coordinates of the touch.
->pressure:
+* pressure:
 	The pressure of the touch.
 
+
 ===========================================================================
 Notes
 ===========================================================================
--- a/docs/README.md	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/README.md	Wed Aug 20 17:20:22 2014 -0300
@@ -12,7 +12,7 @@
 to provide low level access to audio, keyboard, mouse, joystick, and graphics
 hardware via OpenGL and Direct3D. It is used by video playback software,
 emulators, and popular games including Valve's award winning catalog
-and many Humble Bundle games. 42
+and many Humble Bundle games.
 
 SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
 Support for other platforms may be found in the source code.
--- a/docs/doxyfile	Fri Aug 08 15:14:09 2014 -0300
+++ b/docs/doxyfile	Wed Aug 20 17:20:22 2014 -0300
@@ -1510,7 +1510,7 @@
 # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
 # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
 
-DOT_GRAPH_MAX_NODES    = 50
+DOT_GRAPH_MAX_NODES    = 60
 
 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
 # graphs generated by dot. A depth value of 3 means that only nodes reachable 
--- a/include/SDL_config.h.cmake	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_config.h.cmake	Wed Aug 20 17:20:22 2014 -0300
@@ -263,6 +263,7 @@
 #cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
 #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
 #cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
+#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
 
 #if 0
 /* !!! FIXME: in configure script version, missing here: */
--- a/include/SDL_config_android.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_config_android.h	Wed Aug 20 17:20:22 2014 -0300
@@ -141,7 +141,7 @@
 /* Enable system power support */
 #define SDL_POWER_ANDROID 1
 
-/* !!! FIXME: what does Android do for filesystem stuff? */
-#define SDL_FILESYSTEM_DUMMY   1
+/* Enable the filesystem driver */
+#define SDL_FILESYSTEM_ANDROID   1
 
 #endif /* _SDL_config_android_h */
--- a/include/SDL_egl.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_egl.h	Wed Aug 20 17:20:22 2014 -0300
@@ -20,9 +20,9 @@
 */
 
 /**
- *  \file SDL_opengles.h
+ *  \file SDL_egl.h
  *
- *  This is a simple file to encapsulate the OpenGL ES 2.0 API headers.
+ *  This is a simple file to encapsulate the EGL API headers.
  */
 #ifndef _MSC_VER
 
--- a/include/SDL_events.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_events.h	Wed Aug 20 17:20:22 2014 -0300
@@ -59,7 +59,7 @@
     /* Application events */
     SDL_QUIT           = 0x100, /**< User-requested quit */
 
-    /* These application events have special meaning on iOS, see README-ios.txt for details */
+    /* These application events have special meaning on iOS, see README-ios.md for details */
     SDL_APP_TERMINATING,        /**< The application is being terminated by the OS
                                      Called on iOS in applicationWillTerminate()
                                      Called on Android in onDestroy()
--- a/include/SDL_haptic.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_haptic.h	Wed Aug 20 17:20:22 2014 -0300
@@ -370,7 +370,7 @@
                          ^
                          |
                          |
-    (1,0)  West <----[ HAPTIC ]----> East (-1,0)
+   (-1,0)  West <----[ HAPTIC ]----> East (1,0)
                          |
                          |
                          v
@@ -395,9 +395,9 @@
  *  (X axis, Y axis and Z axis (with 3 axes)).  ::SDL_HAPTIC_CARTESIAN uses
  *  the first three \c dir parameters.  The cardinal directions would be:
  *   - North:  0,-1, 0
- *   - East:  -1, 0, 0
+ *   - East:   1, 0, 0
  *   - South:  0, 1, 0
- *   - West:   1, 0, 0
+ *   - West:  -1, 0, 0
  *
  *  The Z axis represents the height of the effect if supported, otherwise
  *  it's unused.  In cartesian encoding (1, 2) would be the same as (2, 4), you
@@ -604,11 +604,11 @@
     Uint16 interval;        /**< How soon it can be triggered again after button. */
 
     /* Condition */
-    Uint16 right_sat[3];    /**< Level when joystick is to the positive side. */
-    Uint16 left_sat[3];     /**< Level when joystick is to the negative side. */
+    Uint16 right_sat[3];    /**< Level when joystick is to the positive side; max 0xFFFF. */
+    Uint16 left_sat[3];     /**< Level when joystick is to the negative side; max 0xFFFF. */
     Sint16 right_coeff[3];  /**< How fast to increase the force towards the positive side. */
     Sint16 left_coeff[3];   /**< How fast to increase the force towards the negative side. */
-    Uint16 deadband[3];     /**< Size of the dead zone. */
+    Uint16 deadband[3];     /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */
     Sint16 center[3];       /**< Position of the dead zone. */
 } SDL_HapticCondition;
 
--- a/include/SDL_hints.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_hints.h	Wed Aug 20 17:20:22 2014 -0300
@@ -478,6 +478,18 @@
  */
 #define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"
 
+/**
+ * \brief A variable to control whether certain IMs should handle text editing internally instead of sending TEXTEDITING events.
+ *
+ *
+ * The variable can be set to the following values:
+ *   "0"       - TEXTEDITING events are sent, and it is the application's
+ *               responsibility to render the text from these events and 
+ *               differentiate it somehow from committed text. (default)
+ *   "1"       - If supported by the IM then TEXTEDITING events are not sent, 
+ *               and text that is being composed will be rendered in its own UI.
+ */
+#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING"
 
 /**
  *  \brief  An enumeration of hint priorities
--- a/include/SDL_opengl.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_opengl.h	Wed Aug 20 17:20:22 2014 -0300
@@ -25,50 +25,6 @@
  *  This is a simple file to encapsulate the OpenGL API headers.
  */
 
-#ifndef _SDL_opengl_h
-#define _SDL_opengl_h
-
-#include "SDL_config.h"
-
-#ifndef __IPHONEOS__
-
-#ifdef __WIN32__
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#ifndef NOMINMAX
-#define NOMINMAX                /* Don't defined min() and max() */
-#endif
-#include <windows.h>
-#endif
-
-#ifdef __glext_h_
-/* Someone has already included glext.h */
-#define NO_SDL_GLEXT
-#else
-#define _SDL_CLEAR_GLEXT_HEADERGUARD
-#define __glext_h_              /* Don't let gl.h include glext.h */
-#endif
-#if defined(__MACOSX__)
-#include <OpenGL/gl.h>          /* Header File For The OpenGL Library */
-#define __X_GL_H
-#else
-#include <GL/gl.h>              /* Header File For The OpenGL Library */
-#endif
-#ifdef _SDL_CLEAR_GLEXT_HEADERGUARD
-#undef __glext_h_
-#endif
-
-/**
- *  \file SDL_opengl.h
- *
- *  This file is included because glext.h is not available on some systems.
- *  If you don't want this version included, simply define ::NO_SDL_GLEXT.
- *
- *  The latest version is available from:
- *      http://www.opengl.org/registry/
- */
-
 /**
  *  \def NO_SDL_GLEXT
  *
@@ -76,9 +32,2142 @@
  *  version included in SDL_opengl.h.
  */
 
+#ifndef _SDL_opengl_h
+#define _SDL_opengl_h
+
+#include "SDL_config.h"
+
+#ifndef __IPHONEOS__  /* No OpenGL on iOS. */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef __gl_h_
+#define __gl_h_
+
+#if defined(USE_MGL_NAMESPACE)
+#include "gl_mangle.h"
+#endif
+
+
+/**********************************************************************
+ * Begin system-specific stuff.
+ */
+
+#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
+#define __WIN32__
+#endif
+
+#if defined(__WIN32__) && !defined(__CYGWIN__)
+#  if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
+#    define GLAPI __declspec(dllexport)
+#  elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
+#    define GLAPI __declspec(dllimport)
+#  else /* for use with static link lib build of Win32 edition only */
+#    define GLAPI extern
+#  endif /* _STATIC_MESA support */
+#  if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE)  /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */
+#    define GLAPIENTRY 
+#  else
+#    define GLAPIENTRY __stdcall
+#  endif
+#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */
+#  define GLAPI extern
+#  define GLAPIENTRY __stdcall
+#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#  define GLAPI __attribute__((visibility("default")))
+#  define GLAPIENTRY
+#endif /* WIN32 && !CYGWIN */
+
+/*
+ * WINDOWS: Include windows.h here to define APIENTRY.
+ * It is also useful when applications include this file by
+ * including only glut.h, since glut.h depends on windows.h.
+ * Applications needing to include windows.h with parms other
+ * than "WIN32_LEAN_AND_MEAN" may include windows.h before
+ * glut.h or gl.h.
+ */
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#ifndef NOMINMAX   /* don't define min() and max(). */
+#define NOMINMAX
+#endif
+#include <windows.h>
+#endif
+
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY GLAPIENTRY
+#endif
+
+/* "P" suffix to be used for a pointer to a function */
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+
+#ifndef GLAPIENTRYP
+#define GLAPIENTRYP GLAPIENTRY *
+#endif
+
+#if defined(PRAGMA_EXPORT_SUPPORTED)
+#pragma export on
+#endif
+
+/*
+ * End system-specific stuff.
+ **********************************************************************/
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#define GL_VERSION_1_1   1
+#define GL_VERSION_1_2   1
+#define GL_VERSION_1_3   1
+#define GL_ARB_imaging   1
+
+
+/*
+ * Datatypes
+ */
+typedef unsigned int	GLenum;
+typedef unsigned char	GLboolean;
+typedef unsigned int	GLbitfield;
+typedef void		GLvoid;
+typedef signed char	GLbyte;		/* 1-byte signed */
+typedef short		GLshort;	/* 2-byte signed */
+typedef int		GLint;		/* 4-byte signed */
+typedef unsigned char	GLubyte;	/* 1-byte unsigned */
+typedef unsigned short	GLushort;	/* 2-byte unsigned */
+typedef unsigned int	GLuint;		/* 4-byte unsigned */
+typedef int		GLsizei;	/* 4-byte signed */
+typedef float		GLfloat;	/* single precision float */
+typedef float		GLclampf;	/* single precision float in [0,1] */
+typedef double		GLdouble;	/* double precision float */
+typedef double		GLclampd;	/* double precision float in [0,1] */
+
+
+
+/*
+ * Constants
+ */
+
+/* Boolean values */
+#define GL_FALSE				0
+#define GL_TRUE					1
+
+/* Data types */
+#define GL_BYTE					0x1400
+#define GL_UNSIGNED_BYTE			0x1401
+#define GL_SHORT				0x1402
+#define GL_UNSIGNED_SHORT			0x1403
+#define GL_INT					0x1404
+#define GL_UNSIGNED_INT				0x1405
+#define GL_FLOAT				0x1406
+#define GL_2_BYTES				0x1407
+#define GL_3_BYTES				0x1408
+#define GL_4_BYTES				0x1409
+#define GL_DOUBLE				0x140A
+
+/* Primitives */
+#define GL_POINTS				0x0000
+#define GL_LINES				0x0001
+#define GL_LINE_LOOP				0x0002
+#define GL_LINE_STRIP				0x0003
+#define GL_TRIANGLES				0x0004
+#define GL_TRIANGLE_STRIP			0x0005
+#define GL_TRIANGLE_FAN				0x0006
+#define GL_QUADS				0x0007
+#define GL_QUAD_STRIP				0x0008
+#define GL_POLYGON				0x0009
+
+/* Vertex Arrays */
+#define GL_VERTEX_ARRAY				0x8074
+#define GL_NORMAL_ARRAY				0x8075
+#define GL_COLOR_ARRAY				0x8076
+#define GL_INDEX_ARRAY				0x8077
+#define GL_TEXTURE_COORD_ARRAY			0x8078
+#define GL_EDGE_FLAG_ARRAY			0x8079
+#define GL_VERTEX_ARRAY_SIZE			0x807A
+#define GL_VERTEX_ARRAY_TYPE			0x807B
+#define GL_VERTEX_ARRAY_STRIDE			0x807C
+#define GL_NORMAL_ARRAY_TYPE			0x807E
+#define GL_NORMAL_ARRAY_STRIDE			0x807F
+#define GL_COLOR_ARRAY_SIZE			0x8081
+#define GL_COLOR_ARRAY_TYPE			0x8082
+#define GL_COLOR_ARRAY_STRIDE			0x8083
+#define GL_INDEX_ARRAY_TYPE			0x8085
+#define GL_INDEX_ARRAY_STRIDE			0x8086
+#define GL_TEXTURE_COORD_ARRAY_SIZE		0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE		0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE		0x808A
+#define GL_EDGE_FLAG_ARRAY_STRIDE		0x808C
+#define GL_VERTEX_ARRAY_POINTER			0x808E
+#define GL_NORMAL_ARRAY_POINTER			0x808F
+#define GL_COLOR_ARRAY_POINTER			0x8090
+#define GL_INDEX_ARRAY_POINTER			0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER		0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER		0x8093
+#define GL_V2F					0x2A20
+#define GL_V3F					0x2A21
+#define GL_C4UB_V2F				0x2A22
+#define GL_C4UB_V3F				0x2A23
+#define GL_C3F_V3F				0x2A24
+#define GL_N3F_V3F				0x2A25
+#define GL_C4F_N3F_V3F				0x2A26
+#define GL_T2F_V3F				0x2A27
+#define GL_T4F_V4F				0x2A28
+#define GL_T2F_C4UB_V3F				0x2A29
+#define GL_T2F_C3F_V3F				0x2A2A
+#define GL_T2F_N3F_V3F				0x2A2B
+#define GL_T2F_C4F_N3F_V3F			0x2A2C
+#define GL_T4F_C4F_N3F_V4F			0x2A2D
+
+/* Matrix Mode */
+#define GL_MATRIX_MODE				0x0BA0
+#define GL_MODELVIEW				0x1700
+#define GL_PROJECTION				0x1701
+#define GL_TEXTURE				0x1702
+
+/* Points */
+#define GL_POINT_SMOOTH				0x0B10
+#define GL_POINT_SIZE				0x0B11
+#define GL_POINT_SIZE_GRANULARITY 		0x0B13
+#define GL_POINT_SIZE_RANGE			0x0B12
+
+/* Lines */
+#define GL_LINE_SMOOTH				0x0B20
+#define GL_LINE_STIPPLE				0x0B24
+#define GL_LINE_STIPPLE_PATTERN			0x0B25
+#define GL_LINE_STIPPLE_REPEAT			0x0B26
+#define GL_LINE_WIDTH				0x0B21
+#define GL_LINE_WIDTH_GRANULARITY		0x0B23
+#define GL_LINE_WIDTH_RANGE			0x0B22
+
+/* Polygons */
+#define GL_POINT				0x1B00
+#define GL_LINE					0x1B01
+#define GL_FILL					0x1B02
+#define GL_CW					0x0900
+#define GL_CCW					0x0901
+#define GL_FRONT				0x0404
+#define GL_BACK					0x0405
+#define GL_POLYGON_MODE				0x0B40
+#define GL_POLYGON_SMOOTH			0x0B41
+#define GL_POLYGON_STIPPLE			0x0B42
+#define GL_EDGE_FLAG				0x0B43
+#define GL_CULL_FACE				0x0B44
+#define GL_CULL_FACE_MODE			0x0B45
+#define GL_FRONT_FACE				0x0B46
+#define GL_POLYGON_OFFSET_FACTOR		0x8038
+#define GL_POLYGON_OFFSET_UNITS			0x2A00
+#define GL_POLYGON_OFFSET_POINT			0x2A01
+#define GL_POLYGON_OFFSET_LINE			0x2A02
+#define GL_POLYGON_OFFSET_FILL			0x8037
+
+/* Display Lists */
+#define GL_COMPILE				0x1300
+#define GL_COMPILE_AND_EXECUTE			0x1301
+#define GL_LIST_BASE				0x0B32
+#define GL_LIST_INDEX				0x0B33
+#define GL_LIST_MODE				0x0B30
+
+/* Depth buffer */
+#define GL_NEVER				0x0200
+#define GL_LESS					0x0201
+#define GL_EQUAL				0x0202
+#define GL_LEQUAL				0x0203
+#define GL_GREATER				0x0204
+#define GL_NOTEQUAL				0x0205
+#define GL_GEQUAL				0x0206
+#define GL_ALWAYS				0x0207
+#define GL_DEPTH_TEST				0x0B71
+#define GL_DEPTH_BITS				0x0D56
+#define GL_DEPTH_CLEAR_VALUE			0x0B73
+#define GL_DEPTH_FUNC				0x0B74
+#define GL_DEPTH_RANGE				0x0B70
+#define GL_DEPTH_WRITEMASK			0x0B72
+#define GL_DEPTH_COMPONENT			0x1902
+
+/* Lighting */
+#define GL_LIGHTING				0x0B50
+#define GL_LIGHT0				0x4000
+#define GL_LIGHT1				0x4001
+#define GL_LIGHT2				0x4002
+#define GL_LIGHT3				0x4003
+#define GL_LIGHT4				0x4004
+#define GL_LIGHT5				0x4005
+#define GL_LIGHT6				0x4006
+#define GL_LIGHT7				0x4007
+#define GL_SPOT_EXPONENT			0x1205
+#define GL_SPOT_CUTOFF				0x1206
+#define GL_CONSTANT_ATTENUATION			0x1207
+#define GL_LINEAR_ATTENUATION			0x1208
+#define GL_QUADRATIC_ATTENUATION		0x1209
+#define GL_AMBIENT				0x1200
+#define GL_DIFFUSE				0x1201
+#define GL_SPECULAR				0x1202
+#define GL_SHININESS				0x1601
+#define GL_EMISSION				0x1600
+#define GL_POSITION				0x1203
+#define GL_SPOT_DIRECTION			0x1204
+#define GL_AMBIENT_AND_DIFFUSE			0x1602
+#define GL_COLOR_INDEXES			0x1603
+#define GL_LIGHT_MODEL_TWO_SIDE			0x0B52
+#define GL_LIGHT_MODEL_LOCAL_VIEWER		0x0B51
+#define GL_LIGHT_MODEL_AMBIENT			0x0B53
+#define GL_FRONT_AND_BACK			0x0408
+#define GL_SHADE_MODEL				0x0B54
+#define GL_FLAT					0x1D00
+#define GL_SMOOTH				0x1D01
+#define GL_COLOR_MATERIAL			0x0B57
+#define GL_COLOR_MATERIAL_FACE			0x0B55
+#define GL_COLOR_MATERIAL_PARAMETER		0x0B56
+#define GL_NORMALIZE				0x0BA1
+
+/* User clipping planes */
+#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
+
+/* Accumulation buffer */
+#define GL_ACCUM_RED_BITS			0x0D58
+#define GL_ACCUM_GREEN_BITS			0x0D59
+#define GL_ACCUM_BLUE_BITS			0x0D5A
+#define GL_ACCUM_ALPHA_BITS			0x0D5B
+#define GL_ACCUM_CLEAR_VALUE			0x0B80
+#define GL_ACCUM				0x0100
+#define GL_ADD					0x0104
+#define GL_LOAD					0x0101
+#define GL_MULT					0x0103
+#define GL_RETURN				0x0102
+
+/* Alpha testing */
+#define GL_ALPHA_TEST				0x0BC0
+#define GL_ALPHA_TEST_REF			0x0BC2
+#define GL_ALPHA_TEST_FUNC			0x0BC1
+
+/* Blending */
+#define GL_BLEND				0x0BE2
+#define GL_BLEND_SRC				0x0BE1
+#define GL_BLEND_DST				0x0BE0
+#define GL_ZERO					0
+#define GL_ONE					1
+#define GL_SRC_COLOR				0x0300
+#define GL_ONE_MINUS_SRC_COLOR			0x0301
+#define GL_SRC_ALPHA				0x0302
+#define GL_ONE_MINUS_SRC_ALPHA			0x0303
+#define GL_DST_ALPHA				0x0304
+#define GL_ONE_MINUS_DST_ALPHA			0x0305
+#define GL_DST_COLOR				0x0306
+#define GL_ONE_MINUS_DST_COLOR			0x0307
+#define GL_SRC_ALPHA_SATURATE			0x0308
+
+/* Render Mode */
+#define GL_FEEDBACK				0x1C01
+#define GL_RENDER				0x1C00
+#define GL_SELECT				0x1C02
+
+/* Feedback */
+#define GL_2D					0x0600
+#define GL_3D					0x0601
+#define GL_3D_COLOR				0x0602
+#define GL_3D_COLOR_TEXTURE			0x0603
+#define GL_4D_COLOR_TEXTURE			0x0604
+#define GL_POINT_TOKEN				0x0701
+#define GL_LINE_TOKEN				0x0702
+#define GL_LINE_RESET_TOKEN			0x0707
+#define GL_POLYGON_TOKEN			0x0703
+#define GL_BITMAP_TOKEN				0x0704
+#define GL_DRAW_PIXEL_TOKEN			0x0705
+#define GL_COPY_PIXEL_TOKEN			0x0706
+#define GL_PASS_THROUGH_TOKEN			0x0700
+#define GL_FEEDBACK_BUFFER_POINTER		0x0DF0
+#define GL_FEEDBACK_BUFFER_SIZE			0x0DF1
+#define GL_FEEDBACK_BUFFER_TYPE			0x0DF2
+
+/* Selection */
+#define GL_SELECTION_BUFFER_POINTER		0x0DF3
+#define GL_SELECTION_BUFFER_SIZE		0x0DF4
+
+/* Fog */
+#define GL_FOG					0x0B60
+#define GL_FOG_MODE				0x0B65
+#define GL_FOG_DENSITY				0x0B62
+#define GL_FOG_COLOR				0x0B66
+#define GL_FOG_INDEX				0x0B61
+#define GL_FOG_START				0x0B63
+#define GL_FOG_END				0x0B64
+#define GL_LINEAR				0x2601
+#define GL_EXP					0x0800
+#define GL_EXP2					0x0801
+
+/* Logic Ops */
+#define GL_LOGIC_OP				0x0BF1
+#define GL_INDEX_LOGIC_OP			0x0BF1
+#define GL_COLOR_LOGIC_OP			0x0BF2
+#define GL_LOGIC_OP_MODE			0x0BF0
+#define GL_CLEAR				0x1500
+#define GL_SET					0x150F
+#define GL_COPY					0x1503
+#define GL_COPY_INVERTED			0x150C
+#define GL_NOOP					0x1505
+#define GL_INVERT				0x150A
+#define GL_AND					0x1501
+#define GL_NAND					0x150E
+#define GL_OR					0x1507
+#define GL_NOR					0x1508
+#define GL_XOR					0x1506
+#define GL_EQUIV				0x1509
+#define GL_AND_REVERSE				0x1502
+#define GL_AND_INVERTED				0x1504
+#define GL_OR_REVERSE				0x150B
+#define GL_OR_INVERTED				0x150D
+
+/* Stencil */
+#define GL_STENCIL_BITS				0x0D57
+#define GL_STENCIL_TEST				0x0B90
+#define GL_STENCIL_CLEAR_VALUE			0x0B91
+#define GL_STENCIL_FUNC				0x0B92
+#define GL_STENCIL_VALUE_MASK			0x0B93
+#define GL_STENCIL_FAIL				0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL		0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS		0x0B96
+#define GL_STENCIL_REF				0x0B97
+#define GL_STENCIL_WRITEMASK			0x0B98
+#define GL_STENCIL_INDEX			0x1901
+#define GL_KEEP					0x1E00
+#define GL_REPLACE				0x1E01
+#define GL_INCR					0x1E02
+#define GL_DECR					0x1E03
+
+/* Buffers, Pixel Drawing/Reading */
+#define GL_NONE					0
+#define GL_LEFT					0x0406
+#define GL_RIGHT				0x0407
+/*GL_FRONT					0x0404 */
+/*GL_BACK					0x0405 */
+/*GL_FRONT_AND_BACK				0x0408 */
+#define GL_FRONT_LEFT				0x0400
+#define GL_FRONT_RIGHT				0x0401
+#define GL_BACK_LEFT				0x0402
+#define GL_BACK_RIGHT				0x0403
+#define GL_AUX0					0x0409
+#define GL_AUX1					0x040A
+#define GL_AUX2					0x040B
+#define GL_AUX3					0x040C
+#define GL_COLOR_INDEX				0x1900
+#define GL_RED					0x1903
+#define GL_GREEN				0x1904
+#define GL_BLUE					0x1905
+#define GL_ALPHA				0x1906
+#define GL_LUMINANCE				0x1909
+#define GL_LUMINANCE_ALPHA			0x190A
+#define GL_ALPHA_BITS				0x0D55
+#define GL_RED_BITS				0x0D52
+#define GL_GREEN_BITS				0x0D53
+#define GL_BLUE_BITS				0x0D54
+#define GL_INDEX_BITS				0x0D51
+#define GL_SUBPIXEL_BITS			0x0D50
+#define GL_AUX_BUFFERS				0x0C00
+#define GL_READ_BUFFER				0x0C02
+#define GL_DRAW_BUFFER				0x0C01
+#define GL_DOUBLEBUFFER				0x0C32
+#define GL_STEREO				0x0C33
+#define GL_BITMAP				0x1A00
+#define GL_COLOR				0x1800
+#define GL_DEPTH				0x1801
+#define GL_STENCIL				0x1802
+#define GL_DITHER				0x0BD0
+#define GL_RGB					0x1907
+#define GL_RGBA					0x1908
+
+/* Implementation limits */
+#define GL_MAX_LIST_NESTING			0x0B31
+#define GL_MAX_EVAL_ORDER			0x0D30
+#define GL_MAX_LIGHTS				0x0D31
+#define GL_MAX_CLIP_PLANES			0x0D32
+#define GL_MAX_TEXTURE_SIZE			0x0D33
+#define GL_MAX_PIXEL_MAP_TABLE			0x0D34
+#define GL_MAX_ATTRIB_STACK_DEPTH		0x0D35
+#define GL_MAX_MODELVIEW_STACK_DEPTH		0x0D36
+#define GL_MAX_NAME_STACK_DEPTH			0x0D37
+#define GL_MAX_PROJECTION_STACK_DEPTH		0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH		0x0D39
+#define GL_MAX_VIEWPORT_DIMS			0x0D3A
+#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH	0x0D3B
+
+/* Gets */
+#define GL_ATTRIB_STACK_DEPTH			0x0BB0
+#define GL_CLIENT_ATTRIB_STACK_DEPTH		0x0BB1
+#define GL_COLOR_CLEAR_VALUE			0x0C22
+#define GL_COLOR_WRITEMASK			0x0C23
+#define GL_CURRENT_INDEX			0x0B01
+#define GL_CURRENT_COLOR			0x0B00
+#define GL_CURRENT_NORMAL			0x0B02
+#define GL_CURRENT_RASTER_COLOR			0x0B04
+#define GL_CURRENT_RASTER_DISTANCE		0x0B09
+#define GL_CURRENT_RASTER_INDEX			0x0B05
+#define GL_CURRENT_RASTER_POSITION		0x0B07
+#define GL_CURRENT_RASTER_TEXTURE_COORDS	0x0B06
+#define GL_CURRENT_RASTER_POSITION_VALID	0x0B08
+#define GL_CURRENT_TEXTURE_COORDS		0x0B03
+#define GL_INDEX_CLEAR_VALUE			0x0C20
+#define GL_INDEX_MODE				0x0C30
+#define GL_INDEX_WRITEMASK			0x0C21
+#define GL_MODELVIEW_MATRIX			0x0BA6
+#define GL_MODELVIEW_STACK_DEPTH		0x0BA3
+#define GL_NAME_STACK_DEPTH			0x0D70
+#define GL_PROJECTION_MATRIX			0x0BA7
+#define GL_PROJECTION_STACK_DEPTH		0x0BA4
+#define GL_RENDER_MODE				0x0C40
+#define GL_RGBA_MODE				0x0C31
+#define GL_TEXTURE_MATRIX			0x0BA8
+#define GL_TEXTURE_STACK_DEPTH			0x0BA5
+#define GL_VIEWPORT				0x0BA2
+
+/* Evaluators */
+#define GL_AUTO_NORMAL				0x0D80
+#define GL_MAP1_COLOR_4				0x0D90
+#define GL_MAP1_INDEX				0x0D91
+#define GL_MAP1_NORMAL				0x0D92
+#define GL_MAP1_TEXTURE_COORD_1			0x0D93
+#define GL_MAP1_TEXTURE_COORD_2			0x0D94
+#define GL_MAP1_TEXTURE_COORD_3			0x0D95
+#define GL_MAP1_TEXTURE_COORD_4			0x0D96
+#define GL_MAP1_VERTEX_3			0x0D97
+#define GL_MAP1_VERTEX_4			0x0D98
+#define GL_MAP2_COLOR_4				0x0DB0
+#define GL_MAP2_INDEX				0x0DB1
+#define GL_MAP2_NORMAL				0x0DB2
+#define GL_MAP2_TEXTURE_COORD_1			0x0DB3
+#define GL_MAP2_TEXTURE_COORD_2			0x0DB4
+#define GL_MAP2_TEXTURE_COORD_3			0x0DB5
+#define GL_MAP2_TEXTURE_COORD_4			0x0DB6
+#define GL_MAP2_VERTEX_3			0x0DB7
+#define GL_MAP2_VERTEX_4			0x0DB8
+#define GL_MAP1_GRID_DOMAIN			0x0DD0
+#define GL_MAP1_GRID_SEGMENTS			0x0DD1
+#define GL_MAP2_GRID_DOMAIN			0x0DD2
+#define GL_MAP2_GRID_SEGMENTS			0x0DD3
+#define GL_COEFF				0x0A00
+#define GL_ORDER				0x0A01
+#define GL_DOMAIN				0x0A02
+
+/* Hints */
+#define GL_PERSPECTIVE_CORRECTION_HINT		0x0C50
+#define GL_POINT_SMOOTH_HINT			0x0C51
+#define GL_LINE_SMOOTH_HINT			0x0C52
+#define GL_POLYGON_SMOOTH_HINT			0x0C53
+#define GL_FOG_HINT				0x0C54
+#define GL_DONT_CARE				0x1100
+#define GL_FASTEST				0x1101
+#define GL_NICEST				0x1102
+
+/* Scissor box */
+#define GL_SCISSOR_BOX				0x0C10
+#define GL_SCISSOR_TEST				0x0C11
+
+/* Pixel Mode / Transfer */
+#define GL_MAP_COLOR				0x0D10
+#define GL_MAP_STENCIL				0x0D11
+#define GL_INDEX_SHIFT				0x0D12
+#define GL_INDEX_OFFSET				0x0D13
+#define GL_RED_SCALE				0x0D14
+#define GL_RED_BIAS				0x0D15
+#define GL_GREEN_SCALE				0x0D18
+#define GL_GREEN_BIAS				0x0D19
+#define GL_BLUE_SCALE				0x0D1A
+#define GL_BLUE_BIAS				0x0D1B
+#define GL_ALPHA_SCALE				0x0D1C
+#define GL_ALPHA_BIAS				0x0D1D
+#define GL_DEPTH_SCALE				0x0D1E
+#define GL_DEPTH_BIAS				0x0D1F
+#define GL_PIXEL_MAP_S_TO_S_SIZE		0x0CB1
+#define GL_PIXEL_MAP_I_TO_I_SIZE		0x0CB0
+#define GL_PIXEL_MAP_I_TO_R_SIZE		0x0CB2
+#define GL_PIXEL_MAP_I_TO_G_SIZE		0x0CB3
+#define GL_PIXEL_MAP_I_TO_B_SIZE		0x0CB4
+#define GL_PIXEL_MAP_I_TO_A_SIZE		0x0CB5
+#define GL_PIXEL_MAP_R_TO_R_SIZE		0x0CB6
+#define GL_PIXEL_MAP_G_TO_G_SIZE		0x0CB7
+#define GL_PIXEL_MAP_B_TO_B_SIZE		0x0CB8
+#define GL_PIXEL_MAP_A_TO_A_SIZE		0x0CB9
+#define GL_PIXEL_MAP_S_TO_S			0x0C71
+#define GL_PIXEL_MAP_I_TO_I			0x0C70
+#define GL_PIXEL_MAP_I_TO_R			0x0C72
+#define GL_PIXEL_MAP_I_TO_G			0x0C73
+#define GL_PIXEL_MAP_I_TO_B			0x0C74
+#define GL_PIXEL_MAP_I_TO_A			0x0C75
+#define GL_PIXEL_MAP_R_TO_R			0x0C76
+#define GL_PIXEL_MAP_G_TO_G			0x0C77
+#define GL_PIXEL_MAP_B_TO_B			0x0C78
+#define GL_PIXEL_MAP_A_TO_A			0x0C79
+#define GL_PACK_ALIGNMENT			0x0D05
+#define GL_PACK_LSB_FIRST			0x0D01
+#define GL_PACK_ROW_LENGTH			0x0D02
+#define GL_PACK_SKIP_PIXELS			0x0D04
+#define GL_PACK_SKIP_ROWS			0x0D03
+#define GL_PACK_SWAP_BYTES			0x0D00
+#define GL_UNPACK_ALIGNMENT			0x0CF5
+#define GL_UNPACK_LSB_FIRST			0x0CF1
+#define GL_UNPACK_ROW_LENGTH			0x0CF2
+#define GL_UNPACK_SKIP_PIXELS			0x0CF4
+#define GL_UNPACK_SKIP_ROWS			0x0CF3
+#define GL_UNPACK_SWAP_BYTES			0x0CF0
+#define GL_ZOOM_X				0x0D16
+#define GL_ZOOM_Y				0x0D17
+
+/* Texture mapping */
+#define GL_TEXTURE_ENV				0x2300
+#define GL_TEXTURE_ENV_MODE			0x2200
+#define GL_TEXTURE_1D				0x0DE0
+#define GL_TEXTURE_2D				0x0DE1
+#define GL_TEXTURE_WRAP_S			0x2802
+#define GL_TEXTURE_WRAP_T			0x2803
+#define GL_TEXTURE_MAG_FILTER			0x2800
+#define GL_TEXTURE_MIN_FILTER			0x2801
+#define GL_TEXTURE_ENV_COLOR			0x2201
+#define GL_TEXTURE_GEN_S			0x0C60
+#define GL_TEXTURE_GEN_T			0x0C61
+#define GL_TEXTURE_GEN_R			0x0C62
+#define GL_TEXTURE_GEN_Q			0x0C63
+#define GL_TEXTURE_GEN_MODE			0x2500
+#define GL_TEXTURE_BORDER_COLOR			0x1004
+#define GL_TEXTURE_WIDTH			0x1000
+#define GL_TEXTURE_HEIGHT			0x1001
+#define GL_TEXTURE_BORDER			0x1005
+#define GL_TEXTURE_COMPONENTS			0x1003
+#define GL_TEXTURE_RED_SIZE			0x805C
+#define GL_TEXTURE_GREEN_SIZE			0x805D
+#define GL_TEXTURE_BLUE_SIZE			0x805E
+#define GL_TEXTURE_ALPHA_SIZE			0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE		0x8060
+#define GL_TEXTURE_INTENSITY_SIZE		0x8061
+#define GL_NEAREST_MIPMAP_NEAREST		0x2700
+#define GL_NEAREST_MIPMAP_LINEAR		0x2702
+#define GL_LINEAR_MIPMAP_NEAREST		0x2701
+#define GL_LINEAR_MIPMAP_LINEAR			0x2703
+#define GL_OBJECT_LINEAR			0x2401
+#define GL_OBJECT_PLANE				0x2501
+#define GL_EYE_LINEAR				0x2400
+#define GL_EYE_PLANE				0x2502
+#define GL_SPHERE_MAP				0x2402
+#define GL_DECAL				0x2101
+#define GL_MODULATE				0x2100
+#define GL_NEAREST				0x2600
+#define GL_REPEAT				0x2901
+#define GL_CLAMP				0x2900
+#define GL_S					0x2000
+#define GL_T					0x2001
+#define GL_R					0x2002
+#define GL_Q					0x2003
+
+/* Utility */
+#define GL_VENDOR				0x1F00
+#define GL_RENDERER				0x1F01
+#define GL_VERSION				0x1F02
+#define GL_EXTENSIONS				0x1F03
+
+/* Errors */
+#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
+
+/* glPush/PopAttrib bits */
+#define GL_CURRENT_BIT				0x00000001
+#define GL_POINT_BIT				0x00000002
+#define GL_LINE_BIT				0x00000004
+#define GL_POLYGON_BIT				0x00000008
+#define GL_POLYGON_STIPPLE_BIT			0x00000010
+#define GL_PIXEL_MODE_BIT			0x00000020
+#define GL_LIGHTING_BIT				0x00000040
+#define GL_FOG_BIT				0x00000080
+#define GL_DEPTH_BUFFER_BIT			0x00000100
+#define GL_ACCUM_BUFFER_BIT			0x00000200
+#define GL_STENCIL_BUFFER_BIT			0x00000400
+#define GL_VIEWPORT_BIT				0x00000800
+#define GL_TRANSFORM_BIT			0x00001000
+#define GL_ENABLE_BIT				0x00002000
+#define GL_COLOR_BUFFER_BIT			0x00004000
+#define GL_HINT_BIT				0x00008000
+#define GL_EVAL_BIT				0x00010000
+#define GL_LIST_BIT				0x00020000
+#define GL_TEXTURE_BIT				0x00040000
+#define GL_SCISSOR_BIT				0x00080000
+#define GL_ALL_ATTRIB_BITS			0x000FFFFF
+
+
+/* OpenGL 1.1 */
+#define GL_PROXY_TEXTURE_1D			0x8063
+#define GL_PROXY_TEXTURE_2D			0x8064
+#define GL_TEXTURE_PRIORITY			0x8066
+#define GL_TEXTURE_RESIDENT			0x8067
+#define GL_TEXTURE_BINDING_1D			0x8068
+#define GL_TEXTURE_BINDING_2D			0x8069
+#define GL_TEXTURE_INTERNAL_FORMAT		0x1003
+#define GL_ALPHA4				0x803B
+#define GL_ALPHA8				0x803C
+#define GL_ALPHA12				0x803D
+#define GL_ALPHA16				0x803E
+#define GL_LUMINANCE4				0x803F
+#define GL_LUMINANCE8				0x8040
+#define GL_LUMINANCE12				0x8041
+#define GL_LUMINANCE16				0x8042
+#define GL_LUMINANCE4_ALPHA4			0x8043
+#define GL_LUMINANCE6_ALPHA2			0x8044
+#define GL_LUMINANCE8_ALPHA8			0x8045
+#define GL_LUMINANCE12_ALPHA4			0x8046
+#define GL_LUMINANCE12_ALPHA12			0x8047
+#define GL_LUMINANCE16_ALPHA16			0x8048
+#define GL_INTENSITY				0x8049
+#define GL_INTENSITY4				0x804A
+#define GL_INTENSITY8				0x804B
+#define GL_INTENSITY12				0x804C
+#define GL_INTENSITY16				0x804D
+#define GL_R3_G3_B2				0x2A10
+#define GL_RGB4					0x804F
+#define GL_RGB5					0x8050
+#define GL_RGB8					0x8051
+#define GL_RGB10				0x8052
+#define GL_RGB12				0x8053
+#define GL_RGB16				0x8054
+#define GL_RGBA2				0x8055
+#define GL_RGBA4				0x8056
+#define GL_RGB5_A1				0x8057
+#define GL_RGBA8				0x8058
+#define GL_RGB10_A2				0x8059
+#define GL_RGBA12				0x805A
+#define GL_RGBA16				0x805B
+#define GL_CLIENT_PIXEL_STORE_BIT		0x00000001
+#define GL_CLIENT_VERTEX_ARRAY_BIT		0x00000002
+#define GL_ALL_CLIENT_ATTRIB_BITS 		0xFFFFFFFF
+#define GL_CLIENT_ALL_ATTRIB_BITS 		0xFFFFFFFF
+
+
+
+/*
+ * Miscellaneous
+ */
+
+GLAPI void GLAPIENTRY glClearIndex( GLfloat c );
+
+GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
+
+GLAPI void GLAPIENTRY glClear( GLbitfield mask );
+
+GLAPI void GLAPIENTRY glIndexMask( GLuint mask );
+
+GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha );
+
+GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref );
+
+GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor );
+
+GLAPI void GLAPIENTRY glLogicOp( GLenum opcode );
+
+GLAPI void GLAPIENTRY glCullFace( GLenum mode );
+
+GLAPI void GLAPIENTRY glFrontFace( GLenum mode );
+
+GLAPI void GLAPIENTRY glPointSize( GLfloat size );
+
+GLAPI void GLAPIENTRY glLineWidth( GLfloat width );
+
+GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern );
+
+GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode );
+
+GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units );
+
+GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask );
+
+GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask );
+
+GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag );
+
+GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag );
+
+GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height);
+
+GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation );
+
+GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation );
+
+GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode );
+
+GLAPI void GLAPIENTRY glReadBuffer( GLenum mode );
+
+GLAPI void GLAPIENTRY glEnable( GLenum cap );
+
+GLAPI void GLAPIENTRY glDisable( GLenum cap );
+
+GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap );
+
+
+GLAPI void GLAPIENTRY glEnableClientState( GLenum cap );  /* 1.1 */
+
+GLAPI void GLAPIENTRY glDisableClientState( GLenum cap );  /* 1.1 */
+
+
+GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params );
+
+GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params );
+
+GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask );
+
+GLAPI void GLAPIENTRY glPopAttrib( void );
+
+
+GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask );  /* 1.1 */
+
+GLAPI void GLAPIENTRY glPopClientAttrib( void );  /* 1.1 */
+
+
+GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode );
+
+GLAPI GLenum GLAPIENTRY glGetError( void );
+
+GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name );
+
+GLAPI void GLAPIENTRY glFinish( void );
+
+GLAPI void GLAPIENTRY glFlush( void );
+
+GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode );
+
+
+/*
+ * Depth Buffer
+ */
+
+GLAPI void GLAPIENTRY glClearDepth( GLclampd depth );
+
+GLAPI void GLAPIENTRY glDepthFunc( GLenum func );
+
+GLAPI void GLAPIENTRY glDepthMask( GLboolean flag );
+
+GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val );
+
+
+/*
+ * Accumulation Buffer
+ */
+
+GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
+
+GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value );
+
+
+/*
+ * Transformation
+ */
+
+GLAPI void GLAPIENTRY glMatrixMode( GLenum mode );
+
+GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right,
+                                 GLdouble bottom, GLdouble top,
+                                 GLdouble near_val, GLdouble far_val );
+
+GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right,
+                                   GLdouble bottom, GLdouble top,
+                                   GLdouble near_val, GLdouble far_val );
+
+GLAPI void GLAPIENTRY glViewport( GLint x, GLint y,
+                                    GLsizei width, GLsizei height );
+
+GLAPI void GLAPIENTRY glPushMatrix( void );
+
+GLAPI void GLAPIENTRY glPopMatrix( void );
+
+GLAPI void GLAPIENTRY glLoadIdentity( void );
+
+GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m );
+GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m );
+
+GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m );
+GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m );
+
+GLAPI void GLAPIENTRY glRotated( GLdouble angle,
+                                   GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glRotatef( GLfloat angle,
+                                   GLfloat x, GLfloat y, GLfloat z );
+
+GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z );
+
+GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z );
+
+
+/*
+ * Display Lists
+ */
+
+GLAPI GLboolean GLAPIENTRY glIsList( GLuint list );
+
+GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range );
+
+GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range );
+
+GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode );
+
+GLAPI void GLAPIENTRY glEndList( void );
+
+GLAPI void GLAPIENTRY glCallList( GLuint list );
+
+GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type,
+                                     const GLvoid *lists );
+
+GLAPI void GLAPIENTRY glListBase( GLuint base );
+
+
+/*
+ * Drawing Functions
+ */
+
+GLAPI void GLAPIENTRY glBegin( GLenum mode );
+
+GLAPI void GLAPIENTRY glEnd( void );
+
+
+GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y );
+GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y );
+GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y );
+GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y );
+
+GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z );
+GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z );
+GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z );
+
+GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
+GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w );
+GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w );
+
+GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex2iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex3iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex4iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz );
+GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz );
+GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz );
+GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz );
+GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz );
+
+GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glNormal3iv( const GLint *v );
+GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glIndexd( GLdouble c );
+GLAPI void GLAPIENTRY glIndexf( GLfloat c );
+GLAPI void GLAPIENTRY glIndexi( GLint c );
+GLAPI void GLAPIENTRY glIndexs( GLshort c );
+GLAPI void GLAPIENTRY glIndexub( GLubyte c );  /* 1.1 */
+
+GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c );
+GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c );
+GLAPI void GLAPIENTRY glIndexiv( const GLint *c );
+GLAPI void GLAPIENTRY glIndexsv( const GLshort *c );
+GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c );  /* 1.1 */
+
+GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue );
+GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue );
+GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue );
+GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue );
+GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue );
+GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue );
+GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue );
+GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue );
+
+GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green,
+                                   GLbyte blue, GLbyte alpha );
+GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green,
+                                   GLdouble blue, GLdouble alpha );
+GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green,
+                                   GLfloat blue, GLfloat alpha );
+GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green,
+                                   GLint blue, GLint alpha );
+GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green,
+                                   GLshort blue, GLshort alpha );
+GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green,
+                                    GLubyte blue, GLubyte alpha );
+GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green,
+                                    GLuint blue, GLuint alpha );
+GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green,
+                                    GLushort blue, GLushort alpha );
+
+
+GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glColor3iv( const GLint *v );
+GLAPI void GLAPIENTRY glColor3sv( const GLshort *v );
+GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v );
+GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v );
+GLAPI void GLAPIENTRY glColor3usv( const GLushort *v );
+
+GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glColor4iv( const GLint *v );
+GLAPI void GLAPIENTRY glColor4sv( const GLshort *v );
+GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v );
+GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v );
+GLAPI void GLAPIENTRY glColor4usv( const GLushort *v );
+
+
+GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s );
+GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s );
+GLAPI void GLAPIENTRY glTexCoord1i( GLint s );
+GLAPI void GLAPIENTRY glTexCoord1s( GLshort s );
+
+GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t );
+GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t );
+GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t );
+GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t );
+
+GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r );
+GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r );
+GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r );
+GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r );
+
+GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q );
+GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q );
+GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q );
+
+GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y );
+GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y );
+GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y );
+GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y );
+
+GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z );
+GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z );
+GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z );
+
+GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
+GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w );
+GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w );
+
+GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 );
+GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 );
+GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 );
+GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 );
+
+
+GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 );
+GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 );
+GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 );
+GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 );
+
+
+/*
+ * Vertex Arrays  (1.1)
+ */
+
+GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type,
+                                       GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride,
+                                       const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type,
+                                      GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride,
+                                      const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type,
+                                         GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params );
+
+GLAPI void GLAPIENTRY glArrayElement( GLint i );
+
+GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count );
+
+GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count,
+                                      GLenum type, const GLvoid *indices );
+
+GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride,
+                                           const GLvoid *pointer );
+
+/*
+ * Lighting
+ */
+
+GLAPI void GLAPIENTRY glShadeModel( GLenum mode );
+
+GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname,
+                                 const GLfloat *params );
+GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname,
+                                 const GLint *params );
+
+GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname,
+                                    GLfloat *params );
+GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname,
+                                    GLint *params );
+
+GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params );
+
+GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode );
+
+
+/*
+ * Raster functions
+ */
+
+GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor );
+
+GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize,
+                                    const GLfloat *values );
+GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize,
+                                     const GLuint *values );
+GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize,
+                                     const GLushort *values );
+
+GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values );
+GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values );
+GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values );
+
+GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height,
+                                GLfloat xorig, GLfloat yorig,
+                                GLfloat xmove, GLfloat ymove,
+                                const GLubyte *bitmap );
+
+GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y,
+                                    GLsizei width, GLsizei height,
+                                    GLenum format, GLenum type,
+                                    GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height,
+                                    GLenum format, GLenum type,
+                                    const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y,
+                                    GLsizei width, GLsizei height,
+                                    GLenum type );
+
+/*
+ * Stenciling
+ */
+
+GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask );
+
+GLAPI void GLAPIENTRY glStencilMask( GLuint mask );
+
+GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass );
+
+GLAPI void GLAPIENTRY glClearStencil( GLint s );
+
+
+
+/*
+ * Texture mapping
+ */
+
+GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param );
+GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params );
+GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params );
+GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname,
+                                          const GLfloat *params );
+GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname,
+                                          const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target,
+                                           GLenum pname, GLfloat *params);
+GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target,
+                                           GLenum pname, GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level,
+                                                GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level,
+                                                GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level,
+                                    GLint internalFormat,
+                                    GLsizei width, GLint border,
+                                    GLenum format, GLenum type,
+                                    const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level,
+                                    GLint internalFormat,
+                                    GLsizei width, GLsizei height,
+                                    GLint border, GLenum format, GLenum type,
+                                    const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level,
+                                     GLenum format, GLenum type,
+                                     GLvoid *pixels );
+
+
+/* 1.1 functions */
+
+GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures );
+
+GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures);
+
+GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture );
+
+GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n,
+                                            const GLuint *textures,
+                                            const GLclampf *priorities );
+
+GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n,
+                                                  const GLuint *textures,
+                                                  GLboolean *residences );
+
+GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture );
+
+
+GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level,
+                                       GLint xoffset,
+                                       GLsizei width, GLenum format,
+                                       GLenum type, const GLvoid *pixels );
+
+
+GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level,
+                                       GLint xoffset, GLint yoffset,
+                                       GLsizei width, GLsizei height,
+                                       GLenum format, GLenum type,
+                                       const GLvoid *pixels );
+
+
+GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level,
+                                        GLenum internalformat,
+                                        GLint x, GLint y,
+                                        GLsizei width, GLint border );
+
+
+GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level,
+                                        GLenum internalformat,
+                                        GLint x, GLint y,
+                                        GLsizei width, GLsizei height,
+                                        GLint border );
+
+
+GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level,
+                                           GLint xoffset, GLint x, GLint y,
+                                           GLsizei width );
+
+
+GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level,
+                                           GLint xoffset, GLint yoffset,
+                                           GLint x, GLint y,
+                                           GLsizei width, GLsizei height );
+
+
+/*
+ * Evaluators
+ */
+
+GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2,
+                               GLint stride,
+                               GLint order, const GLdouble *points );
+GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2,
+                               GLint stride,
+                               GLint order, const GLfloat *points );
+
+GLAPI void GLAPIENTRY glMap2d( GLenum target,
+		     GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
+		     GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
+		     const GLdouble *points );
+GLAPI void GLAPIENTRY glMap2f( GLenum target,
+		     GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+		     GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+		     const GLfloat *points );
+
+GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v );
+GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v );
+GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v );
+
+GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u );
+GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u );
+
+GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u );
+GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u );
+
+GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v );
+GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v );
+
+GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u );
+GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u );
+
+GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 );
+GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 );
+
+GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2,
+                                   GLint vn, GLdouble v1, GLdouble v2 );
+GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2,
+                                   GLint vn, GLfloat v1, GLfloat v2 );
+
+GLAPI void GLAPIENTRY glEvalPoint1( GLint i );
+
+GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j );
+
+GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 );
+
+GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
+
+
+/*
+ * Fog
+ */
+
+GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param );
+
+GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params );
+
+GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params );
+
+
+/*
+ * Selection and Feedback
+ */
+
+GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer );
+
+GLAPI void GLAPIENTRY glPassThrough( GLfloat token );
+
+GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer );
+
+GLAPI void GLAPIENTRY glInitNames( void );
+
+GLAPI void GLAPIENTRY glLoadName( GLuint name );
+
+GLAPI void GLAPIENTRY glPushName( GLuint name );
+
+GLAPI void GLAPIENTRY glPopName( void );
+
+
+
+/*
+ * OpenGL 1.2
+ */
+
+#define GL_RESCALE_NORMAL			0x803A
+#define GL_CLAMP_TO_EDGE			0x812F
+#define GL_MAX_ELEMENTS_VERTICES		0x80E8
+#define GL_MAX_ELEMENTS_INDICES			0x80E9
+#define GL_BGR					0x80E0
+#define GL_BGRA					0x80E1
+#define GL_UNSIGNED_BYTE_3_3_2			0x8032
+#define GL_UNSIGNED_BYTE_2_3_3_REV		0x8362
+#define GL_UNSIGNED_SHORT_5_6_5			0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV		0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4		0x8033
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV		0x8365
+#define GL_UNSIGNED_SHORT_5_5_5_1		0x8034
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV		0x8366
+#define GL_UNSIGNED_INT_8_8_8_8			0x8035
+#define GL_UNSIGNED_INT_8_8_8_8_REV		0x8367
+#define GL_UNSIGNED_INT_10_10_10_2		0x8036
+#define GL_UNSIGNED_INT_2_10_10_10_REV		0x8368
+#define GL_LIGHT_MODEL_COLOR_CONTROL		0x81F8
+#define GL_SINGLE_COLOR				0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR		0x81FA
+#define GL_TEXTURE_MIN_LOD			0x813A
+#define GL_TEXTURE_MAX_LOD			0x813B
+#define GL_TEXTURE_BASE_LEVEL			0x813C
+#define GL_TEXTURE_MAX_LEVEL			0x813D
+#define GL_SMOOTH_POINT_SIZE_RANGE		0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY	0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE		0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY	0x0B23
+#define GL_ALIASED_POINT_SIZE_RANGE		0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE		0x846E
+#define GL_PACK_SKIP_IMAGES			0x806B
+#define GL_PACK_IMAGE_HEIGHT			0x806C
+#define GL_UNPACK_SKIP_IMAGES			0x806D
+#define GL_UNPACK_IMAGE_HEIGHT			0x806E
+#define GL_TEXTURE_3D				0x806F
+#define GL_PROXY_TEXTURE_3D			0x8070
+#define GL_TEXTURE_DEPTH			0x8071
+#define GL_TEXTURE_WRAP_R			0x8072
+#define GL_MAX_3D_TEXTURE_SIZE			0x8073
+#define GL_TEXTURE_BINDING_3D			0x806A
+
+GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start,
+	GLuint end, GLsizei count, GLenum type, const GLvoid *indices );
+
+GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level,
+                                      GLint internalFormat,
+                                      GLsizei width, GLsizei height,
+                                      GLsizei depth, GLint border,
+                                      GLenum format, GLenum type,
+                                      const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level,
+                                         GLint xoffset, GLint yoffset,
+                                         GLint zoffset, GLsizei width,
+                                         GLsizei height, GLsizei depth,
+                                         GLenum format,
+                                         GLenum type, const GLvoid *pixels);
+
+GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level,
+                                             GLint xoffset, GLint yoffset,
+                                             GLint zoffset, GLint x,
+                                             GLint y, GLsizei width,
+                                             GLsizei height );
+
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+
+
+/*
+ * GL_ARB_imaging
+ */
+
+#define GL_CONSTANT_COLOR			0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR		0x8002
+#define GL_CONSTANT_ALPHA			0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA		0x8004
+#define GL_COLOR_TABLE				0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE		0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE	0x80D2
+#define GL_PROXY_COLOR_TABLE			0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE	0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE	0x80D5
+#define GL_COLOR_TABLE_SCALE			0x80D6
+#define GL_COLOR_TABLE_BIAS			0x80D7
+#define GL_COLOR_TABLE_FORMAT			0x80D8
+#define GL_COLOR_TABLE_WIDTH			0x80D9
+#define GL_COLOR_TABLE_RED_SIZE			0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE		0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE		0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE		0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE		0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE		0x80DF
+#define GL_CONVOLUTION_1D			0x8010
+#define GL_CONVOLUTION_2D			0x8011
+#define GL_SEPARABLE_2D				0x8012
+#define GL_CONVOLUTION_BORDER_MODE		0x8013
+#define GL_CONVOLUTION_FILTER_SCALE		0x8014
+#define GL_CONVOLUTION_FILTER_BIAS		0x8015
+#define GL_REDUCE				0x8016
+#define GL_CONVOLUTION_FORMAT			0x8017
+#define GL_CONVOLUTION_WIDTH			0x8018
+#define GL_CONVOLUTION_HEIGHT			0x8019
+#define GL_MAX_CONVOLUTION_WIDTH		0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT		0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE		0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE		0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE		0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE		0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS		0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS		0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS		0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS		0x8023
+#define GL_CONSTANT_BORDER			0x8151
+#define GL_REPLICATE_BORDER			0x8153
+#define GL_CONVOLUTION_BORDER_COLOR		0x8154
+#define GL_COLOR_MATRIX				0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH		0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH		0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE		0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE	0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE		0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE	0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS		0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS		0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS		0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS		0x80BB
+#define GL_HISTOGRAM				0x8024
+#define GL_PROXY_HISTOGRAM			0x8025
+#define GL_HISTOGRAM_WIDTH			0x8026
+#define GL_HISTOGRAM_FORMAT			0x8027
+#define GL_HISTOGRAM_RED_SIZE			0x8028
+#define GL_HISTOGRAM_GREEN_SIZE			0x8029
+#define GL_HISTOGRAM_BLUE_SIZE			0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE			0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE		0x802C
+#define GL_HISTOGRAM_SINK			0x802D
+#define GL_MINMAX				0x802E
+#define GL_MINMAX_FORMAT			0x802F
+#define GL_MINMAX_SINK				0x8030
+#define GL_TABLE_TOO_LARGE			0x8031
+#define GL_BLEND_EQUATION			0x8009
+#define GL_MIN					0x8007
+#define GL_MAX					0x8008
+#define GL_FUNC_ADD				0x8006
+#define GL_FUNC_SUBTRACT			0x800A
+#define GL_FUNC_REVERSE_SUBTRACT		0x800B
+#define GL_BLEND_COLOR				0x8005
+
+
+GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat,
+                                    GLsizei width, GLenum format,
+                                    GLenum type, const GLvoid *table );
+
+GLAPI void GLAPIENTRY glColorSubTable( GLenum target,
+                                       GLsizei start, GLsizei count,
+                                       GLenum format, GLenum type,
+                                       const GLvoid *data );
+
+GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname,
+                                              const GLint *params);
+
+GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname,
+                                              const GLfloat *params);
+
+GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start,
+                                           GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat,
+                                        GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format,
+                                       GLenum type, GLvoid *table );
+
+GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname,
+                                                  GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname,
+                                                  GLint *params );
+
+GLAPI void GLAPIENTRY glBlendEquation( GLenum mode );
+
+GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green,
+                                    GLclampf blue, GLclampf alpha );
+
+GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width,
+				   GLenum internalformat, GLboolean sink );
+
+GLAPI void GLAPIENTRY glResetHistogram( GLenum target );
+
+GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset,
+				      GLenum format, GLenum type,
+				      GLvoid *values );
+
+GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname,
+						 GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname,
+						 GLint *params );
+
+GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat,
+				GLboolean sink );
+
+GLAPI void GLAPIENTRY glResetMinmax( GLenum target );
+
+GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset,
+                                   GLenum format, GLenum types,
+                                   GLvoid *values );
+
+GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname,
+					      GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname,
+					      GLint *params );
+
+GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target,
+	GLenum internalformat, GLsizei width, GLenum format, GLenum type,
+	const GLvoid *image );
+
+GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target,
+	GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+	GLenum type, const GLvoid *image );
+
+GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname,
+	GLfloat params );
+
+GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname,
+	const GLfloat *params );
+
+GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname,
+	GLint params );
+
+GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname,
+	const GLint *params );
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target,
+	GLenum internalformat, GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target,
+	GLenum internalformat, GLint x, GLint y, GLsizei width,
+	GLsizei height);
+
+GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format,
+	GLenum type, GLvoid *image );
+
+GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname,
+	GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname,
+	GLint *params );
+
+GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
+	GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+	GLenum type, const GLvoid *row, const GLvoid *column );
+
+GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
+	GLenum type, GLvoid *row, GLvoid *column, GLvoid *span );
+
+
+
+
+/*
+ * OpenGL 1.3
+ */
+
+/* multitexture */
+#define GL_TEXTURE0				0x84C0
+#define GL_TEXTURE1				0x84C1
+#define GL_TEXTURE2				0x84C2
+#define GL_TEXTURE3				0x84C3
+#define GL_TEXTURE4				0x84C4
+#define GL_TEXTURE5				0x84C5
+#define GL_TEXTURE6				0x84C6
+#define GL_TEXTURE7				0x84C7
+#define GL_TEXTURE8				0x84C8
+#define GL_TEXTURE9				0x84C9
+#define GL_TEXTURE10				0x84CA
+#define GL_TEXTURE11				0x84CB
+#define GL_TEXTURE12				0x84CC
+#define GL_TEXTURE13				0x84CD
+#define GL_TEXTURE14				0x84CE
+#define GL_TEXTURE15				0x84CF
+#define GL_TEXTURE16				0x84D0
+#define GL_TEXTURE17				0x84D1
+#define GL_TEXTURE18				0x84D2
+#define GL_TEXTURE19				0x84D3
+#define GL_TEXTURE20				0x84D4
+#define GL_TEXTURE21				0x84D5
+#define GL_TEXTURE22				0x84D6
+#define GL_TEXTURE23				0x84D7
+#define GL_TEXTURE24				0x84D8
+#define GL_TEXTURE25				0x84D9
+#define GL_TEXTURE26				0x84DA
+#define GL_TEXTURE27				0x84DB
+#define GL_TEXTURE28				0x84DC
+#define GL_TEXTURE29				0x84DD
+#define GL_TEXTURE30				0x84DE
+#define GL_TEXTURE31				0x84DF
+#define GL_ACTIVE_TEXTURE			0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE		0x84E1
+#define GL_MAX_TEXTURE_UNITS			0x84E2
+/* texture_cube_map */
+#define GL_NORMAL_MAP				0x8511
+#define GL_REFLECTION_MAP			0x8512
+#define GL_TEXTURE_CUBE_MAP			0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP		0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X		0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X		0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y		0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y		0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z		0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z		0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP		0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE		0x851C
+/* texture_compression */
+#define GL_COMPRESSED_ALPHA			0x84E9
+#define GL_COMPRESSED_LUMINANCE			0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA		0x84EB
+#define GL_COMPRESSED_INTENSITY			0x84EC
+#define GL_COMPRESSED_RGB			0x84ED
+#define GL_COMPRESSED_RGBA			0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT		0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE	0x86A0
+#define GL_TEXTURE_COMPRESSED			0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS	0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS		0x86A3
+/* multisample */
+#define GL_MULTISAMPLE				0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE		0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE			0x809F
+#define GL_SAMPLE_COVERAGE			0x80A0
+#define GL_SAMPLE_BUFFERS			0x80A8
+#define GL_SAMPLES				0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE		0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT		0x80AB
+#define GL_MULTISAMPLE_BIT			0x20000000
+/* transpose_matrix */
+#define GL_TRANSPOSE_MODELVIEW_MATRIX		0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX		0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX		0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX		0x84E6
+/* texture_env_combine */
+#define GL_COMBINE				0x8570
+#define GL_COMBINE_RGB				0x8571
+#define GL_COMBINE_ALPHA			0x8572
+#define GL_SOURCE0_RGB				0x8580
+#define GL_SOURCE1_RGB				0x8581
+#define GL_SOURCE2_RGB				0x8582
+#define GL_SOURCE0_ALPHA			0x8588
+#define GL_SOURCE1_ALPHA			0x8589
+#define GL_SOURCE2_ALPHA			0x858A
+#define GL_OPERAND0_RGB				0x8590
+#define GL_OPERAND1_RGB				0x8591
+#define GL_OPERAND2_RGB				0x8592
+#define GL_OPERAND0_ALPHA			0x8598
+#define GL_OPERAND1_ALPHA			0x8599
+#define GL_OPERAND2_ALPHA			0x859A
+#define GL_RGB_SCALE				0x8573
+#define GL_ADD_SIGNED				0x8574
+#define GL_INTERPOLATE				0x8575
+#define GL_SUBTRACT				0x84E7
+#define GL_CONSTANT				0x8576
+#define GL_PRIMARY_COLOR			0x8577
+#define GL_PREVIOUS				0x8578
+/* texture_env_dot3 */
+#define GL_DOT3_RGB				0x86AE
+#define GL_DOT3_RGBA				0x86AF
+/* texture_border_clamp */
+#define GL_CLAMP_TO_BORDER			0x812D
+
+GLAPI void GLAPIENTRY glActiveTexture( GLenum texture );
+
+GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture );
+
+GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] );
+
+GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] );
+
+GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] );
+
+GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] );
+
+GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert );
+
+
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
+
+
+
+/*
+ * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
+ */
+#ifndef GL_ARB_multitexture
+#define GL_ARB_multitexture 1
+
+#define GL_TEXTURE0_ARB				0x84C0
+#define GL_TEXTURE1_ARB				0x84C1
+#define GL_TEXTURE2_ARB				0x84C2
+#define GL_TEXTURE3_ARB				0x84C3
+#define GL_TEXTURE4_ARB				0x84C4
+#define GL_TEXTURE5_ARB				0x84C5
+#define GL_TEXTURE6_ARB				0x84C6
+#define GL_TEXTURE7_ARB				0x84C7
+#define GL_TEXTURE8_ARB				0x84C8
+#define GL_TEXTURE9_ARB				0x84C9
+#define GL_TEXTURE10_ARB			0x84CA
+#define GL_TEXTURE11_ARB			0x84CB
+#define GL_TEXTURE12_ARB			0x84CC
+#define GL_TEXTURE13_ARB			0x84CD
+#define GL_TEXTURE14_ARB			0x84CE
+#define GL_TEXTURE15_ARB			0x84CF
+#define GL_TEXTURE16_ARB			0x84D0
+#define GL_TEXTURE17_ARB			0x84D1
+#define GL_TEXTURE18_ARB			0x84D2
+#define GL_TEXTURE19_ARB			0x84D3
+#define GL_TEXTURE20_ARB			0x84D4
+#define GL_TEXTURE21_ARB			0x84D5
+#define GL_TEXTURE22_ARB			0x84D6
+#define GL_TEXTURE23_ARB			0x84D7
+#define GL_TEXTURE24_ARB			0x84D8
+#define GL_TEXTURE25_ARB			0x84D9
+#define GL_TEXTURE26_ARB			0x84DA
+#define GL_TEXTURE27_ARB			0x84DB
+#define GL_TEXTURE28_ARB			0x84DC
+#define GL_TEXTURE29_ARB			0x84DD
+#define GL_TEXTURE30_ARB			0x84DE
+#define GL_TEXTURE31_ARB			0x84DF
+#define GL_ACTIVE_TEXTURE_ARB			0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB		0x84E1
+#define GL_MAX_TEXTURE_UNITS_ARB		0x84E2
+
+GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture);
+GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture);
+GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s);
+GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s);
+GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s);
+GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s);
+GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t);
+GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
+GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t);
+GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t);
+GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r);
+GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r);
+GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r);
+GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r);
+GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q);
+GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v);
+
+typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+
+#endif /* GL_ARB_multitexture */
+
+
+
+/*
+ * Define this token if you want "old-style" header file behaviour (extensions
+ * defined in gl.h).  Otherwise, extensions will be included from glext.h.
+ */
 #if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY)
 #include "SDL_opengl_glext.h"
-#endif /* NO_SDL_GLEXT */
+#endif  /* GL_GLEXT_LEGACY */
+
+
+
+/*
+ * ???. GL_MESA_packed_depth_stencil
+ * XXX obsolete
+ */
+#ifndef GL_MESA_packed_depth_stencil
+#define GL_MESA_packed_depth_stencil 1
+
+#define GL_DEPTH_STENCIL_MESA			0x8750
+#define GL_UNSIGNED_INT_24_8_MESA		0x8751
+#define GL_UNSIGNED_INT_8_24_REV_MESA		0x8752
+#define GL_UNSIGNED_SHORT_15_1_MESA		0x8753
+#define GL_UNSIGNED_SHORT_1_15_REV_MESA		0x8754
+
+#endif /* GL_MESA_packed_depth_stencil */
+
+
+#ifndef GL_ATI_blend_equation_separate
+#define GL_ATI_blend_equation_separate 1
+
+#define GL_ALPHA_BLEND_EQUATION_ATI	        0x883D
+
+GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA );
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA);
+
+#endif /* GL_ATI_blend_equation_separate */
+
+
+/* GL_OES_EGL_image */
+#ifndef GL_OES_EGL_image
+typedef void* GLeglImageOES;
+#endif
+
+#ifndef GL_OES_EGL_image
+#define GL_OES_EGL_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
+#endif
+typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
+#endif
+
+
+/**
+ ** NOTE!!!!!  If you add new functions to this file, or update
+ ** glext.h be sure to regenerate the gl_mangle.h file.  See comments
+ ** in that file for details.
+ **/
+
+
+
+/**********************************************************************
+ * Begin system-specific stuff
+ */
+#if defined(PRAGMA_EXPORT_SUPPORTED)
+#pragma export off
+#endif
+
+/*
+ * End system-specific stuff
+ **********************************************************************/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl_h_ */
 
 #endif /* !__IPHONEOS__ */
 
--- a/include/SDL_opengl_glext.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_opengl_glext.h	Wed Aug 20 17:20:22 2014 -0300
@@ -465,8 +465,13 @@
 #ifndef GL_VERSION_1_5
 #define GL_VERSION_1_5 1
 #include <stddef.h>
+#ifdef __MACOSX__
+typedef long GLsizeiptr;
+typedef long GLintptr;
+#else
 typedef ptrdiff_t GLsizeiptr;
 typedef ptrdiff_t GLintptr;
+#endif
 #define GL_BUFFER_SIZE                    0x8764
 #define GL_BUFFER_USAGE                   0x8765
 #define GL_QUERY_COUNTER_BITS             0x8864
--- a/include/SDL_opengles2.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_opengles2.h	Wed Aug 20 17:20:22 2014 -0300
@@ -20,7 +20,7 @@
 */
 
 /**
- *  \file SDL_opengles.h
+ *  \file SDL_opengles2.h
  *
  *  This is a simple file to encapsulate the OpenGL ES 2.0 API headers.
  */
--- a/include/SDL_pixels.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_pixels.h	Wed Aug 20 17:20:22 2014 -0300
@@ -248,7 +248,11 @@
     SDL_PIXELFORMAT_UYVY =      /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
         SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
     SDL_PIXELFORMAT_YVYU =      /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
-        SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
+        SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'),
+    SDL_PIXELFORMAT_NV12 =      /**< Planar mode: Y + U/V interleaved  (2 planes) */
+        SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'),
+    SDL_PIXELFORMAT_NV21 =      /**< Planar mode: Y + V/U interleaved  (2 planes) */
+        SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1')
 };
 
 typedef struct SDL_Color
--- a/include/SDL_syswm.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/include/SDL_syswm.h	Wed Aug 20 17:20:22 2014 -0300
@@ -208,20 +208,20 @@
 #if defined(SDL_VIDEO_DRIVER_COCOA)
         struct
         {
-#if defined(__OBJC__) && __has_feature(objc_arc)
-            NSWindow * __unsafe_unretained window; /* The Cocoa window */
+#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
+            NSWindow __unsafe_unretained *window; /* The Cocoa window */
 #else
-            NSWindow *window;                      /* The Cocoa window */
+            NSWindow *window;                     /* The Cocoa window */
 #endif
         } cocoa;
 #endif
 #if defined(SDL_VIDEO_DRIVER_UIKIT)
         struct
         {
-#if defined(__OBJC__) && __has_feature(objc_arc)
-            UIWindow * __unsafe_unretained window; /* The UIKit window */
+#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc)
+            UIWindow __unsafe_unretained *window; /* The UIKit window */
 #else
-            UIWindow *window;                      /* The UIKit window */
+            UIWindow *window;                     /* The UIKit window */
 #endif
         } uikit;
 #endif
--- a/src/audio/xaudio2/SDL_xaudio2.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/audio/xaudio2/SDL_xaudio2.c	Wed Aug 20 17:20:22 2014 -0300
@@ -58,7 +58,7 @@
 /* The configure script already did any necessary checking */
 #  define SDL_XAUDIO2_HAS_SDK 1
 #elif defined(__WINRT__)
-/* WinRT always has access to the the XAudio 2 SDK */
+/* WinRT always has access to the XAudio 2 SDK */
 #  define SDL_XAUDIO2_HAS_SDK
 #else
 /* XAudio2 exists as of the March 2008 DirectX SDK 
--- a/src/core/linux/SDL_ibus.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/core/linux/SDL_ibus.c	Wed Aug 20 17:20:22 2014 -0300
@@ -22,10 +22,16 @@
 
 #ifdef HAVE_IBUS_IBUS_H
 #include "SDL.h"
+#include "SDL_syswm.h"
 #include "SDL_ibus.h"
 #include "SDL_dbus.h"
 #include "../../video/SDL_sysvideo.h"
 #include "../../events/SDL_keyboard_c.h"
+
+#if SDL_VIDEO_DRIVER_X11
+    #include "../../video/x11/SDL_x11video.h"
+#endif
+
 #include <sys/inotify.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -39,7 +45,7 @@
 static SDL_Rect ibus_cursor_rect = {0};
 static DBusConnection *ibus_conn = NULL;
 static char *ibus_addr_file = NULL;
-int inotify_fd = -1;
+int inotify_fd = -1, inotify_wd = -1;
 
 static Uint32
 IBus_ModState(void)
@@ -160,8 +166,6 @@
                 i += sz;
                 cursor += chars;
             }
-        } else {
-            SDL_SendEditingText("", 0, 0);
         }
         
         SDL_IBus_UpdateTextRect(NULL);
@@ -169,6 +173,11 @@
         return DBUS_HANDLER_RESULT_HANDLED;
     }
     
+    if(dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "HidePreeditText")){
+    	SDL_SendEditingText("", 0, 0);
+    	return DBUS_HANDLER_RESULT_HANDLED;
+    }
+    
     return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
@@ -279,6 +288,41 @@
     return SDL_strdup(file_path);
 }
 
+static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus);
+
+static void
+IBus_SetCapabilities(void *data, const char *name, const char *old_val,
+                                                   const char *internal_editing)
+{
+    SDL_DBusContext *dbus = SDL_DBus_GetContext();
+    
+    if(IBus_CheckConnection(dbus)){
+
+        DBusMessage *msg = dbus->message_new_method_call(IBUS_SERVICE,
+                                                         input_ctx_path,
+                                                         IBUS_INPUT_INTERFACE,
+                                                         "SetCapabilities");
+        if(msg){
+            Uint32 caps = IBUS_CAP_FOCUS;
+            if(!(internal_editing && *internal_editing == '1')){
+                caps |= IBUS_CAP_PREEDIT_TEXT;
+            }
+            
+            dbus->message_append_args(msg,
+                                      DBUS_TYPE_UINT32, &caps,
+                                      DBUS_TYPE_INVALID);
+        }
+        
+        if(msg){
+            if(dbus->connection_send(ibus_conn, msg, NULL)){
+                dbus->connection_flush(ibus_conn);
+            }
+            dbus->message_unref(msg);
+        }
+    }
+}
+
+
 static SDL_bool
 IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr)
 {
@@ -331,30 +375,14 @@
     }
 
     if(result){
-        msg = dbus->message_new_method_call(IBUS_SERVICE,
-                                            input_ctx_path,
-                                            IBUS_INPUT_INTERFACE,
-                                            "SetCapabilities");
-        if(msg){
-            Uint32 caps = IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT;
-            dbus->message_append_args(msg,
-                                      DBUS_TYPE_UINT32, &caps,
-                                      DBUS_TYPE_INVALID);
-        }
-        
-        if(msg){
-            if(dbus->connection_send(ibus_conn, msg, NULL)){
-                dbus->connection_flush(ibus_conn);
-            }
-            dbus->message_unref(msg);
-        }
+        SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL);
         
         dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL);
         dbus->connection_add_filter(ibus_conn, &IBus_MessageFilter, dbus, NULL);
         dbus->connection_flush(ibus_conn);
     }
 
-    SDL_IBus_SetFocus(SDL_GetFocusWindow() != NULL);
+    SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL);
     SDL_IBus_UpdateTextRect(NULL);
     
     return result;
@@ -369,7 +397,7 @@
         return SDL_TRUE;
     }
     
-    if(inotify_fd != -1){
+    if(inotify_fd > 0 && inotify_wd > 0){
         char buf[1024];
         ssize_t readsize = read(inotify_fd, buf, sizeof(buf));
         if(readsize > 0){
@@ -422,15 +450,17 @@
         
         char *addr = IBus_ReadAddressFromFile(addr_file);
         
-        inotify_fd = inotify_init();
-        fcntl(inotify_fd, F_SETFL, O_NONBLOCK);
+        if(inotify_fd < 0){
+            inotify_fd = inotify_init();
+            fcntl(inotify_fd, F_SETFL, O_NONBLOCK);
+        }
         
         char *addr_file_dir = SDL_strrchr(addr_file, '/');
         if(addr_file_dir){
             *addr_file_dir = 0;
         }
         
-        inotify_add_watch(inotify_fd, addr_file, IN_CREATE | IN_MODIFY);
+        inotify_wd = inotify_add_watch(inotify_fd, addr_file, IN_CREATE | IN_MODIFY);
         SDL_free(addr_file);
         
         result = IBus_SetupConnection(dbus, addr);
@@ -460,6 +490,13 @@
         dbus->connection_unref(ibus_conn);
     }
     
+    if(inotify_fd > 0 && inotify_wd > 0){
+        inotify_rm_watch(inotify_fd, inotify_wd);
+        inotify_wd = -1;
+    }
+    
+    SDL_DelHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL);
+    
     SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect));
 }
 
@@ -532,6 +569,8 @@
         
     }
     
+    SDL_IBus_UpdateTextRect(NULL);
+
     return result;
 }
 
@@ -542,12 +581,34 @@
         SDL_memcpy(&ibus_cursor_rect, rect, sizeof(ibus_cursor_rect));
     }
     
-    SDL_Window *focused_win = SDL_GetFocusWindow();
+    SDL_Window *focused_win = SDL_GetKeyboardFocus();
 
     if(!focused_win) return;
-
+    
+    SDL_SysWMinfo info;
+    SDL_VERSION(&info.version);
+    
+    if(!SDL_GetWindowWMInfo(focused_win, &info)) return;
+    
     int x = 0, y = 0;
+    
     SDL_GetWindowPosition(focused_win, &x, &y);
+   
+#if SDL_VIDEO_DRIVER_X11    
+    if(info.subsystem == SDL_SYSWM_X11){
+        SDL_DisplayData *displaydata =
+            (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata;
+            
+        Display *x_disp = info.info.x11.display;
+        Window x_win = info.info.x11.window;
+        int x_screen = displaydata->screen;
+        Window unused;
+            
+        X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen),
+            0, 0, &x, &y, &unused);
+    }
+#endif
+
     x += ibus_cursor_rect.x;
     y += ibus_cursor_rect.y;
         
--- a/src/cpuinfo/SDL_cpuinfo.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/cpuinfo/SDL_cpuinfo.c	Wed Aug 20 17:20:22 2014 -0300
@@ -246,7 +246,7 @@
     a = 0;
 #if defined(__GNUC__) && (defined(i386) || defined(__x86_64__))
     asm(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx");
-#elif defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */
+#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */
     a = (int)_xgetbv(0);
 #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
     __asm
--- a/src/file/cocoa/SDL_rwopsbundlesupport.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/file/cocoa/SDL_rwopsbundlesupport.m	Wed Aug 20 17:20:22 2014 -0300
@@ -33,6 +33,7 @@
  Also, note the bundle layouts are different for iPhone and Mac.
 */
 FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode)
+{ @autoreleasepool
 {
     FILE* fp = NULL;
 
@@ -41,22 +42,20 @@
         return fopen(file, mode);
     }
 
-    @autoreleasepool {
-        NSFileManager* file_manager = [NSFileManager defaultManager];
-        NSString* resource_path = [[NSBundle mainBundle] resourcePath];
+    NSFileManager* file_manager = [NSFileManager defaultManager];
+    NSString* resource_path = [[NSBundle mainBundle] resourcePath];
 
-        NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
+    NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
 
-        NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
-        if([file_manager fileExistsAtPath:full_path_with_file_to_try]) {
-            fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
-        } else {
-            fp = fopen(file, mode);
-        }
+    NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
+    if([file_manager fileExistsAtPath:full_path_with_file_to_try]) {
+        fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
+    } else {
+        fp = fopen(file, mode);
     }
 
     return fp;
-}
+}}
 
 #endif /* __APPLE__ */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/filesystem/android/SDL_sysfilesystem.c	Wed Aug 20 17:20:22 2014 -0300
@@ -0,0 +1,62 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#ifdef SDL_FILESYSTEM_ANDROID
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* System dependent filesystem routines                                */
+
+#include <unistd.h>
+#include <errno.h>
+
+#include "SDL_error.h"
+#include "SDL_filesystem.h"
+#include "SDL_system.h"
+
+
+char *
+SDL_GetBasePath(void)
+{
+    /* The current working directory is / on Android */
+    return NULL;
+}
+
+char *
+SDL_GetPrefPath(const char *org, const char *app)
+{
+    const char *path = SDL_AndroidGetInternalStoragePath();
+    if (path) {
+        size_t pathlen = SDL_strlen(path)+2;
+        char *fullpath = (char *)SDL_malloc(pathlen);
+        if (!fullpath) {
+            SDL_OutOfMemory();
+            return NULL;
+        }
+        SDL_snprintf(fullpath, pathlen, "%s/", path);
+        return fullpath;
+    }
+    return NULL;
+}
+
+#endif /* SDL_FILESYSTEM_ANDROID */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/filesystem/cocoa/SDL_sysfilesystem.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/filesystem/cocoa/SDL_sysfilesystem.m	Wed Aug 20 17:20:22 2014 -0300
@@ -35,72 +35,71 @@
 
 char *
 SDL_GetBasePath(void)
+{ @autoreleasepool
+{
+    NSBundle *bundle = [NSBundle mainBundle];
+    const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String];
+    const char *base = NULL;
+    char *retval = NULL;
+
+    if (baseType == NULL) {
+        baseType = "resource";
+    }
+    if (SDL_strcasecmp(baseType, "bundle")==0) {
+        base = [[bundle bundlePath] fileSystemRepresentation];
+    } else if (SDL_strcasecmp(baseType, "parent")==0) {
+        base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation];
+    } else {
+        /* this returns the exedir for non-bundled  and the resourceDir for bundled apps */
+        base = [[bundle resourcePath] fileSystemRepresentation];
+    }
+
+    if (base) {
+        const size_t len = SDL_strlen(base) + 2;
+        retval = (char *) SDL_malloc(len);
+        if (retval == NULL) {
+            SDL_OutOfMemory();
+        } else {
+            SDL_snprintf(retval, len, "%s/", base);
+        }
+    }
+
+    return retval;
+}}
+
+char *
+SDL_GetPrefPath(const char *org, const char *app)
+{ @autoreleasepool
 {
     char *retval = NULL;
 
-    @autoreleasepool {
-        const char *base = NULL;
-        NSBundle *bundle = [NSBundle mainBundle];
-        const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String];
-        if (baseType == NULL) {
-            baseType = "resource";
-        }
-        if (SDL_strcasecmp(baseType, "bundle")==0) {
-            base = [[bundle bundlePath] fileSystemRepresentation];
-        } else if (SDL_strcasecmp(baseType, "parent")==0) {
-            base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation];
-        } else {
-            /* this returns the exedir for non-bundled  and the resourceDir for bundled apps */
-            base = [[bundle resourcePath] fileSystemRepresentation];
-        }
+    NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
 
+    if ([array count] > 0) {  /* we only want the first item in the list. */
+        NSString *str = [array objectAtIndex:0];
+        const char *base = [str fileSystemRepresentation];
         if (base) {
-            const size_t len = SDL_strlen(base) + 2;
+            const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
             retval = (char *) SDL_malloc(len);
             if (retval == NULL) {
                 SDL_OutOfMemory();
             } else {
-                SDL_snprintf(retval, len, "%s/", base);
+                char *ptr;
+                SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
+                for (ptr = retval+1; *ptr; ptr++) {
+                    if (*ptr == '/') {
+                        *ptr = '\0';
+                        mkdir(retval, 0700);
+                        *ptr = '/';
+                    }
+                }
+                mkdir(retval, 0700);
             }
         }
     }
 
     return retval;
-}
-
-char *
-SDL_GetPrefPath(const char *org, const char *app)
-{
-    char *retval = NULL;
-
-    @autoreleasepool {
-        NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
-
-        if ([array count] > 0) {  /* we only want the first item in the list. */
-            NSString *str = [array objectAtIndex:0];
-            const char *base = [str fileSystemRepresentation];
-            if (base) {
-                const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
-                retval = (char *) SDL_malloc(len);
-                if (retval == NULL) {
-                    SDL_OutOfMemory();
-                } else {
-                    char *ptr;
-                    SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
-                    for (ptr = retval+1; *ptr; ptr++) {
-                        if (*ptr == '/') {
-                            *ptr = '\0';
-                            mkdir(retval, 0700);
-                            *ptr = '/';
-                        }
-                    }
-                    mkdir(retval, 0700);
-                }
-            }
-        }
-    }
-    return retval;
-}
+}}
 
 #endif /* SDL_FILESYSTEM_COCOA */
 
--- a/src/haptic/darwin/SDL_syshaptic.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/haptic/darwin/SDL_syshaptic.c	Wed Aug 20 17:20:22 2014 -0300
@@ -924,10 +924,10 @@
             condition[i].lNegativeCoefficient =
                 CONVERT(hap_condition->left_coeff[i]);
             condition[i].dwPositiveSaturation =
-                CCONVERT(hap_condition->right_sat[i]);
+                CCONVERT(hap_condition->right_sat[i] / 2);
             condition[i].dwNegativeSaturation =
-                CCONVERT(hap_condition->left_sat[i]);
-            condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i]);
+                CCONVERT(hap_condition->left_sat[i] / 2);
+            condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2);
         }
         dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes;
         dest->lpvTypeSpecificParams = condition;
--- a/src/haptic/linux/SDL_syshaptic.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/haptic/linux/SDL_syshaptic.c	Wed Aug 20 17:20:22 2014 -0300
@@ -652,15 +652,14 @@
 
 
 /*
- * Returns the ff_effect usable direction from a SDL_HapticDirection.
+ * Initializes the ff_effect usable direction from a SDL_HapticDirection.
  */
-static Uint16
-SDL_SYS_ToDirection(SDL_HapticDirection * dir)
+static int
+SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
 {
     Uint32 tmp;
-    float f;                    /* Ideally we'd use fixed point math instead of floats... */
 
-    switch (dir->type) {
+    switch (src->type) {
     case SDL_HAPTIC_POLAR:
         /* Linux directions start from south.
                 (and range from 0 to 0xFFFF)
@@ -671,24 +670,31 @@
                         180 deg -> 0x8000 (up)
                         270 deg -> 0xC000 (right)
                     */
-        tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */
-        return (Uint16) tmp;
+        tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */
+        *dest = (Uint16) tmp;
+        break;
 
-       case SDL_HAPTIC_SPHERICAL:
+    case SDL_HAPTIC_SPHERICAL:
             /*
                 We convert to polar, because that's the only supported direction on Linux.
                 The first value of a spherical direction is practically the same as a
                 Polar direction, except that we have to add 90 degrees. It is the angle
                 from EAST {1,0} towards SOUTH {0,1}.
                 --> add 9000
-                --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
+                --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
             */
-            tmp = ((dir->dir[0]) + 9000) % 36000;    /* Convert to polars */
-        tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */
-        return (Uint16) tmp;
+            tmp = ((src->dir[0]) + 9000) % 36000;    /* Convert to polars */
+        tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */
+        *dest = (Uint16) tmp;
+        break;
 
     case SDL_HAPTIC_CARTESIAN:
-        f = atan2(dir->dir[1], dir->dir[0]);
+        if (!src->dir[1])
+            *dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000);
+        else if (!src->dir[0])
+            *dest = (src->dir[1] >= 0 ? 0x8000 : 0);
+        else {
+            float f = atan2(src->dir[1], src->dir[0]);    /* Ideally we'd use fixed point math instead of floats... */
                     /*
                       atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
                        - Y-axis-value is the second coordinate (from center to SOUTH)
@@ -697,14 +703,16 @@
                         have the first spherical value. Therefore we proceed as in case
                         SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value.
                       --> add 45000 in total
-                      --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
+                      --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR.
                     */
-                tmp = (((int) (f * 18000. / M_PI)) + 45000) % 36000;
-        tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */
-        return (Uint16) tmp;
+                tmp = (((Sint32) (f * 18000. / M_PI)) + 45000) % 36000;
+            tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */
+            *dest = (Uint16) tmp;
+        }
+        break;
 
     default:
-        return (Uint16) SDL_SetError("Haptic: Unsupported direction type.");
+        return SDL_SetError("Haptic: Unsupported direction type.");
     }
 
     return 0;
@@ -735,8 +743,7 @@
 
         /* Header */
         dest->type = FF_CONSTANT;
-        dest->direction = SDL_SYS_ToDirection(&constant->direction);
-        if (dest->direction == (Uint16) - 1)
+        if (SDL_SYS_ToDirection(&dest->direction, &constant->direction) == -1)
             return -1;
 
         /* Replay */
@@ -771,8 +778,7 @@
 
         /* Header */
         dest->type = FF_PERIODIC;
-        dest->direction = SDL_SYS_ToDirection(&periodic->direction);
-        if (dest->direction == (Uint16) - 1)
+        if (SDL_SYS_ToDirection(&dest->direction, &periodic->direction) == -1)
             return -1;
 
         /* Replay */
@@ -841,20 +847,18 @@
 
         /* Condition */
         /* X axis */
-        dest->u.condition[0].right_saturation =
-            CLAMP(condition->right_sat[0]);
-        dest->u.condition[0].left_saturation = CLAMP(condition->left_sat[0]);
+        dest->u.condition[0].right_saturation = condition->right_sat[0];
+        dest->u.condition[0].left_saturation = condition->left_sat[0];
         dest->u.condition[0].right_coeff = condition->right_coeff[0];
         dest->u.condition[0].left_coeff = condition->left_coeff[0];
-        dest->u.condition[0].deadband = CLAMP(condition->deadband[0]);
+        dest->u.condition[0].deadband = condition->deadband[0];
         dest->u.condition[0].center = condition->center[0];
         /* Y axis */
-        dest->u.condition[1].right_saturation =
-            CLAMP(condition->right_sat[1]);
-        dest->u.condition[1].left_saturation = CLAMP(condition->left_sat[1]);
+        dest->u.condition[1].right_saturation = condition->right_sat[1];
+        dest->u.condition[1].left_saturation = condition->left_sat[1];
         dest->u.condition[1].right_coeff = condition->right_coeff[1];
         dest->u.condition[1].left_coeff = condition->left_coeff[1];
-        dest->u.condition[1].deadband = CLAMP(condition->deadband[1]);
+        dest->u.condition[1].deadband = condition->deadband[1];
         dest->u.condition[1].center = condition->center[1];
 
         /*
@@ -868,8 +872,7 @@
 
         /* Header */
         dest->type = FF_RAMP;
-        dest->direction = SDL_SYS_ToDirection(&ramp->direction);
-        if (dest->direction == (Uint16) - 1)
+        if (SDL_SYS_ToDirection(&dest->direction, &ramp->direction) == -1)
             return -1;
 
         /* Replay */
--- a/src/haptic/windows/SDL_dinputhaptic.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/haptic/windows/SDL_dinputhaptic.c	Wed Aug 20 17:20:22 2014 -0300
@@ -602,7 +602,10 @@
     }
 }
 
-#define CONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
+/* Clamps and converts. */
+#define CCONVERT(x)   (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF)
+/* Just converts. */
+#define CONVERT(x)    (((x)*10000) / 0x7FFF)
 /*
  * Creates the DIEFFECT from a SDL_HapticEffect.
  */
@@ -689,9 +692,9 @@
             SDL_free(dest->lpEnvelope);
             dest->lpEnvelope = NULL;
         } else {
-            envelope->dwAttackLevel = CONVERT(hap_constant->attack_level);
+            envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level);
             envelope->dwAttackTime = hap_constant->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_constant->fade_level);
+            envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level);
             envelope->dwFadeTime = hap_constant->fade_length * 1000;
         }
 
@@ -736,9 +739,9 @@
             SDL_free(dest->lpEnvelope);
             dest->lpEnvelope = NULL;
         } else {
-            envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level);
+            envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level);
             envelope->dwAttackTime = hap_periodic->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level);
+            envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level);
             envelope->dwFadeTime = hap_periodic->fade_length * 1000;
         }
 
@@ -763,10 +766,10 @@
             condition[i].lNegativeCoefficient =
                 CONVERT(hap_condition->left_coeff[i]);
             condition[i].dwPositiveSaturation =
-                CONVERT(hap_condition->right_sat[i]);
+                CCONVERT(hap_condition->right_sat[i] / 2);
             condition[i].dwNegativeSaturation =
-                CONVERT(hap_condition->left_sat[i]);
-            condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]);
+                CCONVERT(hap_condition->left_sat[i] / 2);
+            condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2);
         }
         dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes;
         dest->lpvTypeSpecificParams = condition;
@@ -819,9 +822,9 @@
             SDL_free(dest->lpEnvelope);
             dest->lpEnvelope = NULL;
         } else {
-            envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level);
+            envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level);
             envelope->dwAttackTime = hap_ramp->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level);
+            envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level);
             envelope->dwFadeTime = hap_ramp->fade_length * 1000;
         }
 
@@ -842,7 +845,7 @@
         custom->rglForceData =
             SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels);
         for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) {      /* Copy data. */
-            custom->rglForceData[i] = CONVERT(hap_custom->data[i]);
+            custom->rglForceData[i] = CCONVERT(hap_custom->data[i]);
         }
         dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE);
         dest->lpvTypeSpecificParams = custom;
@@ -864,9 +867,9 @@
             SDL_free(dest->lpEnvelope);
             dest->lpEnvelope = NULL;
         } else {
-            envelope->dwAttackLevel = CONVERT(hap_custom->attack_level);
+            envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level);
             envelope->dwAttackTime = hap_custom->attack_length * 1000;
-            envelope->dwFadeLevel = CONVERT(hap_custom->fade_level);
+            envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level);
             envelope->dwFadeTime = hap_custom->fade_length * 1000;
         }
 
--- a/src/joystick/SDL_gamecontrollerdb.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/joystick/SDL_gamecontrollerdb.h	Wed Aug 20 17:20:22 2014 -0300
@@ -67,6 +67,7 @@
     "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
     "030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
     "050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
+    "03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
--- a/src/render/SDL_render.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/SDL_render.c	Wed Aug 20 17:20:22 2014 -0300
@@ -115,6 +115,12 @@
             }
 
             if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
+                /* Make sure we're operating on the default render target */
+                SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
+                if (saved_target) {
+                    SDL_SetRenderTarget(renderer, NULL);
+                }
+
                 if (renderer->logical_w) {
                     UpdateLogicalSize(renderer);
                 } else {
@@ -140,6 +146,10 @@
                         renderer->UpdateViewport(renderer);
                     }
                 }
+
+                if (saved_target) {
+                    SDL_SetRenderTarget(renderer, saved_target);
+                }
             } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
                 renderer->hidden = SDL_TRUE;
             } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
@@ -540,6 +550,10 @@
 
         /* Set up a destination surface for the texture update */
         dst_fmt = SDL_AllocFormat(format);
+        if (!dst_fmt) {
+           SDL_DestroyTexture(texture);
+           return NULL;
+        }
         temp = SDL_ConvertSurface(surface, dst_fmt, 0);
         SDL_FreeFormat(dst_fmt);
         if (temp) {
@@ -912,12 +926,12 @@
         SDL_assert(!texture->native);
         renderer = texture->renderer;
         SDL_assert(renderer->UpdateTextureYUV);
-		if (renderer->UpdateTextureYUV) {
-			return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
-		} else {
-			return SDL_Unsupported();
-		}
-	}
+        if (renderer->UpdateTextureYUV) {
+            return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
+        } else {
+            return SDL_Unsupported();
+        }
+    }
 }
 
 static int
--- a/src/render/direct3d/SDL_render_d3d.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/direct3d/SDL_render_d3d.c	Wed Aug 20 17:20:22 2014 -0300
@@ -193,6 +193,9 @@
 typedef struct
 {
     SDL_bool dirty;
+    int w, h;
+    DWORD usage;
+    Uint32 format;
     IDirect3DTexture9 *texture;
     IDirect3DTexture9 *staging;
 } D3D_TextureRep;
@@ -819,6 +822,10 @@
     HRESULT result;
 
     texture->dirty = SDL_FALSE;
+    texture->w = w;
+    texture->h = h;
+    texture->usage = usage;
+    texture->format = format;
 
     result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage,
         PixelFormatToD3DFMT(format),
@@ -826,10 +833,18 @@
     if (FAILED(result)) {
         return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
     }
+    return 0;
+}
 
-    if (usage != D3DUSAGE_RENDERTARGET) {
-        result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage,
-            PixelFormatToD3DFMT(format),
+
+static int
+D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
+{
+    HRESULT result;
+
+    if (texture->staging == NULL) {
+        result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage,
+            PixelFormatToD3DFMT(texture->format),
             D3DPOOL_SYSTEMMEM, &texture->staging, NULL);
         if (FAILED(result)) {
             return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result);
@@ -845,14 +860,8 @@
 
     if (texture->dirty && texture->staging) {
         if (!texture->texture) {
-            D3DSURFACE_DESC desc;
-            result = IDirect3DTexture9_GetLevelDesc(texture->staging, 0, &desc);
-            if (FAILED(result)) {
-                return D3D_SetError("GetLevelDesc", result);
-            }
-
-            result = IDirect3DDevice9_CreateTexture(device, desc.Width, desc.Height, 1, 0,
-                desc.Format, D3DPOOL_DEFAULT, &texture->texture, NULL);
+            result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage,
+                PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture, NULL);
             if (FAILED(result)) {
                 return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
             }
@@ -878,8 +887,10 @@
         IDirect3DTexture9_Release(texture->texture);
         texture->texture = NULL;
     }
-    IDirect3DTexture9_AddDirtyRect(texture->staging, NULL);
-    texture->dirty = SDL_TRUE;
+    if (texture->staging) {
+        IDirect3DTexture9_AddDirtyRect(texture->staging, NULL);
+        texture->dirty = SDL_TRUE;
+    }
     return 0;
 }
 
@@ -893,10 +904,15 @@
     int row, length;
     HRESULT result;
 
+    if (D3D_CreateStagingTexture(device, texture) < 0) {
+        return -1;
+    }
+
     d3drect.left = x;
     d3drect.right = x + w;
     d3drect.top = y;
     d3drect.bottom = y + h;
+    
     result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0);
     if (FAILED(result)) {
         return D3D_SetError("LockRect()", result);
@@ -1068,7 +1084,9 @@
 D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                 const SDL_Rect * rect, void **pixels, int *pitch)
 {
+    D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
     D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
+    IDirect3DDevice9 *device = data->device;
 
     if (!texturedata) {
         SDL_SetError("Texture is not currently available");
@@ -1095,6 +1113,10 @@
         D3DLOCKED_RECT locked;
         HRESULT result;
 
+        if (D3D_CreateStagingTexture(device, &texturedata->texture) < 0) {
+            return -1;
+        }
+
         d3drect.left = rect->x;
         d3drect.right = rect->x + rect->w;
         d3drect.top = rect->y;
@@ -1137,7 +1159,9 @@
 {
     D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
     D3D_TextureData *texturedata;
+    D3D_TextureRep *texturerep;
     HRESULT result;
+    IDirect3DDevice9 *device = data->device;
 
     /* Release the previous render target if it wasn't the default one */
     if (data->currentRenderTarget != NULL) {
@@ -1156,6 +1180,24 @@
         return -1;
     }
 
+    /* Make sure the render target is updated if it was locked and written to */
+    texturerep = &texturedata->texture;
+    if (texturerep->dirty && texturerep->staging) {
+        if (!texturerep->texture) {
+            result = IDirect3DDevice9_CreateTexture(device, texturerep->w, texturerep->h, 1, texturerep->usage,
+                PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture, NULL);
+            if (FAILED(result)) {
+                return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result);
+            }
+        }
+
+        result = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texturerep->staging, (IDirect3DBaseTexture9 *)texturerep->texture);
+        if (FAILED(result)) {
+            return D3D_SetError("UpdateTexture()", result);
+        }
+        texturerep->dirty = SDL_FALSE;
+    }
+
     result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture.texture, 0, &data->currentRenderTarget);
     if(FAILED(result)) {
         return D3D_SetError("GetSurfaceLevel()", result);
@@ -1789,9 +1831,10 @@
     D3DLOCKED_RECT locked;
     HRESULT result;
 
-    result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
-    if (FAILED(result)) {
-        return D3D_SetError("GetBackBuffer()", result);
+    if (data->currentRenderTarget) {
+        backBuffer = data->currentRenderTarget;
+    } else {
+        backBuffer = data->defaultRenderTarget;
     }
 
     result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
@@ -1832,7 +1875,6 @@
     IDirect3DSurface9_UnlockRect(surface);
 
     IDirect3DSurface9_Release(surface);
-    IDirect3DSurface9_Release(backBuffer);
 
     return 0;
 }
--- a/src/render/opengl/SDL_render_gl.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/opengl/SDL_render_gl.c	Wed Aug 20 17:20:22 2014 -0300
@@ -121,6 +121,7 @@
     GLDEBUGPROCARB next_error_callback;
     GLvoid *next_error_userparam;
 
+    SDL_bool GL_ARB_texture_non_power_of_two_supported;
     SDL_bool GL_ARB_texture_rectangle_supported;
     struct {
         GL_Shader shader;
@@ -164,8 +165,9 @@
     int pitch;
     SDL_Rect locked_rect;
 
-    /* YV12 texture support */
+    /* YUV texture support */
     SDL_bool yuv;
+    SDL_bool nv12;
     GLuint utexture;
     GLuint vtexture;
 
@@ -498,9 +500,13 @@
         data->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
     }
 
-    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
-        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
+    if (SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two")) {
+        data->GL_ARB_texture_non_power_of_two_supported = SDL_TRUE;
+    } else if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") ||
+               SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
         data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
+    }
+    if (data->GL_ARB_texture_rectangle_supported) {
         data->glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &value);
         renderer->info.max_texture_width = value;
         renderer->info.max_texture_height = value;
@@ -531,6 +537,8 @@
     if (data->shaders && data->num_texture_units >= 3) {
         renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
         renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
+        renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12;
+        renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21;
     }
 
 #ifdef __MACOSX__
@@ -611,16 +619,18 @@
         break;
     case SDL_PIXELFORMAT_YV12:
     case SDL_PIXELFORMAT_IYUV:
+    case SDL_PIXELFORMAT_NV12:
+    case SDL_PIXELFORMAT_NV21:
         *internalFormat = GL_LUMINANCE;
         *format = GL_LUMINANCE;
         *type = GL_UNSIGNED_BYTE;
         break;
 #ifdef __MACOSX__
     case SDL_PIXELFORMAT_UYVY:
-		*internalFormat = GL_RGB8;
-		*format = GL_YCBCR_422_APPLE;
-		*type = GL_UNSIGNED_SHORT_8_8_APPLE;
-		break;
+        *internalFormat = GL_RGB8;
+        *format = GL_YCBCR_422_APPLE;
+        *type = GL_UNSIGNED_SHORT_8_8_APPLE;
+        break;
 #endif
     default:
         return SDL_FALSE;
@@ -672,6 +682,11 @@
             /* Need to add size for the U and V planes */
             size += (2 * (texture->h * data->pitch) / 4);
         }
+        if (texture->format == SDL_PIXELFORMAT_NV12 ||
+            texture->format == SDL_PIXELFORMAT_NV21) {
+            /* Need to add size for the U/V plane */
+            size += ((texture->h * data->pitch) / 2);
+        }
         data->pixels = SDL_calloc(1, size);
         if (!data->pixels) {
             SDL_free(data);
@@ -687,7 +702,7 @@
 
     GL_CheckError("", renderer);
     renderdata->glGenTextures(1, &data->texture);
-    if (GL_CheckError("glGenTexures()", renderer) < 0) {
+    if (GL_CheckError("glGenTextures()", renderer) < 0) {
         if (data->pixels) {
             SDL_free(data->pixels);
         }
@@ -696,8 +711,13 @@
     }
     texture->driverdata = data;
 
-    if ((renderdata->GL_ARB_texture_rectangle_supported)
-        /* && texture->access != SDL_TEXTUREACCESS_TARGET */){
+    if (renderdata->GL_ARB_texture_non_power_of_two_supported) {
+        data->type = GL_TEXTURE_2D;
+        texture_w = texture->w;
+        texture_h = texture->h;
+        data->texw = 1.0f;
+        data->texh = 1.0f;
+    } else if (renderdata->GL_ARB_texture_rectangle_supported) {
         data->type = GL_TEXTURE_RECTANGLE_ARB;
         texture_w = texture->w;
         texture_h = texture->h;
@@ -801,6 +821,27 @@
         renderdata->glDisable(data->type);
     }
 
+    if (texture->format == SDL_PIXELFORMAT_NV12 ||
+        texture->format == SDL_PIXELFORMAT_NV21) {
+        data->nv12 = SDL_TRUE;
+
+        renderdata->glGenTextures(1, &data->utexture);
+        renderdata->glEnable(data->type);
+
+        renderdata->glBindTexture(data->type, data->utexture);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
+                                    scaleMode);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
+                                    scaleMode);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
+                                    GL_CLAMP_TO_EDGE);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
+                                    GL_CLAMP_TO_EDGE);
+        renderdata->glTexImage2D(data->type, 0, GL_LUMINANCE_ALPHA, texture_w/2,
+                                 texture_h/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+        renderdata->glDisable(data->type);
+    }
+
     return GL_CheckError("", renderer);
 }
 
@@ -848,6 +889,17 @@
                                     rect->w/2, rect->h/2,
                                     data->format, data->formattype, pixels);
     }
+
+    if (data->nv12) {
+        renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2));
+
+        /* Skip to the correct offset into the next texture */
+        pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
+        renderdata->glBindTexture(data->type, data->utexture);
+        renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2,
+                                    rect->w/2, rect->h/2,
+                                    GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels);
+    }
     renderdata->glDisable(data->type);
 
     return GL_CheckError("glTexSubImage2D()", renderer);
@@ -1184,15 +1236,10 @@
 }
 
 static int
-GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-              const SDL_Rect * srcrect, const SDL_FRect * dstrect)
+GL_SetupCopy(SDL_Renderer * renderer, SDL_Texture * texture)
 {
     GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
     GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
-    GLfloat minx, miny, maxx, maxy;
-    GLfloat minu, maxu, minv, maxv;
-
-    GL_ActivateRenderer(renderer);
 
     data->glEnable(texturedata->type);
     if (texturedata->yuv) {
@@ -1204,6 +1251,12 @@
 
         data->glActiveTextureARB(GL_TEXTURE0_ARB);
     }
+    if (texturedata->nv12) {
+        data->glActiveTextureARB(GL_TEXTURE1_ARB);
+        data->glBindTexture(texturedata->type, texturedata->utexture);
+
+        data->glActiveTextureARB(GL_TEXTURE0_ARB);
+    }
     data->glBindTexture(texturedata->type, texturedata->texture);
 
     if (texture->modMode) {
@@ -1215,10 +1268,33 @@
     GL_SetBlendMode(data, texture->blendMode);
 
     if (texturedata->yuv) {
-        GL_SetShader(data, SHADER_YV12);
+        GL_SetShader(data, SHADER_YUV);
+    } else if (texturedata->nv12) {
+        if (texture->format == SDL_PIXELFORMAT_NV12) {
+            GL_SetShader(data, SHADER_NV12);
+        } else {
+            GL_SetShader(data, SHADER_NV21);
+        }
     } else {
         GL_SetShader(data, SHADER_RGB);
     }
+    return 0;
+}
+
+static int
+GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+              const SDL_Rect * srcrect, const SDL_FRect * dstrect)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
+    GLfloat minx, miny, maxx, maxy;
+    GLfloat minu, maxu, minv, maxv;
+
+    GL_ActivateRenderer(renderer);
+
+    if (GL_SetupCopy(renderer, texture) < 0) {
+        return -1;
+    }
 
     minx = dstrect->x;
     miny = dstrect->y;
@@ -1263,30 +1339,8 @@
 
     GL_ActivateRenderer(renderer);
 
-    data->glEnable(texturedata->type);
-    if (texturedata->yuv) {
-        data->glActiveTextureARB(GL_TEXTURE2_ARB);
-        data->glBindTexture(texturedata->type, texturedata->vtexture);
-
-        data->glActiveTextureARB(GL_TEXTURE1_ARB);
-        data->glBindTexture(texturedata->type, texturedata->utexture);
-
-        data->glActiveTextureARB(GL_TEXTURE0_ARB);
-    }
-    data->glBindTexture(texturedata->type, texturedata->texture);
-
-    if (texture->modMode) {
-        GL_SetColor(data, texture->r, texture->g, texture->b, texture->a);
-    } else {
-        GL_SetColor(data, 255, 255, 255, 255);
-    }
-
-    GL_SetBlendMode(data, texture->blendMode);
-
-    if (texturedata->yuv) {
-        GL_SetShader(data, SHADER_YV12);
-    } else {
-        GL_SetShader(data, SHADER_RGB);
+    if (GL_SetupCopy(renderer, texture) < 0) {
+        return -1;
     }
 
     centerx = center->x;
--- a/src/render/opengl/SDL_shaders_gl.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/opengl/SDL_shaders_gl.c	Wed Aug 20 17:20:22 2014 -0300
@@ -113,7 +113,7 @@
 "}"
     },
 
-    /* SHADER_YV12 */
+    /* SHADER_YUV */
     {
         /* vertex shader */
 "varying vec4 v_color;\n"
@@ -150,7 +150,7 @@
 "    yuv.x = texture2D(tex0, tcoord).r;\n"
 "\n"
 "    // Get the U and V values \n"
-"    tcoord *= 0.5;\n"
+"    tcoord *= UVCoordScale;\n"
 "    yuv.y = texture2D(tex1, tcoord).r;\n"
 "    yuv.z = texture2D(tex2, tcoord).r;\n"
 "\n"
@@ -164,6 +164,106 @@
 "    gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
 "}"
     },
+
+    /* SHADER_NV12 */
+    {
+        /* vertex shader */
+"varying vec4 v_color;\n"
+"varying vec2 v_texCoord;\n"
+"\n"
+"void main()\n"
+"{\n"
+"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+"    v_color = gl_Color;\n"
+"    v_texCoord = vec2(gl_MultiTexCoord0);\n"
+"}",
+        /* fragment shader */
+"varying vec4 v_color;\n"
+"varying vec2 v_texCoord;\n"
+"uniform sampler2D tex0; // Y \n"
+"uniform sampler2D tex1; // U/V \n"
+"\n"
+"// YUV offset \n"
+"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
+"\n"
+"// RGB coefficients \n"
+"const vec3 Rcoeff = vec3(1.164,  0.000,  1.596);\n"
+"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
+"const vec3 Bcoeff = vec3(1.164,  2.018,  0.000);\n"
+"\n"
+"void main()\n"
+"{\n"
+"    vec2 tcoord;\n"
+"    vec3 yuv, rgb;\n"
+"\n"
+"    // Get the Y value \n"
+"    tcoord = v_texCoord;\n"
+"    yuv.x = texture2D(tex0, tcoord).r;\n"
+"\n"
+"    // Get the U and V values \n"
+"    tcoord *= UVCoordScale;\n"
+"    yuv.yz = texture2D(tex1, tcoord).ra;\n"
+"\n"
+"    // Do the color transform \n"
+"    yuv += offset;\n"
+"    rgb.r = dot(yuv, Rcoeff);\n"
+"    rgb.g = dot(yuv, Gcoeff);\n"
+"    rgb.b = dot(yuv, Bcoeff);\n"
+"\n"
+"    // That was easy. :) \n"
+"    gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
+"}"
+    },
+
+    /* SHADER_NV21 */
+    {
+        /* vertex shader */
+"varying vec4 v_color;\n"
+"varying vec2 v_texCoord;\n"
+"\n"
+"void main()\n"
+"{\n"
+"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+"    v_color = gl_Color;\n"
+"    v_texCoord = vec2(gl_MultiTexCoord0);\n"
+"}",
+        /* fragment shader */
+"varying vec4 v_color;\n"
+"varying vec2 v_texCoord;\n"
+"uniform sampler2D tex0; // Y \n"
+"uniform sampler2D tex1; // U/V \n"
+"\n"
+"// YUV offset \n"
+"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
+"\n"
+"// RGB coefficients \n"
+"const vec3 Rcoeff = vec3(1.164,  0.000,  1.596);\n"
+"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
+"const vec3 Bcoeff = vec3(1.164,  2.018,  0.000);\n"
+"\n"
+"void main()\n"
+"{\n"
+"    vec2 tcoord;\n"
+"    vec3 yuv, rgb;\n"
+"\n"
+"    // Get the Y value \n"
+"    tcoord = v_texCoord;\n"
+"    yuv.x = texture2D(tex0, tcoord).r;\n"
+"\n"
+"    // Get the U and V values \n"
+"    tcoord *= UVCoordScale;\n"
+"    yuv.yz = texture2D(tex1, tcoord).ar;\n"
+"\n"
+"    // Do the color transform \n"
+"    yuv += offset;\n"
+"    rgb.r = dot(yuv, Rcoeff);\n"
+"    rgb.g = dot(yuv, Gcoeff);\n"
+"    rgb.b = dot(yuv, Bcoeff);\n"
+"\n"
+"    // That was easy. :) \n"
+"    gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
+"}"
+    },
 };
 
 static SDL_bool
@@ -218,7 +318,11 @@
     if (ctx->GL_ARB_texture_rectangle_supported) {
         frag_defines =
 "#define sampler2D sampler2DRect\n"
-"#define texture2D texture2DRect\n";
+"#define texture2D texture2DRect\n"
+"#define UVCoordScale 0.5\n";
+    } else {
+        frag_defines = 
+"#define UVCoordScale 1.0\n";
     }
 
     /* Create one program object to rule them all */
@@ -276,8 +380,9 @@
         return NULL;
     }
 
-    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
-        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
+    if (!SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two") &&
+        (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") ||
+         SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle"))) {
         ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE;
     }
 
--- a/src/render/opengl/SDL_shaders_gl.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/opengl/SDL_shaders_gl.h	Wed Aug 20 17:20:22 2014 -0300
@@ -26,7 +26,9 @@
     SHADER_NONE,
     SHADER_SOLID,
     SHADER_RGB,
-    SHADER_YV12,
+    SHADER_YUV,
+    SHADER_NV12,
+    SHADER_NV21,
     NUM_SHADERS
 } GL_Shader;
 
--- a/src/render/opengles2/SDL_render_gles2.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/opengles2/SDL_render_gles2.c	Wed Aug 20 17:20:22 2014 -0300
@@ -81,8 +81,9 @@
     GLenum pixel_type;
     void *pixel_data;
     int pitch;
-    /* YV12 texture support */
+    /* YUV texture support */
     SDL_bool yuv;
+    SDL_bool nv12;
     GLenum texture_v;
     GLenum texture_u;
     GLES2_FBOList *fbo;
@@ -151,7 +152,9 @@
     GLES2_IMAGESOURCE_TEXTURE_ARGB,
     GLES2_IMAGESOURCE_TEXTURE_RGB,
     GLES2_IMAGESOURCE_TEXTURE_BGR,
-    GLES2_IMAGESOURCE_TEXTURE_YUV
+    GLES2_IMAGESOURCE_TEXTURE_YUV,
+    GLES2_IMAGESOURCE_TEXTURE_NV12,
+    GLES2_IMAGESOURCE_TEXTURE_NV21
 } GLES2_ImageSource;
 
 typedef struct GLES2_DriverContext
@@ -488,6 +491,8 @@
         break;
     case SDL_PIXELFORMAT_IYUV:
     case SDL_PIXELFORMAT_YV12:
+    case SDL_PIXELFORMAT_NV12:
+    case SDL_PIXELFORMAT_NV21:
         format = GL_LUMINANCE;
         type = GL_UNSIGNED_BYTE;
         break;
@@ -505,6 +510,7 @@
     data->pixel_format = format;
     data->pixel_type = type;
     data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12));
+    data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21));
     data->texture_u = 0;
     data->texture_v = 0;
     scaleMode = GetScaleQuality();
@@ -518,6 +524,10 @@
             /* Need to add size for the U and V planes */
             size += (2 * (texture->h * data->pitch) / 4);
         }
+        if (data->nv12) {
+            /* Need to add size for the U/V plane */
+            size += ((texture->h * data->pitch) / 2);
+        }
         data->pixel_data = SDL_calloc(1, size);
         if (!data->pixel_data) {
             SDL_free(data);
@@ -557,6 +567,23 @@
         }
     }
 
+    if (data->nv12) {
+        renderdata->glGenTextures(1, &data->texture_u);
+        if (GL_CheckError("glGenTexures()", renderer) < 0) {
+            return -1;
+        }
+        renderdata->glActiveTexture(GL_TEXTURE1);
+        renderdata->glBindTexture(data->texture_type, data->texture_u);
+        renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
+        renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
+        renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+        renderdata->glTexImage2D(data->texture_type, 0, GL_LUMINANCE_ALPHA, texture->w / 2, texture->h / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+        if (GL_CheckError("glTexImage2D()", renderer) < 0) {
+            return -1;
+        }
+    }
+
     renderdata->glGenTextures(1, &data->texture);
     if (GL_CheckError("glGenTexures()", renderer) < 0) {
         return -1;
@@ -673,6 +700,20 @@
                 pixels, pitch / 2, 1);
     }
 
+    if (tdata->nv12) {
+        /* Skip to the correct offset into the next texture */
+        pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
+        data->glBindTexture(tdata->texture_type, tdata->texture_u);
+        GLES2_TexSubImage2D(data, tdata->texture_type,
+                rect->x / 2,
+                rect->y / 2,
+                rect->w / 2,
+                rect->h / 2,
+                GL_LUMINANCE_ALPHA,
+                GL_UNSIGNED_BYTE,
+                pixels, pitch, 2);
+    }
+
     return GL_CheckError("glTexSubImage2D()", renderer);
 }
 
@@ -1093,6 +1134,12 @@
     case GLES2_IMAGESOURCE_TEXTURE_YUV:
         ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC;
         break;
+    case GLES2_IMAGESOURCE_TEXTURE_NV12:
+        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC;
+        break;
+    case GLES2_IMAGESOURCE_TEXTURE_NV21:
+        ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC;
+        break;
     default:
         goto fault;
     }
@@ -1432,20 +1479,15 @@
 }
 
 static int
-GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
-                 const SDL_FRect *dstrect)
+GLES2_SetupCopy(SDL_Renderer *renderer, SDL_Texture *texture)
 {
     GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
     GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
     GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
     SDL_BlendMode blendMode;
-    GLfloat vertices[8];
-    GLfloat texCoords[8];
     GLES2_ProgramCacheEntry *program;
     Uint8 r, g, b, a;
 
-    GLES2_ActivateRenderer(renderer);
-
     /* Activate an appropriate shader and set the projection matrix */
     blendMode = texture->blendMode;
     if (renderer->target) {
@@ -1505,11 +1547,22 @@
                         break;
                 }
                 break;
+            case SDL_PIXELFORMAT_IYUV:
+            case SDL_PIXELFORMAT_YV12:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV;
+                break;
+            case SDL_PIXELFORMAT_NV12:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12;
+                break;
+            case SDL_PIXELFORMAT_NV21:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21;
+                break;
+            default:
+                return SDL_SetError("Unsupported texture format");
             }
         }
         else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
-    }
-    else {
+    } else {
         switch (texture->format)
         {
             case SDL_PIXELFORMAT_ARGB8888:
@@ -1524,13 +1577,18 @@
             case SDL_PIXELFORMAT_BGR888:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
                 break;
-            // TODO: new shader to change yv planes YV12 format
             case SDL_PIXELFORMAT_IYUV:
             case SDL_PIXELFORMAT_YV12:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV;
                 break;
+            case SDL_PIXELFORMAT_NV12:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12;
+                break;
+            case SDL_PIXELFORMAT_NV21:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21;
+                break;
             default:
-                return -1;
+                return SDL_SetError("Unsupported texture format");
         }
     }
 
@@ -1548,6 +1606,12 @@
 
         data->glActiveTexture(GL_TEXTURE0);
     }
+    if (tdata->nv12) {
+        data->glActiveTexture(GL_TEXTURE1);
+        data->glBindTexture(tdata->texture_type, tdata->texture_u);
+
+        data->glActiveTexture(GL_TEXTURE0);
+    }
     data->glBindTexture(tdata->texture_type, tdata->texture);
 
     /* Configure color modulation */
@@ -1578,6 +1642,22 @@
     GLES2_SetBlendMode(data, blendMode);
 
     GLES2_SetTexCoords(data, SDL_TRUE);
+    return 0;
+}
+
+static int
+GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect,
+                 const SDL_FRect *dstrect)
+{
+    GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
+    GLfloat vertices[8];
+    GLfloat texCoords[8];
+
+    GLES2_ActivateRenderer(renderer);
+
+    if (GLES2_SetupCopy(renderer, texture) < 0) {
+        return -1;
+    }
 
     /* Emit the textured quad */
     vertices[0] = dstrect->x;
@@ -1608,11 +1688,6 @@
                  const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
 {
     GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
-    GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata;
-    GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
-    GLES2_ProgramCacheEntry *program;
-    Uint8 r, g, b, a;
-    SDL_BlendMode blendMode;
     GLfloat vertices[8];
     GLfloat texCoords[8];
     GLfloat translate[8];
@@ -1621,6 +1696,10 @@
 
     GLES2_ActivateRenderer(renderer);
 
+    if (GLES2_SetupCopy(renderer, texture) < 0) {
+        return -1;
+    }
+
     data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
     data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
     fAngle[0] = fAngle[1] = fAngle[2] = fAngle[3] = (GLfloat)(360.0f - angle);
@@ -1628,124 +1707,6 @@
     translate[0] = translate[2] = translate[4] = translate[6] = (center->x + dstrect->x);
     translate[1] = translate[3] = translate[5] = translate[7] = (center->y + dstrect->y);
 
-    /* Activate an appropriate shader and set the projection matrix */
-    blendMode = texture->blendMode;
-    if (renderer->target) {
-        /* Check if we need to do color mapping between the source and render target textures */
-        if (renderer->target->format != texture->format) {
-            switch (texture->format)
-            {
-            case SDL_PIXELFORMAT_ARGB8888:
-                switch (renderer->target->format)
-                {
-                    case SDL_PIXELFORMAT_ABGR8888:
-                    case SDL_PIXELFORMAT_BGR888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                        break;
-                    case SDL_PIXELFORMAT_RGB888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
-                        break;
-                }
-                break;
-            case SDL_PIXELFORMAT_ABGR8888:
-                switch (renderer->target->format)
-                {
-                    case SDL_PIXELFORMAT_ARGB8888:
-                    case SDL_PIXELFORMAT_RGB888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                        break;
-                    case SDL_PIXELFORMAT_BGR888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
-                        break;
-                }
-                break;
-            case SDL_PIXELFORMAT_RGB888:
-                switch (renderer->target->format)
-                {
-                    case SDL_PIXELFORMAT_ABGR8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                        break;
-                    case SDL_PIXELFORMAT_ARGB8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
-                        break;
-                    case SDL_PIXELFORMAT_BGR888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                        break;
-                }
-                break;
-            case SDL_PIXELFORMAT_BGR888:
-                switch (renderer->target->format)
-                {
-                    case SDL_PIXELFORMAT_ABGR8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
-                        break;
-                    case SDL_PIXELFORMAT_ARGB8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
-                        break;
-                    case SDL_PIXELFORMAT_RGB888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                        break;
-                }
-                break;
-            }
-        }
-        else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
-    }
-    else {
-        switch (texture->format)
-        {
-            case SDL_PIXELFORMAT_ARGB8888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                break;
-            case SDL_PIXELFORMAT_ABGR8888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
-                break;
-            case SDL_PIXELFORMAT_RGB888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
-                break;
-            case SDL_PIXELFORMAT_BGR888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
-                break;
-            default:
-                return -1;
-        }
-    }
-    if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0)
-        return -1;
-
-    /* Select the target texture */
-    data->glBindTexture(tdata->texture_type, tdata->texture);
-
-    /* Configure color modulation */
-    /* !!! FIXME: grep for glUniform4f(), move that stuff to a subroutine, it's a lot of copy/paste. */
-    g = texture->g;
-    a = texture->a;
-
-    if (renderer->target &&
-        (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 ||
-         renderer->target->format == SDL_PIXELFORMAT_RGB888)) {
-        r = texture->b;
-        b = texture->r;
-    } else {
-        r = texture->r;
-        b = texture->b;
-    }
-
-    program = data->current_program;
-
-    if (!CompareColors(program->modulation_r, program->modulation_g, program->modulation_b, program->modulation_a, r, g, b, a)) {
-        data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f);
-        program->modulation_r = r;
-        program->modulation_g = g;
-        program->modulation_b = b;
-        program->modulation_a = a;
-    }
-
-    /* Configure texture blending */
-    GLES2_SetBlendMode(data, blendMode);
-
-    GLES2_SetTexCoords(data, SDL_TRUE);
-
     /* Emit the textured quad */
     vertices[0] = dstrect->x;
     vertices[1] = dstrect->y;
@@ -2066,6 +2027,8 @@
 
     renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
     renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
+    renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12;
+    renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21;
 
     GLES2_ResetState(renderer);
 
--- a/src/render/opengles2/SDL_shaders_gles2.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/opengles2/SDL_shaders_gles2.c	Wed Aug 20 17:20:22 2014 -0300
@@ -150,6 +150,50 @@
     } \
 ";
 
+/* NV12 to ABGR conversion */
+static const Uint8 GLES2_FragmentSrc_TextureNV12Src_[] = " \
+    precision mediump float; \
+    uniform sampler2D u_texture; \
+    uniform sampler2D u_texture_u; \
+    uniform vec4 u_modulation; \
+    varying vec2 v_texCoord; \
+    \
+    void main() \
+    { \
+        mediump vec3 yuv; \
+        lowp vec3 rgb; \
+        yuv.x = texture2D(u_texture,   v_texCoord).r; \
+        yuv.yz = texture2D(u_texture_u, v_texCoord).ra - 0.5; \
+        rgb = mat3( 1,        1,       1, \
+                    0,       -0.39465, 2.03211, \
+                    1.13983, -0.58060, 0) * yuv; \
+        gl_FragColor = vec4(rgb, 1); \
+        gl_FragColor *= u_modulation; \
+    } \
+";
+
+/* NV21 to ABGR conversion */
+static const Uint8 GLES2_FragmentSrc_TextureNV21Src_[] = " \
+    precision mediump float; \
+    uniform sampler2D u_texture; \
+    uniform sampler2D u_texture_u; \
+    uniform vec4 u_modulation; \
+    varying vec2 v_texCoord; \
+    \
+    void main() \
+    { \
+        mediump vec3 yuv; \
+        lowp vec3 rgb; \
+        yuv.x = texture2D(u_texture,   v_texCoord).r; \
+        yuv.yz = texture2D(u_texture_u, v_texCoord).ar - 0.5; \
+        rgb = mat3( 1,        1,       1, \
+                    0,       -0.39465, 2.03211, \
+                    1.13983, -0.58060, 0) * yuv; \
+        gl_FragColor = vec4(rgb, 1); \
+        gl_FragColor *= u_modulation; \
+    } \
+";
+
 static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
     GL_VERTEX_SHADER,
     GLES2_SOURCE_SHADER,
@@ -199,6 +243,20 @@
     GLES2_FragmentSrc_TextureYUVSrc_
 };
 
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12Src = {
+    GL_FRAGMENT_SHADER,
+    GLES2_SOURCE_SHADER,
+    sizeof(GLES2_FragmentSrc_TextureNV12Src_),
+    GLES2_FragmentSrc_TextureNV12Src_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21Src = {
+    GL_FRAGMENT_SHADER,
+    GLES2_SOURCE_SHADER,
+    sizeof(GLES2_FragmentSrc_TextureNV21Src_),
+    GLES2_FragmentSrc_TextureNV21Src_
+};
+
 
 /*************************************************************************************************
  * Vertex/fragment shader binaries (NVIDIA Tegra 1/2)                                            *
@@ -731,6 +789,20 @@
     }
 };
 
+static GLES2_Shader GLES2_FragmentShader_TextureNV12Src = {
+    1,
+    {
+        &GLES2_FragmentSrc_TextureNV12Src
+    }
+};
+
+static GLES2_Shader GLES2_FragmentShader_TextureNV21Src = {
+    1,
+    {
+        &GLES2_FragmentSrc_TextureNV21Src
+    }
+};
+
 
 /*************************************************************************************************
  * Shader selector                                                                               *
@@ -820,6 +892,16 @@
         return &GLES2_FragmentShader_TextureYUVSrc;
     }
 
+    case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC:
+    {
+        return &GLES2_FragmentShader_TextureNV12Src;
+    }
+
+    case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC:
+    {
+        return &GLES2_FragmentShader_TextureNV21Src;
+    }
+
     default:
         return NULL;
     }
--- a/src/render/opengles2/SDL_shaders_gles2.h	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/render/opengles2/SDL_shaders_gles2.h	Wed Aug 20 17:20:22 2014 -0300
@@ -47,7 +47,9 @@
     GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC,
     GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC,
     GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC,
-    GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC
+    GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC,
+    GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC,
+    GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC
 } GLES2_ShaderType;
 
 #define GLES2_SOURCE_SHADER (GLenum)-1
--- a/src/test/SDL_test_common.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/test/SDL_test_common.c	Wed Aug 20 17:20:22 2014 -0300
@@ -572,6 +572,12 @@
     case SDL_PIXELFORMAT_YVYU:
         fprintf(stderr, "YVYU");
         break;
+    case SDL_PIXELFORMAT_NV12:
+        fprintf(stderr, "NV12");
+        break;
+    case SDL_PIXELFORMAT_NV21:
+        fprintf(stderr, "NV21");
+        break;
     default:
         fprintf(stderr, "0x%8.8x", format);
         break;
--- a/src/video/SDL_pixels.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/SDL_pixels.c	Wed Aug 20 17:20:22 2014 -0300
@@ -122,6 +122,8 @@
     CASE(SDL_PIXELFORMAT_YUY2)
     CASE(SDL_PIXELFORMAT_UYVY)
     CASE(SDL_PIXELFORMAT_YVYU)
+    CASE(SDL_PIXELFORMAT_NV12)
+    CASE(SDL_PIXELFORMAT_NV21)
 #undef CASE
     default:
         return "SDL_PIXELFORMAT_UNKNOWN";
--- a/src/video/SDL_surface.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/SDL_surface.c	Wed Aug 20 17:20:22 2014 -0300
@@ -26,7 +26,6 @@
 #include "SDL_RLEaccel_c.h"
 #include "SDL_pixels_c.h"
 
-
 /* Public routines */
 /*
  * Create an empty RGB surface of the appropriate depth
@@ -623,7 +622,12 @@
 SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
               SDL_Surface * dst, SDL_Rect * dstrect)
 {
-    SDL_Rect final_src, final_dst, fulldst;
+    double src_x0, src_y0, src_x1, src_y1;
+    double dst_x0, dst_y0, dst_x1, dst_y1;
+    SDL_Rect final_src, final_dst;
+    double scaling_w, scaling_h;
+    int src_w, src_h;
+    int dst_w, dst_h;
 
     /* Make sure the surfaces aren't locked */
     if (!src || !dst) {
@@ -633,78 +637,135 @@
         return SDL_SetError("Surfaces must not be locked during blit");
     }
 
-    /* If the destination rectangle is NULL, use the entire dest surface */
-    if (dstrect == NULL) {
-        fulldst.x = fulldst.y = 0;
-        fulldst.w = dst->w;
-        fulldst.h = dst->h;
-        dstrect = &fulldst;
+    if (NULL == srcrect) {
+        src_w = src->w;
+        src_h = src->h;
+    } else {
+        src_w = srcrect->w;
+        src_h = srcrect->h;
+    }
+
+    if (NULL == dstrect) {
+        dst_w = dst->w;
+        dst_h = dst->h;
+    } else {
+        dst_w = dstrect->w;
+        dst_h = dstrect->h;
+    }
+
+    if (dst_w == src_w && dst_h == src_h) {
+        /* No scaling, defer to regular blit */
+        return SDL_BlitSurface(src, srcrect, dst, dstrect);
+    }
+
+    scaling_w = (double)dst_w / src_w;
+    scaling_h = (double)dst_h / src_h;
+
+    if (NULL == dstrect) {
+        dst_x0 = 0;
+        dst_y0 = 0;
+        dst_x1 = dst_w - 1;
+        dst_y1 = dst_h - 1;
+    } else {
+        dst_x0 = dstrect->x;
+        dst_y0 = dstrect->y;
+        dst_x1 = dst_x0 + dst_w - 1;
+        dst_y1 = dst_y0 + dst_h - 1;
     }
 
-    /* clip the source rectangle to the source surface */
-    if (srcrect) {
-        int maxw, maxh;
+    if (NULL == srcrect) {
+        src_x0 = 0;
+        src_y0 = 0;
+        src_x1 = src_w - 1;
+        src_y1 = src_h - 1;
+    } else {
+        src_x0 = srcrect->x;
+        src_y0 = srcrect->y;
+        src_x1 = src_x0 + src_w - 1;
+        src_y1 = src_y0 + src_h - 1;
 
-        final_src.x = srcrect->x;
-        final_src.w = srcrect->w;
-        if (final_src.x < 0) {
-            final_src.w += final_src.x;
-            final_src.x = 0;
+        /* Clip source rectangle to the source surface */
+
+        if (src_x0 < 0) {
+            dst_x0 -= src_x0 * scaling_w;
+            src_x0 = 0;
         }
-        maxw = src->w - final_src.x;
-        if (maxw < final_src.w)
-            final_src.w = maxw;
+
+        if (src_x1 >= src->w) {
+            dst_x1 -= (src_x1 - src->w + 1) * scaling_w;
+            src_x1 = src->w - 1;
+        }
 
-        final_src.y = srcrect->y;
-        final_src.h = srcrect->h;
-        if (final_src.y < 0) {
-            final_src.h += final_src.y;
-            final_src.y = 0;
+        if (src_y0 < 0) {
+            dst_y0 -= src_y0 * scaling_h;
+            src_y0 = 0;
+        }
+
+        if (src_y1 >= src->h) {
+            dst_y1 -= (src_y1 - src->h + 1) * scaling_h;
+            src_y1 = src->h - 1;
         }
-        maxh = src->h - final_src.y;
-        if (maxh < final_src.h)
-            final_src.h = maxh;
+    }
+
+    /* Clip destination rectangle to the clip rectangle */
 
-    } else {
-        final_src.x = final_src.y = 0;
-        final_src.w = src->w;
-        final_src.h = src->h;
+    /* Translate to clip space for easier calculations */
+    dst_x0 -= dst->clip_rect.x;
+    dst_x1 -= dst->clip_rect.x;
+    dst_y0 -= dst->clip_rect.y;
+    dst_y1 -= dst->clip_rect.y;
+
+    if (dst_x0 < 0) {
+        src_x0 -= dst_x0 / scaling_w;
+        dst_x0 = 0;
     }
 
-    /* clip the destination rectangle against the clip rectangle */
-    if (dstrect) {
-        int maxw, maxh;
-
-        final_dst.x = dstrect->x;
-        final_dst.w = dstrect->w;
-        if (final_dst.x < 0) {
-            final_dst.w += final_dst.x;
-            final_dst.x = 0;
-        }
-        maxw = dst->w - final_dst.x;
-        if (maxw < final_dst.w)
-            final_dst.w = maxw;
+    if (dst_x1 >= dst->clip_rect.w) {
+        src_x1 -= (dst_x1 - dst->clip_rect.w + 1) / scaling_w;
+        dst_x1 = dst->clip_rect.w - 1;
+    }
 
-        final_dst.y = dstrect->y;
-        final_dst.h = dstrect->h;
-        if (final_dst.y < 0) {
-            final_dst.h += final_dst.y;
-            final_dst.y = 0;
-        }
-        maxh = dst->h - final_dst.y;
-        if (maxh < final_dst.h)
-            final_dst.h = maxh;
-    } else {
-        final_dst.x = final_dst.y = 0;
-        final_dst.w = dst->w;
-        final_dst.h = dst->h;
+    if (dst_y0 < 0) {
+        src_y0 -= dst_y0 / scaling_h;
+        dst_y0 = 0;
+    }
+
+    if (dst_y1 >= dst->clip_rect.h) {
+        src_y1 -= (dst_y1 - dst->clip_rect.h + 1) / scaling_h;
+        dst_y1 = dst->clip_rect.h - 1;
     }
 
-    if (final_dst.w > 0 && final_dst.h > 0) {
-        return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst);
+    /* Translate back to surface coordinates */
+    dst_x0 += dst->clip_rect.x;
+    dst_x1 += dst->clip_rect.x;
+    dst_y0 += dst->clip_rect.y;
+    dst_y1 += dst->clip_rect.y;
+
+    final_src.x = SDL_floor(src_x0 + 0.5);
+    final_src.y = SDL_floor(src_y0 + 0.5);
+    final_src.w = SDL_floor(src_x1 - src_x0 + 1.5);
+    final_src.h = SDL_floor(src_y1 - src_y0 + 1.5);
+
+    final_dst.x = SDL_floor(dst_x0 + 0.5);
+    final_dst.y = SDL_floor(dst_y0 + 0.5);
+    final_dst.w = SDL_floor(dst_x1 - dst_x0 + 1.5);
+    final_dst.h = SDL_floor(dst_y1 - dst_y0 + 1.5);
+
+    if (final_dst.w < 0)
+        final_dst.w = 0;
+    if (final_dst.h < 0)
+        final_dst.h = 0;
+
+    if (dstrect)
+        *dstrect = final_dst;
+
+    if (final_dst.w == 0 || final_dst.h == 0 ||
+        final_src.w <= 0 || final_src.h <= 0) {
+        /* No-op. */
+        return 0;
     }
 
-    return 0;
+    return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst);
 }
 
 /**
@@ -721,43 +782,6 @@
         SDL_COPY_COLORKEY
     );
 
-    /* Save off the original dst width, height */
-    int dstW = dstrect->w;
-    int dstH = dstrect->h;
-    SDL_Rect full_rect;
-    SDL_Rect final_dst = *dstrect;
-    SDL_Rect final_src = *srcrect;
-
-    /* Clip the dst surface to the dstrect */
-    full_rect.x = 0;
-    full_rect.y = 0;
-    full_rect.w = dst->w;
-    full_rect.h = dst->h;
-    if (!SDL_IntersectRect(&final_dst, &full_rect, &final_dst)) {
-        return 0;
-    }
-
-    /* Did the dst width change? */
-    if ( dstW != final_dst.w ) {
-        /* scale the src width appropriately */
-        final_src.w = final_src.w * dst->clip_rect.w / dstW;
-    }
-
-    /* Did the dst height change? */
-    if ( dstH != final_dst.h ) {
-        /* scale the src width appropriately */
-        final_src.h = final_src.h * dst->clip_rect.h / dstH;
-    }
-
-    /* Clip the src surface to the srcrect */
-    full_rect.x = 0;
-    full_rect.y = 0;
-    full_rect.w = src->w;
-    full_rect.h = src->h;
-    if (!SDL_IntersectRect(&final_src, &full_rect, &final_src)) {
-        return 0;
-    }
-
     if (!(src->map->info.flags & SDL_COPY_NEAREST)) {
         src->map->info.flags |= SDL_COPY_NEAREST;
         SDL_InvalidateMap(src->map);
@@ -766,9 +790,9 @@
     if ( !(src->map->info.flags & complex_copy_flags) &&
          src->format->format == dst->format->format &&
          !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) {
-        return SDL_SoftStretch( src, &final_src, dst, &final_dst );
+        return SDL_SoftStretch( src, srcrect, dst, dstrect );
     } else {
-        return SDL_LowerBlit( src, &final_src, dst, &final_dst );
+        return SDL_LowerBlit( src, srcrect, dst, dstrect );
     }
 }
 
@@ -1005,7 +1029,7 @@
     SDL_Rect rect;
     void *nonconst_src = (void *) src;
 
-    /* Check to make sure we are bliting somewhere, so we don't crash */
+    /* Check to make sure we are blitting somewhere, so we don't crash */
     if (!dst) {
         return SDL_InvalidParamError("dst");
     }
@@ -1015,17 +1039,21 @@
 
     /* Fast path for same format copy */
     if (src_format == dst_format) {
-        int bpp;
+        int bpp, i;
 
         if (SDL_ISPIXELFORMAT_FOURCC(src_format)) {
             switch (src_format) {
-            case SDL_PIXELFORMAT_YV12:
-            case SDL_PIXELFORMAT_IYUV:
             case SDL_PIXELFORMAT_YUY2:
             case SDL_PIXELFORMAT_UYVY:
             case SDL_PIXELFORMAT_YVYU:
                 bpp = 2;
                 break;
+            case SDL_PIXELFORMAT_YV12:
+            case SDL_PIXELFORMAT_IYUV:
+            case SDL_PIXELFORMAT_NV12:
+            case SDL_PIXELFORMAT_NV21:
+                bpp = 1;
+                break;
             default:
                 return SDL_SetError("Unknown FOURCC pixel format");
             }
@@ -1034,11 +1062,32 @@
         }
         width *= bpp;
 
-        while (height-- > 0) {
+        for (i = height; i--;) {
             SDL_memcpy(dst, src, width);
             src = (Uint8*)src + src_pitch;
             dst = (Uint8*)dst + dst_pitch;
         }
+
+        if (src_format == SDL_PIXELFORMAT_YV12 || src_format == SDL_PIXELFORMAT_IYUV) {
+            /* U and V planes are a quarter the size of the Y plane */
+            width /= 2;
+            height /= 2;
+            src_pitch /= 2;
+            dst_pitch /= 2;
+            for (i = height * 2; i--;) {
+                SDL_memcpy(dst, src, width);
+                src = (Uint8*)src + src_pitch;
+                dst = (Uint8*)dst + dst_pitch;
+            }
+        } else if (src_format == SDL_PIXELFORMAT_NV12 || src_format == SDL_PIXELFORMAT_NV21) {
+            /* U/V plane is half the height of the Y plane */
+            height /= 2;
+            for (i = height; i--;) {
+                SDL_memcpy(dst, src, width);
+                src = (Uint8*)src + src_pitch;
+                dst = (Uint8*)dst + dst_pitch;
+            }
+        }
         return 0;
     }
 
--- a/src/video/cocoa/SDL_cocoaclipboard.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/cocoa/SDL_cocoaclipboard.m	Wed Aug 20 17:20:22 2014 -0300
@@ -37,34 +37,28 @@
 
 int
 Cocoa_SetClipboardText(_THIS, const char *text)
+{ @autoreleasepool
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    NSAutoreleasePool *pool;
     NSPasteboard *pasteboard;
     NSString *format = GetTextFormat(_this);
 
-    pool = [[NSAutoreleasePool alloc] init];
-
     pasteboard = [NSPasteboard generalPasteboard];
     data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
     [pasteboard setString:[NSString stringWithUTF8String:text] forType:format];
 
-    [pool release];
-
     return 0;
-}
+}}
 
 char *
 Cocoa_GetClipboardText(_THIS)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool;
     NSPasteboard *pasteboard;
     NSString *format = GetTextFormat(_this);
     NSString *available;
     char *text;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
     pasteboard = [NSPasteboard generalPasteboard];
     available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]];
     if ([available isEqualToString:format]) {
@@ -82,10 +76,8 @@
         text = SDL_strdup("");
     }
 
-    [pool release];
-
     return text;
-}
+}}
 
 SDL_bool
 Cocoa_HasClipboardText(_THIS)
@@ -101,13 +93,11 @@
 
 void
 Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool;
     NSPasteboard *pasteboard;
     NSInteger count;
 
-    pool = [[NSAutoreleasePool alloc] init];
-
     pasteboard = [NSPasteboard generalPasteboard];
     count = [pasteboard changeCount];
     if (count != data->clipboard_count) {
@@ -116,9 +106,7 @@
         }
         data->clipboard_count = count;
     }
-
-    [pool release];
-}
+}}
 
 #endif /* SDL_VIDEO_DRIVER_COCOA */
 
--- a/src/video/cocoa/SDL_cocoaevents.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/cocoa/SDL_cocoaevents.m	Wed Aug 20 17:20:22 2014 -0300
@@ -248,17 +248,16 @@
 
 void
 Cocoa_RegisterApp(void)
+{ @autoreleasepool
 {
     /* This can get called more than once! Be careful what you initialize! */
     ProcessSerialNumber psn;
-    NSAutoreleasePool *pool;
 
     if (!GetCurrentProcess(&psn)) {
         TransformProcessType(&psn, kProcessTransformToForegroundApplication);
         SetFrontProcess(&psn);
     }
 
-    pool = [[NSAutoreleasePool alloc] init];
     if (NSApp == nil) {
         [SDLApplication sharedApplication];
         SDL_assert(NSApp != nil);
@@ -287,14 +286,12 @@
             appDelegate->seenFirstActivate = YES;
         }
     }
-    [pool release];
-}
+}}
 
 void
 Cocoa_PumpEvents(_THIS)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool;
-
     /* Update activity every 30 seconds to prevent screensaver */
     if (_this->suspend_screensaver) {
         SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
@@ -306,7 +303,6 @@
         }
     }
 
-    pool = [[NSAutoreleasePool alloc] init];
     for ( ; ; ) {
         NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
         if ( event == nil ) {
@@ -338,8 +334,7 @@
         /* Pass through to NSApp to make sure everything stays in sync */
         [NSApp sendEvent:event];
     }
-    [pool release];
-}
+}}
 
 #endif /* SDL_VIDEO_DRIVER_COCOA */
 
--- a/src/video/cocoa/SDL_cocoakeyboard.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/cocoa/SDL_cocoakeyboard.m	Wed Aug 20 17:20:22 2014 -0300
@@ -479,9 +479,9 @@
 
 void
 Cocoa_StartTextInput(_THIS)
+{ @autoreleasepool
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     SDL_Window *window = SDL_GetKeyboardFocus();
     NSWindow *nswindow = nil;
     if (window) {
@@ -506,23 +506,20 @@
         [parentView addSubview: data->fieldEdit];
         [nswindow makeFirstResponder: data->fieldEdit];
     }
-
-    [pool release];
-}
+}}
 
 void
 Cocoa_StopTextInput(_THIS)
+{ @autoreleasepool
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
 
     if (data && data->fieldEdit) {
-        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
         [data->fieldEdit removeFromSuperview];
         [data->fieldEdit release];
         data->fieldEdit = nil;
-        [pool release];
     }
-}
+}}
 
 void
 Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
--- a/src/video/cocoa/SDL_cocoamessagebox.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/cocoa/SDL_cocoamessagebox.m	Wed Aug 20 17:20:22 2014 -0300
@@ -79,11 +79,10 @@
 /* Display a Cocoa message box */
 int
 Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
+{ @autoreleasepool
 {
     Cocoa_RegisterApp();
 
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
     NSAlert* alert = [[[NSAlert alloc] init] autorelease];
 
     if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
@@ -125,10 +124,8 @@
         returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked);
     }
 
-    [pool release];
-
     return returnValue;
-}
+}}
 
 #endif /* SDL_VIDEO_DRIVER_COCOA */
 
--- a/src/video/cocoa/SDL_cocoamodes.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/cocoa/SDL_cocoamodes.m	Wed Aug 20 17:20:22 2014 -0300
@@ -214,8 +214,8 @@
 
 void
 Cocoa_InitModes(_THIS)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     CGDisplayErr result;
     CGDirectDisplayID *displays;
     CGDisplayCount numDisplays;
@@ -224,7 +224,6 @@
     result = CGGetOnlineDisplayList(0, NULL, &numDisplays);
     if (result != kCGErrorSuccess) {
         CG_SetError("CGGetOnlineDisplayList()", result);
-        [pool release];
         return;
     }
     displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays);
@@ -232,7 +231,6 @@
     if (result != kCGErrorSuccess) {
         CG_SetError("CGGetOnlineDisplayList()", result);
         SDL_stack_free(displays);
-        [pool release];
         return;
     }
 
@@ -297,8 +295,7 @@
         }
     }
     SDL_stack_free(displays);
-    [pool release];
-}
+}}
 
 int
 Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
--- a/src/video/cocoa/SDL_cocoamouse.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/cocoa/SDL_cocoamouse.m	Wed Aug 20 17:20:22 2014 -0300
@@ -66,8 +66,8 @@
 
 static SDL_Cursor *
 Cocoa_CreateDefaultCursor()
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSCursor *nscursor;
     SDL_Cursor *cursor = NULL;
 
@@ -81,15 +81,13 @@
         }
     }
 
-    [pool release];
-
     return cursor;
-}
+}}
 
 static SDL_Cursor *
 Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSImage *nsimage;
     NSCursor *nscursor = NULL;
     SDL_Cursor *cursor = NULL;
@@ -108,15 +106,13 @@
         }
     }
 
-    [pool release];
-
     return cursor;
-}
+}}
 
 static SDL_Cursor *
 Cocoa_CreateSystemCursor(SDL_SystemCursor id)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSCursor *nscursor = NULL;
     SDL_Cursor *cursor = NULL;
 
@@ -169,28 +165,23 @@
         }
     }
 
-    [pool release];
-
     return cursor;
-}
+}}
 
 static void
 Cocoa_FreeCursor(SDL_Cursor * cursor)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSCursor *nscursor = (NSCursor *)cursor->driverdata;
 
     [nscursor release];
     SDL_free(cursor);
-
-    [pool release];
-}
+}}
 
 static int
 Cocoa_ShowCursor(SDL_Cursor * cursor)
+{ @autoreleasepool
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
     SDL_VideoDevice *device = SDL_GetVideoDevice();
     SDL_Window *window = (device ? device->windows : NULL);
     for (; window != NULL; window = window->next) {
@@ -201,48 +192,21 @@
                                                 waitUntilDone:NO];
         }
     }
-
-    [pool release];
-
     return 0;
-}
-
-static void
-Cocoa_WarpMouse(SDL_Window * window, int x, int y)
-{
-    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
-    if ([data->listener isMoving]) {
-        DLog("Postponing warp, window being moved.");
-        [data->listener setPendingMoveX:x
-                                      Y:y];
-        return;
-    }
-
-    SDL_Mouse *mouse = SDL_GetMouse();
-    CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y);
-
-    Cocoa_HandleMouseWarp(point.x, point.y);
-
-    /* According to the docs, this was deprecated in 10.6, but it's still
-     * around. The substitute requires a CGEventSource, but I'm not entirely
-     * sure how we'd procure the right one for this event.
-     */
-    CGSetLocalEventsSuppressionInterval(0.0);
-    CGWarpMouseCursorPosition(point);
-    CGSetLocalEventsSuppressionInterval(0.25);
-
-    if (!mouse->relative_mode) {
-        /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our
-         * other implementations' APIs.
-         */
-        SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
-    }
-}
+}}
 
 static void
 Cocoa_WarpMouseGlobal(int x, int y)
 {
     SDL_Mouse *mouse = SDL_GetMouse();
+    if (mouse->focus) {
+        SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata;
+        if ([data->listener isMoving]) {
+            DLog("Postponing warp, window being moved.");
+            [data->listener setPendingMoveX:x Y:y];
+            return;
+        }
+    }
     CGPoint point = CGPointMake((float)x, (float)y);
 
     Cocoa_HandleMouseWarp(point.x, point.y);
@@ -263,6 +227,12 @@
     }
 }
 
+static void
+Cocoa_WarpMouse(SDL_Window * window, int x, int y)
+{
+    Cocoa_WarpMouseGlobal(x + window->x, y + window->y);
+}
+
 static int
 Cocoa_SetRelativeMouseMode(SDL_bool enabled)
 {
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/cocoa/SDL_cocoawindow.m	Wed Aug 20 17:20:22 2014 -0300
@@ -103,8 +103,7 @@
 
 static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r)
 {
-    NSRect visibleScreen = fullscreen ? [screen frame] : [screen visibleFrame];
-    r->origin.y = (visibleScreen.origin.y + visibleScreen.size.height) - r->origin.y - r->size.height;
+    r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
 }
 
 static void
@@ -389,11 +388,11 @@
         isMoving = NO;
 
         SDL_Mouse *mouse = SDL_GetMouse();
-        if (pendingWindowWarpX >= 0 && pendingWindowWarpY >= 0) {
-            mouse->WarpMouse(_data->window, pendingWindowWarpX, pendingWindowWarpY);
-            pendingWindowWarpX = pendingWindowWarpY = -1;
+        if (pendingWindowWarpX != INT_MAX && pendingWindowWarpY != INT_MAX) {
+            mouse->WarpMouseGlobal(pendingWindowWarpX, pendingWindowWarpY);
+            pendingWindowWarpX = pendingWindowWarpY = INT_MAX;
         }
-        if (mouse->relative_mode && SDL_GetMouseFocus() == _data->window) {
+        if (mouse->relative_mode && !mouse->relative_mode_warp && mouse->focus == _data->window) {
             mouse->SetRelativeMouseMode(SDL_TRUE);
         }
     }
@@ -413,7 +412,7 @@
 - (void)windowWillMove:(NSNotification *)aNotification
 {
     if ([_data->nswindow isKindOfClass:[SDLWindow class]]) {
-        pendingWindowWarpX = pendingWindowWarpY = -1;
+        pendingWindowWarpX = pendingWindowWarpY = INT_MAX;
         isMoving = YES;
     }
 }
@@ -500,7 +499,7 @@
 {
     SDL_Window *window = _data->window;
     SDL_Mouse *mouse = SDL_GetMouse();
-    if (mouse->relative_mode && ![self isMoving]) {
+    if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) {
         mouse->SetRelativeMouseMode(SDL_TRUE);
     }
 
@@ -532,7 +531,7 @@
 - (void)windowDidResignKey:(NSNotification *)aNotification
 {
     SDL_Mouse *mouse = SDL_GetMouse();
-    if (mouse->relative_mode) {
+    if (mouse->relative_mode && !mouse->relative_mode_warp) {
         mouse->SetRelativeMouseMode(SDL_FALSE);
     }
 
--- a/src/video/x11/SDL_x11events.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/x11/SDL_x11events.c	Wed Aug 20 17:20:22 2014 -0300
@@ -347,6 +347,9 @@
         X11_XSetICFocus(data->ic);
     }
 #endif
+#ifdef SDL_USE_IBUS
+    SDL_IBus_SetFocus(SDL_TRUE);
+#endif
 }
 
 static void
@@ -367,6 +370,9 @@
         X11_XUnsetICFocus(data->ic);
     }
 #endif
+#ifdef SDL_USE_IBUS
+    SDL_IBus_SetFocus(SDL_FALSE);
+#endif
 }
 
 static void
@@ -647,11 +653,6 @@
 #ifdef DEBUG_XEVENTS
             printf("window %p: FocusIn!\n", data);
 #endif
-#ifdef SDL_USE_IBUS
-            if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){
-                SDL_IBus_SetFocus(SDL_TRUE);
-            }
-#endif
             if (data->pending_focus == PENDING_FOCUS_OUT &&
                 data->window == SDL_GetKeyboardFocus()) {
                 /* We want to reset the keyboard here, because we may have
@@ -689,11 +690,6 @@
 #ifdef DEBUG_XEVENTS
             printf("window %p: FocusOut!\n", data);
 #endif
-#ifdef SDL_USE_IBUS
-            if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){
-                SDL_IBus_SetFocus(SDL_FALSE);
-            }
-#endif
             data->pending_focus = PENDING_FOCUS_OUT;
             data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_OUT_TIME;
         }
@@ -725,16 +721,11 @@
             KeySym keysym = NoSymbol;
             char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
             Status status = 0;
-#ifdef SDL_USE_IBUS
-            Bool handled = False;
-#endif
+            SDL_bool handled_by_ime = SDL_FALSE;
 
 #ifdef DEBUG_XEVENTS
             printf("window %p: KeyPress (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode);
 #endif
-#ifndef SDL_USE_IBUS
-            SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
-#endif
 #if 1
             if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
                 int min_keycode, max_keycode;
@@ -762,7 +753,7 @@
 #endif
 #ifdef SDL_USE_IBUS
             if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){
-                if(!(handled = SDL_IBus_ProcessKeyEvent(keysym, keycode))){
+                if(!(handled_by_ime = SDL_IBus_ProcessKeyEvent(keysym, keycode))){
 #endif
                     if(*text){
                         SDL_SendKeyboardText(text);
@@ -770,11 +761,11 @@
 #ifdef SDL_USE_IBUS
                 }
             }
-
-            if (!handled) {
+#endif
+            if (!handled_by_ime) {
                 SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
             }
-#endif
+
         }
         break;
 
@@ -1073,7 +1064,8 @@
                    because they use the NETWM protocol to notify us of changes.
                  */
                 Uint32 flags = X11_GetNetWMState(_this, xevent.xproperty.window);
-                if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN) {
+				if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN ||
+					(flags^data->window->flags) & SDL_WINDOW_FULLSCREEN ) {
                     if (flags & SDL_WINDOW_HIDDEN) {
                         X11_DispatchUnmapNotify(data);
                     } else {
--- a/src/video/x11/SDL_x11keyboard.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/src/video/x11/SDL_x11keyboard.c	Wed Aug 20 17:20:22 2014 -0300
@@ -332,9 +332,7 @@
 void
 X11_StartTextInput(_THIS)
 {
-#ifdef SDL_USE_IBUS
-    SDL_IBus_SetFocus(SDL_GetFocusWindow() != NULL);
-#endif
+
 }
 
 void
--- a/test/loopwavequeue.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/test/loopwavequeue.c	Wed Aug 20 17:20:22 2014 -0300
@@ -15,12 +15,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "SDL.h"
+
 #if HAVE_SIGNAL_H
 #include <signal.h>
 #endif
 
-#include "SDL.h"
-
 struct
 {
     SDL_AudioSpec spec;
--- a/test/testautomation_pixels.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/test/testautomation_pixels.c	Wed Aug 20 17:20:22 2014 -0300
@@ -79,14 +79,16 @@
   };
 
 /* Definition of all Non-RGB formats used to test pixel conversions */
-const int _numNonRGBPixelFormats = 5;
+const int _numNonRGBPixelFormats = 7;
 Uint32 _nonRGBPixelFormats[] =
   {
     SDL_PIXELFORMAT_YV12,
     SDL_PIXELFORMAT_IYUV,
     SDL_PIXELFORMAT_YUY2,
     SDL_PIXELFORMAT_UYVY,
-    SDL_PIXELFORMAT_YVYU
+    SDL_PIXELFORMAT_YVYU,
+    SDL_PIXELFORMAT_NV12,
+    SDL_PIXELFORMAT_NV21
   };
 char* _nonRGBPixelFormatsVerbose[] =
   {
@@ -94,7 +96,9 @@
     "SDL_PIXELFORMAT_IYUV",
     "SDL_PIXELFORMAT_YUY2",
     "SDL_PIXELFORMAT_UYVY",
-    "SDL_PIXELFORMAT_YVYU"
+    "SDL_PIXELFORMAT_YVYU",
+    "SDL_PIXELFORMAT_NV12",
+    "SDL_PIXELFORMAT_NV21"
   };
 
 /* Definition of some invalid formats for negative tests */
--- a/test/testhaptic.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/test/testhaptic.c	Wed Aug 20 17:20:22 2014 -0300
@@ -45,8 +45,8 @@
     int i;
     char *name;
     int index;
-    SDL_HapticEffect efx[5];
-    int id[5];
+    SDL_HapticEffect efx[9];
+    int id[9];
     int nefx;
     unsigned int supported;
 
@@ -149,6 +149,7 @@
         }
         nefx++;
     }
+    
     /* Now the classical constant effect. */
     if (supported & SDL_HAPTIC_CONSTANT) {
         SDL_Log("   effect %d: Constant Force\n", nefx);
@@ -166,14 +167,15 @@
         }
         nefx++;
     }
+    
     /* The cute spring effect. */
     if (supported & SDL_HAPTIC_SPRING) {
         SDL_Log("   effect %d: Condition Spring\n", nefx);
         efx[nefx].type = SDL_HAPTIC_SPRING;
         efx[nefx].condition.length = 5000;
         for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
-            efx[nefx].condition.right_sat[i] = 0x7FFF;
-            efx[nefx].condition.left_sat[i] = 0x7FFF;
+            efx[nefx].condition.right_sat[i] = 0xFFFF;
+            efx[nefx].condition.left_sat[i] = 0xFFFF;
             efx[nefx].condition.right_coeff[i] = 0x2000;
             efx[nefx].condition.left_coeff[i] = 0x2000;
             efx[nefx].condition.center[i] = 0x1000;     /* Displace the center for it to move. */
@@ -185,14 +187,51 @@
         }
         nefx++;
     }
+    /* The interesting damper effect. */
+    if (supported & SDL_HAPTIC_DAMPER) {
+        SDL_Log("   effect %d: Condition Damper\n", nefx);
+        efx[nefx].type = SDL_HAPTIC_DAMPER;
+        efx[nefx].condition.length = 5000;
+        for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
+            efx[nefx].condition.right_sat[i] = 0xFFFF;
+            efx[nefx].condition.left_sat[i] = 0xFFFF;
+            efx[nefx].condition.right_coeff[i] = 0x2000;
+            efx[nefx].condition.left_coeff[i] = 0x2000;
+        }
+        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
+        if (id[nefx] < 0) {
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            abort_execution();
+        }
+        nefx++;
+    }
     /* The pretty awesome inertia effect. */
     if (supported & SDL_HAPTIC_INERTIA) {
         SDL_Log("   effect %d: Condition Inertia\n", nefx);
         efx[nefx].type = SDL_HAPTIC_INERTIA;
         efx[nefx].condition.length = 5000;
         for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
-            efx[nefx].condition.right_sat[i] = 0x7FFF;
-            efx[nefx].condition.left_sat[i] = 0x7FFF;
+            efx[nefx].condition.right_sat[i] = 0xFFFF;
+            efx[nefx].condition.left_sat[i] = 0xFFFF;
+            efx[nefx].condition.right_coeff[i] = 0x2000;
+            efx[nefx].condition.left_coeff[i] = 0x2000;
+            efx[nefx].condition.deadband[i] = 0x1000;    /* 1/16th of axis-range around the center is 'dead'. */
+        }
+        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
+        if (id[nefx] < 0) {
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            abort_execution();
+        }
+        nefx++;
+    }
+    /* The hot friction effect. */
+    if (supported & SDL_HAPTIC_FRICTION) {
+        SDL_Log("   effect %d: Condition Friction\n", nefx);
+        efx[nefx].type = SDL_HAPTIC_FRICTION;
+        efx[nefx].condition.length = 5000;
+        for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
+            efx[nefx].condition.right_sat[i] = 0xFFFF;
+            efx[nefx].condition.left_sat[i] = 0xFFFF;
             efx[nefx].condition.right_coeff[i] = 0x2000;
             efx[nefx].condition.left_coeff[i] = 0x2000;
         }
@@ -203,6 +242,26 @@
         }
         nefx++;
     }
+    
+    /* Now we'll try a ramp effect */
+    if (supported & SDL_HAPTIC_RAMP) {
+        SDL_Log("   effect %d: Ramp\n", nefx);
+        efx[nefx].type = SDL_HAPTIC_RAMP;
+        efx[nefx].ramp.direction.type = SDL_HAPTIC_CARTESIAN;
+        efx[nefx].ramp.direction.dir[0] = 1;     /* Force comes from                 */
+        efx[nefx].ramp.direction.dir[1] = -1;    /*                  the north-east. */
+        efx[nefx].ramp.length = 5000;
+        efx[nefx].ramp.start = 0x4000;
+        efx[nefx].ramp.end = -0x4000;
+        efx[nefx].ramp.attack_length = 1000;
+        efx[nefx].ramp.fade_length = 1000;
+        id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
+        if (id[nefx] < 0) {
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            abort_execution();
+        }
+        nefx++;
+    }
 
     /* Finally we'll try a left/right effect. */
     if (supported & SDL_HAPTIC_LEFTRIGHT) {
--- a/test/testoverlay2.c	Fri Aug 08 15:14:09 2014 -0300
+++ b/test/testoverlay2.c	Wed Aug 20 17:20:22 2014 -0300
@@ -206,6 +206,29 @@
     }
 }
 
+void
+ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h,
+                 int monochrome, int luminance)
+{
+    int x, y;
+    int yuv[3];
+    Uint8 *op[2];
+
+    op[0] = out;
+    op[1] = op[0] + w*h;
+    for (y = 0; y < h; ++y) {
+        for (x = 0; x < w; ++x) {
+            RGBtoYUV(rgb, yuv, monochrome, luminance);
+            *(op[0]++) = yuv[0];
+            if (x % 2 == 0 && y % 2 == 0) {
+                *(op[1]++) = yuv[1];
+                *(op[1]++) = yuv[2];
+            }
+            rgb += 3;
+        }
+    }
+}
+
 static void
 PrintUsage(char *argv0)
 {
@@ -241,7 +264,11 @@
     int fps = 12;
     int fpsdelay;
     int nodelay = 0;
+#ifdef TEST_NV12
+    Uint32 pixel_format = SDL_PIXELFORMAT_NV12;
+#else
     Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
+#endif
     int scale = 5;
     SDL_bool done = SDL_FALSE;
 
@@ -371,7 +398,17 @@
             rgb[2] = MooseColors[frame[j]].b;
             rgb += 3;
         }
-        ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
+        switch (pixel_format) {
+        case SDL_PIXELFORMAT_YV12:
+            ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
+            break;
+        case SDL_PIXELFORMAT_NV12:
+            ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
+            break;
+        default:
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n");
+            break;
+        }
     }
 
     free(RawMooseData);