changeset 5157:fb424691cfc7

Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 02 Feb 2011 14:34:54 -0800
parents 3e4086b3bcd2
children f3ebd1950442
files VisualC/SDL/SDL_VS2008.vcproj VisualC/SDL/SDL_VS2010.vcxproj VisualC/SDL_VS2008.sln VisualC/SDL_VS2010.sln Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Xcode/SDL/SDL.xcodeproj/project.pbxproj configure.in include/SDL_rect.h include/SDL_video.h src/events/SDL_events.c src/render/SDL_render.c src/render/SDL_sysrender.h src/render/direct3d/SDL_d3drender.c src/render/opengl/SDL_renderer_gl.c src/render/opengles/SDL_renderer_gles.c src/render/software/SDL_renderer_sw.c src/video/SDL_pixels_c.h src/video/SDL_rect.c src/video/SDL_rect_c.h src/video/SDL_renderer_gl.c src/video/SDL_renderer_gl.h src/video/SDL_renderer_gles.c src/video/SDL_renderer_gles.h src/video/SDL_renderer_sw.c src/video/SDL_renderer_sw.h src/video/SDL_sysvideo.h src/video/SDL_video.c src/video/directfb/SDL_DirectFB_render.c src/video/dummy/SDL_nullrender.c src/video/dummy/SDL_nullrender_c.h src/video/dummy/SDL_nullvideo.c src/video/uikit/SDL_uikitvideo.m src/video/uikit/SDL_uikitwindow.m src/video/windows/SDL_d3drender.c src/video/windows/SDL_d3drender.h src/video/windows/SDL_windowskeyboard.c src/video/windows/SDL_windowsvideo.c src/video/windows/SDL_windowsvideo.h src/video/x11/SDL_x11video.h
diffstat 39 files changed, 5581 insertions(+), 6144 deletions(-) [+]
line wrap: on
line diff
--- a/VisualC/SDL/SDL_VS2008.vcproj	Wed Feb 02 14:34:24 2011 -0800
+++ b/VisualC/SDL/SDL_VS2008.vcproj	Wed Feb 02 14:34:54 2011 -0800
@@ -30,7 +30,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadfood&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;xcopy /d /q /y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -201,7 +201,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadfood&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;xcopy /d /q /y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -386,6 +386,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_blendmode.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_clipboard.h"
 				>
 			</File>
@@ -422,10 +426,18 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_gesture.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_haptic.h"
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_input.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_joystick.h"
 				>
 			</File>
@@ -486,6 +498,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_render.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_revision.h"
 				>
 			</File>
@@ -498,6 +514,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_shape.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_stdinc.h"
 				>
 			</File>
@@ -518,6 +538,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_touch.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_types.h"
 				>
 			</File>
@@ -751,11 +775,7 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\windows\SDL_d3drender.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\video\windows\SDL_d3drender.h"
+			RelativePath="..\..\src\render\direct3d\SDL_d3drender.c"
 			>
 		</File>
 		<File
@@ -943,14 +963,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\dummy\SDL_nullrender.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\video\dummy\SDL_nullrender_c.h"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\video\dummy\SDL_nullvideo.c"
 			>
 		</File>
@@ -987,19 +999,15 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_renderer_gl.c"
+			RelativePath="..\..\src\render\SDL_render.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_renderer_gl.h"
+			RelativePath="..\..\src\render\opengl\SDL_renderer_gl.c"
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\video\SDL_renderer_sw.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\video\SDL_renderer_sw.h"
+			RelativePath="..\..\src\render\software\SDL_renderer_sw.c"
 			>
 		</File>
 		<File
@@ -1075,6 +1083,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\render\SDL_sysrender.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\thread\windows\SDL_syssem.c"
 			>
 		</File>
--- a/VisualC/SDL/SDL_VS2010.vcxproj	Wed Feb 02 14:34:24 2011 -0800
+++ b/VisualC/SDL/SDL_VS2010.vcxproj	Wed Feb 02 14:34:54 2011 -0800
@@ -75,7 +75,7 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>echo Copying SDL_config_windows.h to SDL_config.h...
-copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+xcopy /d /q /y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
@@ -153,7 +153,7 @@
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
       <Command>echo Copying SDL_config_windows.h to SDL_config.h...
-copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
+xcopy /d /q /y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
@@ -231,6 +231,7 @@
     <ClInclude Include="..\..\include\SDL_assert.h" />
     <ClInclude Include="..\..\include\SDL_atomic.h" />
     <ClInclude Include="..\..\include\SDL_audio.h" />
+    <ClInclude Include="..\..\include\SDL_blendmode.h" />
     <ClInclude Include="..\..\include\SDL_clipboard.h" />
     <ClInclude Include="..\..\include\SDL_compat.h" />
     <ClInclude Include="..\..\include\SDL_config.h" />
@@ -240,7 +241,9 @@
     <ClInclude Include="..\..\include\SDL_endian.h" />
     <ClInclude Include="..\..\include\SDL_error.h" />
     <ClInclude Include="..\..\include\SDL_events.h" />
+    <ClInclude Include="..\..\include\SDL_gesture.h" />
     <ClInclude Include="..\..\include\SDL_haptic.h" />
+    <ClInclude Include="..\..\include\SDL_input.h" />
     <ClInclude Include="..\..\include\SDL_joystick.h" />
     <ClInclude Include="..\..\include\SDL_keyboard.h" />
     <ClInclude Include="..\..\include\SDL_keysym.h" />
@@ -256,6 +259,7 @@
     <ClInclude Include="..\..\include\SDL_power.h" />
     <ClInclude Include="..\..\include\SDL_quit.h" />
     <ClInclude Include="..\..\include\SDL_rect.h" />
+    <ClInclude Include="..\..\include\SDL_render.h" />
     <ClInclude Include="..\..\include\SDL_revision.h" />
     <ClInclude Include="..\..\include\SDL_rwops.h" />
     <ClInclude Include="..\..\include\SDL_scancode.h" />
@@ -265,6 +269,7 @@
     <ClInclude Include="..\..\include\SDL_syswm.h" />
     <ClInclude Include="..\..\include\SDL_thread.h" />
     <ClInclude Include="..\..\include\SDL_timer.h" />
+    <ClInclude Include="..\..\include\SDL_touch.h" />
     <ClInclude Include="..\..\include\SDL_types.h" />
     <ClInclude Include="..\..\include\SDL_version.h" />
     <ClInclude Include="..\..\include\SDL_video.h" />
@@ -277,6 +282,7 @@
     <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
     <ClInclude Include="..\..\src\libm\math.h" />
     <ClInclude Include="..\..\src\libm\math_private.h" />
+    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
     <ClInclude Include="..\..\src\video\mmx.h" />
     <ClInclude Include="..\..\src\video\SDL_alphamult.h" />
     <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
@@ -287,7 +293,6 @@
     <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
     <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
     <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
-    <ClInclude Include="..\..\src\video\windows\SDL_d3drender.h" />
     <ClInclude Include="..\..\src\audio\windib\SDL_dibaudio.h" />
     <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
     <ClInclude Include="..\..\src\video\SDL_draw.h" />
@@ -306,12 +311,9 @@
     <ClInclude Include="..\..\src\audio\SDL_mixer_MMX_VC.h" />
     <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
     <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h" />
-    <ClInclude Include="..\..\src\video\dummy\SDL_nullrender_c.h" />
     <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
     <ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
     <ClInclude Include="..\..\src\video\SDL_rect_c.h" />
-    <ClInclude Include="..\..\src\video\SDL_renderer_gl.h" />
-    <ClInclude Include="..\..\src\video\SDL_renderer_sw.h" />
     <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
     <ClInclude Include="..\..\src\video\SDL_stretch_c.h" />
     <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
@@ -360,6 +362,10 @@
     <ClCompile Include="..\..\src\libm\s_floor.c" />
     <ClCompile Include="..\..\src\libm\s_scalbn.c" />
     <ClCompile Include="..\..\src\libm\s_sin.c" />
+    <ClCompile Include="..\..\src\render\direct3d\SDL_d3drender.c" />
+    <ClCompile Include="..\..\src\render\opengl\SDL_renderer_gl.c" />
+    <ClCompile Include="..\..\src\render\SDL_render.c" />
+    <ClCompile Include="..\..\src\render\software\SDL_renderer_sw.c" />
     <ClCompile Include="..\..\src\SDL.c" />
     <ClCompile Include="..\..\src\video\SDL_alphamult.c" />
     <ClCompile Include="..\..\src\SDL_assert.c" />
@@ -386,7 +392,6 @@
     <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
     <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
     <ClCompile Include="..\..\src\video\SDL_shape.c" />
-    <ClCompile Include="..\..\src\video\windows\SDL_d3drender.c" />
     <ClCompile Include="..\..\src\audio\windib\SDL_dibaudio.c" />
     <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
     <ClCompile Include="..\..\src\video\SDL_drawline.c" />
@@ -413,15 +418,12 @@
     <ClCompile Include="..\..\src\joystick\windows\SDL_mmjoystick.c" />
     <ClCompile Include="..\..\src\events\SDL_mouse.c" />
     <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
-    <ClCompile Include="..\..\src\video\dummy\SDL_nullrender.c" />
     <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c" />
     <ClCompile Include="..\..\src\video\SDL_pixels.c" />
     <ClCompile Include="..\..\src\power\SDL_power.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
     <ClCompile Include="..\..\src\events\SDL_quit.c" />
     <ClCompile Include="..\..\src\video\SDL_rect.c" />
-    <ClCompile Include="..\..\src\video\SDL_renderer_gl.c" />
-    <ClCompile Include="..\..\src\video\SDL_renderer_sw.c" />
     <ClCompile Include="..\..\src\video\SDL_RLEaccel.c" />
     <ClCompile Include="..\..\src\file\SDL_rwops.c" />
     <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
@@ -456,4 +458,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
--- a/VisualC/SDL_VS2008.sln	Wed Feb 02 14:34:24 2011 -0800
+++ b/VisualC/SDL_VS2008.sln	Wed Feb 02 14:34:54 2011 -0800
@@ -84,12 +84,6 @@
 		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpalette", "tests\testpalette\testpalette_VS2008.vcproj", "{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}"
-	ProjectSection(ProjectDependencies) = postProject
-		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
-		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
-	EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testplatform", "tests\testplatform\testplatform_VS2008.vcproj", "{26932B24-EFC6-4E3A-B277-ED653DA37968}"
 	ProjectSection(ProjectDependencies) = postProject
 		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
@@ -301,15 +295,6 @@
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|Win32.ActiveCfg = Release|Win32
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|Win32.Build.0 = Release|Win32
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.Build.0 = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|x64.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|Win32.Build.0 = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.Build.0 = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|x64.ActiveCfg = Release|Win32
 		{26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.ActiveCfg = Debug|Win32
 		{26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|Win32.Build.0 = Debug|Win32
 		{26932B24-EFC6-4E3A-B277-ED653DA37968}.Debug|x64.ActiveCfg = Debug|Win32
@@ -418,7 +403,6 @@
 		{55812185-D13C-4022-9C81-32E0F4A08304} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{9E320A14-B443-4DD7-8725-B7020DCFF730} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{26932B24-EFC6-4E3A-B277-ED653DA37968} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{C4E04D18-EF76-4B42-B4C2-16A1BACDC0A3} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{5D0930C0-7C91-4ECE-9014-7B7DDE9502E5} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
--- a/VisualC/SDL_VS2010.sln	Wed Feb 02 14:34:24 2011 -0800
+++ b/VisualC/SDL_VS2010.sln	Wed Feb 02 14:34:54 2011 -0800
@@ -49,12 +49,6 @@
 		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpalette", "tests\testpalette\testpalette_VS2010.vcxproj", "{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}"
-	ProjectSection(ProjectDependencies) = postProject
-		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
-		{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
-	EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testvidinfo", "tests\testvidinfo\testvidinfo_VS2010.vcxproj", "{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}"
 	ProjectSection(ProjectDependencies) = postProject
 		{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
@@ -230,14 +224,6 @@
 		{55812185-D13C-4022-9C81-32E0F4A08304}.Release|Win32.ActiveCfg = Release|Win32
 		{55812185-D13C-4022-9C81-32E0F4A08304}.Release|Win32.Build.0 = Release|Win32
 		{55812185-D13C-4022-9C81-32E0F4A08304}.Release|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|Win32.Build.0 = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Debug|x64.ActiveCfg = Debug|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release_NoSTDIO|x64.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.ActiveCfg = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|Win32.Build.0 = Release|Win32
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC}.Release|x64.ActiveCfg = Release|Win32
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}.Debug|Win32.ActiveCfg = Debug|Win32
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}.Debug|Win32.Build.0 = Debug|Win32
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0}.Debug|x64.ActiveCfg = Debug|Win32
@@ -361,7 +347,6 @@
 		{D974A0DF-3E2E-445C-A2EB-E899E9B582CB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{272D976B-A1DF-4DEB-BD7F-5C0D330E0C7D} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{55812185-D13C-4022-9C81-32E0F4A08304} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
-		{493A8F38-5DA5-4E2D-B5E9-9E69EE4ED1DC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{575FD095-EDAB-4BD4-B733-CD4A874F6FB0} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{0FFD1A21-11DB-492C-A989-E4F195B0C441} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
 		{6AF0724B-BAC1-4C9D-AFBF-F63B4A2FB8FB} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Wed Feb 02 14:34:24 2011 -0800
+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Wed Feb 02 14:34:54 2011 -0800
@@ -62,6 +62,11 @@
 		0098A5631195B4D900343137 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5621195B4D900343137 /* OpenGLES.framework */; };
 		0098A5651195B4D900343137 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5641195B4D900343137 /* UIKit.framework */; };
 		0098A5851195B5E200343137 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0098A5841195B5E200343137 /* QuartzCore.framework */; };
+		041B2CD912FA0E9E0087D585 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2CD812FA0E9E0087D585 /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		041B2CF012FA0F680087D585 /* SDL_renderer_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2CE912FA0F680087D585 /* SDL_renderer_gles.c */; };
+		041B2CF112FA0F680087D585 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2CEA12FA0F680087D585 /* SDL_render.c */; };
+		041B2CF212FA0F680087D585 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2CEB12FA0F680087D585 /* SDL_sysrender.h */; };
+		041B2CF312FA0F680087D585 /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2CED12FA0F680087D585 /* SDL_renderer_sw.c */; };
 		0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */; };
 		0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */; };
 		043DD76F10FD8A0000DED673 /* SDL_alphamult.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76B10FD8A0000DED673 /* SDL_alphamult.c */; };
@@ -69,8 +74,8 @@
 		043DD77110FD8A0000DED673 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */; };
 		043DD77210FD8A0000DED673 /* SDL_drawrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 043DD76E10FD8A0000DED673 /* SDL_drawrect.c */; };
 		04461DEE0EA76BA3006C462D /* SDL_haptic.h in Headers */ = {isa = PBXBuildFile; fileRef = 04461DED0EA76BA3006C462D /* SDL_haptic.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB311E6069F0076F181 /* SDL_clipboard.h */; };
-		044E5FB611E6069F0076F181 /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB411E6069F0076F181 /* SDL_input.h */; };
+		044E5FB511E6069F0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB311E6069F0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		044E5FB611E6069F0076F181 /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5FB411E6069F0076F181 /* SDL_input.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		044E5FB811E606EB0076F181 /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = 044E5FB711E606EB0076F181 /* SDL_clipboard.c */; };
 		0463873F0F0B5B7D0041FD65 /* SDL_blendline.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387370F0B5B7D0041FD65 /* SDL_blendline.c */; };
 		046387400F0B5B7D0041FD65 /* SDL_blendpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = 046387380F0B5B7D0041FD65 /* SDL_blendpoint.c */; };
@@ -86,10 +91,6 @@
 		047AF1B30EA98D6C00811173 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = 047AF1B20EA98D6C00811173 /* SDL_sysloadso.c */; };
 		0495E68A0E97408800152DFE /* SDL_glesfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6840E97408800152DFE /* SDL_glesfuncs.h */; };
 		0495E68B0E97408800152DFE /* SDL_glfuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6850E97408800152DFE /* SDL_glfuncs.h */; };
-		0495E68C0E97408800152DFE /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 0495E6860E97408800152DFE /* SDL_renderer_gl.c */; };
-		0495E68D0E97408800152DFE /* SDL_renderer_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6870E97408800152DFE /* SDL_renderer_gl.h */; };
-		0495E68E0E97408800152DFE /* SDL_renderer_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 0495E6880E97408800152DFE /* SDL_renderer_gles.c */; };
-		0495E68F0E97408800152DFE /* SDL_renderer_gles.h in Headers */ = {isa = PBXBuildFile; fileRef = 0495E6890E97408800152DFE /* SDL_renderer_gles.h */; };
 		04B2ECEC1025CE4800F9BC5F /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04B2ECED1025CE4800F9BC5F /* SDL_power.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B2ECE71025CE4800F9BC5F /* SDL_power.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04B2ECEE1025CE4800F9BC5F /* SDL_revision.h in Headers */ = {isa = PBXBuildFile; fileRef = 04B2ECE81025CE4800F9BC5F /* SDL_revision.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -98,16 +99,15 @@
 		04BA9D6411EF474A00B60E01 /* SDL_gesture.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BA9D6011EF474A00B60E01 /* SDL_gesture.c */; };
 		04BA9D6511EF474A00B60E01 /* SDL_touch_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D6111EF474A00B60E01 /* SDL_touch_c.h */; };
 		04BA9D6611EF474A00B60E01 /* SDL_touch.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BA9D6211EF474A00B60E01 /* SDL_touch.c */; };
-		04BA9D7D11EF497E00B60E01 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7B11EF497E00B60E01 /* SDL_gesture.h */; };
-		04BA9D7E11EF497E00B60E01 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7C11EF497E00B60E01 /* SDL_touch.h */; };
-		04EC8B521025D12900431D42 /* SDL_config_iphoneos.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */; };
-		04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF531104ABC300D6DDF7 /* SDL_assert.h */; };
+		04BA9D7D11EF497E00B60E01 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7B11EF497E00B60E01 /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04BA9D7E11EF497E00B60E01 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7C11EF497E00B60E01 /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04EC8B521025D12900431D42 /* SDL_config_iphoneos.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF531104ABC300D6DDF7 /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04F2AF561104ABD200D6DDF7 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F2AF551104ABD200D6DDF7 /* SDL_assert.c */; };
 		04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8912E23B8D00BA343D /* SDL_atomic.c */; };
 		04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */ = {isa = PBXBuildFile; fileRef = 04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */; };
-		04FFAB9612E23BDC00BA343D /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */; };
-		04FFAB9712E23BDC00BA343D /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9412E23BDC00BA343D /* SDL_scalemode.h */; };
-		04FFAB9812E23BDC00BA343D /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9512E23BDC00BA343D /* SDL_shape.h */; };
+		04FFAB9612E23BDC00BA343D /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04FFAB9812E23BDC00BA343D /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04FFAB9512E23BDC00BA343D /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		56ED04E1118A8EE200A56AA6 /* SDL_power.c in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E0118A8EE200A56AA6 /* SDL_power.c */; };
 		56ED04E3118A8EFD00A56AA6 /* SDL_syspower.m in Sources */ = {isa = PBXBuildFile; fileRef = 56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */; };
 		FD24846D0E5655AE0021E198 /* SDL_uikitkeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = FD24846B0E5655AE0021E198 /* SDL_uikitkeyboard.h */; };
@@ -198,7 +198,6 @@
 		FD689F270E26E5D900F90B21 /* SDL_uikitopenglview.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689F170E26E5D900F90B21 /* SDL_uikitopenglview.m */; };
 		FD689FCE0E26E9D400F90B21 /* SDL_uikitappdelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FD689FCC0E26E9D400F90B21 /* SDL_uikitappdelegate.m */; };
 		FD689FCF0E26E9D400F90B21 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = FD689FCD0E26E9D400F90B21 /* SDL_uikitappdelegate.h */; };
-		FD6C83B60DEA66E500ABEE55 /* SDL_systimer.h in Headers */ = {isa = PBXBuildFile; fileRef = FD99BA2D0DD52EDC00FB1D6B /* SDL_systimer.h */; };
 		FD8BD7AC0E27DCA400B52CD5 /* SDL_opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = FD8BD7AB0E27DCA400B52CD5 /* SDL_opengles.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		FD8BD8250E27E25900B52CD5 /* SDL_sysloadso.c in Sources */ = {isa = PBXBuildFile; fileRef = FD8BD8190E27E25900B52CD5 /* SDL_sysloadso.c */; };
 		FDA6844D0DF2374E00F98A1A /* SDL_blit.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683000DF2374E00F98A1A /* SDL_blit.c */; };
@@ -218,9 +217,6 @@
 		FDA6845C0DF2374E00F98A1A /* SDL_pixels.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */; };
 		FDA6845D0DF2374E00F98A1A /* SDL_pixels_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683100DF2374E00F98A1A /* SDL_pixels_c.h */; };
 		FDA6845E0DF2374E00F98A1A /* SDL_rect.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683110DF2374E00F98A1A /* SDL_rect.c */; };
-		FDA6845F0DF2374E00F98A1A /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683120DF2374E00F98A1A /* SDL_rect_c.h */; };
-		FDA684600DF2374E00F98A1A /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683130DF2374E00F98A1A /* SDL_renderer_sw.c */; };
-		FDA684610DF2374E00F98A1A /* SDL_renderer_sw.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683140DF2374E00F98A1A /* SDL_renderer_sw.h */; };
 		FDA684620DF2374E00F98A1A /* SDL_RLEaccel.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */; };
 		FDA684630DF2374E00F98A1A /* SDL_RLEaccel_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA683160DF2374E00F98A1A /* SDL_RLEaccel_c.h */; };
 		FDA684640DF2374E00F98A1A /* SDL_stretch.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA683170DF2374E00F98A1A /* SDL_stretch.c */; };
@@ -232,8 +228,6 @@
 		FDA6846B0DF2374E00F98A1A /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA6831E0DF2374E00F98A1A /* SDL_yuv_sw_c.h */; };
 		FDA685FB0DF244C800F98A1A /* SDL_nullevents.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA685F50DF244C800F98A1A /* SDL_nullevents.c */; };
 		FDA685FC0DF244C800F98A1A /* SDL_nullevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA685F60DF244C800F98A1A /* SDL_nullevents_c.h */; };
-		FDA685FD0DF244C800F98A1A /* SDL_nullrender.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA685F70DF244C800F98A1A /* SDL_nullrender.c */; };
-		FDA685FE0DF244C800F98A1A /* SDL_nullrender_c.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA685F80DF244C800F98A1A /* SDL_nullrender_c.h */; };
 		FDA685FF0DF244C800F98A1A /* SDL_nullvideo.c in Sources */ = {isa = PBXBuildFile; fileRef = FDA685F90DF244C800F98A1A /* SDL_nullvideo.c */; };
 		FDA686000DF244C800F98A1A /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA685FA0DF244C800F98A1A /* SDL_nullvideo.h */; };
 		FDC656480E560DF800311C8E /* jumphack.c in Sources */ = {isa = PBXBuildFile; fileRef = FDC656440E560DF800311C8E /* jumphack.c */; };
@@ -323,6 +317,11 @@
 		0098A5621195B4D900343137 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
 		0098A5641195B4D900343137 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		0098A5841195B5E200343137 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
+		041B2CD812FA0E9E0087D585 /* SDL_render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_render.h; path = ../../include/SDL_render.h; sourceTree = SOURCE_ROOT; };
+		041B2CE912FA0F680087D585 /* SDL_renderer_gles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gles.c; sourceTree = "<group>"; };
+		041B2CEA12FA0F680087D585 /* SDL_render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render.c; sourceTree = "<group>"; };
+		041B2CEB12FA0F680087D585 /* SDL_sysrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysrender.h; sourceTree = "<group>"; };
+		041B2CED12FA0F680087D585 /* SDL_renderer_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_sw.c; sourceTree = "<group>"; };
 		0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
 		0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
 		043DD76B10FD8A0000DED673 /* SDL_alphamult.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_alphamult.c; sourceTree = "<group>"; };
@@ -347,10 +346,6 @@
 		047AF1B20EA98D6C00811173 /* SDL_sysloadso.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_sysloadso.c; sourceTree = "<group>"; };
 		0495E6840E97408800152DFE /* SDL_glesfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_glesfuncs.h; sourceTree = "<group>"; };
 		0495E6850E97408800152DFE /* SDL_glfuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_glfuncs.h; sourceTree = "<group>"; };
-		0495E6860E97408800152DFE /* SDL_renderer_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gl.c; sourceTree = "<group>"; };
-		0495E6870E97408800152DFE /* SDL_renderer_gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gl.h; sourceTree = "<group>"; };
-		0495E6880E97408800152DFE /* SDL_renderer_gles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gles.c; sourceTree = "<group>"; };
-		0495E6890E97408800152DFE /* SDL_renderer_gles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gles.h; sourceTree = "<group>"; };
 		04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_atomic.h; path = ../../include/SDL_atomic.h; sourceTree = SOURCE_ROOT; };
 		04B2ECE71025CE4800F9BC5F /* SDL_power.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_power.h; path = ../../include/SDL_power.h; sourceTree = SOURCE_ROOT; };
 		04B2ECE81025CE4800F9BC5F /* SDL_revision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_revision.h; path = ../../include/SDL_revision.h; sourceTree = SOURCE_ROOT; };
@@ -367,7 +362,6 @@
 		04FFAB8912E23B8D00BA343D /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = "<group>"; };
 		04FFAB8A12E23B8D00BA343D /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
 		04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_blendmode.h; path = ../../include/SDL_blendmode.h; sourceTree = SOURCE_ROOT; };
-		04FFAB9412E23BDC00BA343D /* SDL_scalemode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scalemode.h; path = ../../include/SDL_scalemode.h; sourceTree = SOURCE_ROOT; };
 		04FFAB9512E23BDC00BA343D /* SDL_shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_shape.h; path = ../../include/SDL_shape.h; sourceTree = SOURCE_ROOT; };
 		56ED04E0118A8EE200A56AA6 /* SDL_power.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_power.c; path = ../../src/power/SDL_power.c; sourceTree = SOURCE_ROOT; };
 		56ED04E2118A8EFD00A56AA6 /* SDL_syspower.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDL_syspower.m; path = ../../src/power/uikit/SDL_syspower.m; sourceTree = SOURCE_ROOT; };
@@ -458,7 +452,6 @@
 		FD99B98E0DD52EDC00FB1D6B /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = "<group>"; };
 		FD99B98F0DD52EDC00FB1D6B /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = "<group>"; };
 		FD99B9900DD52EDC00FB1D6B /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = "<group>"; };
-		FD99B9910DD52EDC00FB1D6B /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = "<group>"; };
 		FD99B9920DD52EDC00FB1D6B /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = "<group>"; };
 		FD99B9930DD52EDC00FB1D6B /* SDL_events.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_events.c; sourceTree = "<group>"; };
 		FD99B9940DD52EDC00FB1D6B /* SDL_events_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_events_c.h; sourceTree = "<group>"; };
@@ -486,7 +479,6 @@
 		FD99BA140DD52EDC00FB1D6B /* SDL_systhread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systhread.h; sourceTree = "<group>"; };
 		FD99BA150DD52EDC00FB1D6B /* SDL_thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_thread.c; sourceTree = "<group>"; };
 		FD99BA160DD52EDC00FB1D6B /* SDL_thread_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_thread_c.h; sourceTree = "<group>"; };
-		FD99BA2D0DD52EDC00FB1D6B /* SDL_systimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systimer.h; sourceTree = "<group>"; };
 		FD99BA2E0DD52EDC00FB1D6B /* SDL_timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_timer.c; sourceTree = "<group>"; };
 		FD99BA2F0DD52EDC00FB1D6B /* SDL_timer_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_timer_c.h; sourceTree = "<group>"; };
 		FD99BA310DD52EDC00FB1D6B /* SDL_systimer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systimer.c; sourceTree = "<group>"; };
@@ -507,9 +499,6 @@
 		FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_pixels.c; sourceTree = "<group>"; };
 		FDA683100DF2374E00F98A1A /* SDL_pixels_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_pixels_c.h; sourceTree = "<group>"; };
 		FDA683110DF2374E00F98A1A /* SDL_rect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rect.c; sourceTree = "<group>"; };
-		FDA683120DF2374E00F98A1A /* SDL_rect_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rect_c.h; sourceTree = "<group>"; };
-		FDA683130DF2374E00F98A1A /* SDL_renderer_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_sw.c; sourceTree = "<group>"; };
-		FDA683140DF2374E00F98A1A /* SDL_renderer_sw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_sw.h; sourceTree = "<group>"; };
 		FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_RLEaccel.c; sourceTree = "<group>"; };
 		FDA683160DF2374E00F98A1A /* SDL_RLEaccel_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_RLEaccel_c.h; sourceTree = "<group>"; };
 		FDA683170DF2374E00F98A1A /* SDL_stretch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_stretch.c; sourceTree = "<group>"; };
@@ -521,8 +510,6 @@
 		FDA6831E0DF2374E00F98A1A /* SDL_yuv_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_sw_c.h; sourceTree = "<group>"; };
 		FDA685F50DF244C800F98A1A /* SDL_nullevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullevents.c; sourceTree = "<group>"; };
 		FDA685F60DF244C800F98A1A /* SDL_nullevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullevents_c.h; sourceTree = "<group>"; };
-		FDA685F70DF244C800F98A1A /* SDL_nullrender.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullrender.c; sourceTree = "<group>"; };
-		FDA685F80DF244C800F98A1A /* SDL_nullrender_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullrender_c.h; sourceTree = "<group>"; };
 		FDA685F90DF244C800F98A1A /* SDL_nullvideo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullvideo.c; sourceTree = "<group>"; };
 		FDA685FA0DF244C800F98A1A /* SDL_nullvideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullvideo.h; sourceTree = "<group>"; };
 		FDC261780E3A3FC8001C4554 /* keyinfotable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keyinfotable.h; sourceTree = "<group>"; };
@@ -668,6 +655,34 @@
 			path = cocoa;
 			sourceTree = "<group>";
 		};
+		041B2CE312FA0F680087D585 /* render */ = {
+			isa = PBXGroup;
+			children = (
+				041B2CE812FA0F680087D585 /* opengles */,
+				041B2CEA12FA0F680087D585 /* SDL_render.c */,
+				041B2CEB12FA0F680087D585 /* SDL_sysrender.h */,
+				041B2CEC12FA0F680087D585 /* software */,
+			);
+			name = render;
+			path = ../../src/render;
+			sourceTree = SOURCE_ROOT;
+		};
+		041B2CE812FA0F680087D585 /* opengles */ = {
+			isa = PBXGroup;
+			children = (
+				041B2CE912FA0F680087D585 /* SDL_renderer_gles.c */,
+			);
+			path = opengles;
+			sourceTree = "<group>";
+		};
+		041B2CEC12FA0F680087D585 /* software */ = {
+			isa = PBXGroup;
+			children = (
+				041B2CED12FA0F680087D585 /* SDL_renderer_sw.c */,
+			);
+			path = software;
+			sourceTree = "<group>";
+		};
 		047677B60EA769DF008ABAF1 /* haptic */ = {
 			isa = PBXGroup;
 			children = (
@@ -849,15 +864,13 @@
 		FD99B8BC0DD52E5C00FB1D6B /* Public Headers */ = {
 			isa = PBXGroup;
 			children = (
-				04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */,
-				04FFAB9412E23BDC00BA343D /* SDL_scalemode.h */,
-				04FFAB9512E23BDC00BA343D /* SDL_shape.h */,
 				FD99B8CC0DD52EB400FB1D6B /* begin_code.h */,
 				FD99B8CD0DD52EB400FB1D6B /* close_code.h */,
 				FD99B8F50DD52EB400FB1D6B /* SDL.h */,
 				04F2AF531104ABC300D6DDF7 /* SDL_assert.h */,
 				04B2ECE61025CE4800F9BC5F /* SDL_atomic.h */,
 				FD99B8CF0DD52EB400FB1D6B /* SDL_audio.h */,
+				04FFAB9312E23BDC00BA343D /* SDL_blendmode.h */,
 				044E5FB311E6069F0076F181 /* SDL_clipboard.h */,
 				FD99B8D10DD52EB400FB1D6B /* SDL_compat.h */,
 				04B2ED061025CF9E00F9BC5F /* SDL_config.h */,
@@ -885,9 +898,11 @@
 				04B2ECE71025CE4800F9BC5F /* SDL_power.h */,
 				FD99B8E90DD52EB400FB1D6B /* SDL_quit.h */,
 				FD99B8EA0DD52EB400FB1D6B /* SDL_rect.h */,
+				041B2CD812FA0E9E0087D585 /* SDL_render.h */,
 				04B2ECE81025CE4800F9BC5F /* SDL_revision.h */,
 				FD99B8EB0DD52EB400FB1D6B /* SDL_rwops.h */,
 				FD99B8EC0DD52EB400FB1D6B /* SDL_scancode.h */,
+				04FFAB9512E23BDC00BA343D /* SDL_shape.h */,
 				FD99B8ED0DD52EB400FB1D6B /* SDL_stdinc.h */,
 				FD99B8EE0DD52EB400FB1D6B /* SDL_surface.h */,
 				FD99B8EF0DD52EB400FB1D6B /* SDL_syswm.h */,
@@ -904,13 +919,6 @@
 		FD99B8BD0DD52E6D00FB1D6B /* Library Source */ = {
 			isa = PBXGroup;
 			children = (
-				04F2AF551104ABD200D6DDF7 /* SDL_assert.c */,
-				FD99B9D30DD52EDC00FB1D6B /* SDL_compat.c */,
-				FD99B9D40DD52EDC00FB1D6B /* SDL_error_c.h */,
-				FD99B9D50DD52EDC00FB1D6B /* SDL_error.c */,
-				FD99B9D60DD52EDC00FB1D6B /* SDL_fatal.c */,
-				FD99B9D70DD52EDC00FB1D6B /* SDL_fatal.h */,
-				FD99B9D80DD52EDC00FB1D6B /* SDL.c */,
 				04B2ECEF1025CEB900F9BC5F /* atomic */,
 				FD99B8FB0DD52EDC00FB1D6B /* audio */,
 				FD99B98A0DD52EDC00FB1D6B /* cpuinfo */,
@@ -920,10 +928,18 @@
 				FD5F9D080E0E08B3008E885B /* joystick */,
 				FD8BD8150E27E25900B52CD5 /* loadso */,
 				56ED04DE118A8E9A00A56AA6 /* power */,
+				041B2CE312FA0F680087D585 /* render */,
 				FD3F4A6F0DEA620800C5B771 /* stdlib */,
 				FD99B9E00DD52EDC00FB1D6B /* thread */,
 				FD99BA1E0DD52EDC00FB1D6B /* timer */,
 				FDA682420DF2374D00F98A1A /* video */,
+				04F2AF551104ABD200D6DDF7 /* SDL_assert.c */,
+				FD99B9D30DD52EDC00FB1D6B /* SDL_compat.c */,
+				FD99B9D40DD52EDC00FB1D6B /* SDL_error_c.h */,
+				FD99B9D50DD52EDC00FB1D6B /* SDL_error.c */,
+				FD99B9D60DD52EDC00FB1D6B /* SDL_fatal.c */,
+				FD99B9D70DD52EDC00FB1D6B /* SDL_fatal.h */,
+				FD99B9D80DD52EDC00FB1D6B /* SDL.c */,
 			);
 			name = "Library Source";
 			sourceTree = "<group>";
@@ -982,7 +998,6 @@
 				FD99B98E0DD52EDC00FB1D6B /* default_cursor.h */,
 				FD99B98F0DD52EDC00FB1D6B /* scancodes_darwin.h */,
 				FD99B9900DD52EDC00FB1D6B /* scancodes_linux.h */,
-				FD99B9910DD52EDC00FB1D6B /* scancodes_win32.h */,
 				FD99B9920DD52EDC00FB1D6B /* scancodes_xfree86.h */,
 				0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */,
 				0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */,
@@ -1039,10 +1054,9 @@
 		FD99BA1E0DD52EDC00FB1D6B /* timer */ = {
 			isa = PBXGroup;
 			children = (
-				FD99BA2D0DD52EDC00FB1D6B /* SDL_systimer.h */,
+				FD99BA300DD52EDC00FB1D6B /* unix */,
 				FD99BA2E0DD52EDC00FB1D6B /* SDL_timer.c */,
 				FD99BA2F0DD52EDC00FB1D6B /* SDL_timer_c.h */,
-				FD99BA300DD52EDC00FB1D6B /* unix */,
 			);
 			name = timer;
 			path = ../../src/timer;
@@ -1059,15 +1073,10 @@
 		FDA682420DF2374D00F98A1A /* video */ = {
 			isa = PBXGroup;
 			children = (
-				044E5FB711E606EB0076F181 /* SDL_clipboard.c */,
 				FD689F090E26E5D900F90B21 /* uikit */,
 				FDA685F40DF244C800F98A1A /* dummy */,
 				0495E6850E97408800152DFE /* SDL_glfuncs.h */,
 				0495E6840E97408800152DFE /* SDL_glesfuncs.h */,
-				0495E6860E97408800152DFE /* SDL_renderer_gl.c */,
-				0495E6870E97408800152DFE /* SDL_renderer_gl.h */,
-				0495E6880E97408800152DFE /* SDL_renderer_gles.c */,
-				0495E6890E97408800152DFE /* SDL_renderer_gles.h */,
 				043DD76B10FD8A0000DED673 /* SDL_alphamult.c */,
 				043DD76C10FD8A0000DED673 /* SDL_alphamult.h */,
 				043DD76D10FD8A0000DED673 /* SDL_blendfillrect.c */,
@@ -1087,6 +1096,7 @@
 				FDA6830A0DF2374E00F98A1A /* SDL_blit_slow.c */,
 				0463873A0F0B5B7D0041FD65 /* SDL_blit_slow.h */,
 				FDA6830B0DF2374E00F98A1A /* SDL_bmp.c */,
+				044E5FB711E606EB0076F181 /* SDL_clipboard.c */,
 				0463873B0F0B5B7D0041FD65 /* SDL_draw.h */,
 				0463873C0F0B5B7D0041FD65 /* SDL_drawline.c */,
 				0463873D0F0B5B7D0041FD65 /* SDL_drawpoint.c */,
@@ -1097,9 +1107,6 @@
 				FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */,
 				FDA683100DF2374E00F98A1A /* SDL_pixels_c.h */,
 				FDA683110DF2374E00F98A1A /* SDL_rect.c */,
-				FDA683120DF2374E00F98A1A /* SDL_rect_c.h */,
-				FDA683130DF2374E00F98A1A /* SDL_renderer_sw.c */,
-				FDA683140DF2374E00F98A1A /* SDL_renderer_sw.h */,
 				FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */,
 				FDA683160DF2374E00F98A1A /* SDL_RLEaccel_c.h */,
 				FDA683170DF2374E00F98A1A /* SDL_stretch.c */,
@@ -1119,8 +1126,6 @@
 			children = (
 				FDA685F50DF244C800F98A1A /* SDL_nullevents.c */,
 				FDA685F60DF244C800F98A1A /* SDL_nullevents_c.h */,
-				FDA685F70DF244C800F98A1A /* SDL_nullrender.c */,
-				FDA685F80DF244C800F98A1A /* SDL_nullrender_c.h */,
 				FDA685F90DF244C800F98A1A /* SDL_nullvideo.c */,
 				FDA685FA0DF244C800F98A1A /* SDL_nullvideo.h */,
 			);
@@ -1134,7 +1139,6 @@
 			isa = PBXHeadersBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				FD6C83B60DEA66E500ABEE55 /* SDL_systimer.h in Headers */,
 				FD3F495C0DEA5B2100C5B771 /* begin_code.h in Headers */,
 				FD3F495D0DEA5B2100C5B771 /* close_code.h in Headers */,
 				FD3F495F0DEA5B2100C5B771 /* SDL_audio.h in Headers */,
@@ -1173,13 +1177,10 @@
 				FDA684550DF2374E00F98A1A /* SDL_blit_copy.h in Headers */,
 				FDA6845B0DF2374E00F98A1A /* SDL_leaks.h in Headers */,
 				FDA6845D0DF2374E00F98A1A /* SDL_pixels_c.h in Headers */,
-				FDA6845F0DF2374E00F98A1A /* SDL_rect_c.h in Headers */,
-				FDA684610DF2374E00F98A1A /* SDL_renderer_sw.h in Headers */,
 				FDA684630DF2374E00F98A1A /* SDL_RLEaccel_c.h in Headers */,
 				FDA684670DF2374E00F98A1A /* SDL_sysvideo.h in Headers */,
 				FDA6846B0DF2374E00F98A1A /* SDL_yuv_sw_c.h in Headers */,
 				FDA685FC0DF244C800F98A1A /* SDL_nullevents_c.h in Headers */,
-				FDA685FE0DF244C800F98A1A /* SDL_nullrender_c.h in Headers */,
 				FDA686000DF244C800F98A1A /* SDL_nullvideo.h in Headers */,
 				FD5F9D300E0E08B3008E885B /* SDL_joystick_c.h in Headers */,
 				FD5F9D310E0E08B3008E885B /* SDL_sysjoystick.h in Headers */,
@@ -1196,8 +1197,6 @@
 				FD24846D0E5655AE0021E198 /* SDL_uikitkeyboard.h in Headers */,
 				0495E68A0E97408800152DFE /* SDL_glesfuncs.h in Headers */,
 				0495E68B0E97408800152DFE /* SDL_glfuncs.h in Headers */,
-				0495E68D0E97408800152DFE /* SDL_renderer_gl.h in Headers */,
-				0495E68F0E97408800152DFE /* SDL_renderer_gles.h in Headers */,
 				047677BD0EA76A31008ABAF1 /* SDL_syshaptic.h in Headers */,
 				04461DEE0EA76BA3006C462D /* SDL_haptic.h in Headers */,
 				046387420F0B5B7D0041FD65 /* SDL_blit_slow.h in Headers */,
@@ -1218,8 +1217,9 @@
 				04BA9D7D11EF497E00B60E01 /* SDL_gesture.h in Headers */,
 				04BA9D7E11EF497E00B60E01 /* SDL_touch.h in Headers */,
 				04FFAB9612E23BDC00BA343D /* SDL_blendmode.h in Headers */,
-				04FFAB9712E23BDC00BA343D /* SDL_scalemode.h in Headers */,
 				04FFAB9812E23BDC00BA343D /* SDL_shape.h in Headers */,
+				041B2CD912FA0E9E0087D585 /* SDL_render.h in Headers */,
+				041B2CF212FA0F680087D585 /* SDL_sysrender.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1423,7 +1423,6 @@
 				FDA6845A0DF2374E00F98A1A /* SDL_gamma.c in Sources */,
 				FDA6845C0DF2374E00F98A1A /* SDL_pixels.c in Sources */,
 				FDA6845E0DF2374E00F98A1A /* SDL_rect.c in Sources */,
-				FDA684600DF2374E00F98A1A /* SDL_renderer_sw.c in Sources */,
 				FDA684620DF2374E00F98A1A /* SDL_RLEaccel.c in Sources */,
 				FDA684640DF2374E00F98A1A /* SDL_stretch.c in Sources */,
 				FDA684660DF2374E00F98A1A /* SDL_surface.c in Sources */,
@@ -1431,7 +1430,6 @@
 				FDA684690DF2374E00F98A1A /* SDL_yuv_mmx.c in Sources */,
 				FDA6846A0DF2374E00F98A1A /* SDL_yuv_sw.c in Sources */,
 				FDA685FB0DF244C800F98A1A /* SDL_nullevents.c in Sources */,
-				FDA685FD0DF244C800F98A1A /* SDL_nullrender.c in Sources */,
 				FDA685FF0DF244C800F98A1A /* SDL_nullvideo.c in Sources */,
 				FD5F9D2F0E0E08B3008E885B /* SDL_joystick.c in Sources */,
 				FD689EFB0E26E57800F90B21 /* SDL_coreaudio_iphone.c in Sources */,
@@ -1446,8 +1444,6 @@
 				FD689FCE0E26E9D400F90B21 /* SDL_uikitappdelegate.m in Sources */,
 				FD8BD8250E27E25900B52CD5 /* SDL_sysloadso.c in Sources */,
 				FDC656480E560DF800311C8E /* jumphack.c in Sources */,
-				0495E68C0E97408800152DFE /* SDL_renderer_gl.c in Sources */,
-				0495E68E0E97408800152DFE /* SDL_renderer_gles.c in Sources */,
 				047677BB0EA76A31008ABAF1 /* SDL_syshaptic.c in Sources */,
 				047677BC0EA76A31008ABAF1 /* SDL_haptic.c in Sources */,
 				047AF1B30EA98D6C00811173 /* SDL_sysloadso.c in Sources */,
@@ -1470,6 +1466,9 @@
 				04BA9D6611EF474A00B60E01 /* SDL_touch.c in Sources */,
 				04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */,
 				04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */,
+				041B2CF012FA0F680087D585 /* SDL_renderer_gles.c in Sources */,
+				041B2CF112FA0F680087D585 /* SDL_render.c in Sources */,
+				041B2CF312FA0F680087D585 /* SDL_renderer_sw.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Wed Feb 02 14:34:24 2011 -0800
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Wed Feb 02 14:34:54 2011 -0800
@@ -121,12 +121,20 @@
 		00D8DA281195093100638393 /* SDL_at.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA151195093100638393 /* SDL_at.c */; };
 		00D8DA291195093100638393 /* surface.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA181195093100638393 /* surface.c */; };
 		00D8DA2A1195093100638393 /* testsdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA1A1195093100638393 /* testsdl.c */; };
+		041B2C9512FA0D2A0087D585 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9412FA0D2A0087D585 /* SDL_render.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		041B2C9612FA0D2A0087D585 /* SDL_render.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9412FA0D2A0087D585 /* SDL_render.h */; };
+		041B2CA312FA0D680087D585 /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2C9B12FA0D680087D585 /* SDL_renderer_gl.c */; };
+		041B2CA512FA0D680087D585 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2C9E12FA0D680087D585 /* SDL_render.c */; };
+		041B2CA612FA0D680087D585 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9F12FA0D680087D585 /* SDL_sysrender.h */; };
+		041B2CA712FA0D680087D585 /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2CA112FA0D680087D585 /* SDL_renderer_sw.c */; };
+		041B2CA912FA0D680087D585 /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2C9B12FA0D680087D585 /* SDL_renderer_gl.c */; };
+		041B2CAB12FA0D680087D585 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2C9E12FA0D680087D585 /* SDL_render.c */; };
+		041B2CAC12FA0D680087D585 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9F12FA0D680087D585 /* SDL_sysrender.h */; };
+		041B2CAD12FA0D680087D585 /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2CA112FA0D680087D585 /* SDL_renderer_sw.c */; };
 		044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; };
 		0469A10B12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		0469A10C12EE4BF100B846D6 /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		0469A10D12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; };
-		0469A10E12EE4BF100B846D6 /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */; };
 		04BD000812E6671800899322 /* SDL_diskaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD8812E6671700899322 /* SDL_diskaudio.c */; };
 		04BD000912E6671800899322 /* SDL_diskaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD8912E6671700899322 /* SDL_diskaudio.h */; };
 		04BD001012E6671800899322 /* SDL_dummyaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD9412E6671700899322 /* SDL_dummyaudio.c */; };
@@ -155,7 +163,6 @@
 		04BD004312E6671800899322 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD712E6671700899322 /* default_cursor.h */; };
 		04BD004412E6671800899322 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD812E6671700899322 /* scancodes_darwin.h */; };
 		04BD004512E6671800899322 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD912E6671700899322 /* scancodes_linux.h */; };
-		04BD004612E6671800899322 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDA12E6671700899322 /* scancodes_win32.h */; };
 		04BD004712E6671800899322 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDB12E6671700899322 /* scancodes_xfree86.h */; };
 		04BD004812E6671800899322 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */; };
 		04BD004912E6671800899322 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */; };
@@ -212,7 +219,6 @@
 		04BD00C912E6671800899322 /* SDL_systhread.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8B12E6671800899322 /* SDL_systhread.h */; };
 		04BD00CA12E6671800899322 /* SDL_thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE8C12E6671800899322 /* SDL_thread.c */; };
 		04BD00CB12E6671800899322 /* SDL_thread_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8D12E6671800899322 /* SDL_thread_c.h */; };
-		04BD00D612E6671800899322 /* SDL_systimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE9E12E6671800899322 /* SDL_systimer.h */; };
 		04BD00D712E6671800899322 /* SDL_timer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE9F12E6671800899322 /* SDL_timer.c */; };
 		04BD00D812E6671800899322 /* SDL_timer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEA012E6671800899322 /* SDL_timer_c.h */; };
 		04BD00D912E6671800899322 /* SDL_systimer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEA212E6671800899322 /* SDL_systimer.c */; };
@@ -236,8 +242,6 @@
 		04BD010412E6671800899322 /* SDL_cocoawindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFED312E6671800899322 /* SDL_cocoawindow.m */; };
 		04BD011712E6671800899322 /* SDL_nullevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEE812E6671800899322 /* SDL_nullevents.c */; };
 		04BD011812E6671800899322 /* SDL_nullevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEE912E6671800899322 /* SDL_nullevents_c.h */; };
-		04BD011912E6671800899322 /* SDL_nullrender.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEA12E6671800899322 /* SDL_nullrender.c */; };
-		04BD011A12E6671800899322 /* SDL_nullrender_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */; };
 		04BD011B12E6671800899322 /* SDL_nullvideo.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEC12E6671800899322 /* SDL_nullvideo.c */; };
 		04BD011C12E6671800899322 /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEED12E6671800899322 /* SDL_nullvideo.h */; };
 		04BD013212E6671800899322 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF0412E6671800899322 /* mmx.h */; };
@@ -273,13 +277,6 @@
 		04BD018C12E6671800899322 /* SDL_pixels.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6512E6671800899322 /* SDL_pixels.c */; };
 		04BD018D12E6671800899322 /* SDL_pixels_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6612E6671800899322 /* SDL_pixels_c.h */; };
 		04BD018E12E6671800899322 /* SDL_rect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6712E6671800899322 /* SDL_rect.c */; };
-		04BD018F12E6671800899322 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6812E6671800899322 /* SDL_rect_c.h */; };
-		04BD019012E6671800899322 /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6912E6671800899322 /* SDL_renderer_gl.c */; };
-		04BD019112E6671800899322 /* SDL_renderer_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */; };
-		04BD019212E6671800899322 /* SDL_renderer_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */; };
-		04BD019312E6671800899322 /* SDL_renderer_gles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */; };
-		04BD019412E6671800899322 /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */; };
-		04BD019512E6671800899322 /* SDL_renderer_sw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */; };
 		04BD019612E6671800899322 /* SDL_RLEaccel.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */; };
 		04BD019712E6671800899322 /* SDL_RLEaccel_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */; };
 		04BD019812E6671800899322 /* SDL_shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7112E6671800899322 /* SDL_shape.c */; };
@@ -311,8 +308,6 @@
 		04BD01EC12E6671800899322 /* SDL_x11opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFC912E6671800899322 /* SDL_x11opengl.h */; };
 		04BD01ED12E6671800899322 /* SDL_x11opengles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCA12E6671800899322 /* SDL_x11opengles.c */; };
 		04BD01EE12E6671800899322 /* SDL_x11opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCB12E6671800899322 /* SDL_x11opengles.h */; };
-		04BD01EF12E6671800899322 /* SDL_x11render.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCC12E6671800899322 /* SDL_x11render.c */; };
-		04BD01F012E6671800899322 /* SDL_x11render.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCD12E6671800899322 /* SDL_x11render.h */; };
 		04BD01F112E6671800899322 /* SDL_x11shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCE12E6671800899322 /* SDL_x11shape.c */; };
 		04BD01F212E6671800899322 /* SDL_x11shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCF12E6671800899322 /* SDL_x11shape.h */; };
 		04BD01F312E6671800899322 /* SDL_x11sym.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD012E6671800899322 /* SDL_x11sym.h */; };
@@ -381,7 +376,6 @@
 		04BD025E12E6671800899322 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD712E6671700899322 /* default_cursor.h */; };
 		04BD025F12E6671800899322 /* scancodes_darwin.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD812E6671700899322 /* scancodes_darwin.h */; };
 		04BD026012E6671800899322 /* scancodes_linux.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDD912E6671700899322 /* scancodes_linux.h */; };
-		04BD026112E6671800899322 /* scancodes_win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDA12E6671700899322 /* scancodes_win32.h */; };
 		04BD026212E6671800899322 /* scancodes_xfree86.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDB12E6671700899322 /* scancodes_xfree86.h */; };
 		04BD026312E6671800899322 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */; };
 		04BD026412E6671800899322 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */; };
@@ -438,7 +432,6 @@
 		04BD02E312E6671800899322 /* SDL_systhread.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8B12E6671800899322 /* SDL_systhread.h */; };
 		04BD02E412E6671800899322 /* SDL_thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE8C12E6671800899322 /* SDL_thread.c */; };
 		04BD02E512E6671800899322 /* SDL_thread_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE8D12E6671800899322 /* SDL_thread_c.h */; };
-		04BD02F012E6671800899322 /* SDL_systimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFE9E12E6671800899322 /* SDL_systimer.h */; };
 		04BD02F112E6671800899322 /* SDL_timer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFE9F12E6671800899322 /* SDL_timer.c */; };
 		04BD02F212E6671800899322 /* SDL_timer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEA012E6671800899322 /* SDL_timer_c.h */; };
 		04BD02F312E6671800899322 /* SDL_systimer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEA212E6671800899322 /* SDL_systimer.c */; };
@@ -462,8 +455,6 @@
 		04BD031E12E6671800899322 /* SDL_cocoawindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFED312E6671800899322 /* SDL_cocoawindow.m */; };
 		04BD033112E6671800899322 /* SDL_nullevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEE812E6671800899322 /* SDL_nullevents.c */; };
 		04BD033212E6671800899322 /* SDL_nullevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEE912E6671800899322 /* SDL_nullevents_c.h */; };
-		04BD033312E6671800899322 /* SDL_nullrender.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEA12E6671800899322 /* SDL_nullrender.c */; };
-		04BD033412E6671800899322 /* SDL_nullrender_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */; };
 		04BD033512E6671800899322 /* SDL_nullvideo.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFEEC12E6671800899322 /* SDL_nullvideo.c */; };
 		04BD033612E6671800899322 /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFEED12E6671800899322 /* SDL_nullvideo.h */; };
 		04BD034C12E6671800899322 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF0412E6671800899322 /* mmx.h */; };
@@ -499,13 +490,6 @@
 		04BD03A612E6671800899322 /* SDL_pixels.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6512E6671800899322 /* SDL_pixels.c */; };
 		04BD03A712E6671800899322 /* SDL_pixels_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6612E6671800899322 /* SDL_pixels_c.h */; };
 		04BD03A812E6671800899322 /* SDL_rect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6712E6671800899322 /* SDL_rect.c */; };
-		04BD03A912E6671800899322 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6812E6671800899322 /* SDL_rect_c.h */; };
-		04BD03AA12E6671800899322 /* SDL_renderer_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6912E6671800899322 /* SDL_renderer_gl.c */; };
-		04BD03AB12E6671800899322 /* SDL_renderer_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */; };
-		04BD03AC12E6671800899322 /* SDL_renderer_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */; };
-		04BD03AD12E6671800899322 /* SDL_renderer_gles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */; };
-		04BD03AE12E6671800899322 /* SDL_renderer_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */; };
-		04BD03AF12E6671800899322 /* SDL_renderer_sw.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */; };
 		04BD03B012E6671800899322 /* SDL_RLEaccel.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */; };
 		04BD03B112E6671800899322 /* SDL_RLEaccel_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */; };
 		04BD03B212E6671800899322 /* SDL_shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFF7112E6671800899322 /* SDL_shape.c */; };
@@ -537,8 +521,6 @@
 		04BD040412E6671800899322 /* SDL_x11opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFC912E6671800899322 /* SDL_x11opengl.h */; };
 		04BD040512E6671800899322 /* SDL_x11opengles.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCA12E6671800899322 /* SDL_x11opengles.c */; };
 		04BD040612E6671800899322 /* SDL_x11opengles.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCB12E6671800899322 /* SDL_x11opengles.h */; };
-		04BD040712E6671800899322 /* SDL_x11render.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCC12E6671800899322 /* SDL_x11render.c */; };
-		04BD040812E6671800899322 /* SDL_x11render.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCD12E6671800899322 /* SDL_x11render.h */; };
 		04BD040912E6671800899322 /* SDL_x11shape.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFCE12E6671800899322 /* SDL_x11shape.c */; };
 		04BD040A12E6671800899322 /* SDL_x11shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFCF12E6671800899322 /* SDL_x11shape.h */; };
 		04BD040B12E6671800899322 /* SDL_x11sym.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD012E6671800899322 /* SDL_x11sym.h */; };
@@ -714,9 +696,13 @@
 		00D8DA191195093100638393 /* surface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = surface.h; sourceTree = "<group>"; };
 		00D8DA1A1195093100638393 /* testsdl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testsdl.c; path = ../../test/automated/testsdl.c; sourceTree = SOURCE_ROOT; };
 		00F5D79E0990CA0D0051C449 /* UniversalBinaryNotes.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = UniversalBinaryNotes.rtf; sourceTree = "<group>"; };
+		041B2C9412FA0D2A0087D585 /* SDL_render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_render.h; path = ../../include/SDL_render.h; sourceTree = SOURCE_ROOT; };
+		041B2C9B12FA0D680087D585 /* SDL_renderer_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gl.c; sourceTree = "<group>"; };
+		041B2C9E12FA0D680087D585 /* SDL_render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render.c; sourceTree = "<group>"; };
+		041B2C9F12FA0D680087D585 /* SDL_sysrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysrender.h; sourceTree = "<group>"; };
+		041B2CA112FA0D680087D585 /* SDL_renderer_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_sw.c; sourceTree = "<group>"; };
 		044E5F8411E6051C0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
 		0469A10912EE4BF100B846D6 /* SDL_blendmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_blendmode.h; path = ../../include/SDL_blendmode.h; sourceTree = SOURCE_ROOT; };
-		0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scalemode.h; path = ../../include/SDL_scalemode.h; sourceTree = SOURCE_ROOT; };
 		04BDFD7412E6671700899322 /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = "<group>"; };
 		04BDFD7512E6671700899322 /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
 		04BDFD8812E6671700899322 /* SDL_diskaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_diskaudio.c; sourceTree = "<group>"; };
@@ -747,7 +733,6 @@
 		04BDFDD712E6671700899322 /* default_cursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = default_cursor.h; sourceTree = "<group>"; };
 		04BDFDD812E6671700899322 /* scancodes_darwin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_darwin.h; sourceTree = "<group>"; };
 		04BDFDD912E6671700899322 /* scancodes_linux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_linux.h; sourceTree = "<group>"; };
-		04BDFDDA12E6671700899322 /* scancodes_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_win32.h; sourceTree = "<group>"; };
 		04BDFDDB12E6671700899322 /* scancodes_xfree86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scancodes_xfree86.h; sourceTree = "<group>"; };
 		04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
 		04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
@@ -804,7 +789,6 @@
 		04BDFE8B12E6671800899322 /* SDL_systhread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systhread.h; sourceTree = "<group>"; };
 		04BDFE8C12E6671800899322 /* SDL_thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_thread.c; sourceTree = "<group>"; };
 		04BDFE8D12E6671800899322 /* SDL_thread_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_thread_c.h; sourceTree = "<group>"; };
-		04BDFE9E12E6671800899322 /* SDL_systimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_systimer.h; sourceTree = "<group>"; };
 		04BDFE9F12E6671800899322 /* SDL_timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_timer.c; sourceTree = "<group>"; };
 		04BDFEA012E6671800899322 /* SDL_timer_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_timer_c.h; sourceTree = "<group>"; };
 		04BDFEA212E6671800899322 /* SDL_systimer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systimer.c; sourceTree = "<group>"; };
@@ -828,8 +812,6 @@
 		04BDFED312E6671800899322 /* SDL_cocoawindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoawindow.m; sourceTree = "<group>"; };
 		04BDFEE812E6671800899322 /* SDL_nullevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullevents.c; sourceTree = "<group>"; };
 		04BDFEE912E6671800899322 /* SDL_nullevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullevents_c.h; sourceTree = "<group>"; };
-		04BDFEEA12E6671800899322 /* SDL_nullrender.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullrender.c; sourceTree = "<group>"; };
-		04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullrender_c.h; sourceTree = "<group>"; };
 		04BDFEEC12E6671800899322 /* SDL_nullvideo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_nullvideo.c; sourceTree = "<group>"; };
 		04BDFEED12E6671800899322 /* SDL_nullvideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullvideo.h; sourceTree = "<group>"; };
 		04BDFF0412E6671800899322 /* mmx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mmx.h; sourceTree = "<group>"; };
@@ -865,13 +847,6 @@
 		04BDFF6512E6671800899322 /* SDL_pixels.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_pixels.c; sourceTree = "<group>"; };
 		04BDFF6612E6671800899322 /* SDL_pixels_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_pixels_c.h; sourceTree = "<group>"; };
 		04BDFF6712E6671800899322 /* SDL_rect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rect.c; sourceTree = "<group>"; };
-		04BDFF6812E6671800899322 /* SDL_rect_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rect_c.h; sourceTree = "<group>"; };
-		04BDFF6912E6671800899322 /* SDL_renderer_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gl.c; sourceTree = "<group>"; };
-		04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gl.h; sourceTree = "<group>"; };
-		04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_gles.c; sourceTree = "<group>"; };
-		04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_gles.h; sourceTree = "<group>"; };
-		04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_renderer_sw.c; sourceTree = "<group>"; };
-		04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_renderer_sw.h; sourceTree = "<group>"; };
 		04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_RLEaccel.c; sourceTree = "<group>"; };
 		04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_RLEaccel_c.h; sourceTree = "<group>"; };
 		04BDFF7112E6671800899322 /* SDL_shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_shape.c; sourceTree = "<group>"; };
@@ -903,8 +878,6 @@
 		04BDFFC912E6671800899322 /* SDL_x11opengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11opengl.h; sourceTree = "<group>"; };
 		04BDFFCA12E6671800899322 /* SDL_x11opengles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11opengles.c; sourceTree = "<group>"; };
 		04BDFFCB12E6671800899322 /* SDL_x11opengles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11opengles.h; sourceTree = "<group>"; };
-		04BDFFCC12E6671800899322 /* SDL_x11render.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11render.c; sourceTree = "<group>"; };
-		04BDFFCD12E6671800899322 /* SDL_x11render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11render.h; sourceTree = "<group>"; };
 		04BDFFCE12E6671800899322 /* SDL_x11shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11shape.c; sourceTree = "<group>"; };
 		04BDFFCF12E6671800899322 /* SDL_x11shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11shape.h; sourceTree = "<group>"; };
 		04BDFFD012E6671800899322 /* SDL_x11sym.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_x11sym.h; sourceTree = "<group>"; };
@@ -969,7 +942,6 @@
 		0C5AF5FE01191D2B7F000001 /* SDL_video.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL_video.h; path = ../../include/SDL_video.h; sourceTree = SOURCE_ROOT; };
 		0C5AF5FF01191D2B7F000001 /* SDL.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL.h; path = ../../include/SDL.h; sourceTree = SOURCE_ROOT; };
 		453773811207C518002F0F45 /* SDL_shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_shape.h; path = ../../include/SDL_shape.h; sourceTree = SOURCE_ROOT; };
-		8C93F0EA11F803710014F54D /* gestureSDLTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "gestureSDLTest-Info.plist"; sourceTree = "<group>"; };
 		8CB0A77611F6A87F00CBA2DE /* SDL_gesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_gesture.h; path = ../../include/SDL_gesture.h; sourceTree = SOURCE_ROOT; };
 		8CB0A77711F6A87F00CBA2DE /* SDL_touch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_touch.h; path = ../../include/SDL_touch.h; sourceTree = SOURCE_ROOT; };
 		B29A290D04E5B28700A80002 /* SDL_loadso.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL_loadso.h; path = ../../include/SDL_loadso.h; sourceTree = "<group>"; };
@@ -1180,9 +1152,9 @@
 				00CFA67E106B44CE00758660 /* SDL_power.h */,
 				0C5AF5F701191D2B7F000001 /* SDL_quit.h */,
 				00CFA67F106B44CE00758660 /* SDL_rect.h */,
+				041B2C9412FA0D2A0087D585 /* SDL_render.h */,
 				00A6EBD91078D569001EEA06 /* SDL_revision.h */,
 				0C5AF5F801191D2B7F000001 /* SDL_rwops.h */,
-				0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */,
 				00CFA680106B44CE00758660 /* SDL_scancode.h */,
 				453773811207C518002F0F45 /* SDL_shape.h */,
 				00162D3909BD1FA90037C8D0 /* SDL_stdinc.h */,
@@ -1211,6 +1183,34 @@
 			name = Products;
 			sourceTree = "<group>";
 		};
+		041B2C9712FA0D680087D585 /* render */ = {
+			isa = PBXGroup;
+			children = (
+				041B2C9A12FA0D680087D585 /* opengl */,
+				041B2CA012FA0D680087D585 /* software */,
+				041B2C9E12FA0D680087D585 /* SDL_render.c */,
+				041B2C9F12FA0D680087D585 /* SDL_sysrender.h */,
+			);
+			name = render;
+			path = ../../src/render;
+			sourceTree = SOURCE_ROOT;
+		};
+		041B2C9A12FA0D680087D585 /* opengl */ = {
+			isa = PBXGroup;
+			children = (
+				041B2C9B12FA0D680087D585 /* SDL_renderer_gl.c */,
+			);
+			path = opengl;
+			sourceTree = "<group>";
+		};
+		041B2CA012FA0D680087D585 /* software */ = {
+			isa = PBXGroup;
+			children = (
+				041B2CA112FA0D680087D585 /* SDL_renderer_sw.c */,
+			);
+			path = software;
+			sourceTree = "<group>";
+		};
 		04BDFD7312E6671700899322 /* atomic */ = {
 			isa = PBXGroup;
 			children = (
@@ -1292,7 +1292,6 @@
 				04BDFDD712E6671700899322 /* default_cursor.h */,
 				04BDFDD812E6671700899322 /* scancodes_darwin.h */,
 				04BDFDD912E6671700899322 /* scancodes_linux.h */,
-				04BDFDDA12E6671700899322 /* scancodes_win32.h */,
 				04BDFDDB12E6671700899322 /* scancodes_xfree86.h */,
 				04BDFDDC12E6671700899322 /* SDL_clipboardevents.c */,
 				04BDFDDD12E6671700899322 /* SDL_clipboardevents_c.h */,
@@ -1462,7 +1461,6 @@
 			isa = PBXGroup;
 			children = (
 				04BDFEA112E6671800899322 /* unix */,
-				04BDFE9E12E6671800899322 /* SDL_systimer.h */,
 				04BDFE9F12E6671800899322 /* SDL_timer.c */,
 				04BDFEA012E6671800899322 /* SDL_timer_c.h */,
 			);
@@ -1518,13 +1516,6 @@
 				04BDFF6512E6671800899322 /* SDL_pixels.c */,
 				04BDFF6612E6671800899322 /* SDL_pixels_c.h */,
 				04BDFF6712E6671800899322 /* SDL_rect.c */,
-				04BDFF6812E6671800899322 /* SDL_rect_c.h */,
-				04BDFF6912E6671800899322 /* SDL_renderer_gl.c */,
-				04BDFF6A12E6671800899322 /* SDL_renderer_gl.h */,
-				04BDFF6B12E6671800899322 /* SDL_renderer_gles.c */,
-				04BDFF6C12E6671800899322 /* SDL_renderer_gles.h */,
-				04BDFF6D12E6671800899322 /* SDL_renderer_sw.c */,
-				04BDFF6E12E6671800899322 /* SDL_renderer_sw.h */,
 				04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */,
 				04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */,
 				04BDFF7112E6671800899322 /* SDL_shape.c */,
@@ -1571,8 +1562,6 @@
 			children = (
 				04BDFEE812E6671800899322 /* SDL_nullevents.c */,
 				04BDFEE912E6671800899322 /* SDL_nullevents_c.h */,
-				04BDFEEA12E6671800899322 /* SDL_nullrender.c */,
-				04BDFEEB12E6671800899322 /* SDL_nullrender_c.h */,
 				04BDFEEC12E6671800899322 /* SDL_nullvideo.c */,
 				04BDFEED12E6671800899322 /* SDL_nullvideo.h */,
 			);
@@ -1602,8 +1591,6 @@
 				04BDFFC912E6671800899322 /* SDL_x11opengl.h */,
 				04BDFFCA12E6671800899322 /* SDL_x11opengles.c */,
 				04BDFFCB12E6671800899322 /* SDL_x11opengles.h */,
-				04BDFFCC12E6671800899322 /* SDL_x11render.c */,
-				04BDFFCD12E6671800899322 /* SDL_x11render.h */,
 				04BDFFCE12E6671800899322 /* SDL_x11shape.c */,
 				04BDFFCF12E6671800899322 /* SDL_x11shape.h */,
 				04BDFFD012E6671800899322 /* SDL_x11sym.h */,
@@ -1715,7 +1702,6 @@
 				BECDF66B0761BA81005FE872 /* Info-Framework.plist */,
 				BEC562FE0761C0E800A33029 /* Linked Frameworks */,
 				00D8D9F11195090700638393 /* testsdl-Info.plist */,
-				8C93F0EA11F803710014F54D /* gestureSDLTest-Info.plist */,
 			);
 			comments = "To build Universal Binaries, we have experimented with a variety of different options.\nThe complication is that we must retain compatibility with at least 10.2. \nThe Universal Binary defaults only work for > 10.3.9\n\nSo far, we have found:\ngcc 4.0.0 with Xcode 2.1 always links against libgcc_s. gcc 4.0.1 from Xcode 2.2 fixes this problem.\n\nBut gcc 4.0 will not work with < 10.3.9 because we continue to get an undefined symbol to _fprintf$LDBL128.\nSo we must use gcc 3.3 on PPC to accomplish 10.2 support. (But 4.0 is required for i386.)\n\nSetting the deployment target to 10.4 will disable prebinding, so for PPC, we set it less than 10.4 to preserve prebinding for legacy support.\n\nSetting the PPC SDKROOT to /Developers/SDKs/MacOSX10.2.8.sdk will link to 63.0.0 libSystem.B.dylib. Leaving it at current or 10.4u links to 88.1.2. However, as long as we are using gcc 3.3, it doesn't seem to matter as testing has demonstrated both will run. We have decided not to invoke the 10.2.8 SDK because it is not a default installed component with Xcode which will probably cause most people problems. However, rather than deleting the SDKROOT_ppc entry entirely, we have mapped it to 10.4u in case we decide we need to change this setting.\n\nTo use Altivec or SSE, we needed architecture specific flags:\nOTHER_CFLAGS_ppc\nOTHER_CFLAGS_i386\nOTHER_CFLAGS=$(OTHER_CFLAGS_($CURRENT_ARCH))\n\nThe general OTHER_CFLAGS needed to be manually mapped to architecture specific options because Xcode didn't do this automatically for us.\n\n\n";
 			name = SDLFramework;
@@ -1740,6 +1726,7 @@
 				04BDFDFF12E6671700899322 /* joystick */,
 				04BDFE2F12E6671700899322 /* loadso */,
 				04BDFE4512E6671700899322 /* power */,
+				041B2C9712FA0D680087D585 /* render */,
 				04BDFE5D12E6671700899322 /* stdlib */,
 				04BDFE6412E6671800899322 /* thread */,
 				04BDFE9512E6671800899322 /* timer */,
@@ -1872,7 +1859,6 @@
 				04BD004312E6671800899322 /* default_cursor.h in Headers */,
 				04BD004412E6671800899322 /* scancodes_darwin.h in Headers */,
 				04BD004512E6671800899322 /* scancodes_linux.h in Headers */,
-				04BD004612E6671800899322 /* scancodes_win32.h in Headers */,
 				04BD004712E6671800899322 /* scancodes_xfree86.h in Headers */,
 				04BD004912E6671800899322 /* SDL_clipboardevents_c.h in Headers */,
 				04BD004B12E6671800899322 /* SDL_events_c.h in Headers */,
@@ -1895,7 +1881,6 @@
 				04BD00C212E6671800899322 /* SDL_systhread_c.h in Headers */,
 				04BD00C912E6671800899322 /* SDL_systhread.h in Headers */,
 				04BD00CB12E6671800899322 /* SDL_thread_c.h in Headers */,
-				04BD00D612E6671800899322 /* SDL_systimer.h in Headers */,
 				04BD00D812E6671800899322 /* SDL_timer_c.h in Headers */,
 				04BD00F312E6671800899322 /* SDL_cocoaclipboard.h in Headers */,
 				04BD00F512E6671800899322 /* SDL_cocoaevents.h in Headers */,
@@ -1907,7 +1892,6 @@
 				04BD010112E6671800899322 /* SDL_cocoavideo.h in Headers */,
 				04BD010312E6671800899322 /* SDL_cocoawindow.h in Headers */,
 				04BD011812E6671800899322 /* SDL_nullevents_c.h in Headers */,
-				04BD011A12E6671800899322 /* SDL_nullrender_c.h in Headers */,
 				04BD011C12E6671800899322 /* SDL_nullvideo.h in Headers */,
 				04BD013212E6671800899322 /* mmx.h in Headers */,
 				04BD017012E6671800899322 /* SDL_alphamult.h in Headers */,
@@ -1920,10 +1904,6 @@
 				04BD018A12E6671800899322 /* SDL_glfuncs.h in Headers */,
 				04BD018B12E6671800899322 /* SDL_leaks.h in Headers */,
 				04BD018D12E6671800899322 /* SDL_pixels_c.h in Headers */,
-				04BD018F12E6671800899322 /* SDL_rect_c.h in Headers */,
-				04BD019112E6671800899322 /* SDL_renderer_gl.h in Headers */,
-				04BD019312E6671800899322 /* SDL_renderer_gles.h in Headers */,
-				04BD019512E6671800899322 /* SDL_renderer_sw.h in Headers */,
 				04BD019712E6671800899322 /* SDL_RLEaccel_c.h in Headers */,
 				04BD019912E6671800899322 /* SDL_shape_internals.h in Headers */,
 				04BD019C12E6671800899322 /* SDL_sysvideo.h in Headers */,
@@ -1938,7 +1918,6 @@
 				04BD01EA12E6671800899322 /* SDL_x11mouse.h in Headers */,
 				04BD01EC12E6671800899322 /* SDL_x11opengl.h in Headers */,
 				04BD01EE12E6671800899322 /* SDL_x11opengles.h in Headers */,
-				04BD01F012E6671800899322 /* SDL_x11render.h in Headers */,
 				04BD01F212E6671800899322 /* SDL_x11shape.h in Headers */,
 				04BD01F312E6671800899322 /* SDL_x11sym.h in Headers */,
 				04BD01F512E6671800899322 /* SDL_x11touch.h in Headers */,
@@ -1961,7 +1940,8 @@
 				04BD020812E6671800899322 /* Xvproto.h in Headers */,
 				04BD021512E6671800899322 /* Xvlibint.h in Headers */,
 				0469A10B12EE4BF100B846D6 /* SDL_blendmode.h in Headers */,
-				0469A10C12EE4BF100B846D6 /* SDL_scalemode.h in Headers */,
+				041B2C9512FA0D2A0087D585 /* SDL_render.h in Headers */,
+				041B2CA612FA0D680087D585 /* SDL_sysrender.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2002,7 +1982,6 @@
 				04BD025E12E6671800899322 /* default_cursor.h in Headers */,
 				04BD025F12E6671800899322 /* scancodes_darwin.h in Headers */,
 				04BD026012E6671800899322 /* scancodes_linux.h in Headers */,
-				04BD026112E6671800899322 /* scancodes_win32.h in Headers */,
 				04BD026212E6671800899322 /* scancodes_xfree86.h in Headers */,
 				04BD026412E6671800899322 /* SDL_clipboardevents_c.h in Headers */,
 				04BD026612E6671800899322 /* SDL_events_c.h in Headers */,
@@ -2025,7 +2004,6 @@
 				04BD02DC12E6671800899322 /* SDL_systhread_c.h in Headers */,
 				04BD02E312E6671800899322 /* SDL_systhread.h in Headers */,
 				04BD02E512E6671800899322 /* SDL_thread_c.h in Headers */,
-				04BD02F012E6671800899322 /* SDL_systimer.h in Headers */,
 				04BD02F212E6671800899322 /* SDL_timer_c.h in Headers */,
 				04BD030D12E6671800899322 /* SDL_cocoaclipboard.h in Headers */,
 				04BD030F12E6671800899322 /* SDL_cocoaevents.h in Headers */,
@@ -2037,7 +2015,6 @@
 				04BD031B12E6671800899322 /* SDL_cocoavideo.h in Headers */,
 				04BD031D12E6671800899322 /* SDL_cocoawindow.h in Headers */,
 				04BD033212E6671800899322 /* SDL_nullevents_c.h in Headers */,
-				04BD033412E6671800899322 /* SDL_nullrender_c.h in Headers */,
 				04BD033612E6671800899322 /* SDL_nullvideo.h in Headers */,
 				04BD034C12E6671800899322 /* mmx.h in Headers */,
 				04BD038A12E6671800899322 /* SDL_alphamult.h in Headers */,
@@ -2050,10 +2027,6 @@
 				04BD03A412E6671800899322 /* SDL_glfuncs.h in Headers */,
 				04BD03A512E6671800899322 /* SDL_leaks.h in Headers */,
 				04BD03A712E6671800899322 /* SDL_pixels_c.h in Headers */,
-				04BD03A912E6671800899322 /* SDL_rect_c.h in Headers */,
-				04BD03AB12E6671800899322 /* SDL_renderer_gl.h in Headers */,
-				04BD03AD12E6671800899322 /* SDL_renderer_gles.h in Headers */,
-				04BD03AF12E6671800899322 /* SDL_renderer_sw.h in Headers */,
 				04BD03B112E6671800899322 /* SDL_RLEaccel_c.h in Headers */,
 				04BD03B312E6671800899322 /* SDL_shape_internals.h in Headers */,
 				04BD03B612E6671800899322 /* SDL_sysvideo.h in Headers */,
@@ -2068,7 +2041,6 @@
 				04BD040212E6671800899322 /* SDL_x11mouse.h in Headers */,
 				04BD040412E6671800899322 /* SDL_x11opengl.h in Headers */,
 				04BD040612E6671800899322 /* SDL_x11opengles.h in Headers */,
-				04BD040812E6671800899322 /* SDL_x11render.h in Headers */,
 				04BD040A12E6671800899322 /* SDL_x11shape.h in Headers */,
 				04BD040B12E6671800899322 /* SDL_x11sym.h in Headers */,
 				04BD040D12E6671800899322 /* SDL_x11touch.h in Headers */,
@@ -2091,7 +2063,8 @@
 				04BD042012E6671800899322 /* Xvproto.h in Headers */,
 				04BD042C12E6671800899322 /* Xvlibint.h in Headers */,
 				0469A10D12EE4BF100B846D6 /* SDL_blendmode.h in Headers */,
-				0469A10E12EE4BF100B846D6 /* SDL_scalemode.h in Headers */,
+				041B2C9612FA0D2A0087D585 /* SDL_render.h in Headers */,
+				041B2CAC12FA0D680087D585 /* SDL_sysrender.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2411,7 +2384,6 @@
 				04BD010212E6671800899322 /* SDL_cocoavideo.m in Sources */,
 				04BD010412E6671800899322 /* SDL_cocoawindow.m in Sources */,
 				04BD011712E6671800899322 /* SDL_nullevents.c in Sources */,
-				04BD011912E6671800899322 /* SDL_nullrender.c in Sources */,
 				04BD011B12E6671800899322 /* SDL_nullvideo.c in Sources */,
 				04BD016F12E6671800899322 /* SDL_alphamult.c in Sources */,
 				04BD017112E6671800899322 /* SDL_blendfillrect.c in Sources */,
@@ -2435,9 +2407,6 @@
 				04BD018812E6671800899322 /* SDL_gamma.c in Sources */,
 				04BD018C12E6671800899322 /* SDL_pixels.c in Sources */,
 				04BD018E12E6671800899322 /* SDL_rect.c in Sources */,
-				04BD019012E6671800899322 /* SDL_renderer_gl.c in Sources */,
-				04BD019212E6671800899322 /* SDL_renderer_gles.c in Sources */,
-				04BD019412E6671800899322 /* SDL_renderer_sw.c in Sources */,
 				04BD019612E6671800899322 /* SDL_RLEaccel.c in Sources */,
 				04BD019812E6671800899322 /* SDL_shape.c in Sources */,
 				04BD019A12E6671800899322 /* SDL_stretch.c in Sources */,
@@ -2455,7 +2424,6 @@
 				04BD01E912E6671800899322 /* SDL_x11mouse.c in Sources */,
 				04BD01EB12E6671800899322 /* SDL_x11opengl.c in Sources */,
 				04BD01ED12E6671800899322 /* SDL_x11opengles.c in Sources */,
-				04BD01EF12E6671800899322 /* SDL_x11render.c in Sources */,
 				04BD01F112E6671800899322 /* SDL_x11shape.c in Sources */,
 				04BD01F412E6671800899322 /* SDL_x11touch.c in Sources */,
 				04BD01F612E6671800899322 /* SDL_x11video.c in Sources */,
@@ -2472,6 +2440,9 @@
 				04BD021312E6671800899322 /* VisCmap.c in Sources */,
 				04BD021412E6671800899322 /* Xv.c in Sources */,
 				04BD021612E6671800899322 /* XF86VMode.c in Sources */,
+				041B2CA312FA0D680087D585 /* SDL_renderer_gl.c in Sources */,
+				041B2CA512FA0D680087D585 /* SDL_render.c in Sources */,
+				041B2CA712FA0D680087D585 /* SDL_renderer_sw.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2540,7 +2511,6 @@
 				04BD031C12E6671800899322 /* SDL_cocoavideo.m in Sources */,
 				04BD031E12E6671800899322 /* SDL_cocoawindow.m in Sources */,
 				04BD033112E6671800899322 /* SDL_nullevents.c in Sources */,
-				04BD033312E6671800899322 /* SDL_nullrender.c in Sources */,
 				04BD033512E6671800899322 /* SDL_nullvideo.c in Sources */,
 				04BD038912E6671800899322 /* SDL_alphamult.c in Sources */,
 				04BD038B12E6671800899322 /* SDL_blendfillrect.c in Sources */,
@@ -2564,9 +2534,6 @@
 				04BD03A212E6671800899322 /* SDL_gamma.c in Sources */,
 				04BD03A612E6671800899322 /* SDL_pixels.c in Sources */,
 				04BD03A812E6671800899322 /* SDL_rect.c in Sources */,
-				04BD03AA12E6671800899322 /* SDL_renderer_gl.c in Sources */,
-				04BD03AC12E6671800899322 /* SDL_renderer_gles.c in Sources */,
-				04BD03AE12E6671800899322 /* SDL_renderer_sw.c in Sources */,
 				04BD03B012E6671800899322 /* SDL_RLEaccel.c in Sources */,
 				04BD03B212E6671800899322 /* SDL_shape.c in Sources */,
 				04BD03B412E6671800899322 /* SDL_stretch.c in Sources */,
@@ -2584,7 +2551,6 @@
 				04BD040112E6671800899322 /* SDL_x11mouse.c in Sources */,
 				04BD040312E6671800899322 /* SDL_x11opengl.c in Sources */,
 				04BD040512E6671800899322 /* SDL_x11opengles.c in Sources */,
-				04BD040712E6671800899322 /* SDL_x11render.c in Sources */,
 				04BD040912E6671800899322 /* SDL_x11shape.c in Sources */,
 				04BD040C12E6671800899322 /* SDL_x11touch.c in Sources */,
 				04BD040E12E6671800899322 /* SDL_x11video.c in Sources */,
@@ -2601,6 +2567,9 @@
 				04BD042A12E6671800899322 /* VisCmap.c in Sources */,
 				04BD042B12E6671800899322 /* Xv.c in Sources */,
 				04BD042D12E6671800899322 /* XF86VMode.c in Sources */,
+				041B2CA912FA0D680087D585 /* SDL_renderer_gl.c in Sources */,
+				041B2CAB12FA0D680087D585 /* SDL_render.c in Sources */,
+				041B2CAD12FA0D680087D585 /* SDL_renderer_sw.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
--- a/configure.in	Wed Feb 02 14:34:24 2011 -0800
+++ b/configure.in	Wed Feb 02 14:34:54 2011 -0800
@@ -330,11 +330,13 @@
 
 # Standard C sources
 SOURCES="$SOURCES $srcdir/src/*.c"
+SOURCES="$SOURCES $srcdir/src/atomic/*.c"
 SOURCES="$SOURCES $srcdir/src/audio/*.c"
-SOURCES="$SOURCES $srcdir/src/atomic/*.c"
 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
 SOURCES="$SOURCES $srcdir/src/events/*.c"
 SOURCES="$SOURCES $srcdir/src/file/*.c"
+SOURCES="$SOURCES $srcdir/src/render/*.c"
+SOURCES="$SOURCES $srcdir/src/render/*/*.c"
 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
 SOURCES="$SOURCES $srcdir/src/thread/*.c"
 SOURCES="$SOURCES $srcdir/src/timer/*.c"
--- a/include/SDL_rect.h	Wed Feb 02 14:34:24 2011 -0800
+++ b/include/SDL_rect.h	Wed Feb 02 14:34:54 2011 -0800
@@ -70,6 +70,25 @@
 } SDL_Rect;
 
 /**
+ *  \brief A structure used to track dirty rectangles
+ *  
+ *  \sa SDL_AddDirtyRect
+ *  \sa SDL_ClearDirtyRects
+ *  \sa SDL_FreeDirtyRects
+ */
+typedef struct SDL_DirtyRect
+{
+    SDL_Rect rect;
+    struct SDL_DirtyRect *next;
+} SDL_DirtyRect;
+
+typedef struct SDL_DirtyRectList
+{
+    SDL_DirtyRect *list;
+    SDL_DirtyRect *free;
+} SDL_DirtyRectList;
+
+/**
  *  \brief Returns true if the rectangle has no area.
  */
 #define SDL_RectEmpty(X)    (((X)->w <= 0) || ((X)->h <= 0))
@@ -124,6 +143,22 @@
                                                           int *Y1, int *X2,
                                                           int *Y2);
 
+/**
+ *  \brief Add a rectangle to a dirty rectangle list
+ */
+extern DECLSPEC void SDLCALL SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect);
+
+/**
+ *  \brief Remove all rectangles associated with a dirty rectangle list
+ */
+extern DECLSPEC void SDLCALL SDL_ClearDirtyRects(SDL_DirtyRectList * list);
+
+/**
+ *  \brief Free memory associated with a dirty rectangle list
+ */
+extern DECLSPEC void SDLCALL SDL_FreeDirtyRects(SDL_DirtyRectList * list);
+
+
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 /* *INDENT-OFF* */
--- a/include/SDL_video.h	Wed Feb 02 14:34:24 2011 -0800
+++ b/include/SDL_video.h	Wed Feb 02 14:34:54 2011 -0800
@@ -356,6 +356,11 @@
                                                      SDL_DisplayMode * mode);
 
 /**
+ *  \brief Get the pixel format associated with the window.
+ */
+extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
+
+/**
  *  \brief Set the gamma correction for each of the color channels on the 
  *         currently selected display.
  *  
--- a/src/events/SDL_events.c	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/events/SDL_events.c	Wed Feb 02 14:34:54 2011 -0800
@@ -116,8 +116,6 @@
 int
 SDL_StartEventLoop(void)
 {
-    int retcode;
-
     /* Clean out the event queue */
     SDL_EventQ.lock = NULL;
     SDL_StopEventLoop();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/SDL_render.c	Wed Feb 02 14:34:54 2011 -0800
@@ -0,0 +1,1113 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* The SDL 2D rendering system */
+
+#include "SDL_render.h"
+#include "SDL_sysrender.h"
+#include "../video/SDL_pixels_c.h"
+
+
+#define CHECK_RENDERER_MAGIC(renderer, retval) \
+    if (!renderer || renderer->magic != &renderer_magic) { \
+        SDL_SetError("Invalid renderer"); \
+        return retval; \
+    }
+
+#define CHECK_TEXTURE_MAGIC(texture, retval) \
+    if (!texture || texture->magic != &texture_magic) { \
+        SDL_SetError("Invalid texture"); \
+        return retval; \
+    }
+
+
+static const SDL_RenderDriver *render_drivers[] = {
+#if SDL_VIDEO_RENDER_D3D
+    &D3D_RenderDriver,
+#endif
+#if SDL_VIDEO_RENDER_OGL
+    &GL_RenderDriver,
+#endif
+#if SDL_VIDEO_RENDER_OGL_ES
+    &GL_ES_RenderDriver,
+#endif
+    &SW_RenderDriver
+};
+static char renderer_magic;
+static char texture_magic;
+
+int
+SDL_GetNumRenderDrivers(void)
+{
+    return SDL_arraysize(render_drivers);
+}
+
+int
+SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
+{
+    if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
+        SDL_SetError("index must be in the range of 0 - %d",
+                     SDL_GetNumRenderDrivers() - 1);
+        return -1;
+    }
+    *info = render_drivers[index]->info;
+    return 0;
+}
+
+static int
+SDL_RendererEventWatch(void *userdata, SDL_Event *event)
+{
+    SDL_Renderer *renderer = (SDL_Renderer *)userdata;
+
+    if (event->type == SDL_WINDOWEVENT && renderer->WindowEvent) {
+        SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
+        if (window == renderer->window) {
+            renderer->WindowEvent(renderer, &event->window);
+        }
+    }
+    return 0;
+}
+
+SDL_Renderer *
+SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
+{
+    SDL_Renderer *renderer = NULL;
+    int n = SDL_GetNumRenderDrivers();
+
+    if (index < 0) {
+        char *override = SDL_getenv("SDL_VIDEO_RENDERER");
+
+        if (override) {
+            for (index = 0; index < n; ++index) {
+                const SDL_RenderDriver *driver = render_drivers[index];
+
+                if (SDL_strcasecmp(override, driver->info.name) == 0) {
+                    /* Create a new renderer instance */
+                    renderer = driver->CreateRenderer(window, flags);
+                    break;
+                }
+            }
+        } else {
+            for (index = 0; index < n; ++index) {
+                const SDL_RenderDriver *driver = render_drivers[index];
+
+                if ((driver->info.flags & flags) == flags) {
+                    /* Create a new renderer instance */
+                    renderer = driver->CreateRenderer(window, flags);
+                    if (renderer) {
+                        /* Yay, we got one! */
+                        break;
+                    }
+                }
+            }
+        }
+        if (index == n) {
+            SDL_SetError("Couldn't find matching render driver");
+            return NULL;
+        }
+    } else {
+        if (index >= SDL_GetNumRenderDrivers()) {
+            SDL_SetError("index must be -1 or in the range of 0 - %d",
+                         SDL_GetNumRenderDrivers() - 1);
+            return NULL;
+        }
+        /* Create a new renderer instance */
+        renderer = render_drivers[index]->CreateRenderer(window, flags);
+    }
+
+    if (renderer) {
+        renderer->magic = &renderer_magic;
+
+        SDL_AddEventWatch(SDL_RendererEventWatch, renderer);
+    }
+    return renderer;
+}
+
+int
+SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    *info = renderer->info;
+    return 0;
+}
+
+SDL_Texture *
+SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h)
+{
+    SDL_Texture *texture;
+
+    CHECK_RENDERER_MAGIC(renderer, NULL);
+
+    if (w <= 0 || h <= 0) {
+        SDL_SetError("Texture dimensions can't be 0");
+        return 0;
+    }
+    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
+    if (!texture) {
+        SDL_OutOfMemory();
+        return 0;
+    }
+    texture->magic = &texture_magic;
+    texture->format = format;
+    texture->access = access;
+    texture->w = w;
+    texture->h = h;
+    texture->r = 255;
+    texture->g = 255;
+    texture->b = 255;
+    texture->a = 255;
+    texture->renderer = renderer;
+    texture->next = renderer->textures;
+    if (renderer->textures) {
+        renderer->textures->prev = texture;
+    }
+    renderer->textures = texture;
+
+    if (renderer->CreateTexture(renderer, texture) < 0) {
+        SDL_DestroyTexture(texture);
+        return 0;
+    }
+    return texture;
+}
+
+SDL_Texture *
+SDL_CreateTextureFromSurface(SDL_Renderer * renderer, Uint32 format, SDL_Surface * surface)
+{
+    SDL_Texture *texture;
+    Uint32 requested_format = format;
+    SDL_PixelFormat *fmt;
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+
+    CHECK_RENDERER_MAGIC(renderer, NULL);
+
+    if (!surface) {
+        SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
+        return NULL;
+    }
+    fmt = surface->format;
+
+    if (format) {
+        if (!SDL_PixelFormatEnumToMasks
+            (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+            SDL_SetError("Unknown pixel format");
+            return 0;
+        }
+    } else {
+        SDL_bool hasColorkey;
+        SDL_BlendMode blendMode;
+        SDL_bool hasBlending;
+
+        hasColorkey = (SDL_GetColorKey(surface, NULL) == 0);
+
+        SDL_GetSurfaceBlendMode(surface, &blendMode);
+        hasBlending = (blendMode == SDL_BLENDMODE_BLEND);
+
+        if (surface->format->Amask || (!hasColorkey && !hasBlending)) {
+            Uint32 it;
+            int pfmt;
+
+            /* Pixel formats, sorted by best first */
+            static const Uint32 sdl_pformats[] = {
+                SDL_PIXELFORMAT_ARGB8888,
+                SDL_PIXELFORMAT_RGBA8888,
+                SDL_PIXELFORMAT_ABGR8888,
+                SDL_PIXELFORMAT_BGRA8888,
+                SDL_PIXELFORMAT_RGB888,
+                SDL_PIXELFORMAT_BGR888,
+                SDL_PIXELFORMAT_RGB24,
+                SDL_PIXELFORMAT_BGR24,
+                SDL_PIXELFORMAT_RGB565,
+                SDL_PIXELFORMAT_BGR565,
+                SDL_PIXELFORMAT_ARGB1555,
+                SDL_PIXELFORMAT_RGBA5551,
+                SDL_PIXELFORMAT_ABGR1555,
+                SDL_PIXELFORMAT_BGRA5551,
+                SDL_PIXELFORMAT_RGB555,
+                SDL_PIXELFORMAT_BGR555,
+                SDL_PIXELFORMAT_ARGB4444,
+                SDL_PIXELFORMAT_RGBA4444,
+                SDL_PIXELFORMAT_ABGR4444,
+                SDL_PIXELFORMAT_BGRA4444,
+                SDL_PIXELFORMAT_RGB444,
+                SDL_PIXELFORMAT_ARGB2101010,
+                SDL_PIXELFORMAT_RGB332,
+                SDL_PIXELFORMAT_UNKNOWN
+            };
+
+            bpp = fmt->BitsPerPixel;
+            Rmask = fmt->Rmask;
+            Gmask = fmt->Gmask;
+            Bmask = fmt->Bmask;
+            Amask = fmt->Amask;
+
+            format =
+                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
+            if (!format) {
+                SDL_SetError("Unknown pixel format");
+                return 0;
+            }
+
+            /* Search requested format in the supported texture */
+            /* formats by current renderer                      */
+            for (it = 0; it < renderer->info.num_texture_formats; it++) {
+                if (renderer->info.texture_formats[it] == format) {
+                    break;
+                }
+            }
+
+            /* If requested format can't be found, search any best */
+            /* format which renderer provides                      */
+            if (it == renderer->info.num_texture_formats) {
+                pfmt = 0;
+                for (;;) {
+                    if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) {
+                        break;
+                    }
+
+                    for (it = 0; it < renderer->info.num_texture_formats;
+                         it++) {
+                        if (renderer->info.texture_formats[it] ==
+                            sdl_pformats[pfmt]) {
+                            break;
+                        }
+                    }
+
+                    if (it != renderer->info.num_texture_formats) {
+                        /* The best format has been found */
+                        break;
+                    }
+                    pfmt++;
+                }
+
+                /* If any format can't be found, then return an error */
+                if (it == renderer->info.num_texture_formats) {
+                    SDL_SetError
+                        ("Any of the supported pixel formats can't be found");
+                    return 0;
+                }
+
+                /* Convert found pixel format back to color masks */
+                if (SDL_PixelFormatEnumToMasks
+                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
+                     &Bmask, &Amask) != SDL_TRUE) {
+                    SDL_SetError("Unknown pixel format");
+                    return 0;
+                }
+            }
+        } else {
+            /* Need a format with alpha */
+            Uint32 it;
+            int apfmt;
+
+            /* Pixel formats with alpha, sorted by best first */
+            static const Uint32 sdl_alpha_pformats[] = {
+                SDL_PIXELFORMAT_ARGB8888,
+                SDL_PIXELFORMAT_RGBA8888,
+                SDL_PIXELFORMAT_ABGR8888,
+                SDL_PIXELFORMAT_BGRA8888,
+                SDL_PIXELFORMAT_ARGB1555,
+                SDL_PIXELFORMAT_RGBA5551,
+                SDL_PIXELFORMAT_ABGR1555,
+                SDL_PIXELFORMAT_BGRA5551,
+                SDL_PIXELFORMAT_ARGB4444,
+                SDL_PIXELFORMAT_RGBA4444,
+                SDL_PIXELFORMAT_ABGR4444,
+                SDL_PIXELFORMAT_BGRA4444,
+                SDL_PIXELFORMAT_ARGB2101010,
+                SDL_PIXELFORMAT_UNKNOWN
+            };
+
+            if (surface->format->Amask) {
+                /* If surface already has alpha, then try an original */
+                /* surface format first                               */
+                bpp = fmt->BitsPerPixel;
+                Rmask = fmt->Rmask;
+                Gmask = fmt->Gmask;
+                Bmask = fmt->Bmask;
+                Amask = fmt->Amask;
+            } else {
+                bpp = 32;
+                Rmask = 0x00FF0000;
+                Gmask = 0x0000FF00;
+                Bmask = 0x000000FF;
+                Amask = 0xFF000000;
+            }
+
+            format =
+                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
+            if (!format) {
+                SDL_SetError("Unknown pixel format");
+                return 0;
+            }
+
+            /* Search this format in the supported texture formats */
+            /* by current renderer                                 */
+            for (it = 0; it < renderer->info.num_texture_formats; it++) {
+                if (renderer->info.texture_formats[it] == format) {
+                    break;
+                }
+            }
+
+            /* If this format can't be found, search any best       */
+            /* compatible format with alpha which renderer provides */
+            if (it == renderer->info.num_texture_formats) {
+                apfmt = 0;
+                for (;;) {
+                    if (sdl_alpha_pformats[apfmt] == SDL_PIXELFORMAT_UNKNOWN) {
+                        break;
+                    }
+
+                    for (it = 0; it < renderer->info.num_texture_formats;
+                         it++) {
+                        if (renderer->info.texture_formats[it] ==
+                            sdl_alpha_pformats[apfmt]) {
+                            break;
+                        }
+                    }
+
+                    if (it != renderer->info.num_texture_formats) {
+                        /* Compatible format has been found */
+                        break;
+                    }
+                    apfmt++;
+                }
+
+                /* If compatible format can't be found, then return an error */
+                if (it == renderer->info.num_texture_formats) {
+                    SDL_SetError("Compatible pixel format can't be found");
+                    return 0;
+                }
+
+                /* Convert found pixel format back to color masks */
+                if (SDL_PixelFormatEnumToMasks
+                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
+                     &Bmask, &Amask) != SDL_TRUE) {
+                    SDL_SetError("Unknown pixel format");
+                    return 0;
+                }
+            }
+        }
+
+        format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
+        if (!format) {
+            SDL_SetError("Unknown pixel format");
+            return 0;
+        }
+    }
+
+    texture =
+        SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
+                          surface->w, surface->h);
+    if (!texture && !requested_format) {
+        SDL_DisplayMode desktop_mode;
+        SDL_GetDesktopDisplayMode(&desktop_mode);
+        format = desktop_mode.format;
+        texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
+                                    surface->w, surface->h);
+    }
+    if (!texture) {
+        return 0;
+    }
+    if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
+        && Bmask == fmt->Bmask && Amask == fmt->Amask) {
+        if (SDL_MUSTLOCK(surface)) {
+            SDL_LockSurface(surface);
+            SDL_UpdateTexture(texture, NULL, surface->pixels,
+                              surface->pitch);
+            SDL_UnlockSurface(surface);
+        } else {
+            SDL_UpdateTexture(texture, NULL, surface->pixels,
+                              surface->pitch);
+        }
+    } else {
+        SDL_PixelFormat dst_fmt;
+        SDL_Surface *dst = NULL;
+
+        /* Set up a destination surface for the texture update */
+        SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
+        dst = SDL_ConvertSurface(surface, &dst_fmt, 0);
+        if (dst) {
+            SDL_UpdateTexture(texture, NULL, dst->pixels, dst->pitch);
+            SDL_FreeSurface(dst);
+        }
+        if (!dst) {
+            SDL_DestroyTexture(texture);
+            return 0;
+        }
+    }
+
+    {
+        Uint8 r, g, b, a;
+        SDL_BlendMode blendMode;
+
+        SDL_GetSurfaceColorMod(surface, &r, &g, &b);
+        SDL_SetTextureColorMod(texture, r, g, b);
+
+        SDL_GetSurfaceAlphaMod(surface, &a);
+        SDL_SetTextureAlphaMod(texture, a);
+
+        if (SDL_GetColorKey(surface, NULL) == 0) {
+            /* We converted to a texture with alpha format */
+            SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
+        } else {
+            SDL_GetSurfaceBlendMode(surface, &blendMode);
+            SDL_SetTextureBlendMode(texture, blendMode);
+        }
+    }
+    return texture;
+}
+
+int
+SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access,
+                 int *w, int *h)
+{
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (format) {
+        *format = texture->format;
+    }
+    if (access) {
+        *access = texture->access;
+    }
+    if (w) {
+        *w = texture->w;
+    }
+    if (h) {
+        *h = texture->h;
+    }
+    return 0;
+}
+
+int
+SDL_QueryTexturePixels(SDL_Texture * texture, void **pixels, int *pitch)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (!renderer->QueryTexturePixels) {
+        SDL_Unsupported();
+        return -1;
+    }
+    return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
+}
+
+int
+SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (r < 255 || g < 255 || b < 255) {
+        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
+    } else {
+        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
+    }
+    texture->r = r;
+    texture->g = g;
+    texture->b = b;
+    if (renderer->SetTextureColorMod) {
+        return renderer->SetTextureColorMod(renderer, texture);
+    } else {
+        return 0;
+    }
+}
+
+int
+SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g,
+                       Uint8 * b)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (r) {
+        *r = texture->r;
+    }
+    if (g) {
+        *g = texture->g;
+    }
+    if (b) {
+        *b = texture->b;
+    }
+    return 0;
+}
+
+int
+SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (alpha < 255) {
+        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
+    } else {
+        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
+    }
+    texture->a = alpha;
+    if (renderer->SetTextureAlphaMod) {
+        return renderer->SetTextureAlphaMod(renderer, texture);
+    } else {
+        return 0;
+    }
+}
+
+int
+SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha)
+{
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (alpha) {
+        *alpha = texture->a;
+    }
+    return 0;
+}
+
+int
+SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    texture->blendMode = blendMode;
+    if (renderer->SetTextureBlendMode) {
+        return renderer->SetTextureBlendMode(renderer, texture);
+    } else {
+        return 0;
+    }
+}
+
+int
+SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode)
+{
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (blendMode) {
+        *blendMode = texture->blendMode;
+    }
+    return 0;
+}
+
+int
+SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
+                  const void *pixels, int pitch)
+{
+    SDL_Renderer *renderer;
+    SDL_Rect full_rect;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    renderer = texture->renderer;
+    if (!renderer->UpdateTexture) {
+        SDL_Unsupported();
+        return -1;
+    }
+    if (!rect) {
+        full_rect.x = 0;
+        full_rect.y = 0;
+        full_rect.w = texture->w;
+        full_rect.h = texture->h;
+        rect = &full_rect;
+    }
+    return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
+}
+
+int
+SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, int markDirty,
+                void **pixels, int *pitch)
+{
+    SDL_Renderer *renderer;
+    SDL_Rect full_rect;
+
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
+        SDL_SetError("SDL_LockTexture(): texture must be streaming");
+        return -1;
+    }
+    renderer = texture->renderer;
+    if (!renderer->LockTexture) {
+        SDL_Unsupported();
+        return -1;
+    }
+    if (!rect) {
+        full_rect.x = 0;
+        full_rect.y = 0;
+        full_rect.w = texture->w;
+        full_rect.h = texture->h;
+        rect = &full_rect;
+    }
+    return renderer->LockTexture(renderer, texture, rect, markDirty, pixels,
+                                 pitch);
+}
+
+void
+SDL_UnlockTexture(SDL_Texture * texture)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, );
+
+    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
+        return;
+    }
+    renderer = texture->renderer;
+    if (!renderer->UnlockTexture) {
+        return;
+    }
+    renderer->UnlockTexture(renderer, texture);
+}
+
+void
+SDL_DirtyTexture(SDL_Texture * texture, int numrects,
+                 const SDL_Rect * rects)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, );
+
+    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
+        return;
+    }
+    renderer = texture->renderer;
+    if (!renderer->DirtyTexture) {
+        return;
+    }
+    renderer->DirtyTexture(renderer, texture, numrects, rects);
+}
+
+int
+SDL_SetRenderDrawColor(SDL_Renderer * renderer,
+                       Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    renderer->r = r;
+    renderer->g = g;
+    renderer->b = b;
+    renderer->a = a;
+    return 0;
+}
+
+int
+SDL_GetRenderDrawColor(SDL_Renderer * renderer,
+                       Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (r) {
+        *r = renderer->r;
+    }
+    if (g) {
+        *g = renderer->g;
+    }
+    if (b) {
+        *b = renderer->b;
+    }
+    if (a) {
+        *a = renderer->a;
+    }
+    return 0;
+}
+
+int
+SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    renderer->blendMode = blendMode;
+    return 0;
+}
+
+int
+SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    *blendMode = renderer->blendMode;
+    return 0;
+}
+
+int
+SDL_RenderClear(SDL_Renderer * renderer)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!renderer->RenderClear) {
+        SDL_BlendMode blendMode = renderer->blendMode;
+        int status;
+
+        if (blendMode >= SDL_BLENDMODE_BLEND) {
+            SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
+        }
+
+        status = SDL_RenderFillRect(renderer, NULL);
+
+        if (blendMode >= SDL_BLENDMODE_BLEND) {
+            SDL_SetRenderDrawBlendMode(renderer, blendMode);
+        }
+        return status;
+    }
+    return renderer->RenderClear(renderer);
+}
+
+int
+SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y)
+{
+    SDL_Point point;
+
+    point.x = x;
+    point.y = y;
+    return SDL_RenderDrawPoints(renderer, &point, 1);
+}
+
+int
+SDL_RenderDrawPoints(SDL_Renderer * renderer,
+                     const SDL_Point * points, int count)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!points) {
+        SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
+        return -1;
+    }
+    if (count < 1) {
+        return 0;
+    }
+    return renderer->RenderDrawPoints(renderer, points, count);
+}
+
+int
+SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
+{
+    SDL_Point points[2];
+
+    points[0].x = x1;
+    points[0].y = y1;
+    points[1].x = x2;
+    points[1].y = y2;
+    return SDL_RenderDrawLines(renderer, points, 2);
+}
+
+int
+SDL_RenderDrawLines(SDL_Renderer * renderer,
+                    const SDL_Point * points, int count)
+{
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!points) {
+        SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
+        return -1;
+    }
+    if (count < 2) {
+        return 0;
+    }
+    return renderer->RenderDrawLines(renderer, points, count);
+}
+
+int
+SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect)
+{
+    SDL_Rect full_rect;
+    SDL_Point points[5];
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    /* If 'rect' == NULL, then outline the whole surface */
+    if (!rect) {
+        SDL_Window *window = renderer->window;
+
+        full_rect.x = 0;
+        full_rect.y = 0;
+        SDL_GetWindowSize(window, &full_rect.w, &full_rect.h);
+        rect = &full_rect;
+    }
+
+    points[0].x = rect->x;
+    points[0].y = rect->y;
+    points[1].x = rect->x+rect->w-1;
+    points[1].y = rect->y;
+    points[2].x = rect->x+rect->w-1;
+    points[2].y = rect->y+rect->h-1;
+    points[3].x = rect->x;
+    points[3].y = rect->y+rect->h-1;
+    points[4].x = rect->x;
+    points[4].y = rect->y;
+    return SDL_RenderDrawLines(renderer, points, 5);
+}
+
+int
+SDL_RenderDrawRects(SDL_Renderer * renderer,
+                    const SDL_Rect ** rects, int count)
+{
+    int i;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!rects) {
+        SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
+        return -1;
+    }
+    if (count < 1) {
+        return 0;
+    }
+
+    /* Check for NULL rect, which means fill entire window */
+    for (i = 0; i < count; ++i) {
+        if (SDL_RenderDrawRect(renderer, rects[i]) < 0) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+int
+SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect)
+{
+    return SDL_RenderFillRects(renderer, &rect, 1);
+}
+
+int
+SDL_RenderFillRects(SDL_Renderer * renderer,
+                    const SDL_Rect ** rects, int count)
+{
+    int i;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!rects) {
+        SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
+        return -1;
+    }
+    if (count < 1) {
+        return 0;
+    }
+
+    /* Check for NULL rect, which means fill entire window */
+    for (i = 0; i < count; ++i) {
+        if (rects[i] == NULL) {
+            SDL_Window *window = renderer->window;
+            SDL_Rect full_rect;
+            const SDL_Rect *rect;
+
+            full_rect.x = 0;
+            full_rect.y = 0;
+            SDL_GetWindowSize(window, &full_rect.w, &full_rect.h);
+            rect = &full_rect;
+            return renderer->RenderFillRects(renderer, &rect, 1);
+        }
+    }
+    return renderer->RenderFillRects(renderer, rects, count);
+}
+
+int
+SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    SDL_Window *window;
+    SDL_Rect real_srcrect;
+    SDL_Rect real_dstrect;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+    CHECK_TEXTURE_MAGIC(texture, -1);
+
+    if (renderer != texture->renderer) {
+        SDL_SetError("Texture was not created with this renderer");
+        return -1;
+    }
+    window = renderer->window;
+
+    real_srcrect.x = 0;
+    real_srcrect.y = 0;
+    real_srcrect.w = texture->w;
+    real_srcrect.h = texture->h;
+    if (srcrect) {
+        if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
+            return 0;
+        }
+    }
+
+    real_dstrect.x = 0;
+    real_dstrect.y = 0;
+    SDL_GetWindowSize(window, &real_dstrect.w, &real_dstrect.h);
+    if (dstrect) {
+        if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
+            return 0;
+        }
+        /* Clip srcrect by the same amount as dstrect was clipped */
+        if (dstrect->w != real_dstrect.w) {
+            int deltax = (real_dstrect.x - dstrect->x);
+            int deltaw = (real_dstrect.w - dstrect->w);
+            real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
+            real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;
+        }
+        if (dstrect->h != real_dstrect.h) {
+            int deltay = (real_dstrect.y - dstrect->y);
+            int deltah = (real_dstrect.h - dstrect->h);
+            real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h;
+            real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h;
+        }
+    }
+
+    return renderer->RenderCopy(renderer, texture, &real_srcrect,
+                                &real_dstrect);
+}
+
+int
+SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 format, void * pixels, int pitch)
+{
+    SDL_Window *window;
+    SDL_Rect real_rect;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!renderer->RenderReadPixels) {
+        SDL_Unsupported();
+        return -1;
+    }
+    window = renderer->window;
+
+    if (!format) {
+        format = SDL_GetWindowPixelFormat(window);
+    }
+
+    real_rect.x = 0;
+    real_rect.y = 0;
+    SDL_GetWindowSize(window, &real_rect.w, &real_rect.h);
+    if (rect) {
+        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
+            return 0;
+        }
+        if (real_rect.y > rect->y) {
+            pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
+        }
+        if (real_rect.x > rect->x) {
+            int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
+            pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
+        }
+    }
+
+    return renderer->RenderReadPixels(renderer, &real_rect,
+                                      format, pixels, pitch);
+}
+
+int
+SDL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                      Uint32 format, const void * pixels, int pitch)
+{
+    SDL_Window *window;
+    SDL_Rect real_rect;
+
+    CHECK_RENDERER_MAGIC(renderer, -1);
+
+    if (!renderer->RenderWritePixels) {
+        SDL_Unsupported();
+        return -1;
+    }
+    window = renderer->window;
+
+    if (!format) {
+        format = SDL_GetWindowPixelFormat(window);
+    }
+
+    real_rect.x = 0;
+    real_rect.y = 0;
+    SDL_GetWindowSize(window, &real_rect.w, &real_rect.h);
+    if (rect) {
+        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
+            return 0;
+        }
+        if (real_rect.y > rect->y) {
+            pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y);
+        }
+        if (real_rect.x > rect->x) {
+            int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
+            pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x);
+        }
+    }
+
+    return renderer->RenderWritePixels(renderer, &real_rect,
+                                       format, pixels, pitch);
+}
+
+void
+SDL_RenderPresent(SDL_Renderer * renderer)
+{
+    CHECK_RENDERER_MAGIC(renderer, );
+
+    renderer->RenderPresent(renderer);
+}
+
+void
+SDL_DestroyTexture(SDL_Texture * texture)
+{
+    SDL_Renderer *renderer;
+
+    CHECK_TEXTURE_MAGIC(texture, );
+    texture->magic = NULL;
+
+    renderer = texture->renderer;
+    if (texture->next) {
+        texture->next->prev = texture->prev;
+    }
+    if (texture->prev) {
+        texture->prev->next = texture->next;
+    } else {
+        renderer->textures = texture->next;
+    }
+
+    renderer->DestroyTexture(renderer, texture);
+    SDL_free(texture);
+}
+
+void
+SDL_DestroyRenderer(SDL_Renderer * renderer)
+{
+    CHECK_RENDERER_MAGIC(renderer, );
+
+    SDL_DelEventWatch(SDL_RendererEventWatch, renderer);
+
+    /* Free existing textures for this renderer */
+    while (renderer->textures) {
+        SDL_DestroyTexture(renderer->textures);
+    }
+
+    /* It's no longer magical... */
+    renderer->magic = NULL;
+
+    /* Free the renderer instance */
+    renderer->DestroyRenderer(renderer);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/SDL_sysrender.h	Wed Feb 02 14:34:54 2011 -0800
@@ -0,0 +1,133 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_sysrender_h
+#define _SDL_sysrender_h
+
+#include "SDL_render.h"
+#include "SDL_events.h"
+
+/* The SDL 2D rendering system */
+
+typedef struct SDL_RenderDriver SDL_RenderDriver;
+
+/* Define the SDL texture structure */
+struct SDL_Texture
+{
+    const void *magic;
+    Uint32 format;              /**< The pixel format of the texture */
+    int access;                 /**< SDL_TextureAccess */
+    int w;                      /**< The width of the texture */
+    int h;                      /**< The height of the texture */
+    int modMode;                /**< The texture modulation mode */
+    SDL_BlendMode blendMode;    /**< The texture blend mode */
+    Uint8 r, g, b, a;           /**< Texture modulation values */
+
+    SDL_Renderer *renderer;
+
+    void *driverdata;           /**< Driver specific texture representation */
+
+    SDL_Texture *prev;
+    SDL_Texture *next;
+};
+
+/* Define the SDL renderer structure */
+struct SDL_Renderer
+{
+    const void *magic;
+
+    void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
+    int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
+    int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
+                               void **pixels, int *pitch);
+    int (*SetTextureColorMod) (SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
+                                SDL_Texture * texture);
+    int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * rect, const void *pixels,
+                          int pitch);
+    int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
+                        const SDL_Rect * rect, int markDirty, void **pixels,
+                        int *pitch);
+    void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
+    void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
+                          int numrects, const SDL_Rect * rects);
+    int (*RenderClear) (SDL_Renderer * renderer);
+    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
+                             int count);
+    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
+                            int count);
+    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
+                            int count);
+    int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
+                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+    int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
+                             Uint32 format, void * pixels, int pitch);
+    int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
+                              Uint32 format, const void * pixels, int pitch);
+    void (*RenderPresent) (SDL_Renderer * renderer);
+    void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
+
+    void (*DestroyRenderer) (SDL_Renderer * renderer);
+
+    /* The current renderer info */
+    SDL_RendererInfo info;
+
+    /* The window associated with the renderer */
+    SDL_Window *window;
+
+    /* The list of textures */
+    SDL_Texture *textures;
+
+    Uint8 r, g, b, a;                   /**< Color for drawing operations values */
+    SDL_BlendMode blendMode;            /**< The drawing blend mode */
+
+    void *driverdata;
+};
+
+/* Define the SDL render driver structure */
+struct SDL_RenderDriver
+{
+    SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
+
+    /* Info about the renderer capabilities */
+    SDL_RendererInfo info;
+};
+
+#if SDL_VIDEO_RENDER_D3D
+extern SDL_RenderDriver D3D_RenderDriver;
+#endif
+#if SDL_VIDEO_RENDER_OGL
+extern SDL_RenderDriver GL_RenderDriver;
+#endif
+#if SDL_VIDEO_RENDER_OGL_ES
+extern SDL_RenderDriver GL_ES_RenderDriver;
+#endif
+extern SDL_RenderDriver SW_RenderDriver;
+
+#endif /* _SDL_sysrender_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/direct3d/SDL_d3drender.c	Wed Feb 02 14:34:54 2011 -0800
@@ -0,0 +1,1260 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_D3D
+
+#include "../../core/windows/SDL_windows.h"
+
+#include "SDL_loadso.h"
+#include "SDL_syswm.h"
+#include "../SDL_sysrender.h"
+#include "../../video/SDL_yuv_sw_c.h"
+
+#if SDL_VIDEO_RENDER_D3D
+#define D3D_DEBUG_INFO
+#include <d3d9.h>
+#endif
+
+#ifdef ASSEMBLE_SHADER
+///////////////////////////////////////////////////////////////////////////
+// ID3DXBuffer:
+// ------------
+// The buffer object is used by D3DX to return arbitrary size data.
+//
+// GetBufferPointer -
+//    Returns a pointer to the beginning of the buffer.
+//
+// GetBufferSize -
+//    Returns the size of the buffer, in bytes.
+///////////////////////////////////////////////////////////////////////////
+
+typedef interface ID3DXBuffer ID3DXBuffer;
+typedef interface ID3DXBuffer *LPD3DXBUFFER;
+
+// {8BA5FB08-5195-40e2-AC58-0D989C3A0102}
+DEFINE_GUID(IID_ID3DXBuffer, 
+0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2);
+
+#undef INTERFACE
+#define INTERFACE ID3DXBuffer
+
+typedef interface ID3DXBuffer {
+    const struct ID3DXBufferVtbl FAR* lpVtbl;
+} ID3DXBuffer;
+typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl;
+const struct ID3DXBufferVtbl
+{
+    // IUnknown
+    STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
+    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG, Release)(THIS) PURE;
+
+    // ID3DXBuffer
+    STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
+    STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
+};
+
+HRESULT WINAPI
+    D3DXAssembleShader(
+        LPCSTR                          pSrcData,
+        UINT                            SrcDataLen,
+        CONST LPVOID*                   pDefines,
+        LPVOID                          pInclude,
+        DWORD                           Flags,
+        LPD3DXBUFFER*                   ppShader,
+        LPD3DXBUFFER*                   ppErrorMsgs);
+
+#endif /* ASSEMBLE_SHADER */
+
+
+/* Direct3D renderer implementation */
+
+#if 1                           /* This takes more memory but you won't lose your texture data */
+#define D3DPOOL_SDL    D3DPOOL_MANAGED
+#define SDL_MEMORY_POOL_MANAGED
+#else
+#define D3DPOOL_SDL    D3DPOOL_DEFAULT
+#define SDL_MEMORY_POOL_DEFAULT
+#endif
+
+static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
+static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int D3D_QueryTexturePixels(SDL_Renderer * renderer,
+                                  SDL_Texture * texture, void **pixels,
+                                  int *pitch);
+static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                             const SDL_Rect * rect, const void *pixels,
+                             int pitch);
+static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                           const SDL_Rect * rect, int markDirty,
+                           void **pixels, int *pitch);
+static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                             int numrects, const SDL_Rect * rects);
+static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
+                                const SDL_Point * points, int count);
+static int D3D_RenderDrawLines(SDL_Renderer * renderer,
+                               const SDL_Point * points, int count);
+static int D3D_RenderFillRects(SDL_Renderer * renderer,
+                               const SDL_Rect ** rects, int count);
+static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                                Uint32 format, void * pixels, int pitch);
+static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                                 Uint32 format, const void * pixels, int pitch);
+static void D3D_RenderPresent(SDL_Renderer * renderer);
+static void D3D_DestroyTexture(SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+static void D3D_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver D3D_RenderDriver = {
+    D3D_CreateRenderer,
+    {
+     "d3d",
+     (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
+     0,
+     {0},
+     0,
+     0}
+};
+
+typedef struct
+{
+    void* d3dDLL;
+    IDirect3D9 *d3d;
+    IDirect3DDevice9 *device;
+    UINT adapter;
+    D3DPRESENT_PARAMETERS pparams;
+    SDL_bool beginScene;
+} D3D_RenderData;
+
+typedef struct
+{
+    SDL_SW_YUVTexture *yuv;
+    Uint32 format;
+    IDirect3DTexture9 *texture;
+} D3D_TextureData;
+
+typedef struct
+{
+    float x, y, z;
+    float rhw;
+    DWORD color;
+    float u, v;
+} Vertex;
+
+static void
+D3D_SetError(const char *prefix, HRESULT result)
+{
+    const char *error;
+
+    switch (result) {
+    case D3DERR_WRONGTEXTUREFORMAT:
+        error = "WRONGTEXTUREFORMAT";
+        break;
+    case D3DERR_UNSUPPORTEDCOLOROPERATION:
+        error = "UNSUPPORTEDCOLOROPERATION";
+        break;
+    case D3DERR_UNSUPPORTEDCOLORARG:
+        error = "UNSUPPORTEDCOLORARG";
+        break;
+    case D3DERR_UNSUPPORTEDALPHAOPERATION:
+        error = "UNSUPPORTEDALPHAOPERATION";
+        break;
+    case D3DERR_UNSUPPORTEDALPHAARG:
+        error = "UNSUPPORTEDALPHAARG";
+        break;
+    case D3DERR_TOOMANYOPERATIONS:
+        error = "TOOMANYOPERATIONS";
+        break;
+    case D3DERR_CONFLICTINGTEXTUREFILTER:
+        error = "CONFLICTINGTEXTUREFILTER";
+        break;
+    case D3DERR_UNSUPPORTEDFACTORVALUE:
+        error = "UNSUPPORTEDFACTORVALUE";
+        break;
+    case D3DERR_CONFLICTINGRENDERSTATE:
+        error = "CONFLICTINGRENDERSTATE";
+        break;
+    case D3DERR_UNSUPPORTEDTEXTUREFILTER:
+        error = "UNSUPPORTEDTEXTUREFILTER";
+        break;
+    case D3DERR_CONFLICTINGTEXTUREPALETTE:
+        error = "CONFLICTINGTEXTUREPALETTE";
+        break;
+    case D3DERR_DRIVERINTERNALERROR:
+        error = "DRIVERINTERNALERROR";
+        break;
+    case D3DERR_NOTFOUND:
+        error = "NOTFOUND";
+        break;
+    case D3DERR_MOREDATA:
+        error = "MOREDATA";
+        break;
+    case D3DERR_DEVICELOST:
+        error = "DEVICELOST";
+        break;
+    case D3DERR_DEVICENOTRESET:
+        error = "DEVICENOTRESET";
+        break;
+    case D3DERR_NOTAVAILABLE:
+        error = "NOTAVAILABLE";
+        break;
+    case D3DERR_OUTOFVIDEOMEMORY:
+        error = "OUTOFVIDEOMEMORY";
+        break;
+    case D3DERR_INVALIDDEVICE:
+        error = "INVALIDDEVICE";
+        break;
+    case D3DERR_INVALIDCALL:
+        error = "INVALIDCALL";
+        break;
+    case D3DERR_DRIVERINVALIDCALL:
+        error = "DRIVERINVALIDCALL";
+        break;
+    case D3DERR_WASSTILLDRAWING:
+        error = "WASSTILLDRAWING";
+        break;
+    default:
+        error = "UNKNOWN";
+        break;
+    }
+    SDL_SetError("%s: %s", prefix, error);
+}
+
+static D3DFORMAT
+PixelFormatToD3DFMT(Uint32 format)
+{
+    switch (format) {
+    case SDL_PIXELFORMAT_INDEX8:
+        return D3DFMT_P8;
+    case SDL_PIXELFORMAT_RGB332:
+        return D3DFMT_R3G3B2;
+    case SDL_PIXELFORMAT_RGB444:
+        return D3DFMT_X4R4G4B4;
+    case SDL_PIXELFORMAT_RGB555:
+        return D3DFMT_X1R5G5B5;
+    case SDL_PIXELFORMAT_ARGB4444:
+        return D3DFMT_A4R4G4B4;
+    case SDL_PIXELFORMAT_ARGB1555:
+        return D3DFMT_A1R5G5B5;
+    case SDL_PIXELFORMAT_RGB565:
+        return D3DFMT_R5G6B5;
+    case SDL_PIXELFORMAT_RGB888:
+        return D3DFMT_X8R8G8B8;
+    case SDL_PIXELFORMAT_ARGB8888:
+        return D3DFMT_A8R8G8B8;
+    case SDL_PIXELFORMAT_ARGB2101010:
+        return D3DFMT_A2R10G10B10;
+    case SDL_PIXELFORMAT_YV12:
+        return MAKEFOURCC('Y','V','1','2');
+    case SDL_PIXELFORMAT_IYUV:
+        return MAKEFOURCC('I','4','2','0');
+    case SDL_PIXELFORMAT_UYVY:
+        return D3DFMT_UYVY;
+    case SDL_PIXELFORMAT_YUY2:
+        return D3DFMT_YUY2;
+    default:
+        return D3DFMT_UNKNOWN;
+    }
+}
+
+static SDL_bool
+D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, UINT adapter,
+                             D3DFORMAT display_format,
+                             D3DFORMAT texture_format)
+{
+    HRESULT result;
+
+    result = IDirect3D9_CheckDeviceFormat(d3d, adapter,
+                                          D3DDEVTYPE_HAL,
+                                          display_format,
+                                          0,
+                                          D3DRTYPE_TEXTURE,
+                                          texture_format);
+    return FAILED(result) ? SDL_FALSE : SDL_TRUE;
+}
+
+static void
+UpdateYUVTextureData(SDL_Texture * texture)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+    SDL_Rect rect;
+    RECT d3drect;
+    D3DLOCKED_RECT locked;
+    HRESULT result;
+
+    d3drect.left = 0;
+    d3drect.right = texture->w;
+    d3drect.top = 0;
+    d3drect.bottom = texture->h;
+
+    result =
+        IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
+    if (FAILED(result)) {
+        return;
+    }
+
+    rect.x = 0;
+    rect.y = 0;
+    rect.w = texture->w;
+    rect.h = texture->h;
+    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
+                        texture->h, locked.pBits, locked.Pitch);
+
+    IDirect3DTexture9_UnlockRect(data->texture, 0);
+}
+
+static void
+D3D_AddTextureFormats(D3D_RenderData *data, SDL_RendererInfo *info)
+{
+    int i;
+    int formats[] = {
+        SDL_PIXELFORMAT_RGB332,
+        SDL_PIXELFORMAT_RGB444,
+        SDL_PIXELFORMAT_RGB555,
+        SDL_PIXELFORMAT_ARGB4444,
+        SDL_PIXELFORMAT_ARGB1555,
+        SDL_PIXELFORMAT_RGB565,
+        SDL_PIXELFORMAT_RGB888,
+        SDL_PIXELFORMAT_ARGB8888,
+        SDL_PIXELFORMAT_ARGB2101010,
+    };
+
+    info->num_texture_formats = 0;
+    for (i = 0; i < SDL_arraysize(formats); ++i) {
+        if (D3D_IsTextureFormatAvailable
+            (data->d3d, data->adapter, data->pparams.BackBufferFormat, PixelFormatToD3DFMT(formats[i]))) {
+            info->texture_formats[info->num_texture_formats++] = formats[i];
+        }
+    }
+    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12;
+    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
+    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2;
+    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY;
+    info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU;
+}
+
+SDL_Renderer *
+D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+    SDL_Renderer *renderer;
+    D3D_RenderData *data;
+    SDL_SysWMinfo windowinfo;
+    HRESULT result;
+    D3DPRESENT_PARAMETERS pparams;
+    IDirect3DSwapChain9 *chain;
+    D3DCAPS9 caps;
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_free(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data->d3dDLL = SDL_LoadObject("D3D9.DLL");
+    if (data->d3dDLL) {
+        IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
+
+        D3DCreate =
+            (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL,
+                                                            "Direct3DCreate9");
+        if (D3DCreate) {
+            data->d3d = D3DCreate(D3D_SDK_VERSION);
+        }
+        if (!data->d3d) {
+            SDL_UnloadObject(data->d3dDLL);
+            data->d3dDLL = NULL;
+        }
+    }
+    if (!data->d3d) {
+        SDL_free(renderer);
+        SDL_free(data);
+        SDL_SetError("Unable to create Direct3D interface");
+        return NULL;
+    }
+
+    renderer->CreateTexture = D3D_CreateTexture;
+    renderer->QueryTexturePixels = D3D_QueryTexturePixels;
+    renderer->UpdateTexture = D3D_UpdateTexture;
+    renderer->LockTexture = D3D_LockTexture;
+    renderer->UnlockTexture = D3D_UnlockTexture;
+    renderer->DirtyTexture = D3D_DirtyTexture;
+    renderer->RenderDrawPoints = D3D_RenderDrawPoints;
+    renderer->RenderDrawLines = D3D_RenderDrawLines;
+    renderer->RenderFillRects = D3D_RenderFillRects;
+    renderer->RenderCopy = D3D_RenderCopy;
+    renderer->RenderReadPixels = D3D_RenderReadPixels;
+    renderer->RenderWritePixels = D3D_RenderWritePixels;
+    renderer->RenderPresent = D3D_RenderPresent;
+    renderer->DestroyTexture = D3D_DestroyTexture;
+    renderer->DestroyRenderer = D3D_DestroyRenderer;
+    renderer->info = D3D_RenderDriver.info;
+    renderer->window = window;
+    renderer->driverdata = data;
+
+    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+
+    SDL_VERSION(&windowinfo.version);
+    SDL_GetWindowWMInfo(window, &windowinfo);
+
+    SDL_zero(pparams);
+    pparams.hDeviceWindow = windowinfo.info.win.window;
+    pparams.BackBufferWidth = window->w;
+    pparams.BackBufferHeight = window->h;
+    if (window->flags & SDL_WINDOW_FULLSCREEN) {
+        pparams.BackBufferFormat =
+            PixelFormatToD3DFMT(window->fullscreen_mode.format);
+    } else {
+        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
+    }
+    pparams.BackBufferCount = 1;
+    pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
+
+    if (window->flags & SDL_WINDOW_FULLSCREEN) {
+        pparams.Windowed = FALSE;
+        pparams.FullScreen_RefreshRateInHz =
+            window->fullscreen_mode.refresh_rate;
+    } else {
+        pparams.Windowed = TRUE;
+        pparams.FullScreen_RefreshRateInHz = 0;
+    }
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+    } else {
+        pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+    }
+
+    /* FIXME: Which adapter? */
+    data->adapter = D3DADAPTER_DEFAULT;
+    IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps);
+
+    result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
+                                     D3DDEVTYPE_HAL,
+                                     pparams.hDeviceWindow,
+                                     (caps.
+                                      DevCaps &
+                                      D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
+                                     D3DCREATE_HARDWARE_VERTEXPROCESSING :
+                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING,
+                                     &pparams, &data->device);
+    if (FAILED(result)) {
+        D3D_DestroyRenderer(renderer);
+        D3D_SetError("CreateDevice()", result);
+        return NULL;
+    }
+    data->beginScene = SDL_TRUE;
+
+    /* Get presentation parameters to fill info */
+    result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
+    if (FAILED(result)) {
+        D3D_DestroyRenderer(renderer);
+        D3D_SetError("GetSwapChain()", result);
+        return NULL;
+    }
+    result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
+    if (FAILED(result)) {
+        IDirect3DSwapChain9_Release(chain);
+        D3D_DestroyRenderer(renderer);
+        D3D_SetError("GetPresentParameters()", result);
+        return NULL;
+    }
+    IDirect3DSwapChain9_Release(chain);
+    if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+    data->pparams = pparams;
+
+    D3D_AddTextureFormats(data, &renderer->info);
+
+    IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
+    renderer->info.max_texture_width = caps.MaxTextureWidth;
+    renderer->info.max_texture_height = caps.MaxTextureHeight;
+
+    /* Set up parameters for rendering */
+    IDirect3DDevice9_SetVertexShader(data->device, NULL);
+    IDirect3DDevice9_SetFVF(data->device,
+                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
+                                    D3DCULL_NONE);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
+    /* Enable color modulation by diffuse color */
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP,
+                                          D3DTOP_MODULATE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1,
+                                          D3DTA_TEXTURE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2,
+                                          D3DTA_DIFFUSE);
+    /* Enable alpha modulation by diffuse alpha */
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP,
+                                          D3DTOP_MODULATE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1,
+                                          D3DTA_TEXTURE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2,
+                                          D3DTA_DIFFUSE);
+    /* Disable second texture stage, since we're done */
+    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP,
+                                          D3DTOP_DISABLE);
+    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP,
+                                          D3DTOP_DISABLE);
+
+    return renderer;
+}
+
+static int
+D3D_Reset(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    HRESULT result;
+
+    result = IDirect3DDevice9_Reset(data->device, &data->pparams);
+    if (FAILED(result)) {
+        if (result == D3DERR_DEVICELOST) {
+            /* Don't worry about it, we'll reset later... */
+            return 0;
+        } else {
+            D3D_SetError("Reset()", result);
+            return -1;
+        }
+    }
+    IDirect3DDevice9_SetVertexShader(data->device, NULL);
+    IDirect3DDevice9_SetFVF(data->device,
+                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
+                                    D3DCULL_NONE);
+    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
+    return 0;
+}
+
+/* FIXME: This needs to be called... when? */
+#if 0
+static int
+D3D_DisplayModeChanged(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    SDL_VideoDisplay *display = window->display;
+
+    data->pparams.BackBufferWidth = window->w;
+    data->pparams.BackBufferHeight = window->h;
+    if (window->flags & SDL_WINDOW_FULLSCREEN) {
+        data->pparams.BackBufferFormat =
+            PixelFormatToD3DFMT(window->fullscreen_mode.format);
+    } else {
+        data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
+    }
+    return D3D_Reset(renderer);
+}
+#endif
+
+static int
+D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    D3DFORMAT display_format = renderdata->pparams.BackBufferFormat;
+    D3D_TextureData *data;
+    HRESULT result;
+
+    data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    texture->driverdata = data;
+
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format) &&
+        (texture->format != SDL_PIXELFORMAT_YUY2 ||
+         !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
+                                       display_format, PixelFormatToD3DFMT(texture->format)))
+        && (texture->format != SDL_PIXELFORMAT_YVYU
+            || !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
+                                             display_format, PixelFormatToD3DFMT(texture->format)))) {
+        data->yuv =
+            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
+        if (!data->yuv) {
+            return -1;
+        }
+        data->format = SDL_GetWindowPixelFormat(window);
+    } else {
+        data->format = texture->format;
+    }
+
+    result =
+        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
+                                       texture->h, 1, 0,
+                                       PixelFormatToD3DFMT(data->format),
+                                       D3DPOOL_SDL, &data->texture, NULL);
+    if (FAILED(result)) {
+        D3D_SetError("CreateTexture()", result);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int
+D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
+                       void **pixels, int *pitch)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+
+    if (data->yuv) {
+        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
+    } else {
+        /* D3D textures don't have their pixels hanging out */
+        return -1;
+    }
+}
+
+static int
+D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                  const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
+
+    if (data->yuv) {
+        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
+            return -1;
+        }
+        UpdateYUVTextureData(texture);
+        return 0;
+    } else {
+#ifdef SDL_MEMORY_POOL_DEFAULT
+        IDirect3DTexture9 *temp;
+        RECT d3drect;
+        D3DLOCKED_RECT locked;
+        const Uint8 *src;
+        Uint8 *dst;
+        int row, length;
+        HRESULT result;
+
+        result =
+            IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
+                                           texture->h, 1, 0,
+                                           PixelFormatToD3DFMT(texture->
+                                                               format),
+                                           D3DPOOL_SYSTEMMEM, &temp, NULL);
+        if (FAILED(result)) {
+            D3D_SetError("CreateTexture()", result);
+            return -1;
+        }
+
+        d3drect.left = rect->x;
+        d3drect.right = rect->x + rect->w;
+        d3drect.top = rect->y;
+        d3drect.bottom = rect->y + rect->h;
+
+        result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0);
+        if (FAILED(result)) {
+            IDirect3DTexture9_Release(temp);
+            D3D_SetError("LockRect()", result);
+            return -1;
+        }
+
+        src = pixels;
+        dst = locked.pBits;
+        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
+        for (row = 0; row < rect->h; ++row) {
+            SDL_memcpy(dst, src, length);
+            src += pitch;
+            dst += locked.Pitch;
+        }
+        IDirect3DTexture9_UnlockRect(temp, 0);
+
+        result =
+            IDirect3DDevice9_UpdateTexture(renderdata->device,
+                                           (IDirect3DBaseTexture9 *) temp,
+                                           (IDirect3DBaseTexture9 *)
+                                           data->texture);
+        IDirect3DTexture9_Release(temp);
+        if (FAILED(result)) {
+            D3D_SetError("UpdateTexture()", result);
+            return -1;
+        }
+#else
+        RECT d3drect;
+        D3DLOCKED_RECT locked;
+        const Uint8 *src;
+        Uint8 *dst;
+        int row, length;
+        HRESULT result;
+
+        d3drect.left = rect->x;
+        d3drect.right = rect->x + rect->w;
+        d3drect.top = rect->y;
+        d3drect.bottom = rect->y + rect->h;
+
+        result =
+            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
+                                       0);
+        if (FAILED(result)) {
+            D3D_SetError("LockRect()", result);
+            return -1;
+        }
+
+        src = pixels;
+        dst = locked.pBits;
+        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
+        for (row = 0; row < rect->h; ++row) {
+            SDL_memcpy(dst, src, length);
+            src += pitch;
+            dst += locked.Pitch;
+        }
+        IDirect3DTexture9_UnlockRect(data->texture, 0);
+#endif // SDL_MEMORY_POOL_DEFAULT
+
+        return 0;
+    }
+}
+
+static int
+D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                const SDL_Rect * rect, int markDirty, void **pixels,
+                int *pitch)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+
+    if (data->yuv) {
+        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
+                                     pitch);
+    } else {
+        RECT d3drect;
+        D3DLOCKED_RECT locked;
+        HRESULT result;
+
+        d3drect.left = rect->x;
+        d3drect.right = rect->x + rect->w;
+        d3drect.top = rect->y;
+        d3drect.bottom = rect->y + rect->h;
+
+        result =
+            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
+                                       markDirty ? 0 :
+                                       D3DLOCK_NO_DIRTY_UPDATE);
+        if (FAILED(result)) {
+            D3D_SetError("LockRect()", result);
+            return -1;
+        }
+        *pixels = locked.pBits;
+        *pitch = locked.Pitch;
+        return 0;
+    }
+}
+
+static void
+D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+
+    if (data->yuv) {
+        SDL_SW_UnlockYUVTexture(data->yuv);
+        UpdateYUVTextureData(texture);
+    } else {
+        IDirect3DTexture9_UnlockRect(data->texture, 0);
+    }
+}
+
+static void
+D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
+                 const SDL_Rect * rects)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+    RECT d3drect;
+    int i;
+
+    for (i = 0; i < numrects; ++i) {
+        const SDL_Rect *rect = &rects[i];
+
+        d3drect.left = rect->x;
+        d3drect.right = rect->x + rect->w;
+        d3drect.top = rect->y;
+        d3drect.bottom = rect->y + rect->h;
+
+        IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect);
+    }
+}
+
+static void
+D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
+{
+    switch (blendMode) {
+    case SDL_BLENDMODE_NONE:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        FALSE);
+        break;
+    case SDL_BLENDMODE_BLEND:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_SRCALPHA);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_INVSRCALPHA);
+        break;
+    case SDL_BLENDMODE_ADD:
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
+                                        TRUE);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
+                                        D3DBLEND_SRCALPHA);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
+                                        D3DBLEND_ONE);
+        break;
+    }
+}
+
+static int
+D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                     int count)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    DWORD color;
+    Vertex *vertices;
+    int i;
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    D3D_SetBlendMode(data, renderer->blendMode);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0,
+                                    (IDirect3DBaseTexture9 *) 0);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+
+    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
+
+    vertices = SDL_stack_alloc(Vertex, count);
+    for (i = 0; i < count; ++i) {
+        vertices[i].x = (float) points[i].x;
+        vertices[i].y = (float) points[i].y;
+        vertices[i].z = 0.0f;
+        vertices[i].rhw = 1.0f;
+        vertices[i].color = color;
+        vertices[i].u = 0.0f;
+        vertices[i].v = 0.0f;
+    }
+    result =
+        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count,
+                                         vertices, sizeof(*vertices));
+    SDL_stack_free(vertices);
+    if (FAILED(result)) {
+        D3D_SetError("DrawPrimitiveUP()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                    int count)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    DWORD color;
+    Vertex *vertices;
+    int i;
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    D3D_SetBlendMode(data, renderer->blendMode);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0,
+                                    (IDirect3DBaseTexture9 *) 0);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+
+    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
+
+    vertices = SDL_stack_alloc(Vertex, count);
+    for (i = 0; i < count; ++i) {
+        vertices[i].x = (float) points[i].x;
+        vertices[i].y = (float) points[i].y;
+        vertices[i].z = 0.0f;
+        vertices[i].rhw = 1.0f;
+        vertices[i].color = color;
+        vertices[i].u = 0.0f;
+        vertices[i].v = 0.0f;
+    }
+    result =
+        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1,
+                                         vertices, sizeof(*vertices));
+
+    /* DirectX 9 has the same line rasterization semantics as GDI,
+       so we need to close the endpoint of the line */
+    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
+        vertices[0].x = (float) points[count-1].x;
+        vertices[0].y = (float) points[count-1].y;
+        result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
+    }
+
+    SDL_stack_free(vertices);
+    if (FAILED(result)) {
+        D3D_SetError("DrawPrimitiveUP()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
+                    int count)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    DWORD color;
+    int i;
+    float minx, miny, maxx, maxy;
+    Vertex vertices[4];
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    D3D_SetBlendMode(data, renderer->blendMode);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0,
+                                    (IDirect3DBaseTexture9 *) 0);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+
+    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
+
+    for (i = 0; i < count; ++i) {
+        const SDL_Rect *rect = rects[i];
+
+        minx = (float) rect->x;
+        miny = (float) rect->y;
+        maxx = (float) rect->x + rect->w;
+        maxy = (float) rect->y + rect->h;
+
+        vertices[0].x = minx;
+        vertices[0].y = miny;
+        vertices[0].z = 0.0f;
+        vertices[0].rhw = 1.0f;
+        vertices[0].color = color;
+        vertices[0].u = 0.0f;
+        vertices[0].v = 0.0f;
+
+        vertices[1].x = maxx;
+        vertices[1].y = miny;
+        vertices[1].z = 0.0f;
+        vertices[1].rhw = 1.0f;
+        vertices[1].color = color;
+        vertices[1].u = 0.0f;
+        vertices[1].v = 0.0f;
+
+        vertices[2].x = maxx;
+        vertices[2].y = maxy;
+        vertices[2].z = 0.0f;
+        vertices[2].rhw = 1.0f;
+        vertices[2].color = color;
+        vertices[2].u = 0.0f;
+        vertices[2].v = 0.0f;
+
+        vertices[3].x = minx;
+        vertices[3].y = maxy;
+        vertices[3].z = 0.0f;
+        vertices[3].rhw = 1.0f;
+        vertices[3].color = color;
+        vertices[3].u = 0.0f;
+        vertices[3].v = 0.0f;
+
+        result =
+            IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN,
+                                             2, vertices, sizeof(*vertices));
+        if (FAILED(result)) {
+            D3D_SetError("DrawPrimitiveUP()", result);
+            return -1;
+        }
+    }
+    return 0;
+}
+
+static int
+D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
+    LPDIRECT3DPIXELSHADER9 shader = NULL;
+    float minx, miny, maxx, maxy;
+    float minu, maxu, minv, maxv;
+    DWORD color;
+    Vertex vertices[4];
+    HRESULT result;
+
+    if (data->beginScene) {
+        IDirect3DDevice9_BeginScene(data->device);
+        data->beginScene = SDL_FALSE;
+    }
+
+    minx = (float) dstrect->x - 0.5f;
+    miny = (float) dstrect->y - 0.5f;
+    maxx = (float) dstrect->x + dstrect->w - 0.5f;
+    maxy = (float) dstrect->y + dstrect->h - 0.5f;
+
+    minu = (float) srcrect->x / texture->w;
+    maxu = (float) (srcrect->x + srcrect->w) / texture->w;
+    minv = (float) srcrect->y / texture->h;
+    maxv = (float) (srcrect->y + srcrect->h) / texture->h;
+
+    color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);
+
+    vertices[0].x = minx;
+    vertices[0].y = miny;
+    vertices[0].z = 0.0f;
+    vertices[0].rhw = 1.0f;
+    vertices[0].color = color;
+    vertices[0].u = minu;
+    vertices[0].v = minv;
+
+    vertices[1].x = maxx;
+    vertices[1].y = miny;
+    vertices[1].z = 0.0f;
+    vertices[1].rhw = 1.0f;
+    vertices[1].color = color;
+    vertices[1].u = maxu;
+    vertices[1].v = minv;
+
+    vertices[2].x = maxx;
+    vertices[2].y = maxy;
+    vertices[2].z = 0.0f;
+    vertices[2].rhw = 1.0f;
+    vertices[2].color = color;
+    vertices[2].u = maxu;
+    vertices[2].v = maxv;
+
+    vertices[3].x = minx;
+    vertices[3].y = maxy;
+    vertices[3].z = 0.0f;
+    vertices[3].rhw = 1.0f;
+    vertices[3].color = color;
+    vertices[3].u = minu;
+    vertices[3].v = maxv;
+
+    D3D_SetBlendMode(data, texture->blendMode);
+
+    IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
+                                     D3DTEXF_LINEAR);
+    IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
+                                     D3DTEXF_LINEAR);
+
+    result =
+        IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
+                                    texturedata->texture);
+    if (FAILED(result)) {
+        D3D_SetError("SetTexture()", result);
+        return -1;
+    }
+    if (shader) {
+        result = IDirect3DDevice9_SetPixelShader(data->device, shader);
+        if (FAILED(result)) {
+            D3D_SetError("SetShader()", result);
+            return -1;
+        }
+    }
+    result =
+        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
+                                         vertices, sizeof(*vertices));
+    if (FAILED(result)) {
+        D3D_SetError("DrawPrimitiveUP()", result);
+        return -1;
+    }
+    if (shader) {
+        result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
+        if (FAILED(result)) {
+            D3D_SetError("SetShader()", result);
+            return -1;
+        }
+    }
+    return 0;
+}
+
+static int
+D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 format, void * pixels, int pitch)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    SDL_VideoDisplay *display = window->display;
+    D3DSURFACE_DESC desc;
+    LPDIRECT3DSURFACE9 backBuffer;
+    LPDIRECT3DSURFACE9 surface;
+    RECT d3drect;
+    D3DLOCKED_RECT locked;
+    HRESULT result;
+
+    result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
+    if (FAILED(result)) {
+        D3D_SetError("GetBackBuffer()", result);
+        return -1;
+    }
+
+    result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
+    if (FAILED(result)) {
+        D3D_SetError("GetDesc()", result);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
+    if (FAILED(result)) {
+        D3D_SetError("CreateOffscreenPlainSurface()", result);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
+    if (FAILED(result)) {
+        D3D_SetError("GetRenderTargetData()", result);
+        IDirect3DSurface9_Release(surface);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    d3drect.left = rect->x;
+    d3drect.right = rect->x + rect->w;
+    d3drect.top = rect->y;
+    d3drect.bottom = rect->y + rect->h;
+
+    result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
+    if (FAILED(result)) {
+        D3D_SetError("LockRect()", result);
+        IDirect3DSurface9_Release(surface);
+        IDirect3DSurface9_Release(backBuffer);
+        return -1;
+    }
+
+    SDL_ConvertPixels(rect->w, rect->h,
+                      display->current_mode.format, locked.pBits, locked.Pitch,
+                      format, pixels, pitch);
+
+    IDirect3DSurface9_UnlockRect(surface);
+
+    IDirect3DSurface9_Release(surface);
+    IDirect3DSurface9_Release(backBuffer);
+
+    return 0;
+}
+
+static int
+D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                      Uint32 format, const void * pixels, int pitch)
+{
+    /* Work in progress */
+    SDL_Unsupported();
+    return -1;
+}
+
+static void
+D3D_RenderPresent(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+    HRESULT result;
+
+    if (!data->beginScene) {
+        IDirect3DDevice9_EndScene(data->device);
+        data->beginScene = SDL_TRUE;
+    }
+
+    result = IDirect3DDevice9_TestCooperativeLevel(data->device);
+    if (result == D3DERR_DEVICELOST) {
+        /* We'll reset later */
+        return;
+    }
+    if (result == D3DERR_DEVICENOTRESET) {
+        D3D_Reset(renderer);
+    }
+    result = IDirect3DDevice9_Present(data->device, NULL, NULL, NULL, NULL);
+    if (FAILED(result)) {
+        D3D_SetError("Present()", result);
+    }
+}
+
+static void
+D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
+
+    if (!data) {
+        return;
+    }
+    if (data->yuv) {
+        SDL_SW_DestroyYUVTexture(data->yuv);
+    }
+    if (data->texture) {
+        IDirect3DTexture9_Release(data->texture);
+    }
+    SDL_free(data);
+    texture->driverdata = NULL;
+}
+
+static void
+D3D_DestroyRenderer(SDL_Renderer * renderer)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+
+    if (data) {
+        if (data->device) {
+            IDirect3DDevice9_Release(data->device);
+        }
+        if (data->d3d) {
+            IDirect3D9_Release(data->d3d);
+            SDL_UnloadObject(data->d3dDLL);
+        }
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+#endif /* SDL_VIDEO_RENDER_D3D */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengl/SDL_renderer_gl.c	Wed Feb 02 14:34:54 2011 -0800
@@ -0,0 +1,1285 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_OGL
+
+#include "SDL_opengl.h"
+#include "../SDL_sysrender.h"
+
+#ifdef __MACOSX__
+#include <OpenGL/OpenGL.h>
+#endif
+
+
+/* OpenGL renderer implementation */
+
+/* Details on optimizing the texture path on Mac OS X:
+   http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/chapter_10_section_2.html
+*/
+
+/* !!! FIXME: this should go in a higher level than the GL renderer. */
+static __inline__ int
+bytes_per_pixel(const Uint32 format)
+{
+    if (!SDL_ISPIXELFORMAT_FOURCC(format)) {
+        return SDL_BYTESPERPIXEL(format);
+    }
+
+    /* FOURCC format */
+    switch (format) {
+    case SDL_PIXELFORMAT_YV12:
+    case SDL_PIXELFORMAT_IYUV:
+    case SDL_PIXELFORMAT_YUY2:
+    case SDL_PIXELFORMAT_UYVY:
+    case SDL_PIXELFORMAT_YVYU:
+        return 2;
+    default:
+        return 1;               /* shouldn't ever hit this. */
+    }
+}
+
+/* Used to re-create the window with OpenGL capability */
+extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
+
+static const float inv255f = 1.0f / 255.0f;
+
+static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
+static void GL_WindowEvent(SDL_Renderer * renderer,
+                           const SDL_WindowEvent *event);
+static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int GL_QueryTexturePixels(SDL_Renderer * renderer,
+                                 SDL_Texture * texture, void **pixels,
+                                 int *pitch);
+static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                            const SDL_Rect * rect, const void *pixels,
+                            int pitch);
+static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * rect, int markDirty, void **pixels,
+                          int *pitch);
+static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                            int numrects, const SDL_Rect * rects);
+static int GL_RenderClear(SDL_Renderer * renderer);
+static int GL_RenderDrawPoints(SDL_Renderer * renderer,
+                               const SDL_Point * points, int count);
+static int GL_RenderDrawLines(SDL_Renderer * renderer,
+                              const SDL_Point * points, int count);
+static int GL_RenderFillRects(SDL_Renderer * renderer,
+                              const SDL_Rect ** rects, int count);
+static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                               Uint32 pixel_format, void * pixels, int pitch);
+static int GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                                Uint32 pixel_format, const void * pixels, int pitch);
+static void GL_RenderPresent(SDL_Renderer * renderer);
+static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void GL_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver GL_RenderDriver = {
+    GL_CreateRenderer,
+    {
+     "opengl",
+     (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
+     13,
+     {
+      SDL_PIXELFORMAT_RGB332,
+      SDL_PIXELFORMAT_RGB444,
+      SDL_PIXELFORMAT_RGB555,
+      SDL_PIXELFORMAT_ARGB4444,
+      SDL_PIXELFORMAT_ARGB1555,
+      SDL_PIXELFORMAT_RGB565,
+      SDL_PIXELFORMAT_RGB24,
+      SDL_PIXELFORMAT_BGR24,
+      SDL_PIXELFORMAT_RGB888,
+      SDL_PIXELFORMAT_BGR888,
+      SDL_PIXELFORMAT_ARGB8888,
+      SDL_PIXELFORMAT_ABGR8888,
+      SDL_PIXELFORMAT_ARGB2101010},
+     0,
+     0}
+};
+
+typedef struct
+{
+    SDL_GLContext context;
+    SDL_bool updateSize;
+    SDL_bool GL_ARB_texture_rectangle_supported;
+    SDL_bool GL_EXT_paletted_texture_supported;
+    SDL_bool GL_APPLE_ycbcr_422_supported;
+    SDL_bool GL_MESA_ycbcr_texture_supported;
+    SDL_bool GL_ARB_fragment_program_supported;
+    int blendMode;
+
+    /* OpenGL functions */
+#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
+#include "../../video/SDL_glfuncs.h"
+#undef SDL_PROC
+
+    void (*glTextureRangeAPPLE) (GLenum target, GLsizei length,
+                                 const GLvoid * pointer);
+
+    PFNGLGETPROGRAMIVARBPROC glGetProgramivARB;
+    PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB;
+    PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB;
+    PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
+    PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
+    PFNGLBINDPROGRAMARBPROC glBindProgramARB;
+    PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
+
+    /* (optional) fragment programs */
+    GLuint fragment_program_UYVY;
+} GL_RenderData;
+
+typedef struct
+{
+    GLuint texture;
+    GLuint shader;
+    GLenum type;
+    GLfloat texw;
+    GLfloat texh;
+    GLenum format;
+    GLenum formattype;
+    Uint8 *palette;
+    void *pixels;
+    int pitch;
+    SDL_DirtyRectList dirty;
+    int HACK_RYAN_FIXME;
+} GL_TextureData;
+
+
+static void
+GL_SetError(const char *prefix, GLenum result)
+{
+    const char *error;
+
+    switch (result) {
+    case GL_NO_ERROR:
+        error = "GL_NO_ERROR";
+        break;
+    case GL_INVALID_ENUM:
+        error = "GL_INVALID_ENUM";
+        break;
+    case GL_INVALID_VALUE:
+        error = "GL_INVALID_VALUE";
+        break;
+    case GL_INVALID_OPERATION:
+        error = "GL_INVALID_OPERATION";
+        break;
+    case GL_STACK_OVERFLOW:
+        error = "GL_STACK_OVERFLOW";
+        break;
+    case GL_STACK_UNDERFLOW:
+        error = "GL_STACK_UNDERFLOW";
+        break;
+    case GL_OUT_OF_MEMORY:
+        error = "GL_OUT_OF_MEMORY";
+        break;
+    case GL_TABLE_TOO_LARGE:
+        error = "GL_TABLE_TOO_LARGE";
+        break;
+    default:
+        error = "UNKNOWN";
+        break;
+    }
+    SDL_SetError("%s: %s", prefix, error);
+}
+
+static int
+GL_LoadFunctions(GL_RenderData * data)
+{
+#ifdef __SDL_NOGETPROCADDR__
+#define SDL_PROC(ret,func,params) data->func=func;
+#else
+#define SDL_PROC(ret,func,params) \
+    do { \
+        data->func = SDL_GL_GetProcAddress(#func); \
+        if ( ! data->func ) { \
+            SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
+            return -1; \
+        } \
+    } while ( 0 );
+#endif /* __SDL_NOGETPROCADDR__ */
+
+#include "../../video/SDL_glfuncs.h"
+#undef SDL_PROC
+    return 0;
+}
+
+SDL_Renderer *
+GL_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+    SDL_Renderer *renderer;
+    GL_RenderData *data;
+    GLint value;
+    Uint32 window_flags;
+
+    window_flags = SDL_GetWindowFlags(window);
+    if (!(window_flags & SDL_WINDOW_OPENGL)) {
+        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
+            return NULL;
+        }
+    }
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        GL_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    renderer->WindowEvent = GL_WindowEvent;
+    renderer->CreateTexture = GL_CreateTexture;
+    renderer->QueryTexturePixels = GL_QueryTexturePixels;
+    renderer->UpdateTexture = GL_UpdateTexture;
+    renderer->LockTexture = GL_LockTexture;
+    renderer->UnlockTexture = GL_UnlockTexture;
+    renderer->DirtyTexture = GL_DirtyTexture;
+    renderer->RenderClear = GL_RenderClear;
+    renderer->RenderDrawPoints = GL_RenderDrawPoints;
+    renderer->RenderDrawLines = GL_RenderDrawLines;
+    renderer->RenderFillRects = GL_RenderFillRects;
+    renderer->RenderCopy = GL_RenderCopy;
+    renderer->RenderReadPixels = GL_RenderReadPixels;
+    renderer->RenderWritePixels = GL_RenderWritePixels;
+    renderer->RenderPresent = GL_RenderPresent;
+    renderer->DestroyTexture = GL_DestroyTexture;
+    renderer->DestroyRenderer = GL_DestroyRenderer;
+    renderer->info = GL_RenderDriver.info;
+    renderer->window = window;
+    renderer->driverdata = data;
+
+    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+
+    if (GL_LoadFunctions(data) < 0) {
+        GL_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    data->context = SDL_GL_CreateContext(window);
+    if (!data->context) {
+        GL_DestroyRenderer(renderer);
+        return NULL;
+    }
+    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+        GL_DestroyRenderer(renderer);
+        return NULL;
+    }
+#ifdef __MACOSX__
+    /* Enable multi-threaded rendering */
+    /* Disabled until Ryan finishes his VBO/PBO code...
+       CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine);
+     */
+#endif
+
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        SDL_GL_SetSwapInterval(1);
+    } else {
+        SDL_GL_SetSwapInterval(0);
+    }
+    if (SDL_GL_GetSwapInterval() > 0) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+
+    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_width = value;
+    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_height = value;
+
+    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
+        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
+        data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
+    }
+    if (SDL_GL_ExtensionSupported("GL_APPLE_ycbcr_422")) {
+        data->GL_APPLE_ycbcr_422_supported = SDL_TRUE;
+    }
+    if (SDL_GL_ExtensionSupported("GL_MESA_ycbcr_texture")) {
+        data->GL_MESA_ycbcr_texture_supported = SDL_TRUE;
+    }
+    if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) {
+        data->glTextureRangeAPPLE =
+            (void (*)(GLenum, GLsizei, const GLvoid *))
+            SDL_GL_GetProcAddress("glTextureRangeAPPLE");
+    }
+
+    /* we might use fragment programs for YUV data, etc. */
+    if (SDL_GL_ExtensionSupported("GL_ARB_fragment_program")) {
+        /* !!! FIXME: this doesn't check for errors. */
+        /* !!! FIXME: this should really reuse the glfuncs.h stuff. */
+        data->glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)
+            SDL_GL_GetProcAddress("glGetProgramivARB");
+        data->glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)
+            SDL_GL_GetProcAddress("glGetProgramStringARB");
+        data->glProgramLocalParameter4fvARB =
+            (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)
+            SDL_GL_GetProcAddress("glProgramLocalParameter4fvARB");
+        data->glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)
+            SDL_GL_GetProcAddress("glDeleteProgramsARB");
+        data->glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)
+            SDL_GL_GetProcAddress("glGenProgramsARB");
+        data->glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)
+            SDL_GL_GetProcAddress("glBindProgramARB");
+        data->glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)
+            SDL_GL_GetProcAddress("glProgramStringARB");
+        data->GL_ARB_fragment_program_supported = SDL_TRUE;
+    }
+
+    /* Set up parameters for rendering */
+    data->blendMode = -1;
+    data->glDisable(GL_DEPTH_TEST);
+    data->glDisable(GL_CULL_FACE);
+    /* This ended up causing video discrepancies between OpenGL and Direct3D */
+    /*data->glEnable(GL_LINE_SMOOTH);*/
+    if (data->GL_ARB_texture_rectangle_supported) {
+        data->glEnable(GL_TEXTURE_RECTANGLE_ARB);
+    } else {
+        data->glEnable(GL_TEXTURE_2D);
+    }
+    data->updateSize = SDL_TRUE;
+
+    return renderer;
+}
+
+static SDL_GLContext SDL_CurrentContext = NULL;
+
+static int
+GL_ActivateRenderer(SDL_Renderer * renderer)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (SDL_CurrentContext != data->context) {
+        if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+            return -1;
+        }
+        SDL_CurrentContext = data->context;
+    }
+    if (data->updateSize) {
+        int w, h;
+
+        SDL_GetWindowSize(window, &w, &h);
+        data->glMatrixMode(GL_PROJECTION);
+        data->glLoadIdentity();
+        data->glMatrixMode(GL_MODELVIEW);
+        data->glLoadIdentity();
+        data->glViewport(0, 0, w, h);
+        data->glOrtho(0.0, (GLdouble) w, (GLdouble) h, 0.0, 0.0, 1.0);
+        data->updateSize = SDL_FALSE;
+    }
+    return 0;
+}
+
+static void
+GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        /* Rebind the context to the window area and update matrices */
+        SDL_CurrentContext = NULL;
+        data->updateSize = SDL_TRUE;
+    }
+}
+
+static __inline__ int
+power_of_2(int input)
+{
+    int value = 1;
+
+    while (value < input) {
+        value <<= 1;
+    }
+    return value;
+}
+
+
+//#define DEBUG_PROGRAM_COMPILE 1
+
+static void
+set_shader_error(GL_RenderData * data, const char *prefix)
+{
+    GLint pos = 0;
+    const GLubyte *errstr;
+    data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
+    errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB);
+    SDL_SetError("%s: shader compile error at position %d: %s",
+           prefix, (int) pos, (const char *) errstr);
+}
+
+static GLuint
+compile_shader(GL_RenderData * data, GLenum shader_type, const char *_code)
+{
+    const int have_texture_rects = data->GL_ARB_texture_rectangle_supported;
+    const char *replacement = have_texture_rects ? "RECT" : "2D";
+    const size_t replacementlen = SDL_strlen(replacement);
+    const char *token = "%TEXTURETARGET%";
+    const size_t tokenlen = SDL_strlen(token);
+    char *code = NULL;
+    char *ptr = NULL;
+    GLuint program = 0;
+
+    /*
+     * The TEX instruction needs a different target depending on what we use.
+     *  To handle this, we use "%TEXTURETARGET%" and replace the string before
+     *  compiling the shader.
+     */
+    code = SDL_strdup(_code);
+    if (code == NULL)
+        return 0;
+
+    for (ptr = SDL_strstr(code, token); ptr; ptr = SDL_strstr(ptr + 1, token)) {
+        SDL_memcpy(ptr, replacement, replacementlen);
+        SDL_memmove(ptr + replacementlen, ptr + tokenlen,
+                    SDL_strlen(ptr + tokenlen) + 1);
+    }
+
+#if DEBUG_PROGRAM_COMPILE
+    printf("compiling shader:\n%s\n\n", code);
+#endif
+
+    data->glGetError();         /* flush any existing error state. */
+    data->glGenProgramsARB(1, &program);
+    data->glBindProgramARB(shader_type, program);
+    data->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB,
+                             (GLsizei)SDL_strlen(code), code);
+
+    SDL_free(code);
+
+    if (data->glGetError() == GL_INVALID_OPERATION) {
+#if DEBUG_PROGRAM_COMPILE
+        GLint pos = 0;
+        const GLubyte *errstr;
+        data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
+        errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB);
+        printf("program compile error at position %d: %s\n\n",
+               (int) pos, (const char *) errstr);
+#endif
+        data->glBindProgramARB(shader_type, 0);
+        data->glDeleteProgramsARB(1, &program);
+        return 0;
+    }
+
+    return program;
+}
+
+
+/*
+ * Fragment program that renders from UYVY textures.
+ * The UYVY to RGB equasion is:
+ *   R = 1.164(Y-16) + 1.596(Cr-128)
+ *   G = 1.164(Y-16) - 0.813(Cr-128) - 0.391(Cb-128)
+ *   B = 1.164(Y-16) + 2.018(Cb-128)
+ * Byte layout is Cb, Y1, Cr, Y2, stored in the R, G, B, A channels.
+ * 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr
+ *
+ * !!! FIXME: this ignores blendmodes, etc.
+ * !!! FIXME: this could be more efficient...use a dot product for green, etc.
+ */
+static const char *fragment_program_UYVY_source_code = "!!ARBfp1.0\n"
+    /* outputs... */
+    "OUTPUT outcolor = result.color;\n"
+    /* scratch registers... */
+    "TEMP uyvy;\n" "TEMP luminance;\n" "TEMP work;\n"
+    /* Halve the coordinates to grab the correct 32 bits for the fragment. */
+    "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n"
+    /* Sample the YUV texture. Cb, Y1, Cr, Y2, are stored in x, y, z, w. */
+    "TEX uyvy, work, texture[0], %TEXTURETARGET%;\n"
+    /* Do subtractions (128/255, 16/255, 128/255, 16/255) */
+    "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n"
+    /* Choose the luminance component by texcoord. */
+    /* !!! FIXME: laziness wins out for now... just average Y1 and Y2. */
+    "ADD luminance, uyvy.yyyy, uyvy.wwww;\n"
+    "MUL luminance, luminance, { 0.5, 0.5, 0.5, 0.5 };\n"
+    /* Multiply luminance by its magic value. */
+    "MUL luminance, luminance, { 1.164, 1.164, 1.164, 1.164 };\n"
+    /* uyvy.xyzw becomes Cr/Cr/Cb/Cb, with multiplications. */
+    "MUL uyvy, uyvy.zzxx, { 1.596, -0.813, 2.018, -0.391 };\n"
+    /* Add luminance to Cr and Cb, store to RGB channels. */
+    "ADD work.rgb, luminance, uyvy;\n"
+    /* Do final addition for Green channel.  (!!! FIXME: this should be a DPH?) */
+    "ADD work.g, work.g, uyvy.w;\n"
+    /* Make sure alpha channel is fully opaque.  (!!! FIXME: blend modes!) */
+    "MOV work.a, { 1.0 };\n"
+    /* Store out the final fragment color... */
+    "MOV outcolor, work;\n"
+    /* ...and we're done! */
+    "END\n";
+
+static __inline__ SDL_bool
+convert_format(GL_RenderData *renderdata, Uint32 pixel_format,
+               GLint* internalFormat, GLenum* format, GLenum* type)
+{
+    switch (pixel_format) {
+    case SDL_PIXELFORMAT_RGB332:
+        *internalFormat = GL_R3_G3_B2;
+        *format = GL_RGB;
+        *type = GL_UNSIGNED_BYTE_3_3_2;
+        break;
+    case SDL_PIXELFORMAT_RGB444:
+        *internalFormat = GL_RGB4;
+        *format = GL_RGB;
+        *type = GL_UNSIGNED_SHORT_4_4_4_4;
+        break;
+    case SDL_PIXELFORMAT_RGB555:
+        *internalFormat = GL_RGB5;
+        *format = GL_RGB;
+        *type = GL_UNSIGNED_SHORT_5_5_5_1;
+        break;
+    case SDL_PIXELFORMAT_ARGB4444:
+        *internalFormat = GL_RGBA4;
+        *format = GL_BGRA;
+        *type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+        break;
+    case SDL_PIXELFORMAT_ARGB1555:
+        *internalFormat = GL_RGB5_A1;
+        *format = GL_BGRA;
+        *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+        break;
+    case SDL_PIXELFORMAT_RGB565:
+        *internalFormat = GL_RGB8;
+        *format = GL_RGB;
+        *type = GL_UNSIGNED_SHORT_5_6_5;
+        break;
+    case SDL_PIXELFORMAT_RGB24:
+        *internalFormat = GL_RGB8;
+        *format = GL_RGB;
+        *type = GL_UNSIGNED_BYTE;
+        break;
+    case SDL_PIXELFORMAT_RGB888:
+        *internalFormat = GL_RGB8;
+        *format = GL_BGRA;
+        *type = GL_UNSIGNED_BYTE;
+        break;
+    case SDL_PIXELFORMAT_BGR24:
+        *internalFormat = GL_RGB8;
+        *format = GL_BGR;
+        *type = GL_UNSIGNED_BYTE;
+        break;
+    case SDL_PIXELFORMAT_BGR888:
+        *internalFormat = GL_RGB8;
+        *format = GL_RGBA;
+        *type = GL_UNSIGNED_BYTE;
+        break;
+    case SDL_PIXELFORMAT_ARGB8888:
+#ifdef __MACOSX__
+        *internalFormat = GL_RGBA;
+        *format = GL_BGRA;
+        *type = GL_UNSIGNED_INT_8_8_8_8_REV;
+#else
+        *internalFormat = GL_RGBA8;
+        *format = GL_BGRA;
+        *type = GL_UNSIGNED_BYTE;
+#endif
+        break;
+    case SDL_PIXELFORMAT_ABGR8888:
+        *internalFormat = GL_RGBA8;
+        *format = GL_RGBA;
+        *type = GL_UNSIGNED_BYTE;
+        break;
+    case SDL_PIXELFORMAT_ARGB2101010:
+        *internalFormat = GL_RGB10_A2;
+        *format = GL_BGRA;
+        *type = GL_UNSIGNED_INT_2_10_10_10_REV;
+        break;
+    case SDL_PIXELFORMAT_UYVY:
+        if (renderdata->GL_APPLE_ycbcr_422_supported) {
+            *internalFormat = GL_RGB;
+            *format = GL_YCBCR_422_APPLE;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+            *type = GL_UNSIGNED_SHORT_8_8_APPLE;
+#else
+            *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
+#endif
+        } else if (renderdata->GL_MESA_ycbcr_texture_supported) {
+            *internalFormat = GL_YCBCR_MESA;
+            *format = GL_YCBCR_MESA;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+            *type = GL_UNSIGNED_SHORT_8_8_MESA;
+#else
+            *type = GL_UNSIGNED_SHORT_8_8_REV_MESA;
+#endif
+        } else if (renderdata->GL_ARB_fragment_program_supported) {
+            *internalFormat = GL_RGBA;
+            *format = GL_RGBA;
+            *type = GL_UNSIGNED_BYTE;
+        } else {
+            return SDL_FALSE;
+        }
+        break;
+    case SDL_PIXELFORMAT_YUY2:
+        if (renderdata->GL_APPLE_ycbcr_422_supported) {
+            *internalFormat = GL_RGB;
+            *format = GL_YCBCR_422_APPLE;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+            *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
+#else
+            *type = GL_UNSIGNED_SHORT_8_8_APPLE;
+#endif
+        } else if (renderdata->GL_MESA_ycbcr_texture_supported) {
+            *internalFormat = GL_YCBCR_MESA;
+            *format = GL_YCBCR_MESA;
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+            *type = GL_UNSIGNED_SHORT_8_8_REV_MESA;
+#else
+            *type = GL_UNSIGNED_SHORT_8_8_MESA;
+#endif
+        } else {
+            return SDL_FALSE;
+        }
+        break;
+    default:
+        return SDL_FALSE;
+    }
+    return SDL_TRUE;
+}
+
+static int
+GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *data;
+    GLint internalFormat;
+    GLenum format, type;
+    int texture_w, texture_h;
+    GLuint shader = 0;
+    GLenum result;
+
+    GL_ActivateRenderer(renderer);
+
+    if (!convert_format(renderdata, texture->format, &internalFormat,
+                        &format, &type)) {
+        SDL_SetError("Texture format %s not supported by OpenGL",
+                     SDL_GetPixelFormatName(texture->format));
+        return -1;
+    }
+    if (texture->format == SDL_PIXELFORMAT_UYVY &&
+        !renderdata->GL_APPLE_ycbcr_422_supported &&
+        !renderdata->GL_MESA_ycbcr_texture_supported &&
+        renderdata->GL_ARB_fragment_program_supported) {
+        if (renderdata->fragment_program_UYVY == 0) {
+            renderdata->fragment_program_UYVY =
+                compile_shader(renderdata, GL_FRAGMENT_PROGRAM_ARB,
+                               fragment_program_UYVY_source_code);
+            if (renderdata->fragment_program_UYVY == 0) {
+                set_shader_error(renderdata, "UYVY");
+                return -1;
+            }
+        }
+        shader = renderdata->fragment_program_UYVY;
+    }
+
+    data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    data->shader = shader;
+
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        data->pitch = texture->w * bytes_per_pixel(texture->format);
+        data->pixels = SDL_malloc(texture->h * data->pitch);
+        if (!data->pixels) {
+            SDL_OutOfMemory();
+            SDL_free(data);
+            return -1;
+        }
+    }
+
+    texture->driverdata = data;
+
+    renderdata->glGetError();
+    renderdata->glGenTextures(1, &data->texture);
+    if (renderdata->GL_ARB_texture_rectangle_supported) {
+        data->type = GL_TEXTURE_RECTANGLE_ARB;
+        texture_w = texture->w;
+        texture_h = texture->h;
+        data->texw = (GLfloat) texture_w;
+        data->texh = (GLfloat) texture_h;
+    } else {
+        data->type = GL_TEXTURE_2D;
+        texture_w = power_of_2(texture->w);
+        texture_h = power_of_2(texture->h);
+        data->texw = (GLfloat) (texture->w) / texture_w;
+        data->texh = (GLfloat) texture->h / texture_h;
+    }
+
+    /* YUV formats use RGBA but are really two bytes per pixel */
+    if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) {
+        texture_w /= 2;
+        if (data->type == GL_TEXTURE_2D) {
+            data->texw *= 2.0f;
+        }
+        data->HACK_RYAN_FIXME = 2;
+    } else {
+        data->HACK_RYAN_FIXME = 1;
+    }
+
+    data->format = format;
+    data->formattype = type;
+    renderdata->glEnable(data->type);
+    renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
+                                GL_LINEAR);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
+                                GL_LINEAR);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
+                                GL_CLAMP_TO_EDGE);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
+                                GL_CLAMP_TO_EDGE);
+#ifdef __MACOSX__
+#ifndef GL_TEXTURE_STORAGE_HINT_APPLE
+#define GL_TEXTURE_STORAGE_HINT_APPLE       0x85BC
+#endif
+#ifndef STORAGE_CACHED_APPLE
+#define STORAGE_CACHED_APPLE                0x85BE
+#endif
+#ifndef STORAGE_SHARED_APPLE
+#define STORAGE_SHARED_APPLE                0x85BF
+#endif
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
+                                    GL_STORAGE_SHARED_APPLE);
+    } else {
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
+                                    GL_STORAGE_CACHED_APPLE);
+    }
+/* This causes a crash in testoverlay for some reason.  Apple bug? */
+#if 0
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING
+        && texture->format == SDL_PIXELFORMAT_ARGB8888) {
+        /*
+           if (renderdata->glTextureRangeAPPLE) {
+           renderdata->glTextureRangeAPPLE(data->type,
+           texture->h * data->pitch,
+           data->pixels);
+           }
+         */
+        renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
+                                 texture_h, 0, format, type, data->pixels);
+    } else
+#endif
+#endif
+    {
+        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
+                                 texture_h, 0, format, type, NULL);
+    }
+    renderdata->glDisable(data->type);
+    result = renderdata->glGetError();
+    if (result != GL_NO_ERROR) {
+        GL_SetError("glTexImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GL_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
+                      void **pixels, int *pitch)
+{
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+
+    *pixels = data->pixels;
+    *pitch = data->pitch;
+    return 0;
+}
+
+static void
+SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture,
+                   int pitch)
+{
+    renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
+                              (pitch / bytes_per_pixel(texture->format)) /
+                              ((GL_TextureData *) texture->driverdata)->
+                              HACK_RYAN_FIXME);
+}
+
+static int
+GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                 const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+    GLenum result;
+
+    GL_ActivateRenderer(renderer);
+
+    renderdata->glGetError();
+    SetupTextureUpdate(renderdata, texture, pitch);
+    renderdata->glEnable(data->type);
+    renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
+                                rect->h, data->format, data->formattype,
+                                pixels);
+    renderdata->glDisable(data->type);
+    result = renderdata->glGetError();
+    if (result != GL_NO_ERROR) {
+        GL_SetError("glTexSubImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * rect, int markDirty, void **pixels,
+               int *pitch)
+{
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+
+    if (markDirty) {
+        SDL_AddDirtyRect(&data->dirty, rect);
+    }
+
+    *pixels =
+        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
+                  rect->x * bytes_per_pixel(texture->format));
+    *pitch = data->pitch;
+    return 0;
+}
+
+static void
+GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+}
+
+static void
+GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
+                const SDL_Rect * rects)
+{
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+    int i;
+
+    for (i = 0; i < numrects; ++i) {
+        SDL_AddDirtyRect(&data->dirty, &rects[i]);
+    }
+}
+
+static void
+GL_SetBlendMode(GL_RenderData * data, int blendMode)
+{
+    if (blendMode != data->blendMode) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_NONE:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+            data->glDisable(GL_BLEND);
+            break;
+        case SDL_BLENDMODE_BLEND:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+            break;
+        case SDL_BLENDMODE_ADD:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+            break;
+        }
+        data->blendMode = blendMode;
+    }
+}
+
+static int
+GL_RenderClear(SDL_Renderer * renderer)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+
+    GL_ActivateRenderer(renderer);
+
+    data->glClearColor((GLfloat) renderer->r * inv255f,
+                       (GLfloat) renderer->g * inv255f,
+                       (GLfloat) renderer->b * inv255f,
+                       (GLfloat) renderer->a * inv255f);
+
+    data->glClear(GL_COLOR_BUFFER_BIT);
+
+    return 0;
+}
+
+static int
+GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                    int count)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    int i;
+
+    GL_ActivateRenderer(renderer);
+
+    GL_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    data->glBegin(GL_POINTS);
+    for (i = 0; i < count; ++i) {
+        data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
+    }
+    data->glEnd();
+
+    return 0;
+}
+
+static int
+GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                   int count)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    int i;
+
+    GL_ActivateRenderer(renderer);
+
+    GL_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    if (count > 2 && 
+        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
+        data->glBegin(GL_LINE_LOOP);
+        /* GL_LINE_LOOP takes care of the final segment */
+        --count;
+        for (i = 0; i < count; ++i) {
+            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
+        }
+        data->glEnd();
+    } else {
+#if defined(__APPLE__) || defined(__WIN32__)
+#else
+        int x1, y1, x2, y2;
+#endif
+
+        data->glBegin(GL_LINE_STRIP);
+        for (i = 0; i < count; ++i) {
+            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
+        }
+        data->glEnd();
+
+        /* The line is half open, so we need one more point to complete it.
+         * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
+         * If we have to, we can use vertical line and horizontal line textures
+         * for vertical and horizontal lines, and then create custom textures
+         * for diagonal lines and software render those.  It's terrible, but at
+         * least it would be pixel perfect.
+         */
+        data->glBegin(GL_POINTS);
+#if defined(__APPLE__) || defined(__WIN32__)
+        /* Mac OS X and Windows seem to always leave the second point open */
+        data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y);
+#else
+        /* Linux seems to leave the right-most or bottom-most point open */
+        x1 = points[0].x;
+        y1 = points[0].y;
+        x2 = points[count-1].x;
+        y2 = points[count-1].y;
+
+        if (x1 > x2) {
+            data->glVertex2f(0.5f + x1, 0.5f + y1);
+        } else if (x2 > x1) {
+            data->glVertex2f(0.5f + x2, 0.5f + y2);
+        } else if (y1 > y2) {
+            data->glVertex2f(0.5f + x1, 0.5f + y1);
+        } else if (y2 > y1) {
+            data->glVertex2f(0.5f + x2, 0.5f + y2);
+        }
+#endif
+        data->glEnd();
+    }
+
+    return 0;
+}
+
+static int
+GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    int i;
+
+    GL_ActivateRenderer(renderer);
+
+    GL_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    for (i = 0; i < count; ++i) {
+        const SDL_Rect *rect = rects[i];
+
+        data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
+    }
+
+    return 0;
+}
+
+static int
+GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
+    int minx, miny, maxx, maxy;
+    GLfloat minu, maxu, minv, maxv;
+
+    GL_ActivateRenderer(renderer);
+
+    if (texturedata->dirty.list) {
+        SDL_DirtyRect *dirty;
+        void *pixels;
+        int bpp = bytes_per_pixel(texture->format);
+        int pitch = texturedata->pitch;
+
+        SetupTextureUpdate(data, texture, pitch);
+        data->glEnable(texturedata->type);
+        data->glBindTexture(texturedata->type, texturedata->texture);
+        for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
+            SDL_Rect *rect = &dirty->rect;
+            pixels =
+                (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
+                          rect->x * bpp);
+            data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
+                                  rect->w / texturedata->HACK_RYAN_FIXME,
+                                  rect->h, texturedata->format,
+                                  texturedata->formattype, pixels);
+        }
+        SDL_ClearDirtyRects(&texturedata->dirty);
+    }
+
+    minx = dstrect->x;
+    miny = dstrect->y;
+    maxx = dstrect->x + dstrect->w;
+    maxy = dstrect->y + dstrect->h;
+
+    minu = (GLfloat) srcrect->x / texture->w;
+    minu *= texturedata->texw;
+    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
+    maxu *= texturedata->texw;
+    minv = (GLfloat) srcrect->y / texture->h;
+    minv *= texturedata->texh;
+    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
+    maxv *= texturedata->texh;
+
+    data->glEnable(texturedata->type);
+    data->glBindTexture(texturedata->type, texturedata->texture);
+
+    if (texture->modMode) {
+        data->glColor4f((GLfloat) texture->r * inv255f,
+                        (GLfloat) texture->g * inv255f,
+                        (GLfloat) texture->b * inv255f,
+                        (GLfloat) texture->a * inv255f);
+    } else {
+        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    }
+
+    GL_SetBlendMode(data, texture->blendMode);
+
+    /* Set up the shader for the copy, if any */
+    if (texturedata->shader) {
+        data->glEnable(GL_FRAGMENT_PROGRAM_ARB);
+        data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, texturedata->shader);
+    }
+
+    data->glBegin(GL_TRIANGLE_STRIP);
+    data->glTexCoord2f(minu, minv);
+    data->glVertex2f((GLfloat) minx, (GLfloat) miny);
+    data->glTexCoord2f(maxu, minv);
+    data->glVertex2f((GLfloat) maxx, (GLfloat) miny);
+    data->glTexCoord2f(minu, maxv);
+    data->glVertex2f((GLfloat) minx, (GLfloat) maxy);
+    data->glTexCoord2f(maxu, maxv);
+    data->glVertex2f((GLfloat) maxx, (GLfloat) maxy);
+    data->glEnd();
+
+    if (texturedata->shader) {
+        data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
+    }
+
+    data->glDisable(texturedata->type);
+
+    return 0;
+}
+
+static int
+GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                    Uint32 pixel_format, void * pixels, int pitch)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    GLint internalFormat;
+    GLenum format, type;
+    Uint8 *src, *dst, *tmp;
+    int w, h, length, rows;
+
+    GL_ActivateRenderer(renderer);
+
+    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
+        /* FIXME: Do a temp copy to a format that is supported */
+        SDL_SetError("Unsupported pixel format");
+        return -1;
+    }
+
+    SDL_GetWindowSize(window, &w, &h);
+
+    data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
+    data->glPixelStorei(GL_PACK_ROW_LENGTH,
+                        (pitch / bytes_per_pixel(pixel_format)));
+
+    data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h,
+                       format, type, pixels);
+
+    /* Flip the rows to be top-down */
+    length = rect->w * bytes_per_pixel(pixel_format);
+    src = (Uint8*)pixels + (rect->h-1)*pitch;
+    dst = (Uint8*)pixels;
+    tmp = SDL_stack_alloc(Uint8, length);
+    rows = rect->h / 2;
+    while (rows--) {
+        SDL_memcpy(tmp, dst, length);
+        SDL_memcpy(dst, src, length);
+        SDL_memcpy(src, tmp, length);
+        dst += pitch;
+        src -= pitch;
+    }
+    SDL_stack_free(tmp);
+
+    return 0;
+}
+
+static int
+GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 pixel_format, const void * pixels, int pitch)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+    GLint internalFormat;
+    GLenum format, type;
+    Uint8 *src, *dst, *tmp;
+    int w, h, length, rows;
+
+    GL_ActivateRenderer(renderer);
+
+    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
+        /* FIXME: Do a temp copy to a format that is supported */
+        SDL_SetError("Unsupported pixel format");
+        return -1;
+    }
+
+    SDL_GetWindowSize(window, &w, &h);
+
+    data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    data->glPixelStorei(GL_UNPACK_ROW_LENGTH,
+                        (pitch / bytes_per_pixel(pixel_format)));
+
+    /* Flip the rows to be bottom-up */
+    length = rect->h * rect->w * pitch;
+    tmp = SDL_stack_alloc(Uint8, length);
+    src = (Uint8*)pixels + (rect->h-1)*pitch;
+    dst = (Uint8*)tmp;
+    rows = rect->h;
+    while (rows--) {
+        SDL_memcpy(dst, src, pitch);
+        dst += pitch;
+        src -= pitch;
+    }
+
+    data->glRasterPos2i(rect->x, (h-rect->y));
+    data->glDrawPixels(rect->w, rect->h, format, type, tmp);
+    SDL_stack_free(tmp);
+
+    return 0;
+}
+
+static void
+GL_RenderPresent(SDL_Renderer * renderer)
+{
+    GL_ActivateRenderer(renderer);
+
+    SDL_GL_SwapWindow(renderer->window);
+}
+
+static void
+GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
+    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
+
+    GL_ActivateRenderer(renderer);
+
+    if (!data) {
+        return;
+    }
+    if (data->texture) {
+        renderdata->glDeleteTextures(1, &data->texture);
+    }
+    if (data->palette) {
+        SDL_free(data->palette);
+    }
+    if (data->pixels) {
+        SDL_free(data->pixels);
+    }
+    SDL_FreeDirtyRects(&data->dirty);
+    SDL_free(data);
+    texture->driverdata = NULL;
+}
+
+static void
+GL_DestroyRenderer(SDL_Renderer * renderer)
+{
+    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
+
+    if (data) {
+        if (data->context) {
+            if (data->GL_ARB_fragment_program_supported) {
+                data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
+                data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
+                if (data->fragment_program_UYVY &&
+                    data->fragment_program_UYVY != ~0) {
+                    data->glDeleteProgramsARB(1,
+                                              &data->fragment_program_UYVY);
+                }
+            }
+
+            /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
+            SDL_GL_DeleteContext(data->context);
+        }
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+#endif /* SDL_VIDEO_RENDER_OGL */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/opengles/SDL_renderer_gles.c	Wed Feb 02 14:34:54 2011 -0800
@@ -0,0 +1,842 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#if SDL_VIDEO_RENDER_OGL_ES
+
+#include "SDL_opengles.h"
+#include "../SDL_sysrender.h"
+
+#if defined(SDL_VIDEO_DRIVER_PANDORA)
+
+/* Empty function stub to get OpenGL ES 1.x support without  */
+/* OpenGL ES extension GL_OES_draw_texture supported         */
+GL_API void GL_APIENTRY
+glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
+{
+    return;
+}
+
+#endif /* PANDORA */
+
+/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
+
+/* Used to re-create the window with OpenGL capability */
+extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
+
+static const float inv255f = 1.0f / 255.0f;
+
+static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
+static void GLES_WindowEvent(SDL_Renderer * renderer,
+                             const SDL_WindowEvent *event);
+static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int GLES_QueryTexturePixels(SDL_Renderer * renderer,
+                                   SDL_Texture * texture, void **pixels,
+                                   int *pitch);
+static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                              const SDL_Rect * rect, const void *pixels,
+                              int pitch);
+static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                            const SDL_Rect * rect, int markDirty,
+                            void **pixels, int *pitch);
+static void GLES_UnlockTexture(SDL_Renderer * renderer,
+                               SDL_Texture * texture);
+static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                              int numrects, const SDL_Rect * rects);
+static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
+                                 const SDL_Point * points, int count);
+static int GLES_RenderDrawLines(SDL_Renderer * renderer,
+                                const SDL_Point * points, int count);
+static int GLES_RenderFillRects(SDL_Renderer * renderer,
+                                const SDL_Rect ** rects, int count);
+static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                           const SDL_Rect * srcrect,
+                           const SDL_Rect * dstrect);
+static void GLES_RenderPresent(SDL_Renderer * renderer);
+static void GLES_DestroyTexture(SDL_Renderer * renderer,
+                                SDL_Texture * texture);
+static void GLES_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver GL_ES_RenderDriver = {
+    GLES_CreateRenderer,
+    {
+     "opengl_es",
+     (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
+     6,
+     {
+      /* OpenGL ES 1.x supported formats list */
+      SDL_PIXELFORMAT_RGBA4444,
+      SDL_PIXELFORMAT_RGBA5551,
+      SDL_PIXELFORMAT_RGB565,
+      SDL_PIXELFORMAT_RGB24,
+      SDL_PIXELFORMAT_BGR888,
+      SDL_PIXELFORMAT_ABGR8888},
+     0,
+     0}
+};
+
+typedef struct
+{
+    SDL_GLContext context;
+    SDL_bool updateSize;
+    int blendMode;
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+
+    SDL_bool useDrawTexture;
+    SDL_bool GL_OES_draw_texture_supported;
+
+    /* OpenGL ES functions */
+#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
+#include "SDL_glesfuncs.h"
+#undef SDL_PROC
+
+} GLES_RenderData;
+
+typedef struct
+{
+    GLuint texture;
+    GLenum type;
+    GLfloat texw;
+    GLfloat texh;
+    GLenum format;
+    GLenum formattype;
+    void *pixels;
+    int pitch;
+    SDL_DirtyRectList dirty;
+} GLES_TextureData;
+
+static void
+GLES_SetError(const char *prefix, GLenum result)
+{
+    const char *error;
+
+    switch (result) {
+    case GL_NO_ERROR:
+        error = "GL_NO_ERROR";
+        break;
+    case GL_INVALID_ENUM:
+        error = "GL_INVALID_ENUM";
+        break;
+    case GL_INVALID_VALUE:
+        error = "GL_INVALID_VALUE";
+        break;
+    case GL_INVALID_OPERATION:
+        error = "GL_INVALID_OPERATION";
+        break;
+    case GL_STACK_OVERFLOW:
+        error = "GL_STACK_OVERFLOW";
+        break;
+    case GL_STACK_UNDERFLOW:
+        error = "GL_STACK_UNDERFLOW";
+        break;
+    case GL_OUT_OF_MEMORY:
+        error = "GL_OUT_OF_MEMORY";
+        break;
+    default:
+        error = "UNKNOWN";
+        break;
+    }
+    SDL_SetError("%s: %s", prefix, error);
+}
+
+static int
+GLES_LoadFunctions(GLES_RenderData * data)
+{
+
+#define SDL_PROC(ret,func,params) \
+    data->func = func;
+#include "SDL_glesfuncs.h"
+#undef SDL_PROC
+
+    return 0;
+}
+
+SDL_Renderer *
+GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+
+    SDL_Renderer *renderer;
+    GLES_RenderData *data;
+    GLint value;
+    Uint32 window_flags;
+
+    window_flags = SDL_GetWindowFlags(window);
+    if (!(window_flags & SDL_WINDOW_OPENGL)) {
+        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
+            return NULL;
+        }
+    }
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        GLES_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    renderer->WindowEvent = GLES_WindowEvent;
+    renderer->CreateTexture = GLES_CreateTexture;
+    renderer->QueryTexturePixels = GLES_QueryTexturePixels;
+    renderer->UpdateTexture = GLES_UpdateTexture;
+    renderer->LockTexture = GLES_LockTexture;
+    renderer->UnlockTexture = GLES_UnlockTexture;
+    renderer->DirtyTexture = GLES_DirtyTexture;
+    renderer->RenderDrawPoints = GLES_RenderDrawPoints;
+    renderer->RenderDrawLines = GLES_RenderDrawLines;
+    renderer->RenderFillRects = GLES_RenderFillRects;
+    renderer->RenderCopy = GLES_RenderCopy;
+    renderer->RenderPresent = GLES_RenderPresent;
+    renderer->DestroyTexture = GLES_DestroyTexture;
+    renderer->DestroyRenderer = GLES_DestroyRenderer;
+    renderer->info = GL_ES_RenderDriver.info;
+    renderer->window = window;
+    renderer->driverdata = data;
+
+    renderer->info.flags = SDL_RENDERER_ACCELERATED;
+
+    if (GLES_LoadFunctions(data) < 0) {
+        GLES_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    data->context = SDL_GL_CreateContext(window);
+    if (!data->context) {
+        GLES_DestroyRenderer(renderer);
+        return NULL;
+    }
+    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+        GLES_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        SDL_GL_SetSwapInterval(1);
+    } else {
+        SDL_GL_SetSwapInterval(0);
+    }
+    if (SDL_GL_GetSwapInterval() > 0) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+
+#if SDL_VIDEO_DRIVER_PANDORA
+    data->GL_OES_draw_texture_supported = SDL_FALSE;
+    data->useDrawTexture = SDL_FALSE;
+#else
+    if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
+        data->GL_OES_draw_texture_supported = SDL_TRUE;
+        data->useDrawTexture = SDL_TRUE;
+    } else {
+        data->GL_OES_draw_texture_supported = SDL_FALSE;
+        data->useDrawTexture = SDL_FALSE;
+    }
+#endif
+
+    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_width = value;
+    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
+    renderer->info.max_texture_height = value;
+
+    /* Set up parameters for rendering */
+    data->blendMode = -1;
+    data->glDisable(GL_DEPTH_TEST);
+    data->glDisable(GL_CULL_FACE);
+    data->updateSize = SDL_TRUE;
+
+    data->glEnableClientState(GL_VERTEX_ARRAY);
+    data->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+    
+    return renderer;
+}
+
+static SDL_GLContext SDL_CurrentContext = NULL;
+
+static int
+GLES_ActivateRenderer(SDL_Renderer * renderer)
+{
+
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (SDL_CurrentContext != data->context) {
+        if (SDL_GL_MakeCurrent(window, data->context) < 0) {
+            return -1;
+        }
+        SDL_CurrentContext = data->context;
+    }
+    if (data->updateSize) {
+        int w, h;
+
+        SDL_GetWindowSize(window, &w, &h);
+        data->glMatrixMode(GL_PROJECTION);
+        data->glLoadIdentity();
+        data->glMatrixMode(GL_MODELVIEW);
+        data->glLoadIdentity();
+        data->glViewport(0, 0, w, h);
+        data->glOrthof(0.0, (GLfloat) w, (GLfloat) h, 0.0, 0.0, 1.0);
+        data->updateSize = SDL_FALSE;
+    }
+    return 0;
+}
+
+static void
+GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        /* Rebind the context to the window area and update matrices */
+        SDL_CurrentContext = NULL;
+        data->updateSize = SDL_TRUE;
+    }
+}
+
+static __inline__ int
+power_of_2(int input)
+{
+    int value = 1;
+
+    while (value < input) {
+        value <<= 1;
+    }
+    return value;
+}
+
+static int
+GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
+    GLES_TextureData *data;
+    GLint internalFormat;
+    GLenum format, type;
+    int texture_w, texture_h;
+    GLenum result;
+
+    GLES_ActivateRenderer(renderer);
+
+    switch (texture->format) {
+    case SDL_PIXELFORMAT_RGB24:
+        internalFormat = GL_RGB;
+        format = GL_RGB;
+        type = GL_UNSIGNED_BYTE;
+        break;
+    case SDL_PIXELFORMAT_BGR888:
+    case SDL_PIXELFORMAT_ABGR8888:
+        internalFormat = GL_RGBA;
+        format = GL_RGBA;
+        type = GL_UNSIGNED_BYTE;
+        break;
+    case SDL_PIXELFORMAT_RGB565:
+        internalFormat = GL_RGB;
+        format = GL_RGB;
+        type = GL_UNSIGNED_SHORT_5_6_5;
+        break;
+    case SDL_PIXELFORMAT_RGBA5551:
+        internalFormat = GL_RGBA;
+        format = GL_RGBA;
+        type = GL_UNSIGNED_SHORT_5_5_5_1;
+        break;
+    case SDL_PIXELFORMAT_RGBA4444:
+        internalFormat = GL_RGBA;
+        format = GL_RGBA;
+        type = GL_UNSIGNED_SHORT_4_4_4_4;
+        break;
+    default:
+        SDL_SetError("Texture format %s not supported by OpenGL ES",
+                     SDL_GetPixelFormatName(texture->format));
+        return -1;
+    }
+
+    data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SDL_OutOfMemory();
+        return -1;
+    }
+
+    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
+        data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
+        data->pixels = SDL_malloc(texture->h * data->pitch);
+        if (!data->pixels) {
+            SDL_OutOfMemory();
+            SDL_free(data);
+            return -1;
+        }
+    }
+
+    texture->driverdata = data;
+
+    renderdata->glGetError();
+    renderdata->glEnable(GL_TEXTURE_2D);
+    renderdata->glGenTextures(1, &data->texture);
+
+    data->type = GL_TEXTURE_2D;
+    /* no NPOV textures allowed in OpenGL ES (yet) */
+    texture_w = power_of_2(texture->w);
+    texture_h = power_of_2(texture->h);
+    data->texw = (GLfloat) texture->w / texture_w;
+    data->texh = (GLfloat) texture->h / texture_h;
+
+    data->format = format;
+    data->formattype = type;
+    renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
+                                GL_LINEAR);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
+                                GL_LINEAR);
+    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, internalFormat, texture_w,
+                             texture_h, 0, format, type, NULL);
+    renderdata->glDisable(GL_TEXTURE_2D);
+
+    result = renderdata->glGetError();
+    if (result != GL_NO_ERROR) {
+        GLES_SetError("glTexImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GLES_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
+                        void **pixels, int *pitch)
+{
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+
+    *pixels = data->pixels;
+    *pitch = data->pitch;
+    return 0;
+}
+
+static void
+SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture,
+                   int pitch)
+{
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+    renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+}
+
+static int
+GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                   const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+    GLenum result;
+    int bpp = SDL_BYTESPERPIXEL(texture->format);
+    void * temp_buffer;
+    void * temp_ptr;
+    int i;
+
+    GLES_ActivateRenderer(renderer);
+
+    renderdata->glGetError();
+    renderdata->glEnable(data->type);
+    SetupTextureUpdate(renderdata, texture, pitch);
+
+    if( rect->w * bpp == pitch ) {
+         temp_buffer = (void *)pixels; /* No need to reformat */
+    } else {
+         /* Reformatting of mem area required */
+         temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
+         temp_ptr = temp_buffer;
+         for (i = 0; i < rect->h; i++) {
+             SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
+             temp_ptr += rect->w * bpp;
+             pixels += pitch;
+         }
+    }
+
+    renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
+                                rect->h, data->format, data->formattype,
+                                temp_buffer);
+
+    if( temp_buffer != pixels ) {
+        SDL_free(temp_buffer);
+    }
+
+    renderdata->glDisable(data->type);
+    result = renderdata->glGetError();
+    if (result != GL_NO_ERROR) {
+        GLES_SetError("glTexSubImage2D()", result);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                 const SDL_Rect * rect, int markDirty, void **pixels,
+                 int *pitch)
+{
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+
+    if (markDirty) {
+        SDL_AddDirtyRect(&data->dirty, rect);
+    }
+
+    *pixels =
+        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
+                  rect->x * SDL_BYTESPERPIXEL(texture->format));
+    *pitch = data->pitch;
+    return 0;
+}
+
+static void
+GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+}
+
+static void
+GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                  int numrects, const SDL_Rect * rects)
+{
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+    int i;
+
+    for (i = 0; i < numrects; ++i) {
+        SDL_AddDirtyRect(&data->dirty, &rects[i]);
+    }
+}
+
+static void
+GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
+{
+    if (blendMode != data->blendMode) {
+        switch (blendMode) {
+        case SDL_BLENDMODE_NONE:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+            data->glDisable(GL_BLEND);
+            break;
+        case SDL_BLENDMODE_BLEND:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+            break;
+        case SDL_BLENDMODE_ADD:
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+            break;
+        }
+        data->blendMode = blendMode;
+    }
+}
+
+static int
+GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                      int count)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    int i;
+    GLshort *vertices;
+
+    GLES_ActivateRenderer(renderer);
+
+    GLES_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    vertices = SDL_stack_alloc(GLshort, count*2);
+    for (i = 0; i < count; ++i) {
+        vertices[2*i+0] = (GLshort)points[i].x;
+        vertices[2*i+1] = (GLshort)points[i].y;
+    }
+    data->glVertexPointer(2, GL_SHORT, 0, vertices);
+    data->glDrawArrays(GL_POINTS, 0, count);
+    SDL_stack_free(vertices);
+
+    return 0;
+}
+
+static int
+GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                     int count)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    int i;
+    GLshort *vertices;
+
+    GLES_ActivateRenderer(renderer);
+
+    GLES_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    vertices = SDL_stack_alloc(GLshort, count*2);
+    for (i = 0; i < count; ++i) {
+        vertices[2*i+0] = (GLshort)points[i].x;
+        vertices[2*i+1] = (GLshort)points[i].y;
+    }
+    data->glVertexPointer(2, GL_SHORT, 0, vertices);
+    if (count > 2 && 
+        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
+        /* GL_LINE_LOOP takes care of the final segment */
+        --count;
+        data->glDrawArrays(GL_LINE_LOOP, 0, count);
+    } else {
+        data->glDrawArrays(GL_LINE_STRIP, 0, count);
+    }
+    SDL_stack_free(vertices);
+
+    return 0;
+}
+
+static int
+GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
+                     int count)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    int i;
+
+    GLES_ActivateRenderer(renderer);
+
+    GLES_SetBlendMode(data, renderer->blendMode);
+
+    data->glColor4f((GLfloat) renderer->r * inv255f,
+                    (GLfloat) renderer->g * inv255f,
+                    (GLfloat) renderer->b * inv255f,
+                    (GLfloat) renderer->a * inv255f);
+
+    for (i = 0; i < count; ++i) {
+        const SDL_Rect *rect = rects[i];
+        GLshort minx = rect->x;
+        GLshort maxx = rect->x + rect->w;
+        GLshort miny = rect->y;
+        GLshort maxy = rect->y + rect->h;
+        GLshort vertices[8];
+        vertices[0] = minx;
+        vertices[1] = miny;
+        vertices[2] = maxx;
+        vertices[3] = miny;
+        vertices[4] = minx;
+        vertices[5] = maxy;
+        vertices[6] = maxx;
+        vertices[7] = maxy;
+
+        data->glVertexPointer(2, GL_SHORT, 0, vertices);
+        data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    }
+
+    return 0;
+}
+
+static int
+GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
+    int minx, miny, maxx, maxy;
+    GLfloat minu, maxu, minv, maxv;
+    int i;
+    void *temp_buffer;          /* used for reformatting dirty rect pixels */
+    void *temp_ptr;
+
+    GLES_ActivateRenderer(renderer);
+
+    data->glEnable(GL_TEXTURE_2D);
+
+    if (texturedata->dirty.list) {
+        SDL_DirtyRect *dirty;
+        void *pixels;
+        int bpp = SDL_BYTESPERPIXEL(texture->format);
+        int pitch = texturedata->pitch;
+
+        SetupTextureUpdate(data, texture, pitch);
+
+        data->glBindTexture(texturedata->type, texturedata->texture);
+        for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
+            SDL_Rect *rect = &dirty->rect;
+            pixels =
+                (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
+                          rect->x * bpp);
+            /*      There is no GL_UNPACK_ROW_LENGTH in OpenGLES 
+               we must do this reformatting ourselves(!)
+
+               maybe it'd be a good idea to keep a temp buffer around
+               for this purpose rather than allocating it each time
+             */
+            if( rect->x == 0 && rect->w * bpp == pitch ) {
+                temp_buffer = pixels; /* Updating whole texture, no need to reformat */
+            } else {
+                temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
+                temp_ptr = temp_buffer;
+                for (i = 0; i < rect->h; i++) {
+                    SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
+                    temp_ptr += rect->w * bpp;
+                    pixels += pitch;
+                }
+            }
+
+            data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
+                                  rect->w, rect->h, texturedata->format,
+                                  texturedata->formattype, temp_buffer);
+
+            if( temp_buffer != pixels ) {
+                SDL_free(temp_buffer);
+            }
+        }
+        SDL_ClearDirtyRects(&texturedata->dirty);
+    }
+
+    data->glBindTexture(texturedata->type, texturedata->texture);
+
+    if (texture->modMode) {
+        data->glColor4f((GLfloat) texture->r * inv255f,
+                        (GLfloat) texture->g * inv255f,
+                        (GLfloat) texture->b * inv255f,
+                        (GLfloat) texture->a * inv255f);
+    } else {
+        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    }
+
+    GLES_SetBlendMode(data, texture->blendMode);
+
+    if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
+        /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
+        GLint cropRect[4];
+        int w, h;
+        SDL_Window *window = renderer->window;
+
+        SDL_GetWindowSize(window, &w, &h);
+        cropRect[0] = srcrect->x;
+        cropRect[1] = srcrect->y + srcrect->h;
+        cropRect[2] = srcrect->w;
+        cropRect[3] = -srcrect->h;
+        data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
+                               cropRect);
+        data->glDrawTexiOES(dstrect->x, h - dstrect->y - dstrect->h, 0,
+                            dstrect->w, dstrect->h);
+    } else {
+
+        minx = dstrect->x;
+        miny = dstrect->y;
+        maxx = dstrect->x + dstrect->w;
+        maxy = dstrect->y + dstrect->h;
+
+        minu = (GLfloat) srcrect->x / texture->w;
+        minu *= texturedata->texw;
+        maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
+        maxu *= texturedata->texw;
+        minv = (GLfloat) srcrect->y / texture->h;
+        minv *= texturedata->texh;
+        maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
+        maxv *= texturedata->texh;
+
+        GLshort vertices[8];
+        GLfloat texCoords[8];
+
+        vertices[0] = minx;
+        vertices[1] = miny;
+        vertices[2] = maxx;
+        vertices[3] = miny;
+        vertices[4] = minx;
+        vertices[5] = maxy;
+        vertices[6] = maxx;
+        vertices[7] = maxy;
+
+        texCoords[0] = minu;
+        texCoords[1] = minv;
+        texCoords[2] = maxu;
+        texCoords[3] = minv;
+        texCoords[4] = minu;
+        texCoords[5] = maxv;
+        texCoords[6] = maxu;
+        texCoords[7] = maxv;
+
+        data->glVertexPointer(2, GL_SHORT, 0, vertices);
+        data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
+        data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+    }
+
+    data->glDisable(GL_TEXTURE_2D);
+
+    return 0;
+}
+
+static void
+GLES_RenderPresent(SDL_Renderer * renderer)
+{
+    GLES_ActivateRenderer(renderer);
+
+    SDL_GL_SwapWindow(renderer->window);
+}
+
+static void
+GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
+
+    GLES_ActivateRenderer(renderer);
+
+    if (!data) {
+        return;
+    }
+    if (data->texture) {
+        glDeleteTextures(1, &data->texture);
+    }
+    if (data->pixels) {
+        SDL_free(data->pixels);
+    }
+    SDL_FreeDirtyRects(&data->dirty);
+    SDL_free(data);
+    texture->driverdata = NULL;
+}
+
+static void
+GLES_DestroyRenderer(SDL_Renderer * renderer)
+{
+    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
+
+    if (data) {
+        if (data->context) {
+            SDL_GL_DeleteContext(data->context);
+        }
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+#endif /* SDL_VIDEO_RENDER_OGL_ES */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/render/software/SDL_renderer_sw.c	Wed Feb 02 14:34:54 2011 -0800
@@ -0,0 +1,726 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "../SDL_sysrender.h"
+#include "../../video/SDL_pixels_c.h"
+#include "../../video/SDL_yuv_sw_c.h"
+
+
+/* SDL surface based renderer implementation */
+
+static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
+static void SW_WindowEvent(SDL_Renderer * renderer,
+                           const SDL_WindowEvent *event);
+static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int SW_QueryTexturePixels(SDL_Renderer * renderer,
+                                 SDL_Texture * texture, void **pixels,
+                                 int *pitch);
+static int SW_SetTextureColorMod(SDL_Renderer * renderer,
+                                 SDL_Texture * texture);
+static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
+                                 SDL_Texture * texture);
+static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
+                                  SDL_Texture * texture);
+static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                            const SDL_Rect * rect, const void *pixels,
+                            int pitch);
+static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                          const SDL_Rect * rect, int markDirty, void **pixels,
+                          int *pitch);
+static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static int SW_RenderDrawPoints(SDL_Renderer * renderer,
+                               const SDL_Point * points, int count);
+static int SW_RenderDrawLines(SDL_Renderer * renderer,
+                              const SDL_Point * points, int count);
+static int SW_RenderFillRects(SDL_Renderer * renderer,
+                              const SDL_Rect ** rects, int count);
+static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
+static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                               Uint32 format, void * pixels, int pitch);
+static int SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                                Uint32 format, const void * pixels, int pitch);
+static void SW_RenderPresent(SDL_Renderer * renderer);
+static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void SW_DestroyRenderer(SDL_Renderer * renderer);
+
+
+SDL_RenderDriver SW_RenderDriver = {
+    SW_CreateRenderer,
+    {
+     "software",
+     (SDL_RENDERER_PRESENTVSYNC),
+     13,
+     {
+      SDL_PIXELFORMAT_RGB555,
+      SDL_PIXELFORMAT_RGB565,
+      SDL_PIXELFORMAT_RGB888,
+      SDL_PIXELFORMAT_BGR888,
+      SDL_PIXELFORMAT_ARGB8888,
+      SDL_PIXELFORMAT_RGBA8888,
+      SDL_PIXELFORMAT_ABGR8888,
+      SDL_PIXELFORMAT_BGRA8888,
+      SDL_PIXELFORMAT_YV12,
+      SDL_PIXELFORMAT_IYUV,
+      SDL_PIXELFORMAT_YUY2,
+      SDL_PIXELFORMAT_UYVY,
+      SDL_PIXELFORMAT_YVYU},
+     0,
+     0}
+};
+
+typedef struct
+{
+    Uint32 format;
+    SDL_bool updateSize;
+    SDL_Texture *texture;
+    SDL_Surface surface;
+    SDL_Renderer *renderer;
+    SDL_DirtyRectList dirty;
+} SW_RenderData;
+
+static SDL_Texture *
+CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h)
+{
+    SDL_Texture *texture;
+
+    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
+    if (!texture) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    texture->format = format;
+    texture->access = SDL_TEXTUREACCESS_STREAMING;
+    texture->w = w;
+    texture->h = h;
+    texture->renderer = renderer;
+
+    if (renderer->CreateTexture(renderer, texture) < 0) {
+        SDL_free(texture);
+        return NULL;
+    }
+    return texture;
+}
+
+static void
+DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    renderer->DestroyTexture(renderer, texture);
+    SDL_free(texture);
+}
+
+SDL_Renderer *
+SW_CreateRenderer(SDL_Window * window, Uint32 flags)
+{
+    SDL_Renderer *renderer;
+    SW_RenderData *data;
+    int i;
+    Uint32 format;
+    int bpp;
+    Uint32 Rmask, Gmask, Bmask, Amask;
+    Uint32 renderer_flags;
+    const char *desired_driver;
+
+    format = SDL_GetWindowPixelFormat(window);
+    if (!SDL_PixelFormatEnumToMasks
+        (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+        SDL_SetError("Unknown display format");
+        return NULL;
+    }
+
+    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
+    if (!renderer) {
+        SDL_OutOfMemory();
+        return NULL;
+    }
+
+    data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
+    if (!data) {
+        SW_DestroyRenderer(renderer);
+        SDL_OutOfMemory();
+        return NULL;
+    }
+    renderer->WindowEvent = SW_WindowEvent;
+    renderer->CreateTexture = SW_CreateTexture;
+    renderer->QueryTexturePixels = SW_QueryTexturePixels;
+    renderer->SetTextureColorMod = SW_SetTextureColorMod;
+    renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
+    renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
+    renderer->UpdateTexture = SW_UpdateTexture;
+    renderer->LockTexture = SW_LockTexture;
+    renderer->UnlockTexture = SW_UnlockTexture;
+    renderer->DestroyTexture = SW_DestroyTexture;
+    renderer->RenderDrawPoints = SW_RenderDrawPoints;
+    renderer->RenderDrawLines = SW_RenderDrawLines;
+    renderer->RenderFillRects = SW_RenderFillRects;
+    renderer->RenderCopy = SW_RenderCopy;
+    renderer->RenderReadPixels = SW_RenderReadPixels;
+    renderer->RenderWritePixels = SW_RenderWritePixels;
+    renderer->RenderPresent = SW_RenderPresent;
+    renderer->DestroyRenderer = SW_DestroyRenderer;
+    renderer->info = SW_RenderDriver.info;
+    renderer->info.flags = 0;
+    renderer->window = window;
+    renderer->driverdata = data;
+
+    data->format = format;
+
+    /* Find a render driver that we can use to display data */
+    renderer_flags = 0;
+    if (flags & SDL_RENDERER_PRESENTVSYNC) {
+        renderer_flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+    desired_driver = SDL_getenv("SDL_VIDEO_RENDERER_SWDRIVER");
+    for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
+        SDL_RendererInfo info;
+        SDL_GetRenderDriverInfo(i, &info);
+        if (SDL_strcmp(info.name, SW_RenderDriver.info.name) == 0) {
+            continue;
+        }
+        if (desired_driver
+            && SDL_strcasecmp(desired_driver, info.name) != 0) {
+            continue;
+        }
+        data->renderer = SDL_CreateRenderer(window, i, renderer_flags);
+        if (data->renderer) {
+            break;
+        }
+    }
+    if (i == SDL_GetNumRenderDrivers()) {
+        SW_DestroyRenderer(renderer);
+        SDL_SetError("Couldn't find display render driver");
+        return NULL;
+    }
+    if (data->renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
+        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
+    }
+
+    /* Create the textures we'll use for display */
+    data->texture =
+        CreateTexture(data->renderer, data->format, window->w, window->h);
+    if (!data->texture) {
+        SW_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    /* Create a surface we'll use for rendering */
+    data->surface.flags = SDL_PREALLOC;
+    data->surface.format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
+    if (!data->surface.format) {
+        SW_DestroyRenderer(renderer);
+        return NULL;
+    }
+
+    return renderer;
+}
+
+static SDL_Texture *
+SW_ActivateRenderer(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (data->updateSize) {
+        /* Recreate the textures for the new window size */
+        if (data->texture) {
+            DestroyTexture(data->renderer, data->texture);
+        }
+        data->texture = CreateTexture(data->renderer, data->format,
+                                      window->w, window->h);
+        if (data->texture) {
+            data->updateSize = SDL_FALSE;
+        }
+    }
+    return data->texture;
+}
+
+static void
+SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+
+    if (event->event == SDL_WINDOWEVENT_RESIZED) {
+        data->updateSize = SDL_TRUE;
+    }
+}
+
+static int
+SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        texture->driverdata =
+            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
+    } else {
+        int bpp;
+        Uint32 Rmask, Gmask, Bmask, Amask;
+
+        if (!SDL_PixelFormatEnumToMasks
+            (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
+            SDL_SetError("Unknown texture format");
+            return -1;
+        }
+
+        texture->driverdata =
+            SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
+                                 Bmask, Amask);
+        SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
+                               texture->b);
+        SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
+        SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
+
+        if (texture->access == SDL_TEXTUREACCESS_STATIC) {
+            SDL_SetSurfaceRLE(texture->driverdata, 1);
+        }
+    }
+
+    if (!texture->driverdata) {
+        return -1;
+    }
+    return 0;
+}
+
+static int
+SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
+                      void **pixels, int *pitch)
+{
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *)
+                                            texture->driverdata, pixels,
+                                            pitch);
+    } else {
+        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+
+        *pixels = surface->pixels;
+        *pitch = surface->pitch;
+        return 0;
+    }
+}
+
+static int
+SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
+                                  texture->b);
+}
+
+static int
+SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceAlphaMod(surface, texture->a);
+}
+
+static int
+SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+    return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
+}
+
+static int
+SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+                 const SDL_Rect * rect, const void *pixels, int pitch)
+{
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *)
+                                       texture->driverdata, rect, pixels,
+                                       pitch);
+    } else {
+        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+        Uint8 *src, *dst;
+        int row;
+        size_t length;
+
+        src = (Uint8 *) pixels;
+        dst =
+            (Uint8 *) surface->pixels + rect->y * surface->pitch +
+            rect->x * surface->format->BytesPerPixel;
+        length = rect->w * surface->format->BytesPerPixel;
+        for (row = 0; row < rect->h; ++row) {
+            SDL_memcpy(dst, src, length);
+            src += pitch;
+            dst += surface->pitch;
+        }
+        return 0;
+    }
+}
+
+static int
+SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
+               const SDL_Rect * rect, int markDirty, void **pixels,
+               int *pitch)
+{
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *)
+                                     texture->driverdata, rect, markDirty,
+                                     pixels, pitch);
+    } else {
+        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+
+        *pixels =
+            (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
+                      rect->x * surface->format->BytesPerPixel);
+        *pitch = surface->pitch;
+        return 0;
+    }
+}
+
+static void
+SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
+    }
+}
+
+static int
+SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
+                    int count)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Texture *texture = SW_ActivateRenderer(renderer);
+    SDL_Rect rect;
+    int i;
+    int x, y;
+    int status = 0;
+
+    if (!texture) {
+        return -1;
+    }
+
+    /* Get the smallest rectangle that contains everything */
+    rect.x = 0;
+    rect.y = 0;
+    rect.w = texture->w;
+    rect.h = texture->h;
+    if (!SDL_EnclosePoints(points, count, &rect, &rect)) {
+        /* Nothing to draw */
+        return 0;
+    }
+
+    if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
+                                    &data->surface.pixels,
+                                    &data->surface.pitch) < 0) {
+        return -1;
+    }
+
+    data->surface.clip_rect.w = data->surface.w = rect.w;
+    data->surface.clip_rect.h = data->surface.h = rect.h;
+
+    /* Draw the points! */
+    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+        Uint32 color = SDL_MapRGBA(data->surface.format,
+                                   renderer->r, renderer->g, renderer->b,
+                                   renderer->a);
+
+        for (i = 0; i < count; ++i) {
+            x = points[i].x - rect.x;
+            y = points[i].y - rect.y;
+
+            status = SDL_DrawPoint(&data->surface, x, y, color);
+        }
+    } else {
+        for (i = 0; i < count; ++i) {
+            x = points[i].x - rect.x;
+            y = points[i].y - rect.y;
+
+            status = SDL_BlendPoint(&data->surface, x, y,
+                                    renderer->blendMode,
+                                    renderer->r, renderer->g, renderer->b,
+                                    renderer->a);
+        }
+    }
+
+    data->renderer->UnlockTexture(data->renderer, texture);
+
+    return status;
+}
+
+static int
+SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
+                   int count)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Texture *texture = SW_ActivateRenderer(renderer);
+    SDL_Rect clip, rect;
+    int i;
+    int x1, y1, x2, y2;
+    int status = 0;
+
+    if (!texture) {
+        return -1;
+    }
+
+    /* Get the smallest rectangle that contains everything */
+    clip.x = 0;
+    clip.y = 0;
+    clip.w = texture->w;
+    clip.h = texture->h;
+    SDL_EnclosePoints(points, count, NULL, &rect);
+    if (!SDL_IntersectRect(&rect, &clip, &rect)) {
+        /* Nothing to draw */
+        return 0;
+    }
+
+    if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
+                                    &data->surface.pixels,
+                                    &data->surface.pitch) < 0) {
+        return -1;
+    }
+
+    data->surface.clip_rect.w = data->surface.w = rect.w;
+    data->surface.clip_rect.h = data->surface.h = rect.h;
+
+    /* Draw the points! */
+    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+        Uint32 color = SDL_MapRGBA(data->surface.format,
+                                   renderer->r, renderer->g, renderer->b,
+                                   renderer->a);
+
+        for (i = 1; i < count; ++i) {
+            x1 = points[i-1].x - rect.x;
+            y1 = points[i-1].y - rect.y;
+            x2 = points[i].x - rect.x;
+            y2 = points[i].y - rect.y;
+
+            status = SDL_DrawLine(&data->surface, x1, y1, x2, y2, color);
+        }
+    } else {
+        for (i = 1; i < count; ++i) {
+            x1 = points[i-1].x - rect.x;
+            y1 = points[i-1].y - rect.y;
+            x2 = points[i].x - rect.x;
+            y2 = points[i].y - rect.y;
+
+            status = SDL_BlendLine(&data->surface, x1, y1, x2, y2,
+                                   renderer->blendMode,
+                                   renderer->r, renderer->g, renderer->b,
+                                   renderer->a);
+        }
+    }
+
+    data->renderer->UnlockTexture(data->renderer, texture);
+
+    return status;
+}
+
+static int
+SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
+                   int count)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Texture *texture = SW_ActivateRenderer(renderer);
+    SDL_Rect clip, rect;
+    Uint32 color = 0;
+    int i;
+    int status = 0;
+
+    if (!texture) {
+        return -1;
+    }
+
+    clip.x = 0;
+    clip.y = 0;
+    clip.w = texture->w;
+    clip.h = texture->h;
+
+    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+        color = SDL_MapRGBA(data->surface.format,
+                            renderer->r, renderer->g, renderer->b,
+                            renderer->a);
+    }
+
+    for (i = 0; i < count; ++i) {
+        if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
+            /* Nothing to draw */
+            continue;
+        }
+
+        if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
+                                        &data->surface.pixels,
+                                        &data->surface.pitch) < 0) {
+            return -1;
+        }
+
+        data->surface.clip_rect.w = data->surface.w = rect.w;
+        data->surface.clip_rect.h = data->surface.h = rect.h;
+
+        if (renderer->blendMode == SDL_BLENDMODE_NONE) {
+            status = SDL_FillRect(&data->surface, NULL, color);
+        } else {
+            status = SDL_BlendFillRect(&data->surface, NULL,
+                                       renderer->blendMode,
+                                       renderer->r, renderer->g, renderer->b,
+                                       renderer->a);
+        }
+
+        data->renderer->UnlockTexture(data->renderer, texture);
+    }
+    return status;
+}
+
+static int
+SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
+              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    int status;
+
+    if (!SW_ActivateRenderer(renderer)) {
+        return -1;
+    }
+
+    if (data->renderer->LockTexture(data->renderer, data->texture,
+                                    dstrect, 1, &data->surface.pixels,
+                                    &data->surface.pitch) < 0) {
+        return -1;
+    }
+
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        status =
+            SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
+                                srcrect, data->format, dstrect->w, dstrect->h,
+                                data->surface.pixels, data->surface.pitch);
+    } else {
+        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+        SDL_Rect real_srcrect = *srcrect;
+        SDL_Rect real_dstrect;
+
+        data->surface.w = dstrect->w;
+        data->surface.h = dstrect->h;
+        data->surface.clip_rect.w = dstrect->w;
+        data->surface.clip_rect.h = dstrect->h;
+        real_dstrect = data->surface.clip_rect;
+
+        status =
+            SDL_LowerBlit(surface, &real_srcrect, &data->surface,
+                          &real_dstrect);
+    }
+    data->renderer->UnlockTexture(data->renderer, data->texture);
+    return status;
+}
+
+static int
+SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                    Uint32 format, void * pixels, int pitch)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+
+    if (!SW_ActivateRenderer(renderer)) {
+        return -1;
+    }
+
+    if (data->renderer->LockTexture(data->renderer, data->texture,
+                                    rect, 0, &data->surface.pixels,
+                                    &data->surface.pitch) < 0) {
+        return -1;
+    }
+
+    SDL_ConvertPixels(rect->w, rect->h,
+                      data->format, data->surface.pixels, data->surface.pitch,
+                      format, pixels, pitch);
+
+    data->renderer->UnlockTexture(data->renderer, data->texture);
+    return 0;
+}
+
+static int
+SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
+                     Uint32 format, const void * pixels, int pitch)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+
+    if (!SW_ActivateRenderer(renderer)) {
+        return -1;
+    }
+
+    if (data->renderer->LockTexture(data->renderer, data->texture,
+                                    rect, 1, &data->surface.pixels,
+                                    &data->surface.pitch) < 0) {
+        return -1;
+    }
+
+    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
+                      data->format, data->surface.pixels, data->surface.pitch);
+
+    data->renderer->UnlockTexture(data->renderer, data->texture);
+    return 0;
+}
+
+static void
+SW_RenderPresent(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Texture *texture = SW_ActivateRenderer(renderer);
+    SDL_Rect rect;
+
+    if (!texture) {
+        return;
+    }
+
+    /* Send the data to the display */
+    rect.x = 0;
+    rect.y = 0;
+    rect.w = texture->w;
+    rect.h = texture->h;
+    data->renderer->RenderCopy(data->renderer, texture, &rect, &rect);
+    data->renderer->RenderPresent(data->renderer);
+}
+
+static void
+SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
+{
+    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
+        SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
+    } else {
+        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+
+        SDL_FreeSurface(surface);
+    }
+}
+
+static void
+SW_DestroyRenderer(SDL_Renderer * renderer)
+{
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Window *window = renderer->window;
+
+    if (data) {
+        if (data->texture) {
+            DestroyTexture(data->renderer, data->texture);
+        }
+        if (data->surface.format) {
+            SDL_FreeFormat(data->surface.format);
+        }
+        if (data->renderer) {
+            data->renderer->DestroyRenderer(data->renderer);
+        }
+        SDL_FreeDirtyRects(&data->dirty);
+        SDL_free(data);
+    }
+    SDL_free(renderer);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_pixels_c.h	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/SDL_pixels_c.h	Wed Feb 02 14:34:54 2011 -0800
@@ -47,4 +47,5 @@
 extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b);
 extern void SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors,
                            SDL_Color * output, int ncolors);
+
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_rect.c	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/SDL_rect.c	Wed Feb 02 14:34:54 2011 -0800
@@ -21,8 +21,7 @@
 */
 #include "SDL_config.h"
 
-#include "SDL_video.h"
-#include "SDL_rect_c.h"
+#include "SDL_rect.h"
 
 SDL_bool
 SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
--- a/src/video/SDL_rect_c.h	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-typedef struct SDL_DirtyRect
-{
-    SDL_Rect rect;
-    struct SDL_DirtyRect *next;
-} SDL_DirtyRect;
-
-typedef struct SDL_DirtyRectList
-{
-    SDL_DirtyRect *list;
-    SDL_DirtyRect *free;
-} SDL_DirtyRectList;
-
-extern void SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect);
-extern void SDL_ClearDirtyRects(SDL_DirtyRectList * list);
-extern void SDL_FreeDirtyRects(SDL_DirtyRectList * list);
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gl.c	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1285 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_OGL
-
-#include "SDL_video.h"
-#include "SDL_opengl.h"
-#include "SDL_sysvideo.h"
-#include "SDL_pixels_c.h"
-#include "SDL_rect_c.h"
-#include "SDL_yuv_sw_c.h"
-
-#ifdef __MACOSX__
-#include <OpenGL/OpenGL.h>
-#endif
-
-
-/* OpenGL renderer implementation */
-
-/* Details on optimizing the texture path on Mac OS X:
-   http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/chapter_10_section_2.html
-*/
-
-/* !!! FIXME: this should go in a higher level than the GL renderer. */
-static __inline__ int
-bytes_per_pixel(const Uint32 format)
-{
-    if (!SDL_ISPIXELFORMAT_FOURCC(format)) {
-        return SDL_BYTESPERPIXEL(format);
-    }
-
-    /* FOURCC format */
-    switch (format) {
-    case SDL_PIXELFORMAT_YV12:
-    case SDL_PIXELFORMAT_IYUV:
-    case SDL_PIXELFORMAT_YUY2:
-    case SDL_PIXELFORMAT_UYVY:
-    case SDL_PIXELFORMAT_YVYU:
-        return 2;
-    default:
-        return 1;               /* shouldn't ever hit this. */
-    }
-}
-
-
-static const float inv255f = 1.0f / 255.0f;
-
-static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
-static void GL_WindowEvent(SDL_Renderer * renderer,
-                           const SDL_WindowEvent *event);
-static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int GL_QueryTexturePixels(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, void **pixels,
-                                 int *pitch);
-static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * rect, const void *pixels,
-                            int pitch);
-static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, int markDirty, void **pixels,
-                          int *pitch);
-static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            int numrects, const SDL_Rect * rects);
-static int GL_RenderClear(SDL_Renderer * renderer);
-static int GL_RenderDrawPoints(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int GL_RenderDrawLines(SDL_Renderer * renderer,
-                              const SDL_Point * points, int count);
-static int GL_RenderFillRects(SDL_Renderer * renderer,
-                              const SDL_Rect ** rects, int count);
-static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                               Uint32 pixel_format, void * pixels, int pitch);
-static int GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 pixel_format, const void * pixels, int pitch);
-static void GL_RenderPresent(SDL_Renderer * renderer);
-static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void GL_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver GL_RenderDriver = {
-    GL_CreateRenderer,
-    {
-     "opengl",
-     (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
-     13,
-     {
-      SDL_PIXELFORMAT_RGB332,
-      SDL_PIXELFORMAT_RGB444,
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_ARGB4444,
-      SDL_PIXELFORMAT_ARGB1555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB24,
-      SDL_PIXELFORMAT_BGR24,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_ABGR8888,
-      SDL_PIXELFORMAT_ARGB2101010},
-     0,
-     0}
-};
-
-typedef struct
-{
-    SDL_GLContext context;
-    SDL_bool updateSize;
-    SDL_bool GL_ARB_texture_rectangle_supported;
-    SDL_bool GL_EXT_paletted_texture_supported;
-    SDL_bool GL_APPLE_ycbcr_422_supported;
-    SDL_bool GL_MESA_ycbcr_texture_supported;
-    SDL_bool GL_ARB_fragment_program_supported;
-    int blendMode;
-
-    /* OpenGL functions */
-#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
-#include "SDL_glfuncs.h"
-#undef SDL_PROC
-
-    void (*glTextureRangeAPPLE) (GLenum target, GLsizei length,
-                                 const GLvoid * pointer);
-
-    PFNGLGETPROGRAMIVARBPROC glGetProgramivARB;
-    PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB;
-    PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB;
-    PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
-    PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
-    PFNGLBINDPROGRAMARBPROC glBindProgramARB;
-    PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
-
-    /* (optional) fragment programs */
-    GLuint fragment_program_UYVY;
-} GL_RenderData;
-
-typedef struct
-{
-    GLuint texture;
-    GLuint shader;
-    GLenum type;
-    GLfloat texw;
-    GLfloat texh;
-    GLenum format;
-    GLenum formattype;
-    Uint8 *palette;
-    void *pixels;
-    int pitch;
-    SDL_DirtyRectList dirty;
-    int HACK_RYAN_FIXME;
-} GL_TextureData;
-
-
-static void
-GL_SetError(const char *prefix, GLenum result)
-{
-    const char *error;
-
-    switch (result) {
-    case GL_NO_ERROR:
-        error = "GL_NO_ERROR";
-        break;
-    case GL_INVALID_ENUM:
-        error = "GL_INVALID_ENUM";
-        break;
-    case GL_INVALID_VALUE:
-        error = "GL_INVALID_VALUE";
-        break;
-    case GL_INVALID_OPERATION:
-        error = "GL_INVALID_OPERATION";
-        break;
-    case GL_STACK_OVERFLOW:
-        error = "GL_STACK_OVERFLOW";
-        break;
-    case GL_STACK_UNDERFLOW:
-        error = "GL_STACK_UNDERFLOW";
-        break;
-    case GL_OUT_OF_MEMORY:
-        error = "GL_OUT_OF_MEMORY";
-        break;
-    case GL_TABLE_TOO_LARGE:
-        error = "GL_TABLE_TOO_LARGE";
-        break;
-    default:
-        error = "UNKNOWN";
-        break;
-    }
-    SDL_SetError("%s: %s", prefix, error);
-}
-
-static int
-GL_LoadFunctions(GL_RenderData * data)
-{
-#ifdef __SDL_NOGETPROCADDR__
-#define SDL_PROC(ret,func,params) data->func=func;
-#else
-#define SDL_PROC(ret,func,params) \
-    do { \
-        data->func = SDL_GL_GetProcAddress(#func); \
-        if ( ! data->func ) { \
-            SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
-            return -1; \
-        } \
-    } while ( 0 );
-#endif /* __SDL_NOGETPROCADDR__ */
-
-#include "SDL_glfuncs.h"
-#undef SDL_PROC
-    return 0;
-}
-
-SDL_Renderer *
-GL_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_Renderer *renderer;
-    GL_RenderData *data;
-    GLint value;
-
-    /* Render directly to the window, unless we're compositing */
-#ifndef __MACOSX__
-    if (flags & SDL_RENDERER_SINGLEBUFFER) {
-        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
-    }
-#endif
-    if (!(window->flags & SDL_WINDOW_OPENGL)) {
-        if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
-            return NULL;
-        }
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        GL_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    renderer->WindowEvent = GL_WindowEvent;
-    renderer->CreateTexture = GL_CreateTexture;
-    renderer->QueryTexturePixels = GL_QueryTexturePixels;
-    renderer->UpdateTexture = GL_UpdateTexture;
-    renderer->LockTexture = GL_LockTexture;
-    renderer->UnlockTexture = GL_UnlockTexture;
-    renderer->DirtyTexture = GL_DirtyTexture;
-    renderer->RenderClear = GL_RenderClear;
-    renderer->RenderDrawPoints = GL_RenderDrawPoints;
-    renderer->RenderDrawLines = GL_RenderDrawLines;
-    renderer->RenderFillRects = GL_RenderFillRects;
-    renderer->RenderCopy = GL_RenderCopy;
-    renderer->RenderReadPixels = GL_RenderReadPixels;
-    renderer->RenderWritePixels = GL_RenderWritePixels;
-    renderer->RenderPresent = GL_RenderPresent;
-    renderer->DestroyTexture = GL_DestroyTexture;
-    renderer->DestroyRenderer = GL_DestroyRenderer;
-    renderer->info = GL_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
-
-    if (GL_LoadFunctions(data) < 0) {
-        GL_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    data->context = SDL_GL_CreateContext(window);
-    if (!data->context) {
-        GL_DestroyRenderer(renderer);
-        return NULL;
-    }
-    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-        GL_DestroyRenderer(renderer);
-        return NULL;
-    }
-#ifdef __MACOSX__
-    /* Enable multi-threaded rendering */
-    /* Disabled until Ryan finishes his VBO/PBO code...
-       CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine);
-     */
-#endif
-
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        SDL_GL_SetSwapInterval(1);
-    } else {
-        SDL_GL_SetSwapInterval(0);
-    }
-    if (SDL_GL_GetSwapInterval() > 0) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_width = value;
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_height = value;
-
-    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
-        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
-        data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
-    }
-    if (SDL_GL_ExtensionSupported("GL_APPLE_ycbcr_422")) {
-        data->GL_APPLE_ycbcr_422_supported = SDL_TRUE;
-    }
-    if (SDL_GL_ExtensionSupported("GL_MESA_ycbcr_texture")) {
-        data->GL_MESA_ycbcr_texture_supported = SDL_TRUE;
-    }
-    if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) {
-        data->glTextureRangeAPPLE =
-            (void (*)(GLenum, GLsizei, const GLvoid *))
-            SDL_GL_GetProcAddress("glTextureRangeAPPLE");
-    }
-
-    /* we might use fragment programs for YUV data, etc. */
-    if (SDL_GL_ExtensionSupported("GL_ARB_fragment_program")) {
-        /* !!! FIXME: this doesn't check for errors. */
-        /* !!! FIXME: this should really reuse the glfuncs.h stuff. */
-        data->glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)
-            SDL_GL_GetProcAddress("glGetProgramivARB");
-        data->glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)
-            SDL_GL_GetProcAddress("glGetProgramStringARB");
-        data->glProgramLocalParameter4fvARB =
-            (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)
-            SDL_GL_GetProcAddress("glProgramLocalParameter4fvARB");
-        data->glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)
-            SDL_GL_GetProcAddress("glDeleteProgramsARB");
-        data->glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)
-            SDL_GL_GetProcAddress("glGenProgramsARB");
-        data->glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)
-            SDL_GL_GetProcAddress("glBindProgramARB");
-        data->glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)
-            SDL_GL_GetProcAddress("glProgramStringARB");
-        data->GL_ARB_fragment_program_supported = SDL_TRUE;
-    }
-
-    /* Set up parameters for rendering */
-    data->blendMode = -1;
-    data->glDisable(GL_DEPTH_TEST);
-    data->glDisable(GL_CULL_FACE);
-    /* This ended up causing video discrepancies between OpenGL and Direct3D */
-    /*data->glEnable(GL_LINE_SMOOTH);*/
-    if (data->GL_ARB_texture_rectangle_supported) {
-        data->glEnable(GL_TEXTURE_RECTANGLE_ARB);
-    } else {
-        data->glEnable(GL_TEXTURE_2D);
-    }
-    data->updateSize = SDL_TRUE;
-
-    return renderer;
-}
-
-static SDL_GLContext SDL_CurrentContext = NULL;
-
-static int
-GL_ActivateRenderer(SDL_Renderer * renderer)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-
-    if (SDL_CurrentContext != data->context) {
-        if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-            return -1;
-        }
-        SDL_CurrentContext = data->context;
-    }
-    if (data->updateSize) {
-        data->glMatrixMode(GL_PROJECTION);
-        data->glLoadIdentity();
-        data->glMatrixMode(GL_MODELVIEW);
-        data->glLoadIdentity();
-        data->glViewport(0, 0, window->w, window->h);
-        data->glOrtho(0.0, (GLdouble) window->w,
-                      (GLdouble) window->h, 0.0, 0.0, 1.0);
-        data->updateSize = SDL_FALSE;
-    }
-    return 0;
-}
-
-static void
-GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-
-    if (event->event == SDL_WINDOWEVENT_RESIZED) {
-        /* Rebind the context to the window area and update matrices */
-        SDL_CurrentContext = NULL;
-        data->updateSize = SDL_TRUE;
-    }
-}
-
-static __inline__ int
-power_of_2(int input)
-{
-    int value = 1;
-
-    while (value < input) {
-        value <<= 1;
-    }
-    return value;
-}
-
-
-//#define DEBUG_PROGRAM_COMPILE 1
-
-static void
-set_shader_error(GL_RenderData * data, const char *prefix)
-{
-    GLint pos = 0;
-    const GLubyte *errstr;
-    data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
-    errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB);
-    SDL_SetError("%s: shader compile error at position %d: %s",
-           prefix, (int) pos, (const char *) errstr);
-}
-
-static GLuint
-compile_shader(GL_RenderData * data, GLenum shader_type, const char *_code)
-{
-    const int have_texture_rects = data->GL_ARB_texture_rectangle_supported;
-    const char *replacement = have_texture_rects ? "RECT" : "2D";
-    const size_t replacementlen = SDL_strlen(replacement);
-    const char *token = "%TEXTURETARGET%";
-    const size_t tokenlen = SDL_strlen(token);
-    char *code = NULL;
-    char *ptr = NULL;
-    GLuint program = 0;
-
-    /*
-     * The TEX instruction needs a different target depending on what we use.
-     *  To handle this, we use "%TEXTURETARGET%" and replace the string before
-     *  compiling the shader.
-     */
-    code = SDL_strdup(_code);
-    if (code == NULL)
-        return 0;
-
-    for (ptr = SDL_strstr(code, token); ptr; ptr = SDL_strstr(ptr + 1, token)) {
-        SDL_memcpy(ptr, replacement, replacementlen);
-        SDL_memmove(ptr + replacementlen, ptr + tokenlen,
-                    SDL_strlen(ptr + tokenlen) + 1);
-    }
-
-#if DEBUG_PROGRAM_COMPILE
-    printf("compiling shader:\n%s\n\n", code);
-#endif
-
-    data->glGetError();         /* flush any existing error state. */
-    data->glGenProgramsARB(1, &program);
-    data->glBindProgramARB(shader_type, program);
-    data->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB,
-                             (GLsizei)SDL_strlen(code), code);
-
-    SDL_free(code);
-
-    if (data->glGetError() == GL_INVALID_OPERATION) {
-#if DEBUG_PROGRAM_COMPILE
-        GLint pos = 0;
-        const GLubyte *errstr;
-        data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
-        errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB);
-        printf("program compile error at position %d: %s\n\n",
-               (int) pos, (const char *) errstr);
-#endif
-        data->glBindProgramARB(shader_type, 0);
-        data->glDeleteProgramsARB(1, &program);
-        return 0;
-    }
-
-    return program;
-}
-
-
-/*
- * Fragment program that renders from UYVY textures.
- * The UYVY to RGB equasion is:
- *   R = 1.164(Y-16) + 1.596(Cr-128)
- *   G = 1.164(Y-16) - 0.813(Cr-128) - 0.391(Cb-128)
- *   B = 1.164(Y-16) + 2.018(Cb-128)
- * Byte layout is Cb, Y1, Cr, Y2, stored in the R, G, B, A channels.
- * 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr
- *
- * !!! FIXME: this ignores blendmodes, etc.
- * !!! FIXME: this could be more efficient...use a dot product for green, etc.
- */
-static const char *fragment_program_UYVY_source_code = "!!ARBfp1.0\n"
-    /* outputs... */
-    "OUTPUT outcolor = result.color;\n"
-    /* scratch registers... */
-    "TEMP uyvy;\n" "TEMP luminance;\n" "TEMP work;\n"
-    /* Halve the coordinates to grab the correct 32 bits for the fragment. */
-    "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n"
-    /* Sample the YUV texture. Cb, Y1, Cr, Y2, are stored in x, y, z, w. */
-    "TEX uyvy, work, texture[0], %TEXTURETARGET%;\n"
-    /* Do subtractions (128/255, 16/255, 128/255, 16/255) */
-    "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n"
-    /* Choose the luminance component by texcoord. */
-    /* !!! FIXME: laziness wins out for now... just average Y1 and Y2. */
-    "ADD luminance, uyvy.yyyy, uyvy.wwww;\n"
-    "MUL luminance, luminance, { 0.5, 0.5, 0.5, 0.5 };\n"
-    /* Multiply luminance by its magic value. */
-    "MUL luminance, luminance, { 1.164, 1.164, 1.164, 1.164 };\n"
-    /* uyvy.xyzw becomes Cr/Cr/Cb/Cb, with multiplications. */
-    "MUL uyvy, uyvy.zzxx, { 1.596, -0.813, 2.018, -0.391 };\n"
-    /* Add luminance to Cr and Cb, store to RGB channels. */
-    "ADD work.rgb, luminance, uyvy;\n"
-    /* Do final addition for Green channel.  (!!! FIXME: this should be a DPH?) */
-    "ADD work.g, work.g, uyvy.w;\n"
-    /* Make sure alpha channel is fully opaque.  (!!! FIXME: blend modes!) */
-    "MOV work.a, { 1.0 };\n"
-    /* Store out the final fragment color... */
-    "MOV outcolor, work;\n"
-    /* ...and we're done! */
-    "END\n";
-
-static __inline__ SDL_bool
-convert_format(GL_RenderData *renderdata, Uint32 pixel_format,
-               GLint* internalFormat, GLenum* format, GLenum* type)
-{
-    switch (pixel_format) {
-    case SDL_PIXELFORMAT_RGB332:
-        *internalFormat = GL_R3_G3_B2;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_BYTE_3_3_2;
-        break;
-    case SDL_PIXELFORMAT_RGB444:
-        *internalFormat = GL_RGB4;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_SHORT_4_4_4_4;
-        break;
-    case SDL_PIXELFORMAT_RGB555:
-        *internalFormat = GL_RGB5;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_SHORT_5_5_5_1;
-        break;
-    case SDL_PIXELFORMAT_ARGB4444:
-        *internalFormat = GL_RGBA4;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
-        break;
-    case SDL_PIXELFORMAT_ARGB1555:
-        *internalFormat = GL_RGB5_A1;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-        break;
-    case SDL_PIXELFORMAT_RGB565:
-        *internalFormat = GL_RGB8;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_SHORT_5_6_5;
-        break;
-    case SDL_PIXELFORMAT_RGB24:
-        *internalFormat = GL_RGB8;
-        *format = GL_RGB;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_RGB888:
-        *internalFormat = GL_RGB8;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_BGR24:
-        *internalFormat = GL_RGB8;
-        *format = GL_BGR;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_BGR888:
-        *internalFormat = GL_RGB8;
-        *format = GL_RGBA;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_ARGB8888:
-#ifdef __MACOSX__
-        *internalFormat = GL_RGBA;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_INT_8_8_8_8_REV;
-#else
-        *internalFormat = GL_RGBA8;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_BYTE;
-#endif
-        break;
-    case SDL_PIXELFORMAT_ABGR8888:
-        *internalFormat = GL_RGBA8;
-        *format = GL_RGBA;
-        *type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_ARGB2101010:
-        *internalFormat = GL_RGB10_A2;
-        *format = GL_BGRA;
-        *type = GL_UNSIGNED_INT_2_10_10_10_REV;
-        break;
-    case SDL_PIXELFORMAT_UYVY:
-        if (renderdata->GL_APPLE_ycbcr_422_supported) {
-            *internalFormat = GL_RGB;
-            *format = GL_YCBCR_422_APPLE;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_APPLE;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
-#endif
-        } else if (renderdata->GL_MESA_ycbcr_texture_supported) {
-            *internalFormat = GL_YCBCR_MESA;
-            *format = GL_YCBCR_MESA;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_MESA;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_REV_MESA;
-#endif
-        } else if (renderdata->GL_ARB_fragment_program_supported) {
-            *internalFormat = GL_RGBA;
-            *format = GL_RGBA;
-            *type = GL_UNSIGNED_BYTE;
-        } else {
-            return SDL_FALSE;
-        }
-        break;
-    case SDL_PIXELFORMAT_YUY2:
-        if (renderdata->GL_APPLE_ycbcr_422_supported) {
-            *internalFormat = GL_RGB;
-            *format = GL_YCBCR_422_APPLE;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_APPLE;
-#endif
-        } else if (renderdata->GL_MESA_ycbcr_texture_supported) {
-            *internalFormat = GL_YCBCR_MESA;
-            *format = GL_YCBCR_MESA;
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-            *type = GL_UNSIGNED_SHORT_8_8_REV_MESA;
-#else
-            *type = GL_UNSIGNED_SHORT_8_8_MESA;
-#endif
-        } else {
-            return SDL_FALSE;
-        }
-        break;
-    default:
-        return SDL_FALSE;
-    }
-    return SDL_TRUE;
-}
-
-static int
-GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *data;
-    GLint internalFormat;
-    GLenum format, type;
-    int texture_w, texture_h;
-    GLuint shader = 0;
-    GLenum result;
-
-    GL_ActivateRenderer(renderer);
-
-    if (!convert_format(renderdata, texture->format, &internalFormat,
-                        &format, &type)) {
-        SDL_SetError("Texture format %s not supported by OpenGL",
-                     SDL_GetPixelFormatName(texture->format));
-        return -1;
-    }
-    if (texture->format == SDL_PIXELFORMAT_UYVY &&
-        !renderdata->GL_APPLE_ycbcr_422_supported &&
-        !renderdata->GL_MESA_ycbcr_texture_supported &&
-        renderdata->GL_ARB_fragment_program_supported) {
-        if (renderdata->fragment_program_UYVY == 0) {
-            renderdata->fragment_program_UYVY =
-                compile_shader(renderdata, GL_FRAGMENT_PROGRAM_ARB,
-                               fragment_program_UYVY_source_code);
-            if (renderdata->fragment_program_UYVY == 0) {
-                set_shader_error(renderdata, "UYVY");
-                return -1;
-            }
-        }
-        shader = renderdata->fragment_program_UYVY;
-    }
-
-    data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    data->shader = shader;
-
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
-        data->pitch = texture->w * bytes_per_pixel(texture->format);
-        data->pixels = SDL_malloc(texture->h * data->pitch);
-        if (!data->pixels) {
-            SDL_OutOfMemory();
-            SDL_free(data);
-            return -1;
-        }
-    }
-
-    texture->driverdata = data;
-
-    renderdata->glGetError();
-    renderdata->glGenTextures(1, &data->texture);
-    if (renderdata->GL_ARB_texture_rectangle_supported) {
-        data->type = GL_TEXTURE_RECTANGLE_ARB;
-        texture_w = texture->w;
-        texture_h = texture->h;
-        data->texw = (GLfloat) texture_w;
-        data->texh = (GLfloat) texture_h;
-    } else {
-        data->type = GL_TEXTURE_2D;
-        texture_w = power_of_2(texture->w);
-        texture_h = power_of_2(texture->h);
-        data->texw = (GLfloat) (texture->w) / texture_w;
-        data->texh = (GLfloat) texture->h / texture_h;
-    }
-
-    /* YUV formats use RGBA but are really two bytes per pixel */
-    if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) {
-        texture_w /= 2;
-        if (data->type == GL_TEXTURE_2D) {
-            data->texw *= 2.0f;
-        }
-        data->HACK_RYAN_FIXME = 2;
-    } else {
-        data->HACK_RYAN_FIXME = 1;
-    }
-
-    data->format = format;
-    data->formattype = type;
-    renderdata->glEnable(data->type);
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
-                                GL_LINEAR);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
-                                GL_LINEAR);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
-                                GL_CLAMP_TO_EDGE);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
-                                GL_CLAMP_TO_EDGE);
-#ifdef __MACOSX__
-#ifndef GL_TEXTURE_STORAGE_HINT_APPLE
-#define GL_TEXTURE_STORAGE_HINT_APPLE       0x85BC
-#endif
-#ifndef STORAGE_CACHED_APPLE
-#define STORAGE_CACHED_APPLE                0x85BE
-#endif
-#ifndef STORAGE_SHARED_APPLE
-#define STORAGE_SHARED_APPLE                0x85BF
-#endif
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
-        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
-                                    GL_STORAGE_SHARED_APPLE);
-    } else {
-        renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
-                                    GL_STORAGE_CACHED_APPLE);
-    }
-/* This causes a crash in testoverlay for some reason.  Apple bug? */
-#if 0
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING
-        && texture->format == SDL_PIXELFORMAT_ARGB8888) {
-        /*
-           if (renderdata->glTextureRangeAPPLE) {
-           renderdata->glTextureRangeAPPLE(data->type,
-           texture->h * data->pitch,
-           data->pixels);
-           }
-         */
-        renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
-        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
-                                 texture_h, 0, format, type, data->pixels);
-    } else
-#endif
-#endif
-    {
-        renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
-                                 texture_h, 0, format, type, NULL);
-    }
-    renderdata->glDisable(data->type);
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GL_SetError("glTexImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GL_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                      void **pixels, int *pitch)
-{
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-
-    *pixels = data->pixels;
-    *pitch = data->pitch;
-    return 0;
-}
-
-static void
-SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture,
-                   int pitch)
-{
-    renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
-                              (pitch / bytes_per_pixel(texture->format)) /
-                              ((GL_TextureData *) texture->driverdata)->
-                              HACK_RYAN_FIXME);
-}
-
-static int
-GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-    GLenum result;
-
-    GL_ActivateRenderer(renderer);
-
-    renderdata->glGetError();
-    SetupTextureUpdate(renderdata, texture, pitch);
-    renderdata->glEnable(data->type);
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
-                                rect->h, data->format, data->formattype,
-                                pixels);
-    renderdata->glDisable(data->type);
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GL_SetError("glTexSubImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * rect, int markDirty, void **pixels,
-               int *pitch)
-{
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-
-    if (markDirty) {
-        SDL_AddDirtyRect(&data->dirty, rect);
-    }
-
-    *pixels =
-        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
-                  rect->x * bytes_per_pixel(texture->format));
-    *pitch = data->pitch;
-    return 0;
-}
-
-static void
-GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static void
-GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
-                const SDL_Rect * rects)
-{
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-    int i;
-
-    for (i = 0; i < numrects; ++i) {
-        SDL_AddDirtyRect(&data->dirty, &rects[i]);
-    }
-}
-
-static void
-GL_SetBlendMode(GL_RenderData * data, int blendMode)
-{
-    if (blendMode != data->blendMode) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_NONE:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-            data->glDisable(GL_BLEND);
-            break;
-        case SDL_BLENDMODE_BLEND:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-            break;
-        case SDL_BLENDMODE_ADD:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-            break;
-        }
-        data->blendMode = blendMode;
-    }
-}
-
-static int
-GL_RenderClear(SDL_Renderer * renderer)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-
-    GL_ActivateRenderer(renderer);
-
-    data->glClearColor((GLfloat) renderer->r * inv255f,
-                       (GLfloat) renderer->g * inv255f,
-                       (GLfloat) renderer->b * inv255f,
-                       (GLfloat) renderer->a * inv255f);
-
-    data->glClear(GL_COLOR_BUFFER_BIT);
-
-    return 0;
-}
-
-static int
-GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    int i;
-
-    GL_ActivateRenderer(renderer);
-
-    GL_SetBlendMode(data, renderer->blendMode);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    data->glBegin(GL_POINTS);
-    for (i = 0; i < count; ++i) {
-        data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
-    }
-    data->glEnd();
-
-    return 0;
-}
-
-static int
-GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                   int count)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    int i;
-
-    GL_ActivateRenderer(renderer);
-
-    GL_SetBlendMode(data, renderer->blendMode);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    if (count > 2 && 
-        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
-        data->glBegin(GL_LINE_LOOP);
-        /* GL_LINE_LOOP takes care of the final segment */
-        --count;
-        for (i = 0; i < count; ++i) {
-            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
-        }
-        data->glEnd();
-    } else {
-#if defined(__APPLE__) || defined(__WIN32__)
-#else
-        int x1, y1, x2, y2;
-#endif
-
-        data->glBegin(GL_LINE_STRIP);
-        for (i = 0; i < count; ++i) {
-            data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
-        }
-        data->glEnd();
-
-        /* The line is half open, so we need one more point to complete it.
-         * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
-         * If we have to, we can use vertical line and horizontal line textures
-         * for vertical and horizontal lines, and then create custom textures
-         * for diagonal lines and software render those.  It's terrible, but at
-         * least it would be pixel perfect.
-         */
-        data->glBegin(GL_POINTS);
-#if defined(__APPLE__) || defined(__WIN32__)
-        /* Mac OS X and Windows seem to always leave the second point open */
-        data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y);
-#else
-        /* Linux seems to leave the right-most or bottom-most point open */
-        x1 = points[0].x;
-        y1 = points[0].y;
-        x2 = points[count-1].x;
-        y2 = points[count-1].y;
-
-        if (x1 > x2) {
-            data->glVertex2f(0.5f + x1, 0.5f + y1);
-        } else if (x2 > x1) {
-            data->glVertex2f(0.5f + x2, 0.5f + y2);
-        } else if (y1 > y2) {
-            data->glVertex2f(0.5f + x1, 0.5f + y1);
-        } else if (y2 > y1) {
-            data->glVertex2f(0.5f + x2, 0.5f + y2);
-        }
-#endif
-        data->glEnd();
-    }
-
-    return 0;
-}
-
-static int
-GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    int i;
-
-    GL_ActivateRenderer(renderer);
-
-    GL_SetBlendMode(data, renderer->blendMode);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
-    }
-
-    return 0;
-}
-
-static int
-GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
-    int minx, miny, maxx, maxy;
-    GLfloat minu, maxu, minv, maxv;
-
-    GL_ActivateRenderer(renderer);
-
-    if (texturedata->dirty.list) {
-        SDL_DirtyRect *dirty;
-        void *pixels;
-        int bpp = bytes_per_pixel(texture->format);
-        int pitch = texturedata->pitch;
-
-        SetupTextureUpdate(data, texture, pitch);
-        data->glEnable(texturedata->type);
-        data->glBindTexture(texturedata->type, texturedata->texture);
-        for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
-            SDL_Rect *rect = &dirty->rect;
-            pixels =
-                (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
-                          rect->x * bpp);
-            data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
-                                  rect->w / texturedata->HACK_RYAN_FIXME,
-                                  rect->h, texturedata->format,
-                                  texturedata->formattype, pixels);
-        }
-        SDL_ClearDirtyRects(&texturedata->dirty);
-    }
-
-    minx = dstrect->x;
-    miny = dstrect->y;
-    maxx = dstrect->x + dstrect->w;
-    maxy = dstrect->y + dstrect->h;
-
-    minu = (GLfloat) srcrect->x / texture->w;
-    minu *= texturedata->texw;
-    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
-    maxu *= texturedata->texw;
-    minv = (GLfloat) srcrect->y / texture->h;
-    minv *= texturedata->texh;
-    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
-    maxv *= texturedata->texh;
-
-    data->glEnable(texturedata->type);
-    data->glBindTexture(texturedata->type, texturedata->texture);
-
-    if (texture->modMode) {
-        data->glColor4f((GLfloat) texture->r * inv255f,
-                        (GLfloat) texture->g * inv255f,
-                        (GLfloat) texture->b * inv255f,
-                        (GLfloat) texture->a * inv255f);
-    } else {
-        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-    }
-
-    GL_SetBlendMode(data, texture->blendMode);
-
-    /* Set up the shader for the copy, if any */
-    if (texturedata->shader) {
-        data->glEnable(GL_FRAGMENT_PROGRAM_ARB);
-        data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, texturedata->shader);
-    }
-
-    data->glBegin(GL_TRIANGLE_STRIP);
-    data->glTexCoord2f(minu, minv);
-    data->glVertex2f((GLfloat) minx, (GLfloat) miny);
-    data->glTexCoord2f(maxu, minv);
-    data->glVertex2f((GLfloat) maxx, (GLfloat) miny);
-    data->glTexCoord2f(minu, maxv);
-    data->glVertex2f((GLfloat) minx, (GLfloat) maxy);
-    data->glTexCoord2f(maxu, maxv);
-    data->glVertex2f((GLfloat) maxx, (GLfloat) maxy);
-    data->glEnd();
-
-    if (texturedata->shader) {
-        data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
-    }
-
-    data->glDisable(texturedata->type);
-
-    return 0;
-}
-
-static int
-GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                    Uint32 pixel_format, void * pixels, int pitch)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    GLint internalFormat;
-    GLenum format, type;
-    Uint8 *src, *dst, *tmp;
-    int length, rows;
-
-    GL_ActivateRenderer(renderer);
-
-    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
-        /* FIXME: Do a temp copy to a format that is supported */
-        SDL_SetError("Unsupported pixel format");
-        return -1;
-    }
-
-    data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
-    data->glPixelStorei(GL_PACK_ROW_LENGTH,
-                        (pitch / bytes_per_pixel(pixel_format)));
-
-    data->glReadPixels(rect->x, (window->h-rect->y)-rect->h, rect->w, rect->h,
-                       format, type, pixels);
-
-    /* Flip the rows to be top-down */
-    length = rect->w * bytes_per_pixel(pixel_format);
-    src = (Uint8*)pixels + (rect->h-1)*pitch;
-    dst = (Uint8*)pixels;
-    tmp = SDL_stack_alloc(Uint8, length);
-    rows = rect->h / 2;
-    while (rows--) {
-        SDL_memcpy(tmp, dst, length);
-        SDL_memcpy(dst, src, length);
-        SDL_memcpy(src, tmp, length);
-        dst += pitch;
-        src -= pitch;
-    }
-    SDL_stack_free(tmp);
-
-    return 0;
-}
-
-static int
-GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 pixel_format, const void * pixels, int pitch)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    GLint internalFormat;
-    GLenum format, type;
-    Uint8 *src, *dst, *tmp;
-    int length, rows;
-
-    GL_ActivateRenderer(renderer);
-
-    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
-        /* FIXME: Do a temp copy to a format that is supported */
-        SDL_SetError("Unsupported pixel format");
-        return -1;
-    }
-
-    data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    data->glPixelStorei(GL_UNPACK_ROW_LENGTH,
-                        (pitch / bytes_per_pixel(pixel_format)));
-
-    /* Flip the rows to be bottom-up */
-    length = rect->h * rect->w * pitch;
-    tmp = SDL_stack_alloc(Uint8, length);
-    src = (Uint8*)pixels + (rect->h-1)*pitch;
-    dst = (Uint8*)tmp;
-    rows = rect->h;
-    while (rows--) {
-        SDL_memcpy(dst, src, pitch);
-        dst += pitch;
-        src -= pitch;
-    }
-
-    data->glRasterPos2i(rect->x, (window->h-rect->y));
-    data->glDrawPixels(rect->w, rect->h, format, type, tmp);
-    SDL_stack_free(tmp);
-
-    return 0;
-}
-
-static void
-GL_RenderPresent(SDL_Renderer * renderer)
-{
-    GL_ActivateRenderer(renderer);
-
-    SDL_GL_SwapWindow(renderer->window);
-}
-
-static void
-GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata;
-    GL_TextureData *data = (GL_TextureData *) texture->driverdata;
-
-    GL_ActivateRenderer(renderer);
-
-    if (!data) {
-        return;
-    }
-    if (data->texture) {
-        renderdata->glDeleteTextures(1, &data->texture);
-    }
-    if (data->palette) {
-        SDL_free(data->palette);
-    }
-    if (data->pixels) {
-        SDL_free(data->pixels);
-    }
-    SDL_FreeDirtyRects(&data->dirty);
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-GL_DestroyRenderer(SDL_Renderer * renderer)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-
-    if (data) {
-        if (data->context) {
-            if (data->GL_ARB_fragment_program_supported) {
-                data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
-                data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
-                if (data->fragment_program_UYVY &&
-                    data->fragment_program_UYVY != ~0) {
-                    data->glDeleteProgramsARB(1,
-                                              &data->fragment_program_UYVY);
-                }
-            }
-
-            /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
-            SDL_GL_DeleteContext(data->context);
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_OGL */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gl.h	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* OpenGL renderer implementation */
-
-extern SDL_RenderDriver GL_RenderDriver;
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gles.c	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,841 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_OGL_ES
-
-#include "SDL_video.h"
-#include "SDL_opengles.h"
-#include "SDL_sysvideo.h"
-#include "SDL_pixels_c.h"
-#include "SDL_rect_c.h"
-#include "SDL_yuv_sw_c.h"
-
-#if defined(SDL_VIDEO_DRIVER_PANDORA)
-
-/* Empty function stub to get OpenGL ES 1.x support without  */
-/* OpenGL ES extension GL_OES_draw_texture supported         */
-GL_API void GL_APIENTRY
-glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
-{
-    return;
-}
-
-#endif /* PANDORA */
-
-/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
-
-static const float inv255f = 1.0f / 255.0f;
-
-static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
-static void GLES_WindowEvent(SDL_Renderer * renderer,
-                             const SDL_WindowEvent *event);
-static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int GLES_QueryTexturePixels(SDL_Renderer * renderer,
-                                   SDL_Texture * texture, void **pixels,
-                                   int *pitch);
-static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                              const SDL_Rect * rect, const void *pixels,
-                              int pitch);
-static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * rect, int markDirty,
-                            void **pixels, int *pitch);
-static void GLES_UnlockTexture(SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                              int numrects, const SDL_Rect * rects);
-static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
-                                 const SDL_Point * points, int count);
-static int GLES_RenderDrawLines(SDL_Renderer * renderer,
-                                const SDL_Point * points, int count);
-static int GLES_RenderFillRects(SDL_Renderer * renderer,
-                                const SDL_Rect ** rects, int count);
-static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                           const SDL_Rect * srcrect,
-                           const SDL_Rect * dstrect);
-static void GLES_RenderPresent(SDL_Renderer * renderer);
-static void GLES_DestroyTexture(SDL_Renderer * renderer,
-                                SDL_Texture * texture);
-static void GLES_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver GL_ES_RenderDriver = {
-    GLES_CreateRenderer,
-    {
-     "opengl_es",
-     (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
-     {
-      /* OpenGL ES 1.x supported formats list */
-      SDL_PIXELFORMAT_RGBA4444,
-      SDL_PIXELFORMAT_RGBA5551,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB24,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ABGR8888},
-     0,
-     0}
-};
-
-typedef struct
-{
-    SDL_GLContext context;
-    SDL_bool updateSize;
-    int blendMode;
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-
-    SDL_bool useDrawTexture;
-    SDL_bool GL_OES_draw_texture_supported;
-
-    /* OpenGL ES functions */
-#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
-#include "SDL_glesfuncs.h"
-#undef SDL_PROC
-
-} GLES_RenderData;
-
-typedef struct
-{
-    GLuint texture;
-    GLenum type;
-    GLfloat texw;
-    GLfloat texh;
-    GLenum format;
-    GLenum formattype;
-    void *pixels;
-    int pitch;
-    SDL_DirtyRectList dirty;
-} GLES_TextureData;
-
-static void
-GLES_SetError(const char *prefix, GLenum result)
-{
-    const char *error;
-
-    switch (result) {
-    case GL_NO_ERROR:
-        error = "GL_NO_ERROR";
-        break;
-    case GL_INVALID_ENUM:
-        error = "GL_INVALID_ENUM";
-        break;
-    case GL_INVALID_VALUE:
-        error = "GL_INVALID_VALUE";
-        break;
-    case GL_INVALID_OPERATION:
-        error = "GL_INVALID_OPERATION";
-        break;
-    case GL_STACK_OVERFLOW:
-        error = "GL_STACK_OVERFLOW";
-        break;
-    case GL_STACK_UNDERFLOW:
-        error = "GL_STACK_UNDERFLOW";
-        break;
-    case GL_OUT_OF_MEMORY:
-        error = "GL_OUT_OF_MEMORY";
-        break;
-    default:
-        error = "UNKNOWN";
-        break;
-    }
-    SDL_SetError("%s: %s", prefix, error);
-}
-
-static int
-GLES_LoadFunctions(GLES_RenderData * data)
-{
-
-#define SDL_PROC(ret,func,params) \
-    data->func = func;
-#include "SDL_glesfuncs.h"
-#undef SDL_PROC
-
-    return 0;
-}
-
-SDL_Renderer *
-GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-
-    SDL_Renderer *renderer;
-    GLES_RenderData *data;
-    GLint value;
-    int doublebuffer;
-
-    if (!(window->flags & SDL_WINDOW_OPENGL)) {
-        if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
-            return NULL;
-        }
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        GLES_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    renderer->WindowEvent = GLES_WindowEvent;
-    renderer->CreateTexture = GLES_CreateTexture;
-    renderer->QueryTexturePixels = GLES_QueryTexturePixels;
-    renderer->UpdateTexture = GLES_UpdateTexture;
-    renderer->LockTexture = GLES_LockTexture;
-    renderer->UnlockTexture = GLES_UnlockTexture;
-    renderer->DirtyTexture = GLES_DirtyTexture;
-    renderer->RenderDrawPoints = GLES_RenderDrawPoints;
-    renderer->RenderDrawLines = GLES_RenderDrawLines;
-    renderer->RenderFillRects = GLES_RenderFillRects;
-    renderer->RenderCopy = GLES_RenderCopy;
-    renderer->RenderPresent = GLES_RenderPresent;
-    renderer->DestroyTexture = GLES_DestroyTexture;
-    renderer->DestroyRenderer = GLES_DestroyRenderer;
-    renderer->info = GL_ES_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
-
-    if (GLES_LoadFunctions(data) < 0) {
-        GLES_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    data->context = SDL_GL_CreateContext(window);
-    if (!data->context) {
-        GLES_DestroyRenderer(renderer);
-        return NULL;
-    }
-    if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-        GLES_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        SDL_GL_SetSwapInterval(1);
-    } else {
-        SDL_GL_SetSwapInterval(0);
-    }
-    if (SDL_GL_GetSwapInterval() > 0) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-
-    if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
-        if (!doublebuffer) {
-            renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
-        }
-    }
-#if SDL_VIDEO_DRIVER_PANDORA
-    data->GL_OES_draw_texture_supported = SDL_FALSE;
-    data->useDrawTexture = SDL_FALSE;
-#else
-    if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
-        data->GL_OES_draw_texture_supported = SDL_TRUE;
-        data->useDrawTexture = SDL_TRUE;
-    } else {
-        data->GL_OES_draw_texture_supported = SDL_FALSE;
-        data->useDrawTexture = SDL_FALSE;
-    }
-#endif
-
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_width = value;
-    data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
-    renderer->info.max_texture_height = value;
-
-    /* Set up parameters for rendering */
-    data->blendMode = -1;
-    data->glDisable(GL_DEPTH_TEST);
-    data->glDisable(GL_CULL_FACE);
-    data->updateSize = SDL_TRUE;
-
-    data->glEnableClientState(GL_VERTEX_ARRAY);
-    data->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-    
-    return renderer;
-}
-
-static SDL_GLContext SDL_CurrentContext = NULL;
-
-static int
-GLES_ActivateRenderer(SDL_Renderer * renderer)
-{
-
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-
-    if (SDL_CurrentContext != data->context) {
-        if (SDL_GL_MakeCurrent(window, data->context) < 0) {
-            return -1;
-        }
-        SDL_CurrentContext = data->context;
-    }
-    if (data->updateSize) {
-        data->glMatrixMode(GL_PROJECTION);
-        data->glLoadIdentity();
-        data->glMatrixMode(GL_MODELVIEW);
-        data->glLoadIdentity();
-        data->glViewport(0, 0, window->w, window->h);
-        data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, 0.0,
-                       0.0, 1.0);
-        data->updateSize = SDL_FALSE;
-    }
-    return 0;
-}
-
-static void
-GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-
-    if (event->event == SDL_WINDOWEVENT_RESIZED) {
-        /* Rebind the context to the window area and update matrices */
-        SDL_CurrentContext = NULL;
-        data->updateSize = SDL_TRUE;
-    }
-}
-
-static __inline__ int
-power_of_2(int input)
-{
-    int value = 1;
-
-    while (value < input) {
-        value <<= 1;
-    }
-    return value;
-}
-
-static int
-GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
-    GLES_TextureData *data;
-    GLint internalFormat;
-    GLenum format, type;
-    int texture_w, texture_h;
-    GLenum result;
-
-    GLES_ActivateRenderer(renderer);
-
-    switch (texture->format) {
-    case SDL_PIXELFORMAT_RGB24:
-        internalFormat = GL_RGB;
-        format = GL_RGB;
-        type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_BGR888:
-    case SDL_PIXELFORMAT_ABGR8888:
-        internalFormat = GL_RGBA;
-        format = GL_RGBA;
-        type = GL_UNSIGNED_BYTE;
-        break;
-    case SDL_PIXELFORMAT_RGB565:
-        internalFormat = GL_RGB;
-        format = GL_RGB;
-        type = GL_UNSIGNED_SHORT_5_6_5;
-        break;
-    case SDL_PIXELFORMAT_RGBA5551:
-        internalFormat = GL_RGBA;
-        format = GL_RGBA;
-        type = GL_UNSIGNED_SHORT_5_5_5_1;
-        break;
-    case SDL_PIXELFORMAT_RGBA4444:
-        internalFormat = GL_RGBA;
-        format = GL_RGBA;
-        type = GL_UNSIGNED_SHORT_4_4_4_4;
-        break;
-    default:
-        SDL_SetError("Texture format %s not supported by OpenGL ES",
-                     SDL_GetPixelFormatName(texture->format));
-        return -1;
-    }
-
-    data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
-        data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
-        data->pixels = SDL_malloc(texture->h * data->pitch);
-        if (!data->pixels) {
-            SDL_OutOfMemory();
-            SDL_free(data);
-            return -1;
-        }
-    }
-
-    texture->driverdata = data;
-
-    renderdata->glGetError();
-    renderdata->glEnable(GL_TEXTURE_2D);
-    renderdata->glGenTextures(1, &data->texture);
-
-    data->type = GL_TEXTURE_2D;
-    /* no NPOV textures allowed in OpenGL ES (yet) */
-    texture_w = power_of_2(texture->w);
-    texture_h = power_of_2(texture->h);
-    data->texw = (GLfloat) texture->w / texture_w;
-    data->texh = (GLfloat) texture->h / texture_h;
-
-    data->format = format;
-    data->formattype = type;
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
-                                GL_LINEAR);
-    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
-                                GL_LINEAR);
-    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, internalFormat, texture_w,
-                             texture_h, 0, format, type, NULL);
-    renderdata->glDisable(GL_TEXTURE_2D);
-
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GLES_SetError("glTexImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GLES_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                        void **pixels, int *pitch)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-
-    *pixels = data->pixels;
-    *pitch = data->pitch;
-    return 0;
-}
-
-static void
-SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture,
-                   int pitch)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-    renderdata->glBindTexture(data->type, data->texture);
-    renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-}
-
-static int
-GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                   const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-    GLenum result;
-    int bpp = SDL_BYTESPERPIXEL(texture->format);
-    void * temp_buffer;
-    void * temp_ptr;
-    int i;
-
-    GLES_ActivateRenderer(renderer);
-
-    renderdata->glGetError();
-    renderdata->glEnable(data->type);
-    SetupTextureUpdate(renderdata, texture, pitch);
-
-    if( rect->w * bpp == pitch ) {
-         temp_buffer = (void *)pixels; /* No need to reformat */
-    } else {
-         /* Reformatting of mem area required */
-         temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
-         temp_ptr = temp_buffer;
-         for (i = 0; i < rect->h; i++) {
-             SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
-             temp_ptr += rect->w * bpp;
-             pixels += pitch;
-         }
-    }
-
-    renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
-                                rect->h, data->format, data->formattype,
-                                temp_buffer);
-
-    if( temp_buffer != pixels ) {
-        SDL_free(temp_buffer);
-    }
-
-    renderdata->glDisable(data->type);
-    result = renderdata->glGetError();
-    if (result != GL_NO_ERROR) {
-        GLES_SetError("glTexSubImage2D()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, int markDirty, void **pixels,
-                 int *pitch)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-
-    if (markDirty) {
-        SDL_AddDirtyRect(&data->dirty, rect);
-    }
-
-    *pixels =
-        (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
-                  rect->x * SDL_BYTESPERPIXEL(texture->format));
-    *pitch = data->pitch;
-    return 0;
-}
-
-static void
-GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-}
-
-static void
-GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                  int numrects, const SDL_Rect * rects)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-    int i;
-
-    for (i = 0; i < numrects; ++i) {
-        SDL_AddDirtyRect(&data->dirty, &rects[i]);
-    }
-}
-
-static void
-GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
-{
-    if (blendMode != data->blendMode) {
-        switch (blendMode) {
-        case SDL_BLENDMODE_NONE:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-            data->glDisable(GL_BLEND);
-            break;
-        case SDL_BLENDMODE_BLEND:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-            break;
-        case SDL_BLENDMODE_ADD:
-            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-            data->glEnable(GL_BLEND);
-            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-            break;
-        }
-        data->blendMode = blendMode;
-    }
-}
-
-static int
-GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                      int count)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    int i;
-    GLshort *vertices;
-
-    GLES_ActivateRenderer(renderer);
-
-    GLES_SetBlendMode(data, renderer->blendMode);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    vertices = SDL_stack_alloc(GLshort, count*2);
-    for (i = 0; i < count; ++i) {
-        vertices[2*i+0] = (GLshort)points[i].x;
-        vertices[2*i+1] = (GLshort)points[i].y;
-    }
-    data->glVertexPointer(2, GL_SHORT, 0, vertices);
-    data->glDrawArrays(GL_POINTS, 0, count);
-    SDL_stack_free(vertices);
-
-    return 0;
-}
-
-static int
-GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                     int count)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    int i;
-    GLshort *vertices;
-
-    GLES_ActivateRenderer(renderer);
-
-    GLES_SetBlendMode(data, renderer->blendMode);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    vertices = SDL_stack_alloc(GLshort, count*2);
-    for (i = 0; i < count; ++i) {
-        vertices[2*i+0] = (GLshort)points[i].x;
-        vertices[2*i+1] = (GLshort)points[i].y;
-    }
-    data->glVertexPointer(2, GL_SHORT, 0, vertices);
-    if (count > 2 && 
-        points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
-        /* GL_LINE_LOOP takes care of the final segment */
-        --count;
-        data->glDrawArrays(GL_LINE_LOOP, 0, count);
-    } else {
-        data->glDrawArrays(GL_LINE_STRIP, 0, count);
-    }
-    SDL_stack_free(vertices);
-
-    return 0;
-}
-
-static int
-GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                     int count)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    int i;
-
-    GLES_ActivateRenderer(renderer);
-
-    GLES_SetBlendMode(data, renderer->blendMode);
-
-    data->glColor4f((GLfloat) renderer->r * inv255f,
-                    (GLfloat) renderer->g * inv255f,
-                    (GLfloat) renderer->b * inv255f,
-                    (GLfloat) renderer->a * inv255f);
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-        GLshort minx = rect->x;
-        GLshort maxx = rect->x + rect->w;
-        GLshort miny = rect->y;
-        GLshort maxy = rect->y + rect->h;
-        GLshort vertices[8];
-        vertices[0] = minx;
-        vertices[1] = miny;
-        vertices[2] = maxx;
-        vertices[3] = miny;
-        vertices[4] = minx;
-        vertices[5] = maxy;
-        vertices[6] = maxx;
-        vertices[7] = maxy;
-
-        data->glVertexPointer(2, GL_SHORT, 0, vertices);
-        data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-    }
-
-    return 0;
-}
-
-static int
-GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-    GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
-    int minx, miny, maxx, maxy;
-    GLfloat minu, maxu, minv, maxv;
-    int i;
-    void *temp_buffer;          /* used for reformatting dirty rect pixels */
-    void *temp_ptr;
-
-    GLES_ActivateRenderer(renderer);
-
-    data->glEnable(GL_TEXTURE_2D);
-
-    if (texturedata->dirty.list) {
-        SDL_DirtyRect *dirty;
-        void *pixels;
-        int bpp = SDL_BYTESPERPIXEL(texture->format);
-        int pitch = texturedata->pitch;
-
-        SetupTextureUpdate(data, texture, pitch);
-
-        data->glBindTexture(texturedata->type, texturedata->texture);
-        for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
-            SDL_Rect *rect = &dirty->rect;
-            pixels =
-                (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
-                          rect->x * bpp);
-            /*      There is no GL_UNPACK_ROW_LENGTH in OpenGLES 
-               we must do this reformatting ourselves(!)
-
-               maybe it'd be a good idea to keep a temp buffer around
-               for this purpose rather than allocating it each time
-             */
-            if( rect->x == 0 && rect->w * bpp == pitch ) {
-                temp_buffer = pixels; /* Updating whole texture, no need to reformat */
-            } else {
-                temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
-                temp_ptr = temp_buffer;
-                for (i = 0; i < rect->h; i++) {
-                    SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
-                    temp_ptr += rect->w * bpp;
-                    pixels += pitch;
-                }
-            }
-
-            data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
-                                  rect->w, rect->h, texturedata->format,
-                                  texturedata->formattype, temp_buffer);
-
-            if( temp_buffer != pixels ) {
-                SDL_free(temp_buffer);
-            }
-        }
-        SDL_ClearDirtyRects(&texturedata->dirty);
-    }
-
-    data->glBindTexture(texturedata->type, texturedata->texture);
-
-    if (texture->modMode) {
-        data->glColor4f((GLfloat) texture->r * inv255f,
-                        (GLfloat) texture->g * inv255f,
-                        (GLfloat) texture->b * inv255f,
-                        (GLfloat) texture->a * inv255f);
-    } else {
-        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-    }
-
-    GLES_SetBlendMode(data, texture->blendMode);
-
-    if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
-        /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
-        SDL_Window *window = renderer->window;
-        GLint cropRect[4];
-        cropRect[0] = srcrect->x;
-        cropRect[1] = srcrect->y + srcrect->h;
-        cropRect[2] = srcrect->w;
-        cropRect[3] = -srcrect->h;
-        data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
-                               cropRect);
-        data->glDrawTexiOES(dstrect->x, window->h - dstrect->y - dstrect->h,
-                            0, dstrect->w, dstrect->h);
-    } else {
-
-        minx = dstrect->x;
-        miny = dstrect->y;
-        maxx = dstrect->x + dstrect->w;
-        maxy = dstrect->y + dstrect->h;
-
-        minu = (GLfloat) srcrect->x / texture->w;
-        minu *= texturedata->texw;
-        maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
-        maxu *= texturedata->texw;
-        minv = (GLfloat) srcrect->y / texture->h;
-        minv *= texturedata->texh;
-        maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
-        maxv *= texturedata->texh;
-
-        GLshort vertices[8];
-        GLfloat texCoords[8];
-
-        vertices[0] = minx;
-        vertices[1] = miny;
-        vertices[2] = maxx;
-        vertices[3] = miny;
-        vertices[4] = minx;
-        vertices[5] = maxy;
-        vertices[6] = maxx;
-        vertices[7] = maxy;
-
-        texCoords[0] = minu;
-        texCoords[1] = minv;
-        texCoords[2] = maxu;
-        texCoords[3] = minv;
-        texCoords[4] = minu;
-        texCoords[5] = maxv;
-        texCoords[6] = maxu;
-        texCoords[7] = maxv;
-
-        data->glVertexPointer(2, GL_SHORT, 0, vertices);
-        data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
-        data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-    }
-
-    data->glDisable(GL_TEXTURE_2D);
-
-    return 0;
-}
-
-static void
-GLES_RenderPresent(SDL_Renderer * renderer)
-{
-    GLES_ActivateRenderer(renderer);
-
-    SDL_GL_SwapWindow(renderer->window);
-}
-
-static void
-GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
-
-    GLES_ActivateRenderer(renderer);
-
-    if (!data) {
-        return;
-    }
-    if (data->texture) {
-        glDeleteTextures(1, &data->texture);
-    }
-    if (data->pixels) {
-        SDL_free(data->pixels);
-    }
-    SDL_FreeDirtyRects(&data->dirty);
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-GLES_DestroyRenderer(SDL_Renderer * renderer)
-{
-    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
-
-    if (data) {
-        if (data->context) {
-            SDL_GL_DeleteContext(data->context);
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_OGL_ES */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gles.h	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* OpenGL renderer implementation */
-
-extern SDL_RenderDriver GL_ES_RenderDriver;
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_sw.c	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,747 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-#include "SDL_sysvideo.h"
-#include "SDL_pixels_c.h"
-#include "SDL_rect_c.h"
-#include "SDL_yuv_sw_c.h"
-#include "SDL_renderer_sw.h"
-
-
-/* SDL surface based renderer implementation */
-
-static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
-static void SW_WindowEvent(SDL_Renderer * renderer,
-                           const SDL_WindowEvent *event);
-static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int SW_QueryTexturePixels(SDL_Renderer * renderer,
-                                 SDL_Texture * texture, void **pixels,
-                                 int *pitch);
-static int SW_SetTextureColorMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
-                                 SDL_Texture * texture);
-static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
-                                  SDL_Texture * texture);
-static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                            const SDL_Rect * rect, const void *pixels,
-                            int pitch);
-static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, int markDirty, void **pixels,
-                          int *pitch);
-static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int SW_RenderDrawPoints(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int SW_RenderDrawLines(SDL_Renderer * renderer,
-                              const SDL_Point * points, int count);
-static int SW_RenderFillRects(SDL_Renderer * renderer,
-                              const SDL_Rect ** rects, int count);
-static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                               Uint32 format, void * pixels, int pitch);
-static int SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 format, const void * pixels, int pitch);
-static void SW_RenderPresent(SDL_Renderer * renderer);
-static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void SW_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver SW_RenderDriver = {
-    SW_CreateRenderer,
-    {
-     "software",
-     (SDL_RENDERER_PRESENTVSYNC),
-     13,
-     {
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_BGR888,
-      SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_RGBA8888,
-      SDL_PIXELFORMAT_ABGR8888,
-      SDL_PIXELFORMAT_BGRA8888,
-      SDL_PIXELFORMAT_YV12,
-      SDL_PIXELFORMAT_IYUV,
-      SDL_PIXELFORMAT_YUY2,
-      SDL_PIXELFORMAT_UYVY,
-      SDL_PIXELFORMAT_YVYU},
-     0,
-     0}
-};
-
-typedef struct
-{
-    Uint32 format;
-    SDL_bool updateSize;
-    SDL_Texture *texture;
-    SDL_Surface surface;
-    SDL_Renderer *renderer;
-    SDL_DirtyRectList dirty;
-} SW_RenderData;
-
-static SDL_Texture *
-CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h)
-{
-    SDL_Texture *texture;
-
-    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
-    if (!texture) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    texture->format = format;
-    texture->access = SDL_TEXTUREACCESS_STREAMING;
-    texture->w = w;
-    texture->h = h;
-    texture->renderer = renderer;
-
-    if (renderer->CreateTexture(renderer, texture) < 0) {
-        SDL_free(texture);
-        return NULL;
-    }
-    return texture;
-}
-
-static void
-DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    renderer->DestroyTexture(renderer, texture);
-    SDL_free(texture);
-}
-
-void
-Setup_SoftwareRenderer(SDL_Renderer * renderer)
-{
-    renderer->CreateTexture = SW_CreateTexture;
-    renderer->QueryTexturePixels = SW_QueryTexturePixels;
-    renderer->SetTextureColorMod = SW_SetTextureColorMod;
-    renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
-    renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
-    renderer->UpdateTexture = SW_UpdateTexture;
-    renderer->LockTexture = SW_LockTexture;
-    renderer->UnlockTexture = SW_UnlockTexture;
-    renderer->DestroyTexture = SW_DestroyTexture;
-
-    renderer->info.num_texture_formats =
-        SW_RenderDriver.info.num_texture_formats;
-    SDL_memcpy(renderer->info.texture_formats,
-               SW_RenderDriver.info.texture_formats,
-               sizeof(renderer->info.texture_formats));;
-    renderer->info.max_texture_width = SW_RenderDriver.info.max_texture_width;
-    renderer->info.max_texture_height =
-        SW_RenderDriver.info.max_texture_height;
-}
-
-SDL_Renderer *
-SW_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayMode *displayMode = &display->current_mode;
-    SDL_Renderer *renderer;
-    SW_RenderData *data;
-    int i, n;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-    Uint32 renderer_flags;
-    const char *desired_driver;
-
-    if (!SDL_PixelFormatEnumToMasks
-        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        SDL_SetError("Unknown display format");
-        return NULL;
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SW_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    renderer->WindowEvent = SW_WindowEvent;
-
-    renderer->RenderDrawPoints = SW_RenderDrawPoints;
-    renderer->RenderDrawLines = SW_RenderDrawLines;
-    renderer->RenderFillRects = SW_RenderFillRects;
-    renderer->RenderCopy = SW_RenderCopy;
-    renderer->RenderReadPixels = SW_RenderReadPixels;
-    renderer->RenderWritePixels = SW_RenderWritePixels;
-    renderer->RenderPresent = SW_RenderPresent;
-    renderer->DestroyRenderer = SW_DestroyRenderer;
-    renderer->info.name = SW_RenderDriver.info.name;
-    renderer->info.flags = 0;
-    renderer->window = window;
-    renderer->driverdata = data;
-    Setup_SoftwareRenderer(renderer);
-
-    n = 1;
-    data->format = displayMode->format;
-
-    /* Find a render driver that we can use to display data */
-    renderer_flags = 0;
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        renderer_flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-    desired_driver = SDL_getenv("SDL_VIDEO_RENDERER_SWDRIVER");
-    for (i = 0; i < display->num_render_drivers; ++i) {
-        SDL_RenderDriver *driver = &display->render_drivers[i];
-        if (driver->info.name == SW_RenderDriver.info.name) {
-            continue;
-        }
-        if (desired_driver
-            && SDL_strcasecmp(desired_driver, driver->info.name) != 0) {
-            continue;
-        }
-        data->renderer = driver->CreateRenderer(window, renderer_flags);
-        if (data->renderer) {
-            break;
-        }
-    }
-    if (i == display->num_render_drivers) {
-        SW_DestroyRenderer(renderer);
-        SDL_SetError("Couldn't find display render driver");
-        return NULL;
-    }
-    if (data->renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-
-    /* Create the textures we'll use for display */
-    data->texture =
-        CreateTexture(data->renderer, data->format, window->w, window->h);
-    if (!data->texture) {
-        SW_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    /* Create a surface we'll use for rendering */
-    data->surface.flags = SDL_PREALLOC;
-    data->surface.format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
-    if (!data->surface.format) {
-        SW_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    return renderer;
-}
-
-static SDL_Texture *
-SW_ActivateRenderer(SDL_Renderer * renderer)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-
-    if (data->updateSize) {
-        /* Recreate the textures for the new window size */
-        if (data->texture) {
-            DestroyTexture(data->renderer, data->texture);
-        }
-        data->texture = CreateTexture(data->renderer, data->format,
-                                      window->w, window->h);
-        if (data->texture) {
-            data->updateSize = SDL_FALSE;
-        }
-    }
-    return data->texture;
-}
-
-static void
-SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-
-    if (event->event == SDL_WINDOWEVENT_RESIZED) {
-        data->updateSize = SDL_TRUE;
-    }
-}
-
-static int
-SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        texture->driverdata =
-            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
-    } else {
-        int bpp;
-        Uint32 Rmask, Gmask, Bmask, Amask;
-
-        if (!SDL_PixelFormatEnumToMasks
-            (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-            SDL_SetError("Unknown texture format");
-            return -1;
-        }
-
-        texture->driverdata =
-            SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
-                                 Bmask, Amask);
-        SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
-                               texture->b);
-        SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
-        SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
-
-        if (texture->access == SDL_TEXTUREACCESS_STATIC) {
-            SDL_SetSurfaceRLE(texture->driverdata, 1);
-        }
-    }
-
-    if (!texture->driverdata) {
-        return -1;
-    }
-    return 0;
-}
-
-static int
-SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                      void **pixels, int *pitch)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *)
-                                            texture->driverdata, pixels,
-                                            pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        *pixels = surface->pixels;
-        *pitch = surface->pitch;
-        return 0;
-    }
-}
-
-static int
-SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-    return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
-                                  texture->b);
-}
-
-static int
-SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-    return SDL_SetSurfaceAlphaMod(surface, texture->a);
-}
-
-static int
-SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-    return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
-}
-
-static int
-SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                 const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *)
-                                       texture->driverdata, rect, pixels,
-                                       pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        Uint8 *src, *dst;
-        int row;
-        size_t length;
-
-        src = (Uint8 *) pixels;
-        dst =
-            (Uint8 *) surface->pixels + rect->y * surface->pitch +
-            rect->x * surface->format->BytesPerPixel;
-        length = rect->w * surface->format->BytesPerPixel;
-        for (row = 0; row < rect->h; ++row) {
-            SDL_memcpy(dst, src, length);
-            src += pitch;
-            dst += surface->pitch;
-        }
-        return 0;
-    }
-}
-
-static int
-SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * rect, int markDirty, void **pixels,
-               int *pitch)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *)
-                                     texture->driverdata, rect, markDirty,
-                                     pixels, pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        *pixels =
-            (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
-                      rect->x * surface->format->BytesPerPixel);
-        *pitch = surface->pitch;
-        return 0;
-    }
-}
-
-static void
-SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
-    }
-}
-
-static int
-SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = SW_ActivateRenderer(renderer);
-    SDL_Rect rect;
-    int i;
-    int x, y;
-    int status = 0;
-
-    if (!texture) {
-        return -1;
-    }
-
-    /* Get the smallest rectangle that contains everything */
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    if (!SDL_EnclosePoints(points, count, &rect, &rect)) {
-        /* Nothing to draw */
-        return 0;
-    }
-
-    if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
-                                    &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    data->surface.clip_rect.w = data->surface.w = rect.w;
-    data->surface.clip_rect.h = data->surface.h = rect.h;
-
-    /* Draw the points! */
-    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
-        Uint32 color = SDL_MapRGBA(data->surface.format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        for (i = 0; i < count; ++i) {
-            x = points[i].x - rect.x;
-            y = points[i].y - rect.y;
-
-            status = SDL_DrawPoint(&data->surface, x, y, color);
-        }
-    } else {
-        for (i = 0; i < count; ++i) {
-            x = points[i].x - rect.x;
-            y = points[i].y - rect.y;
-
-            status = SDL_BlendPoint(&data->surface, x, y,
-                                    renderer->blendMode,
-                                    renderer->r, renderer->g, renderer->b,
-                                    renderer->a);
-        }
-    }
-
-    data->renderer->UnlockTexture(data->renderer, texture);
-
-    return status;
-}
-
-static int
-SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                   int count)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = SW_ActivateRenderer(renderer);
-    SDL_Rect clip, rect;
-    int i;
-    int x1, y1, x2, y2;
-    int status = 0;
-
-    if (!texture) {
-        return -1;
-    }
-
-    /* Get the smallest rectangle that contains everything */
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = texture->w;
-    clip.h = texture->h;
-    SDL_EnclosePoints(points, count, NULL, &rect);
-    if (!SDL_IntersectRect(&rect, &clip, &rect)) {
-        /* Nothing to draw */
-        return 0;
-    }
-
-    if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
-                                    &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    data->surface.clip_rect.w = data->surface.w = rect.w;
-    data->surface.clip_rect.h = data->surface.h = rect.h;
-
-    /* Draw the points! */
-    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
-        Uint32 color = SDL_MapRGBA(data->surface.format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        for (i = 1; i < count; ++i) {
-            x1 = points[i-1].x - rect.x;
-            y1 = points[i-1].y - rect.y;
-            x2 = points[i].x - rect.x;
-            y2 = points[i].y - rect.y;
-
-            status = SDL_DrawLine(&data->surface, x1, y1, x2, y2, color);
-        }
-    } else {
-        for (i = 1; i < count; ++i) {
-            x1 = points[i-1].x - rect.x;
-            y1 = points[i-1].y - rect.y;
-            x2 = points[i].x - rect.x;
-            y2 = points[i].y - rect.y;
-
-            status = SDL_BlendLine(&data->surface, x1, y1, x2, y2,
-                                   renderer->blendMode,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-        }
-    }
-
-    data->renderer->UnlockTexture(data->renderer, texture);
-
-    return status;
-}
-
-static int
-SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                   int count)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = SW_ActivateRenderer(renderer);
-    SDL_Rect clip, rect;
-    Uint32 color = 0;
-    int i;
-    int status = 0;
-
-    if (!texture) {
-        return -1;
-    }
-
-    clip.x = 0;
-    clip.y = 0;
-    clip.w = texture->w;
-    clip.h = texture->h;
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
-        color = SDL_MapRGBA(data->surface.format,
-                            renderer->r, renderer->g, renderer->b,
-                            renderer->a);
-    }
-
-    for (i = 0; i < count; ++i) {
-        if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
-            /* Nothing to draw */
-            continue;
-        }
-
-        if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
-                                        &data->surface.pixels,
-                                        &data->surface.pitch) < 0) {
-            return -1;
-        }
-
-        data->surface.clip_rect.w = data->surface.w = rect.w;
-        data->surface.clip_rect.h = data->surface.h = rect.h;
-
-        if (renderer->blendMode == SDL_BLENDMODE_NONE) {
-            status = SDL_FillRect(&data->surface, NULL, color);
-        } else {
-            status = SDL_BlendFillRect(&data->surface, NULL,
-                                       renderer->blendMode,
-                                       renderer->r, renderer->g, renderer->b,
-                                       renderer->a);
-        }
-
-        data->renderer->UnlockTexture(data->renderer, texture);
-    }
-    return status;
-}
-
-static int
-SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    int status;
-
-    if (!SW_ActivateRenderer(renderer)) {
-        return -1;
-    }
-
-    if (data->renderer->LockTexture(data->renderer, data->texture,
-                                    dstrect, 1, &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        status =
-            SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
-                                srcrect, data->format, dstrect->w, dstrect->h,
-                                data->surface.pixels, data->surface.pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        SDL_Rect real_srcrect = *srcrect;
-        SDL_Rect real_dstrect;
-
-        data->surface.w = dstrect->w;
-        data->surface.h = dstrect->h;
-        data->surface.clip_rect.w = dstrect->w;
-        data->surface.clip_rect.h = dstrect->h;
-        real_dstrect = data->surface.clip_rect;
-
-        status =
-            SDL_LowerBlit(surface, &real_srcrect, &data->surface,
-                          &real_dstrect);
-    }
-    data->renderer->UnlockTexture(data->renderer, data->texture);
-    return status;
-}
-
-static int
-SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                    Uint32 format, void * pixels, int pitch)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-
-    if (!SW_ActivateRenderer(renderer)) {
-        return -1;
-    }
-
-    if (data->renderer->LockTexture(data->renderer, data->texture,
-                                    rect, 0, &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      data->format, data->surface.pixels, data->surface.pitch,
-                      format, pixels, pitch);
-
-    data->renderer->UnlockTexture(data->renderer, data->texture);
-    return 0;
-}
-
-static int
-SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, const void * pixels, int pitch)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-
-    if (!SW_ActivateRenderer(renderer)) {
-        return -1;
-    }
-
-    if (data->renderer->LockTexture(data->renderer, data->texture,
-                                    rect, 1, &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
-                      data->format, data->surface.pixels, data->surface.pitch);
-
-    data->renderer->UnlockTexture(data->renderer, data->texture);
-    return 0;
-}
-
-static void
-SW_RenderPresent(SDL_Renderer * renderer)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Texture *texture = SW_ActivateRenderer(renderer);
-    SDL_Rect rect;
-
-    if (!texture) {
-        return;
-    }
-
-    /* Send the data to the display */
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    data->renderer->RenderCopy(data->renderer, texture, &rect, &rect);
-    data->renderer->RenderPresent(data->renderer);
-}
-
-static void
-SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-
-        SDL_FreeSurface(surface);
-    }
-}
-
-static void
-SW_DestroyRenderer(SDL_Renderer * renderer)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    int i;
-
-    if (data) {
-        if (data->texture) {
-            DestroyTexture(data->renderer, data->texture);
-        }
-        if (data->surface.format) {
-            SDL_FreeFormat(data->surface.format);
-        }
-        if (data->renderer) {
-            data->renderer->DestroyRenderer(data->renderer);
-        }
-        SDL_FreeDirtyRects(&data->dirty);
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_sw.h	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* SDL surface based renderer implementation */
-
-extern SDL_RenderDriver SW_RenderDriver;
-
-/* Set up SDL_Surface texture functions for a renderer */
-void Setup_SoftwareRenderer(SDL_Renderer * renderer);
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_sysvideo.h	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/SDL_sysvideo.h	Wed Feb 02 14:34:54 2011 -0800
@@ -24,106 +24,15 @@
 #ifndef _SDL_sysvideo_h
 #define _SDL_sysvideo_h
 
-#include "SDL_events.h"
-#include "SDL_mouse.h"
-#include "SDL_keysym.h"
-#include "SDL_render.h"
 #include "SDL_shape.h"
 
 /* The SDL video driver */
 
-typedef struct SDL_RenderDriver SDL_RenderDriver;
 typedef struct SDL_WindowShaper SDL_WindowShaper;
 typedef struct SDL_ShapeDriver SDL_ShapeDriver;
 typedef struct SDL_VideoDisplay SDL_VideoDisplay;
 typedef struct SDL_VideoDevice SDL_VideoDevice;
 
-/* Define the SDL texture structure */
-struct SDL_Texture
-{
-    const void *magic;
-    Uint32 format;              /**< The pixel format of the texture */
-    int access;                 /**< SDL_TextureAccess */
-    int w;                      /**< The width of the texture */
-    int h;                      /**< The height of the texture */
-    int modMode;                /**< The texture modulation mode */
-    SDL_BlendMode blendMode;    /**< The texture blend mode */
-    Uint8 r, g, b, a;           /**< Texture modulation values */
-
-    SDL_Renderer *renderer;
-
-    void *driverdata;           /**< Driver specific texture representation */
-
-    SDL_Texture *prev;
-    SDL_Texture *next;
-};
-
-/* Define the SDL renderer structure */
-struct SDL_Renderer
-{
-    const void *magic;
-
-    void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
-    int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
-    int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
-                               void **pixels, int *pitch);
-    int (*SetTextureColorMod) (SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
-                                SDL_Texture * texture);
-    int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * rect, const void *pixels,
-                          int pitch);
-    int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
-                        const SDL_Rect * rect, int markDirty, void **pixels,
-                        int *pitch);
-    void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
-    void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
-                          int numrects, const SDL_Rect * rects);
-    int (*RenderClear) (SDL_Renderer * renderer);
-    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
-                             int count);
-    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
-                            int count);
-    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
-                            int count);
-    int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
-                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-    int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
-                             Uint32 format, void * pixels, int pitch);
-    int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
-                              Uint32 format, const void * pixels, int pitch);
-    void (*RenderPresent) (SDL_Renderer * renderer);
-    void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
-
-    void (*DestroyRenderer) (SDL_Renderer * renderer);
-
-    /* The current renderer info */
-    SDL_RendererInfo info;
-
-    /* The window associated with the renderer */
-    SDL_Window *window;
-
-    /* The list of textures */
-    SDL_Texture *textures;
-
-    Uint8 r, g, b, a;                   /**< Color for drawing operations values */
-    SDL_BlendMode blendMode;            /**< The drawing blend mode */
-
-    void *driverdata;
-};
-
-/* Define the SDL render driver structure */
-struct SDL_RenderDriver
-{
-    SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
-
-    /* Info about the renderer capabilities */
-    SDL_RendererInfo info;
-};
-
 /* Define the SDL window-shaper structure */
 struct SDL_WindowShaper
 {   
@@ -193,9 +102,6 @@
     Uint16 *gamma;
     Uint16 *saved_gamma;        /* (just offset into gamma) */
 
-    int num_render_drivers;
-    SDL_RenderDriver *render_drivers;
-
     SDL_Window *windows;
     SDL_Window *fullscreen_window;
 
@@ -327,8 +233,6 @@
     SDL_VideoDisplay *displays;
     int current_display;
     Uint8 window_magic;
-    Uint8 renderer_magic;
-    Uint8 texture_magic;
     Uint32 next_object_id;
     char * clipboard_text;
 
@@ -427,7 +331,6 @@
 extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
 extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
 extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
-extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver);
 
 extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
 
--- a/src/video/SDL_video.c	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/SDL_video.c	Wed Feb 02 14:34:54 2011 -0800
@@ -28,16 +28,8 @@
 #include "SDL_sysvideo.h"
 #include "SDL_blit.h"
 #include "SDL_pixels_c.h"
-#include "SDL_renderer_gl.h"
-#include "SDL_renderer_gles.h"
-#include "SDL_renderer_sw.h"
 #include "../events/SDL_events_c.h"
 
-#if SDL_VIDEO_DRIVER_WINDOWS
-#include "windows/SDL_windowsvideo.h"
-extern void IME_Present(SDL_VideoData *videodata);
-#endif
-
 #if SDL_VIDEO_OPENGL_ES
 #include "SDL_opengles.h"
 #endif /* SDL_VIDEO_OPENGL_ES */
@@ -100,22 +92,6 @@
         return retval; \
     }
 
-#define CHECK_RENDERER_MAGIC(renderer, retval) \
-    if (!renderer || renderer->magic != &_this->renderer_magic) { \
-        SDL_SetError("Invalid renderer"); \
-        return retval; \
-    }
-
-#define CHECK_TEXTURE_MAGIC(texture, retval) \
-    if (!_this) { \
-        SDL_UninitializedVideo(); \
-        return retval; \
-    } \
-    if (!texture || texture->magic != &_this->texture_magic) { \
-        SDL_SetError("Invalid texture"); \
-        return retval; \
-    }
-
 /* Various local functions */
 static void SDL_UpdateWindowGrab(SDL_Window * window);
 
@@ -258,21 +234,6 @@
         SDL_VideoQuit();
         return (-1);
     }
-    /* The software renderer is always available */
-    for (i = 0; i < _this->num_displays; ++i) {
-        SDL_VideoDisplay *display = &_this->displays[i];
-        if (_this->GL_CreateContext) {
-#if SDL_VIDEO_RENDER_OGL
-            SDL_AddRenderDriver(display, &GL_RenderDriver);
-#endif
-#if SDL_VIDEO_RENDER_OGL_ES
-            SDL_AddRenderDriver(display, &GL_ES_RenderDriver);
-#endif
-        }
-        if (display->num_render_drivers > 0) {
-            SDL_AddRenderDriver(display, &SW_RenderDriver);
-        }
-    }
 
     /* We're ready to go! */
     return 0;
@@ -723,6 +684,14 @@
     return 0;
 }
 
+Uint32
+SDL_GetWindowPixelFormat(SDL_Window * window)
+{
+    SDL_VideoDisplay *display = window->display;
+    SDL_DisplayMode *displayMode = &display->current_mode;
+    return displayMode->format;
+}
+
 static void
 SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
 {
@@ -1355,1100 +1324,6 @@
     SDL_free(window);
 }
 
-void
-SDL_AddRenderDriver(SDL_VideoDisplay * display, const SDL_RenderDriver * driver)
-{
-    SDL_RenderDriver *render_drivers;
-
-    render_drivers =
-        SDL_realloc(display->render_drivers,
-                    (display->num_render_drivers +
-                     1) * sizeof(*render_drivers));
-    if (render_drivers) {
-        render_drivers[display->num_render_drivers] = *driver;
-        display->render_drivers = render_drivers;
-        display->num_render_drivers++;
-    }
-}
-
-int
-SDL_GetNumRenderDrivers(void)
-{
-    if (_this) {
-        return SDL_CurrentDisplay->num_render_drivers;
-    }
-    return 0;
-}
-
-int
-SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
-{
-    if (!_this) {
-        SDL_UninitializedVideo();
-        return -1;
-    }
-    if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
-        SDL_SetError("index must be in the range of 0 - %d",
-                     SDL_GetNumRenderDrivers() - 1);
-        return -1;
-    }
-    *info = SDL_CurrentDisplay->render_drivers[index].info;
-    return 0;
-}
-
-static int
-SDL_RendererEventWatch(void *userdata, SDL_Event *event)
-{
-    SDL_Renderer *renderer = (SDL_Renderer *)userdata;
-
-    if (event->type == SDL_WINDOWEVENT && renderer->WindowEvent) {
-        SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
-        if (window == renderer->window) {
-            renderer->WindowEvent(renderer, &event->window);
-        }
-    }
-    return 0;
-}
-
-SDL_Renderer *
-SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
-{
-    SDL_Renderer *renderer = NULL;
-
-    CHECK_WINDOW_MAGIC(window, NULL);
-
-    if (index < 0) {
-        char *override = SDL_getenv("SDL_VIDEO_RENDERER");
-        int n = SDL_GetNumRenderDrivers();
-
-#if SDL_VIDEO_RENDER_OGL
-        if (!override && (window->flags & SDL_WINDOW_OPENGL)) {
-            override = "opengl";
-        }
-#endif /* SDL_VIDEO_RENDER_OGL */
-#if SDL_VIDEO_RENDER_OGL_ES
-        if (!override && (window->flags & SDL_WINDOW_OPENGL)) {
-            override = "opengl_es";
-        }
-#endif /* SDL_VIDEO_RENDER_OGL_ES */
-        if (override) {
-            for (index = 0; index < n; ++index) {
-                SDL_RenderDriver *driver =
-                    &SDL_CurrentDisplay->render_drivers[index];
-
-                if (SDL_strcasecmp(override, driver->info.name) == 0) {
-                    /* Create a new renderer instance */
-                    renderer = driver->CreateRenderer(window, flags);
-                    break;
-                }
-            }
-        } else {
-            for (index = 0; index < n; ++index) {
-                SDL_RenderDriver *driver =
-                    &SDL_CurrentDisplay->render_drivers[index];
-
-                if ((driver->info.flags & flags) == flags) {
-                    /* Create a new renderer instance */
-                    renderer = driver->CreateRenderer(window, flags);
-                    if (renderer) {
-                        /* Yay, we got one! */
-                        break;
-                    }
-                }
-            }
-        }
-        if (index == n) {
-            SDL_SetError("Couldn't find matching render driver");
-            return NULL;
-        }
-    } else {
-        if (index >= SDL_GetNumRenderDrivers()) {
-            SDL_SetError("index must be -1 or in the range of 0 - %d",
-                         SDL_GetNumRenderDrivers() - 1);
-            return NULL;
-        }
-        /* Create a new renderer instance */
-        renderer = SDL_CurrentDisplay->render_drivers[index].CreateRenderer(window, flags);
-    }
-
-    if (renderer) {
-        renderer->magic = &_this->renderer_magic;
-
-        SDL_AddEventWatch(SDL_RendererEventWatch, renderer);
-    }
-    return renderer;
-}
-
-int
-SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    *info = renderer->info;
-    return 0;
-}
-
-SDL_Texture *
-SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h)
-{
-    SDL_Texture *texture;
-
-    CHECK_RENDERER_MAGIC(renderer, NULL);
-
-    if (w <= 0 || h <= 0) {
-        SDL_SetError("Texture dimensions can't be 0");
-        return 0;
-    }
-    texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
-    if (!texture) {
-        SDL_OutOfMemory();
-        return 0;
-    }
-    texture->magic = &_this->texture_magic;
-    texture->format = format;
-    texture->access = access;
-    texture->w = w;
-    texture->h = h;
-    texture->r = 255;
-    texture->g = 255;
-    texture->b = 255;
-    texture->a = 255;
-    texture->renderer = renderer;
-    texture->next = renderer->textures;
-    if (renderer->textures) {
-        renderer->textures->prev = texture;
-    }
-    renderer->textures = texture;
-
-    if (renderer->CreateTexture(renderer, texture) < 0) {
-        SDL_DestroyTexture(texture);
-        return 0;
-    }
-    return texture;
-}
-
-SDL_Texture *
-SDL_CreateTextureFromSurface(SDL_Renderer * renderer, Uint32 format, SDL_Surface * surface)
-{
-    SDL_Texture *texture;
-    Uint32 requested_format = format;
-    SDL_PixelFormat *fmt;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    CHECK_RENDERER_MAGIC(renderer, NULL);
-
-    if (!surface) {
-        SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
-        return NULL;
-    }
-    fmt = surface->format;
-
-    if (format) {
-        if (!SDL_PixelFormatEnumToMasks
-            (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-            SDL_SetError("Unknown pixel format");
-            return 0;
-        }
-    } else {
-        if (surface->format->Amask
-            || !(surface->map->info.flags &
-                 (SDL_COPY_COLORKEY | SDL_COPY_BLEND))) {
-            Uint32 it;
-            int pfmt;
-
-            /* Pixel formats, sorted by best first */
-            static const Uint32 sdl_pformats[] = {
-                SDL_PIXELFORMAT_ARGB8888,
-                SDL_PIXELFORMAT_RGBA8888,
-                SDL_PIXELFORMAT_ABGR8888,
-                SDL_PIXELFORMAT_BGRA8888,
-                SDL_PIXELFORMAT_RGB888,
-                SDL_PIXELFORMAT_BGR888,
-                SDL_PIXELFORMAT_RGB24,
-                SDL_PIXELFORMAT_BGR24,
-                SDL_PIXELFORMAT_RGB565,
-                SDL_PIXELFORMAT_BGR565,
-                SDL_PIXELFORMAT_ARGB1555,
-                SDL_PIXELFORMAT_RGBA5551,
-                SDL_PIXELFORMAT_ABGR1555,
-                SDL_PIXELFORMAT_BGRA5551,
-                SDL_PIXELFORMAT_RGB555,
-                SDL_PIXELFORMAT_BGR555,
-                SDL_PIXELFORMAT_ARGB4444,
-                SDL_PIXELFORMAT_RGBA4444,
-                SDL_PIXELFORMAT_ABGR4444,
-                SDL_PIXELFORMAT_BGRA4444,
-                SDL_PIXELFORMAT_RGB444,
-                SDL_PIXELFORMAT_ARGB2101010,
-                SDL_PIXELFORMAT_RGB332,
-                SDL_PIXELFORMAT_UNKNOWN
-            };
-
-            bpp = fmt->BitsPerPixel;
-            Rmask = fmt->Rmask;
-            Gmask = fmt->Gmask;
-            Bmask = fmt->Bmask;
-            Amask = fmt->Amask;
-
-            format =
-                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
-            if (!format) {
-                SDL_SetError("Unknown pixel format");
-                return 0;
-            }
-
-            /* Search requested format in the supported texture */
-            /* formats by current renderer                      */
-            for (it = 0; it < renderer->info.num_texture_formats; it++) {
-                if (renderer->info.texture_formats[it] == format) {
-                    break;
-                }
-            }
-
-            /* If requested format can't be found, search any best */
-            /* format which renderer provides                      */
-            if (it == renderer->info.num_texture_formats) {
-                pfmt = 0;
-                for (;;) {
-                    if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) {
-                        break;
-                    }
-
-                    for (it = 0; it < renderer->info.num_texture_formats;
-                         it++) {
-                        if (renderer->info.texture_formats[it] ==
-                            sdl_pformats[pfmt]) {
-                            break;
-                        }
-                    }
-
-                    if (it != renderer->info.num_texture_formats) {
-                        /* The best format has been found */
-                        break;
-                    }
-                    pfmt++;
-                }
-
-                /* If any format can't be found, then return an error */
-                if (it == renderer->info.num_texture_formats) {
-                    SDL_SetError
-                        ("Any of the supported pixel formats can't be found");
-                    return 0;
-                }
-
-                /* Convert found pixel format back to color masks */
-                if (SDL_PixelFormatEnumToMasks
-                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
-                     &Bmask, &Amask) != SDL_TRUE) {
-                    SDL_SetError("Unknown pixel format");
-                    return 0;
-                }
-            }
-        } else {
-            /* Need a format with alpha */
-            Uint32 it;
-            int apfmt;
-
-            /* Pixel formats with alpha, sorted by best first */
-            static const Uint32 sdl_alpha_pformats[] = {
-                SDL_PIXELFORMAT_ARGB8888,
-                SDL_PIXELFORMAT_RGBA8888,
-                SDL_PIXELFORMAT_ABGR8888,
-                SDL_PIXELFORMAT_BGRA8888,
-                SDL_PIXELFORMAT_ARGB1555,
-                SDL_PIXELFORMAT_RGBA5551,
-                SDL_PIXELFORMAT_ABGR1555,
-                SDL_PIXELFORMAT_BGRA5551,
-                SDL_PIXELFORMAT_ARGB4444,
-                SDL_PIXELFORMAT_RGBA4444,
-                SDL_PIXELFORMAT_ABGR4444,
-                SDL_PIXELFORMAT_BGRA4444,
-                SDL_PIXELFORMAT_ARGB2101010,
-                SDL_PIXELFORMAT_UNKNOWN
-            };
-
-            if (surface->format->Amask) {
-                /* If surface already has alpha, then try an original */
-                /* surface format first                               */
-                bpp = fmt->BitsPerPixel;
-                Rmask = fmt->Rmask;
-                Gmask = fmt->Gmask;
-                Bmask = fmt->Bmask;
-                Amask = fmt->Amask;
-            } else {
-                bpp = 32;
-                Rmask = 0x00FF0000;
-                Gmask = 0x0000FF00;
-                Bmask = 0x000000FF;
-                Amask = 0xFF000000;
-            }
-
-            format =
-                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
-            if (!format) {
-                SDL_SetError("Unknown pixel format");
-                return 0;
-            }
-
-            /* Search this format in the supported texture formats */
-            /* by current renderer                                 */
-            for (it = 0; it < renderer->info.num_texture_formats; it++) {
-                if (renderer->info.texture_formats[it] == format) {
-                    break;
-                }
-            }
-
-            /* If this format can't be found, search any best       */
-            /* compatible format with alpha which renderer provides */
-            if (it == renderer->info.num_texture_formats) {
-                apfmt = 0;
-                for (;;) {
-                    if (sdl_alpha_pformats[apfmt] == SDL_PIXELFORMAT_UNKNOWN) {
-                        break;
-                    }
-
-                    for (it = 0; it < renderer->info.num_texture_formats;
-                         it++) {
-                        if (renderer->info.texture_formats[it] ==
-                            sdl_alpha_pformats[apfmt]) {
-                            break;
-                        }
-                    }
-
-                    if (it != renderer->info.num_texture_formats) {
-                        /* Compatible format has been found */
-                        break;
-                    }
-                    apfmt++;
-                }
-
-                /* If compatible format can't be found, then return an error */
-                if (it == renderer->info.num_texture_formats) {
-                    SDL_SetError("Compatible pixel format can't be found");
-                    return 0;
-                }
-
-                /* Convert found pixel format back to color masks */
-                if (SDL_PixelFormatEnumToMasks
-                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
-                     &Bmask, &Amask) != SDL_TRUE) {
-                    SDL_SetError("Unknown pixel format");
-                    return 0;
-                }
-            }
-        }
-
-        format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
-        if (!format) {
-            SDL_SetError("Unknown pixel format");
-            return 0;
-        }
-    }
-
-    texture =
-        SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
-                          surface->w, surface->h);
-    if (!texture && !requested_format) {
-        SDL_DisplayMode desktop_mode;
-        SDL_GetDesktopDisplayMode(&desktop_mode);
-        format = desktop_mode.format;
-        texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
-                                    surface->w, surface->h);
-    }
-    if (!texture) {
-        return 0;
-    }
-    if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
-        && Bmask == fmt->Bmask && Amask == fmt->Amask) {
-        if (SDL_MUSTLOCK(surface)) {
-            SDL_LockSurface(surface);
-            SDL_UpdateTexture(texture, NULL, surface->pixels,
-                              surface->pitch);
-            SDL_UnlockSurface(surface);
-        } else {
-            SDL_UpdateTexture(texture, NULL, surface->pixels,
-                              surface->pitch);
-        }
-    } else {
-        SDL_PixelFormat dst_fmt;
-        SDL_Surface *dst = NULL;
-
-        /* Set up a destination surface for the texture update */
-        SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
-        dst = SDL_ConvertSurface(surface, &dst_fmt, 0);
-        if (dst) {
-            SDL_UpdateTexture(texture, NULL, dst->pixels, dst->pitch);
-            SDL_FreeSurface(dst);
-        }
-        if (!dst) {
-            SDL_DestroyTexture(texture);
-            return 0;
-        }
-    }
-
-    {
-        Uint8 r, g, b, a;
-        SDL_BlendMode blendMode;
-
-        SDL_GetSurfaceColorMod(surface, &r, &g, &b);
-        SDL_SetTextureColorMod(texture, r, g, b);
-
-        SDL_GetSurfaceAlphaMod(surface, &a);
-        SDL_SetTextureAlphaMod(texture, a);
-
-        if (surface->map->info.flags & SDL_COPY_COLORKEY) {
-            /* We converted to a texture with alpha format */
-            SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
-        } else {
-            SDL_GetSurfaceBlendMode(surface, &blendMode);
-            SDL_SetTextureBlendMode(texture, blendMode);
-        }
-    }
-    return texture;
-}
-
-int
-SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access,
-                 int *w, int *h)
-{
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (format) {
-        *format = texture->format;
-    }
-    if (access) {
-        *access = texture->access;
-    }
-    if (w) {
-        *w = texture->w;
-    }
-    if (h) {
-        *h = texture->h;
-    }
-    return 0;
-}
-
-int
-SDL_QueryTexturePixels(SDL_Texture * texture, void **pixels, int *pitch)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->QueryTexturePixels) {
-        SDL_Unsupported();
-        return -1;
-    }
-    return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
-}
-
-int
-SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (r < 255 || g < 255 || b < 255) {
-        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
-    } else {
-        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
-    }
-    texture->r = r;
-    texture->g = g;
-    texture->b = b;
-    if (renderer->SetTextureColorMod) {
-        return renderer->SetTextureColorMod(renderer, texture);
-    } else {
-        return 0;
-    }
-}
-
-int
-SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g,
-                       Uint8 * b)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (r) {
-        *r = texture->r;
-    }
-    if (g) {
-        *g = texture->g;
-    }
-    if (b) {
-        *b = texture->b;
-    }
-    return 0;
-}
-
-int
-SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (alpha < 255) {
-        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
-    } else {
-        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
-    }
-    texture->a = alpha;
-    if (renderer->SetTextureAlphaMod) {
-        return renderer->SetTextureAlphaMod(renderer, texture);
-    } else {
-        return 0;
-    }
-}
-
-int
-SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha)
-{
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (alpha) {
-        *alpha = texture->a;
-    }
-    return 0;
-}
-
-int
-SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    texture->blendMode = blendMode;
-    if (renderer->SetTextureBlendMode) {
-        return renderer->SetTextureBlendMode(renderer, texture);
-    } else {
-        return 0;
-    }
-}
-
-int
-SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode)
-{
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (blendMode) {
-        *blendMode = texture->blendMode;
-    }
-    return 0;
-}
-
-int
-SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
-                  const void *pixels, int pitch)
-{
-    SDL_Renderer *renderer;
-    SDL_Rect full_rect;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    renderer = texture->renderer;
-    if (!renderer->UpdateTexture) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (!rect) {
-        full_rect.x = 0;
-        full_rect.y = 0;
-        full_rect.w = texture->w;
-        full_rect.h = texture->h;
-        rect = &full_rect;
-    }
-    return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
-}
-
-int
-SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, int markDirty,
-                void **pixels, int *pitch)
-{
-    SDL_Renderer *renderer;
-    SDL_Rect full_rect;
-
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
-        SDL_SetError("SDL_LockTexture(): texture must be streaming");
-        return -1;
-    }
-    renderer = texture->renderer;
-    if (!renderer->LockTexture) {
-        SDL_Unsupported();
-        return -1;
-    }
-    if (!rect) {
-        full_rect.x = 0;
-        full_rect.y = 0;
-        full_rect.w = texture->w;
-        full_rect.h = texture->h;
-        rect = &full_rect;
-    }
-    return renderer->LockTexture(renderer, texture, rect, markDirty, pixels,
-                                 pitch);
-}
-
-void
-SDL_UnlockTexture(SDL_Texture * texture)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, );
-
-    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
-        return;
-    }
-    renderer = texture->renderer;
-    if (!renderer->UnlockTexture) {
-        return;
-    }
-    renderer->UnlockTexture(renderer, texture);
-}
-
-void
-SDL_DirtyTexture(SDL_Texture * texture, int numrects,
-                 const SDL_Rect * rects)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, );
-
-    if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
-        return;
-    }
-    renderer = texture->renderer;
-    if (!renderer->DirtyTexture) {
-        return;
-    }
-    renderer->DirtyTexture(renderer, texture, numrects, rects);
-}
-
-int
-SDL_SetRenderDrawColor(SDL_Renderer * renderer,
-                       Uint8 r, Uint8 g, Uint8 b, Uint8 a)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    renderer->r = r;
-    renderer->g = g;
-    renderer->b = b;
-    renderer->a = a;
-    return 0;
-}
-
-int
-SDL_GetRenderDrawColor(SDL_Renderer * renderer,
-                       Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (r) {
-        *r = renderer->r;
-    }
-    if (g) {
-        *g = renderer->g;
-    }
-    if (b) {
-        *b = renderer->b;
-    }
-    if (a) {
-        *a = renderer->a;
-    }
-    return 0;
-}
-
-int
-SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    renderer->blendMode = blendMode;
-    return 0;
-}
-
-int
-SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    *blendMode = renderer->blendMode;
-    return 0;
-}
-
-int
-SDL_RenderClear(SDL_Renderer * renderer)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!renderer->RenderClear) {
-        SDL_BlendMode blendMode = renderer->blendMode;
-        int status;
-
-        if (blendMode >= SDL_BLENDMODE_BLEND) {
-            SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
-        }
-
-        status = SDL_RenderFillRect(renderer, NULL);
-
-        if (blendMode >= SDL_BLENDMODE_BLEND) {
-            SDL_SetRenderDrawBlendMode(renderer, blendMode);
-        }
-        return status;
-    }
-    return renderer->RenderClear(renderer);
-}
-
-int
-SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y)
-{
-    SDL_Point point;
-
-    point.x = x;
-    point.y = y;
-    return SDL_RenderDrawPoints(renderer, &point, 1);
-}
-
-int
-SDL_RenderDrawPoints(SDL_Renderer * renderer,
-                     const SDL_Point * points, int count)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!points) {
-        SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
-        return -1;
-    }
-    if (count < 1) {
-        return 0;
-    }
-    return renderer->RenderDrawPoints(renderer, points, count);
-}
-
-int
-SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
-{
-    SDL_Point points[2];
-
-    points[0].x = x1;
-    points[0].y = y1;
-    points[1].x = x2;
-    points[1].y = y2;
-    return SDL_RenderDrawLines(renderer, points, 2);
-}
-
-int
-SDL_RenderDrawLines(SDL_Renderer * renderer,
-                    const SDL_Point * points, int count)
-{
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!points) {
-        SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
-        return -1;
-    }
-    if (count < 2) {
-        return 0;
-    }
-    return renderer->RenderDrawLines(renderer, points, count);
-}
-
-int
-SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect)
-{
-    SDL_Rect full_rect;
-    SDL_Point points[5];
-
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    /* If 'rect' == NULL, then outline the whole surface */
-    if (!rect) {
-        SDL_Window *window = renderer->window;
-
-        full_rect.x = 0;
-        full_rect.y = 0;
-        full_rect.w = window->w;
-        full_rect.h = window->h;
-        rect = &full_rect;
-    }
-
-    points[0].x = rect->x;
-    points[0].y = rect->y;
-    points[1].x = rect->x+rect->w-1;
-    points[1].y = rect->y;
-    points[2].x = rect->x+rect->w-1;
-    points[2].y = rect->y+rect->h-1;
-    points[3].x = rect->x;
-    points[3].y = rect->y+rect->h-1;
-    points[4].x = rect->x;
-    points[4].y = rect->y;
-    return SDL_RenderDrawLines(renderer, points, 5);
-}
-
-int
-SDL_RenderDrawRects(SDL_Renderer * renderer,
-                    const SDL_Rect ** rects, int count)
-{
-    int i;
-
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!rects) {
-        SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
-        return -1;
-    }
-    if (count < 1) {
-        return 0;
-    }
-
-    /* Check for NULL rect, which means fill entire window */
-    for (i = 0; i < count; ++i) {
-        if (SDL_RenderDrawRect(renderer, rects[i]) < 0) {
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int
-SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect)
-{
-    return SDL_RenderFillRects(renderer, &rect, 1);
-}
-
-int
-SDL_RenderFillRects(SDL_Renderer * renderer,
-                    const SDL_Rect ** rects, int count)
-{
-    int i;
-
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!rects) {
-        SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
-        return -1;
-    }
-    if (count < 1) {
-        return 0;
-    }
-
-    /* Check for NULL rect, which means fill entire window */
-    for (i = 0; i < count; ++i) {
-        if (rects[i] == NULL) {
-            SDL_Window *window = renderer->window;
-            SDL_Rect full_rect;
-            const SDL_Rect *rect;
-
-            full_rect.x = 0;
-            full_rect.y = 0;
-            full_rect.w = window->w;
-            full_rect.h = window->h;
-            rect = &full_rect;
-            return renderer->RenderFillRects(renderer, &rect, 1);
-        }
-    }
-    return renderer->RenderFillRects(renderer, rects, count);
-}
-
-int
-SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    SDL_Window *window;
-    SDL_Rect real_srcrect;
-    SDL_Rect real_dstrect;
-
-    CHECK_RENDERER_MAGIC(renderer, -1);
-    CHECK_TEXTURE_MAGIC(texture, -1);
-
-    if (renderer != texture->renderer) {
-        SDL_SetError("Texture was not created with this renderer");
-        return -1;
-    }
-    window = renderer->window;
-
-    real_srcrect.x = 0;
-    real_srcrect.y = 0;
-    real_srcrect.w = texture->w;
-    real_srcrect.h = texture->h;
-    if (srcrect) {
-        if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
-            return 0;
-        }
-    }
-
-    real_dstrect.x = 0;
-    real_dstrect.y = 0;
-    real_dstrect.w = window->w;
-    real_dstrect.h = window->h;
-    if (dstrect) {
-        if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
-            return 0;
-        }
-        /* Clip srcrect by the same amount as dstrect was clipped */
-        if (dstrect->w != real_dstrect.w) {
-            int deltax = (real_dstrect.x - dstrect->x);
-            int deltaw = (real_dstrect.w - dstrect->w);
-            real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
-            real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;
-        }
-        if (dstrect->h != real_dstrect.h) {
-            int deltay = (real_dstrect.y - dstrect->y);
-            int deltah = (real_dstrect.h - dstrect->h);
-            real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h;
-            real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h;
-        }
-    }
-
-    return renderer->RenderCopy(renderer, texture, &real_srcrect,
-                                &real_dstrect);
-}
-
-int
-SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, void * pixels, int pitch)
-{
-    SDL_Window *window;
-    SDL_Rect real_rect;
-
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!renderer->RenderReadPixels) {
-        SDL_Unsupported();
-        return -1;
-    }
-    window = renderer->window;
-
-    if (!format) {
-        format = window->display->current_mode.format;
-    }
-
-    real_rect.x = 0;
-    real_rect.y = 0;
-    real_rect.w = window->w;
-    real_rect.h = window->h;
-    if (rect) {
-        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
-            return 0;
-        }
-        if (real_rect.y > rect->y) {
-            pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
-        }
-        if (real_rect.x > rect->x) {
-            Uint32 format = SDL_CurrentDisplay->current_mode.format;
-            int bpp = SDL_BYTESPERPIXEL(format);
-            pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
-        }
-    }
-
-    return renderer->RenderReadPixels(renderer, &real_rect,
-                                      format, pixels, pitch);
-}
-
-int
-SDL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                      Uint32 format, const void * pixels, int pitch)
-{
-    SDL_Window *window;
-    SDL_Rect real_rect;
-
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!renderer->RenderWritePixels) {
-        SDL_Unsupported();
-        return -1;
-    }
-    window = renderer->window;
-
-    if (!format) {
-        format = window->display->current_mode.format;
-    }
-
-    real_rect.x = 0;
-    real_rect.y = 0;
-    real_rect.w = window->w;
-    real_rect.h = window->h;
-    if (rect) {
-        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
-            return 0;
-        }
-        if (real_rect.y > rect->y) {
-            pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y);
-        }
-        if (real_rect.x > rect->x) {
-            Uint32 format = SDL_CurrentDisplay->current_mode.format;
-            int bpp = SDL_BYTESPERPIXEL(format);
-            pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x);
-        }
-    }
-
-    return renderer->RenderWritePixels(renderer, &real_rect,
-                                       format, pixels, pitch);
-}
-
-void
-SDL_RenderPresent(SDL_Renderer * renderer)
-{
-    CHECK_RENDERER_MAGIC(renderer, );
-
-#if SDL_VIDEO_DRIVER_WINDOWS
-    IME_Present((SDL_VideoData *)_this->driverdata);
-#endif
-    renderer->RenderPresent(renderer);
-}
-
-void
-SDL_DestroyTexture(SDL_Texture * texture)
-{
-    SDL_Renderer *renderer;
-
-    CHECK_TEXTURE_MAGIC(texture, );
-    texture->magic = NULL;
-
-    renderer = texture->renderer;
-    if (texture->next) {
-        texture->next->prev = texture->prev;
-    }
-    if (texture->prev) {
-        texture->prev->next = texture->next;
-    } else {
-        renderer->textures = texture->next;
-    }
-
-    renderer->DestroyTexture(renderer, texture);
-    SDL_free(texture);
-}
-
-void
-SDL_DestroyRenderer(SDL_Renderer * renderer)
-{
-    CHECK_RENDERER_MAGIC(renderer, );
-
-    SDL_DelEventWatch(SDL_RendererEventWatch, renderer);
-
-    /* Free existing textures for this renderer */
-    while (renderer->textures) {
-        SDL_DestroyTexture(renderer->textures);
-    }
-
-    /* It's no longer magical... */
-    renderer->magic = NULL;
-
-    /* Free the renderer instance */
-    renderer->DestroyRenderer(renderer);
-}
-
 SDL_bool
 SDL_IsScreenSaverEnabled()
 {
@@ -2511,11 +1386,6 @@
         while (display->windows) {
             SDL_DestroyWindow(display->windows);
         }
-        if (display->render_drivers) {
-            SDL_free(display->render_drivers);
-            display->render_drivers = NULL;
-        }
-        display->num_render_drivers = 0;
     }
     _this->VideoQuit(_this);
 
--- a/src/video/directfb/SDL_DirectFB_render.c	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_render.c	Wed Feb 02 14:34:54 2011 -0800
@@ -26,7 +26,6 @@
 
 #include "SDL_DirectFB_video.h"
 #include "SDL_DirectFB_render.h"
-#include "../SDL_rect_c.h"
 #include "../SDL_yuv_sw_c.h"
 
 /* the following is not yet tested ... */
--- a/src/video/dummy/SDL_nullrender.c	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,288 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_video.h"
-#include "../SDL_sysvideo.h"
-#include "../SDL_yuv_sw_c.h"
-#include "../SDL_renderer_sw.h"
-
-
-/* SDL surface based renderer implementation */
-
-static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
-                                              Uint32 flags);
-static int SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
-                                      const SDL_Point * points, int count);
-static int SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
-                                     const SDL_Point * points, int count);
-static int SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer,
-                                     const SDL_Rect ** rects, int count);
-static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
-                                SDL_Texture * texture,
-                                const SDL_Rect * srcrect,
-                                const SDL_Rect * dstrect);
-static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer,
-                                      const SDL_Rect * rect,
-                                      Uint32 format,
-                                      void * pixels, int pitch);
-static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer,
-                                       const SDL_Rect * rect,
-                                       Uint32 format,
-                                       const void * pixels, int pitch);
-static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer);
-static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver SDL_DUMMY_RenderDriver = {
-    SDL_DUMMY_CreateRenderer,
-    {
-     "dummy",
-     (0),
-     }
-};
-
-typedef struct
-{
-    SDL_Surface *screen;
-} SDL_DUMMY_RenderData;
-
-SDL_Renderer *
-SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_DisplayMode *displayMode = &display->current_mode;
-    SDL_Renderer *renderer;
-    SDL_DUMMY_RenderData *data;
-    int bpp;
-    Uint32 Rmask, Gmask, Bmask, Amask;
-
-    if (!SDL_PixelFormatEnumToMasks
-        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
-        SDL_SetError("Unknown display format");
-        return NULL;
-    }
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (SDL_DUMMY_RenderData *) SDL_malloc(sizeof(*data));
-    if (!data) {
-        SDL_DUMMY_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    SDL_zerop(data);
-
-    renderer->RenderDrawPoints = SDL_DUMMY_RenderDrawPoints;
-    renderer->RenderDrawLines = SDL_DUMMY_RenderDrawLines;
-    renderer->RenderFillRects = SDL_DUMMY_RenderFillRects;
-    renderer->RenderCopy = SDL_DUMMY_RenderCopy;
-    renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels;
-    renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels;
-    renderer->RenderPresent = SDL_DUMMY_RenderPresent;
-    renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer;
-    renderer->info.name = SDL_DUMMY_RenderDriver.info.name;
-    renderer->info.flags = 0;
-    renderer->window = window;
-    renderer->driverdata = data;
-    Setup_SoftwareRenderer(renderer);
-
-    data->screen =
-        SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
-                             Bmask, Amask);
-    if (!data->screen) {
-        SDL_DUMMY_DestroyRenderer(renderer);
-        return NULL;
-    }
-
-    return renderer;
-}
-
-static int
-SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
-                           const SDL_Point * points, int count)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Surface *target = data->screen;
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
-        Uint32 color = SDL_MapRGBA(target->format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        return SDL_DrawPoints(target, points, count, color);
-    } else {
-        return SDL_BlendPoints(target, points, count, renderer->blendMode,
-                               renderer->r, renderer->g, renderer->b,
-                               renderer->a);
-    }
-}
-
-static int
-SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
-                          const SDL_Point * points, int count)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Surface *target = data->screen;
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
-        Uint32 color = SDL_MapRGBA(target->format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        return SDL_DrawLines(target, points, count, color);
-    } else {
-        return SDL_BlendLines(target, points, count, renderer->blendMode,
-                              renderer->r, renderer->g, renderer->b,
-                              renderer->a);
-    }
-}
-
-static int
-SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                          int count)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Surface *target = data->screen;
-
-    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
-        Uint32 color = SDL_MapRGBA(target->format,
-                                   renderer->r, renderer->g, renderer->b,
-                                   renderer->a);
-
-        return SDL_FillRects(target, rects, count, color);
-    } else {
-        return SDL_BlendFillRects(target, rects, count,
-                                  renderer->blendMode,
-                                  renderer->r, renderer->g, renderer->b,
-                                  renderer->a);
-    }
-}
-
-static int
-SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-        SDL_Surface *target = data->screen;
-        void *pixels =
-            (Uint8 *) target->pixels + dstrect->y * target->pitch +
-            dstrect->x * target->format->BytesPerPixel;
-        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
-                                   srcrect, display->current_mode.format,
-                                   dstrect->w, dstrect->h, pixels,
-                                   target->pitch);
-    } else {
-        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
-        SDL_Surface *target = data->screen;
-        SDL_Rect real_srcrect = *srcrect;
-        SDL_Rect real_dstrect = *dstrect;
-
-        return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
-    }
-}
-
-static int
-SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                           Uint32 format, void * pixels, int pitch)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    SDL_Surface *screen = data->screen;
-    Uint32 screen_format = display->current_mode.format;
-    Uint8 *screen_pixels = (Uint8 *) screen->pixels +
-                            rect->y * screen->pitch +
-                            rect->x * screen->format->BytesPerPixel;
-    int screen_pitch = screen->pitch;
-
-    return SDL_ConvertPixels(rect->w, rect->h,
-                             screen_format, screen_pixels, screen_pitch,
-                             format, pixels, pitch);
-}
-
-static int
-SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                            Uint32 format, const void * pixels, int pitch)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    SDL_Surface *screen = data->screen;
-    Uint32 screen_format = display->current_mode.format;
-    Uint8 *screen_pixels = (Uint8 *) screen->pixels +
-                            rect->y * screen->pitch +
-                            rect->x * screen->format->BytesPerPixel;
-    int screen_pitch = screen->pitch;
-
-    return SDL_ConvertPixels(rect->w, rect->h,
-                             format, pixels, pitch,
-                             screen_format, screen_pixels, screen_pitch);
-}
-
-static void
-SDL_DUMMY_RenderPresent(SDL_Renderer * renderer)
-{
-    static int frame_number;
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-
-    /* Send the data to the display */
-    if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
-        char file[128];
-        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
-                     renderer->window->id, ++frame_number);
-        SDL_SaveBMP(data->screen, file);
-    }
-}
-
-static void
-SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
-{
-    SDL_DUMMY_RenderData *data =
-        (SDL_DUMMY_RenderData *) renderer->driverdata;
-    int i;
-
-    if (data) {
-        if (data->screen) {
-            SDL_FreeSurface(data->screen);
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/dummy/SDL_nullrender_c.h	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* SDL surface based renderer implementation */
-
-extern SDL_RenderDriver SDL_DUMMY_RenderDriver;
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/dummy/SDL_nullvideo.c	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/dummy/SDL_nullvideo.c	Wed Feb 02 14:34:54 2011 -0800
@@ -44,7 +44,6 @@
 
 #include "SDL_nullvideo.h"
 #include "SDL_nullevents_c.h"
-#include "SDL_nullrender_c.h"
 
 #define DUMMYVID_DRIVER_NAME "dummy"
 
@@ -118,7 +117,6 @@
     if (SDL_AddBasicVideoDisplay(&mode) < 0) {
         return -1;
     }
-    SDL_AddRenderDriver(&_this->displays[0], &SDL_DUMMY_RenderDriver);
 
     SDL_zero(mode);
     SDL_AddDisplayMode(&_this->displays[0], &mode);
--- a/src/video/uikit/SDL_uikitvideo.m	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/uikit/SDL_uikitvideo.m	Wed Feb 02 14:34:54 2011 -0800
@@ -35,9 +35,6 @@
 #include "SDL_uikitwindow.h"
 #include "SDL_uikitopengles.h"
 
-#include "SDL_renderer_sw.h"
-#include "SDL_renderer_gles.h"
-
 #include "SDL_assert.h"
 
 #define UIKITVID_DRIVER_NAME "uikit"
--- a/src/video/uikit/SDL_uikitwindow.m	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/uikit/SDL_uikitwindow.m	Wed Feb 02 14:34:54 2011 -0800
@@ -35,7 +35,6 @@
 #import "SDL_uikitappdelegate.h"
 
 #import "SDL_uikitopenglview.h"
-#import "SDL_renderer_sw.h"
 
 #include <Foundation/Foundation.h>
 
--- a/src/video/windows/SDL_d3drender.c	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1271 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_D3D
-
-#include "SDL_windowsvideo.h"
-#include "../SDL_yuv_sw_c.h"
-
-#ifdef ASSEMBLE_SHADER
-///////////////////////////////////////////////////////////////////////////
-// ID3DXBuffer:
-// ------------
-// The buffer object is used by D3DX to return arbitrary size data.
-//
-// GetBufferPointer -
-//    Returns a pointer to the beginning of the buffer.
-//
-// GetBufferSize -
-//    Returns the size of the buffer, in bytes.
-///////////////////////////////////////////////////////////////////////////
-
-typedef interface ID3DXBuffer ID3DXBuffer;
-typedef interface ID3DXBuffer *LPD3DXBUFFER;
-
-// {8BA5FB08-5195-40e2-AC58-0D989C3A0102}
-DEFINE_GUID(IID_ID3DXBuffer, 
-0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2);
-
-#undef INTERFACE
-#define INTERFACE ID3DXBuffer
-
-typedef interface ID3DXBuffer {
-    const struct ID3DXBufferVtbl FAR* lpVtbl;
-} ID3DXBuffer;
-typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl;
-const struct ID3DXBufferVtbl
-{
-    // IUnknown
-    STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
-    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG, Release)(THIS) PURE;
-
-    // ID3DXBuffer
-    STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
-    STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
-};
-
-HRESULT WINAPI
-    D3DXAssembleShader(
-        LPCSTR                          pSrcData,
-        UINT                            SrcDataLen,
-        CONST LPVOID*                   pDefines,
-        LPVOID                          pInclude,
-        DWORD                           Flags,
-        LPD3DXBUFFER*                   ppShader,
-        LPD3DXBUFFER*                   ppErrorMsgs);
-
-#endif /* ASSEMBLE_SHADER */
-
-
-/* Direct3D renderer implementation */
-
-#if 1                           /* This takes more memory but you won't lose your texture data */
-#define D3DPOOL_SDL    D3DPOOL_MANAGED
-#define SDL_MEMORY_POOL_MANAGED
-#else
-#define D3DPOOL_SDL    D3DPOOL_DEFAULT
-#define SDL_MEMORY_POOL_DEFAULT
-#endif
-
-static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
-static int D3D_DisplayModeChanged(SDL_Renderer * renderer);
-static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static int D3D_QueryTexturePixels(SDL_Renderer * renderer,
-                                  SDL_Texture * texture, void **pixels,
-                                  int *pitch);
-static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                             const SDL_Rect * rect, const void *pixels,
-                             int pitch);
-static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                           const SDL_Rect * rect, int markDirty,
-                           void **pixels, int *pitch);
-static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
-static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                             int numrects, const SDL_Rect * rects);
-static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
-                                const SDL_Point * points, int count);
-static int D3D_RenderDrawLines(SDL_Renderer * renderer,
-                               const SDL_Point * points, int count);
-static int D3D_RenderFillRects(SDL_Renderer * renderer,
-                               const SDL_Rect ** rects, int count);
-static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
-static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 format, void * pixels, int pitch);
-static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                 Uint32 format, const void * pixels, int pitch);
-static void D3D_RenderPresent(SDL_Renderer * renderer);
-static void D3D_DestroyTexture(SDL_Renderer * renderer,
-                               SDL_Texture * texture);
-static void D3D_DestroyRenderer(SDL_Renderer * renderer);
-
-
-SDL_RenderDriver D3D_RenderDriver = {
-    D3D_CreateRenderer,
-    {
-     "d3d",
-     (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
-     0,
-     {0},
-     0,
-     0}
-};
-
-typedef struct
-{
-    IDirect3D9 *d3d;
-    IDirect3DDevice9 *device;
-    UINT adapter;
-    D3DPRESENT_PARAMETERS pparams;
-    SDL_bool beginScene;
-} D3D_RenderData;
-
-typedef struct
-{
-    SDL_SW_YUVTexture *yuv;
-    Uint32 format;
-    IDirect3DTexture9 *texture;
-} D3D_TextureData;
-
-typedef struct
-{
-    float x, y, z;
-    float rhw;
-    DWORD color;
-    float u, v;
-} Vertex;
-
-static void
-D3D_SetError(const char *prefix, HRESULT result)
-{
-    const char *error;
-
-    switch (result) {
-    case D3DERR_WRONGTEXTUREFORMAT:
-        error = "WRONGTEXTUREFORMAT";
-        break;
-    case D3DERR_UNSUPPORTEDCOLOROPERATION:
-        error = "UNSUPPORTEDCOLOROPERATION";
-        break;
-    case D3DERR_UNSUPPORTEDCOLORARG:
-        error = "UNSUPPORTEDCOLORARG";
-        break;
-    case D3DERR_UNSUPPORTEDALPHAOPERATION:
-        error = "UNSUPPORTEDALPHAOPERATION";
-        break;
-    case D3DERR_UNSUPPORTEDALPHAARG:
-        error = "UNSUPPORTEDALPHAARG";
-        break;
-    case D3DERR_TOOMANYOPERATIONS:
-        error = "TOOMANYOPERATIONS";
-        break;
-    case D3DERR_CONFLICTINGTEXTUREFILTER:
-        error = "CONFLICTINGTEXTUREFILTER";
-        break;
-    case D3DERR_UNSUPPORTEDFACTORVALUE:
-        error = "UNSUPPORTEDFACTORVALUE";
-        break;
-    case D3DERR_CONFLICTINGRENDERSTATE:
-        error = "CONFLICTINGRENDERSTATE";
-        break;
-    case D3DERR_UNSUPPORTEDTEXTUREFILTER:
-        error = "UNSUPPORTEDTEXTUREFILTER";
-        break;
-    case D3DERR_CONFLICTINGTEXTUREPALETTE:
-        error = "CONFLICTINGTEXTUREPALETTE";
-        break;
-    case D3DERR_DRIVERINTERNALERROR:
-        error = "DRIVERINTERNALERROR";
-        break;
-    case D3DERR_NOTFOUND:
-        error = "NOTFOUND";
-        break;
-    case D3DERR_MOREDATA:
-        error = "MOREDATA";
-        break;
-    case D3DERR_DEVICELOST:
-        error = "DEVICELOST";
-        break;
-    case D3DERR_DEVICENOTRESET:
-        error = "DEVICENOTRESET";
-        break;
-    case D3DERR_NOTAVAILABLE:
-        error = "NOTAVAILABLE";
-        break;
-    case D3DERR_OUTOFVIDEOMEMORY:
-        error = "OUTOFVIDEOMEMORY";
-        break;
-    case D3DERR_INVALIDDEVICE:
-        error = "INVALIDDEVICE";
-        break;
-    case D3DERR_INVALIDCALL:
-        error = "INVALIDCALL";
-        break;
-    case D3DERR_DRIVERINVALIDCALL:
-        error = "DRIVERINVALIDCALL";
-        break;
-    case D3DERR_WASSTILLDRAWING:
-        error = "WASSTILLDRAWING";
-        break;
-    default:
-        error = "UNKNOWN";
-        break;
-    }
-    SDL_SetError("%s: %s", prefix, error);
-}
-
-static D3DFORMAT
-PixelFormatToD3DFMT(Uint32 format)
-{
-    switch (format) {
-    case SDL_PIXELFORMAT_INDEX8:
-        return D3DFMT_P8;
-    case SDL_PIXELFORMAT_RGB332:
-        return D3DFMT_R3G3B2;
-    case SDL_PIXELFORMAT_RGB444:
-        return D3DFMT_X4R4G4B4;
-    case SDL_PIXELFORMAT_RGB555:
-        return D3DFMT_X1R5G5B5;
-    case SDL_PIXELFORMAT_ARGB4444:
-        return D3DFMT_A4R4G4B4;
-    case SDL_PIXELFORMAT_ARGB1555:
-        return D3DFMT_A1R5G5B5;
-    case SDL_PIXELFORMAT_RGB565:
-        return D3DFMT_R5G6B5;
-    case SDL_PIXELFORMAT_RGB888:
-        return D3DFMT_X8R8G8B8;
-    case SDL_PIXELFORMAT_ARGB8888:
-        return D3DFMT_A8R8G8B8;
-    case SDL_PIXELFORMAT_ARGB2101010:
-        return D3DFMT_A2R10G10B10;
-    case SDL_PIXELFORMAT_YV12:
-        return MAKEFOURCC('Y','V','1','2');
-    case SDL_PIXELFORMAT_IYUV:
-        return MAKEFOURCC('I','4','2','0');
-    case SDL_PIXELFORMAT_UYVY:
-        return D3DFMT_UYVY;
-    case SDL_PIXELFORMAT_YUY2:
-        return D3DFMT_YUY2;
-    default:
-        return D3DFMT_UNKNOWN;
-    }
-}
-
-static UINT D3D_FindAdapter(IDirect3D9 * d3d, SDL_VideoDisplay * display)
-{
-    SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
-    UINT adapter, count;
-
-    count = IDirect3D9_GetAdapterCount(d3d);
-    for (adapter = 0; adapter < count; ++adapter) {
-        HRESULT result;
-        D3DADAPTER_IDENTIFIER9 info;
-        char *name;
-
-        result = IDirect3D9_GetAdapterIdentifier(d3d, adapter, 0, &info);
-        if (FAILED(result)) {
-            continue;
-        }
-        name = WIN_StringToUTF8(displaydata->DeviceName);
-        if (SDL_strcmp(name, info.DeviceName) == 0) {
-            SDL_free(name);
-            return adapter;
-        }
-        SDL_free(name);
-    }
-
-    /* This should never happen, but just in case... */
-    return D3DADAPTER_DEFAULT;
-}
-
-static SDL_bool
-D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, UINT adapter,
-                             Uint32 display_format,
-                             Uint32 texture_format)
-{
-    HRESULT result;
-
-    result = IDirect3D9_CheckDeviceFormat(d3d, adapter,
-                                          D3DDEVTYPE_HAL,
-                                          PixelFormatToD3DFMT(display_format),
-                                          0,
-                                          D3DRTYPE_TEXTURE,
-                                          PixelFormatToD3DFMT
-                                          (texture_format));
-    return FAILED(result) ? SDL_FALSE : SDL_TRUE;
-}
-
-static void
-UpdateYUVTextureData(SDL_Texture * texture)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-    SDL_Rect rect;
-    RECT d3drect;
-    D3DLOCKED_RECT locked;
-    HRESULT result;
-
-    d3drect.left = 0;
-    d3drect.right = texture->w;
-    d3drect.top = 0;
-    d3drect.bottom = texture->h;
-
-    result =
-        IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
-    if (FAILED(result)) {
-        return;
-    }
-
-    rect.x = 0;
-    rect.y = 0;
-    rect.w = texture->w;
-    rect.h = texture->h;
-    SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
-                        texture->h, locked.pBits, locked.Pitch);
-
-    IDirect3DTexture9_UnlockRect(data->texture, 0);
-}
-
-void
-D3D_AddRenderDriver(_THIS)
-{
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_RendererInfo *info = &D3D_RenderDriver.info;
-
-    if (data->d3d) {
-        int i, j;
-        int formats[] = {
-            SDL_PIXELFORMAT_RGB332,
-            SDL_PIXELFORMAT_RGB444,
-            SDL_PIXELFORMAT_RGB555,
-            SDL_PIXELFORMAT_ARGB4444,
-            SDL_PIXELFORMAT_ARGB1555,
-            SDL_PIXELFORMAT_RGB565,
-            SDL_PIXELFORMAT_RGB888,
-            SDL_PIXELFORMAT_ARGB8888,
-            SDL_PIXELFORMAT_ARGB2101010,
-        };
-
-        for (i = 0; i < _this->num_displays; ++i) {
-            SDL_VideoDisplay *display = &_this->displays[i];
-            SDL_DisplayMode *mode = &display->desktop_mode;
-            UINT adapter = D3D_FindAdapter(data->d3d, display);
-
-            /* Get the matching D3D adapter for this display */
-            info->num_texture_formats = 0;
-            for (j = 0; j < SDL_arraysize(formats); ++j) {
-                if (D3D_IsTextureFormatAvailable
-                    (data->d3d, adapter, mode->format, formats[j])) {
-                    info->texture_formats[info->num_texture_formats++] =
-                        formats[j];
-                }
-            }
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_YV12;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_IYUV;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_YUY2;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_UYVY;
-            info->texture_formats[info->num_texture_formats++] =
-                SDL_PIXELFORMAT_YVYU;
-
-            SDL_AddRenderDriver(display, &D3D_RenderDriver);
-        }
-    }
-}
-
-SDL_Renderer *
-D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
-{
-    SDL_VideoDisplay *display = window->display;
-    SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
-    SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
-    SDL_Renderer *renderer;
-    D3D_RenderData *data;
-    HRESULT result;
-    D3DPRESENT_PARAMETERS pparams;
-    IDirect3DSwapChain9 *chain;
-    D3DCAPS9 caps;
-
-    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
-    if (!renderer) {
-        SDL_OutOfMemory();
-        return NULL;
-    }
-
-    data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        D3D_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
-        return NULL;
-    }
-    data->d3d = videodata->d3d;
-
-    videodata->render = RENDER_D3D;
-
-    renderer->DisplayModeChanged = D3D_DisplayModeChanged;
-    renderer->CreateTexture = D3D_CreateTexture;
-    renderer->QueryTexturePixels = D3D_QueryTexturePixels;
-    renderer->UpdateTexture = D3D_UpdateTexture;
-    renderer->LockTexture = D3D_LockTexture;
-    renderer->UnlockTexture = D3D_UnlockTexture;
-    renderer->DirtyTexture = D3D_DirtyTexture;
-    renderer->RenderDrawPoints = D3D_RenderDrawPoints;
-    renderer->RenderDrawLines = D3D_RenderDrawLines;
-    renderer->RenderFillRects = D3D_RenderFillRects;
-    renderer->RenderCopy = D3D_RenderCopy;
-    renderer->RenderReadPixels = D3D_RenderReadPixels;
-    renderer->RenderWritePixels = D3D_RenderWritePixels;
-    renderer->RenderPresent = D3D_RenderPresent;
-    renderer->DestroyTexture = D3D_DestroyTexture;
-    renderer->DestroyRenderer = D3D_DestroyRenderer;
-    renderer->info = D3D_RenderDriver.info;
-    renderer->window = window;
-    renderer->driverdata = data;
-
-    renderer->info.flags = SDL_RENDERER_ACCELERATED;
-
-    SDL_zero(pparams);
-    pparams.BackBufferWidth = window->w;
-    pparams.BackBufferHeight = window->h;
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        pparams.BackBufferFormat =
-            PixelFormatToD3DFMT(window->fullscreen_mode.format);
-    } else {
-        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
-    }
-    pparams.BackBufferCount = 1;
-    pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
-
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        pparams.Windowed = FALSE;
-        pparams.FullScreen_RefreshRateInHz =
-            window->fullscreen_mode.refresh_rate;
-    } else {
-        pparams.Windowed = TRUE;
-        pparams.FullScreen_RefreshRateInHz = 0;
-    }
-    if (flags & SDL_RENDERER_PRESENTVSYNC) {
-        pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
-    } else {
-        pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
-    }
-
-    data->adapter = D3D_FindAdapter(videodata->d3d, display);
-    IDirect3D9_GetDeviceCaps(videodata->d3d, data->adapter,
-                             D3DDEVTYPE_HAL, &caps);
-
-    result = IDirect3D9_CreateDevice(videodata->d3d, data->adapter,
-                                     D3DDEVTYPE_HAL,
-                                     windowdata->hwnd,
-                                     (caps.
-                                      DevCaps &
-                                      D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
-                                     D3DCREATE_HARDWARE_VERTEXPROCESSING :
-                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING,
-                                     &pparams, &data->device);
-    if (FAILED(result)) {
-        D3D_DestroyRenderer(renderer);
-        D3D_SetError("CreateDevice()", result);
-        return NULL;
-    }
-    data->beginScene = SDL_TRUE;
-
-    /* Get presentation parameters to fill info */
-    result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
-    if (FAILED(result)) {
-        D3D_DestroyRenderer(renderer);
-        D3D_SetError("GetSwapChain()", result);
-        return NULL;
-    }
-    result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
-    if (FAILED(result)) {
-        IDirect3DSwapChain9_Release(chain);
-        D3D_DestroyRenderer(renderer);
-        D3D_SetError("GetPresentParameters()", result);
-        return NULL;
-    }
-    IDirect3DSwapChain9_Release(chain);
-    if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
-        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
-    }
-    data->pparams = pparams;
-
-    IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
-    renderer->info.max_texture_width = caps.MaxTextureWidth;
-    renderer->info.max_texture_height = caps.MaxTextureHeight;
-
-    /* Set up parameters for rendering */
-    IDirect3DDevice9_SetVertexShader(data->device, NULL);
-    IDirect3DDevice9_SetFVF(data->device,
-                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
-                                    D3DCULL_NONE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
-    /* Enable color modulation by diffuse color */
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP,
-                                          D3DTOP_MODULATE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1,
-                                          D3DTA_TEXTURE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2,
-                                          D3DTA_DIFFUSE);
-    /* Enable alpha modulation by diffuse alpha */
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP,
-                                          D3DTOP_MODULATE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1,
-                                          D3DTA_TEXTURE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2,
-                                          D3DTA_DIFFUSE);
-    /* Disable second texture stage, since we're done */
-    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP,
-                                          D3DTOP_DISABLE);
-    IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP,
-                                          D3DTOP_DISABLE);
-
-    return renderer;
-}
-
-static int
-D3D_Reset(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    HRESULT result;
-
-    result = IDirect3DDevice9_Reset(data->device, &data->pparams);
-    if (FAILED(result)) {
-        if (result == D3DERR_DEVICELOST) {
-            /* Don't worry about it, we'll reset later... */
-            return 0;
-        } else {
-            D3D_SetError("Reset()", result);
-            return -1;
-        }
-    }
-    IDirect3DDevice9_SetVertexShader(data->device, NULL);
-    IDirect3DDevice9_SetFVF(data->device,
-                            D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
-                                    D3DCULL_NONE);
-    IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
-    return 0;
-}
-
-static int
-D3D_DisplayModeChanged(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-
-    data->pparams.BackBufferWidth = window->w;
-    data->pparams.BackBufferHeight = window->h;
-    if (window->flags & SDL_WINDOW_FULLSCREEN) {
-        data->pparams.BackBufferFormat =
-            PixelFormatToD3DFMT(window->fullscreen_mode.format);
-    } else {
-        data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
-    }
-    return D3D_Reset(renderer);
-}
-
-static int
-D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    Uint32 display_format = display->current_mode.format;
-    D3D_TextureData *data;
-    HRESULT result;
-
-    data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
-    if (!data) {
-        SDL_OutOfMemory();
-        return -1;
-    }
-
-    texture->driverdata = data;
-
-    if (SDL_ISPIXELFORMAT_FOURCC(texture->format) &&
-        (texture->format != SDL_PIXELFORMAT_YUY2 ||
-         !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
-                                       display_format, texture->format))
-        && (texture->format != SDL_PIXELFORMAT_YVYU
-            || !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter,
-                                             display_format, texture->format))) {
-        data->yuv =
-            SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
-        if (!data->yuv) {
-            return -1;
-        }
-        data->format = display->current_mode.format;
-    } else {
-        data->format = texture->format;
-    }
-
-    result =
-        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
-                                       texture->h, 1, 0,
-                                       PixelFormatToD3DFMT(data->format),
-                                       D3DPOOL_SDL, &data->texture, NULL);
-    if (FAILED(result)) {
-        D3D_SetError("CreateTexture()", result);
-        return -1;
-    }
-
-    return 0;
-}
-
-static int
-D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
-                       void **pixels, int *pitch)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
-    } else {
-        /* D3D textures don't have their pixels hanging out */
-        return -1;
-    }
-}
-
-static int
-D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                  const SDL_Rect * rect, const void *pixels, int pitch)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
-
-    if (data->yuv) {
-        if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
-            return -1;
-        }
-        UpdateYUVTextureData(texture);
-        return 0;
-    } else {
-#ifdef SDL_MEMORY_POOL_DEFAULT
-        IDirect3DTexture9 *temp;
-        RECT d3drect;
-        D3DLOCKED_RECT locked;
-        const Uint8 *src;
-        Uint8 *dst;
-        int row, length;
-        HRESULT result;
-
-        result =
-            IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
-                                           texture->h, 1, 0,
-                                           PixelFormatToD3DFMT(texture->
-                                                               format),
-                                           D3DPOOL_SYSTEMMEM, &temp, NULL);
-        if (FAILED(result)) {
-            D3D_SetError("CreateTexture()", result);
-            return -1;
-        }
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0);
-        if (FAILED(result)) {
-            IDirect3DTexture9_Release(temp);
-            D3D_SetError("LockRect()", result);
-            return -1;
-        }
-
-        src = pixels;
-        dst = locked.pBits;
-        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-        for (row = 0; row < rect->h; ++row) {
-            SDL_memcpy(dst, src, length);
-            src += pitch;
-            dst += locked.Pitch;
-        }
-        IDirect3DTexture9_UnlockRect(temp, 0);
-
-        result =
-            IDirect3DDevice9_UpdateTexture(renderdata->device,
-                                           (IDirect3DBaseTexture9 *) temp,
-                                           (IDirect3DBaseTexture9 *)
-                                           data->texture);
-        IDirect3DTexture9_Release(temp);
-        if (FAILED(result)) {
-            D3D_SetError("UpdateTexture()", result);
-            return -1;
-        }
-#else
-        RECT d3drect;
-        D3DLOCKED_RECT locked;
-        const Uint8 *src;
-        Uint8 *dst;
-        int row, length;
-        HRESULT result;
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        result =
-            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
-                                       0);
-        if (FAILED(result)) {
-            D3D_SetError("LockRect()", result);
-            return -1;
-        }
-
-        src = pixels;
-        dst = locked.pBits;
-        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-        for (row = 0; row < rect->h; ++row) {
-            SDL_memcpy(dst, src, length);
-            src += pitch;
-            dst += locked.Pitch;
-        }
-        IDirect3DTexture9_UnlockRect(data->texture, 0);
-#endif // SDL_MEMORY_POOL_DEFAULT
-
-        return 0;
-    }
-}
-
-static int
-D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
-                const SDL_Rect * rect, int markDirty, void **pixels,
-                int *pitch)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
-                                     pitch);
-    } else {
-        RECT d3drect;
-        D3DLOCKED_RECT locked;
-        HRESULT result;
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        result =
-            IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect,
-                                       markDirty ? 0 :
-                                       D3DLOCK_NO_DIRTY_UPDATE);
-        if (FAILED(result)) {
-            D3D_SetError("LockRect()", result);
-            return -1;
-        }
-        *pixels = locked.pBits;
-        *pitch = locked.Pitch;
-        return 0;
-    }
-}
-
-static void
-D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (data->yuv) {
-        SDL_SW_UnlockYUVTexture(data->yuv);
-        UpdateYUVTextureData(texture);
-    } else {
-        IDirect3DTexture9_UnlockRect(data->texture, 0);
-    }
-}
-
-static void
-D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
-                 const SDL_Rect * rects)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-    RECT d3drect;
-    int i;
-
-    for (i = 0; i < numrects; ++i) {
-        const SDL_Rect *rect = &rects[i];
-
-        d3drect.left = rect->x;
-        d3drect.right = rect->x + rect->w;
-        d3drect.top = rect->y;
-        d3drect.bottom = rect->y + rect->h;
-
-        IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect);
-    }
-}
-
-static void
-D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
-{
-    switch (blendMode) {
-    case SDL_BLENDMODE_NONE:
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                        FALSE);
-        break;
-    case SDL_BLENDMODE_BLEND:
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                        TRUE);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
-                                        D3DBLEND_SRCALPHA);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
-                                        D3DBLEND_INVSRCALPHA);
-        break;
-    case SDL_BLENDMODE_ADD:
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
-                                        TRUE);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
-                                        D3DBLEND_SRCALPHA);
-        IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
-                                        D3DBLEND_ONE);
-        break;
-    }
-}
-
-static int
-D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
-                     int count)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    DWORD color;
-    Vertex *vertices;
-    int i;
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    D3D_SetBlendMode(data, renderer->blendMode);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0,
-                                    (IDirect3DBaseTexture9 *) 0);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-
-    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
-
-    vertices = SDL_stack_alloc(Vertex, count);
-    for (i = 0; i < count; ++i) {
-        vertices[i].x = (float) points[i].x;
-        vertices[i].y = (float) points[i].y;
-        vertices[i].z = 0.0f;
-        vertices[i].rhw = 1.0f;
-        vertices[i].color = color;
-        vertices[i].u = 0.0f;
-        vertices[i].v = 0.0f;
-    }
-    result =
-        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count,
-                                         vertices, sizeof(*vertices));
-    SDL_stack_free(vertices);
-    if (FAILED(result)) {
-        D3D_SetError("DrawPrimitiveUP()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
-                    int count)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    DWORD color;
-    Vertex *vertices;
-    int i;
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    D3D_SetBlendMode(data, renderer->blendMode);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0,
-                                    (IDirect3DBaseTexture9 *) 0);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-
-    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
-
-    vertices = SDL_stack_alloc(Vertex, count);
-    for (i = 0; i < count; ++i) {
-        vertices[i].x = (float) points[i].x;
-        vertices[i].y = (float) points[i].y;
-        vertices[i].z = 0.0f;
-        vertices[i].rhw = 1.0f;
-        vertices[i].color = color;
-        vertices[i].u = 0.0f;
-        vertices[i].v = 0.0f;
-    }
-    result =
-        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1,
-                                         vertices, sizeof(*vertices));
-
-    /* DirectX 9 has the same line rasterization semantics as GDI,
-       so we need to close the endpoint of the line */
-    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
-        vertices[0].x = (float) points[count-1].x;
-        vertices[0].y = (float) points[count-1].y;
-        result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
-    }
-
-    SDL_stack_free(vertices);
-    if (FAILED(result)) {
-        D3D_SetError("DrawPrimitiveUP()", result);
-        return -1;
-    }
-    return 0;
-}
-
-static int
-D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
-                    int count)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    DWORD color;
-    int i;
-    float minx, miny, maxx, maxy;
-    Vertex vertices[4];
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    D3D_SetBlendMode(data, renderer->blendMode);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0,
-                                    (IDirect3DBaseTexture9 *) 0);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-
-    color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b);
-
-    for (i = 0; i < count; ++i) {
-        const SDL_Rect *rect = rects[i];
-
-        minx = (float) rect->x;
-        miny = (float) rect->y;
-        maxx = (float) rect->x + rect->w;
-        maxy = (float) rect->y + rect->h;
-
-        vertices[0].x = minx;
-        vertices[0].y = miny;
-        vertices[0].z = 0.0f;
-        vertices[0].rhw = 1.0f;
-        vertices[0].color = color;
-        vertices[0].u = 0.0f;
-        vertices[0].v = 0.0f;
-
-        vertices[1].x = maxx;
-        vertices[1].y = miny;
-        vertices[1].z = 0.0f;
-        vertices[1].rhw = 1.0f;
-        vertices[1].color = color;
-        vertices[1].u = 0.0f;
-        vertices[1].v = 0.0f;
-
-        vertices[2].x = maxx;
-        vertices[2].y = maxy;
-        vertices[2].z = 0.0f;
-        vertices[2].rhw = 1.0f;
-        vertices[2].color = color;
-        vertices[2].u = 0.0f;
-        vertices[2].v = 0.0f;
-
-        vertices[3].x = minx;
-        vertices[3].y = maxy;
-        vertices[3].z = 0.0f;
-        vertices[3].rhw = 1.0f;
-        vertices[3].color = color;
-        vertices[3].u = 0.0f;
-        vertices[3].v = 0.0f;
-
-        result =
-            IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN,
-                                             2, vertices, sizeof(*vertices));
-        if (FAILED(result)) {
-            D3D_SetError("DrawPrimitiveUP()", result);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static int
-D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
-               const SDL_Rect * srcrect, const SDL_Rect * dstrect)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
-    LPDIRECT3DPIXELSHADER9 shader = NULL;
-    float minx, miny, maxx, maxy;
-    float minu, maxu, minv, maxv;
-    DWORD color;
-    Vertex vertices[4];
-    HRESULT result;
-
-    if (data->beginScene) {
-        IDirect3DDevice9_BeginScene(data->device);
-        data->beginScene = SDL_FALSE;
-    }
-
-    minx = (float) dstrect->x - 0.5f;
-    miny = (float) dstrect->y - 0.5f;
-    maxx = (float) dstrect->x + dstrect->w - 0.5f;
-    maxy = (float) dstrect->y + dstrect->h - 0.5f;
-
-    minu = (float) srcrect->x / texture->w;
-    maxu = (float) (srcrect->x + srcrect->w) / texture->w;
-    minv = (float) srcrect->y / texture->h;
-    maxv = (float) (srcrect->y + srcrect->h) / texture->h;
-
-    color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b);
-
-    vertices[0].x = minx;
-    vertices[0].y = miny;
-    vertices[0].z = 0.0f;
-    vertices[0].rhw = 1.0f;
-    vertices[0].color = color;
-    vertices[0].u = minu;
-    vertices[0].v = minv;
-
-    vertices[1].x = maxx;
-    vertices[1].y = miny;
-    vertices[1].z = 0.0f;
-    vertices[1].rhw = 1.0f;
-    vertices[1].color = color;
-    vertices[1].u = maxu;
-    vertices[1].v = minv;
-
-    vertices[2].x = maxx;
-    vertices[2].y = maxy;
-    vertices[2].z = 0.0f;
-    vertices[2].rhw = 1.0f;
-    vertices[2].color = color;
-    vertices[2].u = maxu;
-    vertices[2].v = maxv;
-
-    vertices[3].x = minx;
-    vertices[3].y = maxy;
-    vertices[3].z = 0.0f;
-    vertices[3].rhw = 1.0f;
-    vertices[3].color = color;
-    vertices[3].u = minu;
-    vertices[3].v = maxv;
-
-    D3D_SetBlendMode(data, texture->blendMode);
-
-    IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
-                                     D3DTEXF_LINEAR);
-    IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
-                                     D3DTEXF_LINEAR);
-
-    result =
-        IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *)
-                                    texturedata->texture);
-    if (FAILED(result)) {
-        D3D_SetError("SetTexture()", result);
-        return -1;
-    }
-    if (shader) {
-        result = IDirect3DDevice9_SetPixelShader(data->device, shader);
-        if (FAILED(result)) {
-            D3D_SetError("SetShader()", result);
-            return -1;
-        }
-    }
-    result =
-        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
-                                         vertices, sizeof(*vertices));
-    if (FAILED(result)) {
-        D3D_SetError("DrawPrimitiveUP()", result);
-        return -1;
-    }
-    if (shader) {
-        result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
-        if (FAILED(result)) {
-            D3D_SetError("SetShader()", result);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-static int
-D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, void * pixels, int pitch)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    SDL_VideoDisplay *display = window->display;
-    D3DSURFACE_DESC desc;
-    LPDIRECT3DSURFACE9 backBuffer;
-    LPDIRECT3DSURFACE9 surface;
-    RECT d3drect;
-    D3DLOCKED_RECT locked;
-    HRESULT result;
-
-    result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer);
-    if (FAILED(result)) {
-        D3D_SetError("GetBackBuffer()", result);
-        return -1;
-    }
-
-    result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
-    if (FAILED(result)) {
-        D3D_SetError("GetDesc()", result);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL);
-    if (FAILED(result)) {
-        D3D_SetError("CreateOffscreenPlainSurface()", result);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
-    if (FAILED(result)) {
-        D3D_SetError("GetRenderTargetData()", result);
-        IDirect3DSurface9_Release(surface);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    d3drect.left = rect->x;
-    d3drect.right = rect->x + rect->w;
-    d3drect.top = rect->y;
-    d3drect.bottom = rect->y + rect->h;
-
-    result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
-    if (FAILED(result)) {
-        D3D_SetError("LockRect()", result);
-        IDirect3DSurface9_Release(surface);
-        IDirect3DSurface9_Release(backBuffer);
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h,
-                      display->current_mode.format, locked.pBits, locked.Pitch,
-                      format, pixels, pitch);
-
-    IDirect3DSurface9_UnlockRect(surface);
-
-    IDirect3DSurface9_Release(surface);
-    IDirect3DSurface9_Release(backBuffer);
-
-    return 0;
-}
-
-static int
-D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                      Uint32 format, const void * pixels, int pitch)
-{
-    /* Work in progress */
-    SDL_Unsupported();
-    return -1;
-}
-
-static void
-D3D_RenderPresent(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-    HRESULT result;
-
-    if (!data->beginScene) {
-        IDirect3DDevice9_EndScene(data->device);
-        data->beginScene = SDL_TRUE;
-    }
-
-    result = IDirect3DDevice9_TestCooperativeLevel(data->device);
-    if (result == D3DERR_DEVICELOST) {
-        /* We'll reset later */
-        return;
-    }
-    if (result == D3DERR_DEVICENOTRESET) {
-        D3D_Reset(renderer);
-    }
-    result = IDirect3DDevice9_Present(data->device, NULL, NULL, NULL, NULL);
-    if (FAILED(result)) {
-        D3D_SetError("Present()", result);
-    }
-}
-
-static void
-D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
-{
-    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
-
-    if (!data) {
-        return;
-    }
-    if (data->yuv) {
-        SDL_SW_DestroyYUVTexture(data->yuv);
-    }
-    if (data->texture) {
-        IDirect3DTexture9_Release(data->texture);
-    }
-    SDL_free(data);
-    texture->driverdata = NULL;
-}
-
-static void
-D3D_DestroyRenderer(SDL_Renderer * renderer)
-{
-    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
-
-    if (data) {
-        if (data->device) {
-            IDirect3DDevice9_Release(data->device);
-        }
-        SDL_free(data);
-    }
-    SDL_free(renderer);
-}
-
-#endif /* SDL_VIDEO_RENDER_D3D */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_d3drender.h	Wed Feb 02 14:34:24 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_VIDEO_RENDER_D3D
-extern void D3D_AddRenderDriver(_THIS);
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowskeyboard.c	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/windows/SDL_windowskeyboard.c	Wed Feb 02 14:34:54 2011 -0800
@@ -116,7 +116,6 @@
     data->ime_candlistindexbase = 0;
     data->ime_candvertical = SDL_TRUE;
 
-    data->ime_candtex = NULL;
     data->ime_dirty = SDL_FALSE;
     SDL_memset(&data->ime_rect, 0, sizeof(data->ime_rect));
     SDL_memset(&data->ime_candlistrect, 0, sizeof(data->ime_candlistrect));
@@ -1274,36 +1273,6 @@
     }
 }
 
-static void
-BitmapToTexture(HBITMAP hbm, BYTE *bits, int width, int height, SDL_Texture **texture)
-{
-    SDL_Surface *surface = NULL;
-    BITMAP bm = {0};
-
-    if (GetObject(hbm, sizeof(bm), &bm) == 0)
-        return;
-
-    if (bits && texture) {
-        /*
-            For transparency:
-
-            const Uint8 alpha = 130;
-            unsigned long *p = (unsigned long *)bits;
-            unsigned long *end = (unsigned long *)(bits + (bm.bmWidthBytes * bm.bmHeight));
-            while (p < end) {
-                *p = RGB(GetRValue(*p), GetGValue(*p), GetBValue(*p)) | (alpha << 24);
-                ++p;
-            }
-            surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
-        */
-        surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
-        if (surface) {
-            *texture = SDL_CreateTextureFromSurface(0, surface);
-            SDL_FreeSurface(surface);
-        }
-    }
-}
-
 /* This draws only within the specified area and fills the entire region. */
 static void
 DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize)
@@ -1318,18 +1287,8 @@
 }
 
 static void
-DestroyTexture(SDL_Texture **texture)
-{
-    if (texture && *texture) {
-        SDL_DestroyTexture(*texture);
-        *texture = NULL;
-    }
-}
-
-static void
 IME_DestroyTextures(SDL_VideoData *videodata)
 {
-    DestroyTexture(&videodata->ime_candtex);
 }
 
 #define SDL_swap(a,b) { \
@@ -1544,7 +1503,6 @@
         DrawRect(hdc, left, top, right, bottom, candborder);
         ExtTextOutW(hdc, left + candborder + candpadding, top + candborder + candpadding, 0, NULL, s, SDL_wcslen(s), NULL);
     }
-    BitmapToTexture(hbm, bits, size.cx, size.cy, &videodata->ime_candtex);
     StopDrawToBitmap(hdc, &hbm);
 
     DeleteObject(listpen);
@@ -1576,7 +1534,7 @@
     if (videodata->ime_dirty)
         IME_Render(videodata);
 
-    SDL_RenderCopy(videodata->ime_candtex, NULL, &videodata->ime_candlistrect);
+    // FIXME: Need to show the IME bitmap
 }
 
 #endif /* SDL_DISABLE_WINDOWS_IME */
--- a/src/video/windows/SDL_windowsvideo.c	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/windows/SDL_windowsvideo.c	Wed Feb 02 14:34:54 2011 -0800
@@ -29,7 +29,6 @@
 
 #include "SDL_windowsvideo.h"
 #include "SDL_windowsshape.h"
-#include "SDL_d3drender.h"
 
 /* Initialization/Query functions */
 static int WIN_VideoInit(_THIS);
@@ -50,12 +49,6 @@
     SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
 
     SDL_UnregisterApp();
-#if SDL_VIDEO_RENDER_D3D
-    if (data->d3d) {
-        IDirect3D9_Release(data->d3d);
-        SDL_UnloadObject(data->d3dDLL);
-    }
-#endif
 #ifdef _WIN32_WCE
     if(data->hAygShell) {
        SDL_UnloadObject(data->hAygShell);
@@ -175,10 +168,6 @@
         return -1;
     }
 
-#if SDL_VIDEO_RENDER_D3D
-    D3D_AddRenderDriver(_this);
-#endif
-
     WIN_InitKeyboard(_this);
     WIN_InitMouse(_this);
 
--- a/src/video/windows/SDL_windowsvideo.h	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/windows/SDL_windowsvideo.h	Wed Feb 02 14:34:54 2011 -0800
@@ -39,12 +39,6 @@
 #define MAX_CANDLIST    10
 #define MAX_CANDLENGTH  256
 
-#if SDL_VIDEO_RENDER_D3D
-//#include <d3d9.h>
-#define D3D_DEBUG_INFO
-#include "d3d9.h"
-#endif
-
 #include "SDL_windowsclipboard.h"
 #include "SDL_windowsevents.h"
 #include "SDL_windowsgamma.h"
@@ -57,8 +51,6 @@
 #include "SDL_loadso.h"
 
 
-enum { RENDER_NONE, RENDER_D3D };
-
 #if WINVER < 0x0601
 /* Touch input definitions */
 #define TWF_FINETOUCH	1
@@ -125,10 +117,6 @@
 {
     int render;
 
-#if SDL_VIDEO_RENDER_D3D
-    void* d3dDLL;
-    IDirect3D9 *d3d;
-#endif
 #ifdef _WIN32_WCE
     void* hAygShell;
     PFNSHFullScreen SHFullScreen;
@@ -166,7 +154,6 @@
     int ime_candlistindexbase;
     SDL_bool ime_candvertical;
 
-    SDL_Texture *ime_candtex;
     SDL_bool ime_dirty;
     SDL_Rect ime_rect;
     SDL_Rect ime_candlistrect;
--- a/src/video/x11/SDL_x11video.h	Wed Feb 02 14:34:24 2011 -0800
+++ b/src/video/x11/SDL_x11video.h	Wed Feb 02 14:34:54 2011 -0800
@@ -24,6 +24,8 @@
 #ifndef _SDL_x11video_h
 #define _SDL_x11video_h
 
+#include "SDL_keysym.h"
+
 #include "../SDL_sysvideo.h"
 
 #include <X11/Xlib.h>