flutter3d
Showcase Changelog 38 packages API reference

Impeller

since 0.1.0 Backends

On macOS, Windows, Linux, Android and iOS this engine draws through flutter_gpu, Flutter's own rendering layer, itself built on Impeller. This page does not force that backend open. It reads the device that actually did open, and asks it what it can do, the same way every ordinary page does.

Step 1: How the choice is made #

Nothing in flutter3d_app picks Impeller by name. It registers every native backend it has and asks a shared registry to open one, trying them in order until one starts.

// `flutter3d_app`'s native `openDevice` never names a backend. It asks
// `flutter3d_hardware`'s registry to open one, having first made sure
// Impeller and the software rasteriser have both registered themselves:
//
//     ensureGpuBackendRegistered();
//     ensureCpuBackendRegistered();
//     return openRegisteredDevice(width: width, height: height, ...);
//
// Impeller is tried first; the software device is what a native build
// falls back to if flutter_gpu will not start.

Note. A build never names the backend that opened. Two backends registered the same way means the fallback needs no change the day a third one exists.

Step 2: Ask what differs, not what it is called #

GraphicsDevice.supportsWireframe is the one capability that answers differently on all three backends here: true on Impeller's Metal and Vulkan path, false on its own OpenGL ES path, false on WebGL2 and false on the software rasteriser. Asking it, rather than checking a name, is what keeps a page correct the day a backend's answer changes.

String _report(GraphicsDevice device) =>
    'wireframe: ${device.supportsWireframe}\n'
    'blend constant: ${device.supportsBlendColor}\n'
    'max colour attachments: ${device.maxColorAttachments}\n'
    'max anisotropy: ${device.maxAnisotropy}';

Step 3: A setting that asks for it anyway #

This page asks for wireframe unconditionally. Whatever the device answers, the frame has to agree with it: declined when the device cannot draw it, given when it can.

@override
RenderSettings settings(DemoContext context) =>
    const RenderSettings(wireframe: true);

The panel above shows what the device actually open right now says about itself, not a description of Impeller in the abstract.