Exemple #1
0
        /// <summary>
        /// Handles the AfterSwapChainResized event of the Screen control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="AfterSwapChainResizedEventArgs"/> instance containing the event data.</param>
        private static void Screen_AfterSwapChainResized(object sender, AfterSwapChainResizedEventArgs e)
        {
            BuildRenderTargets();
            InitializeBackgroundTexturePositioning();

            _gaussBlur.BlurRenderTargetsSize = new DX.Size2(_screen.Width / 2, _screen.Height / 2);
        }
Exemple #2
0
        /// <summary>
        /// Handles the AfterSwapChainResized event of the Screen control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="AfterSwapChainResizedEventArgs"/> instance containing the event data.</param>
        private void Screen_AfterSwapChainResized(object sender, AfterSwapChainResizedEventArgs e)
        {
            _halfSize = new DX.Size2F(e.Size.Width / 2.0f, e.Size.Height / 2.0f);

            // Update the image.
            DrawAPrettyPicture();
        }
Exemple #3
0
        /// <summary>
        /// Handles the Resized event of the _swap control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="AfterSwapChainResizedEventArgs" /> instance containing the event data.</param>
        /// <exception cref="NotSupportedException"></exception>
        private static void Swap_AfterResized(object sender, AfterSwapChainResizedEventArgs e)
        {
            // This method allows us to restore projection matrix after the swap chain has been resized.  If we didn't do this, we'd have a weird looking (e.g. distorted)
            // image because the old projection matrix would be in place for the previous swap chain size.
            //
            // This is also the place to re-apply any custom viewports, or scissor rectangles.

            // Reset our projection matrix to match our new size.
            _projMatrix = DX.Matrix.PerspectiveFovLH((75.0f).ToRadians(), e.Size.Width / (float)e.Size.Height, 500.0f, 0.125f);
            BuildDepthBuffer(e.Size.Width, e.Size.Height);
            _graphics.SetDepthStencil(_depthBuffer);
        }
Exemple #4
0
        /// <summary>
        /// Function called after a swap chain is resized.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="AfterSwapChainResizedEventArgs"/> instance containing the event data.</param>
        private void AfterSwapChainResized(object sender, AfterSwapChainResizedEventArgs e)
        {
            // Restore the render target buffer and restore the contents of it.
            _backBuffer = GorgonRenderTarget2DView.CreateRenderTarget(_graphics,
                                                                      new GorgonTexture2DInfo("Backbuffer")
            {
                Width  = ClientSize.Width,
                Height = ClientSize.Height,
                Format = BufferFormat.R8G8B8A8_UNorm
            });
            _backBuffer.Clear(Color.White);
            _backupImage.CopyTo(_backBuffer.Texture, new DX.Rectangle(0, 0, _backBuffer.Width, _backBuffer.Height));

            _backBufferView = _backBuffer.GetShaderResourceView();
        }
Exemple #5
0
        /// <summary>
        /// Handles the AfterSwapChainResized event of the Swap control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="AfterSwapChainResizedEventArgs"/> instance containing the event data.</param>
        private static void Swap_AfterSwapChainResized(object sender, AfterSwapChainResizedEventArgs e)
        {
            // We need to recreate the depth/stencil here to match the updated size of the render target (the depth/stencil and render targets must be the same size).
            _depthStencil = GorgonDepthStencil2DView.CreateDepthStencil(_graphics,
                                                                        new GorgonTexture2DInfo
            {
                Format  = BufferFormat.D24_UNorm_S8_UInt,
                Binding = TextureBinding.DepthStencil,
                Usage   = ResourceUsage.Default,
                Width   = _swap.Width,
                Height  = _swap.Height
            });
            _graphics.SetDepthStencil(_depthStencil);

            // When we resize, the projection matrix will go out of date, so we need to update our constant buffer with an updated projection.
            DX.Matrix.PerspectiveFovLH((65.0f).ToRadians(), (float)_swap.Width / _swap.Height, 0.125f, 1000.0f, out _projection);
            _vsConstants.Buffer.SetData(ref _projection);
        }
Exemple #6
0
 /// <summary>
 /// Screens the after swap chain resized.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="AfterSwapChainResizedEventArgs" /> instance containing the event data.</param>
 private static void Screen_AfterSwapChainResized(object sender, AfterSwapChainResizedEventArgs e) => UpdateRenderTarget();