gpt4 book ai didi

c++ - E_INVALIDARG 一个或多个参数无效。 - 创 build 备

转载 作者:行者123 更新时间:2023-11-30 01:55:02 26 4
gpt4 key购买 nike

我有一个 d3dDevice:

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

最佳答案

问题是您尚未创建与 Direct2D 兼容的 DX11 设备。您需要传递正确的创建标志,还应该考虑定义所需的功能级别。像这样的东西:

// 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);

关于c++ - E_INVALIDARG 一个或多个参数无效。 - 创 build 备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21151941/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com