创建全屏 DirectX 设备会导致 D3DERR_INVALIDCALL
我正在尝试以全屏方式创建 DirectX 设备(到目前为止,我一直处于窗口化状态),但该设备不会被创建,并且我收到无效呼叫 HR 失败。
这是我的代码:
md3dPP.BackBufferWidth = 1280;
md3dPP.BackBufferHeight = 720;
md3dPP.BackBufferFormat = D3DFMT_UNKNOWN;
md3dPP.BackBufferCount = 1;
md3dPP.MultiSampleType = D3DMULTISAMPLE_NONE;
md3dPP.MultiSampleQuality = 0;
md3dPP.SwapEffect = D3DSWAPEFFECT_DISCARD;
md3dPP.hDeviceWindow = mhMainWnd;
md3dPP.Windowed = false;
md3dPP.EnableAutoDepthStencil = true;
md3dPP.AutoDepthStencilFormat = D3DFMT_D24S8;
md3dPP.Flags = 0;
md3dPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
md3dPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
HR(md3dObject->CreateDevice(
D3DADAPTER_DEFAULT, // primary adapter
mDevType, // device type
mhMainWnd, // window associated with device
devBehaviorFlags, // vertex processing
&md3dPP, // present parameters
&m_pd3dDevice)); // return created device
注意“md3dPP.Windowed = false;”,如果这是真的,设备会在窗口模式下创建。
我的印象是我在一些默认值中犯了错误,但不知道在哪里查找。有没有办法获得更详细的报告,说明为什么设备创建在 D3DERR_INVALIDCALL 之外失败?
I'm trying to create a DirectX device in full screen (up until this point in time I've been doign windowed), but the device won't get created and I get an invalid call HR fail.
This is my code:
md3dPP.BackBufferWidth = 1280;
md3dPP.BackBufferHeight = 720;
md3dPP.BackBufferFormat = D3DFMT_UNKNOWN;
md3dPP.BackBufferCount = 1;
md3dPP.MultiSampleType = D3DMULTISAMPLE_NONE;
md3dPP.MultiSampleQuality = 0;
md3dPP.SwapEffect = D3DSWAPEFFECT_DISCARD;
md3dPP.hDeviceWindow = mhMainWnd;
md3dPP.Windowed = false;
md3dPP.EnableAutoDepthStencil = true;
md3dPP.AutoDepthStencilFormat = D3DFMT_D24S8;
md3dPP.Flags = 0;
md3dPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
md3dPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
HR(md3dObject->CreateDevice(
D3DADAPTER_DEFAULT, // primary adapter
mDevType, // device type
mhMainWnd, // window associated with device
devBehaviorFlags, // vertex processing
&md3dPP, // present parameters
&m_pd3dDevice)); // return created device
Notice 'md3dPP.Windowed = false;', if that's true the device creates in windowed mode.
I'm under the impression I've made a mistake in some of my default values but have no idea where to look. Is there a way to get a more detailed report as to why the device creation failed beyond D3DERR_INVALIDCALL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要为
BackBufferFormat
指定不同的值,因为只有窗口应用程序允许使用值D3DFMT_UNKNOWN
。选择您的设备支持的一个(您可以使用 CheckDeviceFormat())。You need to specify a different value for
BackBufferFormat
because only windowed apps allow the valueD3DFMT_UNKNOWN
. Pick one that is supported by your device (you can check by using CheckDeviceFormat()).