GPU.js Constructor Configuration Options Guide

This guide provides an overview of the configuration options available when instantiating the GPU.js library. By passing an options object to the GPU constructor (new GPU(options)), developers can fine-tune rendering contexts, select specific execution modes, and control platform-specific drivers for both browser and Node.js environments.

The Constructor Options Object

When creating a new instance via new GPU([options]), the constructor accepts an optional configuration object. The available properties are:

1. mode

2. canvas

3. context

4. webGL

5. webGL2

6. headlessGL

Example Usage

// Browser configuration using WebGL2 and a custom canvas
const myCanvas = document.getElementById('output-canvas');

const gpu = new GPU({
  mode: 'webgl2',
  canvas: myCanvas
});

// Node.js configuration using headless-gl
const gl = require('gl');

const serverGpu = new GPU({
  mode: 'headlessgl',
  headlessGL: gl
});