Skip to content

Commit

Permalink
WinRT: added Win10/UWP (Universal Windows Platform) support
Browse files Browse the repository at this point in the history
"UWP" appears to be Microsoft's new name for WinRT/Windows-Store APIs.

This set of changes updates SDL's WinRT backends to support the Win10 flavor
of WinRT.  It has been tested on Win10 on a desktop.  In theory, it should
also support Win10 on other devices (phone, Xbox One, etc.), however further
patches may be necessary.

This adds:
- a set of MSVC 2015 project files, for use in creating UWP apps
- modifications to various pieces of SDL, in order to compile via MSVC 2015 +
  the Win10 API set
- enables SDL_Window resizing and programmatic-fullscreen toggling, when using
  the WinRT backend
- WinRT README updates
  • Loading branch information
DavidLudwig committed Nov 30, 2015
1 parent fa2d5ab commit 25abce5
Show file tree
Hide file tree
Showing 12 changed files with 1,762 additions and 57 deletions.
554 changes: 554 additions & 0 deletions VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj

Large diffs are not rendered by default.

720 changes: 720 additions & 0 deletions VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters

Large diffs are not rendered by default.

58 changes: 23 additions & 35 deletions docs/README-winrt.md
Expand Up @@ -10,6 +10,7 @@ primarily, via a Microsoft-run online store (of the same name).

Some of the operating systems that include WinRT, are:

* Windows 10, via its Universal Windows Platform (UWP) APIs
* Windows 8.x
* Windows RT 8.x (aka. Windows 8.x for ARM processors)
* Windows Phone 8.x
Expand All @@ -18,12 +19,12 @@ Some of the operating systems that include WinRT, are:
Requirements
------------

