gpu library

Curated public GPU surface for the custom-shader (ShaderMaterial) workflow.

flutter_scene ships an internal flutter_gpu shim (a WebGL2 backend on web; a zero-cost re-export of package:flutter_gpu on native). Most of it is implementation detail. This library exposes only the handful of types a caller needs to author a custom material: load a compiled shader bundle and hand its fragment shader to a ShaderMaterial.

import 'package:flutter_scene/gpu.dart' as gpu;

final library = await gpu.loadShaderLibraryAsync(
  await gpu.resolveShaderBundleKey('my'),
);
final material = ShaderMaterial(fragmentShader: library!['MyFragment']!);

Properties

externalColorTargetsSupported → bool Rendering
Whether this backend can render into a color target it did not allocate (see wrapExternalColorTarget).
no setter
nativeGraphicsContext → Object? Rendering
The platform graphics context the backend draws with, for a runtime that has to bind it, or null where the backend keeps it private.
no setter

Functions

loadShaderLibraryAsync(String assetName) → Future<ShaderLibrary?>
resolveShaderBundleKey(String bundleName, {String? package, AssetBundle? bundle}) → Future<String> Assets and loading
Resolves the asset key of a shader bundle built by buildTargetShaderBundleJson (or flutter_gpu_shaders' buildShaderBundleJson), by its bundle name.
textureToPlatformImage(Texture texture) → Object? Rendering
A snapshot of texture as a platform image another graphics context can draw, or null where the backend has none.
wrapExternalColorTarget(Object handle, {required int width, required int height, ExternalTargetHandleKind kind = gpu.ExternalTargetHandleKind.framebuffer, PixelFormat format = gpu.PixelFormat.r8g8b8a8UNormInt}) → Texture Rendering
Wraps handle, a platform color target, as a texture a scene can render into through an ExternalRenderTarget.