/// <summary> /// Handles the BeforeSwapChainResized event of the Swap control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="BeforeSwapChainResizedEventArgs"/> instance containing the event data.</param> private static void Swap_BeforeSwapChainResized(object sender, BeforeSwapChainResizedEventArgs e) { // Before we go about resizing the render target, we need to ensure the depth stencil is removed so that we don't end up with a depth/stencil still // attached that's not matched to the size of the render target. _graphics.SetDepthStencil(null); _depthStencil?.Dispose(); }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GorgonApplication.Run(Initialize(), Idle); } catch (Exception ex) { GorgonExample.HandleException(ex); } finally { GorgonExample.UnloadResources(); foreach (GorgonTexture2D texture in _textures) { texture?.Dispose(); } _renderer?.Dispose(); _depthBuffer?.Dispose(); _screen?.Dispose(); _graphics?.Dispose(); _assemblyCache?.Dispose(); } }
/// <summary> /// Function to build or rebuild the depth buffer. /// </summary> /// <param name="width">The width of the depth buffer.</param> /// <param name="height">The height of the depth buffer.</param> private static void BuildDepthBuffer(int width, int height) { _graphics.SetDepthStencil(null); _depthBuffer?.Dispose(); _depthBuffer = GorgonDepthStencil2DView.CreateDepthStencil(_graphics, new GorgonTexture2DInfo("Depth Buffer") { Usage = ResourceUsage.Default, Width = width, Height = height, Format = _depthFormat }); }
/// <summary> /// Function to build or rebuild the depth buffer. /// </summary> /// <param name="width">The width of the depth buffer.</param> /// <param name="height">The height of the depth buffer.</param> private static void BuildDepthBuffer(int width, int height) { _depthBuffer?.Dispose(); _depthBuffer = GorgonDepthStencil2DView.CreateDepthStencil(_graphics, new GorgonTexture2DInfo { Usage = ResourceUsage.Default, Width = width, Height = height, Format = BufferFormat.D24_UNorm_S8_UInt, Binding = TextureBinding.DepthStencil }); }