瀏覽代碼

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 ([email protected]) for the patch.  Thanks!
David Ludwig 8 年之前
父節點
當前提交
0e032d5860
共有 2 個文件被更改,包括 6 次插入6 次删除
  1. 5 0
      src/core/winrt/SDL_winrtapp_common.cpp
  2. 1 6
      src/main/winrt/SDL_winrt_main_NonXAML.cpp

+ 5 - 0
src/core/winrt/SDL_winrtapp_common.cpp

@@ -24,6 +24,8 @@
 #include "SDL_winrtapp_direct3d.h"
 #include "SDL_winrtapp_direct3d.h"
 #include "SDL_winrtapp_xaml.h"
 #include "SDL_winrtapp_xaml.h"
 
 
+#include <wrl.h>
+
 int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
 int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
 
 
 extern "C" DECLSPEC int
 extern "C" DECLSPEC int
@@ -32,6 +34,9 @@ SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel)
     if (xamlBackgroundPanel) {
     if (xamlBackgroundPanel) {
         return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
         return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
     } else {
     } else {
+        if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) {
+            return 1;
+        }
         return SDL_WinRTInitNonXAMLApp(mainFunction);
         return SDL_WinRTInitNonXAMLApp(mainFunction);
     }
     }
 }
 }

+ 1 - 6
src/main/winrt/SDL_winrt_main_NonXAML.cpp

@@ -50,10 +50,5 @@
 
 
 int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
 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);
 }
 }