Skip to content

RenderSurfaceSource

RenderSurfaceSource = { handle: number; kind: "gl-context"; } | { canvasSelector?: string; kind: "webgpu"; readback?: boolean; } | { kind: "default"; }

Defined in: app/app.ts:1582

How the host provides the render surface the C++ renderer binds to — the single seam every platform’s renderer init flows through:

  • gl-context: an emscripten-registered WebGL2 context handle (web/desktop/WeChat).
  • webgpu: the host acquired a GPUDevice (navigator.gpu) and passed it as the module factory’s preinitializedWebGPUDevice before instantiation; the engine owns the swapchain, resolving the canvas via canvasSelector (default ‘#canvas’, via document.querySelector — so the canvas must be in the DOM).
  • default: the module resolves its own surface (module.initRenderer()).

Native (wasm-on-JSC, no DOM): the host injects the device AND an already-built CAMetalLayer/ANativeWindow surface, so { kind: 'webgpu' } omits canvasSelector and must not reach the ‘#canvas’ fallback.

{ handle: number; kind: "gl-context"; }


{ canvasSelector?: string; kind: "webgpu"; readback?: boolean; }

readonly optional canvasSelector?: string

readonly kind: "webgpu"

readonly optional readback?: boolean

Configure the swapchain so the engine can read its own frames back (captureFrame). Fixed at surface configuration, hence here.


{ kind: "default"; }