toTexture method
Implementation
gpu.Texture toTexture() {
if (embeddedImage == null || embeddedImage!.bytes == null) {
throw Exception('Texture has no embedded image');
}
gpu.Texture? texture = gpu.gpuContext.createTexture(
gpu.StorageMode.hostVisible,
embeddedImage!.width,
embeddedImage!.height);
if (texture == null) {
throw Exception('Failed to allocate texture');
}
Uint8List textureData = embeddedImage!.bytes! as Uint8List;
if (!texture.overwrite(ByteData.sublistView(textureData))) {
throw Exception('Failed to overwrite texture data');
}
return texture;
}