Original Post
Hello,
I''m using Direct 3d 8 to make a 2d engine and I am having a litte problem. When I alt-tab and then come back i loose the device or something because it doesn''t redraw the scene.
I made this function to restore the device:
It basically just sets the D3DPRESENT_PARAMETERS back to what they were and calls reset.
Im not even sure if that is the right thing to do, is it?
My main problem is i don''t know what messege i should be acting on to call this function. I tried WM_ACTIVATE but couldn''t get it to work.
I''m pretty sure the RestoreDevices function itself works because i made it so when i press the space bar it calls the function. and when i Alt-tab out and back the screen doesn''t show up at first but when i press space it does.
Any help would be appreciated.
Thanks, Jake.
HRESULT
RestoreDevices()
{
D3DDISPLAYMODE d3ddm;
if( FAILED( dx8.pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT,
&d3ddm )))
return E_FAIL;
// Parameters for the D3DDevice. Most parameters are zero''d out.
// This sets the video format to match the current desktop display.
// Check docs for other options you can set here, such as
// ''Windowed'' which would create a window-based app (not full screen)
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = 1024;
d3dpp.BackBufferHeight = 768;
d3dpp.BackBufferFormat = d3ddm.Format;
if(FAILED(dx8.pd3dDevice->Reset(&d3dpp)))
return E_FAIL;
}