From 0e032d58606a4ab01b38483b894b20d6de930a2b Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Tue, 24 Oct 2017 13:21:11 -0400 Subject: [PATCH] WinRT: Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main. This allows C# UWP applications to use SDL2's SDL_WinRTRunApp function. Kudos to Ethan Lee (flibitijibibo@flibitijibibo.com) for the patch. Thanks! --- src/core/winrt/SDL_winrtapp_common.cpp | 5 +++++ src/main/winrt/SDL_winrt_main_NonXAML.cpp | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/winrt/SDL_winrtapp_common.cpp b/src/core/winrt/SDL_winrtapp_common.cpp index 408f98db2..3ee0be32f 100644 --- a/src/core/winrt/SDL_winrtapp_common.cpp +++ b/src/core/winrt/SDL_winrtapp_common.cpp @@ -24,6 +24,8 @@ #include "SDL_winrtapp_direct3d.h" #include "SDL_winrtapp_xaml.h" +#include + int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL; extern "C" DECLSPEC int @@ -32,6 +34,9 @@ SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel) if (xamlBackgroundPanel) { return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel); } else { + if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) { + return 1; + } return SDL_WinRTInitNonXAMLApp(mainFunction); } } diff --git a/src/main/winrt/SDL_winrt_main_NonXAML.cpp b/src/main/winrt/SDL_winrt_main_NonXAML.cpp index ce5e82473..19d22504c 100644 --- a/src/main/winrt/SDL_winrt_main_NonXAML.cpp +++ b/src/main/winrt/SDL_winrt_main_NonXAML.cpp @@ -50,10 +50,5 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { - if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) { - return 1; - } - - SDL_WinRTRunApp(SDL_main, NULL); - return 0; + return SDL_WinRTRunApp(SDL_main, NULL); }