Within my Renderscene function I have this code.
switch(g_pd3dDevice->TestCooperativeLevel())
{
case D3DERR_DEVICELOST :
Cleanup() ;
return ;
case D3DERR_DEVICENOTRESET :
// release the objects
if(g_pVB != NULL)
g_pVB->Release() ;
if(g_pTexture[0] != NULL)
g_pTexture[0]->Release() ;
if(g_pTexture[1] != NULL)
g_pTexture[1]->Release() ;
// reset the device
g_pd3dDevice->Reset(&d3dpp) ;
// recreate and initialize the objects
ZeroMemory(&d3dpp, sizeof(d3dpp)) ;
d3dpp.Windowed = TRUE ;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD ;
d3dpp.BackBufferWidth = g_width ;
d3dpp.BackBufferHeight = g_height ;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN ;
d3dpp.EnableAutoDepthStencil = TRUE ;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16 ;
// create the D3DDevice
if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice)))
return ;
// turn of culling
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE) ;
// turn off D3D lighting
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE) ;
// turn on the zbuffer
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE) ;
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE) ;
InitGeometry() ;
break ;
}
In my Message Proc I have this code :
case WM_SIZE :
GetClientRect(hWnd, &rc) ;
g_width = rc.right - rc.left ; // reset the width
g_height = rc.bottom - rc.top ; // reset the height
return 0 ;
I have tried releasing->reseting->recreating/initializing the objects within the WM_SIZE message but then the application doesn't even load.
Any suggestions?
TIA