首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >E_INVALIDARG一个或多个参数无效。- CreateDevice

E_INVALIDARG一个或多个参数无效。- CreateDevice
EN

Stack Overflow用户
提问于 2014-01-16 01:44:57
回答 1查看 6.6K关注 0票数 1

我有一个d3dDevice:

代码语言:javascript
运行
复制
ComPtr<ID3D11Device1>d3dDevice;

我在这里用它做dxgiDevice:

代码语言:javascript
运行
复制
    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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-16 11:57:31

问题是,您还没有创建与DX11兼容的Direct2D设备。您需要传递正确的创建标志,还应该考虑定义所需的功能级别。类似于:

代码语言:javascript
运行
复制
// 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); 
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21151941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档