A nice Hello,
I want to capture the monitor output and hand it over to a Unity texture pointer. I used DXGICaptureSample from Pavel Gurenko which works great (saves a bitmap from monitor) and merged it with the Unity Plugin Example. My idea was to take the BYTEs and copy them into the texture pointer, but I get a black texture with some scrambled lines.
Here's the code from the DX11 section
// update native texture from code
if (g_TexturePointer)
{
ID3D11Texture2D* d3dtex = (ID3D11Texture2D*)g_TexturePointer;
D3D11_TEXTURE2D_DESC desc;
d3dtex->GetDesc (&desc);
BYTE* data = new BYTE[desc.Width*desc.Height*4];
CoInitialize(NULL);
g_DXGIManager.SetCaptureSource(CSMonitor1);
RECT rcDim;
g_DXGIManager.GetOutputRect(rcDim);
CComPtr spWICFactory = NULL;
HRESULT hr = spWICFactory.CoCreateInstance(CLSID_WICImagingFactory);
int i = 0;
do
{
hr = g_DXGIManager.GetOutputBits(data, rcDim);
i++;
} while (hr == DXGI_ERROR_WAIT_TIMEOUT || i < 2);
ctx->UpdateSubresource (d3dtex, 0, NULL, data, desc.Width*4, 0);
delete[] data;
}
↧