diff --git a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj
index 53171dbd4..cc5fddd7b 100644
--- a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj
+++ b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj
@@ -97,6 +97,14 @@
+
+ true
+ true
+ true
+ true
+ true
+ true
+
@@ -277,6 +285,7 @@
+
diff --git a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters
index f24a448d3..fb3195f91 100644
--- a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters
+++ b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters
@@ -280,6 +280,9 @@
Source Files
+
+ Source Files
+
@@ -636,6 +639,9 @@
Source Files
+
+ Source Files
+
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index caa875599..58673d465 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -22,18 +22,6 @@
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
-#ifdef __WINRT__
-#include
-#include
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-#include
-#endif
-
-using namespace Windows::UI::Core;
-using namespace Windows::Graphics::Display;
-#endif /* __WINRT__ */
-
#define COBJMACROS
#include "../../core/windows/SDL_windows.h"
#include "SDL_hints.h"
@@ -45,6 +33,19 @@ using namespace Windows::Graphics::Display;
#include
+#ifdef __WINRT__
+
+#include "SDL_render_d3d11_winrthelpers_cpp.h"
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+#include
+/* 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; }
@@ -960,10 +961,11 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
D3D11_SAMPLER_DESC samplerDesc;
D3D11_RASTERIZER_DESC rasterDesc;
-#ifdef __WINRT__
- CreateDXGIFactoryFunc = CreateDXGIFactory;
- D3D11CreateDeviceFunc = D3D11CreateDevice;
-#else
+ // 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
data->hDXGIMod = SDL_LoadObject("dxgi.dll");
if (!data->hDXGIMod) {
result = E_FAIL;
@@ -987,7 +989,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
result = E_FAIL;
goto done;
}
-#endif /* __WINRT__ */
+//#endif /* __WINRT__ */
result = CreateDXGIFactoryFunc(&IID_IDXGIFactory2, &data->dxgiFactory);
if (FAILED(result)) {
@@ -1269,79 +1271,7 @@ done:
return result;
}
-#ifdef __WINRT__
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */
-extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative;
-#endif
-
-static IUnknown *
-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;
-}
-
-static DXGI_MODE_ROTATION
-D3D11_GetCurrentRotation()
-{
- switch (DisplayProperties::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 */
-
- default:
- return DXGI_MODE_ROTATION_UNSPECIFIED;
- }
-}
-
-#else
+#ifdef __WIN32__
static DXGI_MODE_ROTATION
D3D11_GetCurrentRotation()
@@ -1350,7 +1280,7 @@ D3D11_GetCurrentRotation()
return DXGI_MODE_ROTATION_IDENTITY;
}
-#endif /* __WINRT__ */
+#endif /* __WIN32__ */
static BOOL
D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation)
@@ -1460,7 +1390,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
}
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
- result = WINRT_GlobalSwapChainBackgroundPanelNative->SetSwapChain(data->swapChain);
+ result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *) data->swapChain);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ISwapChainBackgroundPanelNative::SetSwapChain", result);
goto done;
@@ -1471,6 +1401,7 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
goto done;
#endif
} else {
+#ifdef __WIN32__
SDL_SysWMinfo windowinfo;
SDL_VERSION(&windowinfo.version);
SDL_GetWindowWMInfo(renderer->window, &windowinfo);
@@ -1487,6 +1418,10 @@ D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h)
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;
@@ -2379,7 +2314,7 @@ static void
D3D11_RenderSetBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode)
{
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
- ID3D11BlendState *blendState;
+ ID3D11BlendState *blendState = NULL;
switch (blendMode) {
case SDL_BLENDMODE_BLEND:
blendState = rendererData->blendModeBlend;
diff --git a/src/render/direct3d11/SDL_render_d3d11_winrthelpers.cpp b/src/render/direct3d11/SDL_render_d3d11_winrthelpers.cpp
new file mode 100644
index 000000000..25e6765e9
--- /dev/null
+++ b/src/render/direct3d11/SDL_render_d3d11_winrthelpers.cpp
@@ -0,0 +1,109 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ 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
+#include
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+#include
+#endif
+
+using namespace Windows::UI::Core;
+using namespace Windows::Graphics::Display;
+
+
+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()
+{
+ switch (DisplayProperties::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 */
+
+ default:
+ return DXGI_MODE_ROTATION_UNSPECIFIED;
+ }
+}
+
+
+#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/direct3d11/SDL_render_d3d11_winrthelpers_cpp.h b/src/render/direct3d11/SDL_render_d3d11_winrthelpers_cpp.h
new file mode 100644
index 000000000..19df2a20c
--- /dev/null
+++ b/src/render/direct3d11/SDL_render_d3d11_winrthelpers_cpp.h
@@ -0,0 +1,40 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ 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: */