* Microsoft Visual C++ (aka Visual Studio), either 2013 or 2012 versions
* Microsoft Visual C++ (aka Visual Studio), either 2015, 2013, or 2012
- Free, "Community" or "Express" editions may be used, so long as they
include support for either "Windows Store" or "Windows Phone" apps.
"Express" versions marked as supporting "Windows Desktop" development
typically do not include support for creating WinRT apps, to note.
(The "Community" edition of Visual C++ 2013 does, however, support both
(The "Community" editions of Visual C++ do, however, support both
desktop/Win32 and WinRT development).
- Visual C++ 2012 can only build apps that target versions 8.0 of Windows,
or Windows Phone. 8.0-targetted apps will run on devices running 8.1
Expand All @@ -50,36 +51,29 @@ Status
Here is a rough list of what works, and what doens't:

* What works:
* compilation via Visual C++ 2012 and 2013
* compilation via Visual C++ 2012 through 2015
* compile-time platform detection for SDL programs. The C/C++ #define,
`__WINRT__`, will be set to 1 (by SDL) when compiling for WinRT.
* GPU-accelerated 2D rendering, via SDL_Renderer.
* OpenGL ES 2, via the ANGLE library (included separately from SDL)
* software rendering, via either SDL_Surface (optionally in conjunction with
SDL_GetWindowSurface() and SDL_UpdateWindowSurface()) or via the
SDL_Renderer APIs
* threads. Significant chunks of Win32's threading APIs are not available in
WinRT. A new, SDL threading backend was built using C++11's threading APIs
(std::thread, std::mutex, std::condition_variable, etc.), which C or C++
programs alike can access via SDL's threading APIs. Support for thread
priorities is not, however, currently available, due to restrictions in
WinRT's own API set.
* threads
* timers (via SDL_GetTicks(), SDL_AddTimer(), SDL_GetPerformanceCounter(),
SDL_GetPerformanceFrequency(), etc.)
* file I/O via SDL_RWops
* mouse input (unsupported on Windows Phone)
* audio, via a modified version of SDL's XAudio2 backend
* .DLL file loading. Libraries must be packaged inside applications. Loading
* .DLL file loading. Libraries *MUST* be packaged inside applications. Loading
anything outside of the app is not supported.
* system path retrieval via SDL's filesystem APIs
* game controllers. Support is provided via the SDL_Joystick and
SDL_GameController APIs, and is backed by Microsoft's XInput API.
* multi-touch input
* app events. SDL_APP_WILLENTER* and SDL_APP_DIDENTER* events get sent out as
appropriate.
* window events. SDL_WINDOWEVENT_MINIMIZED and SDL_WINDOWEVENT_RESTORED are
sent out on app suspend and resume, respectively. SDL_WINDOWEVENT_SHOWN and
SDL_WINDOWEVENT_HIDDEN are also sent, but not necessarily on app suspend or
resume, as WinRT treats these two concepts differently..
* window events
* using Direct3D 11.x APIs outside of SDL. Non-XAML / Direct3D-only apps can
choose to render content directly via Direct3D, using SDL to manage the
internal WinRT window, as well as input and audio. (Use
Expand All @@ -89,24 +83,13 @@ Here is a rough list of what works, and what doens't:
* What partially works:
* keyboard input. Most of WinRT's documented virtual keys are supported, as
well as many keys with documented hardware scancodes.
* OpenGL. Experimental support for OpenGL ES 2 is available via the ANGLE
project, using either:
* MS Open Technologies' "ms-master" repository, at https://github.com/MSOpenTech/angle
(for use with Windows 8.1+ or Windows Phone 8.1+)
* MS Open Technologies' "angle-win8.0" repository, at https://github.com/MSOpenTech/angle-win8.0
(for Windows 8.0 only!)
* Google's main ANGLE repository, at https://chromium.googlesource.com/angle/angle
* SDLmain. WinRT uses a different signature for each app's main() function.
SDL-based apps that use this port must compile in SDL_winrt_main_NonXAML.cpp
(in `SDL\src\main\winrt\`) directly in order for their C-style main()
functions to be called.
* XAML interoperability. This feature is currently experimental (there are
**many** known bugs in this, at present!), preliminary, and only for
Windows 8.x/RT at the moment. Windows Phone + XAML support is still
pending.

* What doesn't work:
* compilation with anything other than Visual C++ 2012 or 2013
* compilation with anything other than Visual C++
* programmatically-created custom cursors. These don't appear to be supported
by WinRT. Different OS-provided cursors can, however, be created via
SDL_CreateSystemCursor() (unsupported on Windows Phone)
Expand Down Expand Up @@ -236,10 +219,10 @@ To set this up for SDL/WinRT, you'll need to run through the following steps:
4. find SDL/WinRT's Visual C++ project file and open it. Different project
files exist for different WinRT platforms. All of them are in SDL's
source distribution, in the following directories:
* `VisualC-WinRT/WinPhone80_VS2012/` - for Windows Phone 8.0 apps
* `VisualC-WinRT/UWP_VS2015/` - for Windows 10 / UWP apps
* `VisualC-WinRT/WinPhone81_VS2013/` - for Windows Phone 8.1 apps
* `VisualC-WinRT/WinRT80_VS2012/` - for Windows 8.0 apps
* `VisualC-WinRT/WinRT81_VS2013/` - for Windows 8.1 apps
* `VisualC-WinRT/WinRT80_VS2012/` - for Windows 8.0 apps
* `VisualC-WinRT/WinRT81_VS2013/` - for Windows 8.1 apps
5. once the project has been added, right-click on your app's project and
select, "References..."
6. click on the button titled, "Add New Reference..."
Expand Down Expand Up @@ -400,11 +383,11 @@ A list of unsupported C APIs can be found at
<http://msdn.microsoft.com/en-us/library/windows/apps/jj606124.aspx>

General information on using the C runtime in WinRT can be found at
<http://msdn.microsoft.com/en-us/LIBRARY/hh972425(v=vs.110).aspx>
<https://msdn.microsoft.com/en-us/library/hh972425.aspx>

A list of supported Win32 APIs for Windows 8/RT apps can be found at
A list of supported Win32 APIs for WinRT apps can be found at
<http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx>. To note,
the list of supported Win32 APIs for Windows Phone 8 development is different.
the list of supported Win32 APIs for Windows Phone 8.0 is different.
That list can be found at
<http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662956(v=vs.105).aspx>

Expand All @@ -422,7 +405,12 @@ Simulator. Once you do that, any time you build and run the app, the app will
launch in window, rather than full-screen.


#### 7.A. Running apps on ARM-based devices ####
#### 7.A. Running apps on older, ARM-based, "Windows RT" devices ####

**These instructions do not include Windows Phone, despite Windows Phone
typically running on ARM processors.** They are specifically for devices
that use the "Windows RT" operating system, which was a modified version of
Windows 8.x that ran primarily on ARM-based tablet computers.

To build and run the app on ARM-based, "Windows RT" devices, you'll need to:

Expand All @@ -433,9 +421,9 @@ To build and run the app on ARM-based, "Windows RT" devices, you'll need to:
Windows RT device (on the network).

Microsoft's Remote Debugger can be found at
<http://msdn.microsoft.com/en-us/library/vstudio/bt727f1t.aspx>. Please note
<https://msdn.microsoft.com/en-us/library/hh441469.aspx>. Please note
that separate versions of this debugger exist for different versions of Visual
C++, one for debugging with MSVC 2012, another for debugging with MSVC 2013.
C++, one each for MSVC 2015, 2013, and 2012.

To setup Visual C++ to launch your app on an ARM device:

Expand Down
3 changes: 3 additions & 0 deletions include/SDL_config_winrt.h
Expand Up @@ -35,6 +35,9 @@
#ifndef NTDDI_WINBLUE
#define NTDDI_WINBLUE 0x06030000
#endif
#ifndef NTDDI_WIN10
#define NTDDI_WIN10 0x0A000000
#endif

/* This is a set of defines to configure the SDL features */

Expand Down
18 changes: 8 additions & 10 deletions src/audio/xaudio2/SDL_xaudio2.c
Expand Up @@ -58,8 +58,13 @@
/* The configure script already did any necessary checking */
# define SDL_XAUDIO2_HAS_SDK 1
#elif defined(__WINRT__)
/* WinRT always has access to the XAudio 2 SDK */
/* WinRT always has access to the XAudio 2 SDK (albeit with a header file
that doesn't compile as C code).
*/
# define SDL_XAUDIO2_HAS_SDK
#include "SDL_xaudio2.h" /* ... compiles as C code, in contrast to XAudio2 headers
in the Windows SDK, v.10.0.10240.0 (Win 10's initial SDK)
*/
#else
/* XAudio2 exists as of the March 2008 DirectX SDK
The XAudio2 implementation available in the Windows 8 SDK targets Windows 8 and newer.
Expand Down Expand Up @@ -88,17 +93,10 @@
#endif
#endif

/* The XAudio header file, when #include'd on WinRT, will only compile in C++
files, but not C. A few preprocessor-based hacks are defined below in order
to get xaudio2.h to compile in the C/non-C++ file, SDL_xaudio2.c.
*/
#ifdef __WINRT__
#define uuid(x)
#define DX_BUILD
#endif

#if !defined(_SDL_XAUDIO2_H)
#define INITGUID 1
#include <xaudio2.h>
#endif

/* Hidden "this" pointer for the audio functions */
#define _THIS SDL_AudioDevice *this
Expand Down

0 comments on commit 25abce5

Please sign in to comment.