Is there a SharpDx template for Windows Universal App?
I tried to write a game for Windows and Windows Phone 8.1 using SharpDx. But when I try to add the Windows Phone 8.1 version to my already existing Windows 8.1 game, I get several errors and the application doesn't work. Now the question is, is there an XNA-style SharpDx template for a Universal Windows Application like the template I got for my only Windows 8.1 game (from the Visual Studio extension for SharpDx)?
source to share
Not yet.
What you need to do is open an issue ( https://github.com/sharpdx/SharpDX/issues ) and ask to implement this feature.
But you can still get started while waiting for its implementation: D
This is how I tried your scenario:
- create a universal app project
- add SharpDX.Toolkit.Game NuGet package to every project of your device ( METHODOLOGICAL )
Then in your general project
Add your game:
using SharpDX;
using SharpDX.Toolkit;
namespace App1 {
internal class MyGame : Game {
private GraphicsDeviceManager _manager;
public MyGame() {
_manager = new GraphicsDeviceManager(this);
}
protected override void Draw(GameTime gameTime) {
#if WINDOWS_APP
// desktop related
#elif WINDOWS_PHONE_APP
// phone related
#endif
GraphicsDevice.Clear(Color.Magenta);
base.Draw(gameTime);
}
}
}
On the desktop
Add SwapChainPanel
:
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<SwapChainPanel x:Name="SwapChainPanel1" />
</Grid>
</Page>
Start the game:
using Windows.UI.Xaml.Controls;
namespace App1 {
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page {
public MainPage() {
InitializeComponent();
Loaded += (sender, e) => {
var myGame = new MyGame();
myGame.Run(SwapChainPanel1);
};
}
}
}
In your phone project
Do the same as above:
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<SwapChainPanel x:Name="SwapChainPanel1" />
</Grid>
</Page>
Finally:
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace App1 {
public sealed partial class MainPage : Page {
public MainPage() {
InitializeComponent();
NavigationCacheMode = NavigationCacheMode.Required;
}
protected override void OnNavigatedTo(NavigationEventArgs e) {
var myGame = new MyGame();
myGame.Run(SwapChainPanel1);
}
}
}
You are done!
source to share