user2064064
user2064064

Reputation: 11

failed to create d2d device in c++

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.

Upvotes: 1

Views: 1002

Answers (1)

Cu2S
Cu2S

Reputation: 686

I recommend you set the options to D2D1_DEBUG_LEVEL_INFORMATION when _DEBUG is defined and then you may see some error messages in your output window. For example, the output told me that

D2D DEBUG WARNING - The Direct3D device was not created with D3D11_CREATE_DEVICE_BGRA_SUPPORT, and therefore is not compatible with Direct2D.

which is really helpful.

Upvotes: 1

Related Questions