Welcome to WindowsClient.net | My Blog | Sign in | Join

Rob Relyea - XAMLified

WPF, Silverlight and XAML

Syndication

Sponsors





  • advertise here
Gizmodo posts WPF + Direct2D Sample, wow!

You’ll never believe what I found in a bar tonight…

A USB key, with the following note taped to it:

This is a copy of the DX interop sample I’d like to share with the world, and I’d love your help.  It consists of a VS10 solution with 4 projects:

The other two projects are the fun bits:

  • SurfaceQueueInteropHelper (which probably needs a better name):  this is a mixed-mode C++ assembly that provides APIs to managed your D3DImage, resizing, surface lost/regained and rendering callbacks.
  • WpfD2DSample: Normal C# application that uses SurfaceQueueInteropHelper and managed D2D (via CodePack) to draw a simulated scatterplot, providing pan/zoom/LOD, as well as (logical) hit testing of the D2D content and WPF overlays (which is made much easier with surface interop (vs. HWND interop)).  The piece de resistance would be to have a demo button that shows all of this working on the surface of a sphere or similar, but I haven't done that. :)

I think there's a lot more benefit to a .sln that you can unzip and run compared to a set of instructions like "Unzip this, then download the code pack, then make the following two changes, then import it into your sln, then...", etc.

Help me Obi-Wan, you are my only hope.

I have no idea what this all means, but I posted the solution .zip file here: http://robrelyea.com/demos/WPFDirect2DSample/WPFandDirect2DSample.zip

[Update: you need DirectX 9 SDK installed to use this sample.]

You like?

Published Friday, April 30, 2010 9:51 PM by Rob_Relyea

Comments

# Twitter Trackbacks for Gizmodo posts WPF + Direct2D Sample, wow! - Rob Relyea - XAMLified [windowsclient.net] on Topsy.com@ Saturday, May 01, 2010 1:06 AM

Pingback from  Twitter Trackbacks for                 Gizmodo posts WPF + Direct2D Sample, wow! - Rob Relyea - XAMLified         [windowsclient.net]        on Topsy.com

# re: Gizmodo posts WPF + Direct2D Sample, wow!@ Saturday, May 01, 2010 8:25 PM

Very cool Rob!  I think though you missed some very big features of this code sample :).  With some small additions, it allows rendering of DX10 and DX11 into WPF with D3DImage.  I think resource sharing features of D3D are some of the more little known, but extremely powerful gems...specially in the context of D3D interop.

I had written a WPF/DX10/11 interop lib a while ago, but it's not in the same league as this sample.  Great stuff!  

jmorrill.hjtcentral.com/.../Direct3D-10-11-Direct2D-in-WPF.aspx

# re: Gizmodo posts WPF + Direct2D Sample, wow!@ Sunday, July 18, 2010 7:58 PM

The blog post had me completely sucked in, but then the 404 for the zip file smashed my hopes and dreams.  

by Philip

# re: Gizmodo posts WPF + Direct2D Sample, wow!@ Sunday, July 18, 2010 11:43 PM

Philip-

Sorry, was transitioning servers at my ISP. Should be fixed now.

Sorry I smashed your dreams.

-Rob

# re: Gizmodo posts WPF + Direct2D Sample, wow!@ Wednesday, November 10, 2010 11:35 AM

Hey Rob,

I downloaded this sample in a flurry of total excitement only tu run it on my Win7 machine inside VMWare Fusion and have my hopes dashed. Fortunately, after some digging, i was able to track down the issue. The code in SurfaceQueueInteropHelper.h tries to create a DX10 surface with a DX10 hardware level which really isn't necessary. So i changed the following code

/* THIS IS THE OLD CODE

if (FAILED(hr = D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL,

                               DeviceFlags, D3D10_FEATURE_LEVEL_10_0, D3D10_1_SDK_VERSION, ppD3D10Device)))

               {

                   return hr;

               }*/

/* THIS IS THE NEW CODE */

if (FAILED(hr = D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL,

                               DeviceFlags, D3D10_FEATURE_LEVEL_9_3, D3D10_1_SDK_VERSION, ppD3D10Device)))

               {

                   return hr;

               }

Notice I changed D3D10_FEATURE_LEVEL_10_0 to D3D10_FEATURE_LEVEL_9_3 and Voilà!

Leave a Comment

(required) 
(required) 
(optional)
(required)