问题
Is it possible to use DirectX 10 (I am using SlimDX) with WPF's D3DImage? The only examples and docs I can find only show using DX9 surfaces.
回答1:
Yes, you can use DirectX 10, 11, and DirectWrite using the D3DImage in WPF by creating your render target surface as shared, and then creating a DX9 texture based on that shared texture handle to use in WPF.
This means that essentially you can use 10, 11, and DirectWrite the same way you use DX9 with no additional overhead, and no airspace issues.
A sample WPF project with DX9, DX10, DX11, and DirectWrite integration can be found referenced in this blog post here:
http://blogs.windowsclient.net/rob_relyea/archive/2010/04/30/gizmodo-posts-wpf-direct2d-sample-wow.aspx
The Microsoft Code Pack contains a thin managed wrapper for Windows 7 components including DX9, DX10, DX11 and DirectWrite in addition to various other unmanaged libraries in Windows 7.
The SurfaceQueueInteropHelper is a WPF control that manages automatically creating DX9, 10, and 11 contexts in WPF and managing D3DImage updating and various other aspects of the rendering system including device lost events.
回答2:
Not out of the box as far as I know. WPF is based on DirectX, but as WPF is also supported on Windows XP it's based on DirectX 9.
I do know that it's possible to use DirectX 10 with WPF, but then your application won't be able to run on XP.
There's a library for WPF called Bling which supports DirectX 10 (on Vista and Windows 7) which might be of interest to you. You can find it here. I don't know how mature it is though.
Also, I ran into this blog (mostly in french) who speaks about using DirectX 10 with WPF.
Lastly there's a good introduction to using D3DImage with DirectX over at CodeProject
I know this doesn't exactly answer your question, but I thought I'd share it with you anyways. Best of luck.
回答3:
If you're willing to use SlimDX for the DirectX calls, you can try SlimDXControl (slimdxcontrol.codeplex.com) -- it is a WPF content control I wrote which explicitly only supports D3D10 instead of '9.
-mpg
来源:https://stackoverflow.com/questions/1252780/d3dimage-using-dx10