TextureBuilder WithStaticUsage()

book_4_sparkGenerated
code_blocksInput

Description

The WithStaticUsage method of the TextureBuilder class provides a hint to the GPU that the texture being built will not be modified after its creation. This can optimize the performance by allowing the GPU to handle the texture more efficiently, as it can assume the texture data will remain constant.

Usage

Use the WithStaticUsage method when you are certain that the texture will not change after it is created. This is particularly useful for textures that are loaded once and used repeatedly without any modifications, such as static background images or UI elements.

Example

// Example of using WithStaticUsage in a TextureBuilder
TextureBuilder builder = new TextureBuilder();
builder.WithSize(256, 256)
       .WithFormat(ImageFormat.RGBA8)
       .WithStaticUsage();

Texture texture = builder.Create("MyStaticTexture", false, data, data.Length);