WinRT: Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main.
authorDavid Ludwig <dludwig@pobox.com>
Tue, 24 Oct 2017 13:21:11 -0400
changeset 11661bd1495ebc979
parent 11660 2119394cbc86
child 11662 a996f135cc81
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
src/main/winrt/SDL_winrt_main_NonXAML.cpp
     1.1 --- a/src/core/winrt/SDL_winrtapp_common.cpp	Sun Oct 29 21:09:09 2017 -0700
     1.2 +++ b/src/core/winrt/SDL_winrtapp_common.cpp	Tue Oct 24 13:21:11 2017 -0400
     1.3 @@ -24,6 +24,8 @@
     1.4  #include "SDL_winrtapp_direct3d.h"
     1.5  #include "SDL_winrtapp_xaml.h"
     1.6  
     1.7 +#include <wrl.h>
     1.8 +
     1.9  int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
    1.10  
    1.11  extern "C" DECLSPEC int
    1.12 @@ -32,6 +34,9 @@
    1.13      if (xamlBackgroundPanel) {
    1.14          return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
    1.15      } else {
    1.16 +        if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) {
    1.17 +            return 1;
    1.18 +        }
    1.19          return SDL_WinRTInitNonXAMLApp(mainFunction);
    1.20      }
    1.21  }
     2.1 --- a/src/main/winrt/SDL_winrt_main_NonXAML.cpp	Sun Oct 29 21:09:09 2017 -0700
     2.2 +++ b/src/main/winrt/SDL_winrt_main_NonXAML.cpp	Tue Oct 24 13:21:11 2017 -0400
     2.3 @@ -50,10 +50,5 @@
     2.4  
     2.5  int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
     2.6  {
     2.7 -    if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) {
     2.8 -        return 1;
     2.9 -    }
    2.10 -
    2.11 -    SDL_WinRTRunApp(SDL_main, NULL);
    2.12 -    return 0;
    2.13 +    return SDL_WinRTRunApp(SDL_main, NULL);
    2.14  }