DirectX9 CreateDevice failed with D3DERR_NOTAVAILABLE

僤鯓⒐⒋嵵緔 提交于 2019-12-25 06:59:44

问题


There is initializing code for dx9 device

D3DDISPLAYMODE display;
m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &display);

ZeroMemory(&m_d3dpp, sizeof(m_d3dpp));
m_d3dpp.Windowed = false;
m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_d3dpp.BackBufferFormat = display.Format;
m_d3dpp.EnableAutoDepthStencil = false;
m_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
/*BackBufferHeight and BackBufferWidth also set from elsewhere*/
DWORD flags = D3DCREATE_FPU_PRESERVE|D3DCREATE_MULTITHREADED;
m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, m_Devtype, hWnd, flags, &m_d3dpp, &m_pd3dDevice)

The fact is that this works well with both m_Devtype = D3DDEVTYPE_HAL and m_Devtype = D3DDEVTYPE_REF.

But on some particular computer (winXP, sp3, last dx installed) CreateDevice returns D3DERR_INVALIDCALL for D3DDEVTYPE_HAL and D3DERR_NOTAVAILABLE for D3DDEVTYPE_REF. m_pD3D and display are both valid. display struct has rgb565 in format field.

Seems to be important: "DX Caps Viewer" shows no hardware adapters and only one software, with format rgb565.

Looks like every parameter is right in CreateDevice and i expect that it must return D3D_OK for reference device, why not?

UPD1: Now i know, that this unlucky XP runs on some virtual machine. That's why there is just one software adapter, i guess.


回答1:


You didn't specify any vertex processing method in CreateDevice function. try set it as D3DCREATE_SOFTWARE_VERTEXPROCESSING, you must set one of the vertex process method, this is mandatory accroding to DirectX SDK document.

D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DCREATE_MIXED_VERTEXPROCESSING, and D3DCREATE_SOFTWARE_VERTEXPROCESSING are mutually exclusive flags. At least one of these vertex processing flags must be specified when calling CreateDevice.



来源:https://stackoverflow.com/questions/21140926/directx9-createdevice-failed-with-d3derr-notavailable

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