diff --git a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj index a9fd5460c..a78608bdb 100644 --- a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj +++ b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj @@ -53,6 +53,7 @@ true true + @@ -68,6 +69,7 @@ + diff --git a/include/SDL_config_windowsrt.h b/include/SDL_config_windowsrt.h index e0a16b22d..3223ca261 100644 --- a/include/SDL_config_windowsrt.h +++ b/include/SDL_config_windowsrt.h @@ -146,9 +146,7 @@ typedef unsigned int uintptr_t; #define SDL_JOYSTICK_DISABLED 1 /* Enable various shared object loading systems */ -// TODO, WinRT: adapt the Win32 shared object loading code for WinRT -#define SDL_LOADSO_DISABLED 1 -//#define SDL_LOADSO_WINDOWS 1 +#define SDL_LOADSO_WINDOWS 1 /* Enable various threading systems */ #define SDL_THREAD_STDCPP 1 diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 4103d98d8..cd8a0d088 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -20,12 +20,12 @@ */ #include "SDL_config.h" -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINRT__) #include "SDL_error.h" #include "SDL_windows.h" -#include /* for CoInitialize/CoUninitialize */ +#include /* for CoInitialize/CoUninitialize (Win32 only) */ /* Sets an error message based on GetLastError() */ @@ -44,6 +44,14 @@ WIN_SetError(const char *prefix) HRESULT WIN_CoInitialize(void) { +#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 const HRESULT hr = CoInitialize(NULL); /* S_FALSE means success, but someone else already initialized. */ @@ -53,12 +61,15 @@ WIN_CoInitialize(void) } return hr; +#endif } void WIN_CoUninitialize(void) { +#ifndef __WINRT__ CoUninitialize(); +#endif } #endif /* __WIN32__ */ diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index f07752cb8..e0a459499 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -33,7 +33,15 @@ void * 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 */