sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 639 forks source link

Passing a NativePointer to C++ possible? #835

Closed LennardF1989 closed 7 years ago

LennardF1989 commented 7 years ago

I'm trying to pass a NativePointer of a D3D11Device to C++ through a DirectShow filter, which uses a COMImport-attribute. The idea is that C++ will create a texture on the device I pass in and hand that back to me in C#.

I can verify my NativePointer, which I assume becomes a ComPtr, reaches my C++ code. However, after doing so, I have trouble actually using the device in the ComPtr. My function signature looks something like this in C++: void Renderer::setDevice(ComPtr<ID3D11Device> device)

Any tips on how to achieve what I want? Or is what I'm trying to do plain impossible? The latter of which would seem silly as technically it would be possible to instance a device on the C++ side, and pass that to C# to wrap it in a SharpDX Device-class...

LennardF1989 commented 7 years ago

Nevermind, I spoke too soon. My issue was related to texture-creation being in an unexpected format, passing pointers as I did work just fine.