D3D - D2D interop, ID2D1Factory problem RRS feed

  • Question

  • 1. To be able to share the surface between D3D and D2D one need to create 

    D2D1CreateDevice(d3dDeviceIn, property, *d2dDeviceOut);

    This will create a new ID2D1Factory  for the D2D code.
    In effect the D2D factory is becoming device dependent (on the D3D device)

    2. now there is a problem with "device independent" 2D resources such as ID2D1PathGeometry. I can't use a global factory object to create them, I should use the one of the device.

    Is there a work around?
    i.e. is it possible to share the D3D device and D2D device and still have a singleton ID2D1Factory object?
    That will simplify my code greatly!

    Sunday, February 3, 2013 3:16 PM


All replies

  • Have a look at the Direct3D-Direct2D Interop sample - http://code.msdn.microsoft.com/windowsapps/Direct2D-Direct3D-Interop-ee641e46 . It shows you how to create an independent ID2D1Factory while still getting the D2D device from the D3D device such that you are still sharing underneath. Specifically look at the CreateDeviceIndependentResources and CreateDeviceResources member functions in DirectXBase.cpp.

    XNA/DirectX MVP | Website | Blog | @mikebmcl

    • Proposed as answer by MikeBMcL Monday, February 4, 2013 9:24 AM
    • Marked as answer by Lloyd Monday, February 4, 2013 9:33 AM
    Monday, February 4, 2013 9:24 AM
  • Awesome, works a treat!
    Would greatly reduce and improve my device independent code! ^^
    Monday, February 4, 2013 9:34 AM