I'm having some troubles when alt-tabbing out then back into my game. The Direct3DDevice->Reset() method fails, returning an "invalid parameter" error message. I have no idea what this could be. The device creation goes fine with the parameters, but when I use the same for the reset it fails (I've double chekced, they aren't modified somewhere else along the way). All buffers I use are managed.
Any idea?
These are the parameters I set up Direct3D with:
This is the function I call before every rendering session:Code:DeviceInfo.BackBufferWidth = Width; DeviceInfo.BackBufferHeight = Height; DeviceInfo.BackBufferFormat = D3DFMT_A8R8G8B8; DeviceInfo.BackBufferCount = 1; DeviceInfo.MultiSampleType = D3DMULTISAMPLE_NONE; DeviceInfo.MultiSampleQuality = 0; DeviceInfo.SwapEffect = D3DSWAPEFFECT_DISCARD; DeviceInfo.hDeviceWindow = Window; DeviceInfo.Windowed = FALSE; DeviceInfo.EnableAutoDepthStencil = TRUE; DeviceInfo.AutoDepthStencilFormat = D3DFMT_D16; DeviceInfo.Flags = 0; DeviceInfo.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; DeviceInfo.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
Code:BOOL GRAPHICS::BeginRender() { HRESULT Result; //Clears the debug information BlocksRendered = 0; SidesRendered = 0; //Checks if the program lost focus Result = Direct3DDevice->TestCooperativeLevel(); if(Result != D3D_OK) { //If you cannot simply reset, wait until you can if(Result == D3DERR_DEVICELOST) { return FALSE; } //Resets the device if(FAILED(Direct3DDevice->Reset(&DeviceInfo))) { return FALSE; } //Re-sets the render states SetupRenderStates(); } //Clears the back buffer and Z-buffer if(FAILED(Direct3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, BackgroundColor, 1.0, 0))) { return FALSE; } //Begins rendering if(FAILED(Direct3DDevice->BeginScene())) { return FALSE; } return TRUE; }



LinkBack URL
About LinkBacks


