src/main/winrt/SDL_winrt_main.cpp
author David Ludwig <dludwig@pobox.com>
Mon, 16 Sep 2013 21:09:58 -0400
changeset 8528 38d0b62a215f
parent 8525 817a90b4704e
permissions -rw-r--r--
WinRT: reduced the size of SDL_winrt_main.cpp by a little bit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8355
f73480bf3e55 WinRT: pseudo-implemented SDLmain for WinRT. It has to be compiled directly into apps, for now.
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     1
8525
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
     2
#include <wrl.h>
8355
f73480bf3e55 WinRT: pseudo-implemented SDLmain for WinRT. It has to be compiled directly into apps, for now.
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     3
8525
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
     4
/* The app's C-style main will be passed into SDL.dll as a function
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
     5
   pointer, and called at the appropriate time.
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
     6
*/
8528
38d0b62a215f WinRT: reduced the size of SDL_winrt_main.cpp by a little bit
David Ludwig <dludwig@pobox.com>
parents: 8525
diff changeset
     7
extern __declspec(dllimport) int SDL_WinRT_RunApplication(int (*)(int, char **));
8355
f73480bf3e55 WinRT: pseudo-implemented SDLmain for WinRT. It has to be compiled directly into apps, for now.
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     8
extern "C" int SDL_main(int, char **);
f73480bf3e55 WinRT: pseudo-implemented SDLmain for WinRT. It has to be compiled directly into apps, for now.
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     9
8525
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    10
/* Prevent MSVC++ from warning about threading models when defining our
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    11
   custom WinMain.  The threading model will instead be set via a direct
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    12
   call to Windows::Foundation::Initialize (rather than via an attributed
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    13
   function).
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    14
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    15
   To note, this warning (C4447) does not seem to come up unless this file
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    16
   is compiled with C++/CX enabled (via the /ZW compiler flag).
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    17
*/
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    18
#ifdef _MSC_VER
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    19
#pragma warning(disable:4447)
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    20
#endif
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    21
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    22
/* Make sure the function to initialize the Windows Runtime gets linked in. */
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    23
#ifdef _MSC_VER
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    24
#pragma comment(lib, "runtimeobject.lib")
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    25
#endif
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    26
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    27
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
8355
f73480bf3e55 WinRT: pseudo-implemented SDLmain for WinRT. It has to be compiled directly into apps, for now.
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    28
{
8525
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    29
    if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) {
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    30
        return 1;
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    31
    }
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    32
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    33
    SDL_WinRT_RunApplication(SDL_main);
817a90b4704e WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag)
David Ludwig <dludwig@pobox.com>
parents: 8502
diff changeset
    34
    return 0;
8355
f73480bf3e55 WinRT: pseudo-implemented SDLmain for WinRT. It has to be compiled directly into apps, for now.
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    35
}