Skip to main content

Function: setRenderBackend()

setRenderBackend(backend, reason?): void

Sets the global render backend for GenericViewport-based viewports and live-switches all mounted viewports to the new backend in place: viewport ids, mounted data, cameras, presentation state and tool annotations are preserved; only the render paths are rebuilt. The switch is reversible in both directions at runtime.

Cornerstone never switches backends on its own. Applications listening to the degradation events (WEBGL_CONTEXT_LOST, RENDER_PATH_ERROR) are expected to call this, typically after prompting the user.

Emits RENDER_BACKEND_CHANGED on the eventTarget when the value changes.

Parameters

backend: RenderBackend

'auto' or any backend registered via registerRenderBackend() (built-ins: 'gpu' | 'cpu')

reason?: string

Optional human-readable reason carried on the change event (e.g. 'webgl-context-lost').

Returns

void

Defined in

packages/core/src/init.ts:246