Description
The WithDepthFormat
method of the TextureBuilder
class configures the texture to use the same depth format as the screen or framebuffer. This is useful when you want to ensure that the texture's depth format is compatible with the current rendering context, particularly when dealing with depth-based effects or operations.
Usage
To use the WithDepthFormat
method, you need to have an instance of TextureBuilder
. Call this method on the instance to set the depth format to match the screen's depth format. This method is chainable, allowing you to configure multiple properties of the texture in a fluent manner.
Example
// Example of using WithDepthFormat
TextureBuilder textureBuilder = new TextureBuilder();
textureBuilder.WithDepthFormat();
// Continue configuring the texture as needed
textureBuilder.WithSize(1024, 768)
.WithFormat(ImageFormat.RGBA8)
.WithStaticUsage();
// Create the texture
Texture texture = textureBuilder.Create("MyTexture", false, data, data.Length);