ExternalRenderTarget class Rendering
A color target the caller owns, which a RenderView renders into through
Scene.renderViewsToTargets.
The scene never allocates, resizes, samples, or disposes color; it only
draws into it. That is the contract a platform runtime's swapchain image
needs (a WebXR layer, later an OpenXR swapchain), and it also fits a
texture an application allocated itself. A RenderView.viewport on a
view with this target selects the region of color the view fills, so
two eyes can share one image.
final target = ExternalRenderTarget.platform(
layer.framebuffer,
width: layer.framebufferWidth,
height: layer.framebufferHeight,
);
final views = [
RenderView(camera: leftEye, externalTarget: target,
viewport: const Rect.fromLTWH(0, 0, 0.5, 1)),
RenderView(camera: rightEye, externalTarget: target,
viewport: const Rect.fromLTWH(0.5, 0, 0.5, 1)),
];
final frame = scene.renderViewsToTargets([RenderViewGroup(views)]);
Constructors
- ExternalRenderTarget.allocate({required int width, required int height, Color? backgroundColor})
-
Allocates a color target of
widthbyheightpixels 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, socolor.asImage()draws it onto a canvas afterwards. - ExternalRenderTarget.platform(Object handle, {required int width, required int height, ExternalTargetHandleKind kind = gpu.ExternalTargetHandleKind.framebuffer, PixelFormat format = gpu.PixelFormat.r8g8b8a8UNormInt, Color? backgroundColor})
-
Wraps a platform object the active backend can draw into, through
wrapExternalColorTarget(see that function for what each backend accepts). Throws UnsupportedError where the backend cannot. - ExternalRenderTarget.surfaceFrame(GpuSurfaceFrame frame, {Color? backgroundColor})
-
Leases
frame, one image of a surface the platform presents (a swapchain image an engine or runtime lends out). - ExternalRenderTarget.texture(Texture color, {Color? backgroundColor})
-
Wraps
color, a texture the caller created with render-target usage.
Properties
- backgroundColor ↔ Color?
-
A color composited under the finished image, or null to keep the
scene's own alpha.
getter/setter pair
- color → Texture
-
The color texture views draw into.
final
- encodesSrgb → bool
-
Whether color encodes sRGB on write (an sRGB swapchain format). The
scene then writes linear color and lets the attachment encode it, so
the stored image matches what a plain target of the same scene holds.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
The target's height in pixels.
no setter
- isSpent → bool
-
Whether surfaceFrame was presented or discarded, after which the
target cannot be rendered into. Always false without a surface frame.
no setter
- presentStatus → GpuPresentStatus?
-
What presenting surfaceFrame reported, or null before the scene has
presented it, after a discard, and for a target without one.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- surfaceFrame → GpuSurfaceFrame?
-
The surface frame this target leases, or null for a target the caller
keeps.
final
- width → int
-
The target's width in pixels.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited