ExternalRenderTarget.allocate constructor

ExternalRenderTarget.allocate({
  1. required int width,
  2. required int height,
  3. Color? backgroundColor,
})

Allocates a color target of width by height pixels this package's backend owns, for a caller that has nowhere else to render (an emulated XR layer without a framebuffer, a capture). It is shader-readable, so color.asImage() draws it onto a canvas afterwards.

Implementation

ExternalRenderTarget.allocate({
  required int width,
  required int height,
  this.backgroundColor,
}) : surfaceFrame = null,
     color = gpu.gpuContext.createTexture(
       gpu.StorageMode.devicePrivate,
       width,
       height,
       enableRenderTargetUsage: true,
       enableShaderReadUsage: true,
     );