diff --git a/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj index 4eaeca36b..12c724dde 100644 --- a/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj +++ b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj @@ -62,7 +62,7 @@ - _USRDLL;UNICODE;%(PreprocessorDefinitions) + _USRDLL;UNICODE;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) NotUsing pch.h false @@ -75,12 +75,12 @@ false false true - d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) + DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) - _USRDLL;UNICODE;NDEBUG;%(PreprocessorDefinitions) + _USRDLL;UNICODE;SDL_BUILDING_WINRT=1;NDEBUG;%(PreprocessorDefinitions) NotUsing pch.h false @@ -92,12 +92,12 @@ false false true - d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) + DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) - _USRDLL;UNICODE;%(PreprocessorDefinitions) + _USRDLL;UNICODE;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) NotUsing pch.h false @@ -110,12 +110,12 @@ false false true - d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) + DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) - _USRDLL;UNICODE;NDEBUG;%(PreprocessorDefinitions) + _USRDLL;UNICODE;SDL_BUILDING_WINRT=1;NDEBUG;%(PreprocessorDefinitions) NotUsing pch.h false @@ -127,7 +127,7 @@ false false true - d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) + DXGI.lib;d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies) @@ -201,6 +201,9 @@ + + + @@ -215,7 +218,9 @@ + + @@ -289,6 +294,7 @@ true + @@ -311,12 +317,16 @@ - + + + + true true true true + diff --git a/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters index 9535fe759..4c8d7d485 100644 --- a/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters +++ b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters @@ -339,6 +339,21 @@ Header Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -572,9 +587,6 @@ Source Files - - Source Files - Source Files @@ -608,5 +620,23 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + \ No newline at end of file diff --git a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj index cc5fddd7b..c864a97d1 100644 --- a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj +++ b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj @@ -72,6 +72,7 @@ true + @@ -96,6 +97,8 @@ + + true @@ -107,6 +110,7 @@ + @@ -270,6 +274,9 @@ + + + @@ -289,6 +296,7 @@ + @@ -426,7 +434,7 @@ NotUsing false ..\..\include;%(AdditionalIncludeDirectories) - _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) Console @@ -440,7 +448,7 @@ NotUsing false ..\..\include;%(AdditionalIncludeDirectories) - _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) Console @@ -454,7 +462,7 @@ NotUsing false ..\..\include;%(AdditionalIncludeDirectories) - _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) Console @@ -468,7 +476,7 @@ NotUsing false ..\..\include;%(AdditionalIncludeDirectories) - _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) Console @@ -482,7 +490,7 @@ NotUsing false ..\..\include;%(AdditionalIncludeDirectories) - _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) Console @@ -496,7 +504,7 @@ NotUsing false ..\..\include;%(AdditionalIncludeDirectories) - _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) Console diff --git a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters index fb3195f91..108cc86b4 100644 --- a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters +++ b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters @@ -283,6 +283,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -642,6 +654,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + diff --git a/include/SDL_config_winrt.h b/include/SDL_config_winrt.h index 2d9258132..78b43ab64 100644 --- a/include/SDL_config_winrt.h +++ b/include/SDL_config_winrt.h @@ -180,8 +180,7 @@ typedef unsigned int uintptr_t; #endif /* Enable system power support */ -// TODO, WinRT: investigate system power support. The Win32-based APIs don't work on WinRT. -#define SDL_POWER_DISABLED 1 +#define SDL_POWER_WINRT 1 /* Enable assembly routines (Win64 doesn't have inline asm) */ #ifndef _WIN64 diff --git a/src/core/winrt/SDL_winrtapp_xaml.cpp b/src/core/winrt/SDL_winrtapp_xaml.cpp index 67a5cddea..7fe3b822e 100644 --- a/src/core/winrt/SDL_winrtapp_xaml.cpp +++ b/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -42,7 +42,7 @@ SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE; #if WINAPI_FAMILY == WINAPI_FAMILY_APP -ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL; +extern "C" ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL; static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; #endif diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index 3752de1c5..d318552f0 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/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 diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index 0e30f9037..10f8355f4 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -37,6 +37,7 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *, int *, int *); 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 @@ static SDL_GetPowerInfo_Impl implementations[] = { #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, diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 58673d465..2f683b2ca 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -961,11 +961,10 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) D3D11_SAMPLER_DESC samplerDesc; D3D11_RASTERIZER_DESC rasterDesc; - // TODO, WinRT, Mar 11, 2014: once SDL/WinRT is back up and running, see if D3D11 init functions are loadable (via LoadPackagedLibrary/SDL_LoadObject, etc.) -//#ifdef __WINRT__ -// CreateDXGIFactoryFunc = CreateDXGIFactory; -// D3D11CreateDeviceFunc = D3D11CreateDevice; -//#else +#ifdef __WINRT__ + CreateDXGIFactoryFunc = CreateDXGIFactory1; + D3D11CreateDeviceFunc = D3D11CreateDevice; +#else data->hDXGIMod = SDL_LoadObject("dxgi.dll"); if (!data->hDXGIMod) { result = E_FAIL; @@ -989,7 +988,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer) result = E_FAIL; goto done; } -//#endif /* __WINRT__ */ +#endif /* __WINRT__ */ result = CreateDXGIFactoryFunc(&IID_IDXGIFactory2, &data->dxgiFactory); if (FAILED(result)) { @@ -2833,6 +2832,11 @@ D3D11_RenderPresent(SDL_Renderer * renderer) 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; @@ -2841,9 +2845,6 @@ D3D11_RenderPresent(SDL_Renderer * renderer) presentFlags = DXGI_PRESENT_DO_NOT_WAIT; } -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP - result = IDXGISwapChain_Present(data->swapChain, syncInterval, presentFlags); -#else /* 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. diff --git a/src/render/direct3d11/SDL_render_d3d11_winrthelpers.cpp b/src/render/direct3d11/SDL_render_d3d11_winrthelpers.cpp index 25e6765e9..78d99123a 100644 --- a/src/render/direct3d11/SDL_render_d3d11_winrthelpers.cpp +++ b/src/render/direct3d11/SDL_render_d3d11_winrthelpers.cpp @@ -37,6 +37,8 @@ extern "C" { using namespace Windows::UI::Core; using namespace Windows::Graphics::Display; +#include + extern "C" void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer) diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp index ac325039f..c652aabd0 100644 --- a/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/src/thread/stdcpp/SDL_sysmutex.cpp @@ -79,6 +79,21 @@ SDL_mutexP(SDL_mutex * mutex) } } +/* 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