Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Direct2D to draw on Direct3D11 surface

I am trying to create a Media Foundation Transform that draws text on video using D2D and D3D11. I am trying to construct a D2D RenderTarget on top of D3D11 resources, but unfortunately, most means of D2D and D3D interop require D3D10, which is not available within this project.

The parameters I have to work with are as follows: ID3D11Device *pDevice, ID3D11Texture2D *pInput, UINT uiInIndex, ID3D11Texture2D *pOutput, and UINT uiOutIndex.

I attempted to follow the advice of this tutorial, but it turns out that it requires a ID3D10Texture2D object, which again is not an option for me.

like image 754
Zach Avatar asked Aug 02 '12 04:08

Zach


1 Answers

Essentially you copy the frame from the input texture to the output texture, then do the following to retrieve an IDXGI surface:

IDXGISurface *surface;
pOutput->QueryInterface(&surface);

Then, follow the steps in this tutorial to turn the surface into a Direct2D render target. Once you have the render target, you can draw on it in a similar manner to how the tutorial draws the gradient.

like image 123
Zach Avatar answered Sep 21 '22 08:09

Zach