D3D11CreateDevice 0x887a002d 错误
D3D11CreateDevice 0x887a002d error
首先,我正在从 Frank Luna 书中学习 DirectX 11 我来到了需要创建设备的部分,但它给出了错误:“0x887a002d:应用程序请求了一个依赖于 SDK 组件的操作丢失或不匹配。”我一直在寻找,我尝试了不同的解决方案,但没有成功,
我尝试过的解决方案:
1)我用的是visual studio2015自带的DirectX库,所以安装了(正确)
2)我尝试将其更改为 D3D11CreateDeviceAndSwapChain 但它也给出了相同的错误
我有 DirectX SDK(2010 年 6 月)连接到该项目(是的,我想使用 DirectX 遗留 SDK)。
我的代码:
HRESULT hr;
UINT CreateDeviceFlags = 0;
D3D_FEATURE_LEVEL featureLevel;
UINT m4xMsaaQuility;
#if defined(DEBUG) || defined(_DEBUG)
CreateDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
hr = D3D11CreateDevice(
0,
D3D_DRIVER_TYPE_HARDWARE,
0,
CreateDeviceFlags,
0, 0,
D3D11_SDK_VERSION,
&m_pDevice,
&featureLevel,
&m_pDeviceContext);
if (FAILED(hr))
{
return -1;
}
包括:
#include <iostream>
#include <Windows.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#include <DirectXMath.h>
#include <DirectXColors.h>
// Link Library Dependencies
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")
#pragma comment(lib, "winmm.lib")
您没有提到您使用的是哪个OS。
该错误表明您的系统没有 具有支持D3D11_CREATE_DEVICE_DEBUG
所需的DirectX SDK 层包。您可以通过构建不使用此标志的发布配置来验证这一点,并检查它是否可以创建 Direct3D 11 设备。
使用 DirectX 11.0 时,旧版 DirectX SDK(即使是最后一个,2010 年 6 月)仅安装适用于 Windows 7 或更早版本的 DirectX Developer Debug Runtime。它不支持带有 KB 2670838 (a.k.a DirectX 11.1)、Windows 8、Windows 8.1 或 Windows 10 的 Windows 7 SP1。
如果您使用 Windows 7 SP1 和 KB 2670838,那么您应该通过安装 Windows 8.1 SDK(包含在 VS 中)获得正确的调试 SDK 层2015)。参见 DirectX 11.1 and Windows 7 Update。
如果您使用的是 Windows 8、Windows 8.1 或 Windows 8.1 更新,那么您应该通过安装 Windows 8.1 SDK(包含在 VS 2015 中)。请注意,Windows 8 不再受支持,因此您应该确保移动到 Windows 8.1 更新或 Windows 10.
如果您使用的是Windows 10,那么您需要启用Graphics Tools Windows功能,它提供了Debug SDK与您当前的 Windows 10 版本相匹配的层。请记住,这是 OS 版本特定的,因此升级到较新的版本或 Insider 版本可能需要重新安装 Windows 功能。在企业设置中,您的 IT 管理员必须批准使用此 Windows 可选功能,您才能安装它。参见 Visual Studio 2015 and Graphics Tools for Windows 10
见Where is the DirectX SDK (2015 Edition)? and Direct3D SDK Debug Layer Tricks
Frank Luna 的书很棒,但是写于之前 DirectX SDK 的弃用。阅读 this blog post for some important notes. Be sure to read Living without D3DX and consider using the latest version of Effects 11 from GitHub.
As you are new to DirectX 11, I strongly recommend taking a look at Anatomy of Direct3D 11 Create Device as well as the DirectX Tool Kit for DirectX 11 tutorials. It would probably serve you well to do it before working through all of Luna's book so you can get a foundation in the 'modern' way to work with DirectX 11. This will let you more easily discern the deprecated stuff in Luna's book from the parts that are still quite relevant.
首先,我正在从 Frank Luna 书中学习 DirectX 11 我来到了需要创建设备的部分,但它给出了错误:“0x887a002d:应用程序请求了一个依赖于 SDK 组件的操作丢失或不匹配。”我一直在寻找,我尝试了不同的解决方案,但没有成功,
我尝试过的解决方案: 1)我用的是visual studio2015自带的DirectX库,所以安装了(正确) 2)我尝试将其更改为 D3D11CreateDeviceAndSwapChain 但它也给出了相同的错误
我有 DirectX SDK(2010 年 6 月)连接到该项目(是的,我想使用 DirectX 遗留 SDK)。
我的代码:
HRESULT hr;
UINT CreateDeviceFlags = 0;
D3D_FEATURE_LEVEL featureLevel;
UINT m4xMsaaQuility;
#if defined(DEBUG) || defined(_DEBUG)
CreateDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
hr = D3D11CreateDevice(
0,
D3D_DRIVER_TYPE_HARDWARE,
0,
CreateDeviceFlags,
0, 0,
D3D11_SDK_VERSION,
&m_pDevice,
&featureLevel,
&m_pDeviceContext);
if (FAILED(hr))
{
return -1;
}
包括:
#include <iostream>
#include <Windows.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#include <DirectXMath.h>
#include <DirectXColors.h>
// Link Library Dependencies
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")
#pragma comment(lib, "winmm.lib")
您没有提到您使用的是哪个OS。
该错误表明您的系统没有 具有支持D3D11_CREATE_DEVICE_DEBUG
所需的DirectX SDK 层包。您可以通过构建不使用此标志的发布配置来验证这一点,并检查它是否可以创建 Direct3D 11 设备。
使用 DirectX 11.0 时,旧版 DirectX SDK(即使是最后一个,2010 年 6 月)仅安装适用于 Windows 7 或更早版本的 DirectX Developer Debug Runtime。它不支持带有 KB 2670838 (a.k.a DirectX 11.1)、Windows 8、Windows 8.1 或 Windows 10 的 Windows 7 SP1。
如果您使用 Windows 7 SP1 和 KB 2670838,那么您应该通过安装 Windows 8.1 SDK(包含在 VS 中)获得正确的调试 SDK 层2015)。参见 DirectX 11.1 and Windows 7 Update。
如果您使用的是 Windows 8、Windows 8.1 或 Windows 8.1 更新,那么您应该通过安装 Windows 8.1 SDK(包含在 VS 2015 中)。请注意,Windows 8 不再受支持,因此您应该确保移动到 Windows 8.1 更新或 Windows 10.
如果您使用的是Windows 10,那么您需要启用Graphics Tools Windows功能,它提供了Debug SDK与您当前的 Windows 10 版本相匹配的层。请记住,这是 OS 版本特定的,因此升级到较新的版本或 Insider 版本可能需要重新安装 Windows 功能。在企业设置中,您的 IT 管理员必须批准使用此 Windows 可选功能,您才能安装它。参见 Visual Studio 2015 and Graphics Tools for Windows 10
见Where is the DirectX SDK (2015 Edition)? and Direct3D SDK Debug Layer Tricks
Frank Luna 的书很棒,但是写于之前 DirectX SDK 的弃用。阅读 this blog post for some important notes. Be sure to read Living without D3DX and consider using the latest version of Effects 11 from GitHub.
As you are new to DirectX 11, I strongly recommend taking a look at Anatomy of Direct3D 11 Create Device as well as the DirectX Tool Kit for DirectX 11 tutorials. It would probably serve you well to do it before working through all of Luna's book so you can get a foundation in the 'modern' way to work with DirectX 11. This will let you more easily discern the deprecated stuff in Luna's book from the parts that are still quite relevant.