How to use the expo-gl.GLView.takeSnapshotAsync function in expo-gl

To help you get started, we’ve selected a few expo-gl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / apps / native-component-list / src / screens / GL / GLHeadlessRenderingScreen.tsx View on Github external
async draw() {
    if (this.isDrawing) {
      // if another draw call is already running, we need to skip this one
      return;
    }

    this.isDrawing = true;

    const gl = await glPromise;

    gl.uniform1f(contrastLocation, this.state.contrast);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    gl.endFrameEXP();

    // we need to use flip option because framebuffer contents are flipped vertically
    const snapshot = await GLView.takeSnapshotAsync(gl, {
      flip: true,
    });

    // delete previous snapshot
    if (this.state.snapshot) {
      FileSystem.deleteAsync(this.state.snapshot.uri as string, { idempotent: true });
    }

    this.setState({ snapshot });
    this.isDrawing = false;
  }

expo-gl

Provides GLView that acts as OpenGL ES render target and gives GL context object implementing WebGL 2.0 specification.

MIT
Latest version published 6 months ago

Package Health Score

89 / 100
Full package analysis