flutter3d_webgl library
WebGL2 as an implementation of flutter3d_hardware.
The second backend. Its value is not only that it runs on the web: it is the first thing that can tell us whether the HAL is a seam or a description of Impeller, because a fake backend can only confirm that an interface is callable, never that it is implementable.
Status: it draws the engine's scenes. The engine names its stages —
LightingModel.shaderName and the renderer's require calls — and every
backend must ship a set answering to those names. This one's are generated:
tool/generate_shaders.dart translates flutter3d_shaders into GLSL ES
3.00 and writes engine_shaders.dart, which tool/ci.sh regenerates and
diffs, because a table nobody diffed once held a sky from before the sky
was rewritten.
What it draws is measured rather than asserted. Every golden scene is
recorded here as well, and test/cross_backend_test.dart holds each one to
its own measured distance from the picture Impeller recorded — a budget per
scene rather than one tolerance over all of them, because a tolerance wide
enough for the worst scene stops watching the rest.
This paragraph said the opposite for as long as the shaders took to write, which is the trap a status line sets: it is the first thing a reader of the package sees, on pub.flutter-io.cn and in the IDE, and nothing fails when it goes out of date.
Classes
- ShaderSources
- GLSL ES 3.00 sources, by the engine's entry point name.
- WebGlAttribute
- WebGlBlock
- WebGlDevice
-
WebGL2 as a
GraphicsDevice. - WebGlEncoder
- One pass, recorded straight into the context. See the library note above.
- WebGlFramePresenter
- Blits frame onto device's canvas and shows it, styled by fit and quality through CSS on the element rather than through Flutter, since Flutter does not composite these pixels.
- WebGlLoadedShaderLibrary
-
A
LoadedShaderLibraryover sources a bundle carried. - WebGlProgram
- A linked program plus what reflection told us about it.
- WebGlShader
-
What a
ShaderHandlecarries here: a compiled stage and which kind it is. - WebGlShaderLibrary
-
A
ShaderLibraryover sources compiled on first use. - WebGlTexture
-
What a
TextureHandlecarries on this backend.
Functions
-
compileWebGlShader(
WebGL2RenderingContext gl, String name, String source, {required bool isVertex}) → WebGLShader - Compiles one stage, or throws naming it and quoting the driver's log.
-
declarationsOf(
String source) → ({Set< String> blocks, Set<String> samplers}) - The uniform block type names and sampler names a GLSL ES source declares.
-
decodeWebGlSection(
ByteData bytes) → WebGlSectionSources -
The sources in
bytes. -
encodeWebGlSection(
{required Map< String, String> vertex, required Map<String, String> fragment}) → ByteData -
The section bytes for
vertexandfragmentsources. -
ensureWebGlBackendRegistered(
) → void - Registers WebGlDevice as the web fallback opener and a frame presenter, once.
-
fragmentOutputNames(
String source) → Set< String> -
The names of the outputs a GLSL ES fragment
sourcedeclares. -
openWebGl(
{required int width, required int height}) → Future< GraphicsDevice> - Opens this backend with the engine's own shaders, or throws with something worth putting on screen.
Typedefs
- WebGlSampler = ({bool cube, int unit})
- A sampler of a linked program: the texture unit it owns, and whether it samples a cube, which is the target a draw clears it on when it was left unbound.
-
WebGlSectionSources
= ({Map<
String, String> fragment, Map<String, String> vertex}) - What the section decodes to.