Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
WinRT: more minor code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLudwig committed Feb 23, 2013
1 parent 8971883 commit f5013bf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
50 changes: 28 additions & 22 deletions src/video/windowsrt/SDL_WinRTApp.cpp
Expand Up @@ -49,6 +49,34 @@ static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
// SDL_CreateWindow().
SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;

ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
{
public:
virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
};

IFrameworkView^ SDLApplicationSource::CreateView()
{
// TODO, WinRT: see if this function (CreateView) can ever get called
// more than once. For now, just prevent it from ever assigning
// SDL_WinRTGlobalApp more than once.
SDL_assert(!SDL_WinRTGlobalApp);
SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
if (!SDL_WinRTGlobalApp)
{
SDL_WinRTGlobalApp = app;
}
return app;
}

__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
{
SDL_WinRT_main = mainFunction;
auto direct3DApplicationSource = ref new SDLApplicationSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
}

static void WINRT_SetDisplayOrientationsPreference(const char *name, const char *oldValue, const char *newValue)
{
SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
Expand Down Expand Up @@ -859,25 +887,3 @@ void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
{
m_sdlVideoDevice = videoDevice;
}

IFrameworkView^ Direct3DApplicationSource::CreateView()
{
// TODO, WinRT: see if this function (CreateView) can ever get called
// more than once. For now, just prevent it from ever assigning
// SDL_WinRTGlobalApp more than once.
SDL_assert(!SDL_WinRTGlobalApp);
SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
if (!SDL_WinRTGlobalApp)
{
SDL_WinRTGlobalApp = app;
}
return app;
}

__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
{
SDL_WinRT_main = mainFunction;
auto direct3DApplicationSource = ref new Direct3DApplicationSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
}
9 changes: 0 additions & 9 deletions src/video/windowsrt/SDL_WinRTApp.h
Expand Up @@ -2,9 +2,6 @@

#include "SDLmain_WinRT_common.h"
#include "SDL_winrtvideo.h"
#include <vector>

using namespace Windows::UI::Core;

ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
{
Expand Down Expand Up @@ -53,9 +50,3 @@ ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFramewo
const SDL_VideoDevice* m_sdlVideoDevice;
bool m_useRelativeMouseMode;
};

ref class Direct3DApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
{
public:
virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
};
1 change: 1 addition & 0 deletions src/video/windowsrt/SDL_winrtmouse.cpp
Expand Up @@ -32,6 +32,7 @@ extern "C" {
#include "SDL_WinRTApp.h"
#include "SDL_winrtmouse.h"

using namespace Windows::UI::Core;
using Windows::UI::Core::CoreCursor;

extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
Expand Down
2 changes: 2 additions & 0 deletions src/video/windowsrt/SDL_winrtvideo.cpp
Expand Up @@ -43,6 +43,8 @@ extern "C" {
#include "SDL_winrtevents_c.h"
#include "SDL_winrtmouse.h"

using namespace Windows::UI::Core;

/* On Windows, windows.h defines CreateWindow */
#ifdef CreateWindow
#undef CreateWindow
Expand Down

0 comments on commit f5013bf

Please sign in to comment.