I have following code:
void CD3DXGraph::InitializeDevice(
const HWND &f_hwnd,
const CRect &f_rect
) {
try {
D3DPRESENT_PARAMETERS l_d3dpp;
if(NULL == m_d3d) {
m_d3d = Direct3DCreate9(D3D_SDK_VERSION);
if(NULL == m_d3d) {
return;
}
}
ZeroMemory(&l_d3dpp, sizeof(l_d3dpp));
l_d3dpp.Windowed = true;
l_d3dpp.hDeviceWindow = f_hwnd;
l_d3dpp.BackBufferCount = 1;
l_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
l_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
l_d3dpp.BackBufferWidth = f_rect.Width();
l_d3dpp.BackBufferHeight = f_rect.Height();
SetFrameRect(f_rect);
m_graph_hwnd = f_hwnd;
if (NULL != m_d3d)
{
if (NULL != m_3d_device)
{
HRESULT hret = m_3d_device->TestCooperativeLevel();
if (hret == D3DERR_DEVICELOST || hret == D3DERR_DEVICENOTRESET || hret == D3DERR_DRIVERINTERNALERROR)
{
AfxMessageBox("CD3DXGraph::InitializeDevice TestCooperativeLevel -> Error");
}
m_3d_device->Release();
m_3d_device = NULL;
}
HRESULT device_creation_state =
m_d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
f_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &l_d3dpp,
&m_3d_device);
}
} catch (...) {
AfxMessageBox(_T("catch CD3DXGraph::InitializeDevice"));
}
}
This code is in my DLL.
I call this method when application is initialized
m_d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,f_hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &l_d3dpp,
&m_3d_device);
this is called since m_3d_device is NULL.
But when i resize the application then i call this function again to release the device then create new device. (I did this because after resize there was a problem in line drawing lines were looking unclear.)
This was working fine for all the PC client had accepted it, but now the client has changed their grapic card (something like a nvidia quadro). The problem is that when release is called on m_3d_device application is crashing.