enableWebGL1
import { enableWebGL1 } from 'pixi-silk/webgl1';
function enableWebGL1(renderer: Renderer): boolean;
Lets SilkGraphics, SilkText and Glass render on a WebGL1 context. Pixi falls back to WebGL1 when the browser has no WebGL2. This installs GLSL ES 1.00 versions of the shaders, which live in this module so that apps that leave it out do not ship them.
Pass it to createSilkApp as webgl1: enableWebGL1, or call it with the renderer of an
application you create yourself. It does nothing unless the renderer runs WebGL1. Call it before
you create any SilkGraphics: objects created earlier keep the WebGL2 program and draw nothing.
The device needs OES_texture_float, OES_texture_half_float, OES_standard_derivatives and
highp in fragment shaders. Without one of them this logs an error, installs nothing and returns
false: silk objects then draw nothing, and the app can show a fallback. Without
OES_texture_half_float_linear the gradient ramps switch to nearest filtering, which the WebGL1
shaders blend themselves, so they look the same.
Limits on WebGL1: enableSilkBatching() has no effect, each object is one draw call. A filled
path with more than 4096 edges, or a stroked path with more than 256 windows, draws in part with
a warning. Programs are global: once enabled, objects on a WebGL2 renderer on the same page use
the WebGL1 shaders too and do not batch. They give the same pixels.
Parameters#
| Parameter | Type | Description |
|---|---|---|
renderer | Renderer | The renderer of the application. |
Returns#
boolean
true when WebGL1 support is on for this renderer. false when the renderer is not
WebGL1, or the device lacks something the shaders need (an error is logged).
Example#
import { createSilkApp, SilkGraphics } from 'pixi-silk';
import { enableWebGL1 } from 'pixi-silk/webgl1';
const silk = await createSilkApp({ parent: document.body, webgl1: enableWebGL1 });
silk.app.stage.addChild(new SilkGraphics().circle(50, 50, 40).fill(0x30d158));