I have an image in my WPF application that uses a
D3DImage to render DirectX content. On the DirectX side I render everything to a
Texture2D using SharpDX (a C# DirectX wrapper), but I'm not sure how to convert the rendered texture to a
I found the
D3DImage.SetBackBuffer(D3DResourceType backBufferType, IntPtr backBuffer) method, but that requires the texture to be a DXGI Surface. Here's the code I'm working with:
// renderTexture is a Texture2D that serves as the renderTarget for the DirectX content // d3dimg is the D3DImage that WPF uses d3dimg.Lock() d3dimg.SetBackBuffer(D3DResourceType.IDirect3DSurface9, renderTexture.QueryInterface<Surface>().NativePointer); d3dimg.Unlock();
But for some reason, the
SetBackBuffer function call throws an exception saying that the "specified cast is not valid," even though I'm not doing any casts here (as far as I can see). What am I doing wrong?