public unsafe void ChangeResolution(int width, int height) { _width = width; _height = height; //Clear the current render target DeviceContext.OMSetRenderTargets(_context, 0, null, IntPtr.Zero); //Release all target objects, including _defaultRenderTarget ReleaseRenderTargets?.Invoke(); //Release the default render view (containing reference to the back buffer) NativeHelper.Dispose(ref _defaultRenderView); //Resize swapchain SwapChain.ResizeBuffers(_swapchain, 1, (uint)width, (uint)height, 28 /*R8G8B8A8_UNorm*/, 0).Check(); //Get the new back buffer and create default view RebuildBackBuffer(); //Rebuild all target objects RebuildRenderTargets?.Invoke(); //Apply current RenderTarget CurrentTarget.Apply(); //Invoke external event ResolutionChanged?.Invoke(this, EventArgs.Empty); }