private void DoResizeBuffer() { //clear all command buffer EventPreResizeBuffer.Invoke(); Utilities.Dispose(ref m_backBuffer); Utilities.Dispose(ref m_renderTargetView); Utilities.Dispose(ref m_depthBuffer); Utilities.Dispose(ref m_depthcStencilView); Utilities.Dispose(ref m_srvBackBuffer); //Console.WriteLine($"RSZ w:{m_resizeWidth} h:{m_resizeHeight}"); m_swapchain.ResizeBuffers(m_swapchainDesc.BufferCount, m_resizeWidth, m_resizeHeight, Format.Unknown, SwapChainFlags.None); m_backBuffer = Texture2D.FromSwapChain <Texture2D>(m_swapchain, 0); //rtv m_renderTargetView = new RenderTargetView(m_device, m_backBuffer); //back buffer srv m_srvBackBuffer = new ShaderResourceView(m_device, m_backBuffer); //dsv m_depthBuffer = new Texture2D(m_device, new Texture2DDescription() { Format = Format.D32_Float_S8X24_UInt, ArraySize = 1, MipLevels = 1, Width = m_backBuffer.Description.Width, Height = m_backBuffer.Description.Height, SampleDescription = new SampleDescription(1, 0), Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None }); m_depthcStencilView = new DepthStencilView(m_device, m_depthBuffer); m_viewport = new Viewport(0, 0, m_resizeWidth, m_resizeHeight); m_context.Rasterizer.SetViewport(m_viewport); m_context.OutputMerger.SetTargets(m_depthcStencilView, m_renderTargetView); EventPostResizeBuffer.Invoke(); }
protected void onPostResizeBuffer() { EventPostResizeBuffer.Invoke(); }