ExternalRenderTarget.surfaceFrame constructor

ExternalRenderTarget.surfaceFrame(
  1. GpuSurfaceFrame frame, {
  2. Color? backgroundColor,
})

Leases frame, one image of a surface the platform presents (a swapchain image an engine or runtime lends out).

The scene ends the lease. A frame that renders presents frame on its last GPU submission, and a frame that is skipped or throws discards it, so the surface always gets its image back. The target is then spent, so build a new one around the next frame the surface vends.

final frame = surface.acquireNextFrame();
if (frame == null) return;
final target = ExternalRenderTarget.surfaceFrame(frame);
scene.renderViewsToTargets([
  RenderViewGroup([RenderView(camera: eye, externalTarget: target)]),
]);

Implementation

ExternalRenderTarget.surfaceFrame(
  gpu.GpuSurfaceFrame frame, {
  this.backgroundColor,
}) : surfaceFrame = frame,
     color = frame.colorTexture;