mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-17 14:47:19 +01:00
WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
This commit is contained in:
parent
de8d9dbb93
commit
34722465d1
@ -197,8 +197,8 @@
|
||||
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
|
||||
<ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
|
||||
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
|
||||
<ClInclude Include="..\..\src\events\blank_cursor.h" />
|
||||
<ClInclude Include="..\..\src\events\default_cursor.h" />
|
||||
<ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
|
||||
@ -269,7 +269,13 @@
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
@ -281,12 +287,6 @@
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
|
||||
<ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
|
||||
<ClCompile Include="..\..\src\events\SDL_dropevents.c" />
|
||||
|
@ -321,24 +321,24 @@
|
||||
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\SDL_config_winrt.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\atomic\SDL_atomic.c">
|
||||
@ -581,9 +581,6 @@
|
||||
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -599,10 +596,13 @@
|
||||
<ClCompile Include="..\..\src\video\winrt\SDL_winrtkeyboard.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp">
|
||||
<ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
@ -47,7 +47,15 @@
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
@ -63,14 +71,6 @@
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
|
||||
<ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
|
||||
<ClCompile Include="..\..\src\events\SDL_dropevents.c" />
|
||||
@ -244,8 +244,8 @@
|
||||
<ClInclude Include="..\..\src\audio\SDL_wave.h" />
|
||||
<ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
|
||||
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h" />
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h" />
|
||||
<ClInclude Include="..\..\src\events\blank_cursor.h" />
|
||||
<ClInclude Include="..\..\src\events\default_cursor.h" />
|
||||
<ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
|
||||
|
@ -258,9 +258,6 @@
|
||||
<ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -273,7 +270,10 @@
|
||||
<ClCompile Include="..\..\src\video\winrt\SDL_winrtpointerinput.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtxaml.cpp">
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\winrt\SDL_winrtapp_xaml.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@ -593,21 +593,21 @@
|
||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtxaml_cpp.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\SDL_config_winrt.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_direct3d.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\winrt\SDL_winrtapp_xaml.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
|
@ -38,7 +38,7 @@ extern "C" {
|
||||
|
||||
#include "../../video/winrt/SDL_winrtevents_c.h"
|
||||
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||
#include "SDL_winrtapp.h"
|
||||
#include "SDL_winrtapp_direct3d.h"
|
||||
|
||||
|
||||
// Compile-time debugging options:
|
@ -32,7 +32,7 @@
|
||||
#include "SDL.h"
|
||||
#include "../../video/winrt/SDL_winrtevents_c.h"
|
||||
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||
#include "SDL_winrtxaml_cpp.h"
|
||||
#include "SDL_winrtapp_xaml.h"
|
||||
|
||||
|
||||
|
||||
@ -51,28 +51,28 @@ static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken;
|
||||
*/
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
|
||||
static void
|
||||
WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
static void
|
||||
WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
}
|
||||
|
||||
static void
|
||||
WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
static void
|
||||
WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
}
|
||||
|
||||
static void
|
||||
WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
static void
|
||||
WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
}
|
||||
|
||||
static void
|
||||
WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
static void
|
||||
WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
|
||||
{
|
||||
WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
|
||||
}
|
||||
|
||||
#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
@ -128,7 +128,7 @@ SDL_WinRTInitXAMLApp(Platform::Object ^backgroundPanel, int (*mainFunction)(int,
|
||||
swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML);
|
||||
|
||||
// Setup for rendering:
|
||||
IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel);
|
||||
IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel);
|
||||
panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative);
|
||||
|
||||
WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler<Object^>(WINRT_OnRenderViaXAML));
|
@ -20,8 +20,8 @@
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_winrtxaml_h
|
||||
#define _SDL_winrtxaml_h
|
||||
#ifndef _SDL_winrtapp_xaml_h
|
||||
#define _SDL_winrtapp_xaml_h
|
||||
|
||||
#include "SDL_types.h"
|
||||
|
||||
@ -30,4 +30,4 @@ extern SDL_bool WINRT_XAMLWasEnabled;
|
||||
extern int (*WINRT_XAMLAppMainFunction)(int, char **);
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif // ifndef _SDL_winrtxaml_h
|
||||
#endif // ifndef _SDL_winrtapp_xaml_h
|
@ -33,8 +33,8 @@ using Windows::UI::Core::CoreCursor;
|
||||
* SDL includes:
|
||||
*/
|
||||
#include "SDL_winrtevents_c.h"
|
||||
#include "../../core/winrt/SDL_winrtapp.h"
|
||||
#include "../../core/winrt/SDL_winrtxaml_cpp.h"
|
||||
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
|
||||
#include "../../core/winrt/SDL_winrtapp_xaml.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_system.h"
|
||||
|
||||
|
@ -42,7 +42,7 @@ extern "C" {
|
||||
#include "SDL_log.h"
|
||||
}
|
||||
|
||||
#include "../../core/winrt/SDL_winrtapp.h"
|
||||
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
|
||||
#include "SDL_winrtvideo_cpp.h"
|
||||
#include "SDL_winrtmouse_c.h"
|
||||
|
||||
|
@ -44,8 +44,8 @@ extern "C" {
|
||||
#include "SDL_syswm.h"
|
||||
}
|
||||
|
||||
#include "../../core/winrt/SDL_winrtapp.h"
|
||||
#include "../../core/winrt/SDL_winrtxaml_cpp.h"
|
||||
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
|
||||
#include "../../core/winrt/SDL_winrtapp_xaml.h"
|
||||
#include "SDL_winrtvideo_cpp.h"
|
||||
#include "SDL_winrtevents_c.h"
|
||||
#include "SDL_winrtmouse_c.h"
|
||||
@ -61,7 +61,7 @@ static void WINRT_VideoQuit(_THIS);
|
||||
|
||||
|
||||
/* Window functions */
|
||||
static int WINRT_CreateWindow(_THIS, SDL_Window * window);
|
||||
static int WINRT_CreateWindow(_THIS, SDL_Window * window);
|
||||
static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
|
||||
static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
|
||||
|
||||
@ -131,76 +131,76 @@ WINRT_VideoInit(_THIS)
|
||||
}
|
||||
WINRT_InitMouse(_this);
|
||||
WINRT_InitTouch(_this);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_DisplayMode
|
||||
WINRT_CalcDisplayModeUsingNativeWindow()
|
||||
{
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
// Create an empty, zeroed-out display mode:
|
||||
SDL_DisplayMode mode;
|
||||
SDL_zero(mode);
|
||||
|
||||
// Go no further if a native window cannot be accessed. This can happen,
|
||||
// for example, if this function is called from certain threads, such as
|
||||
// the SDL/XAML thread.
|
||||
if (!CoreWindow::GetForCurrentThread()) {
|
||||
return mode;
|
||||
}
|
||||
|
||||
// Fill in most fields:
|
||||
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
|
||||
mode.driverdata = (void *) DisplayProperties::CurrentOrientation;
|
||||
|
||||
// Calculate the display size given the window size, taking into account
|
||||
// the current display's DPI:
|
||||
const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
|
||||
const float dipsPerInch = 96.0f;
|
||||
mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
|
||||
mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
// On Windows Phone, the native window's size is always in portrait,
|
||||
// regardless of the device's orientation. This is in contrast to
|
||||
// Windows 8/RT, which will resize the native window as the device's
|
||||
// orientation changes. In order to compensate for this behavior,
|
||||
// on Windows Phone, the mode's width and height will be swapped when
|
||||
// the device is in a landscape (non-portrait) mode.
|
||||
switch (DisplayProperties::CurrentOrientation) {
|
||||
case DisplayOrientations::Landscape:
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
{
|
||||
const int tmp = mode.h;
|
||||
mode.h = mode.w;
|
||||
mode.w = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Attach the mode to te
|
||||
#endif
|
||||
|
||||
return mode;
|
||||
}
|
||||
SDL_DisplayMode
|
||||
WINRT_CalcDisplayModeUsingNativeWindow()
|
||||
{
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
// Create an empty, zeroed-out display mode:
|
||||
SDL_DisplayMode mode;
|
||||
SDL_zero(mode);
|
||||
|
||||
// Go no further if a native window cannot be accessed. This can happen,
|
||||
// for example, if this function is called from certain threads, such as
|
||||
// the SDL/XAML thread.
|
||||
if (!CoreWindow::GetForCurrentThread()) {
|
||||
return mode;
|
||||
}
|
||||
|
||||
// Fill in most fields:
|
||||
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
|
||||
mode.driverdata = (void *) DisplayProperties::CurrentOrientation;
|
||||
|
||||
// Calculate the display size given the window size, taking into account
|
||||
// the current display's DPI:
|
||||
const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
|
||||
const float dipsPerInch = 96.0f;
|
||||
mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
|
||||
mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
// On Windows Phone, the native window's size is always in portrait,
|
||||
// regardless of the device's orientation. This is in contrast to
|
||||
// Windows 8/RT, which will resize the native window as the device's
|
||||
// orientation changes. In order to compensate for this behavior,
|
||||
// on Windows Phone, the mode's width and height will be swapped when
|
||||
// the device is in a landscape (non-portrait) mode.
|
||||
switch (DisplayProperties::CurrentOrientation) {
|
||||
case DisplayOrientations::Landscape:
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
{
|
||||
const int tmp = mode.h;
|
||||
mode.h = mode.w;
|
||||
mode.w = tmp;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Attach the mode to te
|
||||
#endif
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
int
|
||||
WINRT_InitModes(_THIS)
|
||||
{
|
||||
// Retrieve the display mode:
|
||||
SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow();
|
||||
if (mode.w == 0 || mode.h == 0) {
|
||||
return SDL_SetError("Unable to calculate the WinRT window/display's size");
|
||||
}
|
||||
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
return -1;
|
||||
SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow();
|
||||
if (mode.w == 0 || mode.h == 0) {
|
||||
return SDL_SetError("Unable to calculate the WinRT window/display's size");
|
||||
}
|
||||
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||
@ -219,64 +219,64 @@ WINRT_VideoQuit(_THIS)
|
||||
WINRT_QuitMouse(_this);
|
||||
}
|
||||
|
||||
int
|
||||
WINRT_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
// Make sure that only one window gets created, at least until multimonitor
|
||||
// support is added.
|
||||
if (WINRT_GlobalSDLWindow != NULL) {
|
||||
SDL_SetError("WinRT only supports one window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_WindowData *data = new SDL_WindowData;
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
window->driverdata = data;
|
||||
data->sdlWindow = window;
|
||||
|
||||
/* To note, when XAML support is enabled, access to the CoreWindow will not
|
||||
be possible, at least not via the SDL/XAML thread. Attempts to access it
|
||||
from there will throw exceptions. As such, the SDL_WindowData's
|
||||
'coreWindow' field will only be set (to a non-null value) if XAML isn't
|
||||
enabled.
|
||||
*/
|
||||
if (!WINRT_XAMLWasEnabled) {
|
||||
data->coreWindow = CoreWindow::GetForCurrentThread();
|
||||
}
|
||||
|
||||
/* Make sure the window is considered to be positioned at {0,0},
|
||||
and is considered fullscreen, shown, and the like.
|
||||
*/
|
||||
window->x = 0;
|
||||
window->y = 0;
|
||||
window->flags =
|
||||
SDL_WINDOW_FULLSCREEN |
|
||||
SDL_WINDOW_SHOWN |
|
||||
SDL_WINDOW_BORDERLESS |
|
||||
SDL_WINDOW_MAXIMIZED |
|
||||
SDL_WINDOW_INPUT_GRABBED;
|
||||
|
||||
/* WinRT does not, as of this writing, appear to support app-adjustable
|
||||
window sizes. Set the window size to whatever the native WinRT
|
||||
CoreWindow is set at.
|
||||
|
||||
TODO, WinRT: if and when non-fullscreen XAML control support is added to SDL, consider making those resizable via SDL_Window's interfaces.
|
||||
*/
|
||||
window->w = _this->displays[0].current_mode.w;
|
||||
window->h = _this->displays[0].current_mode.h;
|
||||
|
||||
/* Make sure the WinRT app's IFramworkView can post events on
|
||||
behalf of SDL:
|
||||
*/
|
||||
WINRT_GlobalSDLWindow = window;
|
||||
|
||||
/* All done! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
WINRT_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
// Make sure that only one window gets created, at least until multimonitor
|
||||
// support is added.
|
||||
if (WINRT_GlobalSDLWindow != NULL) {
|
||||
SDL_SetError("WinRT only supports one window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_WindowData *data = new SDL_WindowData;
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
window->driverdata = data;
|
||||
data->sdlWindow = window;
|
||||
|
||||
/* To note, when XAML support is enabled, access to the CoreWindow will not
|
||||
be possible, at least not via the SDL/XAML thread. Attempts to access it
|
||||
from there will throw exceptions. As such, the SDL_WindowData's
|
||||
'coreWindow' field will only be set (to a non-null value) if XAML isn't
|
||||
enabled.
|
||||
*/
|
||||
if (!WINRT_XAMLWasEnabled) {
|
||||
data->coreWindow = CoreWindow::GetForCurrentThread();
|
||||
}
|
||||
|
||||
/* Make sure the window is considered to be positioned at {0,0},
|
||||
and is considered fullscreen, shown, and the like.
|
||||
*/
|
||||
window->x = 0;
|
||||
window->y = 0;
|
||||
window->flags =
|
||||
SDL_WINDOW_FULLSCREEN |
|
||||
SDL_WINDOW_SHOWN |
|
||||
SDL_WINDOW_BORDERLESS |
|
||||
SDL_WINDOW_MAXIMIZED |
|
||||
SDL_WINDOW_INPUT_GRABBED;
|
||||
|
||||
/* WinRT does not, as of this writing, appear to support app-adjustable
|
||||
window sizes. Set the window size to whatever the native WinRT
|
||||
CoreWindow is set at.
|
||||
|
||||
TODO, WinRT: if and when non-fullscreen XAML control support is added to SDL, consider making those resizable via SDL_Window's interfaces.
|
||||
*/
|
||||
window->w = _this->displays[0].current_mode.w;
|
||||
window->h = _this->displays[0].current_mode.h;
|
||||
|
||||
/* Make sure the WinRT app's IFramworkView can post events on
|
||||
behalf of SDL:
|
||||
*/
|
||||
WINRT_GlobalSDLWindow = window;
|
||||
|
||||
/* All done! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
WINRT_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
@ -293,21 +293,21 @@ WINRT_DestroyWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
{
|
||||
SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_WINRT;
|
||||
info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_FALSE;
|
||||
SDL_bool
|
||||
WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
{
|
||||
SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_WINRT;
|
||||
info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINRT */
|
||||
|
Loading…
Reference in New Issue
Block a user