问题描述
我试图在全屏模式下创建一个DirectX设备(直到此时我已将窗口打开),但设备无法创建,并且我收到了无效的呼叫HR fail。
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
注意'md3dPP.Windowed = false;',如果这是真的,在窗口模式下。
Notice 'md3dPP.Windowed = false;', if that's true the device creates in windowed mode.
我的印象是我在某些默认值中犯了一个错误,但不知道在哪里寻找。有没有办法获得更详细的报告,说明为什么设备创建失败超出D3DERR_INVALIDCALL?
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?
推荐答案
您需要指定一个 BackBufferFormat
的不同值,因为只有窗口应用程序允许值 D3DFMT_UNKNOWN
。选择一个您的设备支持的设备(您可以使用)。
You need to specify a different value for BackBufferFormat
because only windowed apps allow the value D3DFMT_UNKNOWN
. Pick one that is supported by your device (you can check by using CheckDeviceFormat()).
这篇关于创建全屏DirectX设备会导致D3DERR_INVALIDCALL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!