Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top