No there isn't, yet.
What you should do is open an issue (https://github.com/sharpdx/SharpDX/issues) and ask for the feature to be implemented.
But you can still get started while waiting for it to be implemented :D
Here's how I tried your scenario:
Then on your shared 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 your desktop project
Add a 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>
Run your 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);
};
}
}
}
On 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>
And 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 !
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…