2014-01-16 122 views
1

我有一个d3dDevice:E_INVALIDARG一个或多个参数无效。 - CreateDevice的

ComPtr<ID3D11Device1>d3dDevice; 

我在这里使用它的dxgiDevice:

ComPtr<IDXGIDevice3> dxgiDevice2; 

    HRESULT hr; 

    hr = d3dDevice.As(&dxgiDevice2); // S_OK 

    hr = d2dFactory->CreateDevice(dxgiDevice2.Get(), d2dDevice.GetAddressOf()); // E_INVALIDARG One or more arguments are invalid 

    hr = d2dDevice->CreateDeviceContext(
     D2D1_DEVICE_CONTEXT_OPTIONS_NONE, 
     &d2dDeviceContext 
     ); 

为什么会这个错误在运行时发生了什么?我的代码

http://msdn.microsoft.com/en-us/library/windows/desktop/dn280482(v=vs.85).aspx

整体性是相关的问题:http://pastebin.com/P7Rs9xdh

+1

你试过'&d2dDevice'吗? –

+0

@ichramm为什么? 'GetAddressOf'语法没什么问题 - 它实际上是MS如何显示其示例代码。 –

回答

4

的问题是,你还没有创建您的DX11设备是使用Direct2D兼容。您需要传递正确的创建标志,并且还应该考虑定义所需的功能级别。例如:

// This flag adds support for surfaces with a different color channel 
// ordering than the API default. 
// You need it for compatibility with Direct2D. 
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; 

// This array defines the set of DirectX hardware feature levels this 
// app supports. 
// The ordering is important and you should preserve it. 
// Don't forget to declare your app's minimum required feature level in its 
// description. All apps are assumed to support 9.1 unless otherwise stated. 
D3D_FEATURE_LEVEL featureLevels[] = 
{ 
    D3D_FEATURE_LEVEL_11_1, 
    D3D_FEATURE_LEVEL_11_0, 
    D3D_FEATURE_LEVEL_10_1, 
    D3D_FEATURE_LEVEL_10_0, 
    D3D_FEATURE_LEVEL_9_3, 
    D3D_FEATURE_LEVEL_9_2, 
    D3D_FEATURE_LEVEL_9_1 
}; 

D3D_FEATURE_LEVEL m_featureLevel; 

// Create 3D device and device context objects 
D3D11CreateDevice(
    nullptr, 
    D3D_DRIVER_TYPE_HARDWARE, 
    nullptr, 
    creationFlags, 
    featureLevels, 
    ARRAYSIZE(featureLevels), 
    D3D11_SDK_VERSION, 
    &d3dDevice11, 
    &m_featureLevel, 
    &d3dDeviceContext11); 
+0

ARGHHHHHHHHHH,Ofcourseeeeee ...让我试试当我回家。如果这是正确的,我会吻你,你这个男人! – Jimmyt1988

+2

@JamesT ROFL,我希望我现在错了;-) –

+1

现在不要害羞......哈。我期待着这样做,尽管..不是这个吻,我的意思是看看它是否有效。会让你更新! – Jimmyt1988

相关问题