Texture constructor

Texture(
  1. ByteData sourceData, {
  2. required int width,
  3. required int height,
  4. PixelFormat format = PixelFormat.rgba8888,
})

Base texture Resource, represents an image/texture on the GPU.

Implementation

Texture(
  ByteData sourceData, {
  required int width,
  required int height,
  PixelFormat format = PixelFormat.rgba8888,
}) : super(
        gpu.gpuContext.createTexture(
          gpu.StorageMode.hostVisible,
          width,
          height,
          format: switch (format) {
            PixelFormat.rgba8888 => gpu.PixelFormat.r8g8b8a8UNormInt,
            PixelFormat.bgra8888 => gpu.PixelFormat.b8g8r8a8UNormInt,
            PixelFormat.rgbaFloat32 => gpu.PixelFormat.r32g32b32a32Float,
          },
        )!
          ..overwrite(sourceData),
      );