I'm working on a project, specifically a game engine, that has support for both Windows Desktop (Win32) and Universal Windows (UWP/WinRT for Xbox One) platforms. Though I'm having trouble managing it. For Visual Studio, WinRT projects and standard C++ projects need to be compiled with different project types. So for each project I need to build I need to have two projects that build the same source code. For example, the engine needs to be compiled using two different projects. Once, for each platform I want to run on. Meaning everytime I need to run and test it on each platform I need to manually set the startup project to the project I want to launch. I hope that makes sense.
So my question is: Are there any tools, best practices or design patterns, for dealing with projects like this? Ideally I would like to just change the configuration to, say Xbox One, to launch for Xbox One, or Win32, to launch for Windows Desktop. But am open to new sugggestions.
Thanks!
I have a number of C++ libraries that build for "classic" Win32 desktop, Windows 10 desktop, UWP, and Xbox. The majority of the code is Win32 C++ or DirectX. For games, audio, and rendering, there's a pretty clear overlap of these platforms which is where I focused.
I have a blog series that captures much of the 'best practices' I used you may want to reference: Dual-use Coding Techniques for Games.
There are a few cases where I needed to interact with Windows Runtime APIs. In some contexts, I use the C++/CX extension guarded with
__cplusplus_winrt. In some cases I used WRL via the low-level ABI (which is frankly pretty ugly, but I didn't need to do all that much). C++/CX is only supported by Microsoft Visual C++, so WRL or better yet C++/WinRT is a better choice for new projects.Concrete examples would be:
GamePads - https://github.com/microsoft/DirectXTK/blob/master/Src/GamePad.cpp
Keyboard - https://github.com/microsoft/DirectXTK/blob/master/Src/Keyboard.cpp
Mouse - https://github.com/microsoft/DirectXTK/blob/master/Src/Mouse.cpp
XAudio2 device enumeration - https://github.com/microsoft/DirectXTK/blob/master/Audio/AudioEngine.cpp
All multi-platform engines isolate things like the 'window management, presentation loop, and swap chain'. For the Microsoft platforms, I've captured these in VS templates on GitHub.
Each platform also has it's own implementation of things like Cloud-based Storage, Store/licensing APIs, Multiplayer matching/connection, etc. so you'll need to isolate these as well if you implement them.