|
|
小弟用下列第的函数初始化d3ddevice9
bool CdxMg::init(HWND hWnd, int width, int height, bool fullscreen)
{
m_pd3d = Direct3DCreate9(D3D_SDK_VERSION);
if (m_pd3d == NULL)
{
MessageBox(NULL, "Unable to create D3D!", "ERROR!", MB_OK);
return false;
}
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = !fullscreen;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight = height;
d3dpp.hDeviceWindow = hWnd;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8;
d3dpp.EnableAutoDepthStencil = true;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
if (FAILED(m_pd3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &m_pd3ddevice)))
{
MessageBox(NULL, "Unable to create D3DDevice!", "ERROR!", MB_OK);
return false;
}
m_pd3ddevice->SetRenderState(D3DRS_NORMALIZENORMALS, true);
return true;
}
结果在有些机器上面可以正常运行,在有些机器上面就告诉我Unable to create D3DDevice!很奇怪,不知道为什么,.dll文件应该都齐全的呀? Who can help me???
|
|