Beispiel #1
0
        /// <summary>
        /// Rebuilds the swap chain and render targets.
        /// </summary>
        protected void UpdatePresenter()
        {
            PresenterReady = false;

            // release our buffers since we are updating the swap chain
            RenderTarget2D.Dispose();
            DxgiSurface.Dispose();
            RenderTargetView.Dispose();
            _backBuffer.Dispose();

            // resize swapchain
            _swapChain.ResizeBuffers(1, Size.Width, Size.Height, Format.R8G8B8A8_UNorm, SwapChainFlags.None);

            // recreate the buffers
            _backBuffer                  = Resource.FromSwapChain <Texture2D>(_swapChain, 0);
            RenderTargetView             = new RenderTargetView(_device, _backBuffer);
            DxgiSurface                  = _backBuffer.QueryInterface <Surface>();
            RenderTarget2D               = new RenderTarget(Factory2D, DxgiSurface, new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)));
            RenderTarget2D.AntialiasMode = AntialiasMode;
            PresenterReady               = true;

            Brushes.Cleanup();
            Fonts.Cleanup();
            IsDirty = true;
            foreach (IRenderComponent component in Layers)
            {
                component.PresenterReset();
            }
        }