src/main/winrt/SDL_winrt_main.cpp
author David Ludwig <dludwig@pobox.com>
Sun, 15 Sep 2013 23:53:51 -0400
changeset 8525 817a90b4704e
parent 8502 78d341895e9f
child 8528 38d0b62a215f
permissions -rw-r--r--
WinRT: made SDL_winrt_main.cpp not have to be compiled as C++/CX (via the /ZW compiler flag) This file can still be compiled as C++/CX, however that is now optional/not-required.
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
*/
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
     7
typedef int (*SDLmain_MainFunction)(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
     8
extern __declspec(dllimport) int SDL_WinRT_RunApplication(SDLmain_MainFunction mainFunction);
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
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
    10
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
    11
/* 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
    12
   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
    13
   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
    14
   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
    15
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
   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
    17
   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
    18
*/
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
#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
    20
#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
    21
#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
    22
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
/* 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
    24
#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
    25
#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
    26
#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
    27
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
    28
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
    29
{
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
    30
    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
    31
        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
    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
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
    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
    35
    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
    36
}