Mac and Linux SDL2 binary snapshots
Edward Rudd
2014-12-01 a4535776e7c06155fc07e8387d47a1d81263bc74

update used source to 2.0.3 tag

85 files modified
52 files added
49 files deleted
16979 ■■■■■ changed files
source/.hgtags 1 ●●●● patch | view | raw | blame | history
source/CMakeLists.txt 13 ●●●●● patch | view | raw | blame | history
source/README-wince.txt 3 ●●●● patch | view | raw | blame | history
source/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj 414 ●●●●● patch | view | raw | blame | history
source/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters 642 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/SDL-WinRT_VS2012.sln 32 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj 519 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters 678 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/tests/loopwave/Assets/Logo.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/loopwave/Package.appxmanifest 42 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj 170 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx patch | view | raw | blame | history
source/VisualC-WinRT/tests/testthread/Assets/Logo.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png patch | view | raw | blame | history
source/VisualC-WinRT/tests/testthread/Package.appxmanifest 42 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj 160 ●●●●● patch | view | raw | blame | history
source/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx patch | view | raw | blame | history
source/VisualC/SDL/SDL_VS2008.vcproj 96 ●●●●● patch | view | raw | blame | history
source/VisualC/SDL/SDL_VS2010.vcxproj 5 ●●●● patch | view | raw | blame | history
source/VisualC/SDL/SDL_VS2012.vcxproj 3 ●●●●● patch | view | raw | blame | history
source/VisualC/SDL/SDL_VS2013.vcxproj 967 ●●●● patch | view | raw | blame | history
source/VisualC/SDL_VS2013.sln 17 ●●●●● patch | view | raw | blame | history
source/VisualC/tests/testoverlay2/testoverlay2_VS2013.vcxproj 10 ●●●● patch | view | raw | blame | history
source/WhatsNew.txt 8 ●●●●● patch | view | raw | blame | history
source/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj 1 ●●●● patch | view | raw | blame | history
source/Xcode/SDL/Info-Framework.plist 4 ●●●● patch | view | raw | blame | history
source/Xcode/SDL/SDL.xcodeproj/project.pbxproj 8 ●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata 7 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/project.xcworkspace/xcuserdata/urkle.xcuserdatad/UserInterfaceState.xcuserstate patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist 21 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/All.xcscheme 59 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/SDL_test.xcscheme 59 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/checkkeys.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/loopwave.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testatomic.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testaudioinfo.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testdraw2.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testdrawchessboard.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testerror.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testfile.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testfilesystem.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testgamecontroller.xcscheme 92 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testgesture.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testgl2.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testhaptic.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testiconv.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testime.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testintersections.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testjoystick.xcscheme 92 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testkeys.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testloadso.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testlock.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testmessage.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testmultiaudio.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testnative.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testoverlay2.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testplatform.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testpower.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrelative.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrendercopyex.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrendertarget.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testresample.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrumble.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testscale.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testsem.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testshader.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testshape.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testsprite2.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testspriteminimal.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/teststreaming.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testthread.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testtimer.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testversion.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testwm2.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/torturethread.xcscheme 86 ●●●●● patch | view | raw | blame | history
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/xcschememanagement.plist 462 ●●●●● patch | view | raw | blame | history
source/build-scripts/raspberrypi-buildbot.sh 2 ●●● patch | view | raw | blame | history
source/configure 17 ●●●● patch | view | raw | blame | history
source/configure.in 10 ●●●● patch | view | raw | blame | history
source/debian/changelog 6 ●●●●● patch | view | raw | blame | history
source/include/SDL_config.h 2 ●●●●● patch | view | raw | blame | history
source/include/SDL_config.h.cmake 1 ●●●● patch | view | raw | blame | history
source/include/SDL_config.h.in 1 ●●●● patch | view | raw | blame | history
source/include/SDL_config_windows.h 3 ●●●●● patch | view | raw | blame | history
source/include/SDL_config_winrt.h 190 ●●●●● patch | view | raw | blame | history
source/include/SDL_cpuinfo.h 2 ●●● patch | view | raw | blame | history
source/include/SDL_egl.h 7 ●●●●● patch | view | raw | blame | history
source/include/SDL_hints.h 71 ●●●●● patch | view | raw | blame | history
source/include/SDL_main.h 30 ●●●●● patch | view | raw | blame | history
source/include/SDL_name.h 22 ●●●●● patch | view | raw | blame | history
source/include/SDL_platform.h 16 ●●●●● patch | view | raw | blame | history
source/include/SDL_stdinc.h 10 ●●●●● patch | view | raw | blame | history
source/include/SDL_system.h 64 ●●●●● patch | view | raw | blame | history
source/include/SDL_syswm.h 12 ●●●●● patch | view | raw | blame | history
source/include/SDL_version.h 2 ●●● patch | view | raw | blame | history
source/include/begin_code.h 4 ●●●● patch | view | raw | blame | history
source/src/SDL_assert.c 2 ●●●●● patch | view | raw | blame | history
source/src/SDL_log.c 9 ●●●● patch | view | raw | blame | history
source/src/atomic/SDL_spinlock.c 2 ●●● patch | view | raw | blame | history
source/src/audio/directsound/directx.h 21 ●●●●● patch | view | raw | blame | history
source/src/audio/winmm/SDL_winmm.c 18 ●●●● patch | view | raw | blame | history
source/src/audio/xaudio2/SDL_xaudio2.c 113 ●●●●● patch | view | raw | blame | history
source/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp 90 ●●●●● patch | view | raw | blame | history
source/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h 70 ●●●●● patch | view | raw | blame | history
source/src/core/windows/SDL_windows.c 26 ●●●● patch | view | raw | blame | history
source/src/core/windows/SDL_windows.h 5 ●●●●● patch | view | raw | blame | history
source/src/core/winrt/SDL_winrtapp_common.cpp 37 ●●●●● patch | view | raw | blame | history
source/src/core/winrt/SDL_winrtapp_common.h 31 ●●●●● patch | view | raw | blame | history
source/src/core/winrt/SDL_winrtapp_direct3d.cpp 699 ●●●●● patch | view | raw | blame | history
source/src/core/winrt/SDL_winrtapp_direct3d.h 80 ●●●●● patch | view | raw | blame | history
source/src/core/winrt/SDL_winrtapp_xaml.cpp 160 ●●●●● patch | view | raw | blame | history
source/src/core/winrt/SDL_winrtapp_xaml.h 33 ●●●●● patch | view | raw | blame | history
source/src/dynapi/SDL_dynapi.h 2 ●●●●● patch | view | raw | blame | history
source/src/file/SDL_rwops.c 7 ●●●●● patch | view | raw | blame | history
source/src/file/cocoa/SDL_rwopsbundlesupport.h 21 ●●●●● patch | view | raw | blame | history
source/src/file/cocoa/SDL_rwopsbundlesupport.m 27 ●●●●● patch | view | raw | blame | history
source/src/filesystem/windows/SDL_sysfilesystem.c 1 ●●●● patch | view | raw | blame | history
source/src/filesystem/winrt/SDL_sysfilesystem.cpp 174 ●●●●● patch | view | raw | blame | history
source/src/joystick/SDL_gamecontroller.c 10 ●●●● patch | view | raw | blame | history
source/src/joystick/SDL_gamecontrollerdb.h 2 ●●●●● patch | view | raw | blame | history
source/src/joystick/SDL_sysjoystick.h 2 ●●● patch | view | raw | blame | history
source/src/joystick/winrt/SDL_xinputjoystick.c 537 ●●●●● patch | view | raw | blame | history
source/src/loadso/windows/SDL_sysloadso.c 8 ●●●●● patch | view | raw | blame | history
source/src/main/android/SDL_android_main.c 4 ●●● patch | view | raw | blame | history
source/src/main/dummy/SDL_dummy_main.c 5 ●●●● patch | view | raw | blame | history
source/src/main/haiku/SDL_BeApp.h 1 ●●●● patch | view | raw | blame | history
source/src/main/psp/SDL_psp_main.c 19 ●●●●● patch | view | raw | blame | history
source/src/main/windows/SDL_windows_main.c 2 ●●● patch | view | raw | blame | history
source/src/main/windows/version.rc 8 ●●●● patch | view | raw | blame | history
source/src/main/winrt/SDL_winrt_main_NonXAML.cpp 59 ●●●●● patch | view | raw | blame | history
source/src/power/SDL_power.c 4 ●●●● patch | view | raw | blame | history
source/src/power/winrt/SDL_syspower.cpp 44 ●●●●● patch | view | raw | blame | history
source/src/render/SDL_d3dmath.c 131 ●●●●● patch | view | raw | blame | history
source/src/render/SDL_d3dmath.h 69 ●●●●● patch | view | raw | blame | history
source/src/render/SDL_render.c 3 ●●●●● patch | view | raw | blame | history
source/src/render/SDL_sysrender.h 3 ●●●●● patch | view | raw | blame | history
source/src/render/direct3d/SDL_render_d3d.c 134 ●●●●● patch | view | raw | blame | history
source/src/render/direct3d11/SDL_render_d3d11.c 2879 ●●●●● patch | view | raw | blame | history
source/src/render/direct3d11/SDL_render_winrt.cpp 119 ●●●●● patch | view | raw | blame | history
source/src/render/direct3d11/SDL_render_winrt.h 40 ●●●●● patch | view | raw | blame | history
source/src/render/opengl/SDL_glfuncs.h 21 ●●●●● patch | view | raw | blame | history
source/src/render/opengl/SDL_render_gl.c 2 ●●● patch | view | raw | blame | history
source/src/render/opengles/SDL_glesfuncs.h 21 ●●●●● patch | view | raw | blame | history
source/src/render/opengles/SDL_render_gles.c 2 ●●● patch | view | raw | blame | history
source/src/render/opengles2/SDL_gles2funcs.h 23 ●●●●● patch | view | raw | blame | history
source/src/render/opengles2/SDL_render_gles2.c 10 ●●●●● patch | view | raw | blame | history
source/src/render/psp/SDL_render_psp.c 2 ●●● patch | view | raw | blame | history
source/src/render/software/SDL_rotate.h 21 ●●●●● patch | view | raw | blame | history
source/src/stdlib/SDL_stdlib.c 4 ●●●● patch | view | raw | blame | history
source/src/test/SDL_test_harness.c 48 ●●●●● patch | view | raw | blame | history
source/src/thread/SDL_thread_c.h 2 ●●●●● patch | view | raw | blame | history
source/src/thread/stdcpp/SDL_syscond.cpp 164 ●●●●● patch | view | raw | blame | history
source/src/thread/stdcpp/SDL_sysmutex.cpp 111 ●●●●● patch | view | raw | blame | history
source/src/thread/stdcpp/SDL_sysmutex_c.h 30 ●●●●● patch | view | raw | blame | history
source/src/thread/stdcpp/SDL_systhread.cpp 167 ●●●●● patch | view | raw | blame | history
source/src/thread/stdcpp/SDL_systhread_c.h 26 ●●●●● patch | view | raw | blame | history
source/src/timer/windows/SDL_systimer.c 29 ●●●●● patch | view | raw | blame | history
source/src/video/SDL_egl.c 6 ●●●● patch | view | raw | blame | history
source/src/video/SDL_sysvideo.h 3 ●●●●● patch | view | raw | blame | history
source/src/video/SDL_video.c 7 ●●●● patch | view | raw | blame | history
source/src/video/cocoa/SDL_cocoaopengl.m 75 ●●●●● patch | view | raw | blame | history
source/src/video/cocoa/SDL_cocoawindow.m 7 ●●●●● patch | view | raw | blame | history
source/src/video/mir/SDL_mirframebuffer.c 6 ●●●●● patch | view | raw | blame | history
source/src/video/windows/SDL_msctf.h 21 ●●●●● patch | view | raw | blame | history
source/src/video/windows/SDL_windowsevents.c 3 ●●●●● patch | view | raw | blame | history
source/src/video/windows/SDL_windowsopengl.c 8 ●●●● patch | view | raw | blame | history
source/src/video/windows/SDL_windowsvideo.c 2 ●●● patch | view | raw | blame | history
source/src/video/windows/wmmsg.h 20 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtevents.cpp 153 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtevents_c.h 72 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtkeyboard.cpp 301 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtmouse.cpp 165 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtmouse_c.h 40 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtopengles.cpp 50 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtopengles.h 48 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtpointerinput.cpp 394 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtvideo.cpp 409 ●●●●● patch | view | raw | blame | history
source/src/video/winrt/SDL_winrtvideo_cpp.h 79 ●●●●● patch | view | raw | blame | history
source/test/loopwave.c 9 ●●●●● patch | view | raw | blame | history
source/test/testautomation_platform.c 44 ●●●● patch | view | raw | blame | history
source/test/testautomation_sdltest.c 38 ●●●●● patch | view | raw | blame | history
source/.hgtags
@@ -25,3 +25,4 @@
0000000000000000000000000000000000000000 release-2.0.1
b9663c77f5c95ebf05f3c18e80619caae8ae1460 release-2.0.1
be2102f000d0d2d9bab75e9703a1d503d0f6bb33 release-2.0.2
f285b9487756ff681f76c85644222c03a7bfa1c7 release-2.0.3
source/CMakeLists.txt
@@ -29,9 +29,9 @@
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 0)
set(SDL_MICRO_VERSION 2)
set(SDL_INTERFACE_AGE 0)
set(SDL_BINARY_AGE 2)
set(SDL_MICRO_VERSION 3)
set(SDL_INTERFACE_AGE 1)
set(SDL_BINARY_AGE 3)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Calculate a libtool-like version number
@@ -799,11 +799,12 @@
    endif()
    set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
    check_include_file(d3d9.h HAVE_D3D_H)
    check_include_file(d3d11_1.h HAVE_D3D11_H)
    check_include_file(ddraw.h HAVE_DDRAW_H)
    check_include_file(dsound.h HAVE_DSOUND_H)
    check_include_file(dinput.h HAVE_DINPUT_H)
    check_include_file(xaudio2.h HAVE_XAUDIO2_H)
    if(HAVE_D3D_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
    if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
      set(HAVE_DIRECTX TRUE)
      # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
      link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
@@ -844,6 +845,10 @@
      set(SDL_VIDEO_RENDER_D3D 1)
      set(HAVE_RENDER_D3D TRUE)
    endif()
    if(RENDER_D3D AND HAVE_D3D11_H)
      set(SDL_VIDEO_RENDER_D3D11 1)
      set(HAVE_RENDER_D3D TRUE)
    endif()
    set(HAVE_SDL_VIDEO TRUE)
  endif()
source/README-wince.txt
@@ -2,8 +2,7 @@
Windows CE is no longer supported by SDL.
We have left the CE support in SDL 1.2 for those that must have it, and we
will accept patches that support more modern Windows Mobile platforms for
SDL 2.0.
have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3.
--ryan.
source/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj
New file
@@ -0,0 +1,414 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{33048af1-031a-4ce6-b61e-fad2db832e9e}</ProjectGuid>
    <RootNamespace>SDL</RootNamespace>
    <DefaultLanguage>en-US</DefaultLanguage>
    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
    <ProjectName>SDL-WinPhone</ProjectName>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110_wp80</PlatformToolset>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110_wp80</PlatformToolset>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110_wp80</PlatformToolset>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110_wp80</PlatformToolset>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <GenerateManifest>false</GenerateManifest>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PreprocessorDefinitions>_USRDLL;UNICODE;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
      <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
      <MinimalRebuild>false</MinimalRebuild>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <AdditionalDependencies>DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PreprocessorDefinitions>_USRDLL;UNICODE;SDL_BUILDING_WINRT=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
      <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <AdditionalDependencies>DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <ClCompile>
      <PreprocessorDefinitions>_USRDLL;UNICODE;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
      <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
      <MinimalRebuild>false</MinimalRebuild>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <AdditionalDependencies>DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <ClCompile>
      <PreprocessorDefinitions>_USRDLL;UNICODE;SDL_BUILDING_WINRT=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
      <AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <AdditionalDependencies>DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <Reference Include="Windows">
      <IsWinMDFile>true</IsWinMDFile>
    </Reference>
    <Reference Include="platform.winmd">
      <IsWinMDFile>true</IsWinMDFile>
      <Private>false</Private>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\..\include\begin_code.h" />
    <ClInclude Include="..\..\include\close_code.h" />
    <ClInclude Include="..\..\include\SDL.h" />
    <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_config.h" />
    <ClInclude Include="..\..\include\SDL_config_minimal.h" />
    <ClInclude Include="..\..\include\SDL_config_winrt.h" />
    <ClInclude Include="..\..\include\SDL_copying.h" />
    <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
    <ClInclude Include="..\..\include\SDL_endian.h" />
    <ClInclude Include="..\..\include\SDL_error.h" />
    <ClInclude Include="..\..\include\SDL_events.h" />
    <ClInclude Include="..\..\include\SDL_filesystem.h" />
    <ClInclude Include="..\..\include\SDL_haptic.h" />
    <ClInclude Include="..\..\include\SDL_hints.h" />
    <ClInclude Include="..\..\include\SDL_input.h" />
    <ClInclude Include="..\..\include\SDL_joystick.h" />
    <ClInclude Include="..\..\include\SDL_keyboard.h" />
    <ClInclude Include="..\..\include\SDL_keycode.h" />
    <ClInclude Include="..\..\include\SDL_loadso.h" />
    <ClInclude Include="..\..\include\SDL_log.h" />
    <ClInclude Include="..\..\include\SDL_main.h" />
    <ClInclude Include="..\..\include\SDL_mouse.h" />
    <ClInclude Include="..\..\include\SDL_mutex.h" />
    <ClInclude Include="..\..\include\SDL_name.h" />
    <ClInclude Include="..\..\include\SDL_pixels.h" />
    <ClInclude Include="..\..\include\SDL_platform.h" />
    <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" />
    <ClInclude Include="..\..\include\SDL_shape.h" />
    <ClInclude Include="..\..\include\SDL_stdinc.h" />
    <ClInclude Include="..\..\include\SDL_surface.h" />
    <ClInclude Include="..\..\include\SDL_system.h" />
    <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" />
    <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
    <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
    <ClInclude Include="..\..\src\audio\SDL_wave.h" />
    <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
    <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_common.h" />
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_overrides.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_procs.h" />
    <ClInclude Include="..\..\src\events\blank_cursor.h" />
    <ClInclude Include="..\..\src\events\default_cursor.h" />
    <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
    <ClInclude Include="..\..\src\events\SDL_dropevents_c.h" />
    <ClInclude Include="..\..\src\events\SDL_events_c.h" />
    <ClInclude Include="..\..\src\events\SDL_keyboard_c.h" />
    <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
    <ClInclude Include="..\..\src\events\SDL_sysevents.h" />
    <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
    <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
    <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
    <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
    <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
    <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
    <ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h" />
    <ClInclude Include="..\..\src\render\mmx.h" />
    <ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
    <ClInclude Include="..\..\src\render\software\SDL_draw.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h" />
    <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_rotate.h" />
    <ClInclude Include="..\..\src\SDL_assert_c.h" />
    <ClInclude Include="..\..\src\SDL_error_c.h" />
    <ClInclude Include="..\..\src\SDL_fatal.h" />
    <ClInclude Include="..\..\src\SDL_hints_c.h" />
    <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
    <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h" />
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h" />
    <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
    <ClInclude Include="..\..\src\video\SDL_blit.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
    <ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
    <ClInclude Include="..\..\src\video\SDL_rect_c.h" />
    <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
    <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h" />
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
    <ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
    <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
    <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
    <ClCompile Include="..\..\src\audio\SDL_audio.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiocvt.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
    <ClCompile Include="..\..\src\audio\SDL_mixer.c" />
    <ClCompile Include="..\..\src\audio\SDL_wave.c" />
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c" />
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_common.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
    <ClCompile Include="..\..\src\dynapi\SDL_dynapi.c" />
    <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
    <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
    <ClCompile Include="..\..\src\events\SDL_events.c" />
    <ClCompile Include="..\..\src\events\SDL_gesture.c" />
    <ClCompile Include="..\..\src\events\SDL_keyboard.c" />
    <ClCompile Include="..\..\src\events\SDL_mouse.c" />
    <ClCompile Include="..\..\src\events\SDL_quit.c" />
    <ClCompile Include="..\..\src\events\SDL_touch.c" />
    <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
    <ClCompile Include="..\..\src\filesystem\winrt\SDL_sysfilesystem.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\file\SDL_rwops.c" />
    <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c" />
    <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
    <ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
    <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
    <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
    <ClCompile Include="..\..\src\power\SDL_power.c" />
    <ClCompile Include="..\..\src\power\winrt\SDL_syspower.cpp" />
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.c" />
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_winrt.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
    <ClCompile Include="..\..\src\render\SDL_render.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_render_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_rotate.c" />
    <ClCompile Include="..\..\src\SDL.c" />
    <ClCompile Include="..\..\src\SDL_assert.c" />
    <ClCompile Include="..\..\src\SDL_error.c" />
    <ClCompile Include="..\..\src\SDL_hints.c" />
    <ClCompile Include="..\..\src\SDL_log.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
    <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c" />
    <ClCompile Include="..\..\src\thread\SDL_thread.c" />
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp" />
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp" />
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp" />
    <ClCompile Include="..\..\src\timer\SDL_timer.c" />
    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c" />
    <ClCompile Include="..\..\src\video\SDL_blit.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
    <ClCompile Include="..\..\src\video\SDL_bmp.c" />
    <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
    <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
    <ClCompile Include="..\..\src\video\SDL_pixels.c" />
    <ClCompile Include="..\..\src\video\SDL_rect.c" />
    <ClCompile Include="..\..\src\video\SDL_RLEaccel.c" />
    <ClCompile Include="..\..\src\video\SDL_shape.c" />
    <ClCompile Include="..\..\src\video\SDL_stretch.c" />
    <ClCompile Include="..\..\src\video\SDL_surface.c" />
    <ClCompile Include="..\..\src\video\SDL_video.c" />
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    </ClCompile>
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
source/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters
New file
@@ -0,0 +1,642 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Filter Include="Header Files">
      <UniqueIdentifier>{02b21b9a-45a7-41ee-a8a6-e45d14aa28da}</UniqueIdentifier>
    </Filter>
    <Filter Include="Source Files">
      <UniqueIdentifier>{abc3a7e6-f955-4cb5-8340-fae0f653e9c1}</UniqueIdentifier>
    </Filter>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\..\include\begin_code.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\close_code.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_assert.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_atomic.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_audio.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_blendmode.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_clipboard.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_config.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_config_minimal.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_copying.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_cpuinfo.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_endian.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_error.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_events.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_haptic.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_hints.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_input.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_joystick.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_keyboard.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_keycode.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_loadso.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_log.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_main.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_mouse.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_mutex.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_name.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_pixels.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_platform.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_power.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_quit.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_rect.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_render.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_revision.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_rwops.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_scancode.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_shape.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_stdinc.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_surface.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_system.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_syswm.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_thread.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_timer.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_touch.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_types.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_version.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_video.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_audiomem.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_sysaudio.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_wave.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\windows\SDL_windows.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\blank_cursor.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\default_cursor.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_dropevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_events_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_keyboard_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_mouse_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_sysevents.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_touch_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_windowevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\mmx.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\SDL_sysrender.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_blendline.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_draw.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_drawline.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_rotate.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_assert_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_error_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_fatal.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_hints_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\SDL_systhread.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\SDL_thread_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\timer\SDL_timer_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit_auto.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit_copy.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit_slow.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_pixels_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_rect_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_shape_internals.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_sysvideo.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_config_winrt.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_common.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_filesystem.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\SDL_d3dmath.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_overrides.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_procs.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h">
      <Filter>Source Files</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\src\atomic\SDL_atomic.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\atomic\SDL_spinlock.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audio.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audiocvt.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audiodev.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_mixer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_wave.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\windows\SDL_windows.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_clipboardevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_dropevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_events.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_gesture.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_keyboard.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_mouse.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_quit.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_touch.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_windowevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\file\SDL_rwops.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\haptic\SDL_haptic.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\joystick\SDL_joystick.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_render.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_blendline.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_drawline.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_render_sw.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_rotate.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_assert.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_error.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_hints.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_log.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_getenv.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_iconv.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_qsort.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_string.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\SDL_thread.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\timer\SDL_timer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_0.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_1.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_A.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_auto.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_copy.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_N.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_slow.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_bmp.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_clipboard.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_fillrect.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_pixels.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_rect.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_RLEaccel.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_shape.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_stretch.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_surface.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_video.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_common.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\filesystem\winrt\SDL_sysfilesystem.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_d3dmath.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\dynapi\SDL_dynapi.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\power\winrt\SDL_syspower.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\power\SDL_power.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_winrt.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
  </ItemGroup>
</Project>
source/VisualC-WinRT/SDL-WinRT_VS2012.sln
New file
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL-WinRT", "SDL\SDL-WinRT_VS2012.vcxproj", "{AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|ARM = Debug|ARM
        Debug|Win32 = Debug|Win32
        Debug|x64 = Debug|x64
        Release|ARM = Release|ARM
        Release|Win32 = Release|Win32
        Release|x64 = Release|x64
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|ARM.ActiveCfg = Debug|ARM
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|ARM.Build.0 = Debug|ARM
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|Win32.ActiveCfg = Debug|Win32
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|Win32.Build.0 = Debug|Win32
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|x64.ActiveCfg = Debug|x64
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|x64.Build.0 = Debug|x64
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|ARM.ActiveCfg = Release|ARM
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|ARM.Build.0 = Release|ARM
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|Win32.ActiveCfg = Release|Win32
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|Win32.Build.0 = Release|Win32
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|x64.ActiveCfg = Release|x64
        {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|x64.Build.0 = Release|x64
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
EndGlobal
source/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj
New file
@@ -0,0 +1,519 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
    <ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
    <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
    <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
    <ClCompile Include="..\..\src\audio\SDL_audio.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiocvt.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
    <ClCompile Include="..\..\src\audio\SDL_mixer.c" />
    <ClCompile Include="..\..\src\audio\SDL_wave.c" />
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c" />
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_common.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
    <ClCompile Include="..\..\src\dynapi\SDL_dynapi.c" />
    <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
    <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
    <ClCompile Include="..\..\src\events\SDL_events.c" />
    <ClCompile Include="..\..\src\events\SDL_gesture.c" />
    <ClCompile Include="..\..\src\events\SDL_keyboard.c" />
    <ClCompile Include="..\..\src\events\SDL_mouse.c" />
    <ClCompile Include="..\..\src\events\SDL_quit.c" />
    <ClCompile Include="..\..\src\events\SDL_touch.c" />
    <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
    <ClCompile Include="..\..\src\filesystem\winrt\SDL_sysfilesystem.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\file\SDL_rwops.c" />
    <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c" />
    <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
    <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
    <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
    <ClCompile Include="..\..\src\joystick\winrt\SDL_xinputjoystick.c" />
    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
    <ClCompile Include="..\..\src\power\SDL_power.c" />
    <ClCompile Include="..\..\src\power\winrt\SDL_syspower.cpp" />
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.c" />
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_winrt.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
    <ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
    <ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
    <ClCompile Include="..\..\src\render\SDL_render.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_render_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_rotate.c" />
    <ClCompile Include="..\..\src\SDL.c" />
    <ClCompile Include="..\..\src\SDL_assert.c" />
    <ClCompile Include="..\..\src\SDL_error.c" />
    <ClCompile Include="..\..\src\SDL_hints.c" />
    <ClCompile Include="..\..\src\SDL_log.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
    <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c" />
    <ClCompile Include="..\..\src\thread\SDL_thread.c" />
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp" />
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp" />
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp" />
    <ClCompile Include="..\..\src\timer\SDL_timer.c" />
    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c" />
    <ClCompile Include="..\..\src\video\SDL_blit.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
    <ClCompile Include="..\..\src\video\SDL_bmp.c" />
    <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
    <ClCompile Include="..\..\src\video\SDL_egl.c" />
    <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
    <ClCompile Include="..\..\src\video\SDL_pixels.c" />
    <ClCompile Include="..\..\src\video\SDL_rect.c" />
    <ClCompile Include="..\..\src\video\SDL_RLEaccel.c" />
    <ClCompile Include="..\..\src\video\SDL_shape.c" />
    <ClCompile Include="..\..\src\video\SDL_stretch.c" />
    <ClCompile Include="..\..\src\video\SDL_surface.c" />
    <ClCompile Include="..\..\src\video\SDL_video.c" />
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtopengles.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\..\include\begin_code.h" />
    <ClInclude Include="..\..\include\close_code.h" />
    <ClInclude Include="..\..\include\SDL.h" />
    <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_config.h" />
    <ClInclude Include="..\..\include\SDL_config_minimal.h" />
    <ClInclude Include="..\..\include\SDL_config_winrt.h" />
    <ClInclude Include="..\..\include\SDL_copying.h" />
    <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
    <ClInclude Include="..\..\include\SDL_egl.h" />
    <ClInclude Include="..\..\include\SDL_endian.h" />
    <ClInclude Include="..\..\include\SDL_error.h" />
    <ClInclude Include="..\..\include\SDL_events.h" />
    <ClInclude Include="..\..\include\SDL_filesystem.h" />
    <ClInclude Include="..\..\include\SDL_haptic.h" />
    <ClInclude Include="..\..\include\SDL_hints.h" />
    <ClInclude Include="..\..\include\SDL_input.h" />
    <ClInclude Include="..\..\include\SDL_joystick.h" />
    <ClInclude Include="..\..\include\SDL_keyboard.h" />
    <ClInclude Include="..\..\include\SDL_keycode.h" />
    <ClInclude Include="..\..\include\SDL_loadso.h" />
    <ClInclude Include="..\..\include\SDL_log.h" />
    <ClInclude Include="..\..\include\SDL_main.h" />
    <ClInclude Include="..\..\include\SDL_mouse.h" />
    <ClInclude Include="..\..\include\SDL_mutex.h" />
    <ClInclude Include="..\..\include\SDL_name.h" />
    <ClInclude Include="..\..\include\SDL_opengles2.h" />
    <ClInclude Include="..\..\include\SDL_pixels.h" />
    <ClInclude Include="..\..\include\SDL_platform.h" />
    <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" />
    <ClInclude Include="..\..\include\SDL_shape.h" />
    <ClInclude Include="..\..\include\SDL_stdinc.h" />
    <ClInclude Include="..\..\include\SDL_surface.h" />
    <ClInclude Include="..\..\include\SDL_system.h" />
    <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" />
    <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
    <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
    <ClInclude Include="..\..\src\audio\SDL_wave.h" />
    <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
    <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_common.h" />
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_overrides.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_procs.h" />
    <ClInclude Include="..\..\src\events\blank_cursor.h" />
    <ClInclude Include="..\..\src\events\default_cursor.h" />
    <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
    <ClInclude Include="..\..\src\events\SDL_dropevents_c.h" />
    <ClInclude Include="..\..\src\events\SDL_events_c.h" />
    <ClInclude Include="..\..\src\events\SDL_keyboard_c.h" />
    <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
    <ClInclude Include="..\..\src\events\SDL_sysevents.h" />
    <ClInclude Include="..\..\src\events\SDL_touch_c.h" />
    <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
    <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
    <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
    <ClInclude Include="..\..\src\joystick\SDL_gamecontrollerdb.h" />
    <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
    <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
    <ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h" />
    <ClInclude Include="..\..\src\render\mmx.h" />
    <ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h" />
    <ClInclude Include="..\..\src\render\opengles2\SDL_shaders_gles2.h" />
    <ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
    <ClInclude Include="..\..\src\render\software\SDL_draw.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h" />
    <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_rotate.h" />
    <ClInclude Include="..\..\src\SDL_assert_c.h" />
    <ClInclude Include="..\..\src\SDL_error_c.h" />
    <ClInclude Include="..\..\src\SDL_fatal.h" />
    <ClInclude Include="..\..\src\SDL_hints_c.h" />
    <ClInclude Include="..\..\src\SDL_internal.h" />
    <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
    <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h" />
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h" />
    <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h" />
    <ClInclude Include="..\..\src\video\SDL_blit.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
    <ClInclude Include="..\..\src\video\SDL_egl.h" />
    <ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
    <ClInclude Include="..\..\src\video\SDL_rect_c.h" />
    <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
    <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h" />
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtopengles.h" />
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h" />
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</ProjectGuid>
    <Keyword>Win32Proj</Keyword>
    <ProjectName>SDL-WinRT</ProjectName>
    <RootNamespace>SDL_VS2012_WinRT</RootNamespace>
    <DefaultLanguage>en-US</DefaultLanguage>
    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
    <AppContainerApplication>true</AppContainerApplication>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <GenerateManifest>false</GenerateManifest>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
    <TargetName>SDL</TargetName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <GenerateManifest>false</GenerateManifest>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
    <TargetName>SDL</TargetName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <GenerateManifest>false</GenerateManifest>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
    <TargetName>SDL</TargetName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <GenerateManifest>false</GenerateManifest>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
    <TargetName>SDL</TargetName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <GenerateManifest>false</GenerateManifest>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
    <TargetName>SDL</TargetName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <GenerateManifest>false</GenerateManifest>
    <IgnoreImportLibrary>false</IgnoreImportLibrary>
    <TargetName>SDL</TargetName>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <CompileAsWinRT>false</CompileAsWinRT>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
      <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
      <AdditionalDependencies>xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
source/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters
New file
@@ -0,0 +1,678 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <ClCompile Include="..\..\src\SDL.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_assert.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\atomic\SDL_atomic.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audio.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audiocvt.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audiodev.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_blendline.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_0.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_1.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_A.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_auto.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_copy.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_N.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_blit_slow.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_bmp.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_clipboard.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_clipboardevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_drawline.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_dropevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_error.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_events.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_fillrect.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_gesture.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_getenv.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\haptic\SDL_haptic.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_hints.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_iconv.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\joystick\SDL_joystick.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_keyboard.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\SDL_log.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_mixer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_mouse.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_pixels.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_qsort.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_quit.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_rect.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_render.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_render_sw.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_RLEaccel.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\software\SDL_rotate.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\file\SDL_rwops.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_shape.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\atomic\SDL_spinlock.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_stretch.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_string.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_surface.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\haptic\dummy\SDL_syshaptic.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\generic\SDL_syssem.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\thread\SDL_thread.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\timer\SDL_timer.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_touch.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_video.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\SDL_wave.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\events\SDL_windowevents.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\windows\SDL_windows.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\joystick\winrt\SDL_xinputjoystick.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_common.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\filesystem\winrt\SDL_sysfilesystem.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\SDL_egl.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\video\winrt\SDL_winrtopengles.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\SDL_d3dmath.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\dynapi\SDL_dynapi.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\power\SDL_power.c">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\render\direct3d11\SDL_render_winrt.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
    <ClCompile Include="..\..\src\power\winrt\SDL_syspower.cpp">
      <Filter>Source Files</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\..\include\begin_code.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\close_code.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_assert.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_error_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_events_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\haptic\SDL_haptic_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_hints_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_mouse_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_sysmutex_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_types.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_assert_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_dropevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_keyboard_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_pixels_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\stdcpp\SDL_systhread_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\SDL_thread_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\timer\SDL_timer_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_touch_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_windowevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_audio.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_atomic.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_blendmode.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_clipboard.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_audiomem.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_blendline.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit_auto.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit_copy.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_blit_slow.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\mmx.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_config.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_config_minimal.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_copying.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_cpuinfo.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_draw.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_drawline.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_endian.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_error.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_events.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_fatal.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_main.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_haptic.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_hints.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_input.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_joystick.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_keyboard.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_keycode.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_loadso.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_log.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_name.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_mouse.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_mutex.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\dummy\SDL_nullvideo.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_quit.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_pixels.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_platform.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_power.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_rect_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_rect.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\software\SDL_rotate.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_shape.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_render.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_revision.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_rwops.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_scancode.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_surface.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_stdinc.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_video.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_syswm.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_thread.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_timer.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_touch.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_version.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_shape_internals.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_sysaudio.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\SDL_sysevents.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\SDL_sysrender.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\thread\SDL_systhread.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_sysvideo.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\SDL_wave.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\windows\SDL_windows.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\blank_cursor.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\events\default_cursor.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_system.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\joystick\SDL_gamecontrollerdb.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_config_winrt.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_common.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_filesystem.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\winrt\SDL_winrtopengles.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\video\SDL_egl.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_opengles2.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\include\SDL_egl.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\opengles2\SDL_shaders_gles2.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\SDL_internal.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\SDL_d3dmath.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_overrides.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_procs.h">
      <Filter>Source Files</Filter>
    </ClInclude>
    <ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h">
      <Filter>Source Files</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <Filter Include="Header Files">
      <UniqueIdentifier>{20773b57-7034-4c24-af5a-334844585f1b}</UniqueIdentifier>
    </Filter>
    <Filter Include="Source Files">
      <UniqueIdentifier>{ddf04d85-6a87-4c5a-bc52-869b38f45a61}</UniqueIdentifier>
    </Filter>
  </ItemGroup>
</Project>
source/VisualC-WinRT/tests/loopwave/Assets/Logo.png
source/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png
source/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png
source/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png
source/VisualC-WinRT/tests/loopwave/Package.appxmanifest
New file
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
  <Identity Name="1702c480-cf09-431e-a5e4-b21b283ec818"
            Publisher="CN=David"
            Version="1.0.0.0" />
  <Properties>
    <DisplayName>loopwave_VS2012_WinRT</DisplayName>
    <PublisherDisplayName>David</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Prerequisites>
    <OSMinVersion>6.2.1</OSMinVersion>
    <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
  </Prerequisites>
  <Resources>
    <Resource Language="x-generate"/>
  </Resources>
  <Applications>
    <Application Id="App"
        Executable="$targetnametoken$.exe"
        EntryPoint="loopwave_VS2012_WinRT.App">
        <VisualElements
            DisplayName="loopwave_VS2012_WinRT"
            Logo="Assets\Logo.png"
            SmallLogo="Assets\SmallLogo.png"
            Description="loopwave_VS2012_WinRT"
            ForegroundText="light"
            BackgroundColor="#464646">
            <DefaultTile ShowName="allLogos" />
            <SplashScreen Image="Assets\SplashScreen.png" />
        </VisualElements>
    </Application>
  </Applications>
  <Capabilities>
    <Capability Name="internetClient" />
  </Capabilities>
</Package>
source/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj
New file
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{03fcc293-9406-49c2-acf6-6e7d460c3239}</ProjectGuid>
    <RootNamespace>loopwave_VS2012</RootNamespace>
    <DefaultLanguage>en-US</DefaultLanguage>
    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
    <AppContainerApplication>true</AppContainerApplication>
    <ProjectName>loopwave</ProjectName>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <PackageCertificateKeyFile>loopwave_VS2012_TemporaryKey.pfx</PackageCertificateKeyFile>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <Link>
      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies)</AdditionalDependencies>
    </Link>
    <ClCompile>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
      <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
      <AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);$(ProjectDir)..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <DisableSpecificWarnings>4453</DisableSpecificWarnings>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
    <ClCompile>
      <PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsWinRT>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
    <ClCompile>
      <PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsWinRT>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemGroup>
    <Image Include="Assets\Logo.png" />
    <Image Include="Assets\SmallLogo.png" />
    <Image Include="Assets\StoreLogo.png" />
    <Image Include="Assets\SplashScreen.png" />
  </ItemGroup>
  <ItemGroup>
    <AppxManifest Include="Package.appxmanifest">
      <SubType>Designer</SubType>
    </AppxManifest>
    <None Include="loopwave_VS2012_TemporaryKey.pfx" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\..\src\main\winrt\SDL_winrt_main_NonXAML.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\..\test\loopwave.c">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsWinRT>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <Media Include="..\..\..\test\sample.wav" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\SDL\SDL-WinRT_VS2012.vcxproj">
      <Project>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</Project>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
source/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx
Binary files differ
source/VisualC-WinRT/tests/testthread/Assets/Logo.png
source/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png
source/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png
source/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png
source/VisualC-WinRT/tests/testthread/Package.appxmanifest
New file
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
  <Identity Name="ca3178f1-b2b2-43bf-97dd-28ee1b7d32c5"
            Publisher="CN=David"
            Version="1.0.0.0" />
  <Properties>
    <DisplayName>testthread_VS2012_WinRT</DisplayName>
    <PublisherDisplayName>David</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Prerequisites>
    <OSMinVersion>6.2.1</OSMinVersion>
    <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
  </Prerequisites>
  <Resources>
    <Resource Language="x-generate"/>
  </Resources>
  <Applications>
    <Application Id="App"
        Executable="$targetnametoken$.exe"
        EntryPoint="testthread_VS2012_WinRT.App">
        <VisualElements
            DisplayName="testthread_VS2012_WinRT"
            Logo="Assets\Logo.png"
            SmallLogo="Assets\SmallLogo.png"
            Description="testthread_VS2012_WinRT"
            ForegroundText="light"
            BackgroundColor="#464646">
            <DefaultTile ShowName="allLogos" />
            <SplashScreen Image="Assets\SplashScreen.png" />
        </VisualElements>
    </Application>
  </Applications>
  <Capabilities>
    <Capability Name="internetClient" />
  </Capabilities>
</Package>
source/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj
New file
@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|ARM">
      <Configuration>Debug</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|ARM">
      <Configuration>Release</Configuration>
      <Platform>ARM</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{a8705bee-d01d-46a4-b2ab-feedfb5fdd11}</ProjectGuid>
    <RootNamespace>testthread_VS2012</RootNamespace>
    <DefaultLanguage>en-US</DefaultLanguage>
    <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
    <AppContainerApplication>true</AppContainerApplication>
    <ProjectName>testthread</ProjectName>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <PlatformToolset>v110</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <PackageCertificateKeyFile>testthread_VS2012_TemporaryKey.pfx</PackageCertificateKeyFile>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <Link>
      <AdditionalDependencies>d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies)</AdditionalDependencies>
    </Link>
    <ClCompile>
      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
      <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
      <AdditionalIncludeDirectories>$(ProjectDir);$(IntermediateOutputPath);$(ProjectDir)..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <DisableSpecificWarnings>4453</DisableSpecificWarnings>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
    <ClCompile>
      <PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsWinRT>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
    <ClCompile>
      <PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsWinRT>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemGroup>
    <Image Include="Assets\Logo.png" />
    <Image Include="Assets\SmallLogo.png" />
    <Image Include="Assets\StoreLogo.png" />
    <Image Include="Assets\SplashScreen.png" />
  </ItemGroup>
  <ItemGroup>
    <AppxManifest Include="Package.appxmanifest">
      <SubType>Designer</SubType>
    </AppxManifest>
    <None Include="testthread_VS2012_TemporaryKey.pfx" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\..\src\main\winrt\SDL_winrt_main_NonXAML.cpp">
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    </ClCompile>
    <ClCompile Include="..\..\..\test\testthread.c" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\SDL\SDL-WinRT_VS2012.vcxproj">
      <Project>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</Project>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
source/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx
Binary files differ
source/VisualC/SDL/SDL_VS2008.vcproj
@@ -415,16 +415,12 @@
                RelativePath="..\..\include\SDL_cpuinfo.h"
                >
            </File>
            <File
                RelativePath="..\..\include\\SDL_egl.h"
            <File
                RelativePath="..\..\include\SDL_egl.h"
                >
            </File>
            <File
                RelativePath="..\..\src\video\sdl_egl_c.h"
                >
            </File>
            <File
                RelativePath="..\..\src\video\windows\SDL_windowsopengles.h"
            <File
                RelativePath="..\..\src\video\sdl_egl_c.h"
                >
            </File>
            <File
@@ -585,6 +581,10 @@
            </File>
            <File
                RelativePath="..\..\include\SDL_video.h"
                >
            </File>
            <File
                RelativePath="..\..\src\video\windows\SDL_windowsopengles.h"
                >
            </File>
        </Filter>
@@ -809,6 +809,14 @@
            >
        </File>
        <File
            RelativePath="..\..\src\render\SDL_d3dmath.c"
            >
        </File>
        <File
            RelativePath="..\..\src\render\SDL_d3dmath.h"
            >
        </File>
        <File
            RelativePath="..\..\src\audio\directsound\SDL_directsound.c"
            >
        </File>
@@ -862,6 +870,26 @@
        </File>
        <File
            RelativePath="..\..\src\joystick\windows\SDL_dxjoystick.c"
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi.c"
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi.h"
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi_overrides.h"
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi_procs.h"
            >
        </File>
        <File
            RelativePath="..\..\src\video\SDL_egl.c"
            >
        </File>
        <File
@@ -1025,7 +1053,15 @@
            >
        </File>
        <File
            RelativePath="..\..\src\render\direct3d11\SDL_render_d3d11.c"
            >
        </File>
        <File
            RelativePath="..\..\src\render\opengl\SDL_render_gl.c"
            >
        </File>
        <File
            RelativePath="..\..\src\render\opengles2\SDL_render_gles2.c"
            >
        </File>
        <File
@@ -1062,6 +1098,10 @@
        </File>
        <File
            RelativePath="..\..\src\render\opengl\SDL_shaders_gl.h"
            >
        </File>
        <File
            RelativePath="..\..\src\render\opengles2\SDL_shaders_gles2.c"
            >
        </File>
        <File
@@ -1145,10 +1185,6 @@
            >
        </File>
        <File
            RelativePath="..\..\src\thread\windows\SDL_systls.c"
            >
        </File>
        <File
            RelativePath="..\..\src\thread\SDL_systhread.h"
            >
        </File>
@@ -1162,6 +1198,10 @@
        </File>
        <File
            RelativePath="..\..\src\timer\SDL_systimer.h"
            >
        </File>
        <File
            RelativePath="..\..\src\thread\windows\SDL_systls.c"
            >
        </File>
        <File
@@ -1225,22 +1265,6 @@
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi.h"
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi_overrides.h"
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi_procs.h"
            >
        </File>
        <File
            RelativePath="..\..\src\dynapi\SDL_dynapi.c"
            >
        </File>
        <File
            RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
            >
        </File>
@@ -1301,23 +1325,11 @@
            >
        </File>
        <File
            RelativePath="..\..\src\render\opengles2\SDL_render_gles2.c"
            >
        </File>
        <File
            RelativePath="..\..\src\render\opengles2\SDL_shaders_gles2.c"
            >
        </File>
        <File
            RelativePath="..\..\src\video\SDL_egl.c"
            >
        </File>
        <File
            RelativePath="..\..\src\video\windows\SDL_windowsopengles.c"
            RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
            >
        </File>
        <File
            RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
            RelativePath="..\..\src\video\windows\SDL_windowsopengles.c"
            >
        </File>
        <File
source/VisualC/SDL/SDL_VS2010.vcxproj
@@ -492,6 +492,7 @@
    <ClInclude Include="..\..\src\libm\math_private.h" />
    <ClInclude Include="..\..\src\render\mmx.h" />
    <ClInclude Include="..\..\src\render\opengl\SDL_shaders_gl.h" />
    <ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
@@ -581,9 +582,11 @@
    <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\direct3d11\SDL_render_d3d11.c" />
    <ClCompile Include="..\..\src\render\direct3d\SDL_render_d3d.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_render_gl.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
    <ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
    <ClCompile Include="..\..\src\render\SDL_render.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
@@ -687,4 +690,4 @@
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
</Project>
source/VisualC/SDL/SDL_VS2012.vcxproj
@@ -283,6 +283,7 @@
    <ClInclude Include="..\..\src\libm\math_private.h" />
    <ClInclude Include="..\..\src\render\mmx.h" />
    <ClInclude Include="..\..\src\render\opengl\SDL_shaders_gl.h" />
    <ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
@@ -372,9 +373,11 @@
    <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\direct3d11\SDL_render_d3d11.c" />
    <ClCompile Include="..\..\src\render\direct3d\SDL_render_d3d.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_render_gl.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
    <ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
    <ClCompile Include="..\..\src\render\SDL_render.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
source/VisualC/SDL/SDL_VS2013.vcxproj
@@ -1,483 +1,486 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectName>SDL2</ProjectName>
    <ProjectGuid>{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}</ProjectGuid>
    <RootNamespace>SDL</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <CharacterSet>MultiByte</CharacterSet>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <PreBuildEvent />
    <Midl>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>Win32</TargetEnvironment>
    </Midl>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
      <CompileAs>Default</CompileAs>
      <ExceptionHandling>false</ExceptionHandling>
      <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <SubSystem>Windows</SubSystem>
      <CLRUnmanagedCodeCheck>false</CLRUnmanagedCodeCheck>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x86</AdditionalLibraryDirectories>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Midl>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>X64</TargetEnvironment>
    </Midl>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
      <ExceptionHandling>false</ExceptionHandling>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <SubSystem>Windows</SubSystem>
      <CLRUnmanagedCodeCheck>false</CLRUnmanagedCodeCheck>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x64</AdditionalLibraryDirectories>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <PreBuildEvent />
    <Midl>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>Win32</TargetEnvironment>
    </Midl>
    <ClCompile>
      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
      <IntrinsicFunctions>false</IntrinsicFunctions>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <StringPooling>true</StringPooling>
      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <CompileAs>Default</CompileAs>
      <ExceptionHandling>false</ExceptionHandling>
      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
      <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <SubSystem>Windows</SubSystem>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x86</AdditionalLibraryDirectories>
      <OptimizeReferences>true</OptimizeReferences>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Midl>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>X64</TargetEnvironment>
    </Midl>
    <ClCompile>
      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
      <IntrinsicFunctions>false</IntrinsicFunctions>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <StringPooling>true</StringPooling>
      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <ExceptionHandling>false</ExceptionHandling>
      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <SubSystem>Windows</SubSystem>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x64</AdditionalLibraryDirectories>
      <OptimizeReferences>true</OptimizeReferences>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClInclude Include="..\..\include\SDL.h" />
    <ClInclude Include="..\..\include\SDL_assert.h" />
    <ClInclude Include="..\..\include\SDL_atomic.h" />
    <ClInclude Include="..\..\include\SDL_audio.h" />
    <ClInclude Include="..\..\include\SDL_bits.h" />
    <ClInclude Include="..\..\include\SDL_blendmode.h" />
    <ClInclude Include="..\..\include\SDL_clipboard.h" />
    <ClInclude Include="..\..\include\SDL_config.h" />
    <ClInclude Include="..\..\include\SDL_config_windows.h" />
    <ClInclude Include="..\..\include\SDL_copying.h" />
    <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
    <ClInclude Include="..\..\include\SDL_egl.h" />
    <ClInclude Include="..\..\include\SDL_endian.h" />
    <ClInclude Include="..\..\include\SDL_error.h" />
    <ClInclude Include="..\..\include\SDL_events.h" />
    <ClInclude Include="..\..\include\SDL_filesystem.h" />
    <ClInclude Include="..\..\include\SDL_gesture.h" />
    <ClInclude Include="..\..\include\SDL_haptic.h" />
    <ClInclude Include="..\..\include\SDL_hints.h" />
    <ClInclude Include="..\..\include\SDL_joystick.h" />
    <ClInclude Include="..\..\include\SDL_keyboard.h" />
    <ClInclude Include="..\..\include\SDL_keycode.h" />
    <ClInclude Include="..\..\include\SDL_loadso.h" />
    <ClInclude Include="..\..\include\SDL_log.h" />
    <ClInclude Include="..\..\include\SDL_main.h" />
    <ClInclude Include="..\..\include\SDL_mouse.h" />
    <ClInclude Include="..\..\include\SDL_mutex.h" />
    <ClInclude Include="..\..\include\SDL_name.h" />
    <ClInclude Include="..\..\include\SDL_opengl.h" />
    <ClInclude Include="..\..\include\SDL_opengles.h" />
    <ClInclude Include="..\..\include\SDL_pixels.h" />
    <ClInclude Include="..\..\include\SDL_platform.h" />
    <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" />
    <ClInclude Include="..\..\include\SDL_shape.h" />
    <ClInclude Include="..\..\include\SDL_stdinc.h" />
    <ClInclude Include="..\..\include\SDL_surface.h" />
    <ClInclude Include="..\..\include\SDL_system.h" />
    <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" />
    <ClInclude Include="..\..\include\SDL_gamecontroller.h" />
    <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_overrides.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_procs.h" />
    <ClInclude Include="..\..\src\events\blank_cursor.h" />
    <ClInclude Include="..\..\src\events\default_cursor.h" />
    <ClInclude Include="..\..\src\audio\directsound\directx.h" />
    <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
    <ClInclude Include="..\..\src\events\SDL_gesture_c.h" />
    <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\mmx.h" />
    <ClInclude Include="..\..\src\render\opengl\SDL_shaders_gl.h" />
    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
    <ClInclude Include="..\..\src\render\software\SDL_draw.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h" />
    <ClInclude Include="..\..\src\events\SDL_dropevents_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_rotate.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
    <ClInclude Include="..\..\src\video\SDL_blit.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
    <ClInclude Include="..\..\src\video\sdl_egl_c.h" />
    <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    <ClInclude Include="..\..\src\audio\winmm\SDL_winmm.h" />
    <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
    <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
    <ClInclude Include="..\..\src\audio\directsound\SDL_directsound.h" />
    <ClInclude Include="..\..\src\SDL_error_c.h" />
    <ClInclude Include="..\..\src\SDL_hints_c.h" />
    <ClInclude Include="..\..\src\events\SDL_events_c.h" />
    <ClInclude Include="..\..\src\video\SDL_glesfuncs.h" />
    <ClInclude Include="..\..\src\video\SDL_glfuncs.h" />
    <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
    <ClInclude Include="..\..\src\events\SDL_keyboard_c.h" />
    <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_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_RLEaccel_c.h" />
    <ClInclude Include="..\..\src\video\SDL_stretch_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
    <ClInclude Include="..\..\src\events\SDL_sysevents.h" />
    <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
    <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
    <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
    <ClInclude Include="..\..\src\thread\windows\SDL_systhread_c.h" />
    <ClInclude Include="..\..\src\timer\SDL_systimer.h" />
    <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
    <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_vkeys.h" />
    <ClInclude Include="..\..\src\audio\SDL_wave.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsclipboard.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsevents.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsframebuffer.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowskeyboard.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsmessagebox.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsmodes.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsmouse.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsopengl.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsopengles.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsshape.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsvideo.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowswindow.h" />
    <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
    <ClInclude Include="..\..\src\video\windows\wmmsg.h" />
    <ClInclude Include="resource.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
    <ClCompile Include="..\..\src\dynapi\SDL_dynapi.c" />
    <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
    <ClCompile Include="..\..\src\events\SDL_gesture.c" />
    <ClCompile Include="..\..\src\events\SDL_touch.c" />
    <ClCompile Include="..\..\src\libm\e_atan2.c" />
    <ClCompile Include="..\..\src\libm\e_log.c" />
    <ClCompile Include="..\..\src\libm\e_pow.c" />
    <ClCompile Include="..\..\src\libm\e_rem_pio2.c" />
    <ClCompile Include="..\..\src\libm\e_sqrt.c" />
    <ClCompile Include="..\..\src\libm\k_cos.c" />
    <ClCompile Include="..\..\src\libm\k_rem_pio2.c" />
    <ClCompile Include="..\..\src\libm\k_sin.c" />
    <ClCompile Include="..\..\src\libm\s_atan.c" />
    <ClCompile Include="..\..\src\libm\s_copysign.c" />
    <ClCompile Include="..\..\src\libm\s_cos.c" />
    <ClCompile Include="..\..\src\libm\s_fabs.c" />
    <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_render_d3d.c" />
    <ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
    <ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_render_gl.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
    <ClCompile Include="..\..\src\render\SDL_render.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_render_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_rotate.c" />
    <ClCompile Include="..\..\src\SDL.c" />
    <ClCompile Include="..\..\src\SDL_assert.c" />
    <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
    <ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
    <ClCompile Include="..\..\src\audio\SDL_audio.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiocvt.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
    <ClCompile Include="..\..\src\SDL_hints.c" />
    <ClCompile Include="..\..\src\SDL_log.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
    <ClCompile Include="..\..\src\video\SDL_blit.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
    <ClCompile Include="..\..\src\video\SDL_bmp.c" />
    <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
    <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
    <ClCompile Include="..\..\src\video\SDL_egl.c" />
    <ClCompile Include="..\..\src\video\SDL_shape.c" />
    <ClCompile Include="..\..\src\audio\winmm\SDL_winmm.c" />
    <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
    <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
    <ClCompile Include="..\..\src\audio\directsound\SDL_directsound.c" />
    <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c" />
    <ClCompile Include="..\..\src\joystick\windows\SDL_dxjoystick.c" />
    <ClCompile Include="..\..\src\SDL_error.c" />
    <ClCompile Include="..\..\src\events\SDL_events.c" />
    <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
    <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
    <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
    <ClCompile Include="..\..\src\events\SDL_keyboard.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
    <ClCompile Include="..\..\src\audio\SDL_mixer.c" />
    <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_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_RLEaccel.c" />
    <ClCompile Include="..\..\src\file\SDL_rwops.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
    <ClCompile Include="..\..\src\video\SDL_stretch.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
    <ClCompile Include="..\..\src\video\SDL_surface.c" />
    <ClCompile Include="..\..\src\thread\generic\SDL_syscond.c" />
    <ClCompile Include="..\..\src\filesystem\windows\SDL_sysfilesystem.c" />
    <ClCompile Include="..\..\src\haptic\windows\SDL_syshaptic.c" />
    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_sysmutex.c" />
    <ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_syssem.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_systhread.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_systls.c" />
    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
    <ClCompile Include="..\..\src\thread\SDL_thread.c" />
    <ClCompile Include="..\..\src\timer\SDL_timer.c" />
    <ClCompile Include="..\..\src\video\SDL_video.c" />
    <ClCompile Include="..\..\src\audio\SDL_wave.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsclipboard.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsevents.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsframebuffer.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowskeyboard.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsmessagebox.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsmodes.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsmouse.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsopengl.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsopengles.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsshape.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
    <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
    <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="..\..\src\main\windows\version.rc" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectName>SDL2</ProjectName>
    <ProjectGuid>{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}</ProjectGuid>
    <RootNamespace>SDL</RootNamespace>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>DynamicLibrary</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <CharacterSet>MultiByte</CharacterSet>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <PreBuildEvent />
    <Midl>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>Win32</TargetEnvironment>
    </Midl>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
      <CompileAs>Default</CompileAs>
      <ExceptionHandling>false</ExceptionHandling>
      <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <SubSystem>Windows</SubSystem>
      <CLRUnmanagedCodeCheck>false</CLRUnmanagedCodeCheck>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x86</AdditionalLibraryDirectories>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Midl>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>X64</TargetEnvironment>
    </Midl>
    <ClCompile>
      <Optimization>Disabled</Optimization>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
      <ExceptionHandling>false</ExceptionHandling>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <SubSystem>Windows</SubSystem>
      <CLRUnmanagedCodeCheck>false</CLRUnmanagedCodeCheck>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x64</AdditionalLibraryDirectories>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <PreBuildEvent />
    <Midl>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>Win32</TargetEnvironment>
    </Midl>
    <ClCompile>
      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
      <IntrinsicFunctions>false</IntrinsicFunctions>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <StringPooling>true</StringPooling>
      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <CompileAs>Default</CompileAs>
      <ExceptionHandling>false</ExceptionHandling>
      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
      <EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <SubSystem>Windows</SubSystem>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x86</AdditionalLibraryDirectories>
      <OptimizeReferences>true</OptimizeReferences>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Midl>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <MkTypLibCompatible>true</MkTypLibCompatible>
      <SuppressStartupBanner>true</SuppressStartupBanner>
      <TargetEnvironment>X64</TargetEnvironment>
    </Midl>
    <ClCompile>
      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
      <IntrinsicFunctions>false</IntrinsicFunctions>
      <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories);"$(DXSDK_DIR)\Include";</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <StringPooling>true</StringPooling>
      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
      <BufferSecurityCheck>false</BufferSecurityCheck>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <PrecompiledHeader>
      </PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <ExceptionHandling>false</ExceptionHandling>
      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
    </ClCompile>
    <ResourceCompile>
      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Culture>0x0409</Culture>
    </ResourceCompile>
    <Link>
      <AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
      <IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
      <SubSystem>Windows</SubSystem>
      <AdditionalLibraryDirectories>$(DXSDK_DIR)\lib\x64</AdditionalLibraryDirectories>
      <OptimizeReferences>true</OptimizeReferences>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <GenerateDebugInformation>true</GenerateDebugInformation>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClInclude Include="..\..\include\SDL.h" />
    <ClInclude Include="..\..\include\SDL_assert.h" />
    <ClInclude Include="..\..\include\SDL_atomic.h" />
    <ClInclude Include="..\..\include\SDL_audio.h" />
    <ClInclude Include="..\..\include\SDL_bits.h" />
    <ClInclude Include="..\..\include\SDL_blendmode.h" />
    <ClInclude Include="..\..\include\SDL_clipboard.h" />
    <ClInclude Include="..\..\include\SDL_config.h" />
    <ClInclude Include="..\..\include\SDL_config_windows.h" />
    <ClInclude Include="..\..\include\SDL_copying.h" />
    <ClInclude Include="..\..\include\SDL_cpuinfo.h" />
    <ClInclude Include="..\..\include\SDL_egl.h" />
    <ClInclude Include="..\..\include\SDL_endian.h" />
    <ClInclude Include="..\..\include\SDL_error.h" />
    <ClInclude Include="..\..\include\SDL_events.h" />
    <ClInclude Include="..\..\include\SDL_filesystem.h" />
    <ClInclude Include="..\..\include\SDL_gesture.h" />
    <ClInclude Include="..\..\include\SDL_haptic.h" />
    <ClInclude Include="..\..\include\SDL_hints.h" />
    <ClInclude Include="..\..\include\SDL_joystick.h" />
    <ClInclude Include="..\..\include\SDL_keyboard.h" />
    <ClInclude Include="..\..\include\SDL_keycode.h" />
    <ClInclude Include="..\..\include\SDL_loadso.h" />
    <ClInclude Include="..\..\include\SDL_log.h" />
    <ClInclude Include="..\..\include\SDL_main.h" />
    <ClInclude Include="..\..\include\SDL_mouse.h" />
    <ClInclude Include="..\..\include\SDL_mutex.h" />
    <ClInclude Include="..\..\include\SDL_name.h" />
    <ClInclude Include="..\..\include\SDL_opengl.h" />
    <ClInclude Include="..\..\include\SDL_opengles.h" />
    <ClInclude Include="..\..\include\SDL_pixels.h" />
    <ClInclude Include="..\..\include\SDL_platform.h" />
    <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" />
    <ClInclude Include="..\..\include\SDL_shape.h" />
    <ClInclude Include="..\..\include\SDL_stdinc.h" />
    <ClInclude Include="..\..\include\SDL_surface.h" />
    <ClInclude Include="..\..\include\SDL_system.h" />
    <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" />
    <ClInclude Include="..\..\include\SDL_gamecontroller.h" />
    <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_overrides.h" />
    <ClInclude Include="..\..\src\dynapi\SDL_dynapi_procs.h" />
    <ClInclude Include="..\..\src\events\blank_cursor.h" />
    <ClInclude Include="..\..\src\events\default_cursor.h" />
    <ClInclude Include="..\..\src\audio\directsound\directx.h" />
    <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
    <ClInclude Include="..\..\src\events\SDL_gesture_c.h" />
    <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\mmx.h" />
    <ClInclude Include="..\..\src\render\opengl\SDL_shaders_gl.h" />
    <ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
    <ClInclude Include="..\..\src\render\SDL_sysrender.h" />
    <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audio_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiodev_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_audiomem.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendfillrect.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_blendpoint.h" />
    <ClInclude Include="..\..\src\render\software\SDL_draw.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawline.h" />
    <ClInclude Include="..\..\src\render\software\SDL_drawpoint.h" />
    <ClInclude Include="..\..\src\events\SDL_dropevents_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_render_sw_c.h" />
    <ClInclude Include="..\..\src\render\software\SDL_rotate.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullframebuffer_c.h" />
    <ClInclude Include="..\..\src\video\SDL_blit.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_auto.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_copy.h" />
    <ClInclude Include="..\..\src\video\SDL_blit_slow.h" />
    <ClInclude Include="..\..\src\video\sdl_egl_c.h" />
    <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    <ClInclude Include="..\..\src\audio\winmm\SDL_winmm.h" />
    <ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
    <ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
    <ClInclude Include="..\..\src\audio\directsound\SDL_directsound.h" />
    <ClInclude Include="..\..\src\SDL_error_c.h" />
    <ClInclude Include="..\..\src\SDL_hints_c.h" />
    <ClInclude Include="..\..\src\events\SDL_events_c.h" />
    <ClInclude Include="..\..\src\video\SDL_glesfuncs.h" />
    <ClInclude Include="..\..\src\video\SDL_glfuncs.h" />
    <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
    <ClInclude Include="..\..\src\events\SDL_keyboard_c.h" />
    <ClInclude Include="..\..\src\events\SDL_mouse_c.h" />
    <ClInclude Include="..\..\src\video\dummy\SDL_nullevents_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_RLEaccel_c.h" />
    <ClInclude Include="..\..\src\video\SDL_stretch_c.h" />
    <ClInclude Include="..\..\src\audio\SDL_sysaudio.h" />
    <ClInclude Include="..\..\src\events\SDL_sysevents.h" />
    <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
    <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
    <ClInclude Include="..\..\src\thread\SDL_systhread.h" />
    <ClInclude Include="..\..\src\thread\windows\SDL_systhread_c.h" />
    <ClInclude Include="..\..\src\timer\SDL_systimer.h" />
    <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    <ClInclude Include="..\..\src\thread\SDL_thread_c.h" />
    <ClInclude Include="..\..\src\timer\SDL_timer_c.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_vkeys.h" />
    <ClInclude Include="..\..\src\audio\SDL_wave.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsclipboard.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsevents.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsframebuffer.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowskeyboard.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsmessagebox.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsmodes.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsmouse.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsopengl.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsopengles.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsshape.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowsvideo.h" />
    <ClInclude Include="..\..\src\video\windows\SDL_windowswindow.h" />
    <ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
    <ClInclude Include="..\..\src\video\windows\wmmsg.h" />
    <ClInclude Include="resource.h" />
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
    <ClCompile Include="..\..\src\dynapi\SDL_dynapi.c" />
    <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
    <ClCompile Include="..\..\src\events\SDL_gesture.c" />
    <ClCompile Include="..\..\src\events\SDL_touch.c" />
    <ClCompile Include="..\..\src\libm\e_atan2.c" />
    <ClCompile Include="..\..\src\libm\e_log.c" />
    <ClCompile Include="..\..\src\libm\e_pow.c" />
    <ClCompile Include="..\..\src\libm\e_rem_pio2.c" />
    <ClCompile Include="..\..\src\libm\e_sqrt.c" />
    <ClCompile Include="..\..\src\libm\k_cos.c" />
    <ClCompile Include="..\..\src\libm\k_rem_pio2.c" />
    <ClCompile Include="..\..\src\libm\k_sin.c" />
    <ClCompile Include="..\..\src\libm\s_atan.c" />
    <ClCompile Include="..\..\src\libm\s_copysign.c" />
    <ClCompile Include="..\..\src\libm\s_cos.c" />
    <ClCompile Include="..\..\src\libm\s_fabs.c" />
    <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\direct3d11\SDL_render_d3d11.c" />
    <ClCompile Include="..\..\src\render\direct3d\SDL_render_d3d.c" />
    <ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
    <ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_render_gl.c" />
    <ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
    <ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
    <ClCompile Include="..\..\src\render\SDL_render.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
    <ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_blendpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawline.c" />
    <ClCompile Include="..\..\src\render\software\SDL_drawpoint.c" />
    <ClCompile Include="..\..\src\render\software\SDL_render_sw.c" />
    <ClCompile Include="..\..\src\render\software\SDL_rotate.c" />
    <ClCompile Include="..\..\src\SDL.c" />
    <ClCompile Include="..\..\src\SDL_assert.c" />
    <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
    <ClCompile Include="..\..\src\atomic\SDL_spinlock.c" />
    <ClCompile Include="..\..\src\audio\SDL_audio.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiocvt.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
    <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
    <ClCompile Include="..\..\src\SDL_hints.c" />
    <ClCompile Include="..\..\src\SDL_log.c" />
    <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
    <ClCompile Include="..\..\src\video\SDL_blit.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_1.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_A.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_auto.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_copy.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_N.c" />
    <ClCompile Include="..\..\src\video\SDL_blit_slow.c" />
    <ClCompile Include="..\..\src\video\SDL_bmp.c" />
    <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
    <ClCompile Include="..\..\src\video\SDL_clipboard.c" />
    <ClCompile Include="..\..\src\video\SDL_egl.c" />
    <ClCompile Include="..\..\src\video\SDL_shape.c" />
    <ClCompile Include="..\..\src\audio\winmm\SDL_winmm.c" />
    <ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
    <ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
    <ClCompile Include="..\..\src\audio\directsound\SDL_directsound.c" />
    <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
    <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c" />
    <ClCompile Include="..\..\src\joystick\windows\SDL_dxjoystick.c" />
    <ClCompile Include="..\..\src\SDL_error.c" />
    <ClCompile Include="..\..\src\events\SDL_events.c" />
    <ClCompile Include="..\..\src\video\SDL_fillrect.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
    <ClCompile Include="..\..\src\haptic\SDL_haptic.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
    <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
    <ClCompile Include="..\..\src\events\SDL_keyboard.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
    <ClCompile Include="..\..\src\audio\SDL_mixer.c" />
    <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_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_RLEaccel.c" />
    <ClCompile Include="..\..\src\file\SDL_rwops.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
    <ClCompile Include="..\..\src\video\SDL_stretch.c" />
    <ClCompile Include="..\..\src\stdlib\SDL_string.c" />
    <ClCompile Include="..\..\src\video\SDL_surface.c" />
    <ClCompile Include="..\..\src\thread\generic\SDL_syscond.c" />
    <ClCompile Include="..\..\src\filesystem\windows\SDL_sysfilesystem.c" />
    <ClCompile Include="..\..\src\haptic\windows\SDL_syshaptic.c" />
    <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_sysmutex.c" />
    <ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_syssem.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_systhread.c" />
    <ClCompile Include="..\..\src\thread\windows\SDL_systls.c" />
    <ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
    <ClCompile Include="..\..\src\thread\SDL_thread.c" />
    <ClCompile Include="..\..\src\timer\SDL_timer.c" />
    <ClCompile Include="..\..\src\video\SDL_video.c" />
    <ClCompile Include="..\..\src\audio\SDL_wave.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsclipboard.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsevents.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsframebuffer.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowskeyboard.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsmessagebox.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsmodes.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsmouse.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsopengl.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsopengles.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsshape.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
    <ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
    <ClCompile Include="..\..\src\events\SDL_windowevents.c" />
    <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
  </ItemGroup>
  <ItemGroup>
    <ResourceCompile Include="..\..\src\main\windows\version.rc" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>
source/VisualC/SDL_VS2013.sln
@@ -112,6 +112,13 @@
        {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}
    EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testoverlay2", "tests\testoverlay2\testoverlay2_VS2013.vcxproj", "{55812185-D13C-4022-9C81-32E0F4A08AAD}"
    ProjectSection(ProjectDependencies) = postProject
        {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68} = {81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
        {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A} = {DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}
        {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A} = {DA956FD3-E143-46F2-9FE5-C77BEBC56B1A}
    EndProjectSection
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Win32 = Debug|Win32
@@ -178,6 +185,7 @@
        {26828762-C95D-4637-9CB1-7F0979523813}.Release|x64.Build.0 = Release|x64
        {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.ActiveCfg = Debug|Win32
        {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.Build.0 = Debug|Win32
        {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|Win32.Deploy.0 = Debug|Win32
        {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.ActiveCfg = Debug|x64
        {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Debug|x64.Build.0 = Debug|x64
        {40FB7794-D3C3-4CFE-BCF4-A80C96635682}.Release|Win32.ActiveCfg = Release|Win32
@@ -280,6 +288,14 @@
        {E5287C64-0646-4BFA-A772-1DB5A649F35E}.Release|Win32.Build.0 = Release|Win32
        {E5287C64-0646-4BFA-A772-1DB5A649F35E}.Release|x64.ActiveCfg = Release|x64
        {E5287C64-0646-4BFA-A772-1DB5A649F35E}.Release|x64.Build.0 = Release|x64
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.ActiveCfg = Debug|Win32
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|Win32.Build.0 = Debug|Win32
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.ActiveCfg = Debug|x64
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Debug|x64.Build.0 = Debug|x64
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.ActiveCfg = Release|Win32
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|Win32.Build.0 = Release|Win32
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.ActiveCfg = Release|x64
        {55812185-D13C-4022-9C81-32E0F4A08AAD}.Release|x64.Build.0 = Release|x64
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
@@ -302,5 +318,6 @@
        {55812185-D13C-4022-9C81-32E0F4A08996} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
        {55812185-D13C-4022-9C81-32E0F4A08BCC} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
        {E5287C64-0646-4BFA-A772-1DB5A649F35E} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
        {55812185-D13C-4022-9C81-32E0F4A08AAD} = {CE748C1F-3C21-4825-AA6A-F895A023F7E7}
    EndGlobalSection
EndGlobal
source/VisualC/tests/testoverlay2/testoverlay2_VS2013.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
@@ -27,23 +27,23 @@
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v110</PlatformToolset>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <CharacterSet>MultiByte</CharacterSet>
    <PlatformToolset>v110</PlatformToolset>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v110</PlatformToolset>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseOfMfc>false</UseOfMfc>
    <PlatformToolset>v110</PlatformToolset>
    <PlatformToolset>v120</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
source/WhatsNew.txt
@@ -2,6 +2,14 @@
This is a list of major changes in SDL's version history.
---------------------------------------------------------------------------
2.0.3:
---------------------------------------------------------------------------
Mac OS X:
* Fixed creating an OpenGL context by default on Mac OS X 10.6
---------------------------------------------------------------------------
2.0.2:
---------------------------------------------------------------------------
General:
source/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
@@ -561,6 +561,7 @@
            );
            name = CustomTemplate;
            sourceTree = "<group>";
            usesTabs = 0;
        };
        56A6702F18565E4F0007D20F /* dynapi */ = {
            isa = PBXGroup;
source/Xcode/SDL/Info-Framework.plist
@@ -19,10 +19,10 @@
    <key>CFBundlePackageType</key>
    <string>FMWK</string>
    <key>CFBundleShortVersionString</key>
    <string>2.0.2</string>
    <string>2.0.3</string>
    <key>CFBundleSignature</key>
    <string>SDLX</string>
    <key>CFBundleVersion</key>
    <string>2.0.2</string>
    <string>2.0.3</string>
</dict>
</plist>
source/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -2773,8 +2773,8 @@
        00CFA622106A567900758660 /* Release */ = {
            isa = XCBuildConfiguration;
            buildSettings = {
                DYLIB_COMPATIBILITY_VERSION = 1;
                DYLIB_CURRENT_VERSION = 1;
                DYLIB_COMPATIBILITY_VERSION = 1.0.0;
                DYLIB_CURRENT_VERSION = 3.1.0;
                FRAMEWORK_VERSION = A;
                HEADER_SEARCH_PATHS = /usr/X11R6/include;
                INFOPLIST_FILE = "Info-Framework.plist";
@@ -2827,8 +2827,8 @@
        00CFA628106A568900758660 /* Debug */ = {
            isa = XCBuildConfiguration;
            buildSettings = {
                DYLIB_COMPATIBILITY_VERSION = 1;
                DYLIB_CURRENT_VERSION = 1;
                DYLIB_COMPATIBILITY_VERSION = 1.0.0;
                DYLIB_CURRENT_VERSION = 3.1.0;
                FRAMEWORK_VERSION = A;
                HEADER_SEARCH_PATHS = /usr/X11R6/include;
                INFOPLIST_FILE = "Info-Framework.plist";
source/Xcode/SDLTest/SDLTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/project.xcworkspace/xcuserdata/urkle.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/All.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/SDL_test.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/checkkeys.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/loopwave.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testatomic.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testaudioinfo.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testdraw2.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testdrawchessboard.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testerror.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testfile.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testfilesystem.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testgamecontroller.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testgesture.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testgl2.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testhaptic.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testiconv.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testime.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testintersections.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testjoystick.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testkeys.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testloadso.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testlock.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testmessage.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testmultiaudio.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testnative.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testoverlay2.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testplatform.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testpower.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrelative.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrendercopyex.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrendertarget.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testresample.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testrumble.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testscale.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testsem.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testshader.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testshape.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testsprite2.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testspriteminimal.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/teststreaming.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testthread.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testtimer.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testversion.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/testwm2.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/torturethread.xcscheme
File was deleted
source/Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata/urkle.xcuserdatad/xcschemes/xcschememanagement.plist
File was deleted
source/build-scripts/raspberrypi-buildbot.sh
@@ -42,7 +42,7 @@
export CC="ccache /opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux -L$SYSROOT/opt/vc/lib"
# -L$SYSROOT/usr/lib/arm-linux-gnueabihf"
# !!! FIXME: shouldn't have to --disable-* things here.
../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd --disable-video-mir
$MAKE
$MAKE install
# Fix up a few things to a real install path on a real Raspberry Pi...
source/configure
@@ -2671,9 +2671,9 @@
#
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=0
SDL_MICRO_VERSION=2
SDL_INTERFACE_AGE=0
SDL_BINARY_AGE=2
SDL_MICRO_VERSION=3
SDL_INTERFACE_AGE=1
SDL_BINARY_AGE=3
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
@@ -21880,6 +21880,12 @@
fi
        ac_fn_c_check_header_mongrel "$LINENO" "d3d11_1.h" "ac_cv_header_d3d11_1_h" "$ac_includes_default"
if test "x$ac_cv_header_d3d11_1_h" = xyes; then :
  have_d3d11=yes
fi
        ac_fn_c_check_header_mongrel "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default"
if test "x$ac_cv_header_ddraw_h" = xyes; then :
  have_ddraw=yes
@@ -22717,6 +22723,11 @@
$as_echo "#define SDL_VIDEO_RENDER_D3D 1" >>confdefs.h
            fi
            if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then
$as_echo "#define SDL_VIDEO_RENDER_D3D11 1" >>confdefs.h
            fi
        fi
        # Set up files for the audio library
        if test x$enable_audio = xyes; then
source/configure.in
@@ -20,9 +20,9 @@
#
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=0
SDL_MICRO_VERSION=2
SDL_INTERFACE_AGE=0
SDL_BINARY_AGE=2
SDL_MICRO_VERSION=3
SDL_INTERFACE_AGE=1
SDL_BINARY_AGE=3
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
AC_SUBST(SDL_MAJOR_VERSION)
@@ -2394,6 +2394,7 @@
                  , enable_directx=yes)
    if test x$enable_directx = xyes; then
        AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
        AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
        AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
        AC_CHECK_HEADER(dsound.h, have_dsound=yes)
        AC_CHECK_HEADER(dinput.h, have_dinput=yes)
@@ -2791,6 +2792,9 @@
            if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
                AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
            fi
            if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then
                AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ])
            fi
        fi
        # Set up files for the audio library
        if test x$enable_audio = xyes; then
source/debian/changelog
@@ -1,3 +1,9 @@
libsdl2 (2.0.3) UNRELEASED; urgency=low
  * Updated SDL to version 2.0.3
 -- Sam Lantinga <slouken@libsdl.org>  Sun, 9 Mar 2014 10:35:54 -0800
libsdl2 (2.0.2) UNRELEASED; urgency=low
  * Updated SDL to version 2.0.2
source/include/SDL_config.h
@@ -33,6 +33,8 @@
#include "SDL_config_premake.h"
#elif defined(__WIN32__)
#include "SDL_config_windows.h"
#elif defined(__WINRT__)
#include "SDL_config_winrt.h"
#elif defined(__MACOSX__)
#include "SDL_config_macosx.h"
#elif defined(__IPHONEOS__)
source/include/SDL_config.h.cmake
@@ -295,6 +295,7 @@
#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@
#cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@
#cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@
#cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@
#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@
#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@
source/include/SDL_config.h.in
@@ -294,6 +294,7 @@
#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
#undef SDL_VIDEO_RENDER_D3D
#undef SDL_VIDEO_RENDER_D3D11
#undef SDL_VIDEO_RENDER_OGL
#undef SDL_VIDEO_RENDER_OGL_ES
#undef SDL_VIDEO_RENDER_OGL_ES2
source/include/SDL_config_windows.h
@@ -171,6 +171,9 @@
#ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D    1
#endif
#ifndef SDL_VIDEO_RENDER_D3D11
#define SDL_VIDEO_RENDER_D3D11    0
#endif
/* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL
source/include/SDL_config_winrt.h
New file
@@ -0,0 +1,190 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _SDL_config_windows_h
#define _SDL_config_windows_h
#include "SDL_platform.h"
/* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
#define HAVE_STDINT_H    1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
#ifdef  _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
#define DWORD_PTR DWORD
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */
#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
#ifdef _WIN64
# define SIZEOF_VOIDP 8
#else
# define SIZEOF_VOIDP 4
#endif
/* Useful headers */
#define HAVE_LIBC 1
#define HAVE_STDIO_H 1
#define STDC_HEADERS 1
#define HAVE_STRING_H 1
#define HAVE_CTYPE_H 1
#define HAVE_MATH_H 1
#define HAVE_FLOAT_H 1
#define HAVE_SIGNAL_H 1
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE__STRREV 1
#define HAVE__STRUPR 1
//#define HAVE__STRLWR 1    // TODO, WinRT: consider using _strlwr_s instead
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
//#define HAVE_ITOA 1   // TODO, WinRT: consider using _itoa_s instead
//#define HAVE__LTOA 1    // TODO, WinRT: consider using _ltoa_s instead
//#define HAVE__ULTOA 1    // TODO, WinRT: consider using _ultoa_s instead
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
//#define HAVE_STRTOLL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE__STRICMP 1
#define HAVE__STRNICMP 1
#define HAVE_VSNPRINTF 1
//#define HAVE_SSCANF 1    // TODO, WinRT: consider using sscanf_s instead
#define HAVE_M_PI 1
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_CEIL 1
#define HAVE__COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_FABS 1
#define HAVE_FLOOR 1
#define HAVE_LOG 1
#define HAVE_POW 1
//#define HAVE_SCALBN 1
#define HAVE__SCALB 1
#define HAVE_SIN 1
#define HAVE_SINF 1
#define HAVE_SQRT 1
#define HAVE__FSEEKI64 1
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_XAUDIO2    1
#define SDL_AUDIO_DRIVER_DISK    1
#define SDL_AUDIO_DRIVER_DUMMY    1
/* Enable various input drivers */
// TODO, WinRT: Get haptic support working
#define SDL_HAPTIC_DISABLED    1
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#define SDL_JOYSTICK_DISABLED 1
#else
#define SDL_JOYSTICK_XINPUT 1
#endif
/* Enable various shared object loading systems */
#define SDL_LOADSO_WINDOWS    1
/* Enable various threading systems */
#define SDL_THREAD_STDCPP   1
/* Enable various timer systems */
#define SDL_TIMER_WINDOWS    1
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_WINRT    1
#define SDL_VIDEO_DRIVER_DUMMY  1
/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP    /* TODO, WinRT: try adding OpenGL ES 2 support for Windows Phone 8 */
#define SDL_VIDEO_OPENGL_ES2 1
#define SDL_VIDEO_OPENGL_EGL 1
#endif
/* Enable appropriate renderer(s) */
#define SDL_VIDEO_RENDER_D3D11  1
#if SDL_VIDEO_OPENGL_ES2
#define SDL_VIDEO_RENDER_OGL_ES2 1
#endif
/* Enable system power support */
#define SDL_POWER_WINRT 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES    1
#endif
#endif /* _SDL_config_windows_h */
source/include/SDL_cpuinfo.h
@@ -32,7 +32,7 @@
/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
#include <intrin.h>
#ifndef _WIN64
#define __MMX__
source/include/SDL_egl.h
@@ -391,9 +391,16 @@
#endif
#include <windows.h>
#if __WINRT__
#include <Unknwn.h>
typedef IUnknown * EGLNativeWindowType;
typedef int EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
#else
typedef HDC     EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND    EGLNativeWindowType;
#endif
#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
source/include/SDL_hints.h
@@ -106,6 +106,19 @@
#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE"
/**
 *  \brief  A variable controlling whether to enable Direct3D 11+'s Debug Layer.
 *
 *  This variable does not have any effect on the Direct3D 9 based renderer.
 *
 *  This variable can be set to the following values:
 *    "0"       - Disable Debug Layer use
 *    "1"       - Enable Debug Layer use
 *
 *  By default, SDL does not use Direct3D Debug Layer.
 */
#define SDL_HINT_RENDER_DIRECT3D11_DEBUG    "SDL_HINT_RENDER_DIRECT3D11_DEBUG"
/**
 *  \brief  A variable controlling the scaling quality
 *
 *  This variable can be set to the following values:
@@ -334,7 +347,7 @@
*  If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has
*  SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly 
*  created SDL_Window:
*
*  1. Its pixel format will be set to the same pixel format as this SDL_Window.  This is
*  needed for example when sharing an OpenGL context across multiple windows.
*
@@ -347,6 +360,62 @@
*/
#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT    "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
/*
 *  \brief A URL to a WinRT app's privacy policy
 *
 *  All network-enabled WinRT apps must make a privacy policy available to its
 *  users.  On Windows 8, 8.1, and RT, Microsoft mandates that this policy be
 *  be available in the Windows Settings charm, as accessed from within the app.
 *  SDL provides code to add a URL-based link there, which can point to the app's
 *  privacy policy.
 *
 *  To setup a URL to an app's privacy policy, set SDL_HINT_WINRT_PRIVACY_POLICY_URL
 *  before calling any SDL_Init functions.  The contents of the hint should
 *  be a valid URL.  For example, "http://www.example.com".
 *
 *  The default value is "", which will prevent SDL from adding a privacy policy
 *  link to the Settings charm.  This hint should only be set during app init.
 *
 *  The label text of an app's "Privacy Policy" link may be customized via another
 *  hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL.
 *
 *  Please note that on Windows Phone, Microsoft does not provide standard UI
 *  for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL
 *  will not get used on that platform.  Network-enabled phone apps should display
 *  their privacy policy through some other, in-app means.
 */
#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_HINT_WINRT_PRIVACY_POLICY_URL"
/** \brief Label text for a WinRT app's privacy policy link
 *
 *  Network-enabled WinRT apps must include a privacy policy.  On Windows 8, 8.1, and RT,
 *  Microsoft mandates that this policy be available via the Windows Settings charm.
 *  SDL provides code to add a link there, with it's label text being set via the
 *  optional hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL.
 *
 *  Please note that a privacy policy's contents are not set via this hint.  A separate
 *  hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the
 *  policy.
 *
 *  The contents of this hint should be encoded as a UTF8 string.
 *
 *  The default value is "Privacy Policy".  This hint should only be set during app
 *  initialization, preferably before any calls to SDL_Init.
 *
 *  For additional information on linking to a privacy policy, see the documentation for
 *  SDL_HINT_WINRT_PRIVACY_POLICY_URL.
 */
#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_HINT_WINRT_PRIVACY_POLICY_LABEL"
/** \brief If set to 1, back button press events on Windows Phone 8+ will be marked as handled.
 *
 *  TODO, WinRT: document SDL_HINT_WINRT_HANDLE_BACK_BUTTON need and use
 *  For now, more details on why this is needed can be found at the
 *  beginning of the following web page:
 *  http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx
 */
#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_HINT_WINRT_HANDLE_BACK_BUTTON"
/**
 *  \brief  A variable that dictates policy for fullscreen Spaces on Mac OS X.
 *
source/include/SDL_main.h
@@ -39,6 +39,18 @@
 */
#define SDL_MAIN_AVAILABLE
#elif defined(__WINRT__)
/* On WinRT, SDL provides a main function that initializes CoreApplication,
   creating an instance of IFrameworkView in the process.
   Please note that #include'ing SDL_main.h is not enough to get a main()
   function working.  In non-XAML apps, the file,
   src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled
   into the app itself.  In XAML apps, the function, SDL_WinRTRunApp must be
   called, with a pointer to the Direct3D-hosted XAML control passed in.
*/
#define SDL_MAIN_NEEDED
#elif defined(__IPHONEOS__)
/* On iOS SDL provides a main function that creates an application delegate
   and starts the iOS application run loop.
@@ -115,6 +127,24 @@
#endif /* __WIN32__ */
#ifdef __WINRT__
/**
 *  \brief Initializes and launches an SDL/WinRT application.
 *
 *  \param mainFunction The SDL app's C-style main().
 *  \param xamlBackgroundPanel An optional, XAML-based, background panel.
 *     For Non-XAML apps, this value must be set to NULL.  For XAML apps,
 *     pass in a pointer to a SwapChainBackgroundPanel, casted to an
 *     IInspectable (via reinterpret_cast).
 *  \ret 0 on success, -1 on failure.  On failure, use SDL_GetError to retrieve more
 *      information on the failure.
 */
extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel);
#endif /* __WINRT__ */
#ifdef __cplusplus
}
#endif
source/include/SDL_name.h
@@ -1,3 +1,23 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _SDLname_h_
#define _SDLname_h_
@@ -9,3 +29,5 @@
#define SDL_NAME(X) SDL_##X
#endif /* _SDLname_h_ */
/* vi: set ts=4 sw=4 expandtab: */
source/include/SDL_platform.h
@@ -113,10 +113,26 @@
#undef __SOLARIS__
#define __SOLARIS__ 1
#endif
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
/* Try to find out if we're compiling for WinRT or non-WinRT */
/* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */
#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_)    /* _MSC_VER==1700 for MSVC 2012 */
#include <winapifamily.h>
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#undef __WINDOWS__
#define __WINDOWS__   1
/* See if we're compiling for WinRT: */
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#undef __WINRT__
#define __WINRT__ 1
#endif
#else
#undef __WINDOWS__
#define __WINDOWS__   1
#endif /* _MSC_VER < 1700 */
#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
#if defined(__WINDOWS__)
#undef __WIN32__
#define __WIN32__ 1
source/include/SDL_stdinc.h
@@ -71,8 +71,18 @@
# include <ctype.h>
#endif
#ifdef HAVE_MATH_H
# if defined(__WINRT__)
/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
   WinRT.  See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
   for more information.
*/
#  define _USE_MATH_DEFINES
# endif
# include <math.h>
#endif
#ifdef HAVE_FLOAT_H
# include <float.h>
#endif
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
# include <iconv.h>
#endif
source/include/SDL_system.h
@@ -116,6 +116,70 @@
#endif /* __ANDROID__ */
/* Platform specific functions for WinRT */
#if defined(__WINRT__) && __WINRT__
/**
 *  \brief WinRT / Windows Phone path types
 */
typedef enum
{
    /** \brief The installed app's root directory.
        Files here are likely to be read-only. */
    SDL_WINRT_PATH_INSTALLED_LOCATION,
    /** \brief The app's local data store.  Files may be written here */
    SDL_WINRT_PATH_LOCAL_FOLDER,
    /** \brief The app's roaming data store.  Unsupported on Windows Phone.
        Files written here may be copied to other machines via a network
        connection.
    */
    SDL_WINRT_PATH_ROAMING_FOLDER,
    /** \brief The app's temporary data store.  Unsupported on Windows Phone.
        Files written here may be deleted at any time. */
    SDL_WINRT_PATH_TEMP_FOLDER
} SDL_WinRT_Path;
/**
 *  \brief Retrieves a WinRT defined path on the local file system
 *
 *  \note Documentation on most app-specific path types on WinRT
 *      can be found on MSDN, at the URL:
 *      http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
 *
 *  \param pathType The type of path to retrieve.
 *  \ret A UCS-2 string (16-bit, wide-char) containing the path, or NULL
 *      if the path is not available for any reason.  Not all paths are
 *      available on all versions of Windows.  This is especially true on
 *      Windows Phone.  Check the documentation for the given
 *      SDL_WinRT_Path for more information on which path types are
 *      supported where.
 */
extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
/**
 *  \brief Retrieves a WinRT defined path on the local file system
 *
 *  \note Documentation on most app-specific path types on WinRT
 *      can be found on MSDN, at the URL:
 *      http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
 *
 *  \param pathType The type of path to retrieve.
 *  \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
 *      if the path is not available for any reason.  Not all paths are
 *      available on all versions of Windows.  This is especially true on
 *      Windows Phone.  Check the documentation for the given
 *      SDL_WinRT_Path for more information on which path types are
 *      supported where.
 */
extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
#endif /* __WINRT__ */
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
source/include/SDL_syswm.h
@@ -56,6 +56,10 @@
#include <windows.h>
#endif
#if defined(SDL_VIDEO_DRIVER_WINRT)
#include <Inspectable.h>
#endif
/* This is the structure for custom window manager events */
#if defined(SDL_VIDEO_DRIVER_X11)
#if defined(__APPLE__) && defined(__MACH__)
@@ -90,6 +94,7 @@
#include <UIKit/UIKit.h>
#else
typedef struct _UIWindow UIWindow;
typedef struct _UIViewController UIViewController;
#endif
#endif
@@ -111,6 +116,7 @@
    SDL_SYSWM_UIKIT,
    SDL_SYSWM_WAYLAND,
    SDL_SYSWM_MIR,
    SDL_SYSWM_WINRT,
} SDL_SYSWM_TYPE;
/**
@@ -175,6 +181,12 @@
            HWND window;                /**< The window handle */
        } win;
#endif
#if defined(SDL_VIDEO_DRIVER_WINRT)
        struct
        {
            IInspectable * window;      /**< The WinRT CoreWindow */
        } winrt;
#endif
#if defined(SDL_VIDEO_DRIVER_X11)
        struct
        {
source/include/SDL_version.h
@@ -59,7 +59,7 @@
*/
#define SDL_MAJOR_VERSION   2
#define SDL_MINOR_VERSION   0
#define SDL_PATCHLEVEL      2
#define SDL_PATCHLEVEL      3
/**
 *  \brief Macro to determine SDL version program was compiled against.
source/include/begin_code.h
@@ -43,7 +43,7 @@
/* Some compilers use a special export keyword */
#ifndef DECLSPEC
# if defined(__WIN32__)
# if defined(__WIN32__) || defined(__WINRT__)
#  ifdef __BORLANDC__
#   ifdef BUILD_SDL
#    define DECLSPEC
@@ -66,7 +66,7 @@
/* By default SDL uses the C calling convention */
#ifndef SDLCALL
#if defined(__WIN32__) && !defined(__GNUC__)
#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
#define SDLCALL __cdecl
#else
#define SDLCALL
source/src/SDL_assert.c
@@ -39,8 +39,10 @@
#else  /* fprintf, _exit(), etc. */
#include <stdio.h>
#include <stdlib.h>
#if ! defined(__WINRT__)
#include <unistd.h>
#endif
#endif
static SDL_assert_state
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
source/src/SDL_log.c
@@ -20,7 +20,7 @@
*/
#include "./SDL_internal.h"
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINRT__)
#include "core/windows/SDL_windows.h"
#endif
@@ -318,13 +318,15 @@
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
              const char *message)
{
#if defined(__WIN32__)
#if defined(__WIN32__) || defined(__WINRT__)
    /* Way too many allocations here, urgh */
    /* Note: One can't call SDL_SetError here, since that function itself logs. */
    {
        char *output;
        size_t length;
        LPTSTR tstr;
#ifndef __WINRT__
        BOOL attachResult;
        DWORD attachError;
        unsigned long charsWritten; 
@@ -356,6 +358,7 @@
                        stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
                }
        }
#endif /* ifndef __WINRT__ */
        length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
        output = SDL_stack_alloc(char, length);
@@ -365,6 +368,7 @@
        /* Output to debugger */
        OutputDebugString(tstr);
       
#ifndef __WINRT__
        /* Screen output to stderr, if console was attached. */
        if (consoleAttached == 1) {
                if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
@@ -374,6 +378,7 @@
                    OutputDebugString(TEXT("Insufficient heap memory to write message\r\n"));
                }
        }
#endif /* ifndef __WINRT__ */
        SDL_free(tstr);
        SDL_stack_free(output);
source/src/atomic/SDL_spinlock.c
@@ -20,7 +20,7 @@
*/
#include "../SDL_internal.h"
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINRT__)
#include "../core/windows/SDL_windows.h"
#endif
source/src/audio/directsound/directx.h
@@ -1,3 +1,23 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _directx_h
#define _directx_h
@@ -78,4 +98,5 @@
#include <dinput.h>
#endif /* _directx_h */
/* vi: set ts=4 sw=4 expandtab: */
source/src/audio/winmm/SDL_winmm.c
@@ -98,12 +98,12 @@
static int
SetMMerror(char *function, MMRESULT code)
{
    size_t len;
    int len;
    char errbuf[MAXERRORLENGTH];
    wchar_t werrbuf[MAXERRORLENGTH];
    SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
    len = SDL_strlen(errbuf);
    len = SDL_static_cast(int, SDL_strlen(errbuf));
    waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len);
    WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len,
@@ -196,7 +196,7 @@
}
static SDL_bool
PrepWaveFormat(_THIS, UINT_PTR devId, WAVEFORMATEX *pfmt, const int iscapture)
PrepWaveFormat(_THIS, UINT devId, WAVEFORMATEX *pfmt, const int iscapture)
{
    SDL_zerop(pfmt);
@@ -226,13 +226,13 @@
    int valid_datatype = 0;
    MMRESULT result;
    WAVEFORMATEX waveformat;
    UINT_PTR devId = WAVE_MAPPER;  /* WAVE_MAPPER == choose system's default */
    UINT devId = WAVE_MAPPER;  /* WAVE_MAPPER == choose system's default */
    char *utf8 = NULL;
    int i;
    UINT i;
    if (devname != NULL) {  /* specific device requested? */
        if (iscapture) {
            const int devcount = (int) waveInGetNumDevs();
            const UINT devcount = waveInGetNumDevs();
            WAVEINCAPS caps;
            for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
                result = waveInGetDevCaps(i, &caps, sizeof (caps));
@@ -241,11 +241,11 @@
                else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
                    continue;
                else if (SDL_strcmp(devname, utf8) == 0)
                    devId = (UINT_PTR) i;
                    devId = i;
                SDL_free(utf8);
            }
        } else {
            const int devcount = (int) waveOutGetNumDevs();
            const UINT devcount = waveOutGetNumDevs();
            WAVEOUTCAPS caps;
            for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
                result = waveOutGetDevCaps(i, &caps, sizeof (caps));
@@ -254,7 +254,7 @@
                else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
                    continue;
                else if (SDL_strcmp(devname, utf8) == 0)
                    devId = (UINT_PTR) i;
                    devId = i;
                SDL_free(utf8);
            }
        }
source/src/audio/xaudio2/SDL_xaudio2.c
@@ -18,6 +18,32 @@
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
/* WinRT NOTICE:
   A few changes to SDL's XAudio2 backend were warranted by API
   changes to Windows.  Many, but not all of these are documented by Microsoft
   at:
   http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx
   1. Windows' thread synchronization function, CreateSemaphore, was removed
      from WinRT.  SDL's semaphore API was substituted instead.
   2. The method calls, IXAudio2::GetDeviceCount and IXAudio2::GetDeviceDetails
      were removed from the XAudio2 API.  Microsoft is telling developers to
      use APIs in Windows::Foundation instead.
      For SDL, the missing methods were reimplemented using the APIs Microsoft
      said to use.
   3. CoInitialize and CoUninitialize are not available in WinRT.
      These calls were removed, as COM will have been initialized earlier,
      at least by the call to the WinRT app's main function
      (aka 'int main(Platform::Array<Platform::String^>^)).  (DLudwig:
      This was my understanding of how WinRT: the 'main' function uses
      a tag of [MTAThread], which should initialize COM.  My understanding
      of COM is somewhat limited, and I may be incorrect here.)
   4. IXAudio2::CreateMasteringVoice changed its integer-based 'DeviceIndex'
      argument to a string-based one, 'szDeviceId'.  In WinRT, the
      string-based argument will be used.
*/
#include "../../SDL_internal.h"
#if SDL_AUDIO_DRIVER_XAUDIO2
@@ -31,6 +57,9 @@
#ifdef __GNUC__
/* The configure script already did any necessary checking */
#  define SDL_XAUDIO2_HAS_SDK 1
#elif defined(__WINRT__)
/* WinRT always has access to the .the XAudio 2 SDK */
#  define SDL_XAUDIO2_HAS_SDK
#else
/* XAudio2 exists as of the March 2008 DirectX SDK 
   The XAudio2 implementation available in the Windows 8 SDK targets Windows 8 and newer.
@@ -42,15 +71,35 @@
#else
#  define SDL_XAUDIO2_HAS_SDK 1
#endif
#endif /* __GNUC__ */
#endif
#ifdef SDL_XAUDIO2_HAS_SDK
/* Check to see if we're compiling for XAudio 2.8, or higher. */
#ifdef WINVER
#if WINVER >= 0x0602  /* Windows 8 SDK or higher? */
#define SDL_XAUDIO2_WIN8 1
#endif
#endif
/* The XAudio header file, when #include'd on WinRT, will only compile in C++
   files, but not C.  A few preprocessor-based hacks are defined below in order
   to get xaudio2.h to compile in the C/non-C++ file, SDL_xaudio2.c.
 */
#ifdef __WINRT__
#define uuid(x)
#define DX_BUILD
#endif
#define INITGUID 1
#include <xaudio2.h>
/* Hidden "this" pointer for the audio functions */
#define _THIS   SDL_AudioDevice *this
#ifdef __WINRT__
#include "SDL_xaudio2_winrthelpers.h"
#endif
/* Fixes bug 1210 where some versions of gcc need named parameters */
#ifdef __GNUC__
@@ -69,7 +118,7 @@
    IXAudio2 *ixa2;
    IXAudio2SourceVoice *source;
    IXAudio2MasteringVoice *mastering;
    HANDLE semaphore;
    SDL_sem * semaphore;
    Uint8 *mixbuf;
    int mixlen;
    Uint8 *nextbuf;
@@ -114,7 +163,7 @@
{
    /* Just signal the SDL audio thread and get out of XAudio2's way. */
    SDL_AudioDevice *this = (SDL_AudioDevice *) data;
    ReleaseSemaphore(this->hidden->semaphore, 1, NULL);
    SDL_SemPost(this->hidden->semaphore);
}
static void STDMETHODCALLTYPE
@@ -180,7 +229,7 @@
XAUDIO2_WaitDevice(_THIS)
{
    if (this->enabled) {
        WaitForSingleObject(this->hidden->semaphore, INFINITE);
        SDL_SemWait(this->hidden->semaphore);
    }
}
@@ -191,10 +240,18 @@
    XAUDIO2_VOICE_STATE state;
    SDL_assert(!this->enabled);  /* flag that stops playing. */
    IXAudio2SourceVoice_Discontinuity(source);
#if SDL_XAUDIO2_WIN8
    IXAudio2SourceVoice_GetState(source, &state, 0);
#else
    IXAudio2SourceVoice_GetState(source, &state);
#endif
    while (state.BuffersQueued > 0) {
        WaitForSingleObject(this->hidden->semaphore, INFINITE);
        SDL_SemWait(this->hidden->semaphore);
#if SDL_XAUDIO2_WIN8
        IXAudio2SourceVoice_GetState(source, &state, 0);
#else
        IXAudio2SourceVoice_GetState(source, &state);
#endif
    }
}
@@ -223,7 +280,7 @@
        }
        SDL_free(this->hidden->mixbuf);
        if (this->hidden->semaphore != NULL) {
            CloseHandle(this->hidden->semaphore);
            SDL_DestroySemaphore(this->hidden->semaphore);
        }
        SDL_free(this->hidden);
@@ -240,7 +297,11 @@
    SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
    IXAudio2 *ixa2 = NULL;
    IXAudio2SourceVoice *source = NULL;
#if defined(SDL_XAUDIO2_WIN8)
    LPCWSTR devId = NULL;
#else
    UINT32 devId = 0;  /* 0 == system default device. */
#endif
    static IXAudio2VoiceCallbackVtbl callbacks_vtable = {
        VoiceCBOnVoiceProcessPassStart,
@@ -260,6 +321,18 @@
        return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
    }
    /*
    XAUDIO2_DEBUG_CONFIGURATION debugConfig;
    debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_FUNC_CALLS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING;
    debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS;
    debugConfig.LogThreadID = TRUE;
    debugConfig.LogFileline = TRUE;
    debugConfig.LogFunctionName = TRUE;
    debugConfig.LogTiming = TRUE;
    ixa2->SetDebugConfiguration(&debugConfig);
    */
#if ! defined(__WINRT__)
    if (devname != NULL) {
        UINT32 devcount = 0;
        UINT32 i = 0;
@@ -288,6 +361,7 @@
            return SDL_SetError("XAudio2: Requested device not found.");
        }
    }
#endif
    /* Initialize all variables that we clean on shutdown */
    this->hidden = (struct SDL_PrivateAudioData *)
@@ -299,7 +373,7 @@
    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    this->hidden->ixa2 = ixa2;
    this->hidden->semaphore = CreateSemaphore(NULL, 1, 2, NULL);
    this->hidden->semaphore = SDL_CreateSemaphore(1);
    if (this->hidden->semaphore == NULL) {
        XAUDIO2_CloseDevice(this);
        return SDL_SetError("XAudio2: CreateSemaphore() failed!");
@@ -342,9 +416,15 @@
       stereo output to appropriate surround sound configurations
       instead of clamping to 2 channels, even though we'll configure the
       Source Voice for whatever number of channels you supply. */
#if SDL_XAUDIO2_WIN8
    result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
                                           XAUDIO2_DEFAULT_CHANNELS,
                                           this->spec.freq, 0, devId, NULL, AudioCategory_GameEffects);
#else
    result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
                                           XAUDIO2_DEFAULT_CHANNELS,
                                           this->spec.freq, 0, devId, NULL);
#endif
    if (result != S_OK) {
        XAUDIO2_CloseDevice(this);
        return SDL_SetError("XAudio2: Couldn't create mastering voice");
@@ -363,11 +443,23 @@
        waveformat.nChannels * (waveformat.wBitsPerSample / 8);
    waveformat.nAvgBytesPerSec =
        waveformat.nSamplesPerSec * waveformat.nBlockAlign;
    waveformat.cbSize = sizeof(waveformat);
#ifdef __WINRT__
    // DLudwig: for now, make XAudio2 do sample rate conversion, just to
    // get the loopwave test to work.
    //
    // TODO, WinRT: consider removing WinRT-specific source-voice creation code from SDL_xaudio2.c
    result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
                                        0,
                                        1.0f, &callbacks, NULL, NULL);
#else
    result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
                                        XAUDIO2_VOICE_NOSRC |
                                        XAUDIO2_VOICE_NOPITCH,
                                        1.0f, &callbacks, NULL, NULL);
#endif
    if (result != S_OK) {
        XAUDIO2_CloseDevice(this);
        return SDL_SetError("XAudio2: Couldn't create source voice");
@@ -393,7 +485,9 @@
static void
XAUDIO2_Deinitialize(void)
{
#if defined(__WIN32__)
    WIN_CoUninitialize();
#endif
}
#endif  /* SDL_XAUDIO2_HAS_SDK */
@@ -408,13 +502,18 @@
#else
    /* XAudio2Create() is a macro that uses COM; we don't load the .dll */
    IXAudio2 *ixa2 = NULL;
#if defined(__WIN32__)
    // TODO, WinRT: Investigate using CoInitializeEx here
    if (FAILED(WIN_CoInitialize())) {
        SDL_SetError("XAudio2: CoInitialize() failed");
        return 0;
    }
#endif
    if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
#if defined(__WIN32__)
        WIN_CoUninitialize();
#endif
        SDL_SetError("XAudio2: XAudio2Create() failed at initialization");
        return 0;  /* not available. */
    }
source/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
New file
@@ -0,0 +1,90 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include <xaudio2.h>
#include "SDL_xaudio2_winrthelpers.h"
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
using Windows::Devices::Enumeration::DeviceClass;
using Windows::Devices::Enumeration::DeviceInformation;
using Windows::Devices::Enumeration::DeviceInformationCollection;
#endif
extern "C" HRESULT __cdecl IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
{
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    // There doesn't seem to be any audio device enumeration on Windows Phone.
    // In lieu of this, just treat things as if there is one and only one
    // audio device.
    *devcount = 1;
    return S_OK;
#else
    // TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
    auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
    while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
    {
    }
    DeviceInformationCollection^ devices = operation->GetResults();
    *devcount = devices->Size;
    return S_OK;
#endif
}
extern "C" HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
{
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    // Windows Phone doesn't seem to have the same device enumeration APIs that
    // Windows 8/RT has, or it doesn't have them at all.  In lieu of this,
    // just treat things as if there is one, and only one, default device.
    if (index != 0)
    {
        return XAUDIO2_E_INVALID_CALL;
    }
    if (details)
    {
        wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE);
        wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE);
    }
    return S_OK;
#else
    auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
    while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
    {
    }
    DeviceInformationCollection^ devices = operation->GetResults();
    if (index >= devices->Size)
    {
        return XAUDIO2_E_INVALID_CALL;
    }
    DeviceInformation^ d = devices->GetAt(index);
    if (details)
    {
        wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
        wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
    }
    return S_OK;
#endif
}
source/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
New file
@@ -0,0 +1,70 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
//
// Re-implementation of methods removed from XAudio2 (in WinRT):
//
typedef struct XAUDIO2_DEVICE_DETAILS
{
    WCHAR DeviceID[256];
    WCHAR DisplayName[256];
    /* Other fields exist in the pre-Windows 8 version of this struct, however
       they weren't used by SDL, so they weren't added.
    */
} XAUDIO2_DEVICE_DETAILS;
#ifdef __cplusplus
extern "C" {
#endif
HRESULT IXAudio2_GetDeviceCount(IXAudio2 * unused, UINT32 * devcount);
HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details);
#ifdef __cplusplus
}
#endif
//
// C-style macros to call XAudio2's methods in C++:
//
#ifdef __cplusplus
/*
#define IXAudio2_CreateMasteringVoice(A, B, C, D, E, F, G) (A)->CreateMasteringVoice((B), (C), (D), (E), (F), (G))
#define IXAudio2_CreateSourceVoice(A, B, C, D, E, F, G, H) (A)->CreateSourceVoice((B), (C), (D), (E), (F), (G), (H))
#define IXAudio2_QueryInterface(A, B, C) (A)->QueryInterface((B), (C))
#define IXAudio2_Release(A) (A)->Release()
#define IXAudio2_StartEngine(A) (A)->StartEngine()
#define IXAudio2_StopEngine(A) (A)->StopEngine()
#define IXAudio2MasteringVoice_DestroyVoice(A) (A)->DestroyVoice()
#define IXAudio2SourceVoice_DestroyVoice(A) (A)->DestroyVoice()
#define IXAudio2SourceVoice_Discontinuity(A) (A)->Discontinuity()
#define IXAudio2SourceVoice_FlushSourceBuffers(A) (A)->FlushSourceBuffers()
#define IXAudio2SourceVoice_GetState(A, B) (A)->GetState((B))
#define IXAudio2SourceVoice_Start(A, B, C) (A)->Start((B), (C))
#define IXAudio2SourceVoice_Stop(A, B, C) (A)->Stop((B), (C))
#define IXAudio2SourceVoice_SubmitSourceBuffer(A, B, C) (A)->SubmitSourceBuffer((B), (C))
*/
#endif // ifdef __cplusplus
source/src/core/windows/SDL_windows.c
@@ -20,26 +20,33 @@
*/
#include "../../SDL_internal.h"
#ifdef __WIN32__
#if defined(__WIN32__) || defined(__WINRT__)
#include "SDL_windows.h"
#include "SDL_error.h"
#include "SDL_assert.h"
#include <objbase.h>  /* for CoInitialize/CoUninitialize */
#include <objbase.h>  /* for CoInitialize/CoUninitialize (Win32 only) */
/* Sets an error message based on GetLastError() */
int
WIN_SetError(const char *prefix)
WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
{
    TCHAR buffer[1024];
    char *message;
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
                  buffer, SDL_arraysize(buffer), NULL);
    message = WIN_StringToUTF8(buffer);
    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
    SDL_free(message);
    return -1;
}
/* Sets an error message based on GetLastError() */
int
WIN_SetError(const char *prefix)
{
    return WIN_SetErrorFromHRESULT(prefix, GetLastError());
}
HRESULT
@@ -50,6 +57,14 @@
       If you need multi-threaded mode, call CoInitializeEx() before SDL_Init()
    */
#ifdef __WINRT__
    /* DLudwig: On WinRT, it is assumed that COM was initialized in main().
       CoInitializeEx is available (not CoInitialize though), however
       on WinRT, main() is typically declared with the [MTAThread]
       attribute, which, AFAIK, should initialize COM.
    */
    return S_OK;
#else
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    if (hr == RPC_E_CHANGED_MODE) {
        hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
@@ -62,12 +77,15 @@
    }
    return hr;
#endif
}
void
WIN_CoUninitialize(void)
{
#ifndef __WINRT__
    CoUninitialize();
#endif
}
#endif /* __WIN32__ */
source/src/core/windows/SDL_windows.h
@@ -24,6 +24,7 @@
#ifndef _INCLUDED_WINDOWS_H
#define _INCLUDED_WINDOWS_H
#if defined(__WIN32__)
#define WIN32_LEAN_AND_MEAN
#define STRICT
#ifndef UNICODE
@@ -31,6 +32,7 @@
#endif
#undef _WIN32_WINNT
#define _WIN32_WINNT  0x501   /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
#endif
#include <windows.h>
@@ -44,6 +46,9 @@
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
#endif
/* Sets an error message based on a given HRESULT */
extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
/* Sets an error message based on GetLastError(). Always return -1. */
extern int WIN_SetError(const char *prefix);
source/src/core/winrt/SDL_winrtapp_common.cpp
New file
@@ -0,0 +1,37 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "SDL_system.h"
#include "SDL_winrtapp_direct3d.h"
#include "SDL_winrtapp_xaml.h"
int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
extern "C" DECLSPEC int
SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel)
{
    if (xamlBackgroundPanel) {
        return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
    } else {
        return SDL_WinRTInitNonXAMLApp(mainFunction);
    }
}
source/src/core/winrt/SDL_winrtapp_common.h
New file
@@ -0,0 +1,31 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#ifndef _SDL_winrtapp_common_h
#define _SDL_winrtapp_common_h
/* A pointer to the app's C-style main() function (which is a different
   function than the WinRT app's actual entry point).
 */
extern int (*WINRT_SDLAppEntryPoint)(int, char **);
#endif // ifndef _SDL_winrtapp_common_h
source/src/core/winrt/SDL_winrtapp_direct3d.cpp
New file
@@ -0,0 +1,699 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
/* Standard C++11 includes */
#include <functional>
#include <string>
#include <sstream>
using namespace std;
/* Windows includes */
#include "ppltasks.h"
using namespace concurrency;
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Devices::Input;
using namespace Windows::Graphics::Display;
using namespace Windows::Foundation;
using namespace Windows::System;
using namespace Windows::UI::Core;
using namespace Windows::UI::Input;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
using namespace Windows::Phone::UI::Input;
#endif
/* SDL includes */
extern "C" {
#include "../../SDL_internal.h"
#include "SDL_assert.h"
#include "SDL_events.h"
#include "SDL_hints.h"
#include "SDL_log.h"
#include "SDL_main.h"
#include "SDL_stdinc.h"
#include "SDL_render.h"
#include "../../video/SDL_sysvideo.h"
//#include "../../SDL_hints_c.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_windowevents_c.h"
#include "../../render/SDL_sysrender.h"
#include "../windows/SDL_windows.h"
}
#include "../../video/winrt/SDL_winrtevents_c.h"
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
#include "SDL_winrtapp_common.h"
#include "SDL_winrtapp_direct3d.h"
// Compile-time debugging options:
// To enable, uncomment; to disable, comment them out.
//#define LOG_POINTER_EVENTS 1
//#define LOG_WINDOW_EVENTS 1
//#define LOG_ORIENTATION_EVENTS 1
// HACK, DLudwig: record a reference to the global, WinRT 'app'/view.
// SDL/WinRT will use this throughout its code.
//
// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
// non-global, such as something created inside
// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
// SDL_CreateWindow().
SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
{
public:
    virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
};
IFrameworkView^ SDLApplicationSource::CreateView()
{
    // TODO, WinRT: see if this function (CreateView) can ever get called
    // more than once.  For now, just prevent it from ever assigning
    // SDL_WinRTGlobalApp more than once.
    SDL_assert(!SDL_WinRTGlobalApp);
    SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
    if (!SDL_WinRTGlobalApp)
    {
        SDL_WinRTGlobalApp = app;
    }
    return app;
}
int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
{
    WINRT_SDLAppEntryPoint = mainFunction;
    auto direct3DApplicationSource = ref new SDLApplicationSource();
    CoreApplication::Run(direct3DApplicationSource);
    return 0;
}
static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
{
    SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
    // Start with no orientation flags, then add each in as they're parsed
    // from newValue.
    unsigned int orientationFlags = 0;
    if (newValue) {
        std::istringstream tokenizer(newValue);
        while (!tokenizer.eof()) {
            std::string orientationName;
            std::getline(tokenizer, orientationName, ' ');
            if (orientationName == "LandscapeLeft") {
                orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
            } else if (orientationName == "LandscapeRight") {
                orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
            } else if (orientationName == "Portrait") {
                orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
            } else if (orientationName == "PortraitUpsideDown") {
                orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
            }
        }
    }
    // If no valid orientation flags were specified, use a reasonable set of defaults:
    if (!orientationFlags) {
        // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
        orientationFlags = (unsigned int) ( \
            DisplayOrientations::Landscape |
            DisplayOrientations::LandscapeFlipped |
            DisplayOrientations::Portrait |
            DisplayOrientations::PortraitFlipped);
    }
    // Set the orientation/rotation preferences.  Please note that this does
    // not constitute a 100%-certain lock of a given set of possible
    // orientations.  According to Microsoft's documentation on WinRT [1]
    // when a device is not capable of being rotated, Windows may ignore
    // the orientation preferences, and stick to what the device is capable of
    // displaying.
    //
    // [1] Documentation on the 'InitialRotationPreference' setting for a
    // Windows app's manifest file describes how some orientation/rotation
    // preferences may be ignored.  See
    // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
    // for details.  Microsoft's "Display orientation sample" also gives an
    // outline of how Windows treats device rotation
    // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
#if NTDDI_VERSION > NTDDI_WIN8
    DisplayInformation::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
#else
    DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
#endif
}
static void
WINRT_ProcessWindowSizeChange()
{
    // Make the new window size be the one true fullscreen mode.
    // This change was initially done, in part, to allow the Direct3D 11.1
    // renderer to receive window-resize events as a device rotates.
    // Before, rotating a device from landscape, to portrait, and then
    // back to landscape would cause the Direct3D 11.1 swap buffer to
    // not get resized appropriately.  SDL would, on the rotation from
    // landscape to portrait, re-resize the SDL window to it's initial
    // size (landscape).  On the subsequent rotation, SDL would drop the
    // window-resize event as it appeared the SDL window didn't change
    // size, and the Direct3D 11.1 renderer wouldn't resize its swap
    // chain.
    SDL_DisplayMode newDisplayMode;
    if (WINRT_CalcDisplayModeUsingNativeWindow(&newDisplayMode) != 0) {
        return;
    }
    // Make note of the old display mode, and it's old driverdata.
    SDL_DisplayMode oldDisplayMode;
    SDL_zero(oldDisplayMode);
    if (WINRT_GlobalSDLVideoDevice) {
        oldDisplayMode = WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode;
    }
    // Setup the new display mode in the appropriate spots.
    if (WINRT_GlobalSDLVideoDevice) {
        // Make a full copy of the display mode for display_modes[0],
        // one with with a separately malloced 'driverdata' field.
        // SDL_VideoQuit(), if called, will attempt to free the driverdata
        // fields in 'desktop_mode' and each entry in the 'display_modes'
        // array.
        if (WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata) {
            // Free the previous mode's memory
            SDL_free(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata);
            WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata = NULL;
        }
        if (WINRT_DuplicateDisplayMode(&(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0]), &newDisplayMode) != 0) {
            // Uh oh, something went wrong.  A malloc call probably failed.
            SDL_free(newDisplayMode.driverdata);
            return;
        }
        // Install 'newDisplayMode' into 'current_mode' and 'desktop_mode'.
        WINRT_GlobalSDLVideoDevice->displays[0].current_mode = newDisplayMode;
        WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = newDisplayMode;
    }
    if (WINRT_GlobalSDLWindow) {
        // Send a window-resize event to the rest of SDL, and to apps:
        SDL_SendWindowEvent(
            WINRT_GlobalSDLWindow,
            SDL_WINDOWEVENT_RESIZED,
            newDisplayMode.w,
            newDisplayMode.h);
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
        // HACK: On Windows Phone, make sure that orientation changes from
        // Landscape to LandscapeFlipped, Portrait to PortraitFlipped,
        // or vice-versa on either of those two, lead to the Direct3D renderer
        // getting updated.
        const DisplayOrientations oldOrientation = ((SDL_DisplayModeData *)oldDisplayMode.driverdata)->currentOrientation;
        const DisplayOrientations newOrientation = ((SDL_DisplayModeData *)newDisplayMode.driverdata)->currentOrientation;
        if ((oldOrientation == DisplayOrientations::Landscape && newOrientation == DisplayOrientations::LandscapeFlipped) ||
            (oldOrientation == DisplayOrientations::LandscapeFlipped && newOrientation == DisplayOrientations::Landscape) ||
            (oldOrientation == DisplayOrientations::Portrait && newOrientation == DisplayOrientations::PortraitFlipped) ||
            (oldOrientation == DisplayOrientations::PortraitFlipped && newOrientation == DisplayOrientations::Portrait))
        {
            // One of the reasons this event is getting sent out is because SDL
            // will ignore requests to send out SDL_WINDOWEVENT_RESIZED events
            // if and when the event size doesn't change (and the Direct3D 11.1
            // renderer doesn't get the memo).
            //
            // Make sure that the display/window size really didn't change.  If
            // it did, then a SDL_WINDOWEVENT_SIZE_CHANGED event got sent, and
            // the Direct3D 11.1 renderer picked it up, presumably.
            if (oldDisplayMode.w == newDisplayMode.w &&
                oldDisplayMode.h == newDisplayMode.h)
            {
                SDL_SendWindowEvent(
                    WINRT_GlobalSDLWindow,
                    SDL_WINDOWEVENT_SIZE_CHANGED,
                    newDisplayMode.w,
                    newDisplayMode.h);
            }
        }
#endif
    }
    // Finally, free the 'driverdata' field of the old 'desktop_mode'.
    if (oldDisplayMode.driverdata) {
        SDL_free(oldDisplayMode.driverdata);
        oldDisplayMode.driverdata = NULL;
    }
}
SDL_WinRTApp::SDL_WinRTApp() :
    m_windowClosed(false),
    m_windowVisible(true)
{
}
void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
{
    applicationView->Activated +=
        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
    CoreApplication::Suspending +=
        ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
    CoreApplication::Resuming +=
        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
    CoreApplication::Exiting +=
        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnExiting);
}
#if NTDDI_VERSION > NTDDI_WIN8
void SDL_WinRTApp::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
#else
void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
#endif
{
#if LOG_ORIENTATION_EVENTS==1
    CoreWindow^ window = CoreWindow::GetForCurrentThread();
    if (window) {
        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
            __FUNCTION__,
            (int)DisplayProperties::CurrentOrientation,
            (int)DisplayProperties::NativeOrientation,
            (int)DisplayProperties::AutoRotationPreferences,
            window->Bounds.Width,
            window->Bounds.Height);
    } else {
        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
            __FUNCTION__,
            (int)DisplayProperties::CurrentOrientation,
            (int)DisplayProperties::NativeOrientation,
            (int)DisplayProperties::AutoRotationPreferences);
    }
#endif
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    // On Windows Phone, treat an orientation change as a change in window size.
    // The native window's size doesn't seem to change, however SDL will simulate
    // a window size change.
    WINRT_ProcessWindowSizeChange();
#endif
}
void SDL_WinRTApp::SetWindow(CoreWindow^ window)
{
#if LOG_WINDOW_EVENTS==1
    SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
        __FUNCTION__,
        (int)DisplayProperties::CurrentOrientation,
        (int)DisplayProperties::NativeOrientation,
        (int)DisplayProperties::AutoRotationPreferences,
        window->Bounds.Width,
        window->Bounds.Height);
#endif
    window->SizeChanged +=
        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
    window->VisibilityChanged +=
        ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
    window->Closed +=
        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
    window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
#endif
    window->PointerPressed +=
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
    window->PointerMoved +=
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
    window->PointerReleased +=
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
    window->PointerWheelChanged +=
        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
    // Retrieves relative-only mouse movements:
    Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
        ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
#endif
    window->KeyDown +=
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
    window->KeyUp +=
        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    HardwareButtons::BackPressed +=
        ref new EventHandler<BackPressedEventArgs^>(this, &SDL_WinRTApp::OnBackButtonPressed);
#endif
#if NTDDI_VERSION > NTDDI_WIN8
    DisplayInformation::GetForCurrentView()->OrientationChanged +=
        ref new TypedEventHandler<Windows::Graphics::Display::DisplayInformation^, Object^>(this, &SDL_WinRTApp::OnOrientationChanged);
#else
    DisplayProperties::OrientationChanged +=
        ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
#endif
    // Register the hint, SDL_HINT_ORIENTATIONS, with SDL.
    // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
    SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
#if WINAPI_FAMILY == WINAPI_FAMILY_APP  // for Windows 8/8.1/RT apps... (and not Phone apps)
    // Make sure we know when a user has opened the app's settings pane.
    // This is needed in order to display a privacy policy, which needs
    // to be done for network-enabled apps, as per Windows Store requirements.
    using namespace Windows::UI::ApplicationSettings;
    SettingsPane::GetForCurrentView()->CommandsRequested +=
        ref new TypedEventHandler<SettingsPane^, SettingsPaneCommandsRequestedEventArgs^>
            (this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested);
#endif
}
void SDL_WinRTApp::Load(Platform::String^ entryPoint)
{
}
void SDL_WinRTApp::Run()
{
    SDL_SetMainReady();
    if (WINRT_SDLAppEntryPoint)
    {
        // TODO, WinRT: pass the C-style main() a reasonably realistic
        // representation of command line arguments.
        int argc = 0;
        char **argv = NULL;
        WINRT_SDLAppEntryPoint(argc, argv);
    }
}
void SDL_WinRTApp::PumpEvents()
{
    if (!m_windowClosed)
    {
        if (m_windowVisible)
        {
            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
        }
        else
        {
            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
        }
    }
}
void SDL_WinRTApp::Uninitialize()
{
}
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
void SDL_WinRTApp::OnSettingsPaneCommandsRequested(
    Windows::UI::ApplicationSettings::SettingsPane ^p,
    Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args)
{
    using namespace Platform;
    using namespace Windows::UI::ApplicationSettings;
    using namespace Windows::UI::Popups;
    String ^privacyPolicyURL = nullptr;     // a URL to an app's Privacy Policy
    String ^privacyPolicyLabel = nullptr;   // label/link text
    const char *tmpHintValue = NULL;        // SDL_GetHint-retrieved value, used immediately
    wchar_t *tmpStr = NULL;                 // used for UTF8 to UCS2 conversion
    // Setup a 'Privacy Policy' link, if one is available (via SDL_GetHint):
    tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_URL);
    if (tmpHintValue && tmpHintValue[0] != '\0') {
        // Convert the privacy policy's URL to UCS2:
        tmpStr = WIN_UTF8ToString(tmpHintValue);
        privacyPolicyURL = ref new String(tmpStr);
        SDL_free(tmpStr);
        // Optionally retrieve custom label-text for the link.  If this isn't
        // available, a default value will be used instead.
        tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_LABEL);
        if (tmpHintValue && tmpHintValue[0] != '\0') {
            tmpStr = WIN_UTF8ToString(tmpHintValue);
            privacyPolicyLabel = ref new String(tmpStr);
            SDL_free(tmpStr);
        } else {
            privacyPolicyLabel = ref new String(L"Privacy Policy");
        }
        // Register the link, along with a handler to be called if and when it is
        // clicked:
        auto cmd = ref new SettingsCommand(L"privacyPolicy", privacyPolicyLabel,
            ref new UICommandInvokedHandler([=](IUICommand ^) {
                Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL));
        }));
        args->Request->ApplicationCommands->Append(cmd);
    }
}
#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP
void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
{
#if LOG_WINDOW_EVENTS==1
    SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n",
        __FUNCTION__,
        args->Size.Width, args->Size.Height,
        (int)DisplayProperties::CurrentOrientation,
        (int)DisplayProperties::NativeOrientation,
        (int)DisplayProperties::AutoRotationPreferences,
        (WINRT_GlobalSDLWindow ? "yes" : "no"));
#endif
    WINRT_ProcessWindowSizeChange();
}
void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
{
#if LOG_WINDOW_EVENTS==1
    SDL_Log("%s, visible?=%s, WINRT_GlobalSDLWindow?=%s\n",
        __FUNCTION__,
        (args->Visible ? "yes" : "no"),
        (WINRT_GlobalSDLWindow ? "yes" : "no"));
#endif
    m_windowVisible = args->Visible;
    if (WINRT_GlobalSDLWindow) {
        SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
        if (args->Visible) {
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
        } else {
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
        }
        // HACK: Prevent SDL's window-hide handling code, which currently
        // triggers a fake window resize (possibly erronously), from
        // marking the SDL window's surface as invalid.
        //
        // A better solution to this probably involves figuring out if the
        // fake window resize can be prevented.
        WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid;
    }
}
void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
{
#if LOG_WINDOW_EVENTS==1
    SDL_Log("%s\n", __FUNCTION__);
#endif
    m_windowClosed = true;
}
void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
{
    CoreWindow::GetForCurrentThread()->Activate();
}
static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
{
    if (event->type == SDL_WINDOWEVENT)
    {
        switch (event->window.event)
        {
            case SDL_WINDOWEVENT_MINIMIZED:
            case SDL_WINDOWEVENT_RESTORED:
                // Return 0 to indicate that the event should be removed from the
                // event queue:
                return 0;
            default:
                break;
        }
    }
    // Return 1 to indicate that the event should stay in the event queue:
    return 1;
}
void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
{
    // Save app state asynchronously after requesting a deferral. Holding a deferral
    // indicates that the application is busy performing suspending operations. Be
    // aware that a deferral may not be held indefinitely. After about five seconds,
    // the app will be forced to exit.
    SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
    create_task([this, deferral]()
    {
        // Send a window-minimized event immediately to observers.
        // CoreDispatcher::ProcessEvents, which is the backbone on which
        // SDL_WinRTApp::PumpEvents is built, will not return to its caller
        // once it sends out a suspend event.  Any events posted to SDL's
        // event queue won't get received until the WinRT app is resumed.
        // SDL_AddEventWatch() may be used to receive app-suspend events on
        // WinRT.
        //
        // In order to prevent app-suspend events from being received twice:
        // first via a callback passed to SDL_AddEventWatch, and second via
        // SDL's event queue, the event will be sent to SDL, then immediately
        // removed from the queue.
        if (WINRT_GlobalSDLWindow)
        {
            SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);   // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
            SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
        }
        SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
        SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
        deferral->Complete();
    });
}
void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
{
    SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
    SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
    // Restore any data or state that was unloaded on suspend. By default, data
    // and state are persisted when resuming from suspend. Note that this event
    // does not occur if the app was previously terminated.
    if (WINRT_GlobalSDLWindow)
    {
        SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0);    // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
        // Remove the app-resume event from the queue, as is done with the
        // app-suspend event.
        //
        // TODO, WinRT: consider posting this event to the queue even though
        // its counterpart, the app-suspend event, effectively has to be
        // processed immediately.
        SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
    }
}
void SDL_WinRTApp::OnExiting(Platform::Object^ sender, Platform::Object^ args)
{
    SDL_SendAppEvent(SDL_APP_TERMINATING);
}
static void
WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
{
    Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
        header,
        pt->Position.X, pt->Position.Y,
        transformedPoint.X, transformedPoint.Y,
        pt->Properties->MouseWheelDelta,
        pt->FrameId,
        pt->PointerId,
        WINRT_GetSDLButtonForPointerPoint(pt));
}
void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
{
#if LOG_POINTER_EVENTS
    WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
#endif
    WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
}
void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
{
#if LOG_POINTER_EVENTS
    WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
#endif
    WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
}
void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
{
#if LOG_POINTER_EVENTS
    WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
#endif
    WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
}
void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
{
#if LOG_POINTER_EVENTS
    WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
#endif
    WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
}
void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
{
    WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
}
void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
{
    WINRT_ProcessKeyDownEvent(args);
}
void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
{
    WINRT_ProcessKeyUpEvent(args);
}
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args)
{
    SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK);
    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK);
    const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON);
    if (hint) {
        if (*hint == '1') {
            args->Handled = true;
        }
    }
}
#endif
source/src/core/winrt/SDL_winrtapp_direct3d.h
New file
@@ -0,0 +1,80 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include <Windows.h>
extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **));
ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
{
public:
    SDL_WinRTApp();
    // IFrameworkView Methods.
    virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
    virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
    virtual void Load(Platform::String^ entryPoint);
    virtual void Run();
    virtual void Uninitialize();
internal:
    // SDL-specific methods
    void PumpEvents();
protected:
    // Event Handlers.
#if WINAPI_FAMILY == WINAPI_FAMILY_APP  // for Windows 8/8.1/RT apps... (and not Phone apps)
    void OnSettingsPaneCommandsRequested(
        Windows::UI::ApplicationSettings::SettingsPane ^p,
        Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args);
#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP
#if NTDDI_VERSION > NTDDI_WIN8
    void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
#else
    void OnOrientationChanged(Platform::Object^ sender);
#endif
    void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
    void OnLogicalDpiChanged(Platform::Object^ sender);
    void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
    void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
    void OnResuming(Platform::Object^ sender, Platform::Object^ args);
    void OnExiting(Platform::Object^ sender, Platform::Object^ args);
    void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
    void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
    void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
    void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
    void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
#endif
private:
    bool m_windowClosed;
    bool m_windowVisible;
};
extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
source/src/core/winrt/SDL_winrtapp_xaml.cpp
New file
@@ -0,0 +1,160 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
/* Windows includes */
#include <agile.h>
#include <Windows.h>
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
#include <windows.ui.xaml.media.dxinterop.h>
#endif
/* SDL includes */
#include "../../SDL_internal.h"
#include "SDL.h"
#include "../../video/winrt/SDL_winrtevents_c.h"
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
#include "SDL_winrtapp_common.h"
#include "SDL_winrtapp_xaml.h"
/* SDL-internal globals: */
SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE;
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
extern "C"
ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL;
static Windows::Foundation::EventRegistrationToken    WINRT_XAMLAppEventToken;
#endif
/*
 * Input event handlers (XAML)
 */
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
static void
WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{
    WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
}
static void
WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{
    WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
}
static void
WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{
    WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
}
static void
WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
{
    WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
}
#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
/*
 * XAML-to-SDL Rendering Callback
 */
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
static void
WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args)
{
    WINRT_CycleXAMLThread();
}
#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
/*
 * SDL + XAML Initialization
 */
int
SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable)
{
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    return SDL_SetError("XAML support is not yet available in Windows Phone.");
#else
    // Declare C++/CX namespaces:
    using namespace Platform;
    using namespace Windows::Foundation;
    using namespace Windows::UI::Core;
    using namespace Windows::UI::Xaml;
    using namespace Windows::UI::Xaml::Controls;
    using namespace Windows::UI::Xaml::Input;
    using namespace Windows::UI::Xaml::Media;
    // Make sure we have a valid XAML element (to draw onto):
    if ( ! backgroundPanelAsIInspectable) {
        return SDL_SetError("'backgroundPanelAsIInspectable' can't be NULL");
    }
    Platform::Object ^ backgroundPanel = reinterpret_cast<Object ^>((IInspectable *) backgroundPanelAsIInspectable);
    SwapChainBackgroundPanel ^swapChainBackgroundPanel = dynamic_cast<SwapChainBackgroundPanel ^>(backgroundPanel);
    if ( ! swapChainBackgroundPanel) {
        return SDL_SetError("An unknown or unsupported type of XAML control was specified.");
    }
    // Setup event handlers:
    swapChainBackgroundPanel->PointerPressed += ref new PointerEventHandler(WINRT_OnPointerPressedViaXAML);
    swapChainBackgroundPanel->PointerReleased += ref new PointerEventHandler(WINRT_OnPointerReleasedViaXAML);
    swapChainBackgroundPanel->PointerWheelChanged += ref new PointerEventHandler(WINRT_OnPointerWheelChangedViaXAML);
    swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML);
    // Setup for rendering:
    IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel);
    panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative);
    WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler<Object^>(WINRT_OnRenderViaXAML));
    // Make sure the app is ready to call the SDL-centric main() function:
    WINRT_SDLAppEntryPoint = mainFunction;
    SDL_SetMainReady();
    // Make sure video-init knows that we're initializing XAML:
    SDL_bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled;
    WINRT_XAMLWasEnabled = SDL_TRUE;
    // Make sure video modes are detected now, while we still have access to the WinRT
    // CoreWindow.  WinRT will not allow the app's CoreWindow to be accessed via the
    // SDL/WinRT thread.
    if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
        // SDL_InitSubSystem will, on error, set the SDL error.  Let that propogate to
        // the caller to here:
        WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue;
        return -1;
    }
    // All done, for now.
    return 0;
#endif // WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP  /  else
}
source/src/core/winrt/SDL_winrtapp_xaml.h
New file
@@ -0,0 +1,33 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#ifndef _SDL_winrtapp_xaml_h
#define _SDL_winrtapp_xaml_h
#include "SDL_types.h"
#ifdef __cplusplus
extern SDL_bool WINRT_XAMLWasEnabled;
extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable);
#endif // ifdef __cplusplus
#endif // ifndef _SDL_winrtapp_xaml_h
source/src/dynapi/SDL_dynapi.h
@@ -45,6 +45,8 @@
#if TARGET_OS_IPHONE  /* probably not useful on iOS. */
#define SDL_DYNAMIC_API 0
#elif SDL_BUILDING_WINRT /* probaly not useful on WinRT, given current .dll loading restrictions */
#define SDL_DYNAMIC_API 0
#else   /* everyone else. */
#define SDL_DYNAMIC_API 1
#endif
source/src/file/SDL_rwops.c
@@ -316,6 +316,10 @@
    if (fseeko(context->hidden.stdio.fp, (off_t)offset, whence) == 0) {
        return ftello(context->hidden.stdio.fp);
    }
#elif defined(HAVE__FSEEKI64)
    if (_fseeki64(context->hidden.stdio.fp, offset, whence) == 0) {
        return _ftelli64(context->hidden.stdio.fp);
    }
#else
    if (fseek(context->hidden.stdio.fp, offset, whence) == 0) {
        return ftell(context->hidden.stdio.fp);
@@ -522,6 +526,9 @@
    {
        #ifdef __APPLE__
        FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
        #elif __WINRT__
        FILE *fp = NULL;
        fopen_s(&fp, file, mode);
        #else
        FILE *fp = fopen(file, mode);
        #endif
source/src/file/cocoa/SDL_rwopsbundlesupport.h
@@ -1,3 +1,24 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#ifdef __APPLE__
#include <stdio.h>
source/src/file/cocoa/SDL_rwopsbundlesupport.m
@@ -1,3 +1,25 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifdef __APPLE__
#import <Foundation/Foundation.h>
@@ -42,4 +64,7 @@
    return fp;
}
#endif
#endif /* __MACOSX__ */
/* vi: set ts=4 sw=4 expandtab: */
source/src/filesystem/windows/SDL_sysfilesystem.c
@@ -70,7 +70,6 @@
     */
    WCHAR path[MAX_PATH];
    char *utf8 = NULL;
    char *retval = NULL;
    WCHAR* worg = NULL;
    WCHAR* wapp = NULL;
source/src/filesystem/winrt/SDL_sysfilesystem.cpp
New file
@@ -0,0 +1,174 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
   TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all
*/
#ifdef __WINRT__
extern "C" {
#include "SDL_filesystem.h"
#include "SDL_error.h"
#include "SDL_stdinc.h"
#include "SDL_system.h"
#include "../../core/windows/SDL_windows.h"
}
#include <string>
#include <unordered_map>
using namespace std;
using namespace Windows::Storage;
extern "C" const wchar_t *
SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
{
    switch (pathType) {
        case SDL_WINRT_PATH_INSTALLED_LOCATION:
        {
            static wstring path;
            if (path.empty()) {
                path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
            }
            return path.c_str();
        }
        case SDL_WINRT_PATH_LOCAL_FOLDER:
        {
            static wstring path;
            if (path.empty()) {
                path = ApplicationData::Current->LocalFolder->Path->Data();
            }
            return path.c_str();
        }
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
        case SDL_WINRT_PATH_ROAMING_FOLDER:
        {
            static wstring path;
            if (path.empty()) {
                path = ApplicationData::Current->RoamingFolder->Path->Data();
            }
            return path.c_str();
        }
        case SDL_WINRT_PATH_TEMP_FOLDER:
        {
            static wstring path;
            if (path.empty()) {
                path = ApplicationData::Current->TemporaryFolder->Path->Data();
            }
            return path.c_str();
        }
#endif
        default:
            break;
    }
    SDL_Unsupported();
    return NULL;
}
extern "C" const char *
SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
{
    typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
    static UTF8PathMap utf8Paths;
    UTF8PathMap::iterator searchResult = utf8Paths.find(pathType);
    if (searchResult != utf8Paths.end()) {
        return searchResult->second.c_str();
    }
    const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
    if (!ucs2Path) {
        return NULL;
    }
    char * utf8Path = WIN_StringToUTF8(ucs2Path);
    utf8Paths[pathType] = utf8Path;
    SDL_free(utf8Path);
    return utf8Paths[pathType].c_str();
}
extern "C" char *
SDL_GetBasePath(void)
{
    const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION);
    size_t destPathLen;
    char * destPath = NULL;
    if (!srcPath) {
        SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
        return NULL;
    }
    destPathLen = SDL_strlen(srcPath) + 2;
    destPath = (char *) SDL_malloc(destPathLen);
    if (!destPath) {
        SDL_OutOfMemory();
        return NULL;
    }
    SDL_snprintf(destPath, destPathLen, "%s\\", srcPath);
    return destPath;
}
extern "C" char *
SDL_GetPrefPath(const char *org, const char *app)
{
    /* WinRT note: The 'SHGetFolderPath' API that is used in Windows 7 and
     * earlier is not available on WinRT or Windows Phone.  WinRT provides
     * a similar API, but SHGetFolderPath can't be called, at least not
     * without violating Microsoft's app-store requirements.
     */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    /* A 'Roaming' folder is not available in Windows Phone 8, however a 'Local' folder is. */
    const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_LOCAL_FOLDER);
#else
    /* A 'Roaming' folder is available on Windows 8 and 8.1.  Use that. */
    const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_ROAMING_FOLDER);
#endif
    size_t destPathLen;
    char * destPath = NULL;
    if (!srcPath) {
        SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
        return NULL;
    }
    destPathLen = SDL_strlen(srcPath) + SDL_strlen(org) + SDL_strlen(app) + 4;
    destPath = (char *) SDL_malloc(destPathLen);
    if (!destPath) {
        SDL_OutOfMemory();
        return NULL;
    }
    SDL_snprintf(destPath, destPathLen, "%s\\%s\\%s\\", srcPath, org, app);
    return destPath;
}
#endif /* __WINRT__ */
source/src/joystick/SDL_gamecontroller.c
@@ -88,7 +88,7 @@
} ControllerMapping_t;
static ControllerMapping_t *s_pSupportedControllers = NULL;
#ifdef SDL_JOYSTICK_DINPUT
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
static ControllerMapping_t *s_pXInputMapping = NULL;
#endif
@@ -279,7 +279,7 @@
 */
ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
{
#ifdef SDL_JOYSTICK_DINPUT
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
    if ( SDL_SYS_IsXInputDeviceIndex(device_index) && s_pXInputMapping )
    {
        return s_pXInputMapping;
@@ -737,7 +737,7 @@
    char *pchMapping;
    SDL_JoystickGUID jGUID;
    ControllerMapping_t *pControllerMapping;
#ifdef SDL_JOYSTICK_DINPUT
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
    SDL_bool is_xinput_mapping = SDL_FALSE;
#endif
@@ -745,7 +745,7 @@
    if (!pchGUID) {
        return SDL_SetError("Couldn't parse GUID from %s", mappingString);
    }
#ifdef SDL_JOYSTICK_DINPUT
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
    if ( !SDL_strcasecmp( pchGUID, "xinput" ) ) {
        is_xinput_mapping = SDL_TRUE;
    }
@@ -782,7 +782,7 @@
            SDL_free( pchMapping );
            return SDL_OutOfMemory();
        }
#ifdef SDL_JOYSTICK_DINPUT
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
        if ( is_xinput_mapping )
        {
            s_pXInputMapping = pControllerMapping;
source/src/joystick/SDL_gamecontrollerdb.h
@@ -42,6 +42,8 @@
    "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,",
    "4c05c405000000000000504944564944,PS4 Controller,a:a3,a:b1,b:b2,back:b8,dpdown:h0.0,dpdown:h0.4,dpleft:h0.8,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,guide:b12,leftshoulder:b4,leftshoulder:h0.0,leftstick:b10,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightshoulder:b6,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:a4,x:b0,y:b3,",
    "xinput,X360 Controller,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,",
#elif defined(SDL_JOYSTICK_XINPUT)
    "xinput,X360 Controller,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,",
#elif defined(__MACOSX__)
    "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
    "6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
source/src/joystick/SDL_sysjoystick.h
@@ -108,7 +108,7 @@
/* Function to return the stable GUID for a opened joystick */
extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick);
#ifdef SDL_JOYSTICK_DINPUT
#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT)
/* Function to get the current instance id of the joystick located at device_index */
extern SDL_bool SDL_SYS_IsXInputDeviceIndex( int device_index );
extern SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick);
source/src/joystick/winrt/SDL_xinputjoystick.c
New file
@@ -0,0 +1,537 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_JOYSTICK_XINPUT
/* SDL_xinputjoystick.c implements an XInput-only joystick and game controller
   backend that is suitable for use on WinRT.  SDL's DirectInput backend, also
   XInput-capable, was not used as DirectInput is not available on WinRT (or,
   at least, it isn't a public API).  Some portions of this XInput backend
   may copy parts of the XInput-using code from the DirectInput backend.
   Refactoring the common parts into one location may be good to-do at some
   point.
   TODO, WinRT: add hotplug support for XInput based game controllers
*/
#include "SDL_joystick.h"
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
#include "SDL_events.h"
#include "../../events/SDL_events_c.h"
#include "SDL_timer.h"
#include <Windows.h>
#include <Xinput.h>
struct joystick_hwdata {
    //Uint8 bXInputHaptic; // Supports force feedback via XInput.
    DWORD userIndex;    // The XInput device index, in the range [0, XUSER_MAX_COUNT-1] (probably [0,3]).
    XINPUT_STATE XInputState;   // the last-read in XInputState, kept around to compare old and new values
    SDL_bool isDeviceConnected; // was the device connected (on the last detection-polling, or during backend-initialization)?
    SDL_bool isDeviceConnectionEventPending;    // was a device added, and is the associated add-event pending?
    SDL_bool isDeviceRemovalEventPending;   // was the device removed, and is the associated remove-event pending?
};
/* Keep track of data on all XInput devices, regardless of whether or not
   they've been opened (via SDL_JoystickOpen).
 */
static struct joystick_hwdata g_XInputData[XUSER_MAX_COUNT];
/* Device detection can be extremely costly performance-wise, in some cases.
   In particular, if no devices are connected, calls to detect a single device,
   via either XInputGetState() or XInputGetCapabilities(), can take upwards of
   20 ms on a 1st generation Surface RT, more if devices are detected across
   all of of XInput's four device slots.  WinRT and XInput do not appear to
   have callback-based APIs to notify an app when a device is connected, at
   least as of Windows 8.1.  The synchronous XInput calls must be used.
   Once a device is connected, calling XInputGetState() is a much less costly
   operation, with individual calls costing well under 1 ms, and often under
   0.1 ms [on a 1st gen Surface RT].
   With XInput's performance limitations in mind, a separate device-detection
   thread will be utilized (by SDL) to try to move costly XInput calls off the
   main thread.  Polling of active devices still, however, occurs on the main
   thread.
 */
static SDL_Thread * g_DeviceDetectionThread = NULL;
static SDL_mutex * g_DeviceInfoLock = NULL;
static SDL_bool g_DeviceDetectionQuit = SDL_FALSE;
/* Main function for the device-detection thread.
 */
static int
DeviceDetectionThreadMain(void * _data)
{
    DWORD result;
    XINPUT_CAPABILITIES tempXInputCaps;
    int i;
    while (1) {
        /* See if the device-detection thread is being asked to shutdown.
         */
        SDL_LockMutex(g_DeviceInfoLock);
        if (g_DeviceDetectionQuit) {
            SDL_UnlockMutex(g_DeviceInfoLock);
            break;
        }
        SDL_UnlockMutex(g_DeviceInfoLock);
        /* Add a short delay to prevent the device-detection thread from eating
           up too much CPU time:
         */
        SDL_Delay(300);
        /* TODO, WinRT: try making the device-detection thread wakeup sooner from its CPU-preserving SDL_Delay, if the thread was asked to quit.
         */
        /* See if any new devices are connected. */
        SDL_LockMutex(g_DeviceInfoLock);
        for (i = 0; i < XUSER_MAX_COUNT; ++i) {
            if (!g_XInputData[i].isDeviceConnected &&
                !g_XInputData[i].isDeviceConnectionEventPending &&
                !g_XInputData[i].isDeviceRemovalEventPending)
            {
                SDL_UnlockMutex(g_DeviceInfoLock);
                result = XInputGetCapabilities(i, 0, &tempXInputCaps);
                SDL_LockMutex(g_DeviceInfoLock);
                if (result == ERROR_SUCCESS) {
                    /* Yes, a device is connected.  Mark it as such.
                       Others will be told about this (via an
                       SDL_JOYDEVICEADDED event) in the next call to
                       SDL_SYS_JoystickDetect.
                     */
                    g_XInputData[i].isDeviceConnected = SDL_TRUE;
                    g_XInputData[i].isDeviceConnectionEventPending = SDL_TRUE;
                }
            }
        }
        SDL_UnlockMutex(g_DeviceInfoLock);
    }
    return 0;
}
/* Function to scan the system for joysticks.
 * It should return 0, or -1 on an unrecoverable fatal error.
 */
int
SDL_SYS_JoystickInit(void)
{
    HRESULT result = S_OK;
    XINPUT_STATE tempXInputState;
    int i;
    SDL_zero(g_XInputData);
    /* Make initial notes on whether or not devices are connected (or not).
     */
    for (i = 0; i < XUSER_MAX_COUNT; ++i) {
        result = XInputGetState(i, &tempXInputState);
        if (result == ERROR_SUCCESS) {
            g_XInputData[i].isDeviceConnected = SDL_TRUE;
        }
    }
    /* Start up the device-detection thread.
     */
    g_DeviceDetectionQuit = SDL_FALSE;
    g_DeviceInfoLock = SDL_CreateMutex();
    g_DeviceDetectionThread = SDL_CreateThread(DeviceDetectionThreadMain, "SDL_joystick", NULL);
    return (0);
}
int SDL_SYS_NumJoysticks()
{
    int joystickCount = 0;
    DWORD i;
    /* Iterate through each possible XInput device and see if something
       was connected (at joystick init, or during the last polling).
     */
    SDL_LockMutex(g_DeviceInfoLock);
    for (i = 0; i < XUSER_MAX_COUNT; ++i) {
        if (g_XInputData[i].isDeviceConnected) {
            ++joystickCount;
        }
    }
    SDL_UnlockMutex(g_DeviceInfoLock);
    return joystickCount;
}
void SDL_SYS_JoystickDetect()
{
    DWORD i;
    SDL_Event event;
    /* Iterate through each possible XInput device, seeing if any devices
       have been connected, or if they were removed.
     */
    SDL_LockMutex(g_DeviceInfoLock);
    for (i = 0; i < XUSER_MAX_COUNT; ++i) {
        /* See if any new devices are connected. */
        if (g_XInputData[i].isDeviceConnectionEventPending) {
#if !SDL_EVENTS_DISABLED
            SDL_zero(event);
            event.type = SDL_JOYDEVICEADDED;
            if (SDL_GetEventState(event.type) == SDL_ENABLE) {
                event.jdevice.which = i;
                if ((SDL_EventOK == NULL)
                    || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
                    SDL_PushEvent(&event);
                }
            }
#endif
            g_XInputData[i].isDeviceConnectionEventPending = SDL_FALSE;
        } else if (g_XInputData[i].isDeviceRemovalEventPending) {
            /* A device was previously marked as removed (by
               SDL_SYS_JoystickUpdate).  Tell others about the device removal.
            */
            g_XInputData[i].isDeviceRemovalEventPending = SDL_FALSE;
#if !SDL_EVENTS_DISABLED
            SDL_zero(event);
            event.type = SDL_JOYDEVICEREMOVED;
            if (SDL_GetEventState(event.type) == SDL_ENABLE) {
                event.jdevice.which = i; //joystick->hwdata->userIndex;
                if ((SDL_EventOK == NULL)
                    || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
                    SDL_PushEvent(&event);
                }
            }
#endif
        }
    }
    SDL_UnlockMutex(g_DeviceInfoLock);
}
SDL_bool SDL_SYS_JoystickNeedsPolling()
{
    /* Since XInput, or WinRT, provides any events to indicate when a game
       controller gets connected, and instead indicates device availability
       solely through polling, we'll poll (for new devices).
     */
    return SDL_TRUE;
}
/* Internal function to retreive device capabilities.
   This function will return an SDL-standard value of 0 on success
   (a device is connected, and data on it was retrieved), or -1
   on failure (no device was connected, or some other error
   occurred.  SDL_SetError() will be invoked to set an appropriate
   error message.
 */
static int
SDL_XInput_GetDeviceCapabilities(int device_index, XINPUT_CAPABILITIES * pDeviceCaps)
{
    HRESULT dwResult;
    /* Make sure that the device index is a valid one.  If not, return to the
       caller with an error.
     */
    if (device_index < 0 || device_index >= XUSER_MAX_COUNT) {
        return SDL_SetError("invalid/unavailable device index");
    }
    /* See if a device exists, and if so, what its capabilities are.  If a
       device is not available, return to the caller with an error.
     */
    switch ((dwResult = XInputGetCapabilities(device_index, 0, pDeviceCaps))) {
        case ERROR_SUCCESS:
            /* A device is available, and its capabilities were retrieved! */
            return 0;
        case ERROR_DEVICE_NOT_CONNECTED:
            return SDL_SetError("no device is connected at joystick index, %d", device_index);
        default:
            return SDL_SetError("an unknown error occurred when retrieving info on a device at joystick index, %d", device_index);
    }
}
/* Function to get the device-dependent name of a joystick */
const char *
SDL_SYS_JoystickNameForDeviceIndex(int device_index)
{
    XINPUT_CAPABILITIES deviceCaps;
    if (SDL_XInput_GetDeviceCapabilities(device_index, &deviceCaps) != 0) {
        /* Uh oh.  Device capabilities couldn't be retrieved.  Return to the
           caller.  SDL_SetError() has already been invoked (with relevant
           information).
         */
        return NULL;
    }
    switch (deviceCaps.SubType) {
        default:
            if (deviceCaps.Type == XINPUT_DEVTYPE_GAMEPAD) {
                return "Undefined game controller";
            } else {
                return "Undefined controller";
            }
        case XINPUT_DEVSUBTYPE_UNKNOWN:
            if (deviceCaps.Type == XINPUT_DEVTYPE_GAMEPAD) {
                return "Unknown game controller";
            } else {
                return "Unknown controller";
            }
        case XINPUT_DEVSUBTYPE_GAMEPAD:
            return "Gamepad controller";
        case XINPUT_DEVSUBTYPE_WHEEL:
            return "Racing wheel controller";
        case XINPUT_DEVSUBTYPE_ARCADE_STICK:
            return "Arcade stick controller";
        case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
            return "Flight stick controller";
        case XINPUT_DEVSUBTYPE_DANCE_PAD:
            return "Dance pad controller";
        case XINPUT_DEVSUBTYPE_GUITAR:
            return "Guitar controller";
        case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE:
            return "Guitar controller, Alternate";
        case XINPUT_DEVSUBTYPE_GUITAR_BASS:
            return "Guitar controller, Bass";
        case XINPUT_DEVSUBTYPE_DRUM_KIT:
            return "Drum controller";
        case XINPUT_DEVSUBTYPE_ARCADE_PAD:
            return "Arcade pad controller";
    }
}
/* Function to perform the mapping from device index to the instance id for this index */
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
{
    return device_index;
}
/* Function to open a joystick for use.
   The joystick to open is specified by the index field of the joystick.
   This should fill the nbuttons and naxes fields of the joystick structure.
   It returns 0, or -1 if there is an error.
 */
int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
{
    XINPUT_CAPABILITIES deviceCaps;
    if (SDL_XInput_GetDeviceCapabilities(device_index, &deviceCaps) != 0) {
        /* Uh oh.  Device capabilities couldn't be retrieved.  Return to the
           caller.  SDL_SetError() has already been invoked (with relevant
           information).
         */
        return -1;
    }
    /* For now, only game pads are supported.  If the device is something other
       than that, return an error to the caller.
     */
    if (deviceCaps.Type != XINPUT_DEVTYPE_GAMEPAD) {
        return SDL_SetError("a device is connected (at joystick index, %d), but it is of an unknown device type (deviceCaps.Flags=%ul)",
            device_index, (unsigned int)deviceCaps.Flags);
    }
    /* Create the joystick data structure */
    joystick->instance_id = device_index;
    joystick->hwdata = &g_XInputData[device_index];
    // The XInput API has a hard coded button/axis mapping, so we just match it
    joystick->naxes = 6;
    joystick->nbuttons = 15;
    joystick->nballs = 0;
    joystick->nhats = 0;
    /* We're done! */
    return (0);
}
/* Function to determine is this joystick is attached to the system right now */
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
{
    SDL_bool isDeviceConnected;
    SDL_LockMutex(g_DeviceInfoLock);
    isDeviceConnected = joystick->hwdata->isDeviceConnected;
    SDL_UnlockMutex(g_DeviceInfoLock);
    return isDeviceConnected;
}
/* Function to return > 0 if a bit array of buttons differs after applying a mask
*/
static int ButtonChanged( int ButtonsNow, int ButtonsPrev, int ButtonMask )
{
    return ( ButtonsNow & ButtonMask ) != ( ButtonsPrev & ButtonMask );
}
/* Function to update the state of a joystick - called as a device poll.
 * This function shouldn't update the joystick structure directly,
 * but instead should call SDL_PrivateJoystick*() to deliver events
 * and update joystick device state.
 */
void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
{
    HRESULT result;
    XINPUT_STATE prevXInputState;
    SDL_LockMutex(g_DeviceInfoLock);
    /* Before polling for new data, make note of the old data */
    prevXInputState = joystick->hwdata->XInputState;
    /* Poll for new data */
    result = XInputGetState(joystick->hwdata->userIndex, &joystick->hwdata->XInputState);
    if (result == ERROR_DEVICE_NOT_CONNECTED) {
        if (joystick->hwdata->isDeviceConnected) {
            joystick->hwdata->isDeviceConnected = SDL_FALSE;
            joystick->hwdata->isDeviceRemovalEventPending = SDL_TRUE;
            /* TODO, WinRT: make sure isDeviceRemovalEventPending gets cleared as appropriate, and that quick re-plugs don't cause trouble */
        }
        SDL_UnlockMutex(g_DeviceInfoLock);
        return;
    }
    /* Make sure the device is marked as connected */
    joystick->hwdata->isDeviceConnected = SDL_TRUE;
    // only fire events if the data changed from last time
    if ( joystick->hwdata->XInputState.dwPacketNumber != 0
        && joystick->hwdata->XInputState.dwPacketNumber != prevXInputState.dwPacketNumber )
    {
        XINPUT_STATE *pXInputState = &joystick->hwdata->XInputState;
        XINPUT_STATE *pXInputStatePrev = &prevXInputState;
        SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX );
        SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-1*pXInputState->Gamepad.sThumbLY-1) );
        SDL_PrivateJoystickAxis(joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX );
        SDL_PrivateJoystickAxis(joystick, 3, (Sint16)(-1*pXInputState->Gamepad.sThumbRY-1) );
        SDL_PrivateJoystickAxis(joystick, 4, (Sint16)((int)pXInputState->Gamepad.bLeftTrigger*32767/255) );
        SDL_PrivateJoystickAxis(joystick, 5, (Sint16)((int)pXInputState->Gamepad.bRightTrigger*32767/255) );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_UP ) )
            SDL_PrivateJoystickButton(joystick, 0, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_DOWN ) )
            SDL_PrivateJoystickButton(joystick, 1, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_LEFT ) )
            SDL_PrivateJoystickButton(joystick, 2, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_RIGHT ) )
            SDL_PrivateJoystickButton(joystick, 3, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_START ) )
            SDL_PrivateJoystickButton(joystick, 4, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_START ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_BACK ) )
            SDL_PrivateJoystickButton(joystick, 5, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_BACK ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_THUMB ) )
            SDL_PrivateJoystickButton(joystick, 6, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_THUMB ) )
            SDL_PrivateJoystickButton(joystick, 7, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_SHOULDER ) )
            SDL_PrivateJoystickButton(joystick, 8, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_SHOULDER ) )
            SDL_PrivateJoystickButton(joystick, 9, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_A ) )
            SDL_PrivateJoystickButton(joystick, 10, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_A ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_B ) )
            SDL_PrivateJoystickButton(joystick, 11, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_B ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_X ) )
            SDL_PrivateJoystickButton(joystick, 12, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_X ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_Y ) )
            SDL_PrivateJoystickButton(joystick, 13, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_Y ? SDL_PRESSED :    SDL_RELEASED );
        if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons,  0x400 ) )
            SDL_PrivateJoystickButton(joystick, 14, pXInputState->Gamepad.wButtons & 0x400 ? SDL_PRESSED :    SDL_RELEASED ); // 0x400 is the undocumented code for the guide button
    }
    SDL_UnlockMutex(g_DeviceInfoLock);
}
/* Function to close a joystick after use */
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{
    /* Clear cached button data on the joystick */
    SDL_LockMutex(g_DeviceInfoLock);
    SDL_zero(joystick->hwdata->XInputState);
    SDL_UnlockMutex(g_DeviceInfoLock);
    /* There's need to free 'hwdata', as it's a pointer to a global array.
       The field will be cleared anyways, just to indicate that it's not
       currently needed.
     */
    joystick->hwdata = NULL;
}
/* Function to perform any system-specific joystick related cleanup */
void
SDL_SYS_JoystickQuit(void)
{
    /* Tell the joystick detection thread to stop, then wait for it to finish */
    SDL_LockMutex(g_DeviceInfoLock);
    g_DeviceDetectionQuit = SDL_TRUE;
    SDL_UnlockMutex(g_DeviceInfoLock);
    SDL_WaitThread(g_DeviceDetectionThread, NULL);
    /* Clean up device-detection stuff */
    SDL_DestroyMutex(g_DeviceInfoLock);
    g_DeviceInfoLock = NULL;
    g_DeviceDetectionThread = NULL;
    g_DeviceDetectionQuit = SDL_FALSE;
    return;
}
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
{
    SDL_JoystickGUID guid;
    // the GUID is just the first 16 chars of the name for now
    const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
    SDL_zero( guid );
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    return guid;
}
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
{
    SDL_JoystickGUID guid;
    // the GUID is just the first 16 chars of the name for now
    const char *name = joystick->name;
    SDL_zero( guid );
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    return guid;
}
SDL_bool SDL_SYS_IsXInputDeviceIndex(int device_index)
{
    /* The XInput-capable DirectInput joystick backend implements the same
       function (SDL_SYS_IsXInputDeviceIndex), however in that case, not all
       joystick devices are XInput devices.  In this case, with the
       WinRT-enabled XInput-only backend, all "joystick" devices are XInput
       devices.
     */
    return SDL_TRUE;
}
#endif /* SDL_JOYSTICK_XINPUT */
/* vi: set ts=4 sw=4 expandtab: */
source/src/loadso/windows/SDL_sysloadso.c
@@ -33,7 +33,15 @@
SDL_LoadObject(const char *sofile)
{
    LPTSTR tstr = WIN_UTF8ToString(sofile);
#ifdef __WINRT__
    /* WinRT only publically supports LoadPackagedLibrary() for loading .dll
       files.  LoadLibrary() is a private API, and not available for apps
       (that can be published to MS' Windows Store.)
    */
    void *handle = (void *) LoadPackagedLibrary(tstr, 0);
#else
    void *handle = (void *) LoadLibrary(tstr);
#endif
    SDL_free(tstr);
    /* Generate an error message if all loads failed */
source/src/main/android/SDL_android_main.c
@@ -1,4 +1,6 @@
/*
    SDL_android_main.c, placed in the public domain by Sam Lantinga  3/13/14
*/
#include "../../SDL_internal.h"
#ifdef __ANDROID__
source/src/main/dummy/SDL_dummy_main.c
@@ -1,6 +1,9 @@
/*
    SDL_dummy_main.c, placed in the public domain by Sam Lantinga  3/13/14
*/
#include "../../SDL_internal.h"
/* Include the SDL main definition header */
#include "../../SDL_internal.h"
#include "SDL_main.h"
#ifdef main
source/src/main/haiku/SDL_BeApp.h
@@ -20,7 +20,6 @@
*/
#include "../../SDL_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
source/src/main/psp/SDL_psp_main.c
@@ -1,22 +1,5 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
    SDL_psp_main.c, placed in the public domain by Sam Lantinga  3/13/14
*/
#include "SDL_main.h"
source/src/main/windows/SDL_windows_main.c
@@ -1,5 +1,5 @@
/*
    SDL_main.c, placed in the public domain by Sam Lantinga  4/13/98
    SDL_windows_main.c, placed in the public domain by Sam Lantinga  4/13/98
    The WinMain function -- calls your program's main() function
*/
source/src/main/windows/version.rc
@@ -9,8 +9,8 @@
//
VS_VERSION_INFO VERSIONINFO
 FILEVERSION 2,0,2,0
 PRODUCTVERSION 2,0,2,0
 FILEVERSION 2,0,3,0
 PRODUCTVERSION 2,0,3,0
 FILEFLAGSMASK 0x3fL
 FILEFLAGS 0x0L
 FILEOS 0x40004L
@@ -23,12 +23,12 @@
        BEGIN
            VALUE "CompanyName", "\0"
            VALUE "FileDescription", "SDL\0"
            VALUE "FileVersion", "2, 0, 2, 0\0"
            VALUE "FileVersion", "2, 0, 3, 0\0"
            VALUE "InternalName", "SDL\0"
            VALUE "LegalCopyright", "Copyright Â© 2014 Sam Lantinga\0"
            VALUE "OriginalFilename", "SDL2.dll\0"
            VALUE "ProductName", "Simple DirectMedia Layer\0"
            VALUE "ProductVersion", "2, 0, 2, 0\0"
            VALUE "ProductVersion", "2, 0, 3, 0\0"
        END
    END
    BLOCK "VarFileInfo"
source/src/main/winrt/SDL_winrt_main_NonXAML.cpp
New file
@@ -0,0 +1,59 @@
/*
    SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig  3/13/14
*/
#include "SDL_main.h"
#include <wrl.h>
/* At least one file in any SDL/WinRT app appears to require compilation
   with C++/CX, otherwise a Windows Metadata file won't get created, and
   an APPX0702 build error can appear shortly after linking.
   The following set of preprocessor code forces this file to be compiled
   as C++/CX, which appears to cause Visual C++ 2012's build tools to
   create this .winmd file, and will help allow builds of SDL/WinRT apps
   to proceed without error.
   If other files in an app's project enable C++/CX compilation, then it might
   be possible for SDL_winrt_main_NonXAML.cpp to be compiled without /ZW,
   for Visual C++'s build tools to create a winmd file, and for the app to
   build without APPX0702 errors.  In this case, if
   SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then
   the #error (to force C++/CX compilation) will be disabled.
   Please note that /ZW can be specified on a file-by-file basis.  To do this,
   right click on the file in Visual C++, click Properties, then change the
   setting through the dialog that comes up.
*/
#ifndef SDL_WINRT_METADATA_FILE_AVAILABLE
#ifndef __cplusplus_winrt
#error SDL_winrt_main_NonXAML.cpp must be compiled with /ZW, otherwise build errors due to missing .winmd files can occur.
#endif
#endif
/* Prevent MSVC++ from warning about threading models when defining our
   custom WinMain.  The threading model will instead be set via a direct
   call to Windows::Foundation::Initialize (rather than via an attributed
   function).
   To note, this warning (C4447) does not seem to come up unless this file
   is compiled with C++/CX enabled (via the /ZW compiler flag).
*/
#ifdef _MSC_VER
#pragma warning(disable:4447)
#endif
/* Make sure the function to initialize the Windows Runtime gets linked in. */
#ifdef _MSC_VER
#pragma comment(lib, "runtimeobject.lib")
#endif
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) {
        return 1;
    }
    SDL_WinRTRunApp(SDL_main, NULL);
    return 0;
}
source/src/power/SDL_power.c
@@ -37,6 +37,7 @@
SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *);
SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *);
SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *);
SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *);
#ifndef SDL_POWER_DISABLED
#ifdef SDL_POWER_HARDWIRED
@@ -77,6 +78,9 @@
#ifdef SDL_POWER_PSP        /* handles PSP. */
    SDL_GetPowerInfo_PSP,
#endif
#ifdef SDL_POWER_WINRT          /* handles WinRT */
    SDL_GetPowerInfo_WinRT,
#endif
#ifdef SDL_POWER_HARDWIRED
    SDL_GetPowerInfo_Hardwired,
source/src/power/winrt/SDL_syspower.cpp
New file
@@ -0,0 +1,44 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef SDL_POWER_DISABLED
#if SDL_POWER_WINRT
#include "SDL_power.h"
extern "C"
SDL_bool
SDL_GetPowerInfo_WinRT(SDL_PowerState * state, int *seconds, int *percent)
{
    /* TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8).  Implement SDL_GetPowerInfo_WinRT as appropriate. */
    /* Notes:
         - the Win32 function, GetSystemPowerStatus, is not available for use on WinRT
         - Windows Phone 8 has a 'Battery' class, which is documented as available for C++
             - More info on WP8's Battery class can be found at http://msdn.microsoft.com/library/windowsphone/develop/jj207231
    */
    return SDL_FALSE;
}
#endif /* SDL_POWER_WINRT */
#endif /* SDL_POWER_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */
source/src/render/SDL_d3dmath.c
New file
@@ -0,0 +1,131 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#include "SDL_stdinc.h"
#include "SDL_d3dmath.h"
/* Direct3D matrix math functions */
Float4X4 MatrixIdentity()
{
    Float4X4 m;
    SDL_zero(m);
    m._11 = 1.0f;
    m._22 = 1.0f;
    m._33 = 1.0f;
    m._44 = 1.0f;
    return m;
}
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2)
{
    Float4X4 m;
    m._11 = M1._11 * M2._11 + M1._12 * M2._21 + M1._13 * M2._31 + M1._14 * M2._41;
    m._12 = M1._11 * M2._12 + M1._12 * M2._22 + M1._13 * M2._32 + M1._14 * M2._42;
    m._13 = M1._11 * M2._13 + M1._12 * M2._23 + M1._13 * M2._33 + M1._14 * M2._43;
    m._14 = M1._11 * M2._14 + M1._12 * M2._24 + M1._13 * M2._34 + M1._14 * M2._44;
    m._21 = M1._21 * M2._11 + M1._22 * M2._21 + M1._23 * M2._31 + M1._24 * M2._41;
    m._22 = M1._21 * M2._12 + M1._22 * M2._22 + M1._23 * M2._32 + M1._24 * M2._42;
    m._23 = M1._21 * M2._13 + M1._22 * M2._23 + M1._23 * M2._33 + M1._24 * M2._43;
    m._24 = M1._21 * M2._14 + M1._22 * M2._24 + M1._23 * M2._34 + M1._24 * M2._44;
    m._31 = M1._31 * M2._11 + M1._32 * M2._21 + M1._33 * M2._31 + M1._34 * M2._41;
    m._32 = M1._31 * M2._12 + M1._32 * M2._22 + M1._33 * M2._32 + M1._34 * M2._42;
    m._33 = M1._31 * M2._13 + M1._32 * M2._23 + M1._33 * M2._33 + M1._34 * M2._43;
    m._34 = M1._31 * M2._14 + M1._32 * M2._24 + M1._33 * M2._34 + M1._34 * M2._44;
    m._41 = M1._41 * M2._11 + M1._42 * M2._21 + M1._43 * M2._31 + M1._44 * M2._41;
    m._42 = M1._41 * M2._12 + M1._42 * M2._22 + M1._43 * M2._32 + M1._44 * M2._42;
    m._43 = M1._41 * M2._13 + M1._42 * M2._23 + M1._43 * M2._33 + M1._44 * M2._43;
    m._44 = M1._41 * M2._14 + M1._42 * M2._24 + M1._43 * M2._34 + M1._44 * M2._44;
    return m;
}
Float4X4 MatrixScaling(float x, float y, float z)
{
    Float4X4 m;
    SDL_zero(m);
    m._11 = x;
    m._22 = y;
    m._33 = z;
    m._44 = 1.0f;
    return m;
}
Float4X4 MatrixTranslation(float x, float y, float z)
{
    Float4X4 m;
    SDL_zero(m);
    m._11 = 1.0f;
    m._22 = 1.0f;
    m._33 = 1.0f;
    m._44 = 1.0f;
    m._41 = x;
    m._42 = y;
    m._43 = z;
    return m;
}
Float4X4 MatrixRotationX(float r)
{
    float sinR = SDL_sinf(r);
    float cosR = SDL_cosf(r);
    Float4X4 m;
    SDL_zero(m);
    m._11 = 1.0f;
    m._22 = cosR;
    m._23 = sinR;
    m._32 = -sinR;
    m._33 = cosR;
    m._44 = 1.0f;
    return m;
}
Float4X4 MatrixRotationY(float r)
{
    float sinR = SDL_sinf(r);
    float cosR = SDL_cosf(r);
    Float4X4 m;
    SDL_zero(m);
    m._11 = cosR;
    m._13 = -sinR;
    m._22 = 1.0f;
    m._31 = sinR;
    m._33 = cosR;
    m._44 = 1.0f;
    return m;
}
Float4X4 MatrixRotationZ(float r)
{
    float sinR = SDL_sinf(r);
    float cosR = SDL_cosf(r);
    Float4X4 m;
    SDL_zero(m);
    m._11 = cosR;
    m._12 = sinR;
    m._21 = -sinR;
    m._22 = cosR;
    m._33 = 1.0f;
    m._44 = 1.0f;
    return m;
}
/* vi: set ts=4 sw=4 expandtab: */
source/src/render/SDL_d3dmath.h
New file
@@ -0,0 +1,69 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
/* Direct3D matrix math functions */
typedef struct
{
    float x;
    float y;
} Float2;
typedef struct
{
    float x;
    float y;
    float z;
} Float3;
typedef struct
{
    float x;
    float y;
    float z;
    float w;
} Float4;
typedef struct
{
    union {
        struct {
            float _11, _12, _13, _14;
            float _21, _22, _23, _24;
            float _31, _32, _33, _34;
            float _41, _42, _43, _44;
        };
        float m[4][4];
    };
} Float4X4;
Float4X4 MatrixIdentity();
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
Float4X4 MatrixScaling(float x, float y, float z);
Float4X4 MatrixTranslation(float x, float y, float z);
Float4X4 MatrixRotationX(float r);
Float4X4 MatrixRotationY(float r);
Float4X4 MatrixRotationZ(float r);
/* vi: set ts=4 sw=4 expandtab: */
source/src/render/SDL_render.c
@@ -50,6 +50,9 @@
#if SDL_VIDEO_RENDER_D3D
    &D3D_RenderDriver,
#endif
#if SDL_VIDEO_RENDER_D3D11
    &D3D11_RenderDriver,
#endif
#if SDL_VIDEO_RENDER_OGL
    &GL_RenderDriver,
#endif
source/src/render/SDL_sysrender.h
@@ -171,6 +171,9 @@
#if SDL_VIDEO_RENDER_D3D
extern SDL_RenderDriver D3D_RenderDriver;
#endif
#if SDL_VIDEO_RENDER_D3D11
extern SDL_RenderDriver D3D11_RenderDriver;
#endif
#if SDL_VIDEO_RENDER_OGL
extern SDL_RenderDriver GL_RenderDriver;
#endif
source/src/render/direct3d/SDL_render_d3d.c
@@ -31,6 +31,7 @@
#include "SDL_loadso.h"
#include "SDL_syswm.h"
#include "../SDL_sysrender.h"
#include "../SDL_d3dmath.h"
#include "../../video/windows/SDL_windowsvideo.h"
#if SDL_VIDEO_RENDER_D3D
@@ -38,89 +39,6 @@
#include <d3d9.h>
#endif
typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK;
typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX;
typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3;
DEFINE_GUID(IID_ID3DXMatrixStack,
0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85);
#undef INTERFACE
#define INTERFACE ID3DXMatrixStack
DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown)
{
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
    STDMETHOD_(ULONG,Release)(THIS) PURE;
    STDMETHOD(Pop)(THIS) PURE;
    STDMETHOD(Push)(THIS) PURE;
    STDMETHOD(LoadIdentity)(THIS) PURE;
    STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE;
    STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE;
    STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE;
    STDMETHOD(RotateAxis)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE;
    STDMETHOD(RotateAxisLocal)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE;
    STDMETHOD(RotateYawPitchRoll)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE;
    STDMETHOD(RotateYawPitchRollLocal)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE;
    STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
    STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
    STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE;
    STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
    STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE;
};
#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
#define ID3DXMatrixStack_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
#define ID3DXMatrixStack_AddRef(p)                        (p)->lpVtbl->AddRef(p)
#define ID3DXMatrixStack_Release(p)                       (p)->lpVtbl->Release(p)
#define ID3DXMatrixStack_Pop(p)                           (p)->lpVtbl->Pop(p)
#define ID3DXMatrixStack_Push(p)                          (p)->lpVtbl->Push(p)
#define ID3DXMatrixStack_LoadIdentity(p)                  (p)->lpVtbl->LoadIdentity(p)
#define ID3DXMatrixStack_LoadMatrix(p,a)                  (p)->lpVtbl->LoadMatrix(p,a)
#define ID3DXMatrixStack_MultMatrix(p,a)                  (p)->lpVtbl->MultMatrix(p,a)
#define ID3DXMatrixStack_MultMatrixLocal(p,a)             (p)->lpVtbl->MultMatrixLocal(p,a)
#define ID3DXMatrixStack_RotateAxis(p,a,b)                (p)->lpVtbl->RotateAxis(p,a,b)
#define ID3DXMatrixStack_RotateAxisLocal(p,a,b)           (p)->lpVtbl->RotateAxisLocal(p,a,b)
#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c)      (p)->lpVtbl->RotateYawPitchRoll(p,a,b,c)
#define ID3DXMatrixStack_RotateYawPitchRollLocal(p,a,b,c) (p)->lpVtbl->RotateYawPitchRollLocal(p,a,b,c)
#define ID3DXMatrixStack_Scale(p,a,b,c)                   (p)->lpVtbl->Scale(p,a,b,c)
#define ID3DXMatrixStack_ScaleLocal(p,a,b,c)              (p)->lpVtbl->ScaleLocal(p,a,b,c)
#define ID3DXMatrixStack_Translate(p,a,b,c)               (p)->lpVtbl->Translate(p,a,b,c)
#define ID3DXMatrixStack_TranslateLocal(p,a,b,c)          (p)->lpVtbl->TranslateLocal(p,a,b,c)
#define ID3DXMatrixStack_GetTop(p)                        (p)->lpVtbl->GetTop(p)
#else
#define ID3DXMatrixStack_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
#define ID3DXMatrixStack_AddRef(p)                        (p)->AddRef()
#define ID3DXMatrixStack_Release(p)                       (p)->Release()
#define ID3DXMatrixStack_Pop(p)    (p)->Pop()
#define ID3DXMatrixStack_Push(p)    (p)->Push()
#define ID3DXMatrixStack_LoadIdentity(p)    (p)->LoadIdentity()
#define ID3DXMatrixStack_LoadMatrix(p,a)    (p)->LoadMatrix(a)
#define ID3DXMatrixStack_MultMatrix(p,a)    (p)->MultMatrix(a)
#define ID3DXMatrixStack_MultMatrixLocal(p,a)    (p)->MultMatrixLocal(a)
#define ID3DXMatrixStack_RotateAxis(p,a,b)    (p)->RotateAxis(a,b)
#define ID3DXMatrixStack_RotateAxisLocal(p,a,b)    (p)->RotateAxisLocal(a,b)
#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c)    (p)->RotateYawPitchRollLocal(a,b,c)
#define ID3DXMatrixStack_Scale(p,a,b,c)    (p)->Scale(a,b,c)
#define ID3DXMatrixStack_ScaleLocal(p,a,b,c)    (p)->ScaleLocal(a,b,c)
#define ID3DXMatrixStack_Translate(p,a,b,c)    (p)->Translate(a,b,c)
#define ID3DXMatrixStack_TranslateLocal(p,a,b,c)    (p)->TranslateLocal(a,b,c)
#define ID3DXMatrixStack_GetTop(p)    (p)->GetTop()
#endif
#ifdef __cplusplus
extern "C" {
#endif
HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack);
#ifdef __cplusplus
}
#endif
#ifdef ASSEMBLE_SHADER
/**************************************************************************
@@ -266,7 +184,6 @@
    IDirect3DSurface9 *defaultRenderTarget;
    IDirect3DSurface9 *currentRenderTarget;
    void* d3dxDLL;
    ID3DXMatrixStack *matrixStack;
    LPDIRECT3DPIXELSHADER9 ps_yuv;
} D3D_RenderData;
@@ -582,8 +499,6 @@
    Uint32 window_flags;
    int w, h;
    SDL_DisplayMode fullscreen_mode;
    int d3dxVersion;
    char d3dxDLLFile[50];
    int displayIndex;
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
@@ -599,29 +514,7 @@
        return NULL;
    }
    if (D3D_LoadDLL(&data->d3dDLL, &data->d3d)) {
        for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) {
            LPTSTR dllName;
            SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion);
            dllName = WIN_UTF8ToString(d3dxDLLFile);
            data->d3dxDLL = (void *)LoadLibrary(dllName); /* not using SDL_LoadObject() as we want silently fail - no error message */
            SDL_free(dllName);
            if (data->d3dxDLL) {
                HRESULT (WINAPI *D3DXCreateMatrixStack) (DWORD Flags, LPD3DXMATRIXSTACK*  ppStack);
                D3DXCreateMatrixStack = (HRESULT (WINAPI *) (DWORD, LPD3DXMATRIXSTACK*)) SDL_LoadFunction(data->d3dxDLL, "D3DXCreateMatrixStack");
                if (D3DXCreateMatrixStack) {
                    D3DXCreateMatrixStack(0, &data->matrixStack);
                    break;
                }
            }
        }
        if (!data->matrixStack) {
            if (data->d3dxDLL) SDL_UnloadObject(data->d3dxDLL);
        }
    }
    if (!data->d3d || !data->matrixStack) {
    if (!D3D_LoadDLL(&data->d3dDLL, &data->d3d)) {
        SDL_free(renderer);
        SDL_free(data);
        SDL_SetError("Unable to create Direct3D interface");
@@ -648,9 +541,8 @@
    renderer->DestroyTexture = D3D_DestroyTexture;
    renderer->DestroyRenderer = D3D_DestroyRenderer;
    renderer->info = D3D_RenderDriver.info;
    renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
    renderer->driverdata = data;
    renderer->info.flags = SDL_RENDERER_ACCELERATED;
    SDL_VERSION(&windowinfo.version);
    SDL_GetWindowWMInfo(window, &windowinfo);
@@ -1698,6 +1590,7 @@
    float centerx, centery;
    DWORD color;
    Vertex vertices[4];
    Float4X4 modelMatrix;
    HRESULT result;
    if (D3D_ActivateRenderer(renderer) < 0) {
@@ -1769,11 +1662,11 @@
    D3D_SetBlendMode(data, texture->blendMode);
    /* Rotate and translate */
    ID3DXMatrixStack_Push(data->matrixStack);
    ID3DXMatrixStack_LoadIdentity(data->matrixStack);
    ID3DXMatrixStack_RotateYawPitchRoll(data->matrixStack, 0.0, 0.0, (float)(M_PI * (float) angle / 180.0f));
    ID3DXMatrixStack_Translate(data->matrixStack, (float)dstrect->x + centerx, (float)dstrect->y + centery, (float)0.0);
    IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)ID3DXMatrixStack_GetTop(data->matrixStack));
    modelMatrix = MatrixMultiply(
            MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)),
            MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0)
            );
    IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
    D3D_UpdateTextureScaleMode(data, texturedata, 0);
@@ -1823,11 +1716,9 @@
            return D3D_SetError("SetShader()", result);
        }
    }
    ID3DXMatrixStack_Pop(data->matrixStack);
    ID3DXMatrixStack_Push(data->matrixStack);
    ID3DXMatrixStack_LoadIdentity(data->matrixStack);
    IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)ID3DXMatrixStack_GetTop(data->matrixStack));
    ID3DXMatrixStack_Pop(data->matrixStack);
    modelMatrix = MatrixIdentity();
    IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
    return 0;
}
@@ -1961,7 +1852,6 @@
        }
        if (data->d3d) {
            IDirect3D9_Release(data->d3d);
            ID3DXMatrixStack_Release(data->matrixStack);
            SDL_UnloadObject(data->d3dDLL);
        }
        SDL_free(data);
source/src/render/direct3d11/SDL_render_d3d11.c
New file
@@ -0,0 +1,2879 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
#define COBJMACROS
#include "../../core/windows/SDL_windows.h"
#include "SDL_hints.h"
#include "SDL_loadso.h"
#include "SDL_syswm.h"
#include "../SDL_sysrender.h"
#include "../SDL_d3dmath.h"
#include <d3d11_1.h>
#ifdef __WINRT__
#include "SDL_render_winrt.h"
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
#include <windows.ui.xaml.media.dxinterop.h>
/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */
extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative;
#endif  /* WINAPI_FAMILY == WINAPI_FAMILY_APP */
#endif  /* __WINRT__ */
#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
/* Vertex shader, common values */
typedef struct
{
    Float4X4 model;
    Float4X4 projectionAndView;
} VertexShaderConstants;
/* Per-vertex data */
typedef struct
{
    Float3 pos;
    Float2 tex;
    Float4 color;
} VertexPositionColor;
/* Per-texture data */
typedef struct
{
    ID3D11Texture2D *mainTexture;
    ID3D11ShaderResourceView *mainTextureResourceView;
    ID3D11RenderTargetView *mainTextureRenderTargetView;
    ID3D11Texture2D *stagingTexture;
    int lockedTexturePositionX;
    int lockedTexturePositionY;
    D3D11_FILTER scaleMode;
    /* YV12 texture support */
    SDL_bool yuv;
    ID3D11Texture2D *mainTextureU;
    ID3D11ShaderResourceView *mainTextureResourceViewU;
    ID3D11Texture2D *mainTextureV;
    ID3D11ShaderResourceView *mainTextureResourceViewV;
    Uint8 *pixels;
    int pitch;
    SDL_Rect locked_rect;
} D3D11_TextureData;
/* Private renderer data */
typedef struct
{
    void *hDXGIMod;
    void *hD3D11Mod;
    IDXGIFactory2 *dxgiFactory;
    IDXGIAdapter *dxgiAdapter;
    ID3D11Device1 *d3dDevice;
    ID3D11DeviceContext1 *d3dContext;
    IDXGISwapChain1 *swapChain;
    DXGI_SWAP_EFFECT swapEffect;
    ID3D11RenderTargetView *mainRenderTargetView;
    ID3D11RenderTargetView *currentOffscreenRenderTargetView;
    ID3D11InputLayout *inputLayout;
    ID3D11Buffer *vertexBuffer;
    ID3D11VertexShader *vertexShader;
    ID3D11PixelShader *colorPixelShader;
    ID3D11PixelShader *texturePixelShader;
    ID3D11PixelShader *yuvPixelShader;
    ID3D11BlendState *blendModeBlend;
    ID3D11BlendState *blendModeAdd;
    ID3D11BlendState *blendModeMod;
    ID3D11SamplerState *nearestPixelSampler;
    ID3D11SamplerState *linearSampler;
    D3D_FEATURE_LEVEL featureLevel;
    /* Rasterizers */
    ID3D11RasterizerState *mainRasterizer;
    ID3D11RasterizerState *clippedRasterizer;
    /* Vertex buffer constants */
    VertexShaderConstants vertexShaderConstantsData;
    ID3D11Buffer *vertexShaderConstants;
    /* Cached renderer properties */
    DXGI_MODE_ROTATION rotation;
    ID3D11RenderTargetView *currentRenderTargetView;
    ID3D11RasterizerState *currentRasterizerState;
    ID3D11BlendState *currentBlendState;
    ID3D11PixelShader *currentShader;
    ID3D11ShaderResourceView *currentShaderResource;
    ID3D11SamplerState *currentSampler;
} D3D11_RenderData;
/* Defined here so we don't have to include uuid.lib */
static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
static const GUID IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
static const GUID IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } };
static const GUID IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } };
static const GUID IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } };
static const GUID IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } };
/* Direct3D 11.x shaders
   SDL's shaders are compiled into SDL itself, to simplify distribution.
   All Direct3D 11.x shaders were compiled with the following:
   fxc /E"main" /T "<TYPE>" /Fo"<OUTPUT FILE>" "<INPUT FILE>"
     Variables:
     - <TYPE>: the type of shader.  A table of utilized shader types is
       listed below.
     - <OUTPUT FILE>: where to store compiled output
     - <INPUT FILE>: where to read shader source code from
     Shader types:
     - ps_4_0_level_9_1: Pixel shader for Windows 8+, including Windows RT
     - vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT
     - ps_4_0_level_9_3: Pixel shader for Windows Phone 8
     - vs_4_0_level_9_3: Vertex shader for Windows Phone 8
   Shader object code was converted to a list of DWORDs via the following
   *nix style command (available separately from Windows + MSVC):
     hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE>
  */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#define D3D11_USE_SHADER_MODEL_4_0_level_9_3
#else
#define D3D11_USE_SHADER_MODEL_4_0_level_9_1
#endif
/* The color-only-rendering pixel shader:
   --- D3D11_PixelShader_Colors.hlsl ---
   struct PixelShaderInput
   {
       float4 pos : SV_POSITION;
       float2 tex : TEXCOORD0;
       float4 color : COLOR0;
   };
   float4 main(PixelShaderInput input) : SV_TARGET
   {
       return input.color;
   }
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_PixelShader_Colors[] = {
    0x43425844, 0xd74c28fe, 0xa1eb8804, 0x269d512a, 0x7699723d, 0x00000001,
    0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
    0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
    0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
    0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
    0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
    0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
    0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
    0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
    0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
    0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
    0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
    0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
    0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_PixelShader_Colors[] = {
    0x43425844, 0x93f6ccfc, 0x5f919270, 0x7a11aa4f, 0x9148e931, 0x00000001,
    0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
    0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
    0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
    0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
    0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
    0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
    0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
    0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
    0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
    0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
    0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
    0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
    0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#else
#error "An appropriate 'colors' pixel shader is not defined."
#endif
/* The texture-rendering pixel shader:
    --- D3D11_PixelShader_Textures.hlsl ---
    Texture2D theTexture : register(t0);
    SamplerState theSampler : register(s0);
    struct PixelShaderInput
    {
        float4 pos : SV_POSITION;
        float2 tex : TEXCOORD0;
        float4 color : COLOR0;
    };
    float4 main(PixelShaderInput input) : SV_TARGET
    {
        return theTexture.Sample(theSampler, input.tex) * input.color;
    }
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_PixelShader_Textures[] = {
    0x43425844, 0x6299b59f, 0x155258f2, 0x873ab86a, 0xfcbb6dcd, 0x00000001,
    0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
    0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
    0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
    0x00280000, 0x00000000, 0xffff0200, 0x0200001f, 0x80000000, 0xb0030000,
    0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
    0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
    0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
    0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
    0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
    0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
    0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
    0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
    0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
    0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
    0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
    0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
    0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
    0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
    0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
    0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
    0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
    0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_PixelShader_Textures[] = {
    0x43425844, 0x5876569a, 0x01b6c87e, 0x8447454f, 0xc7f3ef10, 0x00000001,
    0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
    0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
    0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
    0x00280000, 0x00000000, 0xffff0201, 0x0200001f, 0x80000000, 0xb0030000,
    0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
    0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
    0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
    0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
    0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
    0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
    0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
    0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
    0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
    0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
    0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
    0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
    0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
    0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
    0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
    0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
    0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
    0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#else
#error "An appropriate 'textures' pixel shader is not defined"
#endif
/* The yuv-rendering pixel shader:
    --- D3D11_PixelShader_YUV.hlsl ---
    Texture2D theTextureY : register(t0);
    Texture2D theTextureU : register(t1);
    Texture2D theTextureV : register(t2);
    SamplerState theSampler : register(s0);
    struct PixelShaderInput
    {
        float4 pos : SV_POSITION;
        float2 tex : TEXCOORD0;
        float4 color : COLOR0;
    };
    float4 main(PixelShaderInput input) : SV_TARGET
    {
        const float3 offset = {-0.0625, -0.5, -0.5};
        const float3 Rcoeff = {1.164,  0.000,  1.596};
        const float3 Gcoeff = {1.164, -0.391, -0.813};
        const float3 Bcoeff = {1.164,  2.018,  0.000};
        float4 Output;
        float3 yuv;
        yuv.x = theTextureY.Sample(theSampler, input.tex).r;
        yuv.y = theTextureU.Sample(theSampler, input.tex).r;
        yuv.z = theTextureV.Sample(theSampler, input.tex).r;
        yuv += offset;
        Output.r = dot(yuv, Rcoeff);
        Output.g = dot(yuv, Gcoeff);
        Output.b = dot(yuv, Bcoeff);
        Output.a = 1.0f;
        return Output * input.color;
    }
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_PixelShader_YUV[] = {
    0x43425844, 0x04e69cba, 0x74ce6dd2, 0x7fcf84cb, 0x3003d677, 0x00000001,
    0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
    0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
    0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
    0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
    0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000, 0x3f800000, 0x05000051,
    0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
    0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
    0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
    0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
    0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
    0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
    0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
    0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
    0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
    0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
    0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
    0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
    0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
    0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
    0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
    0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
    0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
    0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
    0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
    0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
    0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
    0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
    0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
    0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
    0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
    0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
    0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, 0x0a00000f, 0x00100012,
    0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
    0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
    0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
    0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
    0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
    0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
    0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
    0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
    0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
    0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
    0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
    0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
    0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
    0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
    0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
    0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
    0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
    0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
    0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_PixelShader_YUV[] = {
    0x43425844, 0xe6d969fc, 0x63cac33c, 0xa4926502, 0x5d788135, 0x00000001,
    0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
    0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
    0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
    0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
    0xa00f0000, 0xbd800000, 0xbf000000, 0x3f800000, 0x00000000, 0x05000051,
    0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
    0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
    0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
    0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
    0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
    0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
    0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
    0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
    0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008,
    0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000,
    0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
    0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
    0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
    0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
    0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
    0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
    0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
    0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
    0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
    0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
    0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
    0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
    0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
    0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
    0x00000000, 0x00004002, 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000,
    0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
    0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
    0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,
    0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
    0x00000000, 0x00004002, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000,
    0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
    0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
    0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
    0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
    0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
    0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
    0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
    0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
    0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
    0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
    0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
    0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
    0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
    0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
    0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
    0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
    0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
    0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
    0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
    0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
    0x45475241, 0xabab0054
};
#else
#error "An appropriate 'yuv' pixel shader is not defined."
#endif
/* The sole vertex shader:
   --- D3D11_VertexShader.hlsl ---
   #pragma pack_matrix( row_major )
   cbuffer VertexShaderConstants : register(b0)
   {
       matrix model;
       matrix projectionAndView;
   };
   struct VertexShaderInput
   {
       float3 pos : POSITION;
       float2 tex : TEXCOORD0;
       float4 color : COLOR0;
   };
   struct VertexShaderOutput
   {
       float4 pos : SV_POSITION;
       float2 tex : TEXCOORD0;
       float4 color : COLOR0;
   };
   VertexShaderOutput main(VertexShaderInput input)
   {
       VertexShaderOutput output;
       float4 pos = float4(input.pos, 1.0f);
       // Transform the vertex position into projected space.
       pos = mul(pos, model);
       pos = mul(pos, projectionAndView);
       output.pos = pos;
       // Pass through texture coordinates and color values without transformation
       output.tex = input.tex;
       output.color = input.color;
       return output;
   }
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_VertexShader[] = {
    0x43425844, 0x62dfae5f, 0x3e8bd8df, 0x9ec97127, 0x5044eefb, 0x00000001,
    0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
    0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
    0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
    0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0200,
    0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
    0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
    0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
    0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
    0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
    0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
    0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
    0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
    0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
    0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
    0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
    0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
    0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
    0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
    0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
    0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
    0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
    0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
    0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
    0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
    0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
    0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
    0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
    0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
    0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
    0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
    0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
    0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
    0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
    0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
    0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
    0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
    0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
    0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
    0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
    0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
    0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
    0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
    0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
    0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
    0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
    0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
    0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
    0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
    0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
    0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
    0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
    0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
    0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_VertexShader[] = {
    0x43425844, 0x01a24e41, 0x696af551, 0x4b2a87d1, 0x82ea03f6, 0x00000001,
    0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
    0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
    0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
    0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0201,
    0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
    0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
    0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
    0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
    0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
    0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
    0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
    0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
    0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
    0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
    0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
    0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
    0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
    0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
    0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
    0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
    0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
    0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
    0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
    0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
    0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
    0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
    0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
    0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
    0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
    0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
    0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
    0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
    0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
    0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
    0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
    0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
    0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
    0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
    0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
    0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
    0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
    0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
    0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
    0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
    0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
    0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
    0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
    0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
    0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
    0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
    0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
    0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
    0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
};
#else
#error "An appropriate vertex shader is not defined."
#endif
/* Direct3D 11.1 renderer implementation */
static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
static void D3D11_WindowEvent(SDL_Renderer * renderer,
                            const SDL_WindowEvent *event);
static int D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static int D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                             const SDL_Rect * rect, const void *srcPixels,
                             int srcPitch);
static int D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
                                  const SDL_Rect * rect,
                                  const Uint8 *Yplane, int Ypitch,
                                  const Uint8 *Uplane, int Upitch,
                                  const Uint8 *Vplane, int Vpitch);
static int D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                             const SDL_Rect * rect, void **pixels, int *pitch);
static void D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static int D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
static int D3D11_UpdateViewport(SDL_Renderer * renderer);
static int D3D11_UpdateClipRect(SDL_Renderer * renderer);
static int D3D11_RenderClear(SDL_Renderer * renderer);
static int D3D11_RenderDrawPoints(SDL_Renderer * renderer,
                                  const SDL_FPoint * points, int count);
static int D3D11_RenderDrawLines(SDL_Renderer * renderer,
                                 const SDL_FPoint * points, int count);
static int D3D11_RenderFillRects(SDL_Renderer * renderer,
                                 const SDL_FRect * rects, int count);
static int D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
                            const SDL_Rect * srcrect, const SDL_FRect * dstrect);
static int D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
                              const SDL_Rect * srcrect, const SDL_FRect * dstrect,
                              const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
static int D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
                                  Uint32 format, void * pixels, int pitch);
static void D3D11_RenderPresent(SDL_Renderer * renderer);
static void D3D11_DestroyTexture(SDL_Renderer * renderer,
                                 SDL_Texture * texture);
static void D3D11_DestroyRenderer(SDL_Renderer * renderer);
/* Direct3D 11.1 Internal Functions */
static HRESULT D3D11_CreateDeviceResources(SDL_Renderer * renderer);
static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer);
static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer);
static HRESULT D3D11_HandleDeviceLost(SDL_Renderer * renderer);
static void D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer);
SDL_RenderDriver D3D11_RenderDriver = {
    D3D11_CreateRenderer,
    {
        "direct3d11",
        (
            SDL_RENDERER_ACCELERATED |
            SDL_RENDERER_PRESENTVSYNC |
            SDL_RENDERER_TARGETTEXTURE
        ),                          /* flags.  see SDL_RendererFlags */
        4,                          /* num_texture_formats */
        {                           /* texture_formats */
            SDL_PIXELFORMAT_ARGB8888,
            SDL_PIXELFORMAT_RGB888,
            SDL_PIXELFORMAT_YV12,
            SDL_PIXELFORMAT_IYUV
        },
        0,                          /* max_texture_width: will be filled in later */
        0                           /* max_texture_height: will be filled in later */
    }
};
static Uint32
DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) {
    switch (dxgiFormat) {
        case DXGI_FORMAT_B8G8R8A8_UNORM:
            return SDL_PIXELFORMAT_ARGB8888;
        case DXGI_FORMAT_B8G8R8X8_UNORM:
            return SDL_PIXELFORMAT_RGB888;
        default:
            return SDL_PIXELFORMAT_UNKNOWN;
    }
}
static DXGI_FORMAT
SDLPixelFormatToDXGIFormat(Uint32 sdlFormat)
{
    switch (sdlFormat) {
        case SDL_PIXELFORMAT_ARGB8888:
            return DXGI_FORMAT_B8G8R8A8_UNORM;
        case SDL_PIXELFORMAT_RGB888:
            return DXGI_FORMAT_B8G8R8X8_UNORM;
        case SDL_PIXELFORMAT_YV12:
        case SDL_PIXELFORMAT_IYUV:
            return DXGI_FORMAT_R8_UNORM;
        default:
            return DXGI_FORMAT_UNKNOWN;
    }
}
SDL_Renderer *
D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
{
    SDL_Renderer *renderer;
    D3D11_RenderData *data;
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
    if (!renderer) {
        SDL_OutOfMemory();
        return NULL;
    }
    data = (D3D11_RenderData *) SDL_calloc(1, sizeof(*data));
    if (!data) {
        SDL_OutOfMemory();
        return NULL;
    }
    renderer->WindowEvent = D3D11_WindowEvent;
    renderer->CreateTexture = D3D11_CreateTexture;
    renderer->UpdateTexture = D3D11_UpdateTexture;
    renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
    renderer->LockTexture = D3D11_LockTexture;
    renderer->UnlockTexture = D3D11_UnlockTexture;
    renderer->SetRenderTarget = D3D11_SetRenderTarget;
    renderer->UpdateViewport = D3D11_UpdateViewport;
    renderer->UpdateClipRect = D3D11_UpdateClipRect;
    renderer->RenderClear = D3D11_RenderClear;
    renderer->RenderDrawPoints = D3D11_RenderDrawPoints;
    renderer->RenderDrawLines = D3D11_RenderDrawLines;
    renderer->RenderFillRects = D3D11_RenderFillRects;
    renderer->RenderCopy = D3D11_RenderCopy;
    renderer->RenderCopyEx = D3D11_RenderCopyEx;
    renderer->RenderReadPixels = D3D11_RenderReadPixels;
    renderer->RenderPresent = D3D11_RenderPresent;
    renderer->DestroyTexture = D3D11_DestroyTexture;
    renderer->DestroyRenderer = D3D11_DestroyRenderer;
    renderer->info = D3D11_RenderDriver.info;
    renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
    renderer->driverdata = data;
    if ((flags & SDL_RENDERER_PRESENTVSYNC)) {
        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
    }
    /* HACK: make sure the SDL_Renderer references the SDL_Window data now, in
     * order to give init functions access to the underlying window handle:
     */
    renderer->window = window;
    /* Initialize Direct3D resources */
    if (FAILED(D3D11_CreateDeviceResources(renderer))) {
        D3D11_DestroyRenderer(renderer);
        return NULL;
    }
    if (FAILED(D3D11_CreateWindowSizeDependentResources(renderer))) {
        D3D11_DestroyRenderer(renderer);
        return NULL;
    }
    return renderer;
}
static void
D3D11_DestroyRenderer(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    if (data) {
        SAFE_RELEASE(data->dxgiFactory);
        SAFE_RELEASE(data->dxgiAdapter);
        SAFE_RELEASE(data->d3dDevice);
        SAFE_RELEASE(data->d3dContext);
        SAFE_RELEASE(data->swapChain);
        SAFE_RELEASE(data->mainRenderTargetView);
        SAFE_RELEASE(data->currentOffscreenRenderTargetView);
        SAFE_RELEASE(data->inputLayout);
        SAFE_RELEASE(data->vertexBuffer);
        SAFE_RELEASE(data->vertexShader);
        SAFE_RELEASE(data->colorPixelShader);
        SAFE_RELEASE(data->texturePixelShader);
        SAFE_RELEASE(data->yuvPixelShader);
        SAFE_RELEASE(data->blendModeBlend);
        SAFE_RELEASE(data->blendModeAdd);
        SAFE_RELEASE(data->blendModeMod);
        SAFE_RELEASE(data->nearestPixelSampler);
        SAFE_RELEASE(data->linearSampler);
        SAFE_RELEASE(data->mainRasterizer);
        SAFE_RELEASE(data->clippedRasterizer);
        SAFE_RELEASE(data->vertexShaderConstants);
        if (data->hD3D11Mod) {
            SDL_UnloadObject(data->hD3D11Mod);
        }
        if (data->hDXGIMod) {
            SDL_UnloadObject(data->hDXGIMod);
        }
        SDL_free(data);
    }
    SDL_free(renderer);
}
static HRESULT
D3D11_CreateBlendMode(SDL_Renderer * renderer,
                      BOOL enableBlending,
                      D3D11_BLEND srcBlend,
                      D3D11_BLEND destBlend,
                      D3D11_BLEND srcBlendAlpha,
                      D3D11_BLEND destBlendAlpha,
                      ID3D11BlendState ** blendStateOutput)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    HRESULT result = S_OK;
    D3D11_BLEND_DESC blendDesc;
    SDL_zero(blendDesc);
    blendDesc.AlphaToCoverageEnable = FALSE;
    blendDesc.IndependentBlendEnable = FALSE;
    blendDesc.RenderTarget[0].BlendEnable = enableBlending;
    blendDesc.RenderTarget[0].SrcBlend = srcBlend;
    blendDesc.RenderTarget[0].DestBlend = destBlend;
    blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
    blendDesc.RenderTarget[0].SrcBlendAlpha = srcBlendAlpha;
    blendDesc.RenderTarget[0].DestBlendAlpha = destBlendAlpha;
    blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
    blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
    result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, blendStateOutput);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBlendState", result);
        return result;
    }
    return S_OK;
}
/* Create resources that depend on the device. */
static HRESULT
D3D11_CreateDeviceResources(SDL_Renderer * renderer)
{
    typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
    PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc;
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc;
    IDXGIAdapter *d3dAdapter = NULL;
    ID3D11Device *d3dDevice = NULL;
    ID3D11DeviceContext *d3dContext = NULL;
    IDXGIDevice1 *dxgiDevice = NULL;
    HRESULT result = S_OK;
    UINT creationFlags;
    const char *hint;
    /* This array defines the set of DirectX hardware feature levels this app will support.
     * Note the ordering should be preserved.
     * Don't forget to declare your application's minimum required feature level in its
     * description.  All applications are assumed to support 9.1 unless otherwise stated.
     */
    D3D_FEATURE_LEVEL featureLevels[] =
    {
        D3D_FEATURE_LEVEL_11_1,
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0,
        D3D_FEATURE_LEVEL_9_3,
        D3D_FEATURE_LEVEL_9_2,
        D3D_FEATURE_LEVEL_9_1
    };
    /* Declare how the input layout for SDL's vertex shader will be setup: */
    const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
    {
        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    };
    D3D11_BUFFER_DESC constantBufferDesc;
    D3D11_SAMPLER_DESC samplerDesc;
    D3D11_RASTERIZER_DESC rasterDesc;
#ifdef __WINRT__
    CreateDXGIFactoryFunc = CreateDXGIFactory1;
    D3D11CreateDeviceFunc = D3D11CreateDevice;
#else
    data->hDXGIMod = SDL_LoadObject("dxgi.dll");
    if (!data->hDXGIMod) {
        result = E_FAIL;
        goto done;
    }
    CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory");
    if (!CreateDXGIFactoryFunc) {
        result = E_FAIL;
        goto done;
    }
    data->hD3D11Mod = SDL_LoadObject("d3d11.dll");
    if (!data->hD3D11Mod) {
        result = E_FAIL;
        goto done;
    }
    D3D11CreateDeviceFunc = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction(data->hD3D11Mod, "D3D11CreateDevice");
    if (!D3D11CreateDeviceFunc) {
        result = E_FAIL;
        goto done;
    }
#endif /* __WINRT__ */
    result = CreateDXGIFactoryFunc(&IID_IDXGIFactory2, &data->dxgiFactory);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory", result);
        goto done;
    }
    /* FIXME: Should we use the default adapter? */
    result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", D3D11CreateDevice", result);
        goto done;
    }
    /* This flag adds support for surfaces with a different color channel ordering
     * than the API default. It is required for compatibility with Direct2D.
     */
    creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
    /* Make sure Direct3D's debugging feature gets used, if the app requests it. */
    hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG);
    if (hint && SDL_atoi(hint) > 0) {
        creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    }
    /* Create the Direct3D 11 API device object and a corresponding context. */
    result = D3D11CreateDeviceFunc(
        data->dxgiAdapter,
        D3D_DRIVER_TYPE_UNKNOWN,
        NULL,
        creationFlags, /* Set set debug and Direct2D compatibility flags. */
        featureLevels, /* List of feature levels this app can support. */
        SDL_arraysize(featureLevels),
        D3D11_SDK_VERSION, /* Always set this to D3D11_SDK_VERSION for Windows Store apps. */
        &d3dDevice, /* Returns the Direct3D device created. */
        &data->featureLevel, /* Returns feature level of device created. */
        &d3dContext /* Returns the device immediate context. */
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", D3D11CreateDevice", result);
        goto done;
    }
    result = ID3D11Device_QueryInterface(d3dDevice, &IID_ID3D11Device1, &data->d3dDevice);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to ID3D11Device1", result);
        goto done;
    }
    result = ID3D11DeviceContext_QueryInterface(d3dContext, &IID_ID3D11DeviceContext1, &data->d3dContext);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext to ID3D11DeviceContext1", result);
        goto done;
    }
    result = ID3D11Device_QueryInterface(d3dDevice, &IID_IDXGIDevice1, &dxgiDevice);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice1", result);
        goto done;
    }
    /* Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and
     * ensures that the application will only render after each VSync, minimizing power consumption.
     */
    result = IDXGIDevice1_SetMaximumFrameLatency(dxgiDevice, 1);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIDevice1::SetMaximumFrameLatency", result);
        goto done;
    }
    /* Make note of the maximum texture size
     * Max texture sizes are documented on MSDN, at:
     * http://msdn.microsoft.com/en-us/library/windows/apps/ff476876.aspx
     */
    switch (data->featureLevel) {
        case D3D_FEATURE_LEVEL_11_1:
        case D3D_FEATURE_LEVEL_11_0:
            renderer->info.max_texture_width = renderer->info.max_texture_height = 16384;
            break;
        case D3D_FEATURE_LEVEL_10_1:
        case D3D_FEATURE_LEVEL_10_0:
            renderer->info.max_texture_width = renderer->info.max_texture_height = 8192;
            break;
        case D3D_FEATURE_LEVEL_9_3:
            renderer->info.max_texture_width = renderer->info.max_texture_height = 4096;
            break;
        case D3D_FEATURE_LEVEL_9_2:
        case D3D_FEATURE_LEVEL_9_1:
            renderer->info.max_texture_width = renderer->info.max_texture_height = 2048;
            break;
        default:
            SDL_SetError(__FUNCTION__ ", Unexpected feature level: %d", data->featureLevel);
            result = E_FAIL;
            goto done;
    }
    /* Load in SDL's one and only vertex shader: */
    result = ID3D11Device_CreateVertexShader(data->d3dDevice,
        D3D11_VertexShader,
        sizeof(D3D11_VertexShader),
        NULL,
        &data->vertexShader
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateVertexShader", result);
        goto done;
    }
    /* Create an input layout for SDL's vertex shader: */
    result = ID3D11Device_CreateInputLayout(data->d3dDevice,
        vertexDesc,
        ARRAYSIZE(vertexDesc),
        D3D11_VertexShader,
        sizeof(D3D11_VertexShader),
        &data->inputLayout
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateInputLayout", result);
        goto done;
    }
    /* Load in SDL's pixel shaders */
    result = ID3D11Device_CreatePixelShader(data->d3dDevice,
        D3D11_PixelShader_Colors,
        sizeof(D3D11_PixelShader_Colors),
        NULL,
        &data->colorPixelShader
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['color' shader]", result);
        goto done;
    }
    result = ID3D11Device_CreatePixelShader(data->d3dDevice,
        D3D11_PixelShader_Textures,
        sizeof(D3D11_PixelShader_Textures),
        NULL,
        &data->texturePixelShader
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['textures' shader]", result);
        goto done;
    }
    result = ID3D11Device_CreatePixelShader(data->d3dDevice,
        D3D11_PixelShader_YUV,
        sizeof(D3D11_PixelShader_YUV),
        NULL,
        &data->yuvPixelShader
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['yuv' shader]", result);
        goto done;
    }
    /* Setup space to hold vertex shader constants: */
    SDL_zero(constantBufferDesc);
    constantBufferDesc.ByteWidth = sizeof(VertexShaderConstants);
    constantBufferDesc.Usage = D3D11_USAGE_DEFAULT;
    constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    result = ID3D11Device_CreateBuffer(data->d3dDevice,
        &constantBufferDesc,
        NULL,
        &data->vertexShaderConstants
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBuffer [vertex shader constants]", result);
        goto done;
    }
    /* Create samplers to use when drawing textures: */
    SDL_zero(samplerDesc);
    samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
    samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
    samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
    samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
    samplerDesc.MipLODBias = 0.0f;
    samplerDesc.MaxAnisotropy = 1;
    samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    samplerDesc.MinLOD = 0.0f;
    samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
    result = ID3D11Device_CreateSamplerState(data->d3dDevice,
        &samplerDesc,
        &data->nearestPixelSampler
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateSamplerState [nearest-pixel filter]", result);
        goto done;
    }
    samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    result = ID3D11Device_CreateSamplerState(data->d3dDevice,
        &samplerDesc,
        &data->linearSampler
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateSamplerState [linear filter]", result);
        goto done;
    }
    /* Setup Direct3D rasterizer states */
    SDL_zero(rasterDesc);
    rasterDesc.AntialiasedLineEnable = FALSE;
    rasterDesc.CullMode = D3D11_CULL_NONE;
    rasterDesc.DepthBias = 0;
    rasterDesc.DepthBiasClamp = 0.0f;
    rasterDesc.DepthClipEnable = TRUE;
    rasterDesc.FillMode = D3D11_FILL_SOLID;
    rasterDesc.FrontCounterClockwise = FALSE;
    rasterDesc.MultisampleEnable = FALSE;
    rasterDesc.ScissorEnable = FALSE;
    rasterDesc.SlopeScaledDepthBias = 0.0f;
    result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->mainRasterizer);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [main rasterizer]", result);
        goto done;
    }
    rasterDesc.ScissorEnable = TRUE;
    result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->clippedRasterizer);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [clipped rasterizer]", result);
        goto done;
    }
    /* Create blending states: */
    result = D3D11_CreateBlendMode(
        renderer,
        TRUE,
        D3D11_BLEND_SRC_ALPHA,          /* srcBlend */
        D3D11_BLEND_INV_SRC_ALPHA,      /* destBlend */
        D3D11_BLEND_ONE,                /* srcBlendAlpha */
        D3D11_BLEND_INV_SRC_ALPHA,      /* destBlendAlpha */
        &data->blendModeBlend);
    if (FAILED(result)) {
        /* D3D11_CreateBlendMode will set the SDL error, if it fails */
        goto done;
    }
    result = D3D11_CreateBlendMode(
        renderer,
        TRUE,
        D3D11_BLEND_SRC_ALPHA,          /* srcBlend */
        D3D11_BLEND_ONE,                /* destBlend */
        D3D11_BLEND_ZERO,               /* srcBlendAlpha */
        D3D11_BLEND_ONE,                /* destBlendAlpha */
        &data->blendModeAdd);
    if (FAILED(result)) {
        /* D3D11_CreateBlendMode will set the SDL error, if it fails */
        goto done;
    }
    result = D3D11_CreateBlendMode(
        renderer,
        TRUE,
        D3D11_BLEND_ZERO,               /* srcBlend */
        D3D11_BLEND_SRC_COLOR,          /* destBlend */
        D3D11_BLEND_ZERO,               /* srcBlendAlpha */
        D3D11_BLEND_ONE,                /* destBlendAlpha */
        &data->blendModeMod);
    if (FAILED(result)) {
        /* D3D11_CreateBlendMode will set the SDL error, if it fails */
        goto done;
    }
    /* Setup render state that doesn't change */
    ID3D11DeviceContext_IASetInputLayout(data->d3dContext, data->inputLayout);
    ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0);
    ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants);
done:
    SAFE_RELEASE(d3dDevice);
    SAFE_RELEASE(d3dContext);
    SAFE_RELEASE(dxgiDevice);
    return result;
}
#ifdef __WIN32__
static DXGI_MODE_ROTATION
D3D11_GetCurrentRotation()
{
    /* FIXME */
    return DXGI_MODE_ROTATION_IDENTITY;
}
#endif /* __WIN32__ */
static BOOL
D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
{
    switch (rotation) {
        case DXGI_MODE_ROTATION_ROTATE90:
        case DXGI_MODE_ROTATION_ROTATE270:
            return TRUE;
        default:
            return FALSE;
    }
}
static int
D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    switch (data->rotation) {
        case DXGI_MODE_ROTATION_IDENTITY:
            outRect->left = sdlRect->x;
            outRect->right = sdlRect->x + sdlRect->w;
            outRect->top = sdlRect->y;
            outRect->bottom = sdlRect->y + sdlRect->h;
            break;
        case DXGI_MODE_ROTATION_ROTATE270:
            outRect->left = sdlRect->y;
            outRect->right = sdlRect->y + sdlRect->h;
            outRect->top = renderer->viewport.w - sdlRect->x - sdlRect->w;
            outRect->bottom = renderer->viewport.w - sdlRect->x;
            break;
        case DXGI_MODE_ROTATION_ROTATE180:
            outRect->left = renderer->viewport.w - sdlRect->x - sdlRect->w;
            outRect->right = renderer->viewport.w - sdlRect->x;
            outRect->top = renderer->viewport.h - sdlRect->y - sdlRect->h;
            outRect->bottom = renderer->viewport.h - sdlRect->y;
            break;
        case DXGI_MODE_ROTATION_ROTATE90:
            outRect->left = renderer->viewport.h - sdlRect->y - sdlRect->h;
            outRect->right = renderer->viewport.h - sdlRect->y;
            outRect->top = sdlRect->x;
            outRect->bottom = sdlRect->x + sdlRect->h;
            break;
        default:
            return SDL_SetError("The physical display is in an unknown or unsupported rotation");
    }
    return 0;
}
static HRESULT
D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
{
    D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
#ifdef __WINRT__
    IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer);
    const BOOL usingXAML = (coreWindow == NULL);
#else
    IUnknown *coreWindow = NULL;
    const BOOL usingXAML = FALSE;
#endif
    HRESULT result = S_OK;
    /* Create a swap chain using the same adapter as the existing Direct3D device. */
    DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
    SDL_zero(swapChainDesc);
    swapChainDesc.Width = w;
    swapChainDesc.Height = h;
    swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */
    swapChainDesc.Stereo = FALSE;
    swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */
    swapChainDesc.SampleDesc.Quality = 0;
    swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */
    swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */
#else
    if (usingXAML) {
        swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
    } else {
        swapChainDesc.Scaling = DXGI_SCALING_NONE;
    }
    swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; /* All Windows Store apps must use this SwapEffect. */
#endif
    swapChainDesc.Flags = 0;
    if (coreWindow) {
        result = IDXGIFactory2_CreateSwapChainForCoreWindow(data->dxgiFactory,
            (IUnknown *)data->d3dDevice,
            coreWindow,
            &swapChainDesc,
            NULL, /* Allow on all displays. */
            &data->swapChain
            );
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForCoreWindow", result);
            goto done;
        }
    } else if (usingXAML) {
        result = IDXGIFactory2_CreateSwapChainForComposition(data->dxgiFactory,
            (IUnknown *)data->d3dDevice,
            &swapChainDesc,
            NULL,
            &data->swapChain);
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForComposition", result);
            goto done;
        }
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
        result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *) data->swapChain);
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", ISwapChainBackgroundPanelNative::SetSwapChain", result);
            goto done;
        }
#else
        SDL_SetError(__FUNCTION__ ", XAML support is not yet available for Windows Phone");
        result = E_FAIL;
        goto done;
#endif
    } else {
#ifdef __WIN32__
        SDL_SysWMinfo windowinfo;
        SDL_VERSION(&windowinfo.version);
        SDL_GetWindowWMInfo(renderer->window, &windowinfo);
        result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory,
            (IUnknown *)data->d3dDevice,
            windowinfo.info.win.window,
            &swapChainDesc,
            NULL,
            NULL, /* Allow on all displays. */
            &data->swapChain
            );
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForHwnd", result);
            goto done;
        }
#else
        SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to");
        goto done;
#endif  /* ifdef __WIN32__ / else */
    }
    data->swapEffect = swapChainDesc.SwapEffect;
done:
    SAFE_RELEASE(coreWindow);
    return result;
}
/* Initialize all resources that change when the window's size changes. */
static HRESULT
D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
    ID3D11Texture2D *backBuffer = NULL;
    HRESULT result = S_OK;
    int w, h;
    /* Release the previous render target view */
    D3D11_ReleaseMainRenderTargetView(renderer);
    /* The width and height of the swap chain must be based on the display's
     * non-rotated size.
     */
    SDL_GetWindowSize(renderer->window, &w, &h);
    data->rotation = D3D11_GetCurrentRotation();
    if (D3D11_IsDisplayRotated90Degrees(data->rotation)) {
        int tmp = w;
        w = h;
        h = tmp;
    }
    if (data->swapChain) {
        /* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */
#if !defined(__WINRT__) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP)
        /* If the swap chain already exists, resize it. */
        result = IDXGISwapChain_ResizeBuffers(data->swapChain,
            0,
            w, h,
            DXGI_FORMAT_UNKNOWN,
            0
            );
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::ResizeBuffers", result);
            goto done;
        }
#endif
    } else {
        result = D3D11_CreateSwapChain(renderer, w, h);
        if (FAILED(result)) {
            goto done;
        }
    }
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
    /* Set the proper rotation for the swap chain, and generate the
     * 3D matrix transformation for rendering to the rotated swap chain.
     *
     * To note, the call for this, IDXGISwapChain1::SetRotation, is not necessary
     * on Windows Phone, nor is it supported there.  It's only needed in Windows 8/RT.
     */
    if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) {
        result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation);
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain1::SetRotation", result);
            goto done;
        }
    }
#endif
    result = IDXGISwapChain_GetBuffer(data->swapChain,
        0,
        &IID_ID3D11Texture2D,
        &backBuffer
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::GetBuffer [back-buffer]", result);
        goto done;
    }
    /* Create a render target view of the swap chain back buffer. */
    result = ID3D11Device_CreateRenderTargetView(data->d3dDevice,
        (ID3D11Resource *)backBuffer,
        NULL,
        &data->mainRenderTargetView
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device::CreateRenderTargetView", result);
        goto done;
    }
    if (D3D11_UpdateViewport(renderer) != 0) {
        /* D3D11_UpdateViewport will set the SDL error if it fails. */
        result = E_FAIL;
        goto done;
    }
done:
    SAFE_RELEASE(backBuffer);
    return result;
}
/* This method is called when the window's size changes. */
static HRESULT
D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
    return D3D11_CreateWindowSizeDependentResources(renderer);
}
HRESULT
D3D11_HandleDeviceLost(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    HRESULT result = S_OK;
    /* FIXME: Need to release all resources - all textures are invalid! */
    result = D3D11_CreateDeviceResources(renderer);
    if (FAILED(result)) {
        /* D3D11_CreateDeviceResources will set the SDL error */
        return result;
    }
    result = D3D11_UpdateForWindowSizeChange(renderer);
    if (FAILED(result)) {
        /* D3D11_UpdateForWindowSizeChange will set the SDL error */
        return result;
    }
    return S_OK;
}
static void
D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
{
    if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
        D3D11_UpdateForWindowSizeChange(renderer);
    }
}
static D3D11_FILTER
GetScaleQuality(void)
{
    const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
    if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) {
        return D3D11_FILTER_MIN_MAG_MIP_POINT;
    } else /* if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) */ {
        return D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    }
}
static int
D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_TextureData *textureData;
    HRESULT result;
    DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format);
    D3D11_TEXTURE2D_DESC textureDesc;
    D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
    if (textureFormat == SDL_PIXELFORMAT_UNKNOWN) {
        return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified",
            __FUNCTION__, texture->format);
    }
    textureData = (D3D11_TextureData*) SDL_calloc(1, sizeof(*textureData));
    if (!textureData) {
        SDL_OutOfMemory();
        return -1;
    }
    textureData->scaleMode = GetScaleQuality();
    texture->driverdata = textureData;
    SDL_zero(textureDesc);
    textureDesc.Width = texture->w;
    textureDesc.Height = texture->h;
    textureDesc.MipLevels = 1;
    textureDesc.ArraySize = 1;
    textureDesc.Format = textureFormat;
    textureDesc.SampleDesc.Count = 1;
    textureDesc.SampleDesc.Quality = 0;
    textureDesc.MiscFlags = 0;
    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
        textureDesc.Usage = D3D11_USAGE_DYNAMIC;
        textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    } else {
        textureDesc.Usage = D3D11_USAGE_DEFAULT;
        textureDesc.CPUAccessFlags = 0;
    }
    if (texture->access == SDL_TEXTUREACCESS_TARGET) {
        textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
    } else {
        textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
    }
    result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
        &textureDesc,
        NULL,
        &textureData->mainTexture
        );
    if (FAILED(result)) {
        D3D11_DestroyTexture(renderer, texture);
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result);
        return -1;
    }
    if (texture->format == SDL_PIXELFORMAT_YV12 ||
        texture->format == SDL_PIXELFORMAT_IYUV) {
        textureData->yuv = SDL_TRUE;
        textureDesc.Width /= 2;
        textureDesc.Height /= 2;
        result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
            &textureDesc,
            NULL,
            &textureData->mainTextureU
            );
        if (FAILED(result)) {
            D3D11_DestroyTexture(renderer, texture);
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result);
            return -1;
        }
        result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
            &textureDesc,
            NULL,
            &textureData->mainTextureV
            );
        if (FAILED(result)) {
            D3D11_DestroyTexture(renderer, texture);
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result);
            return -1;
        }
    }
    resourceViewDesc.Format = textureDesc.Format;
    resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    resourceViewDesc.Texture2D.MostDetailedMip = 0;
    resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
    result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
        (ID3D11Resource *)textureData->mainTexture,
        &resourceViewDesc,
        &textureData->mainTextureResourceView
        );
    if (FAILED(result)) {
        D3D11_DestroyTexture(renderer, texture);
        WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result);
        return -1;
    }
    if (textureData->yuv) {
        result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
            (ID3D11Resource *)textureData->mainTextureU,
            &resourceViewDesc,
            &textureData->mainTextureResourceViewU
            );
        if (FAILED(result)) {
            D3D11_DestroyTexture(renderer, texture);
            WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result);
            return -1;
        }
        result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
            (ID3D11Resource *)textureData->mainTextureV,
            &resourceViewDesc,
            &textureData->mainTextureResourceViewV
            );
        if (FAILED(result)) {
            D3D11_DestroyTexture(renderer, texture);
            WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result);
            return -1;
        }
    }
    if (texture->access & SDL_TEXTUREACCESS_TARGET) {
        D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
        renderTargetViewDesc.Format = textureDesc.Format;
        renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
        renderTargetViewDesc.Texture2D.MipSlice = 0;
        result = ID3D11Device_CreateRenderTargetView(rendererData->d3dDevice,
            (ID3D11Resource *)textureData->mainTexture,
            &renderTargetViewDesc,
            &textureData->mainTextureRenderTargetView);
        if (FAILED(result)) {
            D3D11_DestroyTexture(renderer, texture);
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRenderTargetView", result);
            return -1;
        }
    }
    return 0;
}
static void
D3D11_DestroyTexture(SDL_Renderer * renderer,
                     SDL_Texture * texture)
{
    D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata;
    if (!data) {
        return;
    }
    SAFE_RELEASE(data->mainTexture);
    SAFE_RELEASE(data->mainTextureResourceView);
    SAFE_RELEASE(data->mainTextureRenderTargetView);
    SAFE_RELEASE(data->stagingTexture);
    SAFE_RELEASE(data->mainTextureU);
    SAFE_RELEASE(data->mainTextureResourceViewU);
    SAFE_RELEASE(data->mainTextureV);
    SAFE_RELEASE(data->mainTextureResourceViewV);
    SDL_free(data->pixels);
    SDL_free(data);
    texture->driverdata = NULL;
}
static int
D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, Uint32 format, int x, int y, int w, int h, const void *pixels, int pitch)
{
    ID3D11Texture2D *stagingTexture;
    const Uint8 *src;
    Uint8 *dst;
    int row;
    UINT length;
    HRESULT result;
    D3D11_TEXTURE2D_DESC stagingTextureDesc;
    D3D11_MAPPED_SUBRESOURCE textureMemory;
    /* Create a 'staging' texture, which will be used to write to a portion of the main texture. */
    ID3D11Texture2D_GetDesc(texture, &stagingTextureDesc);
    stagingTextureDesc.Width = w;
    stagingTextureDesc.Height = h;
    stagingTextureDesc.BindFlags = 0;
    stagingTextureDesc.MiscFlags = 0;
    stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    stagingTextureDesc.Usage = D3D11_USAGE_STAGING;
    result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
        &stagingTextureDesc,
        NULL,
        &stagingTexture);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result);
        return -1;
    }
    /* Get a write-only pointer to data in the staging texture: */
    result = ID3D11DeviceContext_Map(rendererData->d3dContext,
        (ID3D11Resource *)stagingTexture,
        0,
        D3D11_MAP_WRITE,
        0,
        &textureMemory
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result);
        SAFE_RELEASE(stagingTexture);
        return -1;
    }
    src = (const Uint8 *)pixels;
    dst = textureMemory.pData;
    length = w * SDL_BYTESPERPIXEL(format);
    if (length == pitch && length == textureMemory.RowPitch) {
        SDL_memcpy(dst, src, length*h);
    } else {
        if (length > (UINT)pitch) {
            length = pitch;
        }
        if (length > textureMemory.RowPitch) {
            length = textureMemory.RowPitch;
        }
        for (row = 0; row < h; ++row) {
            SDL_memcpy(dst, src, length);
            src += pitch;
            dst += textureMemory.RowPitch;
        }
    }
    /* Commit the pixel buffer's changes back to the staging texture: */
    ID3D11DeviceContext_Unmap(rendererData->d3dContext,
        (ID3D11Resource *)stagingTexture,
        0);
    /* Copy the staging texture's contents back to the texture: */
    ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext,
        (ID3D11Resource *)texture,
        0,
        x,
        y,
        0,
        (ID3D11Resource *)stagingTexture,
        0,
        NULL);
    SAFE_RELEASE(stagingTexture);
    return 0;
}
static int
D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                    const SDL_Rect * rect, const void * srcPixels,
                    int srcPitch)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
    D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
    if (!textureData) {
        SDL_SetError("Texture is not currently available");
        return -1;
    }
    if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, texture->format, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) {
        return -1;
    }
    if (textureData->yuv) {
        /* Skip to the correct offset into the next texture */
        srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch);
        if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, srcPixels, srcPitch / 2) < 0) {
            return -1;
        }
        /* Skip to the correct offset into the next texture */
        srcPixels = (const void*)((const Uint8*)srcPixels + (rect->h * srcPitch) / 4);
        if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, srcPixels, srcPitch / 2) < 0) {
            return -1;
        }
    }
    return 0;
}
static int
D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
                       const SDL_Rect * rect,
                       const Uint8 *Yplane, int Ypitch,
                       const Uint8 *Uplane, int Upitch,
                       const Uint8 *Vplane, int Vpitch)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
    D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
    if (!textureData) {
        SDL_SetError("Texture is not currently available");
        return -1;
    }
    if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, texture->format, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
        return -1;
    }
    if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) {
        return -1;
    }
    if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) {
        return -1;
    }
    return 0;
}
static int
D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                  const SDL_Rect * rect, void **pixels, int *pitch)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
    HRESULT result = S_OK;
    D3D11_TEXTURE2D_DESC stagingTextureDesc;
    D3D11_MAPPED_SUBRESOURCE textureMemory;
    if (!textureData) {
        SDL_SetError("Texture is not currently available");
        return -1;
    }
    if (textureData->yuv) {
        /* It's more efficient to upload directly... */
        if (!textureData->pixels) {
            textureData->pitch = texture->w;
            textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2);
            if (!textureData->pixels) {
                return SDL_OutOfMemory();
            }
        }
        textureData->locked_rect = *rect;
        *pixels =
            (void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch +
            rect->x * SDL_BYTESPERPIXEL(texture->format));
        *pitch = textureData->pitch;
        return 0;
    }
    if (textureData->stagingTexture) {
        return SDL_SetError("texture is already locked");
    }
    /* Create a 'staging' texture, which will be used to write to a portion
     * of the main texture.  This is necessary, as Direct3D 11.1 does not
     * have the ability to write a CPU-bound pixel buffer to a rectangular
     * subrect of a texture.  Direct3D 11.1 can, however, write a pixel
     * buffer to an entire texture, hence the use of a staging texture.
     *
     * TODO, WinRT: consider avoiding the use of a staging texture in D3D11_LockTexture if/when the entire texture is being updated
     */
    ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc);
    stagingTextureDesc.Width = rect->w;
    stagingTextureDesc.Height = rect->h;
    stagingTextureDesc.BindFlags = 0;
    stagingTextureDesc.MiscFlags = 0;
    stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    stagingTextureDesc.Usage = D3D11_USAGE_STAGING;
    result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
        &stagingTextureDesc,
        NULL,
        &textureData->stagingTexture);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result);
        return -1;
    }
    /* Get a write-only pointer to data in the staging texture: */
    result = ID3D11DeviceContext_Map(rendererData->d3dContext,
        (ID3D11Resource *)textureData->stagingTexture,
        0,
        D3D11_MAP_WRITE,
        0,
        &textureMemory
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result);
        SAFE_RELEASE(textureData->stagingTexture);
        return -1;
    }
    /* Make note of where the staging texture will be written to
     * (on a call to SDL_UnlockTexture):
     */
    textureData->lockedTexturePositionX = rect->x;
    textureData->lockedTexturePositionY = rect->y;
    /* Make sure the caller has information on the texture's pixel buffer,
     * then return:
     */
    *pixels = textureMemory.pData;
    *pitch = textureMemory.RowPitch;
    return 0;
}
static void
D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
    if (!textureData) {
        return;
    }
    if (textureData->yuv) {
        const SDL_Rect *rect = &textureData->locked_rect;
        void *pixels =
            (void *) ((Uint8 *) textureData->pixels + rect->y * textureData->pitch +
                      rect->x * SDL_BYTESPERPIXEL(texture->format));
        D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch);
        return;
    }
    /* Commit the pixel buffer's changes back to the staging texture: */
    ID3D11DeviceContext_Unmap(rendererData->d3dContext,
        (ID3D11Resource *)textureData->stagingTexture,
        0);
    /* Copy the staging texture's contents back to the main texture: */
    ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext,
        (ID3D11Resource *)textureData->mainTexture,
        0,
        textureData->lockedTexturePositionX,
        textureData->lockedTexturePositionY,
        0,
        (ID3D11Resource *)textureData->stagingTexture,
        0,
        NULL);
    SAFE_RELEASE(textureData->stagingTexture);
}
static int
D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_TextureData *textureData = NULL;
    if (texture == NULL) {
        rendererData->currentOffscreenRenderTargetView = NULL;
        return 0;
    }
    textureData = (D3D11_TextureData *) texture->driverdata;
    if (!textureData->mainTextureRenderTargetView) {
        return SDL_SetError("specified texture is not a render target");
    }
    rendererData->currentOffscreenRenderTargetView = textureData->mainTextureRenderTargetView;
    return 0;
}
static void
D3D11_SetModelMatrix(SDL_Renderer *renderer, const Float4X4 *matrix)
{
    D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
    if (matrix) {
        data->vertexShaderConstantsData.model = *matrix;
    } else {
        data->vertexShaderConstantsData.model = MatrixIdentity();
    }
    ID3D11DeviceContext_UpdateSubresource(data->d3dContext,
        (ID3D11Resource *)data->vertexShaderConstants,
        0,
        NULL,
        &data->vertexShaderConstantsData,
        0,
        0
        );
}
static int
D3D11_UpdateViewport(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    Float4X4 projection;
    Float4X4 view;
    SDL_FRect orientationAlignedViewport;
    BOOL swapDimensions;
    D3D11_VIEWPORT viewport;
    if (renderer->viewport.w == 0 || renderer->viewport.h == 0) {
        /* If the viewport is empty, assume that it is because
         * SDL_CreateRenderer is calling it, and will call it again later
         * with a non-empty viewport.
         */
        return 0;
    }
    /* Make sure the SDL viewport gets rotated to that of the physical display's rotation.
     * Keep in mind here that the Y-axis will be been inverted (from Direct3D's
     * default coordinate system) so rotations will be done in the opposite
     * direction of the DXGI_MODE_ROTATION enumeration.
     */
    switch (data->rotation) {
        case DXGI_MODE_ROTATION_IDENTITY:
            projection = MatrixIdentity();
            break;
        case DXGI_MODE_ROTATION_ROTATE270:
            projection = MatrixRotationZ(SDL_static_cast(float, M_PI * 0.5f));
            break;
        case DXGI_MODE_ROTATION_ROTATE180:
            projection = MatrixRotationZ(SDL_static_cast(float, M_PI));
            break;
        case DXGI_MODE_ROTATION_ROTATE90:
            projection = MatrixRotationZ(SDL_static_cast(float, -M_PI * 0.5f));
            break;
        default:
            return SDL_SetError("An unknown DisplayOrientation is being used");
    }
    /* Update the view matrix */
    view.m[0][0] = 2.0f / renderer->viewport.w;
    view.m[0][1] = 0.0f;
    view.m[0][2] = 0.0f;
    view.m[0][3] = 0.0f;
    view.m[1][0] = 0.0f;
    view.m[1][1] = -2.0f / renderer->viewport.h;
    view.m[1][2] = 0.0f;
    view.m[1][3] = 0.0f;
    view.m[2][0] = 0.0f;
    view.m[2][1] = 0.0f;
    view.m[2][2] = 1.0f;
    view.m[2][3] = 0.0f;
    view.m[3][0] = -1.0f;
    view.m[3][1] = 1.0f;
    view.m[3][2] = 0.0f;
    view.m[3][3] = 1.0f;
    /* Combine the projection + view matrix together now, as both only get
     * set here (as of this writing, on Dec 26, 2013).  When done, store it
     * for eventual transfer to the GPU.
     */
    data->vertexShaderConstantsData.projectionAndView = MatrixMultiply(
            view,
            projection);
    /* Reset the model matrix */
    D3D11_SetModelMatrix(renderer, NULL);
    /* Update the Direct3D viewport, which seems to be aligned to the
     * swap buffer's coordinate space, which is always in either
     * a landscape mode, for all Windows 8/RT devices, or a portrait mode,
     * for Windows Phone devices.
     */
    swapDimensions = D3D11_IsDisplayRotated90Degrees(data->rotation);
    if (swapDimensions) {
        orientationAlignedViewport.x = (float) renderer->viewport.y;
        orientationAlignedViewport.y = (float) renderer->viewport.x;
        orientationAlignedViewport.w = (float) renderer->viewport.h;
        orientationAlignedViewport.h = (float) renderer->viewport.w;
    } else {
        orientationAlignedViewport.x = (float) renderer->viewport.x;
        orientationAlignedViewport.y = (float) renderer->viewport.y;
        orientationAlignedViewport.w = (float) renderer->viewport.w;
        orientationAlignedViewport.h = (float) renderer->viewport.h;
    }
    /* TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) */
    viewport.TopLeftX = orientationAlignedViewport.x;
    viewport.TopLeftY = orientationAlignedViewport.y;
    viewport.Width = orientationAlignedViewport.w;
    viewport.Height = orientationAlignedViewport.h;
    viewport.MinDepth = 0.0f;
    viewport.MaxDepth = 1.0f;
    ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &viewport);
    return 0;
}
static int
D3D11_UpdateClipRect(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    const SDL_Rect *rect = &renderer->clip_rect;
    if (SDL_RectEmpty(rect)) {
        ID3D11DeviceContext_RSSetScissorRects(data->d3dContext, 0, NULL);
    } else {
        D3D11_RECT scissorRect;
        if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &scissorRect) != 0) {
            /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */
            return -1;
        }
        ID3D11DeviceContext_RSSetScissorRects(data->d3dContext, 1, &scissorRect);
    }
    return 0;
}
static void
D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
    ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, 0, NULL, NULL);
    SAFE_RELEASE(data->mainRenderTargetView);
}
static ID3D11RenderTargetView *
D3D11_GetCurrentRenderTargetView(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    if (data->currentOffscreenRenderTargetView) {
        return data->currentOffscreenRenderTargetView;
    } else {
        return data->mainRenderTargetView;
    }
}
static int
D3D11_RenderClear(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    const float colorRGBA[] = {
        (renderer->r / 255.0f),
        (renderer->g / 255.0f),
        (renderer->b / 255.0f),
        (renderer->a / 255.0f)
    };
    ID3D11DeviceContext_ClearRenderTargetView(data->d3dContext,
        D3D11_GetCurrentRenderTargetView(renderer),
        colorRGBA
        );
    return 0;
}
static int
D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
                         const void * vertexData, size_t dataSizeInBytes)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_BUFFER_DESC vertexBufferDesc;
    HRESULT result = S_OK;
    D3D11_SUBRESOURCE_DATA vertexBufferData;
    const UINT stride = sizeof(VertexPositionColor);
    const UINT offset = 0;
    if (rendererData->vertexBuffer) {
        ID3D11Buffer_GetDesc(rendererData->vertexBuffer, &vertexBufferDesc);
    } else {
        SDL_zero(vertexBufferDesc);
    }
    if (rendererData->vertexBuffer && vertexBufferDesc.ByteWidth >= dataSizeInBytes) {
        D3D11_MAPPED_SUBRESOURCE mappedResource;
        result = ID3D11DeviceContext_Map(rendererData->d3dContext,
            (ID3D11Resource *)rendererData->vertexBuffer,
            0,
            D3D11_MAP_WRITE_DISCARD,
            0,
            &mappedResource
            );
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [vertex buffer]", result);
            return -1;
        }
        SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes);
        ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexBuffer, 0);
    } else {
        SAFE_RELEASE(rendererData->vertexBuffer);
        vertexBufferDesc.ByteWidth = dataSizeInBytes;
        vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
        vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
        vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
        SDL_zero(vertexBufferData);
        vertexBufferData.pSysMem = vertexData;
        vertexBufferData.SysMemPitch = 0;
        vertexBufferData.SysMemSlicePitch = 0;
        result = ID3D11Device_CreateBuffer(rendererData->d3dDevice,
            &vertexBufferDesc,
            &vertexBufferData,
            &rendererData->vertexBuffer
            );
        if (FAILED(result)) {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBuffer [vertex buffer]", result);
            return -1;
        }
        ID3D11DeviceContext_IASetVertexBuffers(rendererData->d3dContext,
            0,
            1,
            &rendererData->vertexBuffer,
            &stride,
            &offset
            );
    }
    return 0;
}
static void
D3D11_RenderStartDrawOp(SDL_Renderer * renderer)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
    ID3D11RasterizerState *rasterizerState;
    ID3D11RenderTargetView *renderTargetView = D3D11_GetCurrentRenderTargetView(renderer);
    if (renderTargetView != rendererData->currentRenderTargetView) {
        ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext,
            1,
            &renderTargetView,
            NULL
            );
        rendererData->currentRenderTargetView = renderTargetView;
    }
    if (SDL_RectEmpty(&renderer->clip_rect)) {
        rasterizerState = rendererData->mainRasterizer;
    } else {
        rasterizerState = rendererData->clippedRasterizer;
    }
    if (rasterizerState != rendererData->currentRasterizerState) {
        ID3D11DeviceContext_RSSetState(rendererData->d3dContext, rasterizerState);
        rendererData->currentRasterizerState = rasterizerState;
    }
}
static void
D3D11_RenderSetBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
    ID3D11BlendState *blendState = NULL;
    switch (blendMode) {
    case SDL_BLENDMODE_BLEND:
        blendState = rendererData->blendModeBlend;
        break;
    case SDL_BLENDMODE_ADD:
        blendState = rendererData->blendModeAdd;
        break;
    case SDL_BLENDMODE_MOD:
        blendState = rendererData->blendModeMod;
        break;
    case SDL_BLENDMODE_NONE:
        blendState = NULL;
        break;
    }
    if (blendState != rendererData->currentBlendState) {
        ID3D11DeviceContext_OMSetBlendState(rendererData->d3dContext, blendState, 0, 0xFFFFFFFF);
        rendererData->currentBlendState = blendState;
    }
}
static void
D3D11_SetPixelShader(SDL_Renderer * renderer,
                     ID3D11PixelShader * shader,
                     int numShaderResources,
                     ID3D11ShaderResourceView ** shaderResources,
                     ID3D11SamplerState * sampler)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    ID3D11ShaderResourceView *shaderResource;
    if (shader != rendererData->currentShader) {
        ID3D11DeviceContext_PSSetShader(rendererData->d3dContext, shader, NULL, 0);
        rendererData->currentShader = shader;
    }
    if (numShaderResources > 0) {
        shaderResource = shaderResources[0];
    } else {
        shaderResource = NULL;
    }
    if (shaderResource != rendererData->currentShaderResource) {
        ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, numShaderResources, shaderResources);
        rendererData->currentShaderResource = shaderResource;
    }
    if (sampler != rendererData->currentSampler) {
        ID3D11DeviceContext_PSSetSamplers(rendererData->d3dContext, 0, 1, &sampler);
        rendererData->currentSampler = sampler;
    }
}
static void
D3D11_RenderFinishDrawOp(SDL_Renderer * renderer,
                         D3D11_PRIMITIVE_TOPOLOGY primitiveTopology,
                         UINT vertexCount)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    ID3D11DeviceContext_IASetPrimitiveTopology(rendererData->d3dContext, primitiveTopology);
    ID3D11DeviceContext_Draw(rendererData->d3dContext, vertexCount, 0);
}
static int
D3D11_RenderDrawPoints(SDL_Renderer * renderer,
                       const SDL_FPoint * points, int count)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    float r, g, b, a;
    VertexPositionColor *vertices;
    int i;
    r = (float)(renderer->r / 255.0f);
    g = (float)(renderer->g / 255.0f);
    b = (float)(renderer->b / 255.0f);
    a = (float)(renderer->a / 255.0f);
    vertices = SDL_stack_alloc(VertexPositionColor, count);
    for (i = 0; i < min(count, 128); ++i) {
        const VertexPositionColor v = { { points[i].x, points[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } };
        vertices[i] = v;
    }
    D3D11_RenderStartDrawOp(renderer);
    D3D11_RenderSetBlendMode(renderer, renderer->blendMode);
    if (D3D11_UpdateVertexBuffer(renderer, vertices, (unsigned int)count * sizeof(VertexPositionColor)) != 0) {
        SDL_stack_free(vertices);
        return -1;
    }
    D3D11_SetPixelShader(
        renderer,
        rendererData->colorPixelShader,
        0,
        NULL,
        NULL);
    D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, count);
    SDL_stack_free(vertices);
    return 0;
}
static int
D3D11_RenderDrawLines(SDL_Renderer * renderer,
                      const SDL_FPoint * points, int count)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    float r, g, b, a;
    VertexPositionColor *vertices;
    int i;
    r = (float)(renderer->r / 255.0f);
    g = (float)(renderer->g / 255.0f);
    b = (float)(renderer->b / 255.0f);
    a = (float)(renderer->a / 255.0f);
    vertices = SDL_stack_alloc(VertexPositionColor, count);
    for (i = 0; i < count; ++i) {
        const VertexPositionColor v = { { points[i].x, points[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } };
        vertices[i] = v;
    }
    D3D11_RenderStartDrawOp(renderer);
    D3D11_RenderSetBlendMode(renderer, renderer->blendMode);
    if (D3D11_UpdateVertexBuffer(renderer, vertices, (unsigned int)count * sizeof(VertexPositionColor)) != 0) {
        SDL_stack_free(vertices);
        return -1;
    }
    D3D11_SetPixelShader(
        renderer,
        rendererData->colorPixelShader,
        0,
        NULL,
        NULL);
    D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, count);
    SDL_stack_free(vertices);
    return 0;
}
static int
D3D11_RenderFillRects(SDL_Renderer * renderer,
                      const SDL_FRect * rects, int count)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    float r, g, b, a;
    int i;
    r = (float)(renderer->r / 255.0f);
    g = (float)(renderer->g / 255.0f);
    b = (float)(renderer->b / 255.0f);
    a = (float)(renderer->a / 255.0f);
    for (i = 0; i < count; ++i) {
        VertexPositionColor vertices[] = {
            { { rects[i].x, rects[i].y, 0.0f },                             { 0.0f, 0.0f}, {r, g, b, a} },
            { { rects[i].x, rects[i].y + rects[i].h, 0.0f },                { 0.0f, 0.0f }, { r, g, b, a } },
            { { rects[i].x + rects[i].w, rects[i].y, 0.0f },                { 0.0f, 0.0f }, { r, g, b, a } },
            { { rects[i].x + rects[i].w, rects[i].y + rects[i].h, 0.0f },   { 0.0f, 0.0f }, { r, g, b, a } },
        };
        D3D11_RenderStartDrawOp(renderer);
        D3D11_RenderSetBlendMode(renderer, renderer->blendMode);
        if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
            return -1;
        }
        D3D11_SetPixelShader(
            renderer,
            rendererData->colorPixelShader,
            0,
            NULL,
            NULL);
        D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, SDL_arraysize(vertices));
    }
    return 0;
}
static ID3D11SamplerState *
D3D11_RenderGetSampler(SDL_Renderer * renderer, SDL_Texture * texture)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
    switch (textureData->scaleMode) {
    case D3D11_FILTER_MIN_MAG_MIP_POINT:
        return rendererData->nearestPixelSampler;
    case D3D11_FILTER_MIN_MAG_MIP_LINEAR:
        return rendererData->linearSampler;
    default:
        return NULL;
    }
}
static int
D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
                 const SDL_Rect * srcrect, const SDL_FRect * dstrect)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
    float minu, maxu, minv, maxv;
    Float4 color;
    VertexPositionColor vertices[4];
    ID3D11SamplerState *textureSampler;
    D3D11_RenderStartDrawOp(renderer);
    D3D11_RenderSetBlendMode(renderer, texture->blendMode);
    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.x = 1.0f;     /* red */
    color.y = 1.0f;     /* green */
    color.z = 1.0f;     /* blue */
    color.w = 1.0f;     /* alpha */
    if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
        color.x = (float)(texture->r / 255.0f);     /* red */
        color.y = (float)(texture->g / 255.0f);     /* green */
        color.z = (float)(texture->b / 255.0f);     /* blue */
    }
    if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
        color.w = (float)(texture->a / 255.0f);     /* alpha */
    }
    vertices[0].pos.x = dstrect->x;
    vertices[0].pos.y = dstrect->y;
    vertices[0].pos.z = 0.0f;
    vertices[0].tex.x = minu;
    vertices[0].tex.y = minv;
    vertices[0].color = color;
    vertices[1].pos.x = dstrect->x;
    vertices[1].pos.y = dstrect->y + dstrect->h;
    vertices[1].pos.z = 0.0f;
    vertices[1].tex.x = minu;
    vertices[1].tex.y = maxv;
    vertices[1].color = color;
    vertices[2].pos.x = dstrect->x + dstrect->w;
    vertices[2].pos.y = dstrect->y;
    vertices[2].pos.z = 0.0f;
    vertices[2].tex.x = maxu;
    vertices[2].tex.y = minv;
    vertices[2].color = color;
    vertices[3].pos.x = dstrect->x + dstrect->w;
    vertices[3].pos.y = dstrect->y + dstrect->h;
    vertices[3].pos.z = 0.0f;
    vertices[3].tex.x = maxu;
    vertices[3].tex.y = maxv;
    vertices[3].color = color;
    if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
        return -1;
    }
    textureSampler = D3D11_RenderGetSampler(renderer, texture);
    if (textureData->yuv) {
        ID3D11ShaderResourceView *shaderResources[] = {
            textureData->mainTextureResourceView,
            textureData->mainTextureResourceViewU,
            textureData->mainTextureResourceViewV
        };
        D3D11_SetPixelShader(
            renderer,
            rendererData->yuvPixelShader,
            SDL_arraysize(shaderResources),
            shaderResources,
            textureSampler);
    } else {
        D3D11_SetPixelShader(
            renderer,
            rendererData->texturePixelShader,
            1,
            &textureData->mainTextureResourceView,
            textureSampler);
    }
    D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
    return 0;
}
static int
D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
                   const SDL_Rect * srcrect, const SDL_FRect * dstrect,
                   const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip)
{
    D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
    D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
    float minu, maxu, minv, maxv;
    Float4 color;
    Float4X4 modelMatrix;
    float minx, maxx, miny, maxy;
    VertexPositionColor vertices[4];
    ID3D11SamplerState *textureSampler;
    D3D11_RenderStartDrawOp(renderer);
    D3D11_RenderSetBlendMode(renderer, texture->blendMode);
    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.x = 1.0f;     /* red */
    color.y = 1.0f;     /* green */
    color.z = 1.0f;     /* blue */
    color.w = 1.0f;     /* alpha */
    if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
        color.x = (float)(texture->r / 255.0f);     /* red */
        color.y = (float)(texture->g / 255.0f);     /* green */
        color.z = (float)(texture->b / 255.0f);     /* blue */
    }
    if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
        color.w = (float)(texture->a / 255.0f);     /* alpha */
    }
    if (flip & SDL_FLIP_HORIZONTAL) {
        float tmp = maxu;
        maxu = minu;
        minu = tmp;
    }
    if (flip & SDL_FLIP_VERTICAL) {
        float tmp = maxv;
        maxv = minv;
        minv = tmp;
    }
    modelMatrix = MatrixMultiply(
            MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)),
            MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0)
            );
    D3D11_SetModelMatrix(renderer, &modelMatrix);
    minx = -center->x;
    maxx = dstrect->w - center->x;
    miny = -center->y;
    maxy = dstrect->h - center->y;
    vertices[0].pos.x = minx;
    vertices[0].pos.y = miny;
    vertices[0].pos.z = 0.0f;
    vertices[0].tex.x = minu;
    vertices[0].tex.y = minv;
    vertices[0].color = color;
    vertices[1].pos.x = minx;
    vertices[1].pos.y = maxy;
    vertices[1].pos.z = 0.0f;
    vertices[1].tex.x = minu;
    vertices[1].tex.y = maxv;
    vertices[1].color = color;
    vertices[2].pos.x = maxx;
    vertices[2].pos.y = miny;
    vertices[2].pos.z = 0.0f;
    vertices[2].tex.x = maxu;
    vertices[2].tex.y = minv;
    vertices[2].color = color;
    vertices[3].pos.x = maxx;
    vertices[3].pos.y = maxy;
    vertices[3].pos.z = 0.0f;
    vertices[3].tex.x = maxu;
    vertices[3].tex.y = maxv;
    vertices[3].color = color;
    if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
        return -1;
    }
    textureSampler = D3D11_RenderGetSampler(renderer, texture);
    if (textureData->yuv) {
        ID3D11ShaderResourceView *shaderResources[] = {
            textureData->mainTextureResourceView,
            textureData->mainTextureResourceViewU,
            textureData->mainTextureResourceViewV
        };
        D3D11_SetPixelShader(
            renderer,
            rendererData->yuvPixelShader,
            SDL_arraysize(shaderResources),
            shaderResources,
            textureSampler);
    } else {
        D3D11_SetPixelShader(
            renderer,
            rendererData->texturePixelShader,
            1,
            &textureData->mainTextureResourceView,
            textureSampler);
    }
    D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
    D3D11_SetModelMatrix(renderer, NULL);
    return 0;
}
static int
D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
                       Uint32 format, void * pixels, int pitch)
{
    D3D11_RenderData * data = (D3D11_RenderData *) renderer->driverdata;
    ID3D11Texture2D *backBuffer = NULL;
    ID3D11Texture2D *stagingTexture = NULL;
    HRESULT result;
    int status = -1;
    D3D11_TEXTURE2D_DESC stagingTextureDesc;
    D3D11_RECT srcRect;
    D3D11_BOX srcBox;
    D3D11_MAPPED_SUBRESOURCE textureMemory;
    /* Retrieve a pointer to the back buffer: */
    result = IDXGISwapChain_GetBuffer(data->swapChain,
        0,
        &IID_ID3D11Texture2D,
        &backBuffer
        );
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain1::GetBuffer [get back buffer]", result);
        goto done;
    }
    /* Create a staging texture to copy the screen's data to: */
    ID3D11Texture2D_GetDesc(backBuffer, &stagingTextureDesc);
    stagingTextureDesc.Width = rect->w;
    stagingTextureDesc.Height = rect->h;
    stagingTextureDesc.BindFlags = 0;
    stagingTextureDesc.MiscFlags = 0;
    stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
    stagingTextureDesc.Usage = D3D11_USAGE_STAGING;
    result = ID3D11Device_CreateTexture2D(data->d3dDevice,
        &stagingTextureDesc,
        NULL,
        &stagingTexture);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result);
        goto done;
    }
    /* Copy the desired portion of the back buffer to the staging texture: */
    if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect) != 0) {
        /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */
        goto done;
    }
    srcBox.left = srcRect.left;
    srcBox.right = srcRect.right;
    srcBox.top = srcRect.top;
    srcBox.bottom = srcRect.bottom;
    srcBox.front = 0;
    srcBox.back = 1;
    ID3D11DeviceContext_CopySubresourceRegion(data->d3dContext,
        (ID3D11Resource *)stagingTexture,
        0,
        0, 0, 0,
        (ID3D11Resource *)backBuffer,
        0,
        &srcBox);
    /* Map the staging texture's data to CPU-accessible memory: */
    result = ID3D11DeviceContext_Map(data->d3dContext,
        (ID3D11Resource *)stagingTexture,
        0,
        D3D11_MAP_READ,
        0,
        &textureMemory);
    if (FAILED(result)) {
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result);
        goto done;
    }
    /* Copy the data into the desired buffer, converting pixels to the
     * desired format at the same time:
     */
    if (SDL_ConvertPixels(
        rect->w, rect->h,
        DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
        textureMemory.pData,
        textureMemory.RowPitch,
        format,
        pixels,
        pitch) != 0) {
        /* When SDL_ConvertPixels fails, it'll have already set the format.
         * Get the error message, and attach some extra data to it.
         */
        char errorMessage[1024];
        SDL_snprintf(errorMessage, sizeof(errorMessage), __FUNCTION__ ", Convert Pixels failed: %s", SDL_GetError());
        SDL_SetError(errorMessage);
        goto done;
    }
    /* Unmap the texture: */
    ID3D11DeviceContext_Unmap(data->d3dContext,
        (ID3D11Resource *)stagingTexture,
        0);
    status = 0;
done:
    SAFE_RELEASE(backBuffer);
    SAFE_RELEASE(stagingTexture);
    return status;
}
static void
D3D11_RenderPresent(SDL_Renderer * renderer)
{
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
    UINT syncInterval;
    UINT presentFlags;
    HRESULT result;
    DXGI_PRESENT_PARAMETERS parameters;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    syncInterval = 1;
    presentFlags = 0;
    result = IDXGISwapChain_Present(data->swapChain, syncInterval, presentFlags);
#else
    if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
        syncInterval = 1;
        presentFlags = 0;
    } else {
        syncInterval = 0;
        presentFlags = DXGI_PRESENT_DO_NOT_WAIT;
    }
    /* The application may optionally specify "dirty" or "scroll"
     * rects to improve efficiency in certain scenarios.
     * This option is not available on Windows Phone 8, to note.
     */
    SDL_zero(parameters);
    result = IDXGISwapChain1_Present1(data->swapChain, syncInterval, presentFlags, &parameters);
#endif
    /* Discard the contents of the render target.
     * This is a valid operation only when the existing contents will be entirely
     * overwritten. If dirty or scroll rects are used, this call should be removed.
     */
    ID3D11DeviceContext1_DiscardView(data->d3dContext, (ID3D11View*)data->mainRenderTargetView);
    /* When the present flips, it unbinds the current view, so bind it again on the next draw call */
    data->currentRenderTargetView = NULL;
    if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) {
        /* If the device was removed either by a disconnect or a driver upgrade, we
         * must recreate all device resources.
         *
         * TODO, WinRT: consider throwing an exception if D3D11_RenderPresent fails, especially if there is a way to salvage debug info from users' machines
         */
        if ( result == DXGI_ERROR_DEVICE_REMOVED ) {
            D3D11_HandleDeviceLost(renderer);
        } else if (result == DXGI_ERROR_INVALID_CALL) {
            /* We probably went through a fullscreen <-> windowed transition */
            D3D11_CreateWindowSizeDependentResources(renderer);
        } else {
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::Present", result);
        }
    }
}
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */
source/src/render/direct3d11/SDL_render_winrt.cpp
New file
@@ -0,0 +1,119 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
#include "SDL_syswm.h"
extern "C" {
#include "../SDL_sysrender.h"
}
#include <windows.ui.core.h>
#include <windows.graphics.display.h>
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
#include <windows.ui.xaml.media.dxinterop.h>
#endif
using namespace Windows::UI::Core;
using namespace Windows::Graphics::Display;
#include <DXGI.h>
#include "SDL_render_winrt.h"
extern "C" void *
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
{
    SDL_Window * sdlWindow = renderer->window;
    if ( ! renderer->window ) {
        return NULL;
    }
    SDL_SysWMinfo sdlWindowInfo;
    SDL_VERSION(&sdlWindowInfo.version);
    if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) {
        return NULL;
    }
    if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) {
        return NULL;
    }
    if (!sdlWindowInfo.info.winrt.window) {
        return NULL;
    }
    ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL;
    if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) {
        return NULL;
    }
    IUnknown *coreWindowAsIUnknown = NULL;
    coreWindow->QueryInterface(&coreWindowAsIUnknown);
    coreWindow->Release();
    return coreWindowAsIUnknown;
}
extern "C" DXGI_MODE_ROTATION
D3D11_GetCurrentRotation()
{
#if NTDDI_VERSION > NTDDI_WIN8
    const DisplayOrientations currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
#else
    const DisplayOrientations currentOrientation = DisplayProperties::CurrentOrientation;
#endif
    switch (currentOrientation) {
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    /* Windows Phone rotations */
    case DisplayOrientations::Landscape:
        return DXGI_MODE_ROTATION_ROTATE90;
    case DisplayOrientations::Portrait:
        return DXGI_MODE_ROTATION_IDENTITY;
    case DisplayOrientations::LandscapeFlipped:
        return DXGI_MODE_ROTATION_ROTATE270;
    case DisplayOrientations::PortraitFlipped:
        return DXGI_MODE_ROTATION_ROTATE180;
#else
    /* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */
    case DisplayOrientations::Landscape:
        return DXGI_MODE_ROTATION_IDENTITY;
    case DisplayOrientations::Portrait:
        return DXGI_MODE_ROTATION_ROTATE270;
    case DisplayOrientations::LandscapeFlipped:
        return DXGI_MODE_ROTATION_ROTATE180;
    case DisplayOrientations::PortraitFlipped:
        return DXGI_MODE_ROTATION_ROTATE90;
#endif /* WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP */
    }
    return DXGI_MODE_ROTATION_IDENTITY;
}
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */
source/src/render/direct3d11/SDL_render_winrt.h
New file
@@ -0,0 +1,40 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
#include "SDL_render.h"
#ifdef __cplusplus
extern "C" {
#endif
void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer);
DXGI_MODE_ROTATION D3D11_GetCurrentRotation();
#ifdef __cplusplus
}
#endif
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */
source/src/render/opengl/SDL_glfuncs.h
@@ -1,3 +1,24 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
/* list of OpenGL functions sorted alphabetically
   If you need to use a GL function from the SDL video subsystem,
   change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
source/src/render/opengl/SDL_render_gl.c
@@ -447,7 +447,7 @@
    renderer->GL_BindTexture = GL_BindTexture;
    renderer->GL_UnbindTexture = GL_UnbindTexture;
    renderer->info = GL_RenderDriver.info;
    renderer->info.flags = SDL_RENDERER_ACCELERATED;
    renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
    renderer->driverdata = data;
    renderer->window = window;
source/src/render/opengles/SDL_glesfuncs.h
@@ -1,3 +1,24 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum))
source/src/render/opengles/SDL_render_gles.c
@@ -103,7 +103,7 @@
    GLES_CreateRenderer,
    {
     "opengles",
     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ),
     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
     1,
     {SDL_PIXELFORMAT_ABGR8888},
     0,
source/src/render/opengles2/SDL_gles2funcs.h
@@ -1,3 +1,24 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
SDL_PROC(void, glActiveTexture, (GLenum))
SDL_PROC(void, glAttachShader, (GLuint, GLuint))
SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
@@ -47,4 +68,4 @@
SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
source/src/render/opengles2/SDL_render_gles2.c
@@ -1784,7 +1784,7 @@
        return NULL;
    }
    renderer->info = GLES2_RenderDriver.info;
    renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
    renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
    renderer->driverdata = data;
    renderer->window = window;
@@ -1805,6 +1805,14 @@
        return NULL;
    }
#if __WINRT__
    /* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync
     * is turned on.  Not doing so will freeze the screen's contents to that
     * of the first drawn frame.
     */
    flags |= SDL_RENDERER_PRESENTVSYNC;
#endif
    if (flags & SDL_RENDERER_PRESENTVSYNC) {
        SDL_GL_SetSwapInterval(1);
    } else {
source/src/render/psp/SDL_render_psp.c
@@ -375,7 +375,7 @@
    renderer->DestroyTexture = PSP_DestroyTexture;
    renderer->DestroyRenderer = PSP_DestroyRenderer;
    renderer->info = PSP_RenderDriver.info;
    renderer->info.flags = SDL_RENDERER_ACCELERATED;
    renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
    renderer->driverdata = data;
    renderer->window = window;
source/src/render/software/SDL_rotate.h
@@ -1,3 +1,24 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#ifndef MIN
#define MIN(a,b)    (((a) < (b)) ? (a) : (b))
#endif
source/src/stdlib/SDL_stdlib.c
@@ -102,6 +102,8 @@
{
#if defined(HAVE_COPYSIGN)
    return copysign(x, y);
#elif defined(HAVE__COPYSIGN)
    return _copysign(x, y);
#else
    return SDL_uclibc_copysign(x, y);
#endif /* HAVE_COPYSIGN */
@@ -172,6 +174,8 @@
{
#if defined(HAVE_SCALBN)
    return scalbn(x, n);
#elif defined(HAVE__SCALB)
    return _scalb(x, n);
#else
    return SDL_uclibc_scalbn(x, n);
#endif /* HAVE_SCALBN */
source/src/test/SDL_test_harness.c
@@ -67,12 +67,13 @@
    seed = (char *)SDL_malloc((length + 1) * sizeof(char));
    if (seed == NULL) {
        SDLTest_LogError("SDL_malloc for run seed output buffer failed.");
        SDL_Error(SDL_ENOMEM);
        return NULL;
    }
    /* Generate a random string of alphanumeric characters */
    SDLTest_RandomInitTime(&randomContext);
    for (counter = 0; counter < length - 1; ++counter) {
    for (counter = 0; counter < length; counter++) {
        unsigned int number = SDLTest_Random(&randomContext);
        char ch = (char) (number % (91 - 48)) + 48;
        if (ch >= 58 && ch <= 64) {
@@ -80,7 +81,7 @@
        }
        seed[counter] = ch;
    }
    seed[counter] = '\0';
    seed[length] = '\0';
    return seed;
}
@@ -141,7 +142,8 @@
    entireStringLength  = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1;
    buffer = (char *)SDL_malloc(entireStringLength);
    if (buffer == NULL) {
        SDLTest_LogError("SDL_malloc failed to allocate buffer for execKey generation.");
        SDLTest_LogError("Failed to allocate buffer for execKey generation.");
        SDL_Error(SDL_ENOMEM);
        return 0;
    }
    SDL_snprintf(buffer, entireStringLength, "%s%s%s%d", runSeed, suiteName, testName, iteration);
@@ -347,7 +349,7 @@
}
/**
* \brief Execute a test suite using the given run seend and execution key.
* \brief Execute a test suite using the given run seed and execution key.
*
* The filter string is matched to the suite name (full comparison) to select a single suite,
* or if no suite matches, it is matched to the test names (full comparison) to select a single test.
@@ -362,6 +364,8 @@
*/
int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations)
{
    int totalNumberOfTests = 0;
    int failedNumberOfTests = 0;
    int suiteCounter;
    int testCounter;
    int iterationCounter;
@@ -392,6 +396,7 @@
    Uint32 testSkippedCount = 0;
    Uint32 countSum = 0;
    char *logFormat = (char *)SDLTest_LogSummaryFormat;
    SDLTest_TestCaseReference **failedTests;
    /* Sanitize test iterations */
    if (testIterations < 1) {
@@ -420,6 +425,27 @@
    /* Log run with fuzzer parameters */
    SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed);
    /* Count the total number of tests */
    suiteCounter = 0;
    while (testSuites[suiteCounter]) {
        testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter];
        suiteCounter++;
        testCounter = 0;
        while (testSuite->testCases[testCounter])
        {
            testCounter++;
            totalNumberOfTests++;
        }
    }
    /* Pre-allocate an array for tracking failed tests (potentially all test cases) */
    failedTests = (SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *));
    if (failedTests == NULL) {
       SDLTest_LogError("Unable to allocate cache for failed tests");
           SDL_Error(SDL_ENOMEM);
           return -1;
    }
    /* Initialize filtering */
    if (filter != NULL && filter[0] != '\0') {
@@ -580,6 +606,11 @@
                        break;
                    }
                    /* Collect failed test case references for repro-step display */
                    if (testResult == TEST_RESULT_FAILED) {
                        failedTests[failedNumberOfTests] = testCase;
                        failedNumberOfTests++;
                    }
                }
            }
@@ -630,6 +661,15 @@
        SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed");
    }
    /* Print repro steps for failed tests */
    if (failedNumberOfTests > 0) {
        SDLTest_Log("Harness input to repro failures:");
        for (testCounter = 0; testCounter < failedNumberOfTests; testCounter++) {
          SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name);
        }
    }
    SDL_free(failedTests);
    SDLTest_Log("Exit code: %d", runResult);
    return runResult;
}
source/src/thread/SDL_thread_c.h
@@ -34,6 +34,8 @@
#include "windows/SDL_systhread_c.h"
#elif SDL_THREAD_PSP
#include "psp/SDL_systhread_c.h"
#elif SDL_THREAD_STDCPP
#include "stdcpp/SDL_systhread_c.h"
#else
#error Need thread implementation for this platform
#include "generic/SDL_systhread_c.h"
source/src/thread/stdcpp/SDL_syscond.cpp
New file
@@ -0,0 +1,164 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
extern "C" {
#include "SDL_thread.h"
}
#include <chrono>
#include <condition_variable>
#include <ratio>
#include <system_error>
#include "SDL_sysmutex_c.h"
struct SDL_cond
{
    std::condition_variable_any cpp_cond;
};
/* Create a condition variable */
extern "C"
SDL_cond *
SDL_CreateCond(void)
{
    /* Allocate and initialize the condition variable */
    try {
        SDL_cond * cond = new SDL_cond;
        return cond;
    } catch (std::system_error & ex) {
        SDL_SetError("unable to create a C++ condition variable: code=%d; %s", ex.code(), ex.what());
        return NULL;
    } catch (std::bad_alloc &) {
        SDL_OutOfMemory();
        return NULL;
    }
}
/* Destroy a condition variable */
extern "C"
void
SDL_DestroyCond(SDL_cond * cond)
{
    if (cond) {
        delete cond;
    }
}
/* Restart one of the threads that are waiting on the condition variable */
extern "C"
int
SDL_CondSignal(SDL_cond * cond)
{
    if (!cond) {
        SDL_SetError("Passed a NULL condition variable");
        return -1;
    }
    cond->cpp_cond.notify_one();
    return 0;
}
/* Restart all threads that are waiting on the condition variable */
extern "C"
int
SDL_CondBroadcast(SDL_cond * cond)
{
    if (!cond) {
        SDL_SetError("Passed a NULL condition variable");
        return -1;
    }
    cond->cpp_cond.notify_all();
    return 0;
}
/* Wait on the condition variable for at most 'ms' milliseconds.
   The mutex must be locked before entering this function!
   The mutex is unlocked during the wait, and locked again after the wait.
Typical use:
Thread A:
    SDL_LockMutex(lock);
    while ( ! condition ) {
        SDL_CondWait(cond, lock);
    }
    SDL_UnlockMutex(lock);
Thread B:
    SDL_LockMutex(lock);
    ...
    condition = true;
    ...
    SDL_CondSignal(cond);
    SDL_UnlockMutex(lock);
 */
extern "C"
int
SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
{
    if (!cond) {
        SDL_SetError("Passed a NULL condition variable");
        return -1;
    }
    if (!mutex) {
        SDL_SetError("Passed a NULL mutex variable");
        return -1;
    }
    try {
        std::unique_lock<std::recursive_mutex> cpp_lock(mutex->cpp_mutex, std::defer_lock_t());
        if (ms == SDL_MUTEX_MAXWAIT) {
            cond->cpp_cond.wait(
                cpp_lock
                );
            cpp_lock.release();
            return 0;
        } else {
            auto wait_result = cond->cpp_cond.wait_for(
                cpp_lock,
                std::chrono::duration<Uint32, std::milli>(ms)
                );
            cpp_lock.release();
            if (wait_result == std::cv_status::timeout) {
                return SDL_MUTEX_TIMEDOUT;
            } else {
                return 0;
            }
        }
    } catch (std::system_error & ex) {
        SDL_SetError("unable to wait on a C++ condition variable: code=%d; %s", ex.code(), ex.what());
        return -1;
    }
}
/* Wait on the condition variable forever */
extern "C"
int
SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
{
    return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
}
/* vi: set ts=4 sw=4 expandtab: */
source/src/thread/stdcpp/SDL_sysmutex.cpp
New file
@@ -0,0 +1,111 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
extern "C" {
#include "SDL_thread.h"
#include "SDL_systhread_c.h"
#include "SDL_log.h"
}
#include <system_error>
#include "SDL_sysmutex_c.h"
#include <Windows.h>
/* Create a mutex */
extern "C"
SDL_mutex *
SDL_CreateMutex(void)
{
    /* Allocate and initialize the mutex */
    try {
        SDL_mutex * mutex = new SDL_mutex;
        return mutex;
    } catch (std::system_error & ex) {
        SDL_SetError("unable to create a C++ mutex: code=%d; %s", ex.code(), ex.what());
        return NULL;
    } catch (std::bad_alloc &) {
        SDL_OutOfMemory();
        return NULL;
    }
}
/* Free the mutex */
extern "C"
void
SDL_DestroyMutex(SDL_mutex * mutex)
{
    if (mutex) {
        delete mutex;
    }
}
/* Lock the semaphore */
extern "C"
int
SDL_mutexP(SDL_mutex * mutex)
{
    if (mutex == NULL) {
        SDL_SetError("Passed a NULL mutex");
        return -1;
    }
    try {
        mutex->cpp_mutex.lock();
        return 0;
    } catch (std::system_error & ex) {
        SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what());
        return -1;
    }
}
/* TryLock the mutex */
int
SDL_TryLockMutex(SDL_mutex * mutex)
{
    int retval = 0;
    if (mutex == NULL) {
        return SDL_SetError("Passed a NULL mutex");
    }
    if (mutex->cpp_mutex.try_lock() == false) {
        retval = SDL_MUTEX_TIMEDOUT;
    }
    return retval;
}
/* Unlock the mutex */
extern "C"
int
SDL_mutexV(SDL_mutex * mutex)
{
    if (mutex == NULL) {
        SDL_SetError("Passed a NULL mutex");
        return -1;
    }
    mutex->cpp_mutex.unlock();
    return 0;
}
/* vi: set ts=4 sw=4 expandtab: */
source/src/thread/stdcpp/SDL_sysmutex_c.h
New file
@@ -0,0 +1,30 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include <mutex>
struct SDL_mutex
{
    std::recursive_mutex cpp_mutex;
};
/* vi: set ts=4 sw=4 expandtab: */
source/src/thread/stdcpp/SDL_systhread.cpp
New file
@@ -0,0 +1,167 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
/* Thread management routines for SDL */
extern "C" {
#include "SDL_thread.h"
#include "../SDL_thread_c.h"
#include "../SDL_systhread.h"
#include "SDL_log.h"
}
#include <mutex>
#include <thread>
#include <system_error>
#ifdef __WINRT__
#include <Windows.h>
#endif
static void
RunThread(void *args)
{
    SDL_RunThread(args);
}
extern "C"
int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
{
    try {
        std::thread cpp_thread(RunThread, args);
        thread->handle = (void *) new std::thread(std::move(cpp_thread));
        return 0;
    } catch (std::system_error & ex) {
        SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what());
        return -1;
    } catch (std::bad_alloc &) {
        SDL_OutOfMemory();
        return -1;
    }
}
extern "C"
void
SDL_SYS_SetupThread(const char *name)
{
    // Make sure a thread ID gets assigned ASAP, for debugging purposes:
    SDL_ThreadID();
    return;
}
extern "C"
SDL_threadID
SDL_ThreadID(void)
{
#ifdef __WINRT__
    return GetCurrentThreadId();
#else
    // HACK: Mimick a thread ID, if one isn't otherwise available.
    static thread_local SDL_threadID current_thread_id = 0;
    static SDL_threadID next_thread_id = 1;
    static std::mutex next_thread_id_mutex;
    if (current_thread_id == 0) {
        std::lock_guard<std::mutex> lock(next_thread_id_mutex);
        current_thread_id = next_thread_id;
        ++next_thread_id;
    }
    return current_thread_id;
#endif
}
extern "C"
int
SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
{
    // Thread priorities do not look to be settable via C++11's thread
    // interface, at least as of this writing (Nov 2012).  std::thread does
    // provide access to the OS' native handle, however, and some form of
    // priority-setting could, in theory, be done through this interface.
    //
    // WinRT: UPDATE (Aug 20, 2013): thread priorities cannot be changed
    // on WinRT, at least not for any thread that's already been created.
    // WinRT threads appear to be based off of the WinRT class,
    // ThreadPool, more info on which can be found at:
    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.threading.threadpool.aspx
    //
    // For compatibility sake, 0 will be returned here.
    return (0);
}
extern "C"
void
SDL_SYS_WaitThread(SDL_Thread * thread)
{
    if ( ! thread) {
        return;
    }
    try {
        std::thread * cpp_thread = (std::thread *) thread->handle;
        if (cpp_thread->joinable()) {
            cpp_thread->join();
        }
    } catch (std::system_error &) {
        // An error occurred when joining the thread.  SDL_WaitThread does not,
        // however, seem to provide a means to report errors to its callers
        // though!
    }
}
extern "C"
void
SDL_SYS_DetachThread(SDL_Thread * thread)
{
    if ( ! thread) {
        return;
    }
    try {
        std::thread * cpp_thread = (std::thread *) thread->handle;
        if (cpp_thread->joinable()) {
            cpp_thread->detach();
        }
    } catch (std::system_error &) {
        // An error occurred when detaching the thread.  SDL_DetachThread does not,
        // however, seem to provide a means to report errors to its callers
        // though!
    }
}
extern "C"
SDL_TLSData *
SDL_SYS_GetTLSData()
{
    return SDL_Generic_GetTLSData();
}
extern "C"
int
SDL_SYS_SetTLSData(SDL_TLSData *data)
{
    return SDL_Generic_SetTLSData(data);
}
/* vi: set ts=4 sw=4 expandtab: */
source/src/thread/stdcpp/SDL_systhread_c.h
New file
@@ -0,0 +1,26 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
/* For a thread handle, use a void pointer to a std::thread */
typedef void * SYS_ThreadHandle;
/* vi: set ts=4 sw=4 expandtab: */
source/src/timer/windows/SDL_systimer.c
@@ -41,6 +41,7 @@
/* The number of ticks per second of the high-resolution performance counter */
static LARGE_INTEGER hires_ticks_per_second;
#ifndef __WINRT__
static void
timeSetPeriod(UINT uPeriod)
{
@@ -74,6 +75,7 @@
        timeSetPeriod(uPeriod);
    }
}
#endif /* ifndef __WINRT__ */
#endif /* !USE_GETTICKCOUNT */
@@ -97,13 +99,17 @@
        QueryPerformanceCounter(&hires_start_ticks);
    } else {
        hires_timer_available = FALSE;
#ifdef __WINRT__
        start = 0;            /* the timer failed to start! */
#else
        timeSetPeriod(1);     /* use 1 ms timer precision */
        start = timeGetTime();
        SDL_AddHintCallback(SDL_HINT_TIMER_RESOLUTION,
                            SDL_TimerResolutionChanged, NULL);
#endif /* __WINRT__ */
    }
#endif
#endif /* USE_GETTICKCOUNT */
}
void
@@ -111,12 +117,14 @@
{
#ifndef USE_GETTICKCOUNT
    if (!hires_timer_available) {
#ifndef __WINRT__
        SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION,
                            SDL_TimerResolutionChanged, NULL);
        timeSetPeriod(0);
#endif /* __WINRT__ */
    }
#endif
#endif /* USE_GETTICKCOUNT */
    ticks_started = SDL_FALSE;
}
@@ -145,7 +153,11 @@
        return (DWORD) hires_now.QuadPart;
    } else {
#ifdef __WINRT__
        now = 0;
#else
        now = timeGetTime();
#endif /* __WINRT__ */
    }
#endif
@@ -174,6 +186,19 @@
    return frequency.QuadPart;
}
#ifdef __WINRT__
static void
Sleep(DWORD timeout)
{
    static HANDLE mutex = 0;
    if ( ! mutex )
    {
        mutex = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS);
    }
    WaitForSingleObjectEx(mutex, timeout, FALSE);
}
#endif
void
SDL_Delay(Uint32 ms)
{
source/src/video/SDL_egl.c
@@ -41,7 +41,7 @@
#define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
#define DEFAULT_OGL_ES "libGLESv1_CM.so"
#elif SDL_VIDEO_DRIVER_WINDOWS
#elif SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
/* EGL AND OpenGL ES support via ANGLE */
#define DEFAULT_EGL "libEGL.dll"
#define DEFAULT_OGL_ES2 "libGLESv2.dll"
@@ -119,7 +119,7 @@
{
    void *dll_handle = NULL, *egl_dll_handle = NULL; /* The naming is counter intuitive, but hey, I just work here -- Gabriel */
    char *path = NULL;
#if SDL_VIDEO_DRIVER_WINDOWS
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
    const char *d3dcompiler;
#endif
@@ -132,7 +132,7 @@
        return SDL_OutOfMemory();
    }
#if SDL_VIDEO_DRIVER_WINDOWS
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
    d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
    if (!d3dcompiler) {
        /* By default we load the Vista+ compatible compiler */
source/src/video/SDL_sysvideo.h
@@ -354,6 +354,9 @@
#if SDL_VIDEO_DRIVER_WINDOWS
extern VideoBootStrap WINDOWS_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_WINRT
extern VideoBootStrap WINRT_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_HAIKU
extern VideoBootStrap HAIKU_bootstrap;
#endif
source/src/video/SDL_video.c
@@ -31,6 +31,8 @@
#include "../events/SDL_events_c.h"
#include "../timer/SDL_timer_c.h"
#include "SDL_syswm.h"
#if SDL_VIDEO_OPENGL
#include "SDL_opengl.h"
#endif /* SDL_VIDEO_OPENGL */
@@ -43,8 +45,6 @@
#if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL
#include "SDL_opengles2.h"
#endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */
#include "SDL_syswm.h"
/* On Windows, windows.h defines CreateWindow */
#ifdef CreateWindow
@@ -68,6 +68,9 @@
#if SDL_VIDEO_DRIVER_WINDOWS
    &WINDOWS_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_WINRT
    &WINRT_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_HAIKU
    &HAIKU_bootstrap,
#endif
source/src/video/cocoa/SDL_cocoaopengl.m
@@ -162,7 +162,6 @@
Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
{
    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    const GLubyte *(APIENTRY * glGetStringFunc)(GLenum) = NULL;
    NSAutoreleasePool *pool;
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
@@ -249,7 +248,7 @@
    fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
    if (fmt == nil) {
        SDL_SetError ("Failed creating OpenGL pixel format");
        SDL_SetError("Failed creating OpenGL pixel format");
        [pool release];
        return NULL;
    }
@@ -263,7 +262,7 @@
    [fmt release];
    if (context == nil) {
        SDL_SetError ("Failed creating OpenGL context");
        SDL_SetError("Failed creating OpenGL context");
        [pool release];
        return NULL;
    }
@@ -272,40 +271,50 @@
    if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
        Cocoa_GL_DeleteContext(_this, context);
        SDL_SetError ("Failed making OpenGL context current");
        SDL_SetError("Failed making OpenGL context current");
        return NULL;
    }
    glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
    if (!glGetStringFunc) {
        Cocoa_GL_DeleteContext(_this, context);
        SDL_SetError ("Failed getting OpenGL glGetString entry point");
        return NULL;
    if (_this->gl_config.major_version < 3 &&
        _this->gl_config.profile_mask == 0 &&
        _this->gl_config.flags == 0) {
        /* This is a legacy profile, so to match other backends, we're done. */
    } else {
        const GLubyte *(APIENTRY * glGetStringFunc)(GLenum);
        glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
        if (!glGetStringFunc) {
            Cocoa_GL_DeleteContext(_this, context);
            SDL_SetError ("Failed getting OpenGL glGetString entry point");
            return NULL;
        }
        glversion = (const char *)glGetStringFunc(GL_VERSION);
        if (glversion == NULL) {
            Cocoa_GL_DeleteContext(_this, context);
            SDL_SetError ("Failed getting OpenGL context version");
            return NULL;
        }
        if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
            Cocoa_GL_DeleteContext(_this, context);
            SDL_SetError ("Failed parsing OpenGL context version");
            return NULL;
        }
        if ((glversion_major < _this->gl_config.major_version) ||
           ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
            Cocoa_GL_DeleteContext(_this, context);
            SDL_SetError ("Failed creating OpenGL context at version requested");
            return NULL;
        }
        /* In the future we'll want to do this, but to match other platforms
           we'll leave the OpenGL version the way it is for now
         */
        /*_this->gl_config.major_version = glversion_major;*/
        /*_this->gl_config.minor_version = glversion_minor;*/
    }
    glversion = (const char *)glGetStringFunc(GL_VERSION);
    if (glversion == NULL) {
        Cocoa_GL_DeleteContext(_this, context);
        SDL_SetError ("Failed getting OpenGL context version");
        return NULL;
    }
    if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
        Cocoa_GL_DeleteContext(_this, context);
        SDL_SetError ("Failed parsing OpenGL context version");
        return NULL;
    }
    if ((glversion_major <  _this->gl_config.major_version) ||
       ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
        Cocoa_GL_DeleteContext(_this, context);
        SDL_SetError ("Failed creating OpenGL context at version requested");
        return NULL;
    }
    _this->gl_config.major_version = glversion_major;
    _this->gl_config.minor_version = glversion_minor;
    return context;
}
source/src/video/cocoa/SDL_cocoawindow.m
@@ -587,6 +587,8 @@
    inFullscreenTransition = NO;
    [nswindow setLevel:kCGNormalWindowLevel];
    if (pendingWindowOperation == PENDING_OPERATION_ENTER_FULLSCREEN) {
        pendingWindowOperation = PENDING_OPERATION_NONE;
        [self setFullscreenSpace:YES];
@@ -610,6 +612,11 @@
        window->w = 0;
        window->h = 0;
        [self windowDidResize:aNotification];
        /* FIXME: Why does the window get hidden? */
        if (window->flags & SDL_WINDOW_SHOWN) {
            Cocoa_ShowWindow(SDL_GetVideoDevice(), window);
        }
    }
}
source/src/video/mir/SDL_mirframebuffer.c
@@ -91,11 +91,13 @@
    MirGraphicsRegion region;
    int i, j, x, y, w, h, start;
    int bytes_per_pixel, bytes_per_row, s_stride, d_stride;
    char* s_dest;
    char* pixels;
    MIR_mir_surface_get_graphics_region(mir_window->surface, &region);
    char* s_dest = region.vaddr;
    char* pixels = (char*)window->surface->pixels;
    s_dest = region.vaddr;
    pixels = (char*)window->surface->pixels;
    s_stride = window->surface->pitch;
    d_stride = region.stride;
source/src/video/windows/SDL_msctf.h
@@ -1,3 +1,24 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _SDL_msctf_h
#define _SDL_msctf_h
source/src/video/windows/SDL_windowsevents.c
@@ -71,6 +71,9 @@
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
#endif
#ifndef WM_UNICHAR
#define WM_UNICHAR 0x0109
#endif
static SDL_Scancode
WindowsScanCodeToSDLScanCode( LPARAM lParam, WPARAM wParam )
source/src/video/windows/SDL_windowsopengl.c
@@ -616,13 +616,13 @@
    }
    if (_this->gl_config.major_version < 3 &&
    _this->gl_config.profile_mask == 0 &&
    _this->gl_config.flags == 0) {
        _this->gl_config.profile_mask == 0 &&
        _this->gl_config.flags == 0) {
        /* Create legacy context */
        context = _this->gl_data->wglCreateContext(hdc);
    if( share_context != 0 ) {
        if( share_context != 0 ) {
            _this->gl_data->wglShareLists(share_context, context);
    }
        }
    } else {
        PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
        HGLRC temp_context = _this->gl_data->wglCreateContext(hdc);
source/src/video/windows/SDL_windowsvideo.c
@@ -247,7 +247,7 @@
#define CINTERFACE
#define COBJMACROS
#include <DXGI.h>
#include <dxgi.h>
SDL_bool 
DXGI_LoadDLL( void **pDXGIDLL , IDXGIFactory **pDXGIFactory )
source/src/video/windows/wmmsg.h
@@ -1,3 +1,23 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#define MAX_WMMSG   (sizeof(wmtab)/sizeof(wmtab[0]))
source/src/video/winrt/SDL_winrtevents.cpp
New file
@@ -0,0 +1,153 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_WINRT
/*
 * Windows includes:
 */
#include <Windows.h>
using namespace Windows::UI::Core;
using Windows::UI::Core::CoreCursor;
/*
 * SDL includes:
 */
#include "SDL_winrtevents_c.h"
#include "../../core/winrt/SDL_winrtapp_common.h"
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "../../core/winrt/SDL_winrtapp_xaml.h"
#include "SDL_assert.h"
#include "SDL_system.h"
extern "C" {
#include "../SDL_sysvideo.h"
#include "../../events/SDL_events_c.h"
}
/* Forward declarations */
static void WINRT_YieldXAMLThread();
/* Global event management */
void
WINRT_PumpEvents(_THIS)
{
    if (SDL_WinRTGlobalApp) {
        SDL_WinRTGlobalApp->PumpEvents();
    } else if (WINRT_XAMLWasEnabled) {
        WINRT_YieldXAMLThread();
    }
}
/* XAML Thread management */
enum SDL_XAMLAppThreadState
{
    ThreadState_NotLaunched = 0,
    ThreadState_Running,
    ThreadState_Yielding
};
static SDL_XAMLAppThreadState _threadState = ThreadState_NotLaunched;
static SDL_Thread * _XAMLThread = nullptr;
static SDL_mutex * _mutex = nullptr;
static SDL_cond * _cond = nullptr;
static void
WINRT_YieldXAMLThread()
{
    SDL_LockMutex(_mutex);
    SDL_assert(_threadState == ThreadState_Running);
    _threadState = ThreadState_Yielding;
    SDL_UnlockMutex(_mutex);
    SDL_CondSignal(_cond);
    SDL_LockMutex(_mutex);
    while (_threadState != ThreadState_Running) {
        SDL_CondWait(_cond, _mutex);
    }
    SDL_UnlockMutex(_mutex);
}
static int
WINRT_XAMLThreadMain(void * userdata)
{
    // TODO, WinRT: pass the C-style main() a reasonably realistic
    // representation of command line arguments.
    int argc = 0;
    char **argv = NULL;
    return WINRT_SDLAppEntryPoint(argc, argv);
}
void
WINRT_CycleXAMLThread()
{
    switch (_threadState) {
        case ThreadState_NotLaunched:
        {
            _cond = SDL_CreateCond();
            _mutex = SDL_CreateMutex();
            _threadState = ThreadState_Running;
            _XAMLThread = SDL_CreateThread(WINRT_XAMLThreadMain, "SDL/XAML App Thread", nullptr);
            SDL_LockMutex(_mutex);
            while (_threadState != ThreadState_Yielding) {
                SDL_CondWait(_cond, _mutex);
            }
            SDL_UnlockMutex(_mutex);
            break;
        }
        case ThreadState_Running:
        {
            SDL_assert(false);
            break;
        }
        case ThreadState_Yielding:
        {
            SDL_LockMutex(_mutex);
            SDL_assert(_threadState == ThreadState_Yielding);
            _threadState = ThreadState_Running;
            SDL_UnlockMutex(_mutex);
            SDL_CondSignal(_cond);
            SDL_LockMutex(_mutex);
            while (_threadState != ThreadState_Yielding) {
                SDL_CondWait(_cond, _mutex);
            }
            SDL_UnlockMutex(_mutex);
        }
    }
}
#endif /* SDL_VIDEO_DRIVER_WINRT */
/* vi: set ts=4 sw=4 expandtab: */
source/src/video/winrt/SDL_winrtevents_c.h
New file
@@ -0,0 +1,72 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
extern "C" {
#include "../SDL_sysvideo.h"
}
/*
 * Internal-use, C-style functions:
 */
#ifdef __cplusplus
extern "C" {
#endif
extern void WINRT_InitTouch(_THIS);
extern void WINRT_PumpEvents(_THIS);
#ifdef __cplusplus
}
#endif
/*
 * Internal-use, C++/CX functions:
 */
#ifdef __cplusplus_winrt
/* Pointers (Mice, Touch, etc.) */
typedef enum {
    NormalizeZeroToOne,
    TransformToSDLWindowSize
} WINRT_CursorNormalizationType;
extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window * window,
                                                                Windows::Foundation::Point rawPosition,
                                                                WINRT_CursorNormalizationType normalization);
extern Uint8 WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt);
extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint);
extern void WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args);
/* Keyboard */
extern void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args);
extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args);
/* XAML Thread Management */
extern void WINRT_CycleXAMLThread();
#endif // ifdef __cplusplus_winrt
/* vi: set ts=4 sw=4 expandtab: */
source/src/video/winrt/SDL_winrtkeyboard.cpp
New file
@@ -0,0 +1,301 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_WINRT
/* Standard C++11 includes */
#include <unordered_map>
/* Windows-specific includes */
#include <Windows.h>
#include <agile.h>
/* SDL-specific includes */
#include <SDL.h>
#include "SDL_winrtevents_c.h"
extern "C" {
#include "../../events/scancodes_windows.h"
#include "../../events/SDL_keyboard_c.h"
}
static SDL_Scancode WinRT_Official_Keycodes[] = {
    SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0
    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1
    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2
    SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3
    SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4
    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5
    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6
    SDL_SCANCODE_UNKNOWN, // -- 7
    SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8
    SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9
    SDL_SCANCODE_UNKNOWN, // -- 10
    SDL_SCANCODE_UNKNOWN, // -- 11
    SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12
    SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13
    SDL_SCANCODE_UNKNOWN, // -- 14
    SDL_SCANCODE_UNKNOWN, // -- 15
    SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16
    SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17
    SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18
    SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19
    SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21
    SDL_SCANCODE_UNKNOWN, // -- 22
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25
    SDL_SCANCODE_UNKNOWN, // -- 26
    SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28
    SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30
    SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31  (maybe SDL_SCANCODE_MODE ?)
    SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32
    SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33
    SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34
    SDL_SCANCODE_END, // VirtualKey.End -- 35
    SDL_SCANCODE_HOME, // VirtualKey.Home -- 36
    SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37
    SDL_SCANCODE_UP, // VirtualKey.Up -- 38
    SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39
    SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40
    SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42  (maybe SDL_SCANCODE_PRINTSCREEN ?)
    SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44
    SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45
    SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46
    SDL_SCANCODE_HELP, // VirtualKey.Help -- 47
    SDL_SCANCODE_0, // VirtualKey.Number0 -- 48
    SDL_SCANCODE_1, // VirtualKey.Number1 -- 49
    SDL_SCANCODE_2, // VirtualKey.Number2 -- 50
    SDL_SCANCODE_3, // VirtualKey.Number3 -- 51
    SDL_SCANCODE_4, // VirtualKey.Number4 -- 52
    SDL_SCANCODE_5, // VirtualKey.Number5 -- 53
    SDL_SCANCODE_6, // VirtualKey.Number6 -- 54
    SDL_SCANCODE_7, // VirtualKey.Number7 -- 55
    SDL_SCANCODE_8, // VirtualKey.Number8 -- 56
    SDL_SCANCODE_9, // VirtualKey.Number9 -- 57
    SDL_SCANCODE_UNKNOWN, // -- 58
    SDL_SCANCODE_UNKNOWN, // -- 59
    SDL_SCANCODE_UNKNOWN, // -- 60
    SDL_SCANCODE_UNKNOWN, // -- 61
    SDL_SCANCODE_UNKNOWN, // -- 62
    SDL_SCANCODE_UNKNOWN, // -- 63
    SDL_SCANCODE_UNKNOWN, // -- 64
    SDL_SCANCODE_A, // VirtualKey.A -- 65
    SDL_SCANCODE_B, // VirtualKey.B -- 66
    SDL_SCANCODE_C, // VirtualKey.C -- 67
    SDL_SCANCODE_D, // VirtualKey.D -- 68
    SDL_SCANCODE_E, // VirtualKey.E -- 69
    SDL_SCANCODE_F, // VirtualKey.F -- 70
    SDL_SCANCODE_G, // VirtualKey.G -- 71
    SDL_SCANCODE_H, // VirtualKey.H -- 72
    SDL_SCANCODE_I, // VirtualKey.I -- 73
    SDL_SCANCODE_J, // VirtualKey.J -- 74
    SDL_SCANCODE_K, // VirtualKey.K -- 75
    SDL_SCANCODE_L, // VirtualKey.L -- 76
    SDL_SCANCODE_M, // VirtualKey.M -- 77
    SDL_SCANCODE_N, // VirtualKey.N -- 78
    SDL_SCANCODE_O, // VirtualKey.O -- 79
    SDL_SCANCODE_P, // VirtualKey.P -- 80
    SDL_SCANCODE_Q, // VirtualKey.Q -- 81
    SDL_SCANCODE_R, // VirtualKey.R -- 82
    SDL_SCANCODE_S, // VirtualKey.S -- 83
    SDL_SCANCODE_T, // VirtualKey.T -- 84
    SDL_SCANCODE_U, // VirtualKey.U -- 85
    SDL_SCANCODE_V, // VirtualKey.V -- 86
    SDL_SCANCODE_W, // VirtualKey.W -- 87
    SDL_SCANCODE_X, // VirtualKey.X -- 88
    SDL_SCANCODE_Y, // VirtualKey.Y -- 89
    SDL_SCANCODE_Z, // VirtualKey.Z -- 90
    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?)
    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?)
    SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93
    SDL_SCANCODE_UNKNOWN, // -- 94
    SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95
    SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96
    SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97
    SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98
    SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99
    SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100
    SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101
    SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102
    SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103
    SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104
    SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105
    SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106
    SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108
    SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109
    SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110  (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?)
    SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111
    SDL_SCANCODE_F1, // VirtualKey.F1 -- 112
    SDL_SCANCODE_F2, // VirtualKey.F2 -- 113
    SDL_SCANCODE_F3, // VirtualKey.F3 -- 114
    SDL_SCANCODE_F4, // VirtualKey.F4 -- 115
    SDL_SCANCODE_F5, // VirtualKey.F5 -- 116
    SDL_SCANCODE_F6, // VirtualKey.F6 -- 117
    SDL_SCANCODE_F7, // VirtualKey.F7 -- 118
    SDL_SCANCODE_F8, // VirtualKey.F8 -- 119
    SDL_SCANCODE_F9, // VirtualKey.F9 -- 120
    SDL_SCANCODE_F10, // VirtualKey.F10 -- 121
    SDL_SCANCODE_F11, // VirtualKey.F11 -- 122
    SDL_SCANCODE_F12, // VirtualKey.F12 -- 123
    SDL_SCANCODE_F13, // VirtualKey.F13 -- 124
    SDL_SCANCODE_F14, // VirtualKey.F14 -- 125
    SDL_SCANCODE_F15, // VirtualKey.F15 -- 126
    SDL_SCANCODE_F16, // VirtualKey.F16 -- 127
    SDL_SCANCODE_F17, // VirtualKey.F17 -- 128
    SDL_SCANCODE_F18, // VirtualKey.F18 -- 129
    SDL_SCANCODE_F19, // VirtualKey.F19 -- 130
    SDL_SCANCODE_F20, // VirtualKey.F20 -- 131
    SDL_SCANCODE_F21, // VirtualKey.F21 -- 132
    SDL_SCANCODE_F22, // VirtualKey.F22 -- 133
    SDL_SCANCODE_F23, // VirtualKey.F23 -- 134
    SDL_SCANCODE_F24, // VirtualKey.F24 -- 135
    SDL_SCANCODE_UNKNOWN, // -- 136
    SDL_SCANCODE_UNKNOWN, // -- 137
    SDL_SCANCODE_UNKNOWN, // -- 138
    SDL_SCANCODE_UNKNOWN, // -- 139
    SDL_SCANCODE_UNKNOWN, // -- 140
    SDL_SCANCODE_UNKNOWN, // -- 141
    SDL_SCANCODE_UNKNOWN, // -- 142
    SDL_SCANCODE_UNKNOWN, // -- 143
    SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144
    SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145
    SDL_SCANCODE_UNKNOWN, // -- 146
    SDL_SCANCODE_UNKNOWN, // -- 147
    SDL_SCANCODE_UNKNOWN, // -- 148
    SDL_SCANCODE_UNKNOWN, // -- 149
    SDL_SCANCODE_UNKNOWN, // -- 150
    SDL_SCANCODE_UNKNOWN, // -- 151
    SDL_SCANCODE_UNKNOWN, // -- 152
    SDL_SCANCODE_UNKNOWN, // -- 153
    SDL_SCANCODE_UNKNOWN, // -- 154
    SDL_SCANCODE_UNKNOWN, // -- 155
    SDL_SCANCODE_UNKNOWN, // -- 156
    SDL_SCANCODE_UNKNOWN, // -- 157
    SDL_SCANCODE_UNKNOWN, // -- 158
    SDL_SCANCODE_UNKNOWN, // -- 159
    SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160
    SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161
    SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162
    SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163
    SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164
    SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165
};
static std::unordered_map<int, SDL_Scancode> WinRT_Unofficial_Keycodes;
static SDL_Scancode
TranslateKeycode(int keycode)
{
    if (WinRT_Unofficial_Keycodes.empty()) {
        /* Set up a table of undocumented (by Microsoft), WinRT-specific,
           key codes: */
        // TODO, WinRT: move content declarations of WinRT_Unofficial_Keycodes into a C++11 initializer list, when possible
        WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_GRAVE;
        WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_BACKSLASH;
    }
    /* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
       http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
       If that fails, fall back to a Win32 virtual key.
    */
    // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
    //SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode);
    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
    if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) {
        scancode = WinRT_Official_Keycodes[keycode];
    }
    if (scancode == SDL_SCANCODE_UNKNOWN) {
        if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) {
            scancode = WinRT_Unofficial_Keycodes[keycode];
        }
    }
    if (scancode == SDL_SCANCODE_UNKNOWN) {
        if (keycode < SDL_arraysize(windows_scancode_table)) {
            scancode = windows_scancode_table[keycode];
        }
    }
    if (scancode == SDL_SCANCODE_UNKNOWN) {
        SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
    }
    return scancode;
}
void
WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
{
    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
#if 0
    SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
    SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
        (args->Handled ? "1" : "0"),
        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
        args->KeyStatus.RepeatCount,
        args->KeyStatus.ScanCode,
        (args->KeyStatus.WasKeyDown ? "1" : "0"),
        args->VirtualKey,
        sdlScancode,
        SDL_GetScancodeName(sdlScancode),
        keycode,
        SDL_GetKeyName(keycode));
    //args->Handled = true;
    //VirtualKey vkey = args->VirtualKey;
#endif
    SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode);
}
void
WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args)
{
    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
#if 0
    SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
    SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
        (args->Handled ? "1" : "0"),
        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
        args->KeyStatus.RepeatCount,
        args->KeyStatus.ScanCode,
        (args->KeyStatus.WasKeyDown ? "1" : "0"),
        args->VirtualKey,
        sdlScancode,
        SDL_GetScancodeName(sdlScancode),
        keycode,
        SDL_GetKeyName(keycode));
    //args->Handled = true;
#endif
    SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode);
}
#endif // SDL_VIDEO_DRIVER_WINRT
source/src/video/winrt/SDL_winrtmouse.cpp
New file
@@ -0,0 +1,165 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_WINRT
/*
 * Windows includes:
 */
#include <Windows.h>
using namespace Windows::UI::Core;
using Windows::UI::Core::CoreCursor;
/*
 * SDL includes:
 */
extern "C" {
#include "SDL_assert.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h"
#include "../SDL_sysvideo.h"
#include "SDL_events.h"
#include "SDL_log.h"
}
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtmouse_c.h"
extern "C" SDL_bool WINRT_UsingRelativeMouseMode = SDL_FALSE;
static SDL_Cursor *
WINRT_CreateSystemCursor(SDL_SystemCursor id)
{
    SDL_Cursor *cursor;
    CoreCursorType cursorType = CoreCursorType::Arrow;
    switch(id)
    {
    default:
        SDL_assert(0);
        return NULL;
    case SDL_SYSTEM_CURSOR_ARROW:     cursorType = CoreCursorType::Arrow; break;
    case SDL_SYSTEM_CURSOR_IBEAM:     cursorType = CoreCursorType::IBeam; break;
    case SDL_SYSTEM_CURSOR_WAIT:      cursorType = CoreCursorType::Wait; break;
    case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break;
    case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break;
    case SDL_SYSTEM_CURSOR_SIZENWSE:  cursorType = CoreCursorType::SizeNorthwestSoutheast; break;
    case SDL_SYSTEM_CURSOR_SIZENESW:  cursorType = CoreCursorType::SizeNortheastSouthwest; break;
    case SDL_SYSTEM_CURSOR_SIZEWE:    cursorType = CoreCursorType::SizeWestEast; break;
    case SDL_SYSTEM_CURSOR_SIZENS:    cursorType = CoreCursorType::SizeNorthSouth; break;
    case SDL_SYSTEM_CURSOR_SIZEALL:   cursorType = CoreCursorType::SizeAll; break;
    case SDL_SYSTEM_CURSOR_NO:        cursorType = CoreCursorType::UniversalNo; break;
    case SDL_SYSTEM_CURSOR_HAND:      cursorType = CoreCursorType::Hand; break;
    }
    cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
    if (cursor) {
        /* Create a pointer to a COM reference to a cursor.  The extra
           pointer is used (on top of the COM reference) to allow the cursor
           to be referenced by the SDL_cursor's driverdata field, which is
           a void pointer.
        */
        CoreCursor ^* theCursor = new CoreCursor^(nullptr);
        *theCursor = ref new CoreCursor(cursorType, 0);
        cursor->driverdata = (void *) theCursor;
    } else {
        SDL_OutOfMemory();
    }
    return cursor;
}
static SDL_Cursor *
WINRT_CreateDefaultCursor()
{
    return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
}
static void
WINRT_FreeCursor(SDL_Cursor * cursor)
{
    if (cursor->driverdata) {
        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
        *theCursor = nullptr;       // Release the COM reference to the CoreCursor
        delete theCursor;           // Delete the pointer to the COM reference
    }
    SDL_free(cursor);
}
static int
WINRT_ShowCursor(SDL_Cursor * cursor)
{
    // TODO, WinRT, XAML: make WINRT_ShowCursor work when XAML support is enabled.
    if ( ! CoreWindow::GetForCurrentThread()) {
        return 0;
    }
    if (cursor) {
        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
        CoreWindow::GetForCurrentThread()->PointerCursor = *theCursor;
    } else {
        CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
    }
    return 0;
}
static int
WINRT_SetRelativeMouseMode(SDL_bool enabled)
{
    WINRT_UsingRelativeMouseMode = enabled;
    return 0;
}
void
WINRT_InitMouse(_THIS)
{
    SDL_Mouse *mouse = SDL_GetMouse();
    /* DLudwig, Dec 3, 2012: WinRT does not currently provide APIs for
       the following features, AFAIK:
        - custom cursors  (multiple system cursors are, however, available)
        - programmatically moveable cursors
    */
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
    //mouse->CreateCursor = WINRT_CreateCursor;
    mouse->CreateSystemCursor = WINRT_CreateSystemCursor;
    mouse->ShowCursor = WINRT_ShowCursor;
    mouse->FreeCursor = WINRT_FreeCursor;
    //mouse->WarpMouse = WINRT_WarpMouse;
    mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode;
    SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
#endif
}
void
WINRT_QuitMouse(_THIS)
{
}
#endif /* SDL_VIDEO_DRIVER_WINRT */
/* vi: set ts=4 sw=4 expandtab: */
source/src/video/winrt/SDL_winrtmouse_c.h
New file
@@ -0,0 +1,40 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#ifndef _SDL_winrtmouse_h
#define _SDL_winrtmouse_h
#ifdef __cplusplus
extern "C" {
#endif
extern void WINRT_InitMouse(_THIS);
extern void WINRT_QuitMouse(_THIS);
extern SDL_bool WINRT_UsingRelativeMouseMode;
#ifdef __cplusplus
}
#endif
#endif /* _SDL_windowsmouse_h */
/* vi: set ts=4 sw=4 expandtab: */
source/src/video/winrt/SDL_winrtopengles.cpp
New file
@@ -0,0 +1,50 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
// TODO: WinRT, make this file compile via C code
#if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL
/* EGL implementation of SDL OpenGL support */
#include "SDL_winrtvideo_cpp.h"
extern "C" {
#include "SDL_winrtopengles.h"
}
#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((NativeDisplayType) -3)
extern "C" int
WINRT_GLES_LoadLibrary(_THIS, const char *path) {
    return SDL_EGL_LoadLibrary(_this, path, EGL_D3D11_ONLY_DISPLAY_ANGLE);
}
extern "C" {
SDL_EGL_CreateContext_impl(WINRT)
SDL_EGL_SwapWindow_impl(WINRT)
SDL_EGL_MakeCurrent_impl(WINRT)
}
#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */
/* vi: set ts=4 sw=4 expandtab: */
source/src/video/winrt/SDL_winrtopengles.h
New file
@@ -0,0 +1,48 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#ifndef _SDL_winrtopengles_h
#define _SDL_winrtopengles_h
#if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
/* OpenGLES functions */
#define WINRT_GLES_GetAttribute SDL_EGL_GetAttribute
#define WINRT_GLES_GetProcAddress SDL_EGL_GetProcAddress
#define WINRT_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
#define WINRT_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
#define WINRT_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
#define WINRT_GLES_DeleteContext SDL_EGL_DeleteContext
extern int WINRT_GLES_LoadLibrary(_THIS, const char *path);
extern SDL_GLContext WINRT_GLES_CreateContext(_THIS, SDL_Window * window);
extern void WINRT_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int WINRT_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */
#endif /* _SDL_winrtopengles_h */
/* vi: set ts=4 sw=4 expandtab: */
source/src/video/winrt/SDL_winrtpointerinput.cpp
New file
@@ -0,0 +1,394 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_WINRT
/* SDL includes */
#include "SDL_winrtevents_c.h"
#include "SDL_winrtmouse_c.h"
#include "SDL_winrtvideo_cpp.h"
#include "SDL_assert.h"
#include "SDL_system.h"
extern "C" {
#include "../SDL_sysvideo.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h"
}
/* File-specific globals: */
static SDL_TouchID WINRT_TouchID = 1;
static unsigned int WINRT_LeftFingerDown = 0;
void
WINRT_InitTouch(_THIS)
{
    SDL_AddTouch(WINRT_TouchID, "");
}
//
// Applies necessary geometric transformations to raw cursor positions:
//
Windows::Foundation::Point
WINRT_TransformCursorPosition(SDL_Window * window,
                              Windows::Foundation::Point rawPosition,
                              WINRT_CursorNormalizationType normalization)
{
    using namespace Windows::UI::Core;
    using namespace Windows::Graphics::Display;
    if (!window) {
        return rawPosition;
    }
    SDL_WindowData * windowData = (SDL_WindowData *) window->driverdata;
    if (windowData->coreWindow == nullptr) {
        // For some reason, the window isn't associated with a CoreWindow.
        // This might end up being the case as XAML support is extended.
        // For now, if there's no CoreWindow attached to the SDL_Window,
        // don't do any transforms.
        // TODO, WinRT: make sure touch input coordinate ranges are correct when using XAML support
        return rawPosition;
    }
    // The CoreWindow can only be accessed on certain thread(s).
    SDL_assert(CoreWindow::GetForCurrentThread() != nullptr);
    CoreWindow ^ nativeWindow = windowData->coreWindow.Get();
    Windows::Foundation::Point outputPosition;
    // Compute coordinates normalized from 0..1.
    // If the coordinates need to be sized to the SDL window,
    // we'll do that after.
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
    outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
    outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
#else
    switch (DisplayProperties::CurrentOrientation)
    {
        case DisplayOrientations::Portrait:
            outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
            outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
            break;
        case DisplayOrientations::PortraitFlipped:
            outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
            outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
            break;
        case DisplayOrientations::Landscape:
            outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height;
            outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width);
            break;
        case DisplayOrientations::LandscapeFlipped:
            outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height);
            outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width;
            break;
        default:
            break;
    }
#endif
    if (normalization == TransformToSDLWindowSize) {
        outputPosition.X *= ((float32) window->w);
        outputPosition.Y *= ((float32) window->h);
    }
    return outputPosition;
}
static inline int
_lround(float arg)
{
    if (arg >= 0.0f) {
        return (int)floor(arg + 0.5f);
    } else {
        return (int)ceil(arg - 0.5f);
    }
}
Uint8
WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt)
{
    using namespace Windows::UI::Input;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    return SDL_BUTTON_LEFT;
#else
    switch (pt->Properties->PointerUpdateKind)
    {
        case PointerUpdateKind::LeftButtonPressed:
        case PointerUpdateKind::LeftButtonReleased:
            return SDL_BUTTON_LEFT;
        case PointerUpdateKind::RightButtonPressed:
        case PointerUpdateKind::RightButtonReleased:
            return SDL_BUTTON_RIGHT;
        case PointerUpdateKind::MiddleButtonPressed:
        case PointerUpdateKind::MiddleButtonReleased:
            return SDL_BUTTON_MIDDLE;
        case PointerUpdateKind::XButton1Pressed:
        case PointerUpdateKind::XButton1Released:
            return SDL_BUTTON_X1;
        case PointerUpdateKind::XButton2Pressed:
        case PointerUpdateKind::XButton2Released:
            return SDL_BUTTON_X2;
        default:
            break;
    }
#endif
    return 0;
}
//const char *
//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind)
//{
//    using namespace Windows::UI::Input;
//
//    switch (kind)
//    {
//        case PointerUpdateKind::Other:
//            return "Other";
//        case PointerUpdateKind::LeftButtonPressed:
//            return "LeftButtonPressed";
//        case PointerUpdateKind::LeftButtonReleased:
//            return "LeftButtonReleased";
//        case PointerUpdateKind::RightButtonPressed:
//            return "RightButtonPressed";
//        case PointerUpdateKind::RightButtonReleased:
//            return "RightButtonReleased";
//        case PointerUpdateKind::MiddleButtonPressed:
//            return "MiddleButtonPressed";
//        case PointerUpdateKind::MiddleButtonReleased:
//            return "MiddleButtonReleased";
//        case PointerUpdateKind::XButton1Pressed:
//            return "XButton1Pressed";
//        case PointerUpdateKind::XButton1Released:
//            return "XButton1Released";
//        case PointerUpdateKind::XButton2Pressed:
//            return "XButton2Pressed";
//        case PointerUpdateKind::XButton2Released:
//            return "XButton2Released";
//    }
//
//    return "";
//}
static bool
WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint)
{
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    return true;
#else
    using namespace Windows::Devices::Input;
    switch (pointerPoint->PointerDevice->PointerDeviceType) {
        case PointerDeviceType::Touch:
        case PointerDeviceType::Pen:
            return true;
        default:
            return false;
    }
#endif
}
void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
    if (!window) {
        return;
    }
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
    if ( ! WINRT_IsTouchEvent(pointerPoint)) {
        SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
    } else {
        Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
        Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
        if (!WINRT_LeftFingerDown) {
            if (button) {
                SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
                SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
            }
            WINRT_LeftFingerDown = pointerPoint->PointerId;
        }
        SDL_SendTouch(
            WINRT_TouchID,
            (SDL_FingerID) pointerPoint->PointerId,
            SDL_TRUE,
            normalizedPoint.X,
            normalizedPoint.Y,
            pointerPoint->Properties->Pressure);
    }
}
void
WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
    if (!window || WINRT_UsingRelativeMouseMode) {
        return;
    }
    Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
    Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize);
    if ( ! WINRT_IsTouchEvent(pointerPoint)) {
        SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
    } else if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
        if (pointerPoint->PointerId == WINRT_LeftFingerDown) {
            SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y);
        }
        SDL_SendTouchMotion(
            WINRT_TouchID,
            (SDL_FingerID) pointerPoint->PointerId,
            normalizedPoint.X,
            normalizedPoint.Y,
            pointerPoint->Properties->Pressure);
    }
}
void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
    if (!window) {
        return;
    }
    Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint);
    if (!WINRT_IsTouchEvent(pointerPoint)) {
        SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
    } else {
        Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne);
        if (WINRT_LeftFingerDown == pointerPoint->PointerId) {
            if (button) {
                SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
            }
            WINRT_LeftFingerDown = 0;
        }
        SDL_SendTouch(
            WINRT_TouchID,
            (SDL_FingerID) pointerPoint->PointerId,
            SDL_FALSE,
            normalizedPoint.X,
            normalizedPoint.Y,
            pointerPoint->Properties->Pressure);
    }
}
void
WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint)
{
    if (!window) {
        return;
    }
    // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
    short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
    SDL_SendMouseWheel(window, 0, 0, motion);
}
void
WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args)
{
    if (!window || !WINRT_UsingRelativeMouseMode) {
        return;
    }
    // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
    // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
    // MouseDelta field often reports very large values.  More information
    // on this can be found at the following pages on MSDN:
    //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
    //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
    //
    // The values do not appear to be as large when running on some systems,
    // most notably a Surface RT.  Furthermore, the values returned by
    // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
    // method, do not ever appear to be large, even when MouseEventArgs'
    // MouseDelta is reporting to the contrary.
    //
    // On systems with the large-values behavior, it appears that the values
    // get reported as if the screen's size is 65536 units in both the X and Y
    // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
    // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
    //
    // MSDN's documentation on MouseEventArgs' MouseDelta field (at
    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
    // does not seem to indicate (to me) that its values should be so large.  It
    // says that its values should be a "change in screen location".  I could
    // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see:
    // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
    // indicates that these values are in DIPs, which is the same unit used
    // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
    // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
    // for details.)
    //
    // To note, PointerMoved events are sent a 'RawPosition' value (via the
    // CurrentPoint property in MouseEventArgs), however these do not seem
    // to exhibit the same large-value behavior.
    //
    // The values passed via PointerMoved events can't always be used for relative
    // mouse motion, unfortunately.  Its values are bound to the cursor's position,
    // which stops when it hits one of the screen's edges.  This can be a problem in
    // first person shooters, whereby it is normal for mouse motion to travel far
    // along any one axis for a period of time.  MouseMoved events do not have the
    // screen-bounding limitation, and can be used regardless of where the system's
    // cursor is.
    //
    // One possible workaround would be to programmatically set the cursor's
    // position to the screen's center (when SDL's relative mouse mode is enabled),
    // however WinRT does not yet seem to have the ability to set the cursor's
    // position via a public API.  Win32 did this via an API call, SetCursorPos,
    // however WinRT makes this function be private.  Apps that use it won't get
    // approved for distribution in the Windows Store.  I've yet to be able to find
    // a suitable, store-friendly counterpart for WinRT.
    //
    // There may be some room for a workaround whereby OnPointerMoved's values
    // are compared to the values from OnMouseMoved in order to detect
    // when this bug is active.  A suitable transformation could then be made to
    // OnMouseMoved's values.  For now, however, the system-reported values are sent
    // to SDL with minimal transformation: from native screen coordinates (in DIPs)
    // to SDL window coordinates.
    //
    const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
    const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize);
    SDL_SendMouseMotion(
        window,
        0,
        1,
        _lround(mouseDeltaInSDLWindowCoords.X),
        _lround(mouseDeltaInSDLWindowCoords.Y));
}
#endif // SDL_VIDEO_DRIVER_WINRT
source/src/video/winrt/SDL_winrtvideo.cpp
New file
@@ -0,0 +1,409 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_WINRT
/* WinRT SDL video driver implementation
   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
   was based off of SDL's "dummy" video driver.
 */
/* Windows includes */
#include <agile.h>
using namespace Windows::UI::Core;
/* SDL includes */
extern "C" {
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "../../render/SDL_sysrender.h"
#include "SDL_syswm.h"
#include "SDL_winrtopengles.h"
}
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
#include "../../core/winrt/SDL_winrtapp_xaml.h"
#include "SDL_winrtvideo_cpp.h"
#include "SDL_winrtevents_c.h"
#include "SDL_winrtmouse_c.h"
#include "SDL_main.h"
#include "SDL_system.h"
/* Initialization/Query functions */
static int WINRT_VideoInit(_THIS);
static int WINRT_InitModes(_THIS);
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
static void WINRT_VideoQuit(_THIS);
/* Window functions */
static int WINRT_CreateWindow(_THIS, SDL_Window * window);
static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
/* SDL-internal globals: */
SDL_Window * WINRT_GlobalSDLWindow = NULL;
SDL_VideoDevice * WINRT_GlobalSDLVideoDevice = NULL;
/* WinRT driver bootstrap functions */
static int
WINRT_Available(void)
{
    return (1);
}
static void
WINRT_DeleteDevice(SDL_VideoDevice * device)
{
    if (device == WINRT_GlobalSDLVideoDevice) {
        WINRT_GlobalSDLVideoDevice = NULL;
    }
    SDL_free(device);
}
static SDL_VideoDevice *
WINRT_CreateDevice(int devindex)
{
    SDL_VideoDevice *device;
    /* Initialize all variables that we clean on shutdown */
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    if (!device) {
        SDL_OutOfMemory();
        if (device) {
            SDL_free(device);
        }
        return (0);
    }
    /* Set the function pointers */
    device->VideoInit = WINRT_VideoInit;
    device->VideoQuit = WINRT_VideoQuit;
    device->CreateWindow = WINRT_CreateWindow;
    device->DestroyWindow = WINRT_DestroyWindow;
    device->SetDisplayMode = WINRT_SetDisplayMode;
    device->PumpEvents = WINRT_PumpEvents;
    device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
#ifdef SDL_VIDEO_OPENGL_EGL
    device->GL_LoadLibrary = WINRT_GLES_LoadLibrary;
    device->GL_GetProcAddress = WINRT_GLES_GetProcAddress;
    device->GL_UnloadLibrary = WINRT_GLES_UnloadLibrary;
    device->GL_CreateContext = WINRT_GLES_CreateContext;
    device->GL_MakeCurrent = WINRT_GLES_MakeCurrent;
    device->GL_SetSwapInterval = WINRT_GLES_SetSwapInterval;
    device->GL_GetSwapInterval = WINRT_GLES_GetSwapInterval;
    device->GL_SwapWindow = WINRT_GLES_SwapWindow;
    device->GL_DeleteContext = WINRT_GLES_DeleteContext;
#endif
    device->free = WINRT_DeleteDevice;
    WINRT_GlobalSDLVideoDevice = device;
    return device;
}
#define WINRTVID_DRIVER_NAME "winrt"
VideoBootStrap WINRT_bootstrap = {
    WINRTVID_DRIVER_NAME, "SDL WinRT video driver",
    WINRT_Available, WINRT_CreateDevice
};
int
WINRT_VideoInit(_THIS)
{
    if (WINRT_InitModes(_this) < 0) {
        return -1;
    }
    WINRT_InitMouse(_this);
    WINRT_InitTouch(_this);
    return 0;
}
int
WINRT_CalcDisplayModeUsingNativeWindow(SDL_DisplayMode * mode)
{
    SDL_DisplayModeData * driverdata;
    using namespace Windows::Graphics::Display;
    // Go no further if a native window cannot be accessed.  This can happen,
    // for example, if this function is called from certain threads, such as
    // the SDL/XAML thread.
    if (!CoreWindow::GetForCurrentThread()) {
        return SDL_SetError("SDL/WinRT display modes cannot be calculated outside of the main thread, such as in SDL's XAML thread");
    }
    // Calculate the display size given the window size, taking into account
    // the current display's DPI:
#if NTDDI_VERSION > NTDDI_WIN8
    const float currentDPI = DisplayInformation::GetForCurrentView()->LogicalDpi;
#else
    const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
#endif
    const float dipsPerInch = 96.0f;
    const int w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
    const int h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
    if (w == 0 || w == h) {
        return SDL_SetError("Unable to calculate the WinRT window/display's size");
    }
    // Create a driverdata field:
    driverdata = (SDL_DisplayModeData *) SDL_malloc(sizeof(*driverdata));
    if (!driverdata) {
        return SDL_OutOfMemory();
    }
    SDL_zerop(driverdata);
    // Fill in most fields:
    SDL_zerop(mode);
    mode->format = SDL_PIXELFORMAT_RGB888;
    mode->refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
    mode->w = w;
    mode->h = h;
    mode->driverdata = driverdata;
#if NTDDI_VERSION > NTDDI_WIN8
    driverdata->currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
#else
    driverdata->currentOrientation = DisplayProperties::CurrentOrientation;
#endif
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    // On Windows Phone, the native window's size is always in portrait,
    // regardless of the device's orientation.  This is in contrast to
    // Windows 8/RT, which will resize the native window as the device's
    // orientation changes.  In order to compensate for this behavior,
    // on Windows Phone, the mode's width and height will be swapped when
    // the device is in a landscape (non-portrait) mode.
    switch (DisplayProperties::CurrentOrientation) {
        case DisplayOrientations::Landscape:
        case DisplayOrientations::LandscapeFlipped:
        {
            const int tmp = mode->h;
            mode->h = mode->w;
            mode->w = tmp;
            break;
        }
        default:
            break;
    }
#endif
    return 0;
}
int
WINRT_DuplicateDisplayMode(SDL_DisplayMode * dest, const SDL_DisplayMode * src)
{
    SDL_DisplayModeData * driverdata;
    driverdata = (SDL_DisplayModeData *) SDL_malloc(sizeof(*driverdata));
    if (!driverdata) {
        return SDL_OutOfMemory();
    }
    SDL_memcpy(driverdata, src->driverdata, sizeof(SDL_DisplayModeData));
    SDL_memcpy(dest, src, sizeof(SDL_DisplayMode));
    dest->driverdata = driverdata;
    return 0;
}
int
WINRT_InitModes(_THIS)
{
    // Retrieve the display mode:
    SDL_DisplayMode mode, desktop_mode;
    if (WINRT_CalcDisplayModeUsingNativeWindow(&mode) != 0) {
        return -1;    // If WINRT_CalcDisplayModeUsingNativeWindow fails, it'll already have set the SDL error
    }
    if (WINRT_DuplicateDisplayMode(&desktop_mode, &mode) != 0) {
        return -1;
    }
    if (SDL_AddBasicVideoDisplay(&desktop_mode) < 0) {
        return -1;
    }
    SDL_AddDisplayMode(&_this->displays[0], &mode);
    return 0;
}
static int
WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
    return 0;
}
void
WINRT_VideoQuit(_THIS)
{
    WINRT_QuitMouse(_this);
}
int
WINRT_CreateWindow(_THIS, SDL_Window * window)
{
    // Make sure that only one window gets created, at least until multimonitor
    // support is added.
    if (WINRT_GlobalSDLWindow != NULL) {
        SDL_SetError("WinRT only supports one window");
        return -1;
    }
    SDL_WindowData *data = new SDL_WindowData;
    if (!data) {
        SDL_OutOfMemory();
        return -1;
    }
    window->driverdata = data;
    data->sdlWindow = window;
    /* To note, when XAML support is enabled, access to the CoreWindow will not
       be possible, at least not via the SDL/XAML thread.  Attempts to access it
       from there will throw exceptions.  As such, the SDL_WindowData's
       'coreWindow' field will only be set (to a non-null value) if XAML isn't
       enabled.
    */
    if (!WINRT_XAMLWasEnabled) {
        data->coreWindow = CoreWindow::GetForCurrentThread();
    }
#if SDL_VIDEO_OPENGL_EGL
    /* Setup the EGL surface, but only if OpenGL ES 2 was requested. */
    if (!(window->flags & SDL_WINDOW_OPENGL)) {
        /* OpenGL ES 2 wasn't requested.  Don't set up an EGL surface. */
        data->egl_surface = EGL_NO_SURFACE;
    } else {
        /* OpenGL ES 2 was reuqested.  Set up an EGL surface. */
        /* HACK: ANGLE/WinRT currently uses non-pointer, C++ objects to represent
           native windows.  The object only contains a single pointer to a COM
           interface pointer, which on x86 appears to be castable to the object
           without apparant problems.  On other platforms, notable ARM and x64,
           doing so will cause a crash.  To avoid this crash, we'll bypass
           SDL's normal call to eglCreateWindowSurface, which is invoked from C
           code, and call it here, where an appropriate C++ object may be
           passed in.
         */
        typedef EGLSurface (*eglCreateWindowSurfaceFunction)(EGLDisplay dpy, EGLConfig config,
            Microsoft::WRL::ComPtr<IUnknown> win,
            const EGLint *attrib_list);
        eglCreateWindowSurfaceFunction WINRT_eglCreateWindowSurface =
            (eglCreateWindowSurfaceFunction) _this->egl_data->eglCreateWindowSurface;
        Microsoft::WRL::ComPtr<IUnknown> nativeWindow = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
        data->egl_surface = WINRT_eglCreateWindowSurface(
            _this->egl_data->egl_display,
            _this->egl_data->egl_config,
            nativeWindow, NULL);
        if (data->egl_surface == NULL) {
            // TODO, WinRT: see if eglCreateWindowSurface, or its callee(s), sets an error message.  If so, attach it to the SDL error.
            return SDL_SetError("eglCreateWindowSurface failed");
        }
    }
#endif
    /* Make sure the window is considered to be positioned at {0,0},
       and is considered fullscreen, shown, and the like.
    */
    window->x = 0;
    window->y = 0;
    window->flags =
        SDL_WINDOW_FULLSCREEN |
        SDL_WINDOW_SHOWN |
        SDL_WINDOW_BORDERLESS |
        SDL_WINDOW_MAXIMIZED |
        SDL_WINDOW_INPUT_GRABBED;
#if SDL_VIDEO_OPENGL_EGL
    if (data->egl_surface) {
        window->flags |= SDL_WINDOW_OPENGL;
    }
#endif
    /* WinRT does not, as of this writing, appear to support app-adjustable
       window sizes.  Set the window size to whatever the native WinRT
       CoreWindow is set at.
       TODO, WinRT: if and when non-fullscreen XAML control support is added to SDL, consider making those resizable via SDL_Window's interfaces.
    */
    window->w = _this->displays[0].current_mode.w;
    window->h = _this->displays[0].current_mode.h;
    /* For now, treat WinRT apps as if they always have focus.
       TODO, WinRT: try tracking keyboard and mouse focus state with respect to snapped apps
     */
    SDL_SetMouseFocus(window);
    SDL_SetKeyboardFocus(window);
    /* Make sure the WinRT app's IFramworkView can post events on
       behalf of SDL:
    */
    WINRT_GlobalSDLWindow = window;
    /* All done! */
    return 0;
}
void
WINRT_DestroyWindow(_THIS, SDL_Window * window)
{
    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
    if (WINRT_GlobalSDLWindow == window) {
        WINRT_GlobalSDLWindow = NULL;
    }
    if (data) {
        // Delete the internal window data:
        delete data;
        data = NULL;
    }
}
SDL_bool
WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
{
    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
    if (info->version.major <= SDL_MAJOR_VERSION) {
        info->subsystem = SDL_SYSWM_WINRT;
        info->info.winrt.window = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
        return SDL_TRUE;
    } else {
        SDL_SetError("Application not compiled with SDL %d.%d\n",
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
        return SDL_FALSE;
    }
    return SDL_FALSE;
}
#endif /* SDL_VIDEO_DRIVER_WINRT */
/* vi: set ts=4 sw=4 expandtab: */
source/src/video/winrt/SDL_winrtvideo_cpp.h
New file
@@ -0,0 +1,79 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.
  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:
  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.
*/
/* Windows includes: */
#include <windows.h>
#ifdef __cplusplus_winrt
#include <agile.h>
#endif
/* SDL includes: */
#include "SDL_video.h"
#include "SDL_events.h"
extern "C" {
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"
}
/* The global, WinRT, SDL Window.
   For now, SDL/WinRT only supports one window (due to platform limitations of
   WinRT.
*/
extern SDL_Window * WINRT_GlobalSDLWindow;
/* The global, WinRT, video device. */
extern SDL_VideoDevice * WINRT_GlobalSDLVideoDevice;
/* Creates a display mode for Plain Direct3D (non-XAML) apps, using the lone, native window's settings.
   Pass in an allocated SDL_DisplayMode field to store the data in.
   This function will return 0 on success, -1 on failure.
   If this function succeeds, be sure to call SDL_free on the
   SDL_DisplayMode's driverdata field.
*/
extern int WINRT_CalcDisplayModeUsingNativeWindow(SDL_DisplayMode * mode);
/* Duplicates a display mode, copying over driverdata as necessary */
extern int WINRT_DuplicateDisplayMode(SDL_DisplayMode * dest, const SDL_DisplayMode * src);
/* Display mode internals */
typedef struct
{
    Windows::Graphics::Display::DisplayOrientations currentOrientation;
} SDL_DisplayModeData;
#ifdef __cplusplus_winrt
/* Internal window data */
struct SDL_WindowData
{
    SDL_Window *sdlWindow;
    Platform::Agile<Windows::UI::Core::CoreWindow> coreWindow;
#ifdef SDL_VIDEO_OPENGL_EGL
    EGLSurface egl_surface;
#endif
};
#endif // ifdef __cplusplus_winrt
source/test/loopwave.c
@@ -79,6 +79,7 @@
main(int argc, char *argv[])
{
    int i;
    char filename[4096];
    /* Enable standard application logging */
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
@@ -89,11 +90,13 @@
        return (1);
    }
    if (argv[1] == NULL) {
        argv[1] = "sample.wav";
    if (argc >= 1) {
        SDL_strlcpy(filename, argv[1], sizeof(filename));
    } else {
        SDL_strlcpy(filename, "sample.wav", sizeof(filename));
    }
    /* Load the wave file into memory */
    if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
    if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
        quit(1);
    }
source/test/testautomation_platform.c
@@ -283,6 +283,7 @@
 */
int platform_testGetSetClearError(void *arg)
{
   int result;
   const char *testError = "Testing";
   char *lastError;
   int len;
@@ -301,8 +302,9 @@
             "SDL_GetError(): no message expected, len: %i", len);
   }
   SDL_SetError("%s", testError);
   result = SDL_SetError("%s", testError);
   SDLTest_AssertPass("SDL_SetError()");
   SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
   lastError = (char *)SDL_GetError();
   SDLTest_AssertCheck(lastError != NULL,
             "SDL_GetError() != NULL");
@@ -333,12 +335,14 @@
 */
int platform_testSetErrorEmptyInput(void *arg)
{
   int result;
   const char *testError = "";
   char *lastError;
   int len;
   SDL_SetError("%s", testError);
   result = SDL_SetError("%s", testError);
   SDLTest_AssertPass("SDL_SetError()");
   SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
   lastError = (char *)SDL_GetError();
   SDLTest_AssertCheck(lastError != NULL,
             "SDL_GetError() != NULL");
@@ -369,7 +373,8 @@
 */
int platform_testSetErrorInvalidInput(void *arg)
{
   const char *testError = NULL;
   int result;
   const char *invalidError = NULL;
   const char *probeError = "Testing";
   char *lastError;
   int len;
@@ -379,8 +384,9 @@
   SDLTest_AssertPass("SDL_ClearError()");
   /* Check for no-op */
   SDL_SetError(testError);
   result = SDL_SetError(invalidError);
   SDLTest_AssertPass("SDL_SetError()");
   SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
   lastError = (char *)SDL_GetError();
   SDLTest_AssertCheck(lastError != NULL,
             "SDL_GetError() != NULL");
@@ -397,12 +403,14 @@
   }
   /* Set */
   SDL_SetError(probeError);
   result = SDL_SetError(probeError);
   SDLTest_AssertPass("SDL_SetError()");
   SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
   /* Check for no-op */
   SDL_SetError(testError);
   result = SDL_SetError(invalidError);
   SDLTest_AssertPass("SDL_SetError()");
   SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
   lastError = (char *)SDL_GetError();
   SDLTest_AssertCheck(lastError != NULL,
             "SDL_GetError() != NULL");
@@ -419,6 +427,30 @@
             lastError);
   }
   /* Reset */
   SDL_ClearError();
   SDLTest_AssertPass("SDL_ClearError()");
   /* Set and check */
   result = SDL_SetError(probeError);
   SDLTest_AssertPass("SDL_SetError()");
   SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result);
   lastError = (char *)SDL_GetError();
   SDLTest_AssertCheck(lastError != NULL,
             "SDL_GetError() != NULL");
   if (lastError != NULL)
   {
     len = SDL_strlen(lastError);
     SDLTest_AssertCheck(len == SDL_strlen(probeError),
             "SDL_GetError(): expected message len %i, was len: %i",
             SDL_strlen(probeError),
             len);
     SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0,
             "SDL_GetError(): expected message '%s', was message: '%s'",
             probeError,
             lastError);
   }
   /* Clean up */
   SDL_ClearError();
   SDLTest_AssertPass("SDL_ClearError()");
source/test/testautomation_sdltest.c
@@ -21,6 +21,39 @@
/* Test case functions */
/* Forward declarations for internal harness functions */
extern char *SDLTest_GenerateRunSeed(const int length);
/**
 * @brief Calls to SDLTest_GenerateRunSeed()
 */
int
sdltest_generateRunSeed(void *arg)
{
  char* result;
  int i, l;
  for (i = 1; i <= 10; i += 3) {
     result = SDLTest_GenerateRunSeed((const int)i);
     SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
     SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL");
     if (result != NULL) {
       l = SDL_strlen(result);
       SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", i, l);
       SDL_free(result);
     }
  }
  /* Negative cases */
  for (i = -2; i <= 0; i++) {
     result = SDLTest_GenerateRunSeed((const int)i);
     SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()");
     SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL");
  }
  return TEST_COMPLETED;
}
/**
 * @brief Calls to SDLTest_GetFuzzerInvocationCount()
 */
@@ -1263,11 +1296,14 @@
static const SDLTest_TestCaseReference sdltestTest14 =
        { (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED };
static const SDLTest_TestCaseReference sdltestTest15 =
        { (SDLTest_TestCaseFp)sdltest_generateRunSeed, "sdltest_generateRunSeed", "Checks internal harness function SDLTest_GenerateRunSeed", TEST_ENABLED };
/* Sequence of SDL_test test cases */
static const SDLTest_TestCaseReference *sdltestTests[] =  {
    &sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6,
    &sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12,
    &sdltestTest13, &sdltestTest14, NULL
    &sdltestTest13, &sdltestTest14, &sdltestTest15, NULL
};
/* SDL_test test suite (global) */