Mittwoch, 2. Mai 2012 19:28
So, I have a DirectX (Direct2D with DirectWrite) game project, set up using the Direct2D Application project template. I want to use XAML for the menu and other UI features.
I read this tutorial on DirectX + XAML interop, and I downloaded the D3D Shooting Game samples as well.
I modified my low level DirectX code to be able to use the SwapChainBackgroundPane, but I've got stuck here, because I currently have no XAML file in my project to place the SwapChainBackgroundPane in. I tried to copy the App.xaml and the MainPage.xaml (and the codebehinds of course) from the interop sample to my project, and modify them, but I can't get rid of the main() function and startup using the App::App() method. If I delete the main(...) function I get an unresolved external error.
Should I start the project again using a Metro Style App template, and copy the code, or can I work around this issue?
Thanks for any help
Mittwoch, 2. Mai 2012 21:04
The easiest approach for now is to just create a new C++ "Blank Application" in VS and paste your D2D source files into that. This will ensure everything is set up correctly, and you can just add your SwapChainBackgroundPanel to BlankPage.xaml (or another XAML page you create).
Main things to watch for when switching:
- Change the IDXGIFactory2::CreateSwapChainForCoreWindow call to CreateSwapChainForComposition
- Ensure the swap chain descriptor is setting the correct window bounds and scaling mode (the Direct2D template has different values than are required)
- Remove the old Run() method and instead use the methods in App.xaml.cpp
- In App::OnLaunched, just remove the Frame and Navigate calls and just directly set Window::Current->Content to your XAML page that contains your SwapChainBackgroundPanel
Freitag, 4. Mai 2012 18:16Thanks for your answer