private void RecoverLostDevice() { if (_VIDEO_DEVICE_ == null) { Console.WriteLine("Bad DEVICE"); } try { _VIDEO_DEVICE_.TestCooperativeLevel(); //let's check what the state of the device is, if we can reset the device or not. } catch (DeviceLostException) { } catch (DeviceNotResetException) //The device can be reset { try { _VIDEO_DEVICE_.Reset(_DeviceParams_.PresentationParameters); //Reset the device. } catch (DeviceLostException) { Application.ExitThread(); } } }
/// <summary> /// Handles resetting the device (Private utility function). /// </summary> private void Reset() { font.OnLostDevice(); line.OnLostDevice(); sprite.OnLostDevice(); device.Reset(presentParams); font.OnResetDevice(); sprite.OnResetDevice(); line.OnResetDevice(); }
/// <summary> /// /// </summary> /// <param name="waitForVSync"></param> public override void SwapBuffers(bool waitForVSync) { D3D.Device device = driver.Device; if (device != null) { int status; // tests coop level to make sure we are ok to render device.CheckCooperativeLevel(out status); if (status == (int)Microsoft.DirectX.Direct3D.ResultCode.Success) { // swap back buffer to the front if (isSwapChain) { swapChain.Present(); } else { device.Present(); } } else if (status == (int)Microsoft.DirectX.Direct3D.ResultCode.DeviceLost) { // Device is lost, and is not available for reset now log.Warn("Device State: DeviceLost"); D3D9RenderSystem renderSystem = (D3D9RenderSystem)Root.Instance.RenderSystem; renderSystem.NotifyDeviceLost(); } else if (status == (int)Microsoft.DirectX.Direct3D.ResultCode.DeviceNotReset) { // The device needs to be reset, and has not yet been reset. log.Warn("Device State: DeviceNotReset"); device.Reset(device.PresentationParameters); } else { throw new Exception(string.Format("Unknown status code from CheckCooperativeLevel: {0}", status)); } } }
protected void AttemptRecovery() { Debug.WriteLine("AttemptRecovery()"); try { device.TestCooperativeLevel(); lostDevice = false; } catch (DeviceLostException) { } catch (DeviceNotResetException) { try { device.Reset(d3dpp); lostDevice = false; } catch (DeviceLostException) { // Si c'est toujours perdu ou que ca a encore été perdu, ne fait rien } } }