Closed ThusMad closed 1 year ago
Hi,
Do you have a full reproducing sample (all files, project file, etc.) so it's easier for me to take a look?
Yes, here is a small project containing my code https://github.com/ThusMad/D3DDx11
This is not related to DirectN, the problem comes from how you use DirectX9's CreateTexture
API.
As you can see from the doc here: https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-createtexture, this is the method's layout:
HRESULT CreateTexture(
[in] UINT Width,
[in] UINT Height,
[in] UINT Levels,
[in] DWORD Usage,
[in] D3DFORMAT Format,
[in] D3DPOOL Pool,
[out, retval] IDirect3DTexture9 **ppTexture,
[in] HANDLE *pSharedHandle
);
so, pSharedHandle
is a pointer to a HANDLE
, not a HANDLE
.
To fix it you must allocate some memory and write the shared handle to it, or use DirectN's ComMemory
tool which will handle that for you:
using var handlePtr = new ComMemory(handle);
var hr = _d3DDevice.Object.CreateTexture(description.Width, description.Height, 1, Constants.D3DUSAGE_RENDERTARGET,
format, _D3DPOOL.D3DPOOL_DEFAULT, out var texture, handlePtr.Pointer);
Oh, i see, now it works, thx a lot.
Hi @smourier 👋 I'm using this sample to create my own control that I'll be using to draw some 2d stuff. Since the SharpDX is not supported for .Net 5.0+, I've rewritten the code in sample with DirectN. The code I ended with here but I faced a error![image](https://user-images.githubusercontent.com/24366509/220649835-fa1e0a4d-d01b-4579-99df-433f495e2471.png)
What I'm missing? In what direction should I look? Maybe there is a good sample?