   White Windows after Recovering the Lost Direct3D Device
  Hello all,My application turn white after the lost device is reset. I'm suspecting the recovering code, and this is it :HRESULT result;isAfterLost = true;result = g_pD3DDevice->TestCooperativeLevel();if(g_pSprite!=NULL){g_pSprite->Release();g_pSprite = NULL;}while(result == D3DERR_DEVICELOST) { Sleep(500);result = g_pD3DDevice->TestCooperativeLevel();}if(result == D3DERR_DEVICENOTRESET){result=g_pD3DDevice->Reset(&param);if(SUCCEEDED(result)){result = D3DXCreateSprite(g_pD3DDevice,&g_pSprite);}}This function will be called after g_pD3DDevice->Present() returns D3DERR_DEVICELOST.-----------------------------------------------------------------My system is Windows XP sp-2 with Visual Studio 2005 and DirectX 9 SDK (April 2006 update), Forceware 84.21 with GeForce 6600.   
  Yes, resources in the managed pool don’t need to recreate.Do you have some “SetRenderState” or similar calls  following your device creation? A device reset will reset all render states too.It is a common advice to place the creation of non managed resources and your initial pipeline setup in own functions and call them after device creation and after a reset. That makes sure that you have done it only once.If I see right you create a new sprite interface after the reset but don’t release the old one before the reset. You should release any object that you want to recreate after the reset before you call reset. If you don’t do this reset can fail and you cause memory leaks. ;  That while() loop is A Bad Thing. You're not processing window messages, so TestCooperative() level will always return the same thing. It's not happening just now because TestCooperativeLevel() returns D3DERR_DEVICELOST the first time through.What you should do is remove the while() loop and call that function whenever Present() returns D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET.When you get D3DERR_DEVICELOST, you should release all resources in the default pool to free memory. When you get D3DERR_DEVICENOTRESET, you should Reset() the device, re-create all default pool resources, and then go through your post-device creation code (I.e. set all render states, lights, textures, matrices, etc).There's an example of this process on My site.   