From 186b025b4d75302324008b1fa4552093b782f848 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 26 Jan 2021 21:18:55 -0800 Subject: [PATCH] add depth buffer create shortcuts --- src/Graphics/Resources/RenderTarget.cs | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Graphics/Resources/RenderTarget.cs b/src/Graphics/Resources/RenderTarget.cs index 405a7c2..4e04470 100644 --- a/src/Graphics/Resources/RenderTarget.cs +++ b/src/Graphics/Resources/RenderTarget.cs @@ -36,6 +36,42 @@ namespace MoonWorks.Graphics return new RenderTarget(device, new TextureSlice(texture), sampleCount); } + public static RenderTarget CreateDepthBuffer( + GraphicsDevice device, + uint width, + uint height + ) { + var flags = TextureUsageFlags.DepthStencilTarget; + + var texture = Texture.CreateTexture2D( + device, + width, + height, + TextureFormat.D32, + flags + ); + + return new RenderTarget(device, new TextureSlice(texture)); + } + + public static RenderTarget CreateDepthStencilBuffer( + GraphicsDevice device, + uint width, + uint height + ) { + var flags = TextureUsageFlags.DepthStencilTarget; + + var texture = Texture.CreateTexture2D( + device, + width, + height, + TextureFormat.D32S8, + flags + ); + + return new RenderTarget(device, new TextureSlice(texture)); + } + public RenderTarget(GraphicsDevice device, in TextureSlice textureSlice, SampleCount sampleCount = SampleCount.One) : base(device) { Handle = Refresh.Refresh_CreateRenderTarget(