WEBGL_lose_context-Erweiterung

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

Die WEBGL_lose_context-Erweiterung ist Teil der WebGL API und bietet Funktionen, um das Verlieren und Wiederherstellen eines WebGLRenderingContext zu simulieren.

WebGL-Erweiterungen sind über die Methode WebGLRenderingContext.getExtension() verfügbar. Weitere Informationen finden Sie unter Verwendung von Erweiterungen im WebGL-Leitfaden.

Hinweis: Diese Erweiterung ist sowohl für WebGL1 als auch WebGL2 Kontexte verfügbar.

Instanzmethoden

WEBGL_lose_context.loseContext()

Simuliert das Verlieren des Kontextes.

WEBGL_lose_context.restoreContext()

Simuliert das Wiederherstellen des Kontextes.

Beispiele

Mit dieser Erweiterung können Sie die Ereignisse webglcontextlost und webglcontextrestored simulieren:

js
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");

canvas.addEventListener("webglcontextlost", (event) => {
  console.log(event);
});

gl.getExtension("WEBGL_lose_context").loseContext();

// WebGLContextEvent event with type "webglcontextlost" is logged.

Spezifikationen

Specification
WebGL WEBGL_lose_context Khronos Ratified Extension Specification

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
WEBGL_lose_context
loseContext
restoreContext

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Requires a vendor prefix or different name for use.
Has more compatibility info.

Siehe auch