SlimDX viewports in WPF controls

bufferz picture bufferz · Feb 11, 2010 · Viewed 8.6k times · Source

I am transitioning from WinForms/XNA to WPF/SlimDX because:

  • a) all of the benefits of WPF over WinForms (but learning curve = ouch!)
  • b) I would like to have multiple SlimDX viewports attached to Panels. XNA has 1 "game" screen.
  • c, last and least) DirectX 10 support

All of my previous XNA code is in C#. I am having trouble figuring out how to port this over to SlimDX and WPF on a high level. I have searched like crazy. The closest I have found are:

1) http://www.gamedev.net/community/forums/topic.asp?topic_id=507941 Many articles point to this discussion, however it is incomplete and I can't figure out the XAML, and I get device errors after attaching all of the _slimDXDevice and Window1 events that were left out.

2) http://www.codeproject.com/KB/WPF/D3DImage.aspx This article assumes the user is porting C++. I am porting XNA code which is very close to MDX code.

If I could get to the point where I have a WPF form with a custom SlimDX driven viewport that was just a blue box, I could go from there. In XNA I rendered many separate RenderTargets and placed them all over the screen, now I want to attach them to controls. But first, just 1 blue box! :D

Any ideas? I feel that this is either simple or that there's some "cookie cutter" code that I'm missing. Greatly appreciated!

Answer

user197015 picture user197015 · Feb 12, 2010

You can look at the sample now. It's just been checked in to our repository, so you'll need to use SVN to get it (or wait until we ship the Feb 2010 release):

http://code.google.com/p/slimdx/source/detail?r=1356