Creating full screen DirectX device causes D3DERR_INVALIDCALL

纵然是瞬间 提交于 2019-12-24 09:39:34

问题


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?


回答1:


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()).



来源:https://stackoverflow.com/questions/4074946/creating-full-screen-directx-device-causes-d3derr-invalidcall

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!