add depth buffer create shortcuts

pull/14/head
cosmonaut 2021-01-26 21:18:55 -08:00
parent d10f018f14
commit 186b025b4d
1 changed files with 36 additions and 0 deletions

View File

@ -36,6 +36,42 @@ namespace MoonWorks.Graphics
return new RenderTarget(device, new TextureSlice(texture), sampleCount); 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) public RenderTarget(GraphicsDevice device, in TextureSlice textureSlice, SampleCount sampleCount = SampleCount.One) : base(device)
{ {
Handle = Refresh.Refresh_CreateRenderTarget( Handle = Refresh.Refresh_CreateRenderTarget(