public ResetDevice ( int width, int height ) : void | ||
width | int | |
height | int | |
리턴 | void |
private string HandleDeviceReset() { bool needsReset = false; switch (GraphicsDevice.GraphicsDeviceStatus) { case GraphicsDeviceStatus.Lost: return("Graphics device lost"); case GraphicsDeviceStatus.NotReset: needsReset = true; break; default: PresentationParameters pp = GraphicsDevice.PresentationParameters; needsReset = (ClientSize.Width > pp.BackBufferWidth) || (ClientSize.Height > pp.BackBufferHeight); break; } if (needsReset) { try { _deviceService.ResetDevice(ClientSize.Width, ClientSize.Height); } catch (Exception e) { return("Graphics device reset failed\n\n" + e); } } return(null); }
/// <summary> /// Helper used by BeginDraw. This checks the graphics device status, /// making sure it is big enough for drawing the current control, and /// that the device is not lost. Returns an error string if the device /// could not be reset. /// </summary> string HandleDeviceReset() { bool deviceNeedsReset = false; switch (GraphicsDevice.GraphicsDeviceStatus) { case GraphicsDeviceStatus.Lost: // If the graphics device is lost, we cannot use it at all. return("Graphics device lost"); case GraphicsDeviceStatus.NotReset: // If device is in the not-reset state, we should try to reset it. deviceNeedsReset = true; break; default: // If the device state is ok, check whether it is big enough. PresentationParameters pp = GraphicsDevice.PresentationParameters; deviceNeedsReset = (ClientSize.Width > pp.BackBufferWidth) || (ClientSize.Height > pp.BackBufferHeight); break; } // Do we need to reset the device? if (deviceNeedsReset) { try { graphicsDeviceService.ResetDevice(ClientSize.Width, ClientSize.Height); PresentationParameters pp = GraphicsDevice.PresentationParameters; pp.BackBufferWidth = Math.Max(ClientSize.Width, pp.BackBufferWidth); pp.BackBufferHeight = Math.Max(ClientSize.Height, pp.BackBufferHeight); graphicsDeviceService.GraphicsDevice.Reset(pp); } catch (Exception e) { return("Graphics device reset failed\n\n" + e); } } return(null); }
string HandleDeviceReset() { bool deviceNeedsReset = false; switch (GraphicsDevice.GraphicsDeviceStatus) { case GraphicsDeviceStatus.Lost: return("Graphics device lost"); case GraphicsDeviceStatus.NotReset: deviceNeedsReset = true; break; default: PresentationParameters pp = GraphicsDevice.PresentationParameters; deviceNeedsReset = (ClientSize.Width > pp.BackBufferWidth) || (ClientSize.Height > pp.BackBufferHeight); break; } if (deviceNeedsReset) { try { graphicsDeviceService.ResetDevice(_renderTarget.Width, _renderTarget.Height); _renderTarget.Dispose(); _renderTarget = new SwapChainRenderTarget(GraphicsDevice, Handle, ClientSize.Width, ClientSize.Height); } catch (Exception e) { return("Graphics device reset failed\n\n" + e); } } return(null); }
public void Resize(int w, int h) { graphicsDeviceService.ResetDevice(w, h); }