gpt4 book ai didi

c++ - ' 错误代码 : E_FAIL ' when creating DirectX 10 Device and Swap Chain

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:51:42 29 4
gpt4 key购买 nike

我正在学习“使用 Direct3D 10.0 进行 3D 游戏编程简介”一书的一些简单 DX 教程。我在使用D3D10CreateDeviceAndSwapChain函数的时候遇到了一些问题。以下是代码:

        // Fill out a DXGI_SWAP_CHAIN_DESC to describe our swap chain.

DXGI_SWAP_CHAIN_DESC sd;


sd.BufferDesc.Width = mClientWidth;
sd.BufferDesc.Height = mClientHeight;

sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;

sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

// No multisampling.
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;

sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = mhMainWnd;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;


// Create the device.

UINT createDeviceFlags = 0;

#if defined(DEBUG) || defined(_DEBUG)
createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
#endif

HR( D3D10CreateDeviceAndSwapChain(
0, //default adapter

md3dDriverType,
//D3D10_DRIVER_TYPE_HARDWARE,

0, // no software device
createDeviceFlags,

D3D10_SDK_VERSION,
&sd,
&mSwapChain,
&md3dDevice) );

错误信息是:

错误代码:E_FAIL (0x80004005) 调用:D3D10CreateDeviceAndSwapChain(.....

当我将 D3D10CreateDeviceAndSwapChain 的参数“createDeviceFlags”更改为 0 时,它就起作用了。但为什么??我想知道原因,谁能告诉我???

最佳答案

MSDN 说

To create a device that supports the debug layer, you must install the DirectX SDK (to get D3D10SDKLayers.DLL), and then specify the D3D10_CREATE_DEVICE_DEBUG flag when calling D3D10CreateDevice.

那么,您安装了 SDK 了吗?您有 D3D10SDKLayers.DLL 吗?

关于c++ - ' 错误代码 : E_FAIL ' when creating DirectX 10 Device and Swap Chain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15321581/

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