public void OnDestroyed() { // Destroy presenter first (so that its backbuffer and render target are destroyed properly before other resources) graphicsDevice.Presenter?.OnDestroyed(); foreach (var resource in graphicsDevice.Resources) { resource.OnDestroyed(); resource.LifetimeState = GraphicsResourceLifetimeState.Destroyed; } // Clear various graphics device internal states (input layouts, FBOs, etc...) graphicsDevice.OnDestroyed(); }
protected override void ResizeBackBuffer(int width, int height, PixelFormat format) { graphicsDevice.OnDestroyed(); startingPresentationParameters.BackBufferWidth = width; startingPresentationParameters.BackBufferHeight = height; graphicsDevice.InitDefaultRenderTarget(startingPresentationParameters); var newTextureDescrition = backBuffer.Description; newTextureDescrition.Width = width; newTextureDescrition.Height = height; // Manually update the texture backBuffer.OnDestroyed(); // Put it in our back buffer texture backBuffer.InitializeFrom(newTextureDescrition); }