mwg API
    Preparing search index...

    Function inspectGraphicsCapabilities

    • Reports browser graphics APIs without creating a renderer or selecting a fallback. Pass a probe in tests or host integrations; omitting it reads the current browser safely.

      wgsl cannot be checked synchronously - the only way to genuinely know a WGSL shader compiles is detectWebGpu, which requests a real device and compiles one, and every step of that is asynchronous. Rather than assume WGSL works just because navigator.gpu exists (a browser can expose WebGPU behind a still-broken or disabled implementation), this stays false unless a caller supplies a real result through probe.wgsl.

      Parameters

      Returns GraphicsCapabilities

      import { inspectGraphicsCapabilities } from '@datamoc/mw_games/two-d/render';

      // reads the real browser when no probe is given
      const here = inspectGraphicsCapabilities();

      // a fake probe, for a test or a host integration with no DOM
      const capabilities = inspectGraphicsCapabilities({
      createCanvas: () => ({ getContext: (kind) => (kind === 'webgl2' ? {} : null) }),
      webgpu: false,
      });
      console.log(capabilities.webgl2); // true
      console.log(capabilities.webgpu); // false