Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLCanvasElement
  4. webglcontextlost

HTMLCanvasElement: webglcontextlost event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

Thewebglcontextlost event of theWebGL API is fired if the user agent detects that the drawing buffer associated with aWebGLRenderingContext object has been lost.

This event does not bubble.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("webglcontextlost", (event) => { })onwebglcontextlost = (event) => { }

Event type

AWebGLContextEvent. Inherits fromEvent.

Event WebGLContextEvent

Event properties

This interface inherits properties from its parent interface,Event.

WebGLContextEvent.statusMessage

A read-only property containing additional information about the event.

Example

With the help of theWEBGL_lose_context extension, you can simulate thewebglcontextlost event:

js
const canvas = document.getElementById("canvas");const gl = canvas.getContext("webgl");canvas.addEventListener("webglcontextlost", (event) => {  console.log(event);});gl.getExtension("WEBGL_lose_context").loseContext();// "webglcontextlost" event is logged.

Specifications

Specification
WebGL Specification
# 5.15.2

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp