1

I am new to working with windows applications and c++. I am trying to create a D2D device from Dxgi surface of d3d11 device following this code "http://msdn.microsoft.com/en-us/library/windows/desktop/hh404272(v=vs.85).aspx" .

But HRESULT gr ( creating d2d device) gives me an error "E_INVALIDARG" though I followed the same steps as given.

Here is the code snippet. //m_device is already initialized

// Get DXGI device

 IDXGIDevice* DxgiDevice = nullptr;
HRESULT hr = m_Device->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&DxgiDevice));
// create id2d21factory
ID2D1Factory1* m_d2dFactory=nullptr;
D2D1_FACTORY_OPTIONS options;
    options.debugLevel=  D2D1_DEBUG_LEVEL_NONE;
D2D1_FACTORY_TYPE factoryType = D2D1_FACTORY_TYPE_SINGLE_THREADED;
 hr = D2D1CreateFactory(factoryType, __uuidof(ID2D1Factory1),&options, reinterpret_cast<void **>                       (&m_d2dFactory));
HRESULT gr= m_d2dFactory->CreateDevice(DxgiDevice, &m_d2dDevice );

This code doesn't give any errors while compiling or building solution in visual studio 2012. But giving me error while debugging. I am trying to insert this code in microsoft's desktop duplication sample code. I need to create a d2dbitmap source for my project

please help me with this.

Please let me know if further details are required.

4

1 回答 1

1

我建议您将其设置options为定义的D2D1_DEBUG_LEVEL_INFORMATION时间_DEBUG,然后您可能会在输出窗口中看到一些错误消息。例如,输出告诉我

D2D 调试警告 - Direct3D 设备不是使用 D3D11_CREATE_DEVICE_BGRA_SUPPORT 创建的,因此与 Direct2D 不兼容。

这真的很有帮助。

于 2017-02-21T13:56:07.883 回答