createTexture method
- StorageMode storageMode,
- int width,
- int height, {
- PixelFormat format = PixelFormat.r8g8b8a8UNormInt,
- dynamic sampleCount = 1,
- TextureCoordinateSystem coordinateSystem = TextureCoordinateSystem.renderToTexture,
- TextureType? textureType,
- bool enableRenderTargetUsage = true,
- bool enableShaderReadUsage = true,
- bool enableShaderWriteUsage = false,
Allocates a new texture in GPU-resident memory.
Throws an exception if the Texture creation failed.
Implementation
Texture createTexture(
StorageMode storageMode,
int width,
int height, {
PixelFormat format = PixelFormat.r8g8b8a8UNormInt,
sampleCount = 1,
TextureCoordinateSystem coordinateSystem =
TextureCoordinateSystem.renderToTexture,
/// The type of texture to create.
///
/// If not specified, this will be inferred from the `sampleCount`.
TextureType? textureType,
bool enableRenderTargetUsage = true,
bool enableShaderReadUsage = true,
bool enableShaderWriteUsage = false,
}) {
final resolvedTextureType =
textureType ??
((sampleCount == 1)
? TextureType.texture2D
: TextureType.texture2DMultisample);
Texture result = Texture._initialize(
this,
storageMode,
format,
width,
height,
sampleCount,
coordinateSystem,
resolvedTextureType,
enableRenderTargetUsage,
enableShaderReadUsage,
enableShaderWriteUsage,
);
if (!result.isValid) {
throw Exception('Texture creation failed');
}
return result;
